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
a94d9250
Commit
a94d9250
authored
Mar 17, 2022
by
墨竹
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:企微同步通讯录处理部门
parent
24c5f1ea
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
147 additions
and
68 deletions
+147
-68
WxEditType.java
...main/java/com/gic/haoban/manage/api/enums/WxEditType.java
+6
-6
DepartmentApiService.java
...m/gic/haoban/manage/api/service/DepartmentApiService.java
+5
-2
StaffApiService.java
...va/com/gic/haoban/manage/api/service/StaffApiService.java
+1
-0
DepartmentApiServiceImpl.java
...ge/service/service/out/impl/DepartmentApiServiceImpl.java
+2
-6
MessageApiServiceImpl.java
...anage/service/service/out/impl/MessageApiServiceImpl.java
+133
-54
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/enums/WxEditType.java
View file @
a94d9250
...
...
@@ -4,12 +4,12 @@ package com.gic.haoban.manage.api.enums;
* Created by tgs on 2020/2/20.
*/
public
enum
WxEditType
{
ADDDEPART
(
"create_party"
,
"创建部门"
),
UPDATEDEPART
(
"update_party"
,
"更新部门"
),
DELETEDEPART
(
"delete_party"
,
"删除部门"
),
ADDUSER
(
"create_user"
,
"新增用户"
),
UPDATEUSER
(
"update_user"
,
"更新用户"
),
DELETEUSER
(
"delete_user"
,
"删除用户"
);
ADD
_
DEPART
(
"create_party"
,
"创建部门"
),
UPDATE
_
DEPART
(
"update_party"
,
"更新部门"
),
DELETE
_
DEPART
(
"delete_party"
,
"删除部门"
),
ADD
_
USER
(
"create_user"
,
"新增用户"
),
UPDATE
_
USER
(
"update_user"
,
"更新用户"
),
DELETE
_
USER
(
"delete_user"
,
"删除用户"
);
WxEditType
(
String
type
,
String
desc
){
this
.
code
=
type
;
...
...
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/DepartmentApiService.java
View file @
a94d9250
package
com
.
gic
.
haoban
.
manage
.
api
.
service
;
import
java.util.List
;
import
com.gic.api.base.commons.Page
;
import
com.gic.haoban.base.api.common.BasePageInfo
;
import
com.gic.haoban.base.api.common.ServiceResponse
;
import
com.gic.haoban.manage.api.dto.DepartmentDTO
;
import
com.gic.haoban.manage.api.dto.DepartmentShortDTO
;
import
java.util.List
;
public
interface
DepartmentApiService
{
List
<
DepartmentDTO
>
listByParentId
(
String
parentId
);
...
...
@@ -49,18 +49,21 @@ public interface DepartmentApiService {
* @param department
* @return
*/
@Deprecated
ServiceResponse
<
DepartmentDTO
>
add
(
DepartmentDTO
department
);
/**
* 修改部门
* @param department
* @return
*/
@Deprecated
ServiceResponse
edit
(
DepartmentDTO
department
);
/**
* 删除部门
* @param departmentId
* @return
*/
@Deprecated
ServiceResponse
del
(
String
departmentId
);
/**
* 根据关联id 获取部门
...
...
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/StaffApiService.java
View file @
a94d9250
...
...
@@ -25,6 +25,7 @@ public interface StaffApiService {
Page
<
StaffDTO
>
pageStaff
(
List
<
String
>
departmentId
,
Integer
activeFlag
,
String
keyword
,
BasePageInfo
pageInfo
,
Integer
relationFlag
);
@Deprecated
void
del
(
String
staffDepartmentStaffRelatedId
);
/**
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/DepartmentApiServiceImpl.java
View file @
a94d9250
...
...
@@ -244,7 +244,6 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
return
hr
;
}
}
departmentService
.
del
(
departmentId
);
return
hr
;
}
...
...
@@ -325,23 +324,20 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
public
ServiceResponse
wxCallBackrecycle
(
String
departmentId
)
{
ServiceResponse
hr
=
new
ServiceResponse
();
hr
.
setCode
(
1
);
List
<
TabHaobanDepartment
>
list
=
departmentService
.
listByParentId
(
departmentId
);
logger
.
info
(
"【部门删除】list.size={}"
,
list
.
size
());
if
(
!
list
.
isEmpty
(
))
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
hr
.
setCode
(
0
);
hr
.
setMessage
(
"存在子部门,删除部门失败"
);
return
hr
;
}
List
<
TabHaobanStaffDepartmentRelated
>
staffList
=
staffDepartmentService
.
listByDepartmentId
(
departmentId
);
logger
.
info
(
"【部门删除】staffList.size={}"
,
staffList
.
size
());
if
(
!
staffList
.
isEmpty
(
))
{
if
(
CollectionUtils
.
isNotEmpty
(
staffList
))
{
hr
.
setCode
(
0
);
hr
.
setMessage
(
"存在成员,删除部门失败"
);
return
hr
;
}
departmentService
.
recycle
(
departmentId
);
return
hr
;
}
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/MessageApiServiceImpl.java
View file @
a94d9250
package
com
.
gic
.
haoban
.
manage
.
service
.
service
.
out
.
impl
;
import
cn.hutool.core.convert.Convert
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.clerk.api.dto.ClerkQwDTO
;
import
com.gic.clerk.api.service.ClerkService
;
import
com.gic.commons.util.*
;
import
com.gic.haoban.app.customer.service.api.service.InnerApiService
;
import
com.gic.haoban.base.api.common.
ServiceResponse
;
import
com.gic.haoban.base.api.common.
Constant
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.enums.AppPageType
;
import
com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum
;
import
com.gic.haoban.manage.api.enums.SecretTypeEnum
;
import
com.gic.haoban.manage.api.enums.WxEditType
;
import
com.gic.haoban.manage.api.service.MessageApiService
;
import
com.gic.haoban.manage.api.service.StaffApiService
;
import
com.gic.haoban.manage.api.service.StaffClerkRelationApiService
;
import
com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService
;
import
com.gic.haoban.manage.api.service.*
;
import
com.gic.haoban.manage.api.util.notify.NoticeMessageUtil
;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.entity.*
;
...
...
@@ -84,7 +82,7 @@ public class MessageApiServiceImpl implements MessageApiService {
@Autowired
private
SecretSettingService
secretSettingService
;
@Autowired
private
WxApplicationService
wxApplication
Service
;
private
DepartmentApiService
departmentApi
Service
;
@Override
public
void
gicMessageReceive
(
GicMessageDTO
gicMessageDTO
)
{
...
...
@@ -116,48 +114,10 @@ public class MessageApiServiceImpl implements MessageApiService {
public
void
dealWxMessage
(
String
param
)
{
QywxCallBackDTO
dto
=
JSON
.
parseObject
(
param
,
QywxCallBackDTO
.
class
);
log
.
info
(
"【成员同步回调处理】dto={}"
,
JSON
.
toJSONString
(
param
));
TabHaobanWxApplication
wxApplication
=
wxApplicationService
.
selectByCorpId
(
dto
.
getAuthCorpId
());
if
(
Objects
.
isNull
(
wxApplication
))
{
log
.
info
(
"通过corpId:【{}】未查询到授权企业,无法处理"
,
dto
.
getAuthCorpId
());
return
;
}
String
wxEnterpriseId
=
wxApplication
.
getWxEnterpriseId
();
// 校验适用企业-定制
boolean
suitWxEnterpriseIid
=
checkSuitEnterpriseId
(
wxEnterpriseId
);
if
(
suitWxEnterpriseIid
)
{
log
.
info
(
"成员同步定制化开始"
);
// 处理定制-目前鸿星尔克用
boolean
checkErkeDeal
=
checkErkeDeal
(
dto
);
if
(!
checkErkeDeal
)
{
log
.
info
(
"不符合鸿星尔克需求,返回"
);
return
;
}
log
.
info
(
"微信企业id:{}, 不适用"
,
wxEnterpriseId
);
List
<
TabHaobanWxEnterpriseRelated
>
relatedList
=
wxEnterpriseRelatedService
.
getByWxEnterpriseId
(
wxEnterpriseId
);
if
(
CollectionUtils
.
isEmpty
(
relatedList
))
{
log
.
info
(
"未查询到企业关联企业 wxEnt"
);
return
;
}
ServiceResponse
response
=
staffApiService
.
getWxSaveNew
(
dto
.
getUserid
(),
wxEnterpriseId
);
if
(
response
.
getCode
()
!=
1
)
{
log
.
info
(
"添加企业员工失败:{}"
,
response
.
getMessage
());
return
;
}
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
wxEnterpriseId
,
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
());
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
log
.
info
(
"没有配置secret:{}"
,
JSONObject
.
toJSONString
(
wxApplication
));
return
;
}
// 这里将员工姓名改一下, 代开发返回的 id 和 name 一样
if
(
Objects
.
equals
(
dto
.
getUserid
(),
dto
.
getUserName
()))
{
dto
.
setUserName
((
String
)
response
.
getResult
());
}
// 取第一个企业的id
doDealUser
(
dto
,
relatedList
.
get
(
0
).
getEnterpriseId
(),
secretSetting
.
getSecretVal
());
log
.
info
(
"成员同步定制化结束"
);
}
else
{
dealUser
(
dto
);
}
//处理成员
dealUser
(
dto
);
//处理部门
dealDepartment
(
dto
);
}
/**
...
...
@@ -189,7 +149,14 @@ public class MessageApiServiceImpl implements MessageApiService {
return
wxSet
.
contains
(
wxEnterpriseId
);
}
private
void
doDealUser
(
QywxCallBackDTO
dto
,
String
enterpriseId
,
String
secret
)
{
/**
* 处理同步导购(定制)
*
* @param dto
* @param enterpriseId
* @param secret
*/
private
void
dealClerkUser
(
QywxCallBackDTO
dto
,
String
enterpriseId
,
String
secret
)
{
ClerkQwDTO
clerkQwDTO
=
new
ClerkQwDTO
();
clerkQwDTO
.
setEnterpriseId
(
enterpriseId
);
String
mainDeptId
=
dto
.
getMainDepartment
();
...
...
@@ -228,11 +195,17 @@ public class MessageApiServiceImpl implements MessageApiService {
String
wxEnterpriseId
=
enterprise
.
getWxEnterpriseId
();
String
changeType
=
qywxCallBackDTO
.
getChangeType
();
if
(
changeType
.
equals
(
WxEditType
.
ADDUSER
.
getCode
()))
{
if
(
changeType
.
equals
(
WxEditType
.
ADD
_
USER
.
getCode
()))
{
log
.
info
(
"成员同步新增,userid:{}"
,
userid
);
//新增
this
.
staffApiService
.
wxGetAdd
(
userid
,
wxEnterpriseId
);
}
else
if
(
changeType
.
equals
(
WxEditType
.
UPDATEUSER
.
getCode
()))
{
// 校验适用企业-定制
boolean
suitWxEnterpriseIid
=
checkSuitEnterpriseId
(
wxEnterpriseId
);
if
(
suitWxEnterpriseIid
)
{
//鸿星尔克定制
dealErKe
(
qywxCallBackDTO
,
wxEnterpriseId
);
}
}
else
if
(
changeType
.
equals
(
WxEditType
.
UPDATE_USER
.
getCode
()))
{
log
.
info
(
"成员同步修改,userid:{}"
,
userid
);
//修改
TabHaobanStaff
oldStaff
=
this
.
staffService
.
selectByUserIdAndEnterpriseId
(
userid
,
wxEnterpriseId
);
...
...
@@ -279,7 +252,7 @@ public class MessageApiServiceImpl implements MessageApiService {
}
StaffDTO
staffDTO
=
EntityUtil
.
changeEntityByJSON
(
StaffDTO
.
class
,
staff
);
staffApiService
.
staffEdit
(
staffDTO
,
departmentIds
.
toString
());
}
else
if
(
changeType
.
equals
(
WxEditType
.
DELETEUSER
.
getCode
()))
{
}
else
if
(
changeType
.
equals
(
WxEditType
.
DELETE
_
USER
.
getCode
()))
{
log
.
info
(
"成员同步删除,userid:{}"
,
userid
);
//删除
TabHaobanStaff
oldStaff
=
this
.
staffService
.
selectByUserIdAndEnterpriseId
(
userid
,
wxEnterpriseId
);
...
...
@@ -293,12 +266,118 @@ public class MessageApiServiceImpl implements MessageApiService {
this
.
staffDepartmentRelatedService
.
delByUserid
(
userid
);
//删除员工表
this
.
staffService
.
delByStaffId
(
oldStaff
.
getStaffId
());
}
else
{
log
.
error
(
"成员同步类型错误,changeType:{}"
,
changeType
);
}
log
.
error
(
"成员同步结束"
);
}
/**
* 处理部门
*
* @param qywxCallBackDTO
*/
private
void
dealDepartment
(
QywxCallBackDTO
qywxCallBackDTO
)
{
log
.
info
(
"处理部门:{}"
,
qywxCallBackDTO
);
DepartmentDTO
departmentDTO
=
new
DepartmentDTO
();
departmentDTO
.
setDepartmentName
(
qywxCallBackDTO
.
getDepartmentName
());
departmentDTO
.
setIsStore
(
0
);
TabHaobanWxEnterprise
enterprise
=
this
.
enterpriseService
.
getEnterpriseBycorpId
(
qywxCallBackDTO
.
getAuthCorpId
());
TabHaobanDepartment
parentDepartment
=
new
TabHaobanDepartment
();
if
(
qywxCallBackDTO
.
getParentId
()
!=
null
)
{
parentDepartment
=
this
.
departmentService
.
getByWxId
(
qywxCallBackDTO
.
getParentId
()
+
""
,
enterprise
.
getWxEnterpriseId
());
}
else
{
TabHaobanDepartment
oldDepartment
=
this
.
departmentService
.
getByWxId
(
qywxCallBackDTO
.
getId
()
+
""
,
enterprise
.
getWxEnterpriseId
());
if
(
oldDepartment
!=
null
)
{
parentDepartment
=
departmentService
.
selectById
(
oldDepartment
.
getParentDepartmentId
());
}
}
String
changeType
=
qywxCallBackDTO
.
getChangeType
();
if
(!
changeType
.
equals
(
WxEditType
.
DELETE_DEPART
.
getCode
()))
{
if
(
parentDepartment
==
null
)
{
log
.
info
(
"微信同步父部门不存在"
);
return
;
}
departmentDTO
.
setParentDepartmentId
(
parentDepartment
.
getDepartmentId
());
departmentDTO
.
setChainId
(
parentDepartment
.
getChainId
()
+
Constant
.
ID_SEPARATOR
+
parentDepartment
.
getDepartmentId
());
departmentDTO
.
setChainName
(
parentDepartment
.
getChainName
()
+
Constant
.
NAME_SEPARATOR
+
parentDepartment
.
getChainName
());
departmentDTO
.
setLevel
(
parentDepartment
.
getLevel
()
+
1
);
}
departmentDTO
.
setWxEnterpriseId
(
enterprise
.
getWxEnterpriseId
());
departmentDTO
.
setWxDepartmentId
(
qywxCallBackDTO
.
getId
()
+
""
);
if
(
qywxCallBackDTO
.
getParentId
()
!=
null
)
{
List
<
com
.
gic
.
wechat
.
api
.
dto
.
qywx
.
DepartmentDTO
>
list
=
this
.
qywxDepartmentApiService
.
listDepartment
(
qywxCallBackDTO
.
getAuthCorpId
(),
qywxCallBackDTO
.
getSuiteId
(),
qywxCallBackDTO
.
getParentId
());
if
(
list
!=
null
)
{
for
(
com
.
gic
.
wechat
.
api
.
dto
.
qywx
.
DepartmentDTO
wxDepartmentDTO
:
list
)
{
if
(
Convert
.
toStr
(
wxDepartmentDTO
.
getId
()).
equals
(
departmentDTO
.
getDepartmentId
()))
{
departmentDTO
.
setSort
(
qywxCallBackDTO
.
getOrder
());
}
else
{
TabHaobanDepartment
tab
=
this
.
departmentService
.
getByWxId
(
wxDepartmentDTO
.
getId
()
+
""
,
enterprise
.
getWxEnterpriseId
());
if
(
tab
!=
null
)
{
tab
.
setSort
(
wxDepartmentDTO
.
getOrder
());
this
.
departmentService
.
edit
(
EntityUtil
.
changeEntityByJSON
(
DepartmentDTO
.
class
,
tab
));
}
}
}
}
}
if
(
changeType
.
equals
(
WxEditType
.
ADD_DEPART
.
getCode
()))
{
log
.
info
(
"企微新增部门同步"
);
this
.
departmentService
.
add
(
departmentDTO
);
}
else
if
(
changeType
.
equals
(
WxEditType
.
UPDATE_DEPART
.
getCode
()))
{
log
.
info
(
"企微修改部门同步"
);
TabHaobanDepartment
department
=
this
.
departmentService
.
getByWxId
(
qywxCallBackDTO
.
getId
()
+
""
,
enterprise
.
getWxEnterpriseId
());
if
(
department
==
null
)
{
String
response
=
this
.
departmentService
.
add
(
departmentDTO
);
log
.
info
(
"企微同步新增部门:{}"
,
JSON
.
toJSONString
(
response
));
}
else
{
departmentDTO
.
setIsStore
(
department
.
getIsStore
());
departmentDTO
.
setDepartmentId
(
department
.
getDepartmentId
());
this
.
departmentService
.
edit
(
departmentDTO
);
log
.
info
(
"企微修改部门同步完成"
);
}
}
else
if
(
changeType
.
equals
(
WxEditType
.
DELETE_DEPART
.
getCode
()))
{
log
.
info
(
"企微删除部门同步"
);
TabHaobanDepartment
department
=
this
.
departmentService
.
getByWxId
(
qywxCallBackDTO
.
getId
()
+
""
,
enterprise
.
getWxEnterpriseId
());
if
(
department
==
null
)
{
log
.
info
(
"企微同步删除部门不存在"
);
}
else
{
if
(
StringUtils
.
isBlank
(
department
.
getRelatedId
()))
{
this
.
departmentService
.
del
(
department
.
getDepartmentId
());
}
else
{
this
.
departmentApiService
.
wxCallBackrecycle
(
department
.
getDepartmentId
());
}
log
.
info
(
"企微删除同步完成"
);
}
}
}
/**
* 处理鸿星尔克定制需求
*
* @param qywxCallBackDTO
* @param wxEnterpriseId
*/
private
void
dealErKe
(
QywxCallBackDTO
qywxCallBackDTO
,
String
wxEnterpriseId
)
{
log
.
info
(
"成员同步定制化开始"
);
// 处理定制-目前鸿星尔克用
boolean
checkErkeDeal
=
checkErkeDeal
(
qywxCallBackDTO
);
if
(!
checkErkeDeal
)
{
log
.
info
(
"不符合鸿星尔克需求,返回"
);
return
;
}
List
<
TabHaobanWxEnterpriseRelated
>
relatedList
=
wxEnterpriseRelatedService
.
getByWxEnterpriseId
(
wxEnterpriseId
);
if
(
CollectionUtils
.
isEmpty
(
relatedList
))
{
log
.
info
(
"未查询到企业关联企业 wxEnt"
);
return
;
}
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
wxEnterpriseId
,
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
());
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
log
.
info
(
"没有配置secret:{}"
,
wxEnterpriseId
);
return
;
}
dealClerkUser
(
qywxCallBackDTO
,
relatedList
.
get
(
0
).
getEnterpriseId
(),
secretSetting
.
getSecretVal
());
log
.
info
(
"成员同步定制化结束"
);
}
private
String
changeHeaderImageUrl
(
String
headImgUrl
)
{
try
{
log
.
info
(
"图片headImgUrl:{}"
,
headImgUrl
);
...
...
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