Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QianQiXiang
haoban-manage3.0
Commits
d80029a5
Commit
d80029a5
authored
Jul 09, 2020
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lock
parent
087e3ec2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
135 additions
and
13 deletions
+135
-13
TestService.java
...va/com/gic/haoban/manage/service/service/TestService.java
+3
-0
TestApiServiceImpl.java
...aoban/manage/service/service/impl/TestApiServiceImpl.java
+16
-1
TestMapper.xml
...-manage3-service/src/main/resources/mapper/TestMapper.xml
+4
-1
DealSyncTest.java
haoban-manage3-service/src/test/java/DealSyncTest.java
+100
-11
TestController.java
.../com/gic/haoban/manage/web/controller/TestController.java
+12
-0
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/TestService.java
View file @
d80029a5
package
com
.
gic
.
haoban
.
manage
.
service
.
service
;
package
com
.
gic
.
haoban
.
manage
.
service
.
service
;
import
com.gic.haoban.manage.service.entity.Test
;
/**
/**
* Created by tgs on 2020/2/9.
* Created by tgs on 2020/2/9.
*/
*/
public
interface
TestService
{
public
interface
TestService
{
public
void
save
(
Test
test
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/TestApiServiceImpl.java
View file @
d80029a5
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
impl
;
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
impl
;
import
com.gic.haoban.manage.service.dao.mapper.TestMapper
;
import
com.gic.haoban.manage.service.entity.Test
;
import
com.gic.haoban.manage.service.service.TestService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
/**
* Created by tgs on 2020/2/9.
* Created by tgs on 2020/2/9.
*/
*/
public
class
TestApiServiceImpl
{
@Service
public
class
TestApiServiceImpl
implements
TestService
{
@Autowired
private
TestMapper
testMapper
;
@Override
public
void
save
(
Test
test
)
{
testMapper
.
insert
(
test
);
}
}
}
haoban-manage3-service/src/main/resources/mapper/TestMapper.xml
View file @
d80029a5
...
@@ -8,7 +8,10 @@
...
@@ -8,7 +8,10 @@
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id, name
id, name
</sql>
</sql>
<insert
id=
"insert"
parameterType=
"com.gic.haoban.manage.service.entity.Test"
>
insert into test (id,name)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR})
</insert>
<select
id=
"queryList"
parameterType=
"java.lang.String"
resultMap=
"BaseResultMap"
>
<select
id=
"queryList"
parameterType=
"java.lang.String"
resultMap=
"BaseResultMap"
>
select
select
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
...
...
haoban-manage3-service/src/test/java/DealSyncTest.java
View file @
d80029a5
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.
api.base.commons.JSONResponse
;
import
com.gic.
haoban.manage.api.dto.StaffDTO
;
import
com.gic.haoban.manage.api.dto.SyncSingleDealDTO
;
import
com.gic.haoban.manage.api.dto.SyncSingleDealDTO
;
import
com.gic.haoban.manage.api.service.DealSyncOperationApiService
;
import
com.gic.haoban.manage.api.service.DealSyncOperationApiService
;
import
com.gic.haoban.manage.api.service.DepartmentApiService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService
;
import
com.gic.haoban.manage.service.service.StaffService
;
import
com.gic.haoban.manage.service.service.StaffService
;
import
com.gic.wechat.api.dto.qywx.DepartmentDTO
;
import
com.gic.haoban.manage.service.service.TestService
;
import
com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.dto.qywx.UserDTO
;
import
com.gic.wechat.api.dto.qywx.QywxExternalcontactDTO
;
import
com.gic.wechat.api.service.qywx.QywxDepartmentApiService
;
import
com.gic.wechat.api.service.qywx.QywxSuiteApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
locations
=
{
"classpath:applicationContext-conf.xml"
})
@ContextConfiguration
(
locations
=
{
"classpath:applicationContext-conf.xml"
})
public
class
DealSyncTest
{
public
class
DealSyncTest
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DealSyncTest
.
class
);
@Autowired
@Autowired
private
DealSyncOperationApiService
dealSyncOperationApiService
;
private
DealSyncOperationApiService
dealSyncOperationApiService
;
@Autowired
@Autowired
private
StaffApiService
staffApiService
;
private
StaffApiService
staffApiService
;
@Autowired
private
StaffService
staffService
;
@Autowired
private
QywxUserApiService
qywxUserApiService
;
@Autowired
private
TestService
testService
;
@Test
@Test
public
void
test
()
{
public
void
test
()
{
List
<
SyncSingleDealDTO
>
add
=
new
ArrayList
<>();
List
<
SyncSingleDealDTO
>
add
=
new
ArrayList
<>();
...
@@ -64,11 +74,90 @@ public class DealSyncTest {
...
@@ -64,11 +74,90 @@ public class DealSyncTest {
@Test
@Test
public
void
test2
()
{
public
void
test2
()
{
dealSyncOperationApiService
.
cleanDiffrence
(
"ca66a01b79474c40b3e7c7f93daf1a3b"
,
"73387b7d355c416f93242f3d71a487a8"
);
int
i
=
1
;
while
(
true
)
{
i
++;
if
(
i
==
5
){
System
.
out
.
println
(
"close"
);
RedisUtil
.
close
();
}
if
(
i
==
10
||
i
==
25
){
System
.
out
.
println
(
"creConnect"
);
RedisUtil
.
reConnect
();
}
try
{
RedisUtil
.
setCache
(
"1"
,
"2"
);
Object
cache
=
RedisUtil
.
getCache
(
"1"
);
System
.
out
.
println
(
"======={}"
+
i
+
":"
+
cache
);
Thread
.
sleep
(
2000
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
@Test
@Test
public
void
test3
()
{
public
void
test3
()
{
staffApiService
.
getWxSaveNew
(
"3e7a7c09097a40b18aef1478b04688fe"
,
"ca66a01b79474c40b3e7c7f93daf1a3b"
);
staffApiService
.
getWxSaveNew
(
"3e7a7c09097a40b18aef1478b04688fe"
,
"ca66a01b79474c40b3e7c7f93daf1a3b"
);
}
}
@Test
public
void
test5
()
{
String
key
=
"test2"
;
RedisUtil
.
lock
(
key
,
100L
,
TimeUnit
.
SECONDS
,
0L
);
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// if(RedisUtil.isLocked(key)){
// RedisUtil.unlock(key);
// }
}
@Test
public
void
test6
()
{
String
key
=
"test2"
;
RedisUtil
.
lock
(
key
,
100L
,
TimeUnit
.
SECONDS
,
0L
);
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
if
(
RedisUtil
.
isLocked
(
key
)){
RedisUtil
.
unlock
(
key
);
}
}
@Test
public
void
test4
()
{
List
<
StaffDTO
>
retList
=
staffService
.
listByUserIdsAndWxEnterpriseId
(
null
,
"ca66a01b79474c40b3e7c7f93daf1a3b"
);
System
.
out
.
println
(
retList
.
size
());
if
(
CollectionUtils
.
isEmpty
(
retList
))
{
return
;
}
List
<
StaffDTO
>
staffDTOS
=
retList
.
subList
(
2
,
retList
.
size
()-
1
);
staffDTOS
.
forEach
(
staffDTO
->
{
if
(
StringUtils
.
isNotBlank
(
staffDTO
.
getWxUserId
()))
{
logger
.
info
(
staffDTO
.
getWxUserId
());
QywxExternalcontactDTO
send
=
new
QywxExternalcontactDTO
();
send
.
setType
(
1
);
send
.
setScene
(
1
);
send
.
setRemark
(
"tesst_"
+
staffDTO
.
getPhoneNumber
());
List
<
String
>
userIds
=
new
ArrayList
<>();
userIds
.
add
(
staffDTO
.
getWxUserId
());
send
.
setUser
(
userIds
);
String
configId
=
qywxUserApiService
.
getExternalcontactByUserId
(
"ww9ede832a84b7ae5f"
,
"65zze159pYb4ofbFsIREZ5X7d7iaZ-bWsVIQk2y5kTU"
,
send
);
if
(
StringUtils
.
isNotBlank
(
configId
))
{
logger
.
info
(
"staff:{}"
,
configId
,
JSONObject
.
toJSONString
(
staffDTO
));
com
.
gic
.
haoban
.
manage
.
service
.
entity
.
Test
test
=
new
com
.
gic
.
haoban
.
manage
.
service
.
entity
.
Test
();
test
.
setId
(
configId
);
test
.
setName
(
staffDTO
.
getWxUserId
());
testService
.
save
(
test
);
}
}
});
}
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/TestController.java
View file @
d80029a5
...
@@ -114,4 +114,16 @@ public class TestController extends WebBaseController {
...
@@ -114,4 +114,16 @@ public class TestController extends WebBaseController {
RedisUtil
.
delCache
(
key
);
RedisUtil
.
delCache
(
key
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
@RequestMapping
(
"/lock"
)
public
HaobanResponse
lock
(
String
name
,
Long
time
,
int
ty
)
{
RedisUtil
.
lock
(
name
,
time
,
TimeUnit
.
SECONDS
,
0L
);
if
(
ty
==
0
)
{
if
(
RedisUtil
.
isLocked
(
name
)){
RedisUtil
.
unlock
(
name
);
}
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment