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
33b8db48
Commit
33b8db48
authored
Apr 16, 2020
by
qwmqiuwenmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
e37abe5e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
5 deletions
+118
-5
DepartmentApiService.java
...m/gic/haoban/manage/api/service/DepartmentApiService.java
+2
-0
DepartmentApiServiceImpl.java
...ge/service/service/out/impl/DepartmentApiServiceImpl.java
+85
-5
RouterConstant.java
...va/com/gic/haoban/manage/service/task/RouterConstant.java
+31
-0
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/DepartmentApiService.java
View file @
33b8db48
...
...
@@ -162,5 +162,7 @@ public interface DepartmentApiService {
void
initwxDepartmentMQ
(
String
res
);
boolean
isInitLocked
(
String
wxEnterpriseId
);
void
syncWxDepartmentByParentMQ
(
String
res
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/DepartmentApiServiceImpl.java
View file @
33b8db48
...
...
@@ -21,11 +21,13 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.gic.api.base.commons.JSONResponse
;
import
com.gic.api.base.commons.Page
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.GICMQClientUtil
;
import
com.gic.enterprise.api.dto.StoreDTO
;
import
com.gic.enterprise.api.dto.StoreGroupDTO
;
import
com.gic.enterprise.api.service.StoreGroupService
;
...
...
@@ -46,6 +48,7 @@ import com.gic.haoban.manage.service.service.DepartmentService;
import
com.gic.haoban.manage.service.service.StaffDepartmentRelatedService
;
import
com.gic.haoban.manage.service.service.SyncErrorLogService
;
import
com.gic.haoban.manage.service.service.WxEnterpriseService
;
import
com.gic.haoban.manage.service.task.RouterConstant
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.wechat.api.service.qywx.QywxDepartmentApiService
;
import
com.github.pagehelper.PageHelper
;
...
...
@@ -505,14 +508,91 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
// 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
,
null
);
logger
.
info
(
"企业所有部门数据:{}"
,
JSON
.
toJSONString
(
list
));
if
(
CollectionUtils
.
isNotEmpty
(
list
)){
this
.
addAllDepartment
(
list
,
0
,
wxEnterpriseId
,
corpid
,
contactSecret
,
taskId
);
}
// List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, 0);
// 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
);
}
private
void
insertMQ
(
Integer
parentId
,
String
wxEnterpriseId
,
String
corpid
,
String
contactSecret
,
String
taskId
){
logger
.
info
(
"【初始化部门调用】{},{},{}"
,
RouterConstant
.
INIT_WX_DEPARTMENT_SERVICENAME
,
RouterConstant
.
INIT_WX_DEPARTMENT_METHODNAME
,
wxEnterpriseId
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"parentId"
,
parentId
);
json
.
put
(
"wxEnterpriseId"
,
wxEnterpriseId
);
json
.
put
(
"corpid"
,
corpid
);
json
.
put
(
"contactSecret"
,
contactSecret
);
json
.
put
(
"taskId"
,
taskId
);
try
{
GICMQClientUtil
.
getClientInstance
().
sendCommonMessage
(
RouterConstant
.
ROUTERTYPE
,
wxEnterpriseId
,
RouterConstant
.
INIT_WX_DEPARTMENT_SERVICENAME
,
RouterConstant
.
INIT_WX_DEPARTMENT_METHODNAME
);
}
catch
(
Exception
e
)
{
logger
.
info
(
e
.
getMessage
(),
e
);
}
}
@Override
public
void
syncWxDepartmentByParentMQ
(
String
res
){
JSONObject
json
=
JSON
.
parseObject
(
res
);
Integer
parentId
=
json
.
getInteger
(
"parentId"
);
String
wxEnterpriseId
=
json
.
getString
(
"wxEnterpriseId"
);
String
corpid
=
json
.
getString
(
"corpid"
);
String
contactSecret
=
json
.
getString
(
"contactSecret"
);
String
taskId
=
json
.
getString
(
"taskId"
);
Integer
level
=
1
;
List
<
com
.
gic
.
wechat
.
api
.
dto
.
qywx
.
DepartmentDTO
>
list
=
this
.
qywxDepartmentApiService
.
listSelfDepartment
(
corpid
,
contactSecret
,
parentId
);
String
chainId
=
"0"
;
String
chainName
=
"0"
;
String
pId
=
"0"
;
if
(
parentId
!=
0
){
TabHaobanDepartment
parent
=
this
.
departmentService
.
getByWxId
(
parentId
+
""
,
wxEnterpriseId
);
if
(
parent
!=
null
){
level
=
parent
.
getLevel
()
+
1
;
chainId
=
parent
.
getChainId
()
+
Constant
.
ID_SEPARATOR
+
parent
.
getDepartmentId
();
chainName
=
parent
.
getChainName
()
+
Constant
.
NAME_SEPARATOR
+
parent
.
getDepartmentName
();
pId
=
parent
.
getDepartmentId
();
}
}
for
(
com
.
gic
.
wechat
.
api
.
dto
.
qywx
.
DepartmentDTO
departmentDTO
:
list
)
{
insertMQ
(
departmentDTO
.
getParentid
(),
wxEnterpriseId
,
corpid
,
contactSecret
,
taskId
);
try
{
if
(
parentId
.
equals
(
departmentDTO
.
getParentid
()))
{
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
(
parentId
+
""
);
dto
.
setChainId
(
chainId
);
dto
.
setChainName
(
chainName
);
dto
.
setSort
(
departmentDTO
.
getOrder
());
dto
.
setIsStore
(
0
);
this
.
departmentService
.
add
(
dto
);
}
}
}
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
);
}
}
@Override
public
boolean
isInitLocked
(
String
wxEnterpriseId
){
return
RedisUtil
.
isLocked
(
"init_enterprise_"
+
wxEnterpriseId
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/task/RouterConstant.java
0 → 100644
View file @
33b8db48
package
com
.
gic
.
haoban
.
manage
.
service
.
task
;
/**
* @author
*/
public
class
RouterConstant
{
/**
* 分配_服务名
*/
public
final
static
String
INIT_WX_DEPARTMENT_SERVICENAME
=
"com.gic.haoban.manage.api.service.DepartmentApiService"
;
/**
*
*/
public
final
static
String
INIT_WX_DEPARTMENT_METHODNAME
=
"syncWxDepartmentByParentMQ"
;
/**
* 路由类型(通用)
*/
public
final
static
String
ROUTERTYPE
=
"commonRouter"
;
public
final
static
String
INIT_WX_DEPARTMENT_APP_CODE
=
"INIT_WX_DEPARTMENT"
;
/**
* 默认的数据状态
*/
public
final
static
int
DEFAULT_STATUS
=
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