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
d3cadc5a
Commit
d3cadc5a
authored
Apr 16, 2020
by
fudahua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步通讯录 微信同步gic
parent
0e0d1655
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
249 additions
and
24 deletions
+249
-24
DealSyncOperationApiService.java
...aoban/manage/api/service/DealSyncOperationApiService.java
+6
-0
PreDealLogMapper.java
...ic/haoban/manage/service/dao/mapper/PreDealLogMapper.java
+5
-0
TabHaobanPreDealLog.java
...gic/haoban/manage/service/entity/TabHaobanPreDealLog.java
+10
-0
TabHaobanSyncTask.java
...m/gic/haoban/manage/service/entity/TabHaobanSyncTask.java
+10
-0
DepartmentServiceImpl.java
...an/manage/service/service/impl/DepartmentServiceImpl.java
+1
-1
PreDealServiceImpl.java
...aoban/manage/service/service/impl/PreDealServiceImpl.java
+1
-3
DealSyncOperationApiServiceImpl.java
...ice/service/out/impl/DealSyncOperationApiServiceImpl.java
+50
-6
QywxClerkSyncOperation.java
...ic/haoban/manage/service/task/QywxClerkSyncOperation.java
+135
-0
QywxGroupSyncOperation.java
...ic/haoban/manage/service/task/QywxGroupSyncOperation.java
+0
-0
PreDealLogMapper.xml
...e3-service/src/main/resources/mapper/PreDealLogMapper.xml
+30
-13
DealSyncTest.java
haoban-manage3-service/src/test/java/DealSyncTest.java
+1
-1
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/DealSyncOperationApiService.java
View file @
d3cadc5a
...
...
@@ -96,4 +96,10 @@ public interface DealSyncOperationApiService {
public
Page
<
PreDealLogInfoDTO
>
listSyncTaskDetail
(
String
wxEnterpriseId
,
String
taskId
,
BasePageInfo
pageInfo
);
/**
* 处理同步
*/
public
void
dealQywxDepartment
(
String
taskId
,
String
wxEnterpriseId
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/PreDealLogMapper.java
View file @
d3cadc5a
...
...
@@ -21,6 +21,11 @@ public interface PreDealLogMapper {
*/
int
insertSelective
(
TabHaobanPreDealLog
record
);
/**
*/
int
insertSelectiveBatch
(
List
<
TabHaobanPreDealLog
>
record
);
/**
*/
TabHaobanPreDealLog
selectByPrimaryKey
(
Integer
id
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/entity/TabHaobanPreDealLog.java
View file @
d3cadc5a
...
...
@@ -59,6 +59,16 @@ public class TabHaobanPreDealLog implements Serializable {
*/
private
Date
updateTime
;
private
String
dataContent
;
public
String
getDataContent
()
{
return
dataContent
;
}
public
void
setDataContent
(
String
dataContent
)
{
this
.
dataContent
=
dataContent
;
}
/**
*/
private
static
final
long
serialVersionUID
=
1L
;
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/entity/TabHaobanSyncTask.java
View file @
d3cadc5a
...
...
@@ -37,6 +37,8 @@ public class TabHaobanSyncTask implements Serializable {
*/
private
Integer
statusFlag
;
private
Integer
taskType
;
/**
*
*/
...
...
@@ -51,6 +53,14 @@ public class TabHaobanSyncTask implements Serializable {
*/
private
static
final
long
serialVersionUID
=
1L
;
public
Integer
getTaskType
()
{
return
taskType
;
}
public
void
setTaskType
(
Integer
taskType
)
{
this
.
taskType
=
taskType
;
}
public
String
getWxEnterpriseId
()
{
return
wxEnterpriseId
;
}
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/DepartmentServiceImpl.java
View file @
d3cadc5a
...
...
@@ -52,7 +52,7 @@ public class DepartmentServiceImpl implements DepartmentService {
if
(
null
==
pDepartment
)
{
throw
new
RuntimeException
(
"父部门不存在"
);
}
tab
.
setChainId
(
pDepartment
.
getChainId
()
+
Constant
.
ID_SEPARATOR
+
tab
.
getDepartmentId
());
tab
.
setChainId
(
pDepartment
.
getChainId
()
+
Constant
.
ID_SEPARATOR
+
pDepartment
.
getDepartmentId
());
tab
.
setChainName
(
pDepartment
.
getChainName
()
+
Constant
.
NAME_SEPARATOR
+
tab
.
getDepartmentName
());
tab
.
setLevel
(
pDepartment
.
getLevel
()
+
1
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/PreDealServiceImpl.java
View file @
d3cadc5a
...
...
@@ -34,9 +34,7 @@ public class PreDealServiceImpl implements PreDealService {
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
true
;
}
for
(
TabHaobanPreDealLog
tab
:
list
)
{
preDealLogMapper
.
insert
(
tab
);
}
preDealLogMapper
.
insertSelectiveBatch
(
list
);
return
true
;
}
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/DealSyncOperationApiServiceImpl.java
View file @
d3cadc5a
...
...
@@ -21,17 +21,16 @@ import com.gic.haoban.manage.api.enums.PreDealTypeEnum;
import
com.gic.haoban.manage.api.enums.SyncTaskStatusEnum
;
import
com.gic.haoban.manage.api.service.DealSyncOperationApiService
;
import
com.gic.haoban.manage.api.service.DepartmentApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseApiService
;
import
com.gic.haoban.manage.service.entity.TabHaobanDepartment
;
import
com.gic.haoban.manage.service.entity.TabHaobanPreDealLog
;
import
com.gic.haoban.manage.service.entity.TabHaobanStaff
;
import
com.gic.haoban.manage.service.entity.TabHaobanSyncTask
;
import
com.gic.haoban.manage.service.service.DepartmentService
;
import
com.gic.haoban.manage.service.service.PreDealService
;
import
com.gic.haoban.manage.service.service.StaffService
;
import
com.gic.haoban.manage.service.service.SyncTaskService
;
import
com.gic.haoban.manage.service.service.*
;
import
com.gic.haoban.manage.service.task.BaseSyncOperation
;
import
com.gic.mq.sdk.GicMQClient
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.service.qywx.QywxDepartmentApiService
;
import
com.task.allocation.api.AbstractTaskAllocationNewOperation
;
import
com.task.allocation.exception.TaskAllocationException
;
import
com.task.allocation.qo.TaskAllocationComputed
;
...
...
@@ -42,6 +41,7 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -85,6 +85,12 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
@Autowired
private
ClerkService
clerkService
;
@Autowired
private
QywxDepartmentApiService
qywxDepartmentApiService
;
@Autowired
private
WxEnterpriseService
wxEnterpriseService
;
private
static
final
String
LOCK_KEY
=
"sync_wx_lock_"
;
private
static
final
String
LOCK_SUCCESS_KEY
=
"sync_wx_success_lock_"
;
...
...
@@ -100,9 +106,14 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
logger
.
info
(
"待处理数据不存在:{}"
,
params
);
return
;
}
TabHaobanSyncTask
syncTask
=
syncTaskService
.
getSyncTask
(
dealParamMqDTO
.
getTaskId
());
//部门处理
if
(
dataPre
.
getDataType
().
equals
(
PreDealTypeEnum
.
group
.
getVal
()))
{
operationMap
.
get
(
"groupSyncOperation"
).
dealSingleByMq
(
dealParamMqDTO
,
dataPre
);
if
(
syncTask
.
getTaskType
().
equals
(
0
))
{
operationMap
.
get
(
"groupSyncOperation"
).
dealSingleByMq
(
dealParamMqDTO
,
dataPre
);
}
else
{
operationMap
.
get
(
"qywxGroupSyncOperation"
).
dealSingleByMq
(
dealParamMqDTO
,
dataPre
);
}
//门店处理
}
else
if
(
dataPre
.
getDataType
().
equals
(
PreDealTypeEnum
.
store
.
getVal
()))
{
logger
.
info
(
"门店处理:{}"
,
params
);
...
...
@@ -111,7 +122,11 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
//成员处理
}
else
if
(
dataPre
.
getDataType
().
equals
(
PreDealTypeEnum
.
clerk
.
getVal
()))
{
logger
.
info
(
"店员处理:{}"
,
params
);
operationMap
.
get
(
"clerkSyncOperation"
).
dealSingleByMq
(
dealParamMqDTO
,
dataPre
);
if
(
syncTask
.
getTaskType
().
equals
(
0
))
{
operationMap
.
get
(
"clerkSyncOperation"
).
dealSingleByMq
(
dealParamMqDTO
,
dataPre
);
}
else
{
operationMap
.
get
(
"qywxClerkSyncOperation"
).
dealSingleByMq
(
dealParamMqDTO
,
dataPre
);
}
}
else
{
logger
.
info
(
"不是正常数据:{}"
,
params
);
}
...
...
@@ -450,4 +465,33 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
}
return
page
;
}
@Override
public
void
dealQywxDepartment
(
String
taskId
,
String
wxEnterpriseId
)
{
WxEnterpriseDTO
wxEnterpriseDTO
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
List
<
com
.
gic
.
wechat
.
api
.
dto
.
qywx
.
DepartmentDTO
>
list
=
qywxDepartmentApiService
.
listSelfDepartment
(
wxEnterpriseDTO
.
getCorpid
(),
wxEnterpriseDTO
.
getContactSecret
(),
1
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
logger
.
info
(
"没有数据同步"
);
return
;
}
List
<
TabHaobanPreDealLog
>
dealLogList
=
list
.
stream
().
map
(
dto
->
{
TabHaobanPreDealLog
dealLog
=
new
TabHaobanPreDealLog
();
dealLog
.
setDataId
(
dto
.
getId
().
toString
());
dealLog
.
setpDataId
(
dto
.
getParentid
().
toString
());
dealLog
.
setDataType
(
1
);
dealLog
.
setStatusFlag
(
0
);
dealLog
.
setTaskId
(
taskId
);
dealLog
.
setDataContent
(
JSONObject
.
toJSONString
(
dto
));
dealLog
.
setWxEnterpriseId
(
wxEnterpriseId
);
return
dealLog
;
}).
collect
(
Collectors
.
toList
());
preDealService
.
insert
(
dealLogList
);
HashSet
<
String
>
hashSet
=
new
HashSet
<>();
hashSet
.
add
(
"1"
);
dealDepartmentToMq
(
taskId
,
hashSet
,
SyncTaskStatusEnum
.
group_sync
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/QywxClerkSyncOperation.java
0 → 100644
View file @
d3cadc5a
package
com
.
gic
.
haoban
.
manage
.
service
.
task
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.clerk.api.dto.ClerkDTO
;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.enterprise.api.service.StoreGroupService
;
import
com.gic.enterprise.api.service.StoreService
;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.manage.api.dto.DealParamMqDTO
;
import
com.gic.haoban.manage.api.dto.GicClerkDTO
;
import
com.gic.haoban.manage.api.enums.PreDealStatusEnum
;
import
com.gic.haoban.manage.api.enums.PreDealTypeEnum
;
import
com.gic.haoban.manage.api.enums.SyncTaskStatusEnum
;
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.service.entity.TabHaobanPreDealLog
;
import
com.gic.haoban.manage.service.entity.TabHaobanSyncTask
;
import
com.gic.haoban.manage.service.service.DepartmentService
;
import
com.gic.haoban.manage.service.service.PreDealService
;
import
com.gic.haoban.manage.service.service.SyncTaskService
;
import
com.gic.redis.data.util.RedisUtil
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* Created 2020/4/13.
*
* @author hua
*/
@Service
public
class
QywxClerkSyncOperation
implements
BaseSyncOperation
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
QywxClerkSyncOperation
.
class
);
@Autowired
private
DepartmentService
departmentService
;
@Autowired
private
StoreGroupService
storeGroupService
;
@Autowired
private
PreDealService
preDealService
;
@Autowired
private
DepartmentApiService
departmentApiService
;
@Autowired
private
SyncTaskService
syncTaskService
;
@Autowired
private
StoreService
storeService
;
@Autowired
private
ClerkService
clerkService
;
@Autowired
private
StaffApiService
staffApiService
;
@Autowired
private
DealSyncOperationApiService
dealSyncOperationApiService
;
@Override
public
void
dealSingleByMq
(
DealParamMqDTO
dealParamMqDTO
,
TabHaobanPreDealLog
dataPre
)
{
logger
.
info
(
"微信成员处理:{}"
,
JSONObject
.
toJSONString
(
dealParamMqDTO
));
boolean
dealFlag
=
true
;
//处理clerk
try
{
staffApiService
.
wxGetAdd
(
dealParamMqDTO
.
getData
(),
dataPre
.
getWxEnterpriseId
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
info
(
"微信成员同步失败:"
,
JSONObject
.
toJSONString
(
dataPre
));
dealFlag
=
false
;
}
finally
{
if
(!
dealFlag
)
{
dealException
(
dealParamMqDTO
.
getTaskId
(),
dealParamMqDTO
.
getData
(),
dataPre
.
getEnterpriseId
(),
"成员处理异常"
);
}
else
{
dealSuccess
(
dealParamMqDTO
.
getTaskId
(),
dealParamMqDTO
.
getData
(),
dataPre
.
getEnterpriseId
(),
dataPre
.
getWxEnterpriseId
());
}
}
}
@Override
public
void
dealException
(
String
taskId
,
String
dataId
,
String
enterpriseId
,
String
reason
)
{
logger
.
info
(
"微信成员处理失败:t:{},d:{}"
,
taskId
,
dataId
);
boolean
b
=
preDealService
.
updateStatusByDataId
(
taskId
,
dataId
,
PreDealStatusEnum
.
exception
.
getVal
(),
reason
);
if
(!
b
)
{
logger
.
info
(
"微信成员处理异常:t:{}, d:{}"
,
taskId
,
dataId
);
return
;
}
checkDepartmentTask
(
taskId
);
}
@Override
public
void
dealSuccess
(
String
taskId
,
String
dataId
,
String
enterpriseId
,
String
wxEnterpriseId
)
{
logger
.
info
(
"微信成员处理成功:t:{},d:{}"
,
taskId
,
dataId
);
boolean
b
=
preDealService
.
updateStatusByDataId
(
taskId
,
dataId
,
PreDealStatusEnum
.
computed
.
getVal
(),
"成功"
);
if
(!
b
)
{
logger
.
info
(
"微信成功修改错误!{}"
,
dataId
);
return
;
}
checkDepartmentTask
(
taskId
);
}
@Override
public
void
checkDepartmentTask
(
String
taskId
)
{
boolean
b
=
preDealService
.
checkTask
(
taskId
,
PreDealTypeEnum
.
clerk
.
getVal
());
if
(!
b
)
{
return
;
}
logger
.
info
(
"微信同步成功:{}"
,
taskId
);
String
key
=
"haoban_sync_clerk_task_"
+
taskId
;
RedisUtil
.
lock
(
key
,
3L
);
TabHaobanSyncTask
syncTask
=
syncTaskService
.
getSyncTask
(
taskId
);
//同步成功 进入门店处理
if
(
syncTask
.
getStatusFlag
().
equals
(
SyncTaskStatusEnum
.
clerk_sync
.
getVal
()))
{
int
errCount
=
preDealService
.
countByTaskId
(
taskId
,
-
1
,
PreDealStatusEnum
.
exception
.
getVal
());
if
(
errCount
>
0
)
{
syncTaskService
.
updateTaskStatus
(
taskId
,
SyncTaskStatusEnum
.
exception_compute
.
getVal
());
}
else
{
syncTaskService
.
updateTaskStatus
(
taskId
,
SyncTaskStatusEnum
.
compute
.
getVal
());
dealSyncOperationApiService
.
unlockTask
(
syncTask
.
getWxEnterpriseId
());
}
}
RedisUtil
.
unlock
(
key
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/QywxGroupSyncOperation.java
0 → 100644
View file @
d3cadc5a
This diff is collapsed.
Click to expand it.
haoban-manage3-service/src/main/resources/mapper/PreDealLogMapper.xml
View file @
d3cadc5a
...
...
@@ -6,6 +6,7 @@
<result
column=
"wx_enterprise_id"
jdbcType=
"VARCHAR"
property=
"wxEnterpriseId"
/>
<result
column=
"enterprise_id"
jdbcType=
"VARCHAR"
property=
"enterpriseId"
/>
<result
column=
"data_id"
jdbcType=
"VARCHAR"
property=
"dataId"
/>
<result
column=
"data_content"
jdbcType=
"VARCHAR"
property=
"dataContent"
/>
<result
column=
"p_data_id"
jdbcType=
"VARCHAR"
property=
"pDataId"
/>
<result
column=
"task_id"
jdbcType=
"VARCHAR"
property=
"taskId"
/>
<result
column=
"data_type"
jdbcType=
"INTEGER"
property=
"dataType"
/>
...
...
@@ -28,11 +29,12 @@
where id = #{id,jdbcType=INTEGER}
</delete>
<insert
id=
"insert"
parameterType=
"com.gic.haoban.manage.service.entity.TabHaobanPreDealLog"
>
insert into tab_haoban_pre_deal_log ( wx_enterprise_id,enterprise_id, data_id
,
insert into tab_haoban_pre_deal_log ( wx_enterprise_id,enterprise_id, data_id,data_content
,
p_data_id, task_id, data_type,
status_flag, create_time, update_time
)
values (#{wxEnterpriseId,jdbcType=VARCHAR},#{enterpriseId,jdbcType=VARCHAR}, #{dataId,jdbcType=VARCHAR},
values (#{wxEnterpriseId,jdbcType=VARCHAR},#{enterpriseId,jdbcType=VARCHAR},
#{dataId,jdbcType=VARCHAR},#{dataContent}
#{pDataId,jdbcType=VARCHAR}, #{taskId,jdbcType=VARCHAR}, #{dataType,jdbcType=INTEGER},
#{statusFlag,jdbcType=INTEGER}, now(), now()
)
...
...
@@ -52,6 +54,9 @@
<if
test=
"dataId != null"
>
data_id,
</if>
<if
test=
"dataContent != null"
>
data_content,
</if>
<if
test=
"pDataId != null"
>
p_data_id,
</if>
...
...
@@ -64,12 +69,8 @@
<if
test=
"statusFlag != null"
>
status_flag,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
update_time
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
...
...
@@ -84,6 +85,9 @@
<if
test=
"dataId != null"
>
#{dataId,jdbcType=VARCHAR},
</if>
<if
test=
"dataContent != null"
>
#{dataContent},
</if>
<if
test=
"pDataId != null"
>
#{pDataId,jdbcType=VARCHAR},
</if>
...
...
@@ -96,14 +100,27 @@
<if
test=
"statusFlag != null"
>
#{statusFlag,jdbcType=INTEGER},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
now(),
now()
</trim>
</insert>
<insert
id=
"insertSelectiveBatch"
>
insert into tab_haoban_pre_deal_log ( wx_enterprise_id,enterprise_id, data_id,data_content,
p_data_id, task_id, data_type,
status_flag, create_time, update_time
)
values
<foreach
collection=
"list"
separator=
","
item=
"item"
index=
"index"
>
(#{item.wxEnterpriseId,jdbcType=VARCHAR},#{item.enterpriseId,jdbcType=VARCHAR},
#{item.dataId,jdbcType=VARCHAR},#{item.dataContent},
#{item.pDataId,jdbcType=VARCHAR}, #{item.taskId,jdbcType=VARCHAR}, #{item.dataType,jdbcType=INTEGER},
#{item.statusFlag,jdbcType=INTEGER}, now(), now()
)
</foreach>
</insert>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.gic.haoban.manage.service.entity.TabHaobanPreDealLog"
>
update tab_haoban_pre_deal_log
<set>
...
...
haoban-manage3-service/src/test/java/DealSyncTest.java
View file @
d3cadc5a
...
...
@@ -54,7 +54,7 @@ public class DealSyncTest {
dealDTO
.
setEnterpriseId
(
"ff8080815dacd3a2015dacd3ef5c0000"
);
add
.
add
(
dealDTO
);
}
dealSyncOperationApiService
.
deal
Department
(
"111"
,
"ca66a01b79474c40b3e7c7f93daf1a3b"
,
add
,
edit
);
dealSyncOperationApiService
.
deal
QywxDepartment
(
"111"
,
"ca66a01b79474c40b3e7c7f93daf1a3b"
);
}
...
...
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