Browse Source

人员离职客户交接

v1.0
Yen 2 years ago
parent
commit
815472a869
  1. 3
      src/main/java/com/qs/serve/modules/bms/entity/BmsSupplier.java
  2. 16
      src/main/java/com/qs/serve/modules/bms/mapper/BmsSupplierMapper.java
  3. 64
      src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierApplicationService.java
  4. 2
      src/main/java/com/qs/serve/modules/sys/controller/SysUserController.java
  5. 22
      src/main/java/com/qs/serve/modules/sys/entity/SysSyncLog.java
  6. 5
      src/main/java/com/qs/serve/modules/sys/service/SysUserService.java
  7. 76
      src/main/java/com/qs/serve/modules/sys/service/impl/SysUserServiceImpl.java
  8. 2
      src/main/java/com/qs/serve/modules/third/PortalOfCostController.java
  9. 2
      src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java
  10. 2
      src/main/java/com/qs/serve/modules/third/util/ThirtyVerificationUtil.java
  11. 2
      src/main/java/com/qs/serve/modules/vtb/service/impl/VtbVerificationServiceImpl.java
  12. 14
      src/main/java/com/qs/serve/task/controller/TaskUserController.java
  13. 9
      src/main/resources/mapper/bir/BirActivityCenterGoodsMapper.xml

3
src/main/java/com/qs/serve/modules/bms/entity/BmsSupplier.java

@ -346,6 +346,9 @@ public class BmsSupplier implements Serializable {
private List<String> searchInIds; private List<String> searchInIds;
/*-------------- ----------------- */ /*-------------- ----------------- */
@TableField(exist = false)
private String otherUserIdsString;
public List<String> listBizRegionIds(){ public List<String> listBizRegionIds(){
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
list.add(this.getRegion2First()); list.add(this.getRegion2First());

16
src/main/java/com/qs/serve/modules/bms/mapper/BmsSupplierMapper.java

@ -18,6 +18,22 @@ public interface BmsSupplierMapper extends BaseMapper<BmsSupplier> {
@InterceptorIgnore(tenantLine = "1") @InterceptorIgnore(tenantLine = "1")
List<BmsSupplier> selectSupplierList(@Param("query") BmsSupplier bmsSupplier); List<BmsSupplier> selectSupplierList(@Param("query") BmsSupplier bmsSupplier);
/**
*
* @param query
* @return
*/
@InterceptorIgnore(tenantLine = "1")
@Update("update bms_supplier" +
" set user_id = #{query.userId}" +
",user_code = #{query.userCode}" +
",user_name = #{query.userName}" +
",other_user_ids = #{query.otherUserIdsString}" +
",other_user_names = #{query.otherUserNames}" +
",other_user_codes = #{query.otherUserCodes}" +
" where id = #{query.id}")
int updateRelateUserInfo(@Param("query") BmsSupplier query);
@InterceptorIgnore(tenantLine = "1") @InterceptorIgnore(tenantLine = "1")
@Update("update bms_supplier set user_id = null,user_code = null, user_name = null where id = #{supplierId}") @Update("update bms_supplier set user_id = null,user_code = null, user_name = null where id = #{supplierId}")
int removeRelateUserInfo(@Param("supplierId") Long supplierId); int removeRelateUserInfo(@Param("supplierId") Long supplierId);

64
src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierApplicationService.java

@ -10,6 +10,8 @@ import com.qs.serve.modules.bms.entity.BmsSupplier;
import com.qs.serve.modules.bms.mapper.BmsRegion2Mapper; import com.qs.serve.modules.bms.mapper.BmsRegion2Mapper;
import com.qs.serve.modules.bms.mapper.BmsRegionMapper; import com.qs.serve.modules.bms.mapper.BmsRegionMapper;
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper; import com.qs.serve.modules.bms.mapper.BmsSupplierMapper;
import com.qs.serve.modules.sys.entity.SysUser;
import com.qs.serve.modules.sys.mapper.SysUserMapper;
import com.qs.serve.modules.tbs.common.TbsCenterType; import com.qs.serve.modules.tbs.common.TbsCenterType;
import com.qs.serve.modules.tbs.common.TbsGoodsType; import com.qs.serve.modules.tbs.common.TbsGoodsType;
import com.qs.serve.modules.tbs.common.util.TbsBudgetLogBuildUtil; import com.qs.serve.modules.tbs.common.util.TbsBudgetLogBuildUtil;
@ -26,10 +28,7 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -50,6 +49,63 @@ public class BmsSupplierApplicationService {
// private TbsActivityMapper activityMapper; // private TbsActivityMapper activityMapper;
private BmsSupplierMapper bmsSupplierMapper; private BmsSupplierMapper bmsSupplierMapper;
/**
* 移除用户所有的客户权限
* @param leaveUser 离职用户
* @param enterUser 入职用户(可空)
*/
public void removeUserOfSupplierList(final SysUser leaveUser,SysUser enterUser){
String leaveUserId = leaveUser.getId();
BmsSupplier query = new BmsSupplier();
query.setCurrUserId(leaveUser.getId());
query.setDelFlag(false);
List<BmsSupplier> supplierList = bmsSupplierMapper.selectSupplierList(query);
String enterUserId = "";
String enterUserCode = "";
String enterUserName = "";
if(enterUser!=null){
enterUserId = enterUser.getId();
enterUserCode = enterUser.getCode();
enterUserName = enterUser.getName();
}
for (BmsSupplier supplier : supplierList) {
//主要负责人
if(leaveUserId.equals(supplier.getUserId())){
supplier.setUserId(enterUserId);
if(enterUser==null){
supplier.setUserName("");
supplier.setUserCode("");
}else {
supplier.setUserName(enterUser.getName());
supplier.setUserCode(enterUser.getCode());
}
}
//其它负责人
List<String> otherUserIdList = new ArrayList<>();
for (String otherUserId : supplier.getOtherUserIds()) {
if(otherUserId.equals(leaveUserId)){
if(enterUserId==null){
continue;
}else {
otherUserIdList.add(enterUserId);
continue;
}
}
otherUserIdList.add(otherUserId);
}
if(otherUserIdList.size()>0){
String userIds = otherUserIdList.stream().distinct().collect(Collectors.joining(","));
supplier.setOtherUserIdsString(userIds);
String otherName = supplier.getOtherUserNames().replace(leaveUser.getName(),enterUserName);
String otherCode = supplier.getOtherUserCodes().replace(leaveUser.getCode(),enterUserCode);
supplier.setOtherUserNames(otherName);
supplier.setOtherUserCodes(otherCode);
bmsSupplierMapper.updateRelateUserInfo(supplier);
}
}
}
// /** // /**
// * 客户更新区域时,预算政策统计 // * 客户更新区域时,预算政策统计
// * @param supplierId // * @param supplierId

2
src/main/java/com/qs/serve/modules/sys/controller/SysUserController.java

@ -623,7 +623,7 @@ public class SysUserController {
@SysLog(title = "人员",desc = "离职调整",biz = BizType.LEAVE) @SysLog(title = "人员",desc = "离职调整",biz = BizType.LEAVE)
@PostMapping("/leaveNow") @PostMapping("/leaveNow")
public R<?> leaveNow(String userId){ public R<?> leaveNow(String userId){
sysUserService.leaveNow(userId); sysUserService.leaveNow(Arrays.asList(userId),true);
return R.ok(); return R.ok();
} }

22
src/main/java/com/qs/serve/modules/sys/entity/SysSyncLog.java

@ -34,7 +34,7 @@ public class SysSyncLog implements Serializable {
/** 来自系统 */ /** 来自系统 */
@Length(max = 255,message = "来自系统长度不能超过255字") @Length(max = 255,message = "来自系统长度不能超过255字")
@TableField(value = "form_plat") @TableField(value = "form_plat")
private String from; private String fromPlat;
/** 请求地址 */ /** 请求地址 */
@Length(max = 255,message = "请求地址长度不能超过255字") @Length(max = 255,message = "请求地址长度不能超过255字")
@ -94,25 +94,5 @@ public class SysSyncLog implements Serializable {
@JsonProperty @JsonProperty
private Boolean delFlag; private Boolean delFlag;
public static SysSyncLog toNewObject(SysSyncLog source){
SysSyncLog syncLog = new SysSyncLog();
syncLog.setId(source.getId());
syncLog.setFrom(source.getFrom());
syncLog.setUrl(source.getUrl());
syncLog.setEntityClass(source.getEntityClass());
syncLog.setRequestJson(source.getRequestJson());
syncLog.setFailReason(source.getFailReason());
syncLog.setSuccessStatus(source.getSuccessStatus());
syncLog.setRemark(source.getRemark());
syncLog.setCreateTime(source.getCreateTime());
syncLog.setCreateBy(source.getCreateBy());
syncLog.setUpdateTime(source.getUpdateTime());
syncLog.setUpdateBy(source.getUpdateBy());
syncLog.setTenantId(source.getTenantId());
syncLog.setDelFlag(source.getDelFlag());
return syncLog;
}
} }

5
src/main/java/com/qs/serve/modules/sys/service/SysUserService.java

@ -57,9 +57,10 @@ public interface SysUserService extends IService<SysUser> {
/** /**
* 立刻离职执行函数 * 立刻离职执行函数
* @param userId * @param userIds
* @param updateLeaveStatus
*/ */
void leaveNow(String userId); void leaveNow(List<String> userIds,Boolean updateLeaveStatus);
/** /**
* 取消离职 * 取消离职

76
src/main/java/com/qs/serve/modules/sys/service/impl/SysUserServiceImpl.java

@ -11,6 +11,8 @@ import com.qs.serve.common.model.enums.HttpCode;
import com.qs.serve.common.util.*; import com.qs.serve.common.util.*;
import com.qs.serve.modules.bms.entity.BmsRegionUser; import com.qs.serve.modules.bms.entity.BmsRegionUser;
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper; import com.qs.serve.modules.bms.mapper.BmsSupplierMapper;
import com.qs.serve.modules.bms.service.impl.BmsSupplierApplicationService;
import com.qs.serve.modules.his.service.HisUserSupplierService;
import com.qs.serve.modules.sys.entity.*; import com.qs.serve.modules.sys.entity.*;
import com.qs.serve.modules.sys.entity.bo.SysUserLeaveBo; import com.qs.serve.modules.sys.entity.bo.SysUserLeaveBo;
import com.qs.serve.modules.sys.entity.dto.SysUpdateSeeYonPassword; import com.qs.serve.modules.sys.entity.dto.SysUpdateSeeYonPassword;
@ -41,15 +43,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
private final SysPostUserService sysPostUserService; private final SysPostUserService sysPostUserService;
private final SysUserRoleService sysUserRoleService; private final SysUserRoleService sysUserRoleService;
private final SysUserLeaveService sysUserLeaveService; private final SysUserLeaveService sysUserLeaveService;
private final SysRoleMenuMapper sysRoleMenuMapper;
private final SysPermitService sysPermitService; private final SysPermitService sysPermitService;
private final SysRoleService sysRoleService; private final SysRoleService sysRoleService;
private final SysDeptMapper sysDeptMapper; private final SysDeptMapper sysDeptMapper;
private final SysMenuMapper sysMenuMapper; private final SysMenuMapper sysMenuMapper;
private final SysPostMapper postMapper; private final SysPostMapper postMapper;
private final SysPostUserMapper postUserMapper;
private final BmsSupplierMapper supplierMapper; private final BmsSupplierMapper supplierMapper;
private SeeYonProperties seeYonProperties; private final BmsSupplierApplicationService supplierApplicationService;
private final SeeYonProperties seeYonProperties;
@Override @Override
public void updateSeeYonPassword(String syUserId, String password) { public void updateSeeYonPassword(String syUserId, String password) {
@ -272,17 +273,68 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
} }
@Override @Override
public void leaveNow(String userId) { public void leaveNow(List<String> userIds,Boolean updateLeaveStatus) {
SysUser user = new SysUser(); if(userIds==null||userIds.size()<1){
user.setId(userId); return;
user.setServingState(0); }
user.setLoginEnable(0); //人员业务继承-start
user.setServingLeaveDate(LocalDate.now()); LambdaQueryWrapper<SysUserLeave> lqw = new LambdaQueryWrapper<>();
this.updateById(user); lqw.in(SysUserLeave::getUserId,userIds);
supplierMapper.updateBmsSuppliersOtherUserNullById(Arrays.asList(userId)); lqw.eq(SysUserLeave::getLeaveStatus,0);
supplierMapper.updateBmsSuppliersUserNullById(Arrays.asList(userId)); List<SysUserLeave> sysUserLeaves = sysUserLeaveService.list(lqw);
for (String userId : userIds) {
SysUser leaveUser = super.baseMapper.selectById(userId);
boolean match = false;
for (SysUserLeave userLeave : sysUserLeaves) {
if(userId.equals(userLeave.getUserId())){
match = true;
//客户交接人
String cusUserId = userLeave.getCusUserId();
if(StringUtils.hasText(cusUserId)){
SysUser cusUser = super.baseMapper.selectById(userId);
supplierApplicationService.removeUserOfSupplierList(leaveUser,cusUser);
}
//角色交接人
String roleUserId = userLeave.getRoleUserId();
//工作交接人
String flowUserId = userLeave.getFlowUserId();
}
}
//不匹配也要移除客户权限和角色
if(!match){
supplierApplicationService.removeUserOfSupplierList(leaveUser,null);
}
}
//更新离职记录标为完成
if(updateLeaveStatus&&sysUserLeaves.size()>0){
for (SysUserLeave userLeaf : sysUserLeaves) {
userLeaf.setLeaveStatus(1);
}
sysUserLeaveService.updateBatchById(sysUserLeaves);
} }
//离职人员信息更新
LambdaQueryWrapper<SysUser> updLqw = new LambdaQueryWrapper<>();
updLqw.in(SysUser::getId,userIds);
SysUser sysUser = new SysUser();
sysUser.setServingState(0);
sysUser.setLoginEnable(0);
sysUser.setServingLeaveDate(LocalDate.now());
super.update(sysUser,updLqw);
HisUserSupplierService hisUserSupplierService = SpringUtils.getBean(HisUserSupplierService.class);
hisUserSupplierService.cleanTable();
}
@Override @Override
public void cancelLeave(String userId) { public void cancelLeave(String userId) {
SysUser sysUser = this.getById(userId); SysUser sysUser = this.getById(userId);

2
src/main/java/com/qs/serve/modules/third/PortalOfCostController.java

@ -46,7 +46,7 @@ public class PortalOfCostController {
@PostMapping("createByCostApply") @PostMapping("createByCostApply")
public R<?> createCostProcess(@Valid @RequestBody ProcessCreateCostApplyBo createBo,HttpServletRequest request){ public R<?> createCostProcess(@Valid @RequestBody ProcessCreateCostApplyBo createBo,HttpServletRequest request){
SysSyncLog syncLog = new SysSyncLog(); SysSyncLog syncLog = new SysSyncLog();
syncLog.setFrom("一站式费用"); syncLog.setFromPlat("一站式费用");
syncLog.setUrl(request.getRequestURI()); syncLog.setUrl(request.getRequestURI());
syncLog.setRequestJson(JsonUtil.objectToJson(createBo)); syncLog.setRequestJson(JsonUtil.objectToJson(createBo));
syncLog.setEntityClass(ProcessCreateCostApplyBo.class.getName()); syncLog.setEntityClass(ProcessCreateCostApplyBo.class.getName());

2
src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java

@ -858,7 +858,7 @@ public class PortalOfCostApplication {
String rs = HttpUtil.doPost(COST_TO_PAY_API, json, null); String rs = HttpUtil.doPost(COST_TO_PAY_API, json, null);
SysSyncLog syncLog = new SysSyncLog(); SysSyncLog syncLog = new SysSyncLog();
syncLog.setFrom("to支付请求"); syncLog.setFromPlat("to支付请求");
syncLog.setUrl(COST_TO_PAY_API); syncLog.setUrl(COST_TO_PAY_API);
syncLog.setRequestJson(json); syncLog.setRequestJson(json);
if(rs==null||!rs.contains("200")){ if(rs==null||!rs.contains("200")){

2
src/main/java/com/qs/serve/modules/third/util/ThirtyVerificationUtil.java

@ -105,7 +105,7 @@ public class ThirtyVerificationUtil {
rs = e.getMessage(); rs = e.getMessage();
} }
SysSyncLog syncLog = new SysSyncLog(); SysSyncLog syncLog = new SysSyncLog();
syncLog.setFrom(title); syncLog.setFromPlat(title);
syncLog.setUrl(api); syncLog.setUrl(api);
syncLog.setRequestJson(json); syncLog.setRequestJson(json);
if(rs==null||!rs.contains("200")){ if(rs==null||!rs.contains("200")){

2
src/main/java/com/qs/serve/modules/vtb/service/impl/VtbVerificationServiceImpl.java

@ -1268,7 +1268,7 @@ public class VtbVerificationServiceImpl extends ServiceImpl<VtbVerificationMappe
public void toPayRequest() { public void toPayRequest() {
String COST_TO_PAY_API = projectApisProperties.getCostToPay(); String COST_TO_PAY_API = projectApisProperties.getCostToPay();
LambdaQueryWrapper<SysSyncLog> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SysSyncLog> lqw = new LambdaQueryWrapper<>();
lqw.eq(SysSyncLog::getFrom,"to支付请求") lqw.eq(SysSyncLog::getFromPlat,"to支付请求")
.eq(SysSyncLog::getSuccessStatus,0) .eq(SysSyncLog::getSuccessStatus,0)
.eq(SysSyncLog::getTodoState,1) .eq(SysSyncLog::getTodoState,1)
//重试两次 //重试两次

14
src/main/java/com/qs/serve/task/controller/TaskUserController.java

@ -16,6 +16,7 @@ import com.qs.serve.modules.wx.service.WxUserService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -45,7 +46,7 @@ public class TaskUserController {
private final BmsSupplierMapper supplierMapper; private final BmsSupplierMapper supplierMapper;
private final HisUserSupplierService hisUserSupplierService; private final HisUserSupplierService hisUserSupplierService;
@Transactional
public R<?> doLeave(){ public R<?> doLeave(){
LambdaQueryWrapper<SysUserLeave> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SysUserLeave> lqw = new LambdaQueryWrapper<>();
lqw.select(SysUserLeave::getUserId,SysUserLeave::getId); lqw.select(SysUserLeave::getUserId,SysUserLeave::getId);
@ -60,16 +61,7 @@ public class TaskUserController {
} }
sysUserLeaveService.updateBatchById(sysUserLeaves); sysUserLeaveService.updateBatchById(sysUserLeaves);
List<String> userIds = sysUserLeaves.stream().map(a->a.getUserId()).collect(Collectors.toList()); List<String> userIds = sysUserLeaves.stream().map(a->a.getUserId()).collect(Collectors.toList());
LambdaQueryWrapper<SysUser> updLqw = new LambdaQueryWrapper<>(); sysUserService.leaveNow(userIds,false);
updLqw.in(SysUser::getId,userIds);
SysUser sysUser = new SysUser();
sysUser.setServingState(0);
sysUser.setLoginEnable(0);
sysUser.setServingLeaveDate(LocalDate.now());
sysUserService.update(sysUser,updLqw);
supplierMapper.updateBmsSuppliersOtherUserNullById(userIds);
supplierMapper.updateBmsSuppliersUserNullById(userIds);
hisUserSupplierService.cleanTable();
return R.ok(); return R.ok();
} }

9
src/main/resources/mapper/bir/BirActivityCenterGoodsMapper.xml

@ -141,9 +141,12 @@
left join tbs_activity ON bir_activity_center_goods.activity_id = tbs_activity.id left join tbs_activity ON bir_activity_center_goods.activity_id = tbs_activity.id
left join `tbs_cost_apply` on `bir_activity_center_goods`.cost_apply_id = `tbs_cost_apply`.id left join `tbs_cost_apply` on `bir_activity_center_goods`.cost_apply_id = `tbs_cost_apply`.id
where where
tbs_cost_apply.del_flag = 1 or tbs_cost_apply.id is null tbs_cost_apply.del_flag = 1
and tbs_activity.id is null or tbs_activity.del_flag = 1 or tbs_cost_apply.id is null
or tbs_cost_apply.cancel_flag = 1
or tbs_activity.cancel_flag = 1
or tbs_activity.id is null
or tbs_activity.del_flag = 1
</select> </select>
<select id="listMonthCusCenterVo" <select id="listMonthCusCenterVo"

Loading…
Cancel
Save