Parcourir la source

合作管理、合同管理新增三查询接口

czh il y a 2 ans
Parent
commit
bbe8197530
23 fichiers modifiés avec 363 ajouts et 30 suppressions
  1. 2 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java
  2. 9 0
      sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/RemoteSystemService.java
  3. 12 0
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/controller/KwmCooperateManageController.java
  4. 23 0
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/model/vo/res/FindEntCooperateResVo.java
  5. 59 4
      sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java
  6. 24 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java
  7. 9 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEntDeptDao.java
  8. 6 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteBaseService.java
  9. 19 4
      sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteSystemServiceImpl.java
  10. 39 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/pojo/FindEntDeptInfoPojo.java
  11. 1 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/EditRoleReqVo.java
  12. 34 0
      sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/res/QueryCurrentOrganizationResVo.java
  13. 4 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsDeptService.java
  14. 80 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java
  15. 1 1
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsMenuService.java
  16. 14 9
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsRoleService.java
  17. 2 2
      sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java
  18. 1 1
      sckw-modules/sckw-system/src/main/resources/mapper/KwsDeptDao.xml
  19. 10 0
      sckw-modules/sckw-system/src/main/resources/mapper/KwsEntDeptDao.xml
  20. 9 5
      sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml
  21. 1 0
      sckw-modules/sckw-system/src/main/resources/mapper/KwsRoleDao.xml
  22. 1 1
      sckw-modules/sckw-system/src/main/resources/mapper/KwsUserDao.xml
  23. 3 0
      sckw-modules/sckw-system/src/main/resources/mapper/KwsUserRoleDao.xml

+ 2 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java

@@ -118,6 +118,7 @@ public class HttpStatus {
     public static final int QUERY_FAIL_CODE = 60602;
     public static final String ACCOUNT_NOT_EXISTS = "用户信息不存在或已失效";
     public static final String ENT_NOT_EXISTS = "企业信息不存在或已失效";
+    public static final String DEPT_NOT_EXISTS = "机构信息不存在或已失效";
     public static final String ENTCERTIFICATES_NOT_EXISTS = "未查询到企业资质信息";
     public static final String ENTCERTIFICATES_INVAILD = "企业资质已失效";
     public static final String ROLE_NOT_EXISTS = "未查询到关联的角色";
@@ -160,5 +161,6 @@ public class HttpStatus {
     public static final String MSG_024 = "名称不能重复!";
     public static final String MSG_025 = "禁止删除本人信息!";
     public static final String MSG_026 = "资质认证审核中,请等待审核后再提交!";
+    public static final String MSG_027 = "一级机构不能删除!";
 
 }

+ 9 - 0
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/RemoteSystemService.java

@@ -84,6 +84,15 @@ public interface RemoteSystemService {
      */
     List<EntCacheResDto> queryEntCacheByIds(List<Long> entIds);
 
+    /**
+     * @param entIds 企业id
+     * @return Map
+     * @desc: 从缓存批量主体机构信息
+     * @author: czh
+     * @date: 2023/7/22
+     */
+    Map<Long, List<EntCacheResDto>> queryEntDeptCacheByIds(List<Long> entIds);
+
     /**
      * @desc: 从缓存批量查企业信息
      * @author: yzc

+ 12 - 0
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/controller/KwmCooperateManageController.java

@@ -110,4 +110,16 @@ public class KwmCooperateManageController {
         return HttpResult.ok(kwmCooperateManageService.findListGroup(reqVo));
     }
 
+    /**
+     * @param reqVo 企业id
+     * @return HttpResult
+     * @desc: 查询企业的合作单位
+     * @author: czh
+     * @date: 2023/7/22
+     */
+    @PostMapping("findEntCooperate")
+    public HttpResult findEntCooperate(@RequestBody IdsReqVo reqVo) throws SystemException {
+        return HttpResult.ok(kwmCooperateManageService.findEntCooperate(reqVo.getId()));
+    }
+
 }

+ 23 - 0
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/model/vo/res/FindEntCooperateResVo.java

@@ -0,0 +1,23 @@
+package com.sckw.manage.model.vo.res;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author czh
+ * @desc 合作企业
+ * @date 2023/7/22
+ */
+@Data
+public class FindEntCooperateResVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -3663266782855234702L;
+
+    private Long entId;
+
+    private String entName;
+
+}

+ 59 - 4
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java

@@ -3,6 +3,7 @@ package com.sckw.manage.service;
 import java.io.IOException;
 import java.util.Date;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
@@ -23,10 +24,10 @@ import com.sckw.manage.model.entity.KwmCooperate;
 import com.sckw.manage.model.vo.req.BindManagerReqVo;
 import com.sckw.manage.model.vo.req.CooperateManageQueryReqVo;
 import com.sckw.manage.model.vo.res.CooperateManageQueryResVo;
+import com.sckw.manage.model.vo.res.FindEntCooperateResVo;
 import com.sckw.manage.model.vo.res.FindListGroupResVo;
 import com.sckw.manage.model.vo.res.QueryDetailResVo;
 import com.sckw.system.api.RemoteSystemService;
-import com.sckw.system.api.RemoteUserService;
 import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import lombok.extern.slf4j.Slf4j;
@@ -55,9 +56,6 @@ public class KwmCooperateManageService {
     @DubboReference(version = "2.0.0", group = "design", check = false)
     private RemoteSystemService remoteSystemService;
 
-    @DubboReference(version = "2.0.0", group = "design", check = false)
-    private RemoteUserService remoteUserService;
-
 
     /**
      * @param reqVo 分页入参
@@ -276,4 +274,61 @@ public class KwmCooperateManageService {
         commonBusinessService.fillGroup(result, list);
         return result;
     }
+
+
+    /**
+     * @param id 企业id
+     * @return FindEntCooperateResVo
+     * @desc: 查询企业的合作单位
+     * @author: czh
+     * @date: 2023/7/22
+     */
+    public List<FindEntCooperateResVo> findEntCooperate(Long id) {
+        LambdaQueryWrapper<KwmCooperate> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(KwmCooperate::getInviterEntId, id).or().
+                eq(KwmCooperate::getInviteeEntId, id).and(
+                        wp -> wp.eq(KwmCooperate::getDelFlag, Global.NO).
+                                eq(KwmCooperate::getStatus, CooperateStatusEnum.OK.getCode())
+                );
+        List<KwmCooperate> kwmCooperates = kwmCooperateMapper.selectList(wrapper);
+        if (CollectionUtils.isEmpty(kwmCooperates)) {
+            return Collections.emptyList();
+        }
+
+        //装对方企业的id
+        List<Long> targetEntIdList = new ArrayList<>();
+        kwmCooperates.forEach(item -> targetEntIdList.add(item.getInviterEntId().equals(id) ? item.getInviteeEntId() : item.getInviterEntId()));
+
+        List<EntCacheResDto> entCacheResDtos = remoteSystemService.queryEntCacheByIds(targetEntIdList);
+        if (CollectionUtils.isEmpty(entCacheResDtos)) {
+            return Collections.emptyList();
+        }
+
+        //装对方企业信息
+        List<FindEntCooperateResVo> list = new ArrayList<>();
+        entCacheResDtos.forEach(item -> {
+            FindEntCooperateResVo findEntCooperateResVo = new FindEntCooperateResVo();
+            findEntCooperateResVo.setEntId(item.getId());
+            findEntCooperateResVo.setEntName(item.getFirmName());
+            list.add(findEntCooperateResVo);
+        });
+
+        //装对方企业的主体单位
+        Map<Long, List<EntCacheResDto>> longListMap = remoteSystemService.queryEntDeptCacheByIds(targetEntIdList);
+        List<Long> longs = list.stream().map(FindEntCooperateResVo::getEntId).toList();
+        longs.forEach(item -> {
+            List<EntCacheResDto> entCacheResDtos1 = longListMap.get(item);
+            if (CollectionUtils.isEmpty(entCacheResDtos1)) {
+                return;
+            }
+            entCacheResDtos1.forEach(x -> {
+                FindEntCooperateResVo findEntCooperateResVo = new FindEntCooperateResVo();
+                findEntCooperateResVo.setEntId(x.getId());
+                findEntCooperateResVo.setEntName(x.getFirmName());
+                list.add(findEntCooperateResVo);
+            });
+        });
+        return list;
+    }
+
 }

