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
ccc81120
Commit
ccc81120
authored
Oct 20, 2021
by
xugaojun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【10月迭代】:成员列表查询修改
parent
d63cc730
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
353 additions
and
242 deletions
+353
-242
StaffDTO.java
...src/main/java/com/gic/haoban/manage/api/dto/StaffDTO.java
+47
-12
StaffApiService.java
...va/com/gic/haoban/manage/api/service/StaffApiService.java
+4
-8
TabHaobanStaffClerkRelationMapper.java
...service/dao/mapper/TabHaobanStaffClerkRelationMapper.java
+10
-0
StaffClerkRelationService.java
...ban/manage/service/service/StaffClerkRelationService.java
+9
-0
StaffClerkRelationServiceImpl.java
...e/service/service/impl/StaffClerkRelationServiceImpl.java
+5
-0
StaffApiServiceImpl.java
.../manage/service/service/out/impl/StaffApiServiceImpl.java
+241
-206
TabHaobanStaffClerkRelationMapper.xml
...in/resources/mapper/TabHaobanStaffClerkRelationMapper.xml
+12
-0
StaffController.java
...com/gic/haoban/manage/web/controller/StaffController.java
+25
-16
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/dto/StaffDTO.java
View file @
ccc81120
...
...
@@ -5,29 +5,53 @@ import java.util.Date;
import
java.util.List
;
public
class
StaffDTO
implements
Serializable
{
/**
* 员工id
*/
private
String
staffId
;
/**
* 企业微信id
*/
private
String
wxEnterpriseId
;
/**
* 微信用户id
*/
private
String
wxUserId
;
/**
* 手机号
*/
private
String
phoneNumber
;
/**
* 员工姓名
*/
private
String
staffName
;
/**
* 国家码
*/
private
String
nationCode
;
/**
* 昵称
*/
private
String
nickName
;
/**
* 性别
*/
private
Integer
sex
;
/**
* 职位
*/
private
String
postion
;
/**
* 激活状态
*/
private
Integer
activeFlag
;
/**
* 对外职务
*/
private
String
extendPostion
;
/**
* 状态
*/
private
Integer
statusFlag
;
private
Date
createTime
;
...
...
@@ -59,6 +83,11 @@ public class StaffDTO implements Serializable{
private
long
memberCount
;
private
String
clerkId
;
/**
* 关联状态 1 已关联 0 未关联
* 关联状态为 员工是否关联某门店导购
*/
private
Integer
relationFlag
;
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -281,5 +310,11 @@ public class StaffDTO implements Serializable{
this
.
memberCount
=
memberCount
;
}
public
Integer
getRelationFlag
()
{
return
relationFlag
;
}
public
void
setRelationFlag
(
Integer
relationFlag
)
{
this
.
relationFlag
=
relationFlag
;
}
}
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/StaffApiService.java
View file @
ccc81120
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.GicClerkDTO
;
import
com.gic.haoban.manage.api.dto.StaffClerkRelationDTO
;
import
com.gic.haoban.manage.api.dto.StaffDTO
;
import
com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO
;
import
com.gic.haoban.manage.api.dto.UserLoginLogDTO
;
import
com.gic.haoban.manage.api.dto.*
;
import
java.util.List
;
public
interface
StaffApiService
{
...
...
@@ -27,7 +23,7 @@ public interface StaffApiService {
public
List
<
StaffDepartmentRelatedDTO
>
listStaffDepartmentByStaffId
(
String
staffId
);
public
Page
<
StaffDTO
>
pageStaff
(
List
<
String
>
departmentId
,
Integer
activeFlag
,
String
keyword
,
BasePageInfo
pageInfo
);
public
Page
<
StaffDTO
>
pageStaff
(
List
<
String
>
departmentId
,
Integer
activeFlag
,
String
keyword
,
BasePageInfo
pageInfo
,
Integer
relationFlag
);
public
void
del
(
String
staffDepartmentStaffRelatedId
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/TabHaobanStaffClerkRelationMapper.java
View file @
ccc81120
...
...
@@ -134,4 +134,13 @@ public interface TabHaobanStaffClerkRelationMapper {
* @date 2021-07-15 16:24:27
*/
List
<
StaffClerkRelationDTO
>
listAll
();
/**
* 查询有关联的员工id列表
*
* @param staffIdList 员工id列表
* @author: YongEn
* @return {@link List<String>}
*/
List
<
String
>
listRelationsStaffId
(
@Param
(
"staffIdList"
)
Set
<
String
>
staffIdList
);
}
\ No newline at end of file
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/StaffClerkRelationService.java
View file @
ccc81120
...
...
@@ -131,4 +131,13 @@ public interface StaffClerkRelationService {
* @date 2021-07-15 16:26:17
*/
List
<
StaffClerkRelationDTO
>
listAll
();
/**
* 查询有关联的员工id列表
*
* @param staffIdList 员工id列表
* @author: YongEn
* @return {@link Set<String>}
*/
List
<
String
>
listRelationsStaffId
(
Set
<
String
>
staffIdList
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/StaffClerkRelationServiceImpl.java
View file @
ccc81120
...
...
@@ -291,4 +291,9 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
public
List
<
StaffClerkRelationDTO
>
listAll
()
{
return
mapper
.
listAll
();
}
@Override
public
List
<
String
>
listRelationsStaffId
(
Set
<
String
>
staffIdList
)
{
return
mapper
.
listRelationsStaffId
(
staffIdList
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/StaffApiServiceImpl.java
View file @
ccc81120
...
...
@@ -34,7 +34,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import
com.gic.haoban.manage.service.entity.TabHaobanSyncErrorLog
;
import
com.gic.haoban.manage.service.service.*
;
import
com.gic.haoban.manage.service.util.EmojiFilterUtil
;
import
com.gic.redis.data.anno.RedisCache
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.thirdparty.api.dto.PicUploadResDTO
;
import
com.gic.thirdparty.api.service.QQCloudPicService
;
...
...
@@ -106,6 +105,7 @@ public class StaffApiServiceImpl implements StaffApiService {
TabHaobanStaff
staff
=
staffService
.
selectById
(
staffId
);
return
EntityUtil
.
changeEntityByJSON
(
StaffDTO
.
class
,
staff
);
}
@Override
public
List
<
StaffDTO
>
listByPhoneNumber
(
String
phoneNumber
)
{
List
<
TabHaobanStaff
>
staffs
=
staffMapper
.
listByPhoneNumber
(
phoneNumber
);
...
...
@@ -113,8 +113,8 @@ public class StaffApiServiceImpl implements StaffApiService {
}
@Override
public
StaffDTO
selectByNationcodeAndPhoneNumber
(
String
wxEnterpriseId
,
String
nationcode
,
String
phoneNumber
)
{
TabHaobanStaff
staff
=
staffService
.
selectByNationcodeAndPhoneNumber
(
wxEnterpriseId
,
nationcode
,
phoneNumber
);
public
StaffDTO
selectByNationcodeAndPhoneNumber
(
String
wxEnterpriseId
,
String
nationcode
,
String
phoneNumber
)
{
TabHaobanStaff
staff
=
staffService
.
selectByNationcodeAndPhoneNumber
(
wxEnterpriseId
,
nationcode
,
phoneNumber
);
return
EntityUtil
.
changeEntityByJSON
(
StaffDTO
.
class
,
staff
);
}
...
...
@@ -125,7 +125,7 @@ public class StaffApiServiceImpl implements StaffApiService {
Integer
activeFlag
=
staff
.
getActiveFlag
();
staff
.
setActiveFlag
(
0
);
Integer
syncPostionFlag
=
staff
.
getSyncPostionFlag
();
if
(
syncPostionFlag
!=
null
&&
syncPostionFlag
==
1
)
{
if
(
syncPostionFlag
!=
null
&&
syncPostionFlag
==
1
)
{
staff
.
setExtendPostion
(
staff
.
getPostion
());
}
TabHaobanStaff
tab
=
EntityUtil
.
changeEntityByJSON
(
TabHaobanStaff
.
class
,
staff
);
...
...
@@ -134,7 +134,7 @@ public class StaffApiServiceImpl implements StaffApiService {
//调接口获取
String
wxUserId
=
""
;
WxEnterpriseDTO
enterpriseDTO
=
wxEnterpriseService
.
selectById
(
staff
.
getWxEnterpriseId
());
if
(
enterpriseDTO
!=
null
)
{
if
(
enterpriseDTO
!=
null
)
{
UserDTO
userDTO
=
new
UserDTO
();
userDTO
.
setCorpid
(
enterpriseDTO
.
getCorpid
());
String
[]
departmentIdArr
=
departmentIds
.
split
(
","
);
...
...
@@ -143,23 +143,23 @@ public class StaffApiServiceImpl implements StaffApiService {
for
(
String
string
:
departmentIdArr
)
{
TabHaobanDepartment
tabs
=
departmentService
.
selectById
(
string
);
wxDepartmentIdArrIntegers
[
index
]
=
Integer
.
parseInt
(
tabs
.
getWxDepartmentId
());
index
++;
index
++;
}
userDTO
.
setDepartment
(
wxDepartmentIdArrIntegers
);
userDTO
.
setGender
(
staff
.
getSex
()
==
null
?
null
:
staff
.
getSex
().
toString
());
userDTO
.
setGender
(
staff
.
getSex
()
==
null
?
null
:
staff
.
getSex
().
toString
());
userDTO
.
setMobile
(
staff
.
getPhoneNumber
());
userDTO
.
setName
(
staff
.
getStaffName
());
userDTO
.
setUserid
(
staffId
);
userDTO
.
setAlias
(
staff
.
getNickName
());
userDTO
.
setExternal_position
(
tab
.
getExtendPostion
());
userDTO
.
setPosition
(
tab
.
getPostion
());
if
(
activeFlag
==
1
)
{
if
(
activeFlag
==
1
)
{
userDTO
.
setTo_invite
(
true
);
}
if
(
RedisUtil
.
getCache
(
"is-to-invite-send"
)
!=
null
)
{
if
(
RedisUtil
.
getCache
(
"is-to-invite-send"
)
!=
null
)
{
userDTO
.
setTo_invite
(
false
);
}
logger
.
info
(
"【店员新增】userDTO = {}"
,
JSON
.
toJSONString
(
userDTO
));
logger
.
info
(
"【店员新增】userDTO = {}"
,
JSON
.
toJSONString
(
userDTO
));
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
enterpriseDTO
.
getWxEnterpriseId
(),
SecretTypeEnum
.
CONTACT_SECRET
.
getVal
());
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
hr
.
setCode
(
0
);
...
...
@@ -167,8 +167,8 @@ public class StaffApiServiceImpl implements StaffApiService {
return
hr
;
}
JSONResponse
jp
=
qywxUserApiService
.
createSelfWorkWxUser
(
userDTO
,
enterpriseDTO
.
getCorpid
(),
secretSetting
.
getSecretVal
());
logger
.
info
(
"【店员新增】jp = {}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
!=
0
)
{
logger
.
info
(
"【店员新增】jp = {}"
,
JSON
.
toJSONString
(
jp
));
if
(
jp
.
getErrorCode
()
!=
0
)
{
hr
.
setCode
(
0
);
hr
.
setMessage
(
"微信新增失败:"
+
jp
.
getErrorCode
());
return
hr
;
...
...
@@ -176,7 +176,7 @@ public class StaffApiServiceImpl implements StaffApiService {
staffService
.
add
(
tab
);
wxUserId
=
staffId
;
}
if
(
StringUtils
.
isNotBlank
(
wxUserId
))
{
if
(
StringUtils
.
isNotBlank
(
wxUserId
))
{
String
[]
departmentIdArr
=
departmentIds
.
split
(
","
);
for
(
String
string
:
departmentIdArr
)
{
StaffDepartmentRelatedDTO
related
=
new
StaffDepartmentRelatedDTO
();
...
...
@@ -189,7 +189,7 @@ public class StaffApiServiceImpl implements StaffApiService {
related
.
setWxEnterpriseId
(
staff
.
getWxEnterpriseId
());
staffDepartmentRelatedService
.
add
(
related
);
}
}
else
{
}
else
{
hr
.
setCode
(
0
);
hr
.
setMessage
(
"微信端新增失败"
);
}
...
...
@@ -204,38 +204,70 @@ public class StaffApiServiceImpl implements StaffApiService {
}
@Override
public
Page
<
StaffDTO
>
pageStaff
(
List
<
String
>
departmentIds
,
Integer
activeFlag
,
String
keyword
,
BasePageInfo
pageInfo
)
{
List
<
TabHaobanStaffDepartmentRelated
>
list
=
staffDepartmentRelatedService
.
listByDepartmentIdByKeyword
(
departmentIds
,
keyword
);
Set
<
String
>
staffIds
=
new
HashSet
<
String
>();
for
(
TabHaobanStaffDepartmentRelated
tabHaobanStaffDepartmentRelated
:
list
)
{
staffIds
.
add
(
tabHaobanStaffDepartmentRelated
.
getStaffId
());
}
Map
<
String
,
TabHaobanStaffDepartmentRelated
>
map
=
new
HashMap
<
String
,
TabHaobanStaffDepartmentRelated
>();
if
(
CollectionUtils
.
isNotEmpty
(
list
)){
map
=
list
.
stream
().
collect
(
Collectors
.
toMap
(
TabHaobanStaffDepartmentRelated:
:
getStaffId
,
Function
.
identity
(),
(
s1
,
s2
)
->
s2
));
}
if
(
staffIds
.
isEmpty
())
{
return
new
Page
<
StaffDTO
>();
public
Page
<
StaffDTO
>
pageStaff
(
List
<
String
>
departmentIds
,
Integer
activeFlag
,
String
keyword
,
BasePageInfo
pageInfo
,
Integer
relationFlag
)
{
// 部门 员工列表
List
<
TabHaobanStaffDepartmentRelated
>
list
=
staffDepartmentRelatedService
.
listByDepartmentIdByKeyword
(
departmentIds
,
keyword
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
new
Page
<>();
}
Set
<
String
>
staffIdSet
=
list
.
stream
().
map
(
TabHaobanStaffDepartmentRelated:
:
getStaffId
).
collect
(
Collectors
.
toSet
());
// 员工导购关联-查库过滤掉无关联的员工id
List
<
String
>
relationsStaffIdList
=
staffClerkRelationService
.
listRelationsStaffId
(
staffIdSet
);
Set
<
String
>
relationStaffSet
=
new
HashSet
<>(
relationsStaffIdList
);
Set
<
String
>
queryStaffSet
=
filterByRelationFlag
(
staffIdSet
,
relationStaffSet
,
relationFlag
);
// 分页
PageHelper
.
startPage
(
pageInfo
.
getPageNum
(),
pageInfo
.
getPageSize
());
Page
<
StaffDTO
>
page
=
PageUtil
.
changePageHelperToCurrentPage
(
staffService
.
pageStaff
(
staffIds
,
activeFlag
,
""
),
StaffDTO
.
class
);
List
<
StaffDTO
>
staffList
=
page
.
getResult
();
for
(
StaffDTO
staffDTO
:
staffList
)
{
staffDTO
.
setDepartmentIds
(
map
.
get
(
staffDTO
.
getStaffId
())
==
null
?
null
:
map
.
get
(
staffDTO
.
getStaffId
()).
getDepartmentId
()
);
Page
<
StaffDTO
>
page
=
PageUtil
.
changePageHelperToCurrentPage
(
staffService
.
pageStaff
(
queryStaffSet
,
activeFlag
,
""
),
StaffDTO
.
class
);
if
(
CollectionUtils
.
isEmpty
(
page
.
getResult
())
)
{
return
new
Page
<>(
);
}
Map
<
String
,
TabHaobanStaffDepartmentRelated
>
map
=
list
.
stream
()
.
collect
(
Collectors
.
toMap
(
TabHaobanStaffDepartmentRelated:
:
getStaffId
,
Function
.
identity
(),
(
s1
,
s2
)
->
s2
));
page
.
getResult
().
forEach
(
one
->
{
TabHaobanStaffDepartmentRelated
related
=
map
.
get
(
one
.
getStaffId
());
one
.
setDepartmentIds
(
Objects
.
isNull
(
related
)
?
null
:
related
.
getDepartmentId
());
// 关联状态
one
.
setRelationFlag
(
relationStaffSet
.
contains
(
one
.
getStaffId
())
?
1
:
0
);
});
return
page
;
}
private
Set
<
String
>
filterByRelationFlag
(
Set
<
String
>
sourceStaffSet
,
Set
<
String
>
relationStaffSet
,
Integer
relationFlag
)
{
// 为空默认全部
if
(
Objects
.
isNull
(
relationFlag
))
{
return
sourceStaffSet
;
}
// 已关联 1 未关联 0
if
(
relationFlag
==
1
)
{
// 已关联用已关联id查询
return
relationStaffSet
;
}
// 未关联 0 , 取原集合与关联集合的-差集
boolean
b
=
sourceStaffSet
.
removeAll
(
relationStaffSet
);
// 差集处理成功返回
return
b
?
sourceStaffSet
:
new
HashSet
<>();
}
@Override
public
List
<
StaffDTO
>
listByIds
(
List
<
String
>
staffIds
)
{
if
(
CollectionUtil
.
isEmpty
(
staffIds
))
{
if
(
CollectionUtil
.
isEmpty
(
staffIds
))
{
return
new
ArrayList
<
StaffDTO
>();
}
List
<
TabHaobanStaff
>
staffs
=
staffMapper
.
listByIds
(
staffIds
);
if
(
CollectionUtil
.
isNotEmpty
(
staffs
))
{
if
(
CollectionUtil
.
isNotEmpty
(
staffs
))
{
List
<
StaffDTO
>
resultList
=
EntityUtil
.
changeEntityListByJSON
(
StaffDTO
.
class
,
staffs
);
return
resultList
;
}
else
{
}
else
{
return
new
ArrayList
<
StaffDTO
>();
}
}
...
...
@@ -243,16 +275,16 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public
void
del
(
String
staffDepartmentStaffRelatedId
)
{
StaffDepartmentRelatedDTO
related
=
staffDepartmentRelatedService
.
getById
(
staffDepartmentStaffRelatedId
);
if
(
related
!=
null
)
{
if
(
related
!=
null
)
{
List
<
TabHaobanStaffDepartmentRelated
>
relatedList
=
staffDepartmentRelatedService
.
listStaffDepartmentByStaffId
(
related
.
getStaffId
());
if
(
relatedList
==
null
||
relatedList
.
isEmpty
())
{
if
(
relatedList
==
null
||
relatedList
.
isEmpty
())
{
return
;
}
//只在当前门店
if
(
relatedList
.
size
()
==
1
)
{
if
(
relatedList
.
size
()
==
1
)
{
TabHaobanStaff
staff
=
staffService
.
selectById
(
relatedList
.
get
(
0
).
getStaffId
());
WxEnterpriseDTO
enterpriseDTO
=
wxEnterpriseService
.
selectById
(
staff
.
getWxEnterpriseId
());
if
(
enterpriseDTO
!=
null
)
{
if
(
enterpriseDTO
!=
null
)
{
ServiceResponse
delQywxStaff
=
delQywxStaff
(
staff
,
enterpriseDTO
);
// JSONResponse jp = qywxUserApiService.deleteSelfWorkWxUser(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), staff.getWxUserId());
logger
.
info
(
"【删除成员】{} ,jp={}"
,
staffDepartmentStaffRelatedId
,
JSON
.
toJSONString
(
delQywxStaff
));
...
...
@@ -264,19 +296,19 @@ public class StaffApiServiceImpl implements StaffApiService {
// staffService.delByuserid(relatedList.get(0).getStaffId());
TabHaobanStaffDepartmentRelated
staffRelated
=
relatedList
.
get
(
0
);
if
(
StringUtils
.
isNotBlank
(
staffRelated
.
getClerkCode
()))
{
if
(
StringUtils
.
isNotBlank
(
staffRelated
.
getClerkCode
()))
{
cleanGicClerk
(
staffRelated
.
getClerkCode
(),
related
.
getDepartmentId
());
}
//走修改流程
}
else
{
}
else
{
String
departmentIds
=
""
;
for
(
TabHaobanStaffDepartmentRelated
tabHaobanStaffDepartmentRelated
:
relatedList
)
{
if
(!
staffDepartmentStaffRelatedId
.
equals
(
tabHaobanStaffDepartmentRelated
.
getStaffDepartmentRelatedId
()))
{
if
(!
staffDepartmentStaffRelatedId
.
equals
(
tabHaobanStaffDepartmentRelated
.
getStaffDepartmentRelatedId
()))
{
departmentIds
+=
tabHaobanStaffDepartmentRelated
.
getDepartmentId
()
+
","
;
}
}
if
(
StringUtils
.
isNotBlank
(
departmentIds
))
{
departmentIds
=
departmentIds
.
substring
(
0
,
departmentIds
.
length
()
-
1
);
if
(
StringUtils
.
isNotBlank
(
departmentIds
))
{
departmentIds
=
departmentIds
.
substring
(
0
,
departmentIds
.
length
()
-
1
);
}
TabHaobanStaff
staff
=
staffService
.
selectById
(
relatedList
.
get
(
0
).
getStaffId
());
staffEdit
(
EntityUtil
.
changeEntityByJSON
(
StaffDTO
.
class
,
staff
),
departmentIds
);
...
...
@@ -285,31 +317,31 @@ public class StaffApiServiceImpl implements StaffApiService {
}
@Override
public
void
cleanGicClerk
(
String
code
,
String
departmentId
)
{
public
void
cleanGicClerk
(
String
code
,
String
departmentId
)
{
if
(
true
)
{
return
;
}
if
(
StringUtils
.
isNotBlank
(
code
))
{
if
(
StringUtils
.
isNotBlank
(
code
))
{
TabHaobanDepartment
department
=
departmentService
.
selectById
(
departmentId
);
String
enterpriseId
=
""
;
if
(
department
.
getIsStore
()
==
0
)
{
if
(
department
.
getIsStore
()
==
0
)
{
com
.
gic
.
enterprise
.
api
.
dto
.
DepartmentDTO
dto
=
gicDepartmentService
.
getDeptment
(
department
.
getRelatedId
());
if
(
dto
==
null
)
{
if
(
dto
==
null
)
{
StoreGroupDTO
group
=
storeGroupService
.
getStoreGroupById
(
department
.
getRelatedId
());
if
(
group
!=
null
)
{
if
(
group
!=
null
)
{
enterpriseId
=
group
.
getEnterpriseId
();
}
}
else
{
}
else
{
enterpriseId
=
dto
.
getEnterpriseId
();
}
}
else
{
}
else
{
StoreDTO
store
=
storeService
.
getStore
(
department
.
getRelatedId
());
enterpriseId
=
store
.
getEnterpriseId
();
}
ClerkDTO
clerkDTO
=
clerkService
.
getClerkByCodeNoStatus
(
enterpriseId
,
code
);
if
(
clerkDTO
!=
null
)
{
if
(!
clerkDTO
.
getPhoneNumber
().
equals
(
"--"
)
&&
StringUtils
.
isNotBlank
(
clerkDTO
.
getPhoneNumber
()))
{
logger
.
info
(
"【员工修改】clerkDTO={}"
,
JSON
.
toJSONString
(
clerkDTO
));
ClerkDTO
clerkDTO
=
clerkService
.
getClerkByCodeNoStatus
(
enterpriseId
,
code
);
if
(
clerkDTO
!=
null
)
{
if
(!
clerkDTO
.
getPhoneNumber
().
equals
(
"--"
)
&&
StringUtils
.
isNotBlank
(
clerkDTO
.
getPhoneNumber
()))
{
logger
.
info
(
"【员工修改】clerkDTO={}"
,
JSON
.
toJSONString
(
clerkDTO
));
clerkDTO
.
setPhoneNumber
(
"--"
);
clerkService
.
updateClerk
(
clerkDTO
);
}
...
...
@@ -319,17 +351,17 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public
ServiceResponse
getWxSaveNew
(
String
userId
,
String
wxEnterpriseId
)
{
ServiceResponse
res
=
new
ServiceResponse
();
ServiceResponse
res
=
new
ServiceResponse
();
WxEnterpriseDTO
enterpriseDTO
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
if
(
null
==
enterpriseDTO
)
{
logger
.
info
(
"企业不存在:{}:{}"
,
wxEnterpriseId
,
userId
);
logger
.
info
(
"企业不存在:{}:{}"
,
wxEnterpriseId
,
userId
);
res
.
setMessage
(
"企业不存在"
);
res
.
setCode
(
2
);
return
res
;
}
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
enterpriseDTO
.
getWxEnterpriseId
(),
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
());
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()==
0
)
{
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
logger
.
info
(
"没有配置secret:{}"
,
JSONObject
.
toJSONString
(
enterpriseDTO
));
res
.
setMessage
(
"没有配置secret"
);
res
.
setCode
(
4
);
...
...
@@ -337,19 +369,19 @@ public class StaffApiServiceImpl implements StaffApiService {
}
UserDTO
user
=
qywxUserApiService
.
getSelfWorkWxUser
(
enterpriseDTO
.
getCorpid
(),
secretSetting
.
getSecretVal
(),
userId
);
if
(
null
==
user
)
{
logger
.
info
(
"企业微信用户不存在:{}:{}"
,
wxEnterpriseId
,
userId
);
logger
.
info
(
"企业微信用户不存在:{}:{}"
,
wxEnterpriseId
,
userId
);
res
.
setMessage
(
"企业微信用户不存在"
);
res
.
setCode
(
3
);
return
res
;
}
String
imageUrl
=
changeHeaderImageUrl
(
user
.
getAvatar
());
TabHaobanStaff
staff
=
staffService
.
selectByUserIdAndEnterpriseId
(
userId
,
wxEnterpriseId
);
staff
=
(
staff
==
null
?
new
TabHaobanStaff
():
staff
);
TabHaobanStaff
staff
=
staffService
.
selectByUserIdAndEnterpriseId
(
userId
,
wxEnterpriseId
);
staff
=
(
staff
==
null
?
new
TabHaobanStaff
()
:
staff
);
staff
.
setWxUserId
(
userId
);
staff
.
setUpdateTime
(
new
Date
());
staff
.
setStatusFlag
(
1
);
staff
.
setWxEnterpriseId
(
wxEnterpriseId
);
if
(
StringUtils
.
isNotBlank
(
user
.
getAvatar
()))
{
if
(
StringUtils
.
isNotBlank
(
user
.
getAvatar
()))
{
staff
.
setHeadImg
(
imageUrl
);
}
if
(
StringUtils
.
isNotBlank
(
user
.
getName
()))
{
...
...
@@ -364,75 +396,75 @@ public class StaffApiServiceImpl implements StaffApiService {
String
[]
arr
=
getNationCodeAndPhoneNumber
(
phoneNumber
);
staff
.
setPhoneNumber
(
arr
[
1
]);
staff
.
setNationCode
(
arr
[
0
]);
staff
.
setSex
(
user
.
getGender
()
==
null
?
1
:
Integer
.
parseInt
(
user
.
getGender
()));
staff
.
setSex
(
user
.
getGender
()
==
null
?
1
:
Integer
.
parseInt
(
user
.
getGender
()));
// staff.setActiveFlag(1);
staff
.
setPostion
(
user
.
getPosition
());
staff
.
setExtendPostion
(
user
.
getExternal_position
());
//成员更改或更新
if
(
StringUtils
.
isBlank
(
staff
.
getStaffId
()))
{
if
(
StringUtils
.
isBlank
(
staff
.
getStaffId
()))
{
logger
.
info
(
"新增成员"
);
staff
.
setActiveFlag
(
0
);
staff
.
setCreateTime
(
new
Date
());
staffService
.
add
(
staff
);
}
else
{
}
else
{
staffService
.
updateByPrimaryKey
(
staff
);
}
logger
.
info
(
"门店变更保存:{}"
,
JSONObject
.
toJSONString
(
user
));
staffDepartChange
(
staff
,
wxEnterpriseId
,
user
);
logger
.
info
(
"门店变更保存:{}"
,
JSONObject
.
toJSONString
(
user
));
staffDepartChange
(
staff
,
wxEnterpriseId
,
user
);
return
res
;
}
private
String
[]
getNationCodeAndPhoneNumber
(
String
phoneNumber
)
{
private
String
[]
getNationCodeAndPhoneNumber
(
String
phoneNumber
)
{
String
[]
arr
=
new
String
[
2
];
if
(
StringUtils
.
isBlank
(
phoneNumber
))
{
if
(
StringUtils
.
isBlank
(
phoneNumber
))
{
arr
[
0
]
=
""
;
arr
[
1
]
=
""
;
return
arr
;
}
arr
[
0
]
=
"86"
;
arr
[
1
]
=
phoneNumber
;
if
(
phoneNumber
.
startsWith
(
"+853"
))
{
if
(
phoneNumber
.
startsWith
(
"+853"
))
{
arr
[
0
]
=
"853"
;
arr
[
1
]
=
phoneNumber
.
replace
(
"+853"
,
""
);
}
if
(
phoneNumber
.
startsWith
(
"+852"
))
{
if
(
phoneNumber
.
startsWith
(
"+852"
))
{
arr
[
0
]
=
"852"
;
arr
[
1
]
=
phoneNumber
.
replace
(
"+852"
,
""
);
}
if
(
phoneNumber
.
startsWith
(
"+886"
))
{
if
(
phoneNumber
.
startsWith
(
"+886"
))
{
arr
[
0
]
=
"886"
;
arr
[
1
]
=
phoneNumber
.
replace
(
"+886"
,
""
);
}
if
(
phoneNumber
.
startsWith
(
"+65"
))
{
if
(
phoneNumber
.
startsWith
(
"+65"
))
{
arr
[
0
]
=
"65"
;
arr
[
1
]
=
phoneNumber
.
replace
(
"+65"
,
""
);
}
if
(
phoneNumber
.
startsWith
(
"+66"
))
{
if
(
phoneNumber
.
startsWith
(
"+66"
))
{
arr
[
0
]
=
"66"
;
arr
[
1
]
=
phoneNumber
.
replace
(
"+66"
,
""
);
}
return
arr
;
}
private
void
staffDepartChange
(
TabHaobanStaff
staff
,
String
wxEnterpriseId
,
UserDTO
user
)
{
private
void
staffDepartChange
(
TabHaobanStaff
staff
,
String
wxEnterpriseId
,
UserDTO
user
)
{
//更新部门
Integer
[]
departmentIds
=
user
.
getDepartment
();
List
<
String
>
wxDepartIds
=
new
ArrayList
<>();
for
(
Integer
wDId:
departmentIds
)
{
List
<
String
>
wxDepartIds
=
new
ArrayList
<>();
for
(
Integer
wDId
:
departmentIds
)
{
wxDepartIds
.
add
(
wDId
.
toString
());
}
//关联部门
List
<
DepartmentDTO
>
departmentDTOList
=
departmentService
.
listDepartmentByWxDepartIds
(
wxEnterpriseId
,
wxDepartIds
);
if
(
CollectionUtils
.
isEmpty
(
departmentDTOList
))
{
logger
.
info
(
"部门没有更新或同步:{}"
,
wxEnterpriseId
);
return
;
logger
.
info
(
"部门没有更新或同步:{}"
,
wxEnterpriseId
);
return
;
}
//已存在部门
List
<
TabHaobanStaffDepartmentRelated
>
hasRelation
=
staffDepartmentRelatedService
.
listStaffDepartmentByStaffId
(
staff
.
getStaffId
());
Map
<
String
,
TabHaobanStaffDepartmentRelated
>
hasRelationMap
=
new
HashMap
<>();
Map
<
String
,
TabHaobanStaffDepartmentRelated
>
hasRelationMap
=
new
HashMap
<>();
if
(
CollectionUtils
.
isNotEmpty
(
hasRelation
))
{
hasRelationMap
=
hasRelation
.
stream
().
collect
(
Collectors
.
toMap
(
TabHaobanStaffDepartmentRelated:
:
getDepartmentId
,
tab
->
tab
));
}
...
...
@@ -458,10 +490,10 @@ public class StaffApiServiceImpl implements StaffApiService {
Set
<
String
>
newDepartIds
=
departmentDTOList
.
stream
().
map
(
DepartmentDTO:
:
getDepartmentId
).
collect
(
Collectors
.
toSet
());
Set
<
String
>
hasDepartIds
=
hasRelationMap
.
keySet
();
Sets
.
SetView
<
String
>
delDepartIds
=
Sets
.
difference
(
hasDepartIds
,
newDepartIds
);
Sets
.
SetView
<
String
>
updateDepartIds
=
Sets
.
intersection
(
newDepartIds
,
hasDepartIds
);
//交集
logger
.
info
(
"删除部门:{}"
,
JSONObject
.
toJSONString
(
delDepartIds
));
Sets
.
SetView
<
String
>
updateDepartIds
=
Sets
.
intersection
(
newDepartIds
,
hasDepartIds
);
//交集
logger
.
info
(
"删除部门:{}"
,
JSONObject
.
toJSONString
(
delDepartIds
));
if
(!
delDepartIds
.
isEmpty
())
{
delDepartIds
.
forEach
(
delDepartId
->
{
delDepartIds
.
forEach
(
delDepartId
->
{
TabHaobanStaffDepartmentRelated
departmentRelated
=
finalHasRelationMap
.
get
(
delDepartId
);
if
(
null
!=
departmentRelated
)
{
StaffDepartmentRelatedDTO
relatedDTO
=
new
StaffDepartmentRelatedDTO
();
...
...
@@ -472,7 +504,7 @@ public class StaffApiServiceImpl implements StaffApiService {
}
if
(!
updateDepartIds
.
isEmpty
())
{
updateDepartIds
.
forEach
(
updateDeId
->
{
updateDepartIds
.
forEach
(
updateDeId
->
{
TabHaobanStaffDepartmentRelated
departmentRelated
=
finalHasRelationMap
.
get
(
updateDeId
);
if
(
null
!=
departmentRelated
)
{
departmentRelated
.
setPhoneNumber
(
staff
.
getPhoneNumber
());
...
...
@@ -487,38 +519,38 @@ public class StaffApiServiceImpl implements StaffApiService {
}
@Override
public
void
wxGetAdd
(
String
userId
,
String
wxEnterpriseId
)
{
public
void
wxGetAdd
(
String
userId
,
String
wxEnterpriseId
)
{
RedisUtil
.
lock
(
"haoban_add_user"
+
wxEnterpriseId
+
userId
,
2
l
);
ServiceResponse
wxSaveNew
=
getWxSaveNew
(
userId
,
wxEnterpriseId
);
logger
.
info
(
"信息:{}"
,
JSONObject
.
toJSONString
(
wxSaveNew
));
logger
.
info
(
"信息:{}"
,
JSONObject
.
toJSONString
(
wxSaveNew
));
}
@Deprecated
public
void
wxGetAddOld
(
String
userId
,
String
wxEnterpriseId
)
{
public
void
wxGetAddOld
(
String
userId
,
String
wxEnterpriseId
)
{
//获取微信用户信息
TabHaobanStaff
staff
=
staffService
.
selectByUserIdAndEnterpriseId
(
userId
,
wxEnterpriseId
);
if
(
staff
==
null
)
{
TabHaobanStaff
staff
=
staffService
.
selectByUserIdAndEnterpriseId
(
userId
,
wxEnterpriseId
);
if
(
staff
==
null
)
{
WxEnterpriseDTO
enterpriseDTO
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
if
(
enterpriseDTO
!=
null
)
{
if
(
enterpriseDTO
!=
null
)
{
Date
now
=
new
Date
();
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
wxEnterpriseId
,
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
());
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()==
0
)
{
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
logger
.
info
(
"没有配置secret"
);
return
;
return
;
}
UserDTO
user
=
qywxUserApiService
.
getSelfWorkWxUser
(
enterpriseDTO
.
getCorpid
(),
secretSetting
.
getSecretVal
(),
userId
);
if
(
user
==
null
)
{
if
(
user
==
null
)
{
return
;
}
logger
.
info
(
"【新增用户】user={}"
,
JSON
.
toJSONString
(
user
));
logger
.
info
(
"【新增用户】user={}"
,
JSON
.
toJSONString
(
user
));
TabHaobanStaff
tab
=
new
TabHaobanStaff
();
tab
.
setWxUserId
(
userId
);
tab
.
setCreateTime
(
now
);
tab
.
setUpdateTime
(
now
);
tab
.
setStatusFlag
(
1
);
tab
.
setWxEnterpriseId
(
wxEnterpriseId
);
if
(
StringUtils
.
isNotBlank
(
user
.
getAvatar
()))
{
if
(
StringUtils
.
isNotBlank
(
user
.
getAvatar
()))
{
tab
.
setHeadImg
(
changeHeaderImageUrl
(
user
.
getAvatar
()));
}
tab
.
setPhoneNumber
(
user
.
getMobile
());
...
...
@@ -532,11 +564,11 @@ public class StaffApiServiceImpl implements StaffApiService {
}
// tab.setNickName(user.getAlias());
tab
.
setNationCode
(
"86"
);
tab
.
setSex
(
user
.
getGender
()
==
null
?
1
:
Integer
.
parseInt
(
user
.
getGender
()));
tab
.
setSex
(
user
.
getGender
()
==
null
?
1
:
Integer
.
parseInt
(
user
.
getGender
()));
tab
.
setActiveFlag
(
1
);
tab
.
setPostion
(
user
.
getPosition
());
tab
.
setExtendPostion
(
user
.
getExternal_position
());
if
(
user
.
getStatus
()
!=
null
&&
user
.
getStatus
()
==
1
)
{
if
(
user
.
getStatus
()
!=
null
&&
user
.
getStatus
()
==
1
)
{
tab
.
setActiveFlag
(
1
);
}
else
{
tab
.
setActiveFlag
(
0
);
...
...
@@ -546,9 +578,9 @@ public class StaffApiServiceImpl implements StaffApiService {
Integer
[]
departmentId
=
user
.
getDepartment
();
for
(
Integer
integer
:
departmentId
)
{
TabHaobanDepartment
tabDepartment
=
departmentService
.
getByWxId
(
integer
.
toString
(),
wxEnterpriseId
);
if
(
tabDepartment
!=
null
)
{
if
(
tabDepartment
!=
null
)
{
TabHaobanStaffDepartmentRelated
tabStaff
=
staffDepartmentRelatedService
.
getDepartmentIdAndStaffId
(
tabDepartment
.
getDepartmentId
(),
tab
.
getStaffId
());
if
(
tabStaff
==
null
)
{
if
(
tabStaff
==
null
)
{
StaffDepartmentRelatedDTO
dto
=
new
StaffDepartmentRelatedDTO
();
dto
.
setPhoneNumber
(
user
.
getMobile
());
dto
.
setWxUserId
(
userId
);
...
...
@@ -564,38 +596,38 @@ public class StaffApiServiceImpl implements StaffApiService {
}
}
}
}
else
{
}
else
{
WxEnterpriseDTO
enterpriseDTO
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
if
(
enterpriseDTO
!=
null
)
{
if
(
enterpriseDTO
!=
null
)
{
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
enterpriseDTO
.
getWxEnterpriseId
(),
SecretTypeEnum
.
CONTACT_SECRET
.
getVal
());
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()==
0
)
{
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
logger
.
info
(
"没有设置通讯录secret"
);
return
;
return
;
}
UserDTO
user
=
qywxUserApiService
.
getSelfWorkWxUser
(
enterpriseDTO
.
getCorpid
(),
secretSetting
.
getSecretVal
(),
userId
);
logger
.
info
(
"【修改用户】user={}"
,
JSON
.
toJSONString
(
user
));
logger
.
info
(
"【修改用户】user={}"
,
JSON
.
toJSONString
(
user
));
Integer
[]
departmentId
=
user
.
getDepartment
();
String
departmentIds
=
""
;
for
(
Integer
integer
:
departmentId
)
{
TabHaobanDepartment
tabDepartment
=
departmentService
.
getByWxId
(
integer
.
toString
(),
wxEnterpriseId
);
if
(
tabDepartment
!=
null
)
{
if
(
tabDepartment
!=
null
)
{
departmentIds
+=
tabDepartment
.
getDepartmentId
()
+
","
;
}
}
if
(
StringUtils
.
isNotBlank
(
departmentIds
))
{
departmentIds
=
departmentIds
.
substring
(
0
,
departmentIds
.
length
()
-
1
);
if
(
StringUtils
.
isNotBlank
(
departmentIds
))
{
departmentIds
=
departmentIds
.
substring
(
0
,
departmentIds
.
length
()
-
1
);
}
StaffDTO
staffDTO
=
EntityUtil
.
changeEntityByJSON
(
StaffDTO
.
class
,
staff
);
staffDTO
.
setWeixinPush
(
true
);
if
(
StringUtils
.
isBlank
(
staffDTO
.
getPhoneNumber
()))
{
if
(
StringUtils
.
isBlank
(
staffDTO
.
getPhoneNumber
()))
{
staffDTO
.
setPhoneNumber
(
user
.
getMobile
());
staffDTO
.
setSex
(
StringUtils
.
isBlank
(
user
.
getGender
())?
null
:
Integer
.
parseInt
(
user
.
getGender
()));
staffDTO
.
setSex
(
StringUtils
.
isBlank
(
user
.
getGender
())
?
null
:
Integer
.
parseInt
(
user
.
getGender
()));
staffDTO
.
setHeadImg
(
user
.
getAvatar
());
staffDTO
.
setPostion
(
user
.
getPosition
());
staffDTO
.
setNickName
(
user
.
getAlias
());
staffDTO
.
setExtendPostion
(
user
.
getExternal_position
());
Integer
status
=
user
.
getStatus
();
if
(
status
!=
null
&&
status
==
2
)
{
if
(
status
!=
null
&&
status
==
2
)
{
staffDTO
.
setActiveFlag
(
1
);
}
}
...
...
@@ -608,27 +640,27 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public
void
wxFristAdd
(
String
userJson
,
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isBlank
(
userJson
))
{
public
void
wxFristAdd
(
String
userJson
,
String
wxEnterpriseId
)
{
if
(
StringUtils
.
isBlank
(
userJson
))
{
return
;
}
UserDTO
user
=
JSON
.
parseObject
(
userJson
,
UserDTO
.
class
);
UserDTO
user
=
JSON
.
parseObject
(
userJson
,
UserDTO
.
class
);
//获取微信用户信息
String
userId
=
user
.
getUserid
();
TabHaobanStaff
staff
=
staffService
.
selectByUserIdAndEnterpriseId
(
userId
,
wxEnterpriseId
);
if
(
staff
==
null
)
{
TabHaobanStaff
staff
=
staffService
.
selectByUserIdAndEnterpriseId
(
userId
,
wxEnterpriseId
);
if
(
staff
==
null
)
{
WxEnterpriseDTO
enterpriseDTO
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
if
(
enterpriseDTO
!=
null
)
{
if
(
enterpriseDTO
!=
null
)
{
Date
now
=
new
Date
();
//UserDTO user = qywxUserApiService.getSelfWorkWxUser(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), userId);
logger
.
info
(
"【新增用户】user={}"
,
JSON
.
toJSONString
(
user
));
logger
.
info
(
"【新增用户】user={}"
,
JSON
.
toJSONString
(
user
));
TabHaobanStaff
tab
=
new
TabHaobanStaff
();
tab
.
setWxUserId
(
userId
);
tab
.
setCreateTime
(
now
);
tab
.
setUpdateTime
(
now
);
tab
.
setStatusFlag
(
1
);
tab
.
setWxEnterpriseId
(
wxEnterpriseId
);
if
(
StringUtils
.
isNotBlank
(
user
.
getAvatar
()))
{
if
(
StringUtils
.
isNotBlank
(
user
.
getAvatar
()))
{
tab
.
setHeadImg
(
changeHeaderImageUrl
(
user
.
getAvatar
()));
}
tab
.
setPhoneNumber
(
user
.
getMobile
());
...
...
@@ -642,11 +674,11 @@ public class StaffApiServiceImpl implements StaffApiService {
}
// tab.setNickName(user.getAlias());
tab
.
setNationCode
(
"86"
);
tab
.
setSex
(
user
.
getGender
()
==
null
?
1
:
Integer
.
parseInt
(
user
.
getGender
()));
tab
.
setSex
(
user
.
getGender
()
==
null
?
1
:
Integer
.
parseInt
(
user
.
getGender
()));
tab
.
setActiveFlag
(
1
);
tab
.
setPostion
(
user
.
getPosition
());
tab
.
setExtendPostion
(
user
.
getExternal_position
());
if
(
user
.
getStatus
()
!=
null
&&
user
.
getStatus
()
==
1
)
{
if
(
user
.
getStatus
()
!=
null
&&
user
.
getStatus
()
==
1
)
{
tab
.
setActiveFlag
(
1
);
}
else
{
tab
.
setActiveFlag
(
0
);
...
...
@@ -674,21 +706,21 @@ public class StaffApiServiceImpl implements StaffApiService {
// }
// }
}
}
else
{
}
else
{
WxEnterpriseDTO
enterpriseDTO
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
if
(
enterpriseDTO
!=
null
)
{
if
(
enterpriseDTO
!=
null
)
{
//UserDTO user = qywxUserApiService.getSelfWorkWxUser(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), userId);
logger
.
info
(
"【修改用户】user={}"
,
JSON
.
toJSONString
(
user
));
logger
.
info
(
"【修改用户】user={}"
,
JSON
.
toJSONString
(
user
));
Integer
[]
departmentId
=
user
.
getDepartment
();
String
departmentIds
=
""
;
for
(
Integer
integer
:
departmentId
)
{
TabHaobanDepartment
tabDepartment
=
departmentService
.
getByWxId
(
integer
.
toString
(),
wxEnterpriseId
);
if
(
tabDepartment
!=
null
)
{
if
(
tabDepartment
!=
null
)
{
departmentIds
+=
tabDepartment
.
getDepartmentId
()
+
","
;
}
}
if
(
StringUtils
.
isNotBlank
(
departmentIds
))
{
departmentIds
=
departmentIds
.
substring
(
0
,
departmentIds
.
length
()
-
1
);
if
(
StringUtils
.
isNotBlank
(
departmentIds
))
{
departmentIds
=
departmentIds
.
substring
(
0
,
departmentIds
.
length
()
-
1
);
}
StaffDTO
staffDTO
=
EntityUtil
.
changeEntityByJSON
(
StaffDTO
.
class
,
staff
);
staffDTO
.
setWeixinPush
(
true
);
...
...
@@ -700,20 +732,20 @@ public class StaffApiServiceImpl implements StaffApiService {
private
void
staffEditDeal
(
StaffDTO
staffDTO
,
String
departmentIds
,
boolean
syncGic
)
{
TabHaobanStaff
oldStaff
=
staffMapper
.
selectByPrimaryKey
(
staffDTO
.
getStaffId
());
logger
.
info
(
"【员工修改】oldStaff={}"
,
JSON
.
toJSONString
(
oldStaff
));
logger
.
info
(
"【员工修改】oldStaff={}"
,
JSON
.
toJSONString
(
oldStaff
));
//1、先更新staff
logger
.
info
(
"【员工修改】staffDTO={}"
,
JSON
.
toJSONString
(
staffDTO
));
logger
.
info
(
"【员工修改】staffDTO={}"
,
JSON
.
toJSONString
(
staffDTO
));
TabHaobanStaff
tab
=
EntityUtil
.
changeEntityByJSON
(
TabHaobanStaff
.
class
,
staffDTO
);
staffService
.
updateByPrimaryKey
(
tab
);
String
staffName
=
tab
.
getStaffName
();
List
<
TabHaobanStaffDepartmentRelated
>
list
=
staffDepartmentRelatedService
.
listStaffDepartmentByStaffId
(
staffDTO
.
getStaffId
());
Map
<
String
,
TabHaobanStaffDepartmentRelated
>
map
=
com
.
gic
.
commons
.
util
.
CollectionUtil
.
toMap
(
list
,
"departmentId"
);
Map
<
String
,
TabHaobanStaffDepartmentRelated
>
map
=
com
.
gic
.
commons
.
util
.
CollectionUtil
.
toMap
(
list
,
"departmentId"
);
//2、该员工新增部门
if
(
StringUtils
.
isNotBlank
(
departmentIds
))
{
String
[]
addIds
=
departmentIds
.
split
(
","
);
for
(
String
addId
:
addIds
)
{
if
(!
map
.
containsKey
(
addId
))
{
if
(
StringUtils
.
isNotBlank
(
departmentIds
))
{
String
[]
addIds
=
departmentIds
.
split
(
","
);
for
(
String
addId
:
addIds
)
{
if
(!
map
.
containsKey
(
addId
))
{
//该员工新增了部门
StaffDepartmentRelatedDTO
related
=
new
StaffDepartmentRelatedDTO
();
related
.
setStaffDepartmentRelatedId
(
UuidUtil
.
randomUUID
());
...
...
@@ -729,10 +761,10 @@ public class StaffApiServiceImpl implements StaffApiService {
related
.
setWxEnterpriseId
(
staffDTO
.
getWxEnterpriseId
());
related
.
setStaffName
(
staffName
);
staffDepartmentRelatedService
.
add
(
related
);
}
else
{
}
else
{
//该员工部门没做改变(只更新手机号即可)
TabHaobanStaffDepartmentRelated
related
=
map
.
get
(
addId
);
if
(!
staffDTO
.
getPhoneNumber
().
equals
(
related
.
getPhoneNumber
()))
{
if
(!
staffDTO
.
getPhoneNumber
().
equals
(
related
.
getPhoneNumber
()))
{
related
.
setPhoneNumber
(
staffDTO
.
getPhoneNumber
());
related
.
setNationCode
(
staffDTO
.
getNationCode
());
related
.
setUpdateTime
(
new
Date
());
...
...
@@ -746,13 +778,13 @@ public class StaffApiServiceImpl implements StaffApiService {
}
}
//3、该员工删除部门
for
(
TabHaobanStaffDepartmentRelated
tab1
:
list
)
{
if
(
departmentIds
==
null
)
{
for
(
TabHaobanStaffDepartmentRelated
tab1
:
list
)
{
if
(
departmentIds
==
null
)
{
departmentIds
=
""
;
}
//不包含,则说明员工删除了该部门
if
(!
departmentIds
.
contains
(
tab1
.
getDepartmentId
()))
{
logger
.
info
(
"【员工修改删除】tab1.getDepartmentId()={}"
,
tab1
.
getDepartmentId
());
if
(!
departmentIds
.
contains
(
tab1
.
getDepartmentId
()))
{
logger
.
info
(
"【员工修改删除】tab1.getDepartmentId()={}"
,
tab1
.
getDepartmentId
());
StaffDepartmentRelatedDTO
related
=
EntityUtil
.
changeEntityByJSON
(
StaffDepartmentRelatedDTO
.
class
,
tab1
);
staffDepartmentRelatedService
.
del
(
related
);
// if(org.apache.commons.lang3.StringUtils.isNotBlank(tab1.getClerkCode())){
...
...
@@ -762,38 +794,38 @@ public class StaffApiServiceImpl implements StaffApiService {
}
Boolean
weixinPush
=
staffDTO
.
getWeixinPush
();
if
(
weixinPush
==
null
||
!
weixinPush
)
{
if
(
weixinPush
==
null
||
!
weixinPush
)
{
updateWxMessage
(
oldStaff
,
staffDTO
,
departmentIds
);
}
}
private
void
wxStaffEdit
(
StaffDTO
staffDTO
,
String
departmentIds
)
{
private
void
wxStaffEdit
(
StaffDTO
staffDTO
,
String
departmentIds
)
{
staffDTO
.
setWeixinPush
(
true
);
staffEditDeal
(
staffDTO
,
departmentIds
,
false
);
}
private
void
updateGicClerk
(
TabHaobanStaff
oldStaff
,
StaffDTO
staffDTO
,
String
departmentId
,
TabHaobanStaffDepartmentRelated
related
)
{
logger
.
info
(
"【员工修改】oldName={},name={},oldPhoneNumber={},phoneNumber={}"
,
oldStaff
.
getStaffName
(),
staffDTO
.
getStaffName
(),
oldStaff
.
getPhoneNumber
(),
staffDTO
.
getPhoneNumber
());
private
void
updateGicClerk
(
TabHaobanStaff
oldStaff
,
StaffDTO
staffDTO
,
String
departmentId
,
TabHaobanStaffDepartmentRelated
related
)
{
logger
.
info
(
"【员工修改】oldName={},name={},oldPhoneNumber={},phoneNumber={}"
,
oldStaff
.
getStaffName
(),
staffDTO
.
getStaffName
(),
oldStaff
.
getPhoneNumber
(),
staffDTO
.
getPhoneNumber
());
String
staffName
=
staffDTO
.
getStaffName
();
TabHaobanDepartment
department
=
departmentService
.
selectById
(
departmentId
);
if
(
department
==
null
)
{
if
(
department
==
null
)
{
return
;
}
String
enterpriseId
=
""
;
if
(
department
.
getIsStore
()
==
null
||
department
.
getIsStore
()
==
0
)
{
if
(
department
.
getIsStore
()
==
null
||
department
.
getIsStore
()
==
0
)
{
com
.
gic
.
enterprise
.
api
.
dto
.
DepartmentDTO
dto
=
gicDepartmentService
.
getDeptment
(
department
.
getRelatedId
());
if
(
dto
==
null
)
{
if
(
dto
==
null
)
{
StoreGroupDTO
group
=
storeGroupService
.
getStoreGroupById
(
department
.
getRelatedId
());
if
(
group
!=
null
)
{
if
(
group
!=
null
)
{
enterpriseId
=
group
.
getEnterpriseId
();
}
}
else
{
}
else
{
enterpriseId
=
dto
.
getEnterpriseId
();
}
}
else
{
}
else
{
StoreDTO
store
=
storeService
.
getStore
(
department
.
getRelatedId
());
if
(
store
==
null
)
{
if
(
store
==
null
)
{
return
;
}
enterpriseId
=
store
.
getEnterpriseId
();
...
...
@@ -827,9 +859,9 @@ public class StaffApiServiceImpl implements StaffApiService {
}
private
void
updateWxMessage
(
TabHaobanStaff
oldStaff
,
StaffDTO
staffDTO
,
String
departmentIds
)
{
private
void
updateWxMessage
(
TabHaobanStaff
oldStaff
,
StaffDTO
staffDTO
,
String
departmentIds
)
{
WxEnterpriseDTO
enterpriseDTO
=
wxEnterpriseService
.
selectById
(
oldStaff
.
getWxEnterpriseId
());
if
(
enterpriseDTO
!=
null
)
{
if
(
enterpriseDTO
!=
null
)
{
UserDTO
userDTO
=
new
UserDTO
();
userDTO
.
setCorpid
(
enterpriseDTO
.
getCorpid
());
userDTO
.
setAlias
(
staffDTO
.
getNickName
());
...
...
@@ -840,17 +872,17 @@ public class StaffApiServiceImpl implements StaffApiService {
for
(
String
string
:
departmentIdArr
)
{
TabHaobanDepartment
tabs
=
departmentService
.
selectById
(
string
);
wxDepartmentIdArrIntegers
[
index
]
=
Integer
.
parseInt
(
tabs
.
getWxDepartmentId
());
index
++;
index
++;
}
userDTO
.
setDepartment
(
wxDepartmentIdArrIntegers
);
userDTO
.
setGender
(
staffDTO
.
getSex
()
==
null
?
""
:
staffDTO
.
getSex
().
toString
());
userDTO
.
setGender
(
staffDTO
.
getSex
()
==
null
?
""
:
staffDTO
.
getSex
().
toString
());
userDTO
.
setMobile
(
staffDTO
.
getPhoneNumber
());
userDTO
.
setName
(
staffDTO
.
getStaffName
());
userDTO
.
setUserid
(
oldStaff
.
getWxUserId
());
userDTO
.
setPosition
(
staffDTO
.
getPostion
());
userDTO
.
setExternal_position
(
staffDTO
.
getExtendPostion
());
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
enterpriseDTO
.
getWxEnterpriseId
(),
SecretTypeEnum
.
CONTACT_SECRET
.
getVal
());
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()==
0
)
{
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
throw
new
RuntimeException
(
"没有设置通讯录secret"
);
}
JSONResponse
jp
=
qywxUserApiService
.
updateSelfWorkWxUser
(
userDTO
,
enterpriseDTO
.
getCorpid
(),
secretSetting
.
getSecretVal
());
...
...
@@ -872,13 +904,13 @@ public class StaffApiServiceImpl implements StaffApiService {
}
@Override
public
StaffDTO
selectByUserIdAndEnterpriseId
(
String
userId
,
String
wxEnterpriseId
)
{
return
EntityUtil
.
changeEntityByJSON
(
StaffDTO
.
class
,
staffService
.
selectByUserIdAndEnterpriseId
(
userId
,
wxEnterpriseId
));
public
StaffDTO
selectByUserIdAndEnterpriseId
(
String
userId
,
String
wxEnterpriseId
)
{
return
EntityUtil
.
changeEntityByJSON
(
StaffDTO
.
class
,
staffService
.
selectByUserIdAndEnterpriseId
(
userId
,
wxEnterpriseId
));
}
@Override
public
StaffDepartmentRelatedDTO
getDepartmentIdAndStaffId
(
String
departmentId
,
String
staffId
)
{
TabHaobanStaffDepartmentRelated
tab
=
staffDepartmentRelatedService
.
getDepartmentIdAndStaffId
(
departmentId
,
staffId
);
TabHaobanStaffDepartmentRelated
tab
=
staffDepartmentRelatedService
.
getDepartmentIdAndStaffId
(
departmentId
,
staffId
);
return
EntityUtil
.
changeEntityByJSON
(
StaffDepartmentRelatedDTO
.
class
,
tab
);
}
...
...
@@ -923,18 +955,18 @@ public class StaffApiServiceImpl implements StaffApiService {
Integer
sex
=
clerkDTO
.
getClerkGender
();
String
headPic
=
clerkDTO
.
getHeadImgUrl
();
Integer
status
=
clerkDTO
.
getStatus
();
if
(
status
==
null
)
{
if
(
status
==
null
)
{
status
=
1
;
}
String
postion
=
clerkDTO
.
getPostionName
();
String
enterpriseId
=
clerkDTO
.
getEnterpriseId
();
if
(
StringUtils
.
isBlank
(
gicStoreId
))
{
if
(
StringUtils
.
isBlank
(
gicStoreId
))
{
logger
.
info
(
"【店员同步】gicStoreId为空"
);
return
;
}
TabHaobanDepartment
department
=
departmentService
.
selectByRelatedId
(
gicStoreId
);
if
(
department
==
null
)
{
if
(
department
==
null
)
{
logger
.
info
(
"【店员同步】失败====department为空"
);
return
;
}
...
...
@@ -942,10 +974,10 @@ public class StaffApiServiceImpl implements StaffApiService {
String
wxEnterpriseId
=
department
.
getWxEnterpriseId
();
// StaffDTO staff = this.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber);
StaffDTO
staff
=
geCcheckAndInitUser
(
wxEnterpriseId
,
nationcode
,
phoneNumber
);
if
(
staff
==
null
)
{
if
(
status
!=
1
)
{
if
(
staff
==
null
)
{
if
(
status
!=
1
)
{
return
;
}
else
{
}
else
{
staff
=
new
StaffDTO
();
staff
.
setWxEnterpriseId
(
wxEnterpriseId
);
staff
.
setClerkCode
(
code
);
...
...
@@ -959,69 +991,69 @@ public class StaffApiServiceImpl implements StaffApiService {
staff
.
setStaffName
(
staffName
);
staff
.
setNickName
(
staffName
);
staff
.
setSyncPostionFlag
(
1
);
StaffDepartmentRelatedDTO
isCodeExist
=
this
.
getDepartmentIdAndCode
(
departmentId
,
code
);
logger
.
info
(
"【gic导购新增】isCodeExist={}"
,
JSON
.
toJSONString
(
isCodeExist
));
StaffDepartmentRelatedDTO
isCodeExist
=
this
.
getDepartmentIdAndCode
(
departmentId
,
code
);
logger
.
info
(
"【gic导购新增】isCodeExist={}"
,
JSON
.
toJSONString
(
isCodeExist
));
//如果这个code已经绑定了 先解绑
if
(
isCodeExist
!=
null
)
{
if
(
isCodeExist
!=
null
)
{
isCodeExist
.
setClerkCode
(
null
);
staffDepartmentRelatedMapper
.
updateByPrimaryKey
(
EntityUtil
.
changeEntityByJSON
(
TabHaobanStaffDepartmentRelated
.
class
,
isCodeExist
));
}
ServiceResponse
hr
=
this
.
add
(
staff
,
department
.
getDepartmentId
());
if
(
hr
.
getCode
()
==
1
)
{
if
(
hr
.
getCode
()
==
1
)
{
StaffDepartmentRelatedDTO
staffRelated
=
this
.
getDepartmentIdAndStaffId
(
departmentId
,
hr
.
getResult
().
toString
());
logger
.
info
(
"【gic导购新增】staffRelated={}"
,
JSON
.
toJSONString
(
staffRelated
));
logger
.
info
(
"【gic导购新增】staffRelated={}"
,
JSON
.
toJSONString
(
staffRelated
));
//绑定
if
(
staffRelated
!=
null
)
{
if
(
staffRelated
!=
null
)
{
staffRelated
.
setClerkCode
(
code
);
staffDepartmentRelatedMapper
.
updateByPrimaryKey
(
EntityUtil
.
changeEntityByJSON
(
TabHaobanStaffDepartmentRelated
.
class
,
staffRelated
));
}
}
}
}
else
{
}
else
{
String
staffId
=
staff
.
getStaffId
();
logger
.
info
(
"【员工修改】staff={},status={}"
,
JSON
.
toJSONString
(
staff
),
status
);
logger
.
info
(
"【员工修改】staff={},status={}"
,
JSON
.
toJSONString
(
staff
),
status
);
//删除
if
(
status
==
0
)
{
if
(
status
==
0
)
{
StaffDepartmentRelatedDTO
staffRelated
=
this
.
getDepartmentIdAndStaffId
(
departmentId
,
staffId
);
if
(
staffRelated
!=
null
)
{
if
(
staffRelated
!=
null
)
{
staffRelated
.
setUpdateTime
(
new
Date
());
staffRelated
.
setClerkCode
(
null
);
staffDepartmentRelatedMapper
.
updateByPrimaryKey
(
EntityUtil
.
changeEntityByJSON
(
TabHaobanStaffDepartmentRelated
.
class
,
staffRelated
));
}
//修改
}
else
{
}
else
{
staff
.
setHeadImg
(
headPic
);
staff
.
setSex
(
sex
);
//staff.setPostion(postion);
// staff.setStaffName(staffName);
if
(
staff
.
getActiveFlag
()
!=
null
&&
staff
.
getActiveFlag
()
!=
1
)
{
if
(
staff
.
getActiveFlag
()
!=
null
&&
staff
.
getActiveFlag
()
!=
1
)
{
staff
.
setStaffName
(
staffName
);
}
List
<
StaffDepartmentRelatedDTO
>
relatedList
=
this
.
listStaffDepartmentByStaffId
(
staffId
);
Map
<
String
,
StaffDepartmentRelatedDTO
>
map
=
com
.
gic
.
commons
.
util
.
CollectionUtil
.
toMap
(
relatedList
,
"departmentId"
);
Map
<
String
,
StaffDepartmentRelatedDTO
>
map
=
com
.
gic
.
commons
.
util
.
CollectionUtil
.
toMap
(
relatedList
,
"departmentId"
);
String
departmentIds
=
""
;
if
(
map
.
get
(
departmentId
)
==
null
)
{
if
(
map
.
get
(
departmentId
)
==
null
)
{
departmentIds
=
departmentId
;
}
for
(
StaffDepartmentRelatedDTO
staffDepartmentRelatedDTO
:
relatedList
)
{
departmentIds
+=
","
+
staffDepartmentRelatedDTO
.
getDepartmentId
();
}
if
(
departmentIds
.
startsWith
(
","
))
{
departmentIds
=
departmentIds
.
substring
(
1
,
departmentIds
.
length
());
if
(
departmentIds
.
startsWith
(
","
))
{
departmentIds
=
departmentIds
.
substring
(
1
,
departmentIds
.
length
());
}
if
(
map
.
get
(
departmentId
)
==
null
)
{
if
(
map
.
get
(
departmentId
)
==
null
)
{
this
.
staffEditDeal
(
staff
,
departmentIds
,
true
);
}
StaffDepartmentRelatedDTO
staffRelated
=
this
.
getDepartmentIdAndStaffId
(
departmentId
,
staffId
);
StaffDepartmentRelatedDTO
isCodeExist
=
this
.
getDepartmentIdAndCode
(
departmentId
,
code
);
StaffDepartmentRelatedDTO
isCodeExist
=
this
.
getDepartmentIdAndCode
(
departmentId
,
code
);
//如果这个人已经绑定了 先解绑
if
(
isCodeExist
!=
null
)
{
if
(
isCodeExist
!=
null
)
{
staffRelated
.
setUpdateTime
(
new
Date
());
isCodeExist
.
setClerkCode
(
null
);
staffDepartmentRelatedMapper
.
updateByPrimaryKey
(
EntityUtil
.
changeEntityByJSON
(
TabHaobanStaffDepartmentRelated
.
class
,
isCodeExist
));
}
//如果这个人是未绑定的 则绑定clerk
if
(
staffRelated
!=
null
)
{
if
(
staffRelated
!=
null
)
{
staffRelated
.
setUpdateTime
(
new
Date
());
staffRelated
.
setClerkCode
(
code
);
staffDepartmentRelatedMapper
.
updateByPrimaryKey
(
EntityUtil
.
changeEntityByJSON
(
TabHaobanStaffDepartmentRelated
.
class
,
staffRelated
));
...
...
@@ -1048,12 +1080,12 @@ public class StaffApiServiceImpl implements StaffApiService {
}
WxEnterpriseDTO
enterpriseDTO
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
if
(
null
==
enterpriseDTO
)
{
if
(
null
==
enterpriseDTO
)
{
return
null
;
}
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
wxEnterpriseId
,
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
());
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()==
0
)
{
logger
.
info
(
"没有配置secret:{}"
,
wxEnterpriseId
);
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
logger
.
info
(
"没有配置secret:{}"
,
wxEnterpriseId
);
return
null
;
}
String
userId
=
qywxUserApiService
.
getSelfWxUserIdByPhonenumber
(
enterpriseDTO
.
getCorpid
(),
secretSetting
.
getSecretVal
(),
phoneNumber
);
...
...
@@ -1067,14 +1099,14 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public
StaffDepartmentRelatedDTO
getDepartmentIdAndCode
(
String
departmentId
,
String
code
)
{
return
EntityUtil
.
changeEntityByJSON
(
StaffDepartmentRelatedDTO
.
class
,
staffDepartmentRelatedMapper
.
getDepartmentIdAndCode
(
departmentId
,
code
));
return
EntityUtil
.
changeEntityByJSON
(
StaffDepartmentRelatedDTO
.
class
,
staffDepartmentRelatedMapper
.
getDepartmentIdAndCode
(
departmentId
,
code
));
}
@Override
public
void
initWxUser
(
String
corpid
,
String
contactSecret
,
String
wxEnterpriseId
,
Integer
wxDepartmentId
,
String
taskId
)
{
public
void
initWxUser
(
String
corpid
,
String
contactSecret
,
String
wxEnterpriseId
,
Integer
wxDepartmentId
,
String
taskId
)
{
List
<
UserDTO
>
list
=
this
.
qywxUserApiService
.
listSelfDepartmentUser
(
corpid
,
contactSecret
,
wxDepartmentId
.
toString
(),
0
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
for
(
UserDTO
dto
:
list
)
{
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
for
(
UserDTO
dto
:
list
)
{
try
{
this
.
wxGetAdd
(
dto
.
getUserid
(),
wxEnterpriseId
);
}
catch
(
Exception
e
)
{
...
...
@@ -1097,10 +1129,10 @@ public class StaffApiServiceImpl implements StaffApiService {
storeIds
.
add
(
storeId
);
List
<
String
>
clerkList
=
clerkService
.
getclerkListByStoreIds
(
storeIds
);
List
<
StaffClerkRelationDTO
>
staffRelationList
=
staffClerkRelationService
.
listByClerkIds
(
clerkList
);
List
<
String
>
clerkIds
=
staffRelationList
.
stream
().
filter
(
s
->
s
.
getClerkId
()!=
null
).
map
(
s
->
s
.
getClerkId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
clerkIds
=
staffRelationList
.
stream
().
filter
(
s
->
s
.
getClerkId
()
!=
null
).
map
(
s
->
s
.
getClerkId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
unBindList
=
new
ArrayList
<>();
for
(
String
clerkId
:
clerkList
)
{
if
(!
clerkIds
.
contains
(
clerkId
))
{
if
(!
clerkIds
.
contains
(
clerkId
))
{
unBindList
.
add
(
clerkId
);
}
}
...
...
@@ -1115,15 +1147,16 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public
int
countByDepartmentIds
(
List
<
String
>
departmentIds
)
{
if
(
departmentIds
==
null
||
departmentIds
.
isEmpty
())
{
if
(
departmentIds
==
null
||
departmentIds
.
isEmpty
())
{
return
0
;
}
return
staffDepartmentRelatedMapper
.
countByDepartmentIds
(
departmentIds
);
}
@Override
public
List
<
StaffDTO
>
listByUserIdsAndWxEnterpriseId
(
List
<
String
>
userIds
,
String
wxEnterpriseId
)
{
List
<
StaffDTO
>
list
=
staffService
.
listByUserIdsAndWxEnterpriseId
(
userIds
,
wxEnterpriseId
);
if
(
list
==
null
)
{
List
<
StaffDTO
>
list
=
staffService
.
listByUserIdsAndWxEnterpriseId
(
userIds
,
wxEnterpriseId
);
if
(
list
==
null
)
{
return
Collections
.
EMPTY_LIST
;
}
for
(
StaffDTO
staffDTO
:
list
)
{
...
...
@@ -1267,7 +1300,7 @@ public class StaffApiServiceImpl implements StaffApiService {
PicUploadResDTO
uploadPic
=
qqCloudPicService
.
uploadPic
(
GlobalVar
.
ctxPropertiesMap
.
get
(
GlobalInfo
.
QQPIC_KEY_ENTERPRISE
),
data
);
logger
.
info
(
"腾讯云万象优图返回"
+
JSON
.
toJSONString
(
uploadPic
));
return
uploadPic
.
downloadUrl
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
info
(
"上传腾讯云万象优图返回失败了:"
,
e
);
return
headImgUrl
;
}
...
...
@@ -1316,18 +1349,18 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public
ServiceResponse
<
String
>
getStaffQrcode
(
String
clerkCode
,
String
storeId
)
{
ServiceResponse
<
String
>
resp
=
new
ServiceResponse
<>();
List
<
String
>
clerkCodes
=
new
ArrayList
<>();
List
<
String
>
clerkCodes
=
new
ArrayList
<>();
clerkCodes
.
add
(
clerkCode
);
List
<
ClerkDTO
>
list
=
clerkService
.
listClerk
(
storeId
,
clerkCodes
,
true
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
logger
.
info
(
"成员不存在:{}"
,
clerkCode
);
logger
.
info
(
"成员不存在:{}"
,
clerkCode
);
return
null
;
}
ClerkDTO
clerkDTO
=
list
.
get
(
0
);
StaffClerkRelationDTO
relationDTO
=
staffClerkRelationService
.
getByClerkId
(
clerkDTO
.
getClerkId
());
if
(
relationDTO
==
null
)
{
logger
.
info
(
"成员没有关联:{}"
,
clerkCode
);
if
(
relationDTO
==
null
)
{
logger
.
info
(
"成员没有关联:{}"
,
clerkCode
);
return
null
;
}
String
key
=
"qrcode-"
+
relationDTO
.
getStaffId
();
...
...
@@ -1338,8 +1371,8 @@ public class StaffApiServiceImpl implements StaffApiService {
}
WxEnterpriseDTO
wxEnterpriseDTO
=
wxEnterpriseService
.
selectById
(
relationDTO
.
getWxEnterpriseId
());
SecretSettingDTO
secretSetting
=
secretSettingService
.
getSecretSetting
(
wxEnterpriseDTO
.
getWxEnterpriseId
(),
SecretTypeEnum
.
HAOBAN_HELP
.
getVal
());
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()==
0
)
{
logger
.
info
(
"没有配置secret:{}"
,
wxEnterpriseDTO
.
getWxEnterpriseId
());
if
(
null
==
secretSetting
||
secretSetting
.
getCheckFlag
()
==
0
)
{
logger
.
info
(
"没有配置secret:{}"
,
wxEnterpriseDTO
.
getWxEnterpriseId
());
return
null
;
}
UserDTO
user
=
qywxUserApiService
.
getSelfWorkWxUser
(
wxEnterpriseDTO
.
getCorpid
(),
secretSetting
.
getSecretVal
(),
relationDTO
.
getWxUserId
());
...
...
@@ -1350,6 +1383,7 @@ public class StaffApiServiceImpl implements StaffApiService {
}
return
resp
;
}
@Override
public
List
<
StaffDTO
>
listByWxUserId
(
String
wxUserId
)
{
List
<
TabHaobanStaff
>
list
=
staffMapper
.
listByWxUserId
(
wxUserId
);
...
...
@@ -1371,15 +1405,16 @@ public class StaffApiServiceImpl implements StaffApiService {
storeIds
.
add
(
storeId
);
List
<
String
>
clerkList
=
clerkService
.
getclerkListByStoreIds
(
storeIds
);
List
<
StaffClerkRelationDTO
>
staffRelationList
=
staffClerkRelationService
.
listByClerkIds
(
clerkList
);
Map
<
String
,
StaffClerkRelationDTO
>
clerkIdMap
=
staffRelationList
.
stream
().
filter
(
s
->
s
.
getClerkId
()!=
null
).
collect
(
Collectors
.
toMap
(
StaffClerkRelationDTO:
:
getClerkId
,
s
->
s
));
Map
<
String
,
StaffClerkRelationDTO
>
clerkIdMap
=
staffRelationList
.
stream
().
filter
(
s
->
s
.
getClerkId
()
!=
null
).
collect
(
Collectors
.
toMap
(
StaffClerkRelationDTO:
:
getClerkId
,
s
->
s
));
Set
<
String
>
keySet
=
clerkIdMap
.
keySet
();
for
(
String
clerkId
:
clerkList
)
{
if
(
keySet
.
contains
(
clerkId
))
{
if
(
keySet
.
contains
(
clerkId
))
{
userIdList
.
add
(
clerkIdMap
.
get
(
clerkId
).
getWxUserId
());
}
}
return
userIdList
;
}
@Override
public
List
<
StaffClerkRelationDTO
>
listBindRelationUserId
(
String
storeId
)
{
List
<
StaffClerkRelationDTO
>
bindList
=
new
ArrayList
<
StaffClerkRelationDTO
>();
...
...
@@ -1388,10 +1423,10 @@ public class StaffApiServiceImpl implements StaffApiService {
storeIds
.
add
(
storeId
);
List
<
String
>
clerkList
=
clerkService
.
getclerkListByStoreIds
(
storeIds
);
List
<
StaffClerkRelationDTO
>
staffRelationList
=
staffClerkRelationService
.
listByClerkIds
(
clerkList
);
Map
<
String
,
StaffClerkRelationDTO
>
clerkIdMap
=
staffRelationList
.
stream
().
filter
(
s
->
s
.
getClerkId
()!=
null
).
collect
(
Collectors
.
toMap
(
StaffClerkRelationDTO:
:
getClerkId
,
s
->
s
));
Map
<
String
,
StaffClerkRelationDTO
>
clerkIdMap
=
staffRelationList
.
stream
().
filter
(
s
->
s
.
getClerkId
()
!=
null
).
collect
(
Collectors
.
toMap
(
StaffClerkRelationDTO:
:
getClerkId
,
s
->
s
));
Set
<
String
>
keySet
=
clerkIdMap
.
keySet
();
for
(
String
clerkId
:
clerkList
)
{
if
(
keySet
.
contains
(
clerkId
))
{
if
(
keySet
.
contains
(
clerkId
))
{
bindList
.
add
(
clerkIdMap
.
get
(
clerkId
));
}
}
...
...
@@ -1410,7 +1445,7 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public
StaffDTO
getWxStaffOne
(
String
wxEnterpriseId
)
{
TabHaobanStaff
wxStaffByOne
=
staffService
.
getWxStaffByOne
(
wxEnterpriseId
);
return
EntityUtil
.
changeEntityByJSON
(
StaffDTO
.
class
,
wxStaffByOne
);
return
EntityUtil
.
changeEntityByJSON
(
StaffDTO
.
class
,
wxStaffByOne
);
}
@Override
...
...
haoban-manage3-service/src/main/resources/mapper/TabHaobanStaffClerkRelationMapper.xml
View file @
ccc81120
...
...
@@ -452,4 +452,15 @@
WHERE a.status_flag = 1
GROUP BY a.staff_id
</select>
<select
id=
"listRelationsStaffId"
resultType=
"java.lang.String"
>
select staff_id
from tab_haoban_staff_clerk_relation
where staff_id in
<foreach
collection=
"staffIdList"
item=
"item"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
and status_flag = 1 group by staff_id;
</select>
</mapper>
\ No newline at end of file
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/StaffController.java
View file @
ccc81120
...
...
@@ -13,10 +13,10 @@ import com.gic.enterprise.api.dto.StoreDTO;
import
com.gic.enterprise.api.service.EnterpriseService
;
import
com.gic.enterprise.api.service.StoreService
;
import
com.gic.haoban.base.api.common.BasePageInfo
;
import
com.gic.haoban.base.api.common.PageResult
;
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.common.utils.PageUtil
;
import
com.gic.haoban.manage.api.dto.*
;
import
com.gic.haoban.manage.api.enums.ChannelCodeEnum
;
import
com.gic.haoban.manage.api.service.*
;
...
...
@@ -27,6 +27,7 @@ import com.gic.haoban.manage.web.vo.ClerkInfoVo;
import
com.gic.haoban.manage.web.vo.StaffExportVO
;
import
com.gic.haoban.manage.web.vo.StaffVO
;
import
com.gic.wechat.api.service.qywx.QywxUserApiService
;
import
com.google.common.collect.Lists
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
...
...
@@ -115,24 +116,32 @@ public class StaffController extends WebBaseController {
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
staff
);
}
/**
* 分页查询员工列表
*
* @param departmentId 部门id
* @param activeFlag 激活状态 - 后期删除
* @param keyWord 关键字
* @param relationFlag 关联状态
* @param pageInfo 分页参数
* @return res
*/
@RequestMapping
(
"staff-list"
)
public
HaobanResponse
staffList
(
String
departmentId
,
Integer
activeFlag
,
String
keyWord
,
BasePageInfo
pageInfo
)
{
public
HaobanResponse
staffList
(
String
departmentId
,
Integer
activeFlag
,
Integer
relationFlag
,
String
keyWord
,
BasePageInfo
pageInfo
)
{
LoginDTO
login
=
(
LoginDTO
)
AuthRequestUtil
.
getLoginUser
();
String
wxEnterpriseId
=
login
.
getWxEnterpriseId
();
List
<
String
>
departmentIdSet
=
new
ArrayList
<>();
departmentIdSet
.
add
(
departmentId
);
List
<
DepartmentDTO
>
sonDepartmentList
=
departmentApiService
.
listSonByDepartmentIds
(
departmentIdSet
,
wxEnterpriseId
);
// 部门
List
<
DepartmentDTO
>
sonDepartmentList
=
departmentApiService
.
listSonByDepartmentIds
(
Lists
.
newArrayList
(
departmentId
),
login
.
getWxEnterpriseId
());
List
<
String
>
departmentIds
=
sonDepartmentList
.
stream
().
map
(
DepartmentDTO:
:
getDepartmentId
).
collect
(
Collectors
.
toList
());
Page
<
StaffDTO
>
page
=
staffApiService
.
pageStaff
(
departmentIds
,
activeFlag
,
keyWord
,
pageInfo
);
List
<
StaffDTO
>
list
=
page
.
getResult
();
// 员工
Page
<
StaffDTO
>
page
=
staffApiService
.
pageStaff
(
departmentIds
,
activeFlag
,
keyWord
,
pageInfo
,
relationFlag
);
logger
.
info
(
"pages={},totalPage={}"
,
page
.
getCurrentPage
(),
page
.
getTotalPage
());
PageResult
<
StaffDTO
>
pageVo
=
new
PageResult
<>();
pageVo
.
setList
(
list
);
pageVo
.
setPageNum
(
page
.
getCurrentPage
());
pageVo
.
setPages
(
page
.
getPages
());
pageVo
.
setPageSize
(
page
.
getPageSize
());
pageVo
.
setTotal
(
page
.
getTotalCount
());
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
pageVo
);
return
resultResponse
(
HaoBanErrCode
.
ERR_1
,
PageUtil
.
getPageInfo
(
page
));
}
@RequestMapping
(
"staff-del"
)
...
...
@@ -475,7 +484,7 @@ public class StaffController extends WebBaseController {
List
<
DepartmentDTO
>
relationList
=
departmentApiService
.
listSonByDepartmentIds
(
departmentIdSet
,
wxEnterpriseId
);
Map
<
String
,
DepartmentDTO
>
departmentMap
=
relationList
.
stream
().
collect
(
Collectors
.
toMap
(
DepartmentDTO:
:
getDepartmentId
,
s
->
s
));
List
<
String
>
departmentIds
=
relationList
.
stream
().
map
(
DepartmentDTO:
:
getDepartmentId
).
collect
(
Collectors
.
toList
());
Page
<
StaffDTO
>
page
=
staffApiService
.
pageStaff
(
departmentIds
,
activeFlag
,
keyWord
,
pageInfo
);
Page
<
StaffDTO
>
page
=
staffApiService
.
pageStaff
(
departmentIds
,
activeFlag
,
keyWord
,
pageInfo
,
null
);
List
<
StaffDTO
>
list
=
page
.
getResult
();
List
<
StaffExportVO
>
voList
=
new
ArrayList
<>();
for
(
StaffDTO
staffDTO
:
list
)
{
...
...
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