From be965e67230bf964d451d555f0be0f3b3d13dfdb Mon Sep 17 00:00:00 2001
From: liyj <1003249715@qq.com>
Date: Tue, 10 Sep 2024 17:36:10 +0800
Subject: [PATCH] 1、组织架构调整

---
 dyh-service/dyh-cust/src/main/java/cn/huge/module/bytogz/controller/ByToGzController.java |   15 +++++++
 dyh-service/dyh-cust/src/main/java/cn/huge/module/bytogz/service/ByToGzService.java       |   28 ++++++++++++++
 dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/service/CtUserService.java       |   39 +++++++------------
 3 files changed, 58 insertions(+), 24 deletions(-)

diff --git a/dyh-service/dyh-cust/src/main/java/cn/huge/module/bytogz/controller/ByToGzController.java b/dyh-service/dyh-cust/src/main/java/cn/huge/module/bytogz/controller/ByToGzController.java
index 8188e80..d235f4d 100644
--- a/dyh-service/dyh-cust/src/main/java/cn/huge/module/bytogz/controller/ByToGzController.java
+++ b/dyh-service/dyh-cust/src/main/java/cn/huge/module/bytogz/controller/ByToGzController.java
@@ -61,4 +61,19 @@
             return ReturnFailUtils.getRepInfo();
         }
     }
+
+    /**
+     * 单位名称更新-白云单位名称街道办->综治中心
+     * @url {ctx}/api/byToGz/upUnitNameZzzx
+     * @return Object
+     */
+    @GetMapping("/upUnitNameZzzx")
+    public Object upUnitNameZzzx() {
+        try {
+            service.upUnitNameZzzx();
+            return ReturnSucUtils.getRepInfo();
+        } catch (Exception e) {
+            return ReturnFailUtils.getRepInfo();
+        }
+    }
 }
diff --git a/dyh-service/dyh-cust/src/main/java/cn/huge/module/bytogz/service/ByToGzService.java b/dyh-service/dyh-cust/src/main/java/cn/huge/module/bytogz/service/ByToGzService.java
index f45b832..74a0c5b 100644
--- a/dyh-service/dyh-cust/src/main/java/cn/huge/module/bytogz/service/ByToGzService.java
+++ b/dyh-service/dyh-cust/src/main/java/cn/huge/module/bytogz/service/ByToGzService.java
@@ -6,12 +6,16 @@
 import cn.huge.module.client.api.impl.UtilsClientImpl;
 import cn.huge.module.ctrole.constant.ByRoleBaseEnum;
 import cn.huge.module.ctuser.dao.mapper.CtUseroleMapper;
+import cn.huge.module.ctuser.domain.po.CtUnit;
 import cn.huge.module.ctuser.domain.po.CtUser;
 import cn.huge.module.ctuser.domain.po.CtUserole;
+import cn.huge.module.ctuser.service.CtUnitService;
 import cn.huge.module.ctuser.service.CtUserService;
 import cn.huge.module.ctuser.service.CtUseroleService;
 import cn.huge.module.cust.constant.RoleBaseEnum;
+import cn.huge.module.cust.constant.UserBaseConsts;
 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 lombok.extern.slf4j.Slf4j;
@@ -47,6 +51,8 @@
     private CtUseroleService ctUseroleService;
     @Autowired
     private CtUserService ctUserService;
+    @Autowired
+    private CtUnitService ctUnitService;
 
     /**
      * 用户角色更新-白云角色映射为广州角色
@@ -72,4 +78,26 @@
             throw new ServiceException("ByToGzService.upBytoGzUserole", e);
         }
     }
+
+    /**
+     * 单位名称更新-白云单位名称街道办->综治中心
+     */
+    public void upUnitNameZzzx(){
+        try{
+            QueryWrapper<CtUnit> ctUnitQueryWrapper = new QueryWrapper<>();
+            ctUnitQueryWrapper.eq("unit_grade", UserBaseConsts.UNIT_GRADE_3);
+            List<CtUnit> ctUnitList = ctUnitService.list(ctUnitQueryWrapper);
+            for (CtUnit ctUnit: ctUnitList){
+                ctUnit.setUnitName(ctUnit.getUnitName().replace("街道办", "街综治中心"));
+                ctUnitService.updateById(ctUnit);
+                // 更新人员单位名称
+                UpdateWrapper<CtUser> ctUserUpdateWrapper = new UpdateWrapper<>();
+                ctUserUpdateWrapper.eq("unit_id", ctUnit.getId()).set("unit_name", ctUnit.getUnitName());
+                ctUserService.update(ctUserUpdateWrapper);
+            }
+        }catch (Exception e){
+            log.error("[ByToGzService.upUnitNameZzzx]调用失败,异常信息:"+e, e);
+            throw new ServiceException("ByToGzService.upUnitNameZzzx", e);
+        }
+    }
 }
\ No newline at end of file
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 5411841..08bd4a3 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,6 +17,8 @@
 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;
@@ -65,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;
@@ -253,23 +254,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_1.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);
@@ -391,9 +382,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);
@@ -442,9 +433,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);

--
Gitblit v1.8.0