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
haoban3.0
haoban-manage3.0
Commits
8a176f6f
Commit
8a176f6f
authored
Apr 16, 2020
by
fudahua
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/developer' into developer
parents
d3cadc5a
6c1a398b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
120 additions
and
41 deletions
+120
-41
DepartmentApiServiceImpl.java
...ge/service/service/out/impl/DepartmentApiServiceImpl.java
+52
-41
InfoController.java
.../com/gic/haoban/manage/web/controller/InfoController.java
+68
-0
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/DepartmentApiServiceImpl.java
View file @
8a176f6f
...
...
@@ -486,7 +486,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
@Override
public
void
initwxDepartment
(
String
corpid
,
String
contactSecret
,
String
wxEnterpriseId
)
{
// List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listDepartment(corpid, suiteid, null);
// logger.info("企业所有部门数据:{}", JSON.toJSONString(list)
);
logger
.
info
(
"【同步企业微信】wxEnterpriseId={}"
,
wxEnterpriseId
);
//
// com.gic.wechat.api.dto.qywx.DepartmentDTO rootDepartment = null;
// for (com.gic.wechat.api.dto.qywx.DepartmentDTO departmentDTO : list) {
...
...
@@ -506,15 +506,22 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
//
// DepartmentDTO parent = EntityUtil.changeEntityByJSON(DepartmentDTO.class,departmentService.selectById(parentId));
// this.addSon(subList, wxEnterpriseId, parent,corpid,suiteid);
RedisUtil
.
lock
(
"init_enterprise_"
+
wxEnterpriseId
,
60
*
60L
);
String
taskId
=
StringUtil
.
randomUUID
();
List
<
com
.
gic
.
wechat
.
api
.
dto
.
qywx
.
DepartmentDTO
>
list
=
this
.
qywxDepartmentApiService
.
listSelfDepartment
(
corpid
,
contactSecret
,
1
);
logger
.
info
(
"企业所有部门数据:{}"
,
JSON
.
toJSONString
(
list
));
// if(CollectionUtils.isNotEmpty(list)){
// this.addAllDepartment(list, 0, wxEnterpriseId, corpid, contactSecret,taskId);
// }
// insertMQ(0,wxEnterpriseId, corpid,contactSecret,taskId);
RedisUtil
.
unlock
(
"init_enterprise_"
+
wxEnterpriseId
);
logger
.
info
(
"【同步企业微信】wxEnterpriseId={}"
,
"init-enterprise-"
+
wxEnterpriseId
);
String
key
=
"init-enterprise-"
+
wxEnterpriseId
;
if
(
RedisUtil
.
getCache
(
key
)
==
null
){
RedisUtil
.
setCache
(
key
,
1
,
60
*
60L
);
String
taskId
=
StringUtil
.
randomUUID
();
List
<
com
.
gic
.
wechat
.
api
.
dto
.
qywx
.
DepartmentDTO
>
list
=
this
.
qywxDepartmentApiService
.
listSelfDepartment
(
corpid
,
contactSecret
,
null
);
logger
.
info
(
"企业所有部门数据:{}"
,
JSON
.
toJSONString
(
list
));
if
(
CollectionUtils
.
isNotEmpty
(
list
)){
this
.
addAllDepartment
(
list
,
0
,
wxEnterpriseId
,
corpid
,
contactSecret
,
taskId
);
}
}
else
{
RedisUtil
.
delCache
(
key
);
}
//RedisUtil.lock("init_enterprise_" + wxEnterpriseId,60 * 60L);
//insertMQ(0,wxEnterpriseId, corpid,contactSecret,taskId);
//RedisUtil.unlock("init_enterprise_" + wxEnterpriseId);
}
...
...
@@ -549,7 +556,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
String
chainName
=
"0"
;
String
pid
=
"0"
;
List
<
com
.
gic
.
wechat
.
api
.
dto
.
qywx
.
DepartmentDTO
>
handerList
=
new
ArrayList
<>();
if
(
parentId
==
0
){
if
(
parentId
.
equals
(
0
)
){
for
(
com
.
gic
.
wechat
.
api
.
dto
.
qywx
.
DepartmentDTO
departmentDTO
:
list
)
{
if
(
departmentDTO
.
getId
()
==
1
){
handerList
.
add
(
departmentDTO
);
...
...
@@ -557,7 +564,11 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
}
}
}
else
{
handerList
=
list
;
for
(
com
.
gic
.
wechat
.
api
.
dto
.
qywx
.
DepartmentDTO
departmentDTO
:
list
)
{
if
(
departmentDTO
.
getParentid
().
equals
(
parentId
)){
handerList
.
add
(
departmentDTO
);
}
}
}
if
(
parentId
!=
0
){
TabHaobanDepartment
parent
=
this
.
departmentService
.
getByWxId
(
parentId
+
""
,
wxEnterpriseId
);
...
...
@@ -582,36 +593,36 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
}
logger
.
info
(
"【mq同步】parentId={}"
,
parentId
);
for
(
com
.
gic
.
wechat
.
api
.
dto
.
qywx
.
DepartmentDTO
departmentDTO
:
handerList
)
{
try
{
TabHaobanDepartment
exist
=
this
.
departmentService
.
getByWxId
(
departmentDTO
.
getId
()
+
""
,
wxEnterpriseId
);
logger
.
info
(
"分组是否存在:{}"
,
JSON
.
toJSONString
(
exist
));
if
(
exist
==
null
){
com
.
gic
.
haoban
.
manage
.
api
.
dto
.
DepartmentDTO
dto
=
new
com
.
gic
.
haoban
.
manage
.
api
.
dto
.
DepartmentDTO
();
dto
.
setDepartmentName
(
departmentDTO
.
getName
());
dto
.
setLevel
(
level
);
dto
.
setWxEnterpriseId
(
wxEnterpriseId
);
dto
.
setWxDepartmentId
(
departmentDTO
.
getId
()+
""
);
dto
.
setParentDepartmentId
(
pid
);
dto
.
setChainId
(
chainId
);
dto
.
setChainName
(
chainName
);
dto
.
setSort
(
departmentDTO
.
getOrder
());
dto
.
setIsStore
(
0
);
this
.
departmentService
.
add
(
dto
);
}
insertMQ
(
departmentDTO
.
getId
(),
wxEnterpriseId
,
corpid
,
contactSecret
,
taskId
);
}
catch
(
Exception
e
)
{
TabHaobanSyncErrorLog
tab
=
new
TabHaobanSyncErrorLog
();
tab
.
setDataId
(
departmentDTO
.
getId
()+
""
);
tab
.
setDataType
(
0
);
tab
.
setLogType
(
0
);
tab
.
setReason
(
e
.
getMessage
());
tab
.
setTaskId
(
taskId
);
tab
.
setWxEnterpriseId
(
wxEnterpriseId
);
syncErrorLogService
.
add
(
tab
);
}
//
try {
//
TabHaobanDepartment exist = this.departmentService.getByWxId(departmentDTO.getId() + "", wxEnterpriseId);
//
logger.info("分组是否存在:{}", JSON.toJSONString(exist));
//
if(exist == null){
//
com.gic.haoban.manage.api.dto.DepartmentDTO dto = new com.gic.haoban.manage.api.dto.DepartmentDTO();
//
dto.setDepartmentName(departmentDTO.getName());
//
dto.setLevel(level);
//
dto.setWxEnterpriseId(wxEnterpriseId);
//
dto.setWxDepartmentId(departmentDTO.getId()+"");
//
dto.setParentDepartmentId(pid);
//
dto.setChainId(chainId);
//
dto.setChainName(chainName);
//
dto.setSort(departmentDTO.getOrder());
//
dto.setIsStore(0);
//
this.departmentService.add(dto);
//
}
//
insertMQ(departmentDTO.getId(),wxEnterpriseId, corpid,contactSecret,taskId);
//
} catch (Exception e) {
//
TabHaobanSyncErrorLog tab = new TabHaobanSyncErrorLog();
//
tab.setDataId(departmentDTO.getId()+"");
//
tab.setDataType(0);
//
tab.setLogType(0);
//
tab.setReason(e.getMessage());
//
tab.setTaskId(taskId);
//
tab.setWxEnterpriseId(wxEnterpriseId);
//
syncErrorLogService.add(tab);
//
}
//this.addAllDepartment(list, departmentDTO.getId(), wxEnterpriseId, corpid, contactSecret,taskId);
this
.
staffApiService
.
initWxUser
(
corpid
,
contactSecret
,
wxEnterpriseId
,
departmentDTO
.
getId
(),
taskId
);
//
return;
//
this.staffApiService.initWxUser(corpid, contactSecret, wxEnterpriseId, departmentDTO.getId(),taskId);
return
;
}
}
...
...
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/controller/InfoController.java
View file @
8a176f6f
...
...
@@ -3,15 +3,20 @@ package com.gic.haoban.manage.web.controller;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.clerk.api.dto.ClerkDTO
;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.enterprise.api.dto.StoreDTO
;
import
com.gic.enterprise.api.dto.StorePhotoDTO
;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.contacts.manage.api.service.StoreService
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.service.ClerkMainStoreRelatedApiService
;
import
com.gic.haoban.manage.api.service.DepartmentApiService
;
import
com.gic.haoban.manage.api.service.MemberUnionidRelatedApiService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseApiService
;
import
com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService
;
import
com.gic.haoban.manage.web.config.Config
;
...
...
@@ -60,7 +65,14 @@ public class InfoController extends WebBaseController{
@Autowired
private
MemberUnionidRelatedApiService
memberUnionidRelatedApiService
;
@Autowired
private
ClerkService
clerkService
;
@Autowired
private
ClerkMainStoreRelatedApiService
clerkMainStoreRelatedApiService
;
@Autowired
private
StaffDepartmentRelatedApiService
staffDepartmentRelatedApiService
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
InfoController
.
class
);
@Autowired
...
...
@@ -159,6 +171,62 @@ public class InfoController extends WebBaseController{
VO
.
setCreateTime
(
dto
.
getCreateTime
());
retList
.
add
(
VO
);
});
//塞clerkCOde等基本信息
List
<
StaffDepartmentRelatedDTO
>
relateList
=
staffDepartmentRelatedApiService
.
listByStaffId
(
staffDTO
.
getStaffId
());
Map
<
String
,
StaffDepartmentRelatedDTO
>
map
=
com
.
gic
.
commons
.
util
.
CollectionUtil
.
toMap
(
relateList
,
"departmentId"
);
for
(
StoreVO
VO
:
retList
){
StaffDepartmentRelatedDTO
staffDepartmentRelatedDTO
=
map
.
get
(
VO
.
getDepartmentId
());
if
(
staffDepartmentRelatedDTO
!=
null
){
String
clerkCode
=
staffDepartmentRelatedDTO
.
getClerkCode
();
VO
.
setBindFlag
(
StringUtils
.
isEmpty
(
clerkCode
)?
0
:
1
);
VO
.
setClerkCode
(
clerkCode
);
VO
.
setStaffDepartmentRelatedId
(
staffDepartmentRelatedDTO
.
getStaffDepartmentRelatedId
());
VO
.
setStaffId
(
staffDTO
.
getStaffId
());
ClerkDTO
clerkDTO
=
clerkService
.
getClerkByClerkCode
(
VO
.
getEnterpriseId
(),
clerkCode
);
VO
.
setClerkId
(
clerkDTO
==
null
?
""
:
clerkDTO
.
getClerkId
());
}
else
{
VO
.
setBindFlag
(
0
);
}
}
//塞门店店长标志
ClerkMainStoreRelatedDTO
mainStore
=
clerkMainStoreRelatedApiService
.
getWxEnterpriseIdAndStaffId
(
enterpriseDTO
.
getWxEnterpriseId
(),
staffDTO
.
getStaffId
());
for
(
StoreVO
VO
:
retList
){
//查gic门店
StoreDTO
storeDTO
=
storeService
.
getStore
(
VO
.
getStoreId
());
List
<
StorePhotoDTO
>
imgList
=
storeService
.
getStoreImages
(
VO
.
getStoreId
());
EnterpriseDetailDTO
detail
=
wxEnterpriseRelatedApiService
.
getByEnterpriseId
(
storeDTO
.
getEnterpriseId
());
VO
.
setWxEnterpriseRelatedId
(
detail
.
getWxEnterpriseRelatedId
());
//已经绑定的门店
if
(
VO
.
getBindFlag
()==
1
){
String
clerkCode
=
VO
.
getClerkCode
();
if
(
StringUtils
.
isEmpty
(
clerkCode
)){
VO
.
setClerkType
(
0
);
}
else
{
if
(
storeDTO
!=
null
){
//查gic门店店长
ClerkDTO
clerkDTO
=
clerkService
.
getClerkByClerkId
(
storeDTO
.
getClerkId
());
if
(
clerkDTO
!=
null
){
//code相同,则置为1
if
(
clerkCode
.
equals
(
clerkDTO
.
getClerkCode
())){
VO
.
setClerkType
(
1
);
}
}
}
}
}
if
(
CollectionUtil
.
isNotEmpty
(
imgList
)){
VO
.
setStoreImg
(
imgList
.
get
(
0
).
getQcloudImageUrl
());;
}
if
(
mainStore
!=
null
&&
mainStore
.
getStoreId
().
equals
(
VO
.
getStoreId
())){
VO
.
setMainStoreFlag
(
1
);
}
else
{
VO
.
setMainStoreFlag
(
0
);
}
}
user
.
setStoreList
(
retList
);
}
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
user
);
...
...
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