From 592c8a2dcc33fd6eb32dbcfbaed4a16aab31d28d Mon Sep 17 00:00:00 2001 From: liyj <15602261488@163.com> Date: Mon, 14 Oct 2024 18:02:15 +0800 Subject: [PATCH] 1、线上来访、来访登记、自行排查流程优化 2、任务新增处理耗时、是否超时、超时小时记录 --- dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUserService.java | 186 +++++++++++++++++++++++++++++++++++++++------- 1 files changed, 156 insertions(+), 30 deletions(-) diff --git a/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUserService.java b/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUserService.java index d986d95..25e28f1 100644 --- a/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUserService.java +++ b/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUserService.java @@ -10,7 +10,6 @@ import cn.huge.module.client.api.impl.UtilsClientImpl; import cn.huge.module.constant.BaseConsts; import cn.huge.module.ctrole.domain.po.CtRole; -import cn.huge.module.ctrole.service.CtRoleService; import cn.huge.module.ctuser.dao.mapper.CtUserMapper; import cn.huge.module.ctuser.domain.po.*; import cn.huge.module.ctuser.dto.CtUserSaveDTO; @@ -18,7 +17,10 @@ import cn.huge.module.cust.constant.UserBaseConsts; import cn.huge.module.cust.dto.CtUserDTO; import cn.huge.module.redis.constant.RedisKeyConsts; +import cn.huge.module.rsoper.domain.po.RsRole; +import cn.huge.module.rsoper.service.RsRoleService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Maps; import org.apache.commons.collections.CollectionUtils; @@ -35,11 +37,9 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.DigestUtils; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @title: 客户用户表业务逻辑处理 @@ -66,11 +66,11 @@ @Autowired private CtUseroleService ctUseroleService; @Autowired - private CtRoleService ctRoleService; - @Autowired private CtUsepostService ctUsepostService; @Autowired private CtDeptService ctDeptService; + @Autowired + private RsRoleService rsRoleService; @Autowired private UtilsClientImpl utilsClient; @@ -215,6 +215,10 @@ return mapper.selectById(loginUserId); } + public CtUser getByIdCard(String idCard) { + return mapper.selectByIdCard(idCard); + } + /** * web端-获取人员信息列表查询条件 * @param userId 当前登录用户编号 @@ -254,23 +258,13 @@ } result.put("units", SelectTermUtils.createTreeByFirst(unitSelectTerms, loginUser.getUnitId())); - // 角色条件 - QueryWrapper<CtRole> ctRoleQueryWrapper = new QueryWrapper<>(); - ctRoleQueryWrapper.eq("unit_id", loginUser.getUnitId()); - //判断是否为村居(村居不应该有调委会管理员角色) - QueryWrapper<CtUnit> ctUnitQueryWrapper1 = new QueryWrapper<>(); - ctUnitQueryWrapper1.eq("id", loginUser.getUnitId()).eq("cust_id", loginUser.getCustId()) - .select("unit_type"); - CtUnit ctUnit = ctUnitService.getOne(ctUnitQueryWrapper1); - if (ctUnit.getUnitType() == UserBaseConsts.UNIT_TYPE_4) { - ctRoleQueryWrapper.ne("role_code", RoleBaseEnum.ROLE_9.getIndex()); - } - List<CtRole> ctRoleList = ctRoleService.list(ctRoleQueryWrapper); + // 查询可选角色 List<SelectTermDTO> roleSelectTerms = new ArrayList<>(); - for (CtRole ctRole : ctRoleList) { + List<RsRole> rsRoleList = rsRoleService.list(); + for (RsRole rsRole : rsRoleList) { SelectTermDTO selectTerm = new SelectTermDTO(); - selectTerm.setValue(ctRole.getRoleCode()); - selectTerm.setLabel(ctRole.getName()); + selectTerm.setValue(rsRole.getId()); + selectTerm.setLabel(rsRole.getName()); roleSelectTerms.add(selectTerm); } result.put("roles", roleSelectTerms); @@ -360,7 +354,7 @@ if (IdUtils.checkNewId(ctUser.getId())) { ctUser.setId(utilsClient.getNewTimeId()); ctUser.setCreateTime(nowDate); - ctUser.setDeleteStatus(BaseConsts.DELETE_STATUS_1); + ctUser.setDeleteStatus(BaseConsts.DELETE_STATUS_0); ctUser.setJoinWay(UserBaseConsts.JOIN_WAY_1); ctUser.setRealStatus(UserBaseConsts.REAL_STATUS_0); ctUser.setStatus(UserBaseConsts.USER_STATUS_1); @@ -380,7 +374,7 @@ ctAccount.setAcc(ctUser.getAcc()); ctAccount.setCipher(DigestUtils.md5DigestAsHex(ctUserSaveDTO.getCipher().getBytes())); ctAccount.setCipherOpen(ctUserSaveDTO.getCipher()); - ctAccount.setDeleteStatus(BaseConsts.DELETE_STATUS_1); + ctAccount.setDeleteStatus(BaseConsts.DELETE_STATUS_0); ctAccount.setCreateTime(nowDate); ctAccount.setCipherTime(nowDate); ctAccount.setUpdateTime(nowDate); @@ -392,9 +386,9 @@ for (CtUserole ctUserole : ctUseroleList) { ctUserole.setId(utilsClient.getNewTimeId()); ctUserole.setUserId(ctUser.getId()); - CtRole ctRole = ctRoleService.getByUnitIdAndRoleId(ctUser.getUnitId(), ctUserole.getRoleId()); - ctUserole.setRoleId(ctRole.getId()); - ctUserole.setRoleCode(ctRole.getRoleCode()); + RsRole rsRole = rsRoleService.getById(ctUserole.getRoleId()); + ctUserole.setRoleId(rsRole.getId()); + ctUserole.setRoleCode(rsRole.getId()); ctUserole.setCustId(ctUser.getCustId()); ctUserole.setCreateTime(nowDate); ctUserole.setUpdateTime(nowDate); @@ -443,9 +437,9 @@ ctUserole.setId(utilsClient.getNewTimeId()); ctUserole.setUserId(ctUser.getId()); ctUserole.setCustId(ctUser.getCustId()); - CtRole ctRole = ctRoleService.getByUnitIdAndRoleId(ctUser.getUnitId(), ctUserole.getRoleId()); - ctUserole.setRoleId(ctRole.getId()); - ctUserole.setRoleCode(ctRole.getRoleCode()); + RsRole rsRole = rsRoleService.getById(ctUserole.getRoleId()); + ctUserole.setRoleId(rsRole.getId()); + ctUserole.setRoleCode(rsRole.getId()); ctUserole.setCreateTime(nowDate); ctUserole.setUpdateTime(nowDate); ctUseroleService.save(ctUserole); @@ -520,4 +514,136 @@ return null; } } + + /** + * 批量删除 + * @param data 批量id对象 + */ + public void removeListId(List<String> data) { + for (String id : data) { + // 查询人员信息 + CtUser ctUser = this.getById(id); + // 删除人员 + this.removeById(id); + // 删除账号 + UpdateWrapper<CtAccount> ctAccountUpdateWrapper = new UpdateWrapper(); + ctAccountUpdateWrapper.eq("user_id", ctUser.getId()); + ctAccountService.remove(ctAccountUpdateWrapper); + // 删除人员岗位 + UpdateWrapper<CtUsepost> ctUsepostUpdateWrapper = new UpdateWrapper(); + ctUsepostUpdateWrapper.eq("user_id", ctUser.getId()); + ctUsepostService.remove(ctUsepostUpdateWrapper); + // 删除人员角色 + UpdateWrapper<CtUserole> ctUseroleUpdateWrapper = new UpdateWrapper(); + ctUseroleUpdateWrapper.eq("user_id", ctUser.getId()); + ctUseroleService.remove(ctUseroleUpdateWrapper); + //更新部门和组织的调解专长和范围 + this.updateField("unit", ctUser.getUnitId()); + this.updateField("dept", ctUser.getDeptId()); + } + } + + private void updateField(String tag, String targetId){ + QueryWrapper query = new QueryWrapper(); + if("unit".equals(tag)){ + query.eq("unit_id", targetId); + }else if("dept".equals(tag)){ + query.eq("dept_id", targetId); + } + List<CtUser> ctUser1 = mapper.selectList(query); + Set<String> setGoodField = new HashSet<>(); + Set<String> setGoodFieldName = new HashSet<>(); + Set<String> setCanField = new HashSet<>(); + Set<String> setCanFieldName = new HashSet<>(); + String goodField = new String(); + String goodFieldName = new String(); + String canField = new String(); + String canFieldName = new String(); + if(CollectionUtils.isNotEmpty(ctUser1)){ + for(CtUser ctUsers1: ctUser1){ + if (StringUtils.isNotEmpty(ctUsers1.getGoodField())) { + setGoodField.addAll(Stream.of(ctUsers1.getGoodField().split(",")).collect(Collectors.toSet())); + setGoodFieldName.addAll(Stream.of(ctUsers1.getGoodFieldName().split(",")).collect(Collectors.toSet())); + } + if (StringUtils.isNotEmpty(ctUsers1.getCanField())) { + setCanField.addAll(Stream.of(ctUsers1.getCanField().split(",")).collect(Collectors.toSet())); + setCanFieldName.addAll(Stream.of(ctUsers1.getCanFieldName().split(",")).collect(Collectors.toSet())); + } + } + goodField = String.join(",", setGoodField); + goodFieldName = String.join(",", setGoodFieldName); + canField = String.join(",", setCanField); + canFieldName = String.join(",", setCanFieldName); + } + if("unit".equals(tag)){ + CtUnit ctUnit = new CtUnit(); + ctUnit.setId(targetId); + ctUnit.setGoodField(goodField); + ctUnit.setGoodFieldName(goodFieldName); + ctUnit.setCanField(canField); + ctUnit.setCanFieldName(canFieldName); + ctUnit.setUpdateTime(DateUtils.getNowDate()); + ctUnitService.updateTerms(ctUnit); + }else if("dept".equals(tag)){ + CtDept ctDept = new CtDept(); + ctDept.setId(targetId); + ctDept.setGoodField(goodField); + ctDept.setGoodFieldName(goodFieldName); + ctDept.setCanField(canField); + ctDept.setCanFieldName(canFieldName); + ctDept.setUpdateTime(DateUtils.getNowDate()); + ctDeptService.updateCtDept(ctDept); + } + } + + /** + * 根据部门和角色查询 + * @param unitId 组织编号 + * @param roleCode 角色代码 + * @return List<SelectTermDTO> + */ + public List<CtUser> listUserByDeptRoleList(String unitId, String roleCode){ + return mapper.listUserByUnitRoleList(unitId, roleCode); + } + + /** + * 选择人员 + * @param userId + * @param roleCode + * @return + */ + public List<SelectTermDTO> userChoose(String userId, String roleCode) { + try { + // 获取当前登录用户 + CtUserDTO loginUser = clientGetUserAll(userId); + List<SelectTermDTO> result = new ArrayList<>(); + // 人员条件 + List<CtUser> ctUsers = null; + if (StringUtils.isNotEmpty(roleCode)){ + ctUsers = listUserByDeptRoleList(loginUser.getUnitId(), roleCode); + }else { + QueryWrapper<CtUser> ctUserQueryWrapper = new QueryWrapper<>(); + ctUserQueryWrapper.in("unit_id", loginUser.getUnitId()).select("id", "true_name"); + ctUsers = this.list(ctUserQueryWrapper); + } + SelectTermDTO unitSelectTerm = new SelectTermDTO(); + unitSelectTerm.setValue(loginUser.getUnitId()); + unitSelectTerm.setLabel(loginUser.getUnitName()); + unitSelectTerm.setCheckable(false); + List<SelectTermDTO> userSelectTerms = new ArrayList<>(); + for(CtUser ctUser : ctUsers){ + SelectTermDTO userSelectTerm = new SelectTermDTO(); + userSelectTerm.setValue(ctUser.getId()); + userSelectTerm.setCheckable(true); + userSelectTerm.setLabel(ctUser.getTrueName()); + userSelectTerms.add(userSelectTerm); + } + unitSelectTerm.setChildren(userSelectTerms); + result.add(unitSelectTerm); + return result; + }catch (Exception e) { + log.error("[CtUserService.userChoose]调用失败,异常信息:" + e, e); + throw new ServiceException("CtUserService.userChoose", e); + } + } } -- Gitblit v1.8.0