+ 24 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java

@@ -226,4 +226,28 @@ public class KwsEnterpriseController {
         return HttpResult.ok(kwsEntService.findList(reqVo));
     }
 
+    /**
+     * @param  reqVo id
+     * @return  HttpResult
+     * @desc: 查询企业的信息+主体机构信息
+     * @author: czh
+     * @date: 2023/7/22
+     */
+    @PostMapping("queryEntOrganization")
+    public HttpResult queryEntOrganization(@RequestBody IdReqVo reqVo) {
+        return HttpResult.ok(kwsEntService.queryCurrentOrganization(reqVo.getId()));
+    }
+
+    /**
+     * @param  reqVo id
+     * @return  HttpResult
+     * @desc: 查询其他入驻企
+     * @author: czh
+     * @date: 2023/7/22
+     */
+    @PostMapping("queryOtherEnt")
+    public HttpResult queryOtherEnt(@RequestBody IdReqVo reqVo) {
+        return HttpResult.ok(kwsEntService.queryOtherEnt(reqVo.getId()));
+    }
+
 }

+ 9 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEntDeptDao.java

@@ -1,6 +1,7 @@
 package com.sckw.system.dao;
 
 import com.sckw.system.model.KwsEntDept;
+import com.sckw.system.model.pojo.FindEntDeptInfoPojo;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
@@ -52,4 +53,12 @@ public interface KwsEntDeptDao {
      */
     List<KwsEntDept> selectByEntPid(Long entPid);
 
+    /**
+     * @param list 企业id
+     * @return KwsEntDept
+     * @desc: 查主体单位
+     * @author: czh
+     * @date: 2023/7/22
+     */
+    List<KwsEntDept> selectByEntPidList(List<Long> list);
 }

+ 6 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteBaseService.java

@@ -7,6 +7,7 @@ import com.sckw.system.api.model.dto.res.*;
 import com.sckw.system.api.model.pojo.DeptInfoPojo;
 import com.sckw.system.dao.KwsEntDeptDao;
 import com.sckw.system.model.*;
+import com.sckw.system.model.pojo.FindEntDeptInfoPojo;
 import com.sckw.system.model.vo.res.CertificateResVo;
 import com.sckw.system.model.vo.res.KwsDeptResVo;
 import com.sckw.system.service.KwsDeptService;
@@ -136,4 +137,9 @@ public class RemoteBaseService {
             entCacheResDto.setEntDeptIds(String.join(Global.COMMA, kwsEntDepts.stream().map(KwsEntDept::getEntId).map(String::valueOf).toList()));
         }
     }
+
+
+    public List<KwsEntDept> queryEntDeptCacheByIds(List<Long> entIds) {
+        return kwsEntDeptDao.selectByEntPidList(entIds);
+    }
 }

+ 19 - 4
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteSystemServiceImpl.java

@@ -11,10 +11,7 @@ import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.*;
 import com.sckw.system.api.model.pojo.DeptInfoPojo;
 import com.sckw.system.dao.SysDictDao;
-import com.sckw.system.model.KwsEnterprise;
-import com.sckw.system.model.KwsUser;
-import com.sckw.system.model.SysArea;
-import com.sckw.system.model.SysDict;
+import com.sckw.system.model.*;
 import com.sckw.system.service.KwsUserService;
 import com.sckw.system.service.SysAreaService;
 import org.apache.dubbo.config.annotation.DubboService;
@@ -301,6 +298,24 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
         return list;
     }
 
+    @Override
+    public Map<Long, List<EntCacheResDto>> queryEntDeptCacheByIds(List<Long> entIds) {
+        List<KwsEntDept> kwsEntDepts = remoteBaseService.queryEntDeptCacheByIds(entIds);
+        if (CollectionUtils.isEmpty(kwsEntDepts)) {
+            return new HashMap<>(4);
+        }
+
+        Map<Long, List<KwsEntDept>> collect = kwsEntDepts.stream().collect(Collectors.groupingBy(KwsEntDept::getEntPid));
+        Map<Long, List<EntCacheResDto>> map = new HashMap<>();
+        for (Long key : collect.keySet()) {
+            List<KwsEntDept> kwsEntDepts1 = collect.get(key);
+            List<Long> entIdList = kwsEntDepts1.stream().map(KwsEntDept::getEntId).toList();
+            List<EntCacheResDto> entCacheResDtos = queryEntCacheByIds(entIdList);
+            map.put(key, entCacheResDtos);
+        }
+        return map;
+    }
+
     @Override
     public Map<Long, EntCacheResDto> queryEntCacheMapByIds(List<Long> entIds) {
         List<EntCacheResDto> entCacheResDtos = queryEntCacheByIds(entIds);

+ 39 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/pojo/FindEntDeptInfoPojo.java

@@ -0,0 +1,39 @@
+package com.sckw.system.model.pojo;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author czh
+ * @desc 查企业机构信息
+ * @date 2023/7/22
+ */
+@Data
+public class FindEntDeptInfoPojo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 2877831316094705633L;
+
+    /**
+     * 主体单位id
+     */
+    private Long id;
+
+    /**
+     * 父企业id
+     */
+    private Long pid;
+
+    /**
+     * 主体单为名
+     */
+    private String entName;
+
+    /**
+     * 父企业名
+     */
+    private String pEntName;
+
+}

+ 1 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/req/EditRoleReqVo.java

@@ -25,7 +25,7 @@ public class EditRoleReqVo implements Serializable {
     private String name;
 
     /**
-     * 当前单位id,可以是机构也可以是企业,目前产品设计是企业
+     * 当前机构
      */
     @NotBlank(message = "当前组织机构不能为空")
     private Long currentUnitId;

+ 34 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/res/QueryCurrentOrganizationResVo.java

@@ -0,0 +1,34 @@
+package com.sckw.system.model.vo.res;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author czh
+ * @desc 当前企业组织
+ * @date 2023/7/22
+ */
+@Data
+public class QueryCurrentOrganizationResVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -2663714495448672730L;
+
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+    /**
+     * 企业名
+     */
+    private String entName;
+
+    /**
+     * 父id
+     */
+    private Long pId;
+
+}

+ 4 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsDeptService.java

@@ -96,7 +96,7 @@ public class KwsDeptService {
     public void deleteByKey(String ids) throws SystemException {
         List<Long> list = Arrays.stream(ids.split(",")).map(Long::parseLong).toList();
         List<FindDeptUserPojo> findDeptUserPojoList = kwsDeptDao.findDeptUserByDeptIds(list);
-        if (!CollectionUtils.isEmpty(findDeptUserPojoList)) {
+        if (CollectionUtils.isNotEmpty(findDeptUserPojoList)) {
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.MSG_020);
         }
         deleteDept(kwsDeptDao.selectByKeys(list));
@@ -114,6 +114,9 @@ public class KwsDeptService {
         }
 
         for (KwsDept kwsDept : kwsDepts) {
+            if (kwsDept.getParentId().equals(0L)) {
+                throw new SystemException(HttpStatus.CODE_10301, HttpStatus.MSG_027);
+            }
             kwsDept.setDelFlag(Global.YES);
             if (kwsDeptDao.update(kwsDept) <= 0) {
                 throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);

+ 80 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -15,6 +15,7 @@ import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.model.EntCertificateInfo;
 import com.sckw.system.api.model.dto.req.RegisterReqDto;
+import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import com.sckw.system.api.model.dto.res.RegisterResDto;
 import com.sckw.system.dao.*;
 import com.sckw.system.dubbo.RemoteSystemServiceImpl;
@@ -25,7 +26,6 @@ import com.sckw.system.model.pojo.FindManagePojo;
 import com.sckw.system.model.pojo.FindPojoParam;
 import com.sckw.system.model.vo.req.*;
 import com.sckw.system.model.vo.res.*;
-import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -674,4 +674,83 @@ public class KwsEnterpriseService {
 
         return list;
     }
+
+
+    /**
+     * @param  entId id
+     * @return  QueryCurrentOrganization
+     * @desc: 查询企业的信息+主体机构信息
+     * @author: czh
+     * @date: 2023/7/22
+     */
+    public List<QueryCurrentOrganizationResVo> queryCurrentOrganization(Long entId) {
+        EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(entId);
+        if (Objects.isNull(entCacheResDto)) {
+            return Collections.emptyList();
+        }
+
+        List<QueryCurrentOrganizationResVo> list = new ArrayList<>();
+        QueryCurrentOrganizationResVo queryCurrentOrganizationResVo = new QueryCurrentOrganizationResVo();
+        queryCurrentOrganizationResVo.setEntId(entCacheResDto.getId());
+        queryCurrentOrganizationResVo.setEntName(entCacheResDto.getFirmName());
+        list.add(queryCurrentOrganizationResVo);
+
+        List<KwsEntDept> kwsEntDepts = kwsEntDeptDao.selectByEntPid(entId);
+        if (CollectionUtils.isEmpty(kwsEntDepts)) {
+            return list;
+        }
+
+        List<Long> entIdList = kwsEntDepts.stream().map(KwsEntDept::getEntId).toList();
+        Map<Long, EntCacheResDto> entCacheResDtoMap = remoteSystemService.queryEntCacheMapByIds(entIdList);
+        for (KwsEntDept kwsEntDept : kwsEntDepts) {
+            EntCacheResDto entCacheResDto1 = entCacheResDtoMap.get(kwsEntDept.getEntId());
+            if (Objects.isNull(entCacheResDto1)) {
+                continue;
+            }
+            QueryCurrentOrganizationResVo queryCurrentOrganizationResVo1 = new QueryCurrentOrganizationResVo();
+            queryCurrentOrganizationResVo1.setEntId(entCacheResDto1.getId());
+            queryCurrentOrganizationResVo1.setEntName(entCacheResDto1.getFirmName());
+            queryCurrentOrganizationResVo1.setPId(kwsEntDept.getEntPid());
+            list.add(queryCurrentOrganizationResVo1);
+        }
+
+        return list;
+    }
+
+
+    /**
+     * @param  entId id
+     * @return  QueryCurrentOrganization
+     * @desc: 查询其他入驻企
+     * @author: czh
+     * @date: 2023/7/22
+     */
+    public List<QueryCurrentOrganizationResVo> queryOtherEnt(Long entId) {
+        List<KwsEnterprise> kwsEnterprises = kwsEnterpriseDao.selectByKeys(null);
+        if (CollectionUtils.isEmpty(kwsEnterprises)) {
+            return Collections.emptyList();
+        }
+
+        //过滤除了当前企业的其他企业
+        kwsEnterprises = kwsEnterprises.stream().filter(item -> !item.getId().equals(entId)).toList();
+        if (CollectionUtils.isEmpty(kwsEnterprises)) {
+            return Collections.emptyList();
+        }
+
+        //过滤当前企业的主体机构
+        List<KwsEntDept> kwsEntDepts = kwsEntDeptDao.selectByEntPid(entId);
+        if (CollectionUtils.isNotEmpty(kwsEntDepts)) {
+            List<Long> entIdList = kwsEntDepts.stream().map(KwsEntDept::getEntId).toList();
+            kwsEnterprises = kwsEnterprises.stream().filter(item -> !entIdList.contains(item.getId())).toList();
+        }
+
+        List<QueryCurrentOrganizationResVo> list = new ArrayList<>();
+        for (KwsEnterprise kwsEnterprise : kwsEnterprises) {
+            QueryCurrentOrganizationResVo queryCurrentOrganizationResVo = new QueryCurrentOrganizationResVo();
+            queryCurrentOrganizationResVo.setEntId(kwsEnterprise.getId());
+            queryCurrentOrganizationResVo.setEntName(kwsEnterprise.getFirmName());
+            list.add(queryCurrentOrganizationResVo);
+        }
+        return list;
+    }
 }

+ 1 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsMenuService.java

@@ -262,7 +262,7 @@ public class KwsMenuService {
     }
 
     private void extracted(Long userId, FindMenuTreePojo findMenuTreePojo) {
-        if (Objects.isNull(userId)) {
+        if (Objects.equals(LoginUserHolder.getIsMain(), Global.YES)) {
             return;
         }
         KwsUser kwsUser = kwsUserDao.selectByKey(userId);

+ 14 - 9
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsRoleService.java

@@ -2,14 +2,12 @@ package com.sckw.system.service;
 
 import java.util.Date;
 
-import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
-import com.sckw.core.utils.BeanUtils;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.StringUtils;
@@ -89,9 +87,17 @@ public class KwsRoleService {
      */
     @Transactional(rollbackFor = Exception.class)
     public IdResVo add(EditRoleReqVo reqVo) {
-        IdResVo idResVo = new IdResVo();
+        Long currentUnitId = reqVo.getCurrentUnitId();
+        KwsDept kwsDept = kwsDeptDao.selectByKey(currentUnitId);
+        if (Objects.isNull(kwsDept)) {
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.DEPT_NOT_EXISTS);
+        }
 
-        List<KwsRole> kwsRoles = kwsRoleDao.selectBatchByUnitIds(Collections.singletonList(reqVo.getCurrentUnitId()));
+        String parentIds = kwsDept.getParentIds();
+        String[] split = parentIds.split(Global.COMMA);
+        Long topDeptId = Long.parseLong(split[0]);
+        IdResVo idResVo = new IdResVo();
+        List<KwsRole> kwsRoles = kwsRoleDao.selectBatchByUnitIds(Collections.singletonList(topDeptId));
         if (CollectionUtils.isNotEmpty(kwsRoles)) {
             List<String> nameList = kwsRoles.stream().map(KwsRole::getName).toList();
             if (nameList.contains(reqVo.getName())) {
@@ -105,7 +111,7 @@ public class KwsRoleService {
         idResVo.setId(roleId);
         kwsRole.setId(roleId);
         kwsRole.setName(reqVo.getName());
-        kwsRole.setDeptId(reqVo.getCurrentUnitId());
+        kwsRole.setDeptId(topDeptId);
         kwsRole.setRemark(reqVo.getRemark());
         if (kwsRoleDao.insert(kwsRole) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
@@ -114,7 +120,7 @@ public class KwsRoleService {
         /*2、绑定菜单功能*/
         RoleBindMenuReqVo roleBindMenuReqVo = new RoleBindMenuReqVo();
         roleBindMenuReqVo.setRoleId(roleId);
-        roleBindMenuReqVo.setEntId(reqVo.getCurrentUnitId());
+        roleBindMenuReqVo.setEntId(kwsDept.getEntId());
         roleBindMenuReqVo.setMenuIds(reqVo.getMenuIds());
         kwsMenuService.roleBindMenu(roleBindMenuReqVo);
 
@@ -187,8 +193,7 @@ public class KwsRoleService {
 
     /**
      * @param kwsRoles 角色实体类集合
-     * @return
-     * @desc: TODO
+     * @desc: 删角色
      * @author: czh
      * @date: 2023/6/28
      */
@@ -222,7 +227,7 @@ public class KwsRoleService {
         //让涉及到的用户重新登录获取菜单权限
         for (KwsUserRole kwsUserRole : kwsUserRoleList) {
             Long userId = kwsUserRole.getUserId();
-            RedissonUtils.deleteBactch(Global.REDIS_USER_LOGIN_PREFIX + userId + "*");
+            RedissonUtils.deleteBactch(Global.REDIS_USER_LOGIN_PREFIX + userId + Global.ASTERISK1);
         }
     }
 

+ 2 - 2
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsUserService.java

@@ -177,8 +177,8 @@ public class KwsUserService {
                 throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MENU_NOT_EXISTS);
             }
             editRoleReqVo.setName(Global.MANAGE_NAME);
-            editRoleReqVo.setCurrentUnitId(entId);
-            editRoleReqVo.setMenuIds(String.join(",", kwsMenus.stream().map(KwsMenu::getId).map(String::valueOf).toList()));
+            editRoleReqVo.setCurrentUnitId(kwsDept.getId());
+            editRoleReqVo.setMenuIds(String.join(Global.COMMA, kwsMenus.stream().map(KwsMenu::getId).map(String::valueOf).toList()));
             editRoleReqVo.setVisiblePersonal(false);
             kwsRoleService.add(editRoleReqVo);
         }

+ 1 - 1
sckw-modules/sckw-system/src/main/resources/mapper/KwsDeptDao.xml

@@ -196,7 +196,7 @@
     from kws_dept sd
     left join kws_dept sd2 on sd.parent_id = sd2.id and sd2.del_flag=0
     left join kws_user u1 on sd.create_by = u1.id
-    left join kws_user u2 on sd.update_by = u1.id
+    left join kws_user u2 on sd.update_by = u2.id
     where sd.del_flag = 0
     <if test="systemType != null and systemType != ''">
       and sd.system_type = #{systemType, jdbcType=VARCHAR}

+ 10 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsEntDeptDao.xml

@@ -34,6 +34,16 @@
     select * from kws_ent_dep where del_flag = 0 and ent_pid = #{entPid}
   </select>
 
+  <select id="selectByEntPidList" resultType="com.sckw.system.model.KwsEntDept">
+    select *
+    from kws_ent_dep
+    where del_flag = 0
+      and ent_pid in
+    <foreach collection="list" item="item" open="(" close=")" separator=",">
+        #{item}
+    </foreach>
+  </select>
+
   <insert id="insert" parameterType="com.sckw.system.model.KwsEntDept">
     insert into kws_ent_dep
     <trim prefix="(" suffix=")" suffixOverrides=",">

+ 9 - 5
sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml

@@ -181,11 +181,15 @@
     select
     <include refid="Base_Column_List" />
     from kws_enterprise
-    where id in
-        <foreach collection="list" item="item" open="(" close=")" separator=",">
-          #{item}
-        </foreach>
-      and del_flag = 0
+    where del_flag = 0
+    <if test="list != null and list.size() > 0">
+      and id in
+      <foreach collection="list" item="item" open="(" close=")" separator=",">
+        #{item}
+      </foreach>
+    </if>
+
+
 
   </select>
 

+ 1 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsRoleDao.xml

@@ -144,6 +144,7 @@
     left join kws_user su on sr.create_by = su.id
     left join kws_dept d on sr.dept_id = d.id
     where sr.del_flag = 0
+      and su.del_flag = 0
     <if test="name != null and name != ''">
       and sr.name like concat('%', #{name, jdbcType=VARCHAR}, '%')
     </if>

+ 1 - 1
sckw-modules/sckw-system/src/main/resources/mapper/KwsUserDao.xml

@@ -313,7 +313,7 @@
   </select>
 
   <select id="selectByRoleIds" resultType="com.sckw.system.model.KwsUser">
-    select distinct *
+    select distinct a.*
       from kws_user a
       left join kws_user_role b on a.id = b.user_id
      where a.del_flag = 0

+ 3 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsUserRoleDao.xml

@@ -29,9 +29,11 @@
   <select id="findAllByUserId" resultType="com.sckw.system.model.KwsUserRole">
     select * from kws_user_role where user_id = #{userId} and del_flag = 0 and status = 0
   </select>
+
   <select id="findAllByRoleId" resultType="com.sckw.system.model.KwsUserRole">
     select * from kws_user_role where role_id = #{roleId} and del_flag = 0 and status = 0
   </select>
+
   <select id="findAllByRoleIds" resultType="com.sckw.system.model.KwsUserRole">
     select *
       from kws_user_role
@@ -175,4 +177,5 @@
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
+
 </mapper>