From b47d4a7accabce974e19d2a1ffb3c5c67507d74b Mon Sep 17 00:00:00 2001 From: wangwh <2397901735@qq.com> Date: Wed, 28 Aug 2024 15:11:59 +0800 Subject: [PATCH] 1、组织架构的接口 2、事项登记接口 --- dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUserService.java | 92 +++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 86 insertions(+), 6 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..5746d53 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 @@ -19,6 +19,7 @@ import cn.huge.module.cust.dto.CtUserDTO; import cn.huge.module.redis.constant.RedisKeyConsts; 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 +36,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: 客户用户表业务逻辑处理 @@ -360,7 +359,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 +379,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); @@ -520,4 +519,85 @@ 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); + } + } } -- Gitblit v1.8.0