Просмотр исходного кода

新增密码重置功能、修改当前用户组织树功能

songxinlu 3 лет назад
Родитель
Сommit
c61d6e772a

+ 5 - 0
common/src/main/java/com/lantone/common/dto/GetHospitalListInfoDTO.java

@@ -23,6 +23,10 @@ public class GetHospitalListInfoDTO implements Serializable {
 
     @ApiModelProperty(value = "名称")
     private String hospitalName;
+    @ApiModelProperty(value = "是否存在子组织")
+    private boolean hasHospitalFlag;
+    @ApiModelProperty(value = "该组织是否存在用户")
+    private boolean hasUserFlag;
     @ApiModelProperty(value = "状态")
     private String status;
 
@@ -34,6 +38,7 @@ public class GetHospitalListInfoDTO implements Serializable {
 
     @ApiModelProperty(value = "该虚拟医院的医院列表")
     private List<GetHospitalListInfoDTO> children;
+
     @ApiModelProperty(value = "记录创建时间")
     private Date gmtCreate;
 }

+ 2 - 0
dblayer-mbg/src/main/java/com/lantone/dblayermbg/mapper/UserMapper.java

@@ -25,4 +25,6 @@ public interface UserMapper extends BaseMapper<User> {
     List<SoftwareDTO> getUserSoftwareByUId(@Param("userID") Long userID);
 
     List<GetUserHospitalsDTO> getUserSoftwareHospitals(@Param("userID")Long currentPrincipleId, @Param("softwareID")Long id);
+
+    Long getUserByHospitalId(@Param("hospitalId") Long hospitalId);
 }

+ 19 - 0
dblayer-mbg/src/main/resources/mapper/UserMapper.xml

@@ -101,4 +101,23 @@
         AND u.id = #{userID}
         AND s.id = #{softwareID}
     </select>
+    <select id="getUserByHospitalId" resultType="java.lang.Long">
+        SELECT
+            id
+        FROM
+            sys_user u
+        WHERE
+            u.is_deleted = 'N'
+        AND u.`status` = '1'
+        AND u.remark = 'Administrators'
+        AND u.id IN (
+            SELECT
+                hu.user_id
+            FROM
+                sys_hospital_user hu
+            WHERE
+                hu.is_deleted = 'N'
+            AND hu.hospital_id = #{hospitalId}
+        )
+    </select>
 </mapper>

+ 3 - 0
security-center/src/main/java/com/lantone/security/enums/DictionaryEnum.java

@@ -10,6 +10,9 @@ import lombok.Setter;
  */
 public enum DictionaryEnum implements KeyedNamed {
     TITLE(40, "职称"),
+    HOSPITAL_TYPE(43, "组织类型"),
+    PASSWORD(44, "重置密码"),
+    REGION(45, "病区"),
     NOT_SHOW_MENU(41,"不显示菜单");
 
     @Setter

+ 61 - 34
security-center/src/main/java/com/lantone/security/facade/HospitalManagementFacade.java

@@ -1,5 +1,7 @@
 package com.lantone.security.facade;
 
+import cn.hutool.crypto.digest.BCrypt;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.lantone.common.dto.DownBoxRegionDTO;
@@ -7,6 +9,7 @@ import com.lantone.common.dto.GetHospitalByIdDTO;
 import com.lantone.common.dto.GetHospitalListInfoDTO;
 import com.lantone.common.dto.GetHospitalUserDTO;
 import com.lantone.common.enums.IsDeleteEnum;
+import com.lantone.common.enums.StatusEnum;
 import com.lantone.common.exception.Asserts;
 import com.lantone.common.util.DateUtil;
 import com.lantone.common.util.EntityUtil;
@@ -20,6 +23,7 @@ import com.lantone.common.vo.GetHospitalListInfoVO;
 import com.lantone.common.vo.UpdateHospitalVO;
 import com.lantone.dblayermbg.entity.DictionaryInfo;
 import com.lantone.dblayermbg.entity.Hospital;
+import com.lantone.dblayermbg.entity.HospitalUser;
 import com.lantone.dblayermbg.entity.Region;
 import com.lantone.dblayermbg.entity.Role;
 import com.lantone.dblayermbg.entity.User;
@@ -67,6 +71,7 @@ public class HospitalManagementFacade {
     private RegionFacade regionFacade;
     @Autowired
     private DictionaryInfoFacade dictionaryInfoFacade;
+
     /**
      * @param addHospitalVO
      * @Description添加组织
@@ -155,7 +160,7 @@ public class HospitalManagementFacade {
         //1.获取用户id
         Long userId = hospitalUserFacade.getBaseMapper().getHospitalUserById(hospitalId);
         //2.获取角色id
-        Long roleId = userRoleFacade.getBaseMapper().getUserRoleById(userId,hospitalId);
+        Long roleId = userRoleFacade.getBaseMapper().getUserRoleById(userId, hospitalId);
         if (roleManagementFacade.deleteRole(roleId)) {
             //3.删除用户
             return userManagementFacade.deleteUser(userId);
@@ -217,7 +222,7 @@ public class HospitalManagementFacade {
         getHospitalByIdDTO.setGetHospitalUserDTO(getHospitalUserDTO);
         //3.获取管理角色相关信息
         getHospitalByIdDTO.setGetRoleDTO(roleManagementFacade.getRoleById(userRoleFacade.getBaseMapper()
-                .getUserRoleById(user.getId(),hospitalId)));
+                .getUserRoleById(user.getId(), hospitalId)));
         return getHospitalByIdDTO;
     }
 
@@ -226,8 +231,8 @@ public class HospitalManagementFacade {
      * @Description组织管理列表页管理员下拉框筛选类型、病区查询
      * @Return java.util.Map<java.lang.String, java.lang.Object>
      */
-    public Map<String, Object> getManagerBoxInfo() {
-        Map<String, Object> outMap = new HashMap<>();
+    public Map<Integer, Object> getManagerBoxInfo() {
+        Map<Integer, Object> outMap = new HashMap<>();
         Map<Integer, String> hospitalTypeMap = new HashMap<>();
         //1.获取当前用户的组织类型
         int hospitalType = -1;
@@ -246,28 +251,13 @@ public class HospitalManagementFacade {
                 BeanUtils.copyProperties(region, downBoxRegionDTO);
                 downBoxRegions.add(downBoxRegionDTO);
             });
-            outMap.put("所属病区", downBoxRegions);
-        } else if (HospitalTypeEnum.AI_PLATFORM.getKey() == hospitalType) {
-            hospitalTypeMap.put(HospitalTypeEnum.GROUP_HOSPITAL.getKey(), HospitalTypeEnum.GROUP_HOSPITAL.getName());
-            hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(), HospitalTypeEnum.SINGLE_HOSPITAL.getName());
-            hospitalTypeMap.put(HospitalTypeEnum.COMMON_HOSPITAL.getKey(), HospitalTypeEnum.COMMON_HOSPITAL.getName());
-            hospitalTypeMap.put(HospitalTypeEnum.UNION_HOSPITAL.getKey(), HospitalTypeEnum.UNION_HOSPITAL.getName());
-            outMap.put("类型", hospitalTypeMap);
-        } else if (HospitalTypeEnum.GROUP_HOSPITAL.getKey() == hospitalType) {
-            hospitalTypeMap.put(HospitalTypeEnum.GROUP_HOSPITAL.getKey(), HospitalTypeEnum.GROUP_HOSPITAL.getName());
-            hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(), HospitalTypeEnum.SINGLE_HOSPITAL.getName());
-            outMap.put("类型", hospitalTypeMap);
-        } else if (HospitalTypeEnum.COMMON_HOSPITAL.getKey() == hospitalType) {
-            hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(), HospitalTypeEnum.SINGLE_HOSPITAL.getName());
-            hospitalTypeMap.put(HospitalTypeEnum.COMMON_HOSPITAL.getKey(), HospitalTypeEnum.COMMON_HOSPITAL.getName());
-            outMap.put("类型", hospitalTypeMap);
-        } else if (HospitalTypeEnum.UNION_HOSPITAL.getKey() == hospitalType) {
-            hospitalTypeMap.put(HospitalTypeEnum.SINGLE_HOSPITAL.getKey(), HospitalTypeEnum.SINGLE_HOSPITAL.getName());
-            hospitalTypeMap.put(HospitalTypeEnum.UNION_HOSPITAL.getKey(), HospitalTypeEnum.UNION_HOSPITAL.getName());
-            outMap.put("类型", hospitalTypeMap);
+            outMap.put(DictionaryEnum.REGION.getKey(), downBoxRegions);
+        } else {
+            JSONObject Type = JSONObject.parseObject(dictionaryInfoFacade.getBaseMapper().getDictionaryInfoByType(DictionaryEnum.HOSPITAL_TYPE.getKey()).get(0).getVal());
+            outMap.put(DictionaryEnum.HOSPITAL_TYPE.getKey(), Type.get(hospitalType));
         }
         //添加职称信息
-        outMap.put(DictionaryEnum.TITLE.getName(),dictionaryInfoFacade.getBaseMapper().getDictionaryInfoByType(DictionaryEnum.TITLE.getKey()));
+        outMap.put(DictionaryEnum.TITLE.getKey(), dictionaryInfoFacade.getBaseMapper().getDictionaryInfoByType(DictionaryEnum.TITLE.getKey()));
         return outMap;
     }
 
@@ -287,27 +277,33 @@ public class HospitalManagementFacade {
         //单家医院
         if (HospitalTypeEnum.SINGLE_HOSPITAL.getKey() == hospitalType) {
             //1.获取当前登陆用户所在医院的科室信息
-        GetHospitalListInfoDTO getHospitalListInfoDTO = new GetHospitalListInfoDTO();
-        getHospitalListInfoDTO.setHospitalId(hospital.getId());
-        getHospitalListInfoDTO.setHospitalName(hospital.getName());
-        BeanUtils.copyProperties(hospital,getHospitalListInfoDTO);
-        getHospitalListInfoDTO.setDepts(deptFacade.getBaseMapper().getDeptRegion(getHospitalListInfoVO));
-        List<GetHospitalListInfoDTO> hospitalListInfos = new ArrayList<>();
-        hospitalListInfos.add(getHospitalListInfoDTO);
-        return hospitalListInfos;
+            GetHospitalListInfoDTO getHospitalListInfoDTO = new GetHospitalListInfoDTO();
+            getHospitalListInfoDTO.setHospitalId(hospital.getId());
+            getHospitalListInfoDTO.setHospitalName(hospital.getName());
+            BeanUtils.copyProperties(hospital, getHospitalListInfoDTO);
+            getHospitalListInfoDTO.setDepts(deptFacade.getBaseMapper().getDeptRegion(getHospitalListInfoVO));
+            List<GetHospitalListInfoDTO> hospitalListInfos = new ArrayList<>();
+            if (ListUtil.isNotEmpty(getHospitalListInfoDTO.getDepts())) {
+                getHospitalListInfoDTO.setHasUserFlag(true);
+            }
+            hospitalListInfos.add(getHospitalListInfoDTO);
+            return hospitalListInfos;
             //虚拟医院
         } else if (hospitalType >= 0) {
             List<GetHospitalListInfoDTO> hospitalListInfoDTOS = hospitalFacade.getBaseMapper().getHospitalById(getHospitalListInfoVO);
             Map<Long, List<GetHospitalListInfoDTO>> hospitalMaps = EntityUtil.makeEntityListMap(hospitalListInfoDTOS, "parentId");
             List<GetHospitalListInfoDTO> hospitalListInfos = hospitalMaps.get(hospital.getParentId());
-            for(GetHospitalListInfoDTO bean:hospitalListInfos){
-                getSonHospital(bean,hospitalMaps);
+            for (GetHospitalListInfoDTO bean : hospitalListInfos) {
+                //获取该组织是否有子组织、用户
+                getHospitalSonORUser(bean);
+                getSonHospital(bean, hospitalMaps);
             }
             return hospitalListInfos;
         }
 
         return null;
     }
+
     /**
      * 递归获取医院结构
      *
@@ -316,6 +312,8 @@ public class HospitalManagementFacade {
      * @return 空
      */
     public void getSonHospital(GetHospitalListInfoDTO hospital, Map<Long, List<GetHospitalListInfoDTO>> hospitalMap) {
+        //获取该组织是否有子组织、用户
+        getHospitalSonORUser(hospital);
         List<GetHospitalListInfoDTO> hospitals = hospitalMap.get(hospital.getHospitalId());
         if (ListUtil.isNotEmpty(hospitals)) {
             hospital.setChildren(hospitals);
@@ -324,4 +322,33 @@ public class HospitalManagementFacade {
             }
         }
     }
+
+    private void getHospitalSonORUser(GetHospitalListInfoDTO hospital) {
+        if (hospital != null && hospital.getHospitalId() != null) {
+            //获取该组织用户
+            if(hospitalUserFacade.list(new QueryWrapper<HospitalUser>()
+                    .eq("hospital_id",hospital.getHospitalId())
+                    .eq("is_deleted",IsDeleteEnum.N.getKey())).size()>1){
+                hospital.setHasUserFlag(true);
+            }
+            //获取该组织子组织
+            if(hospitalFacade.list(new QueryWrapper<Hospital>()
+                    .eq("parent_id",hospital.getHospitalId())
+                    .eq("status", StatusEnum.Enable.getKey())
+                    .eq("is_deleted",IsDeleteEnum.N.getKey())).size()>0){
+                hospital.setHasHospitalFlag(true);
+            }
+        }
+    }
+    /**
+     * @Description重置密码
+     * @param hospitalId
+     * @Return boolean
+     */
+    public boolean resetPassword(Long hospitalId) {
+        User user = new User();
+        user.setPassword(BCrypt.hashpw(dictionaryInfoFacade.getBaseMapper().getDictionaryInfoByType(DictionaryEnum.PASSWORD.getKey()).get(0).getVal()));
+        user.setId(userFacade.getBaseMapper().getUserByHospitalId(hospitalId));
+        return userFacade.updateById(user);
+    }
 }

+ 8 - 1
security-center/src/main/java/com/lantone/security/web/HospitalManagementController.java

@@ -69,7 +69,7 @@ public class HospitalManagementController {
 
     @ApiOperation(value = "组织管理列表页管理员下拉框筛选类型、病区、职称查询 [by:songxl]")
     @PostMapping("/getManagerBoxInfo")
-    public CommonResult<Map<String,Object>> getManagerBoxInfo() {
+    public CommonResult<Map<Integer,Object>> getManagerBoxInfo() {
         return CommonResult.success(hospitalManagementFacade.getManagerBoxInfo());
     }
     @ApiOperation(value = "组织管理列表页查询 [by:songxl]")
@@ -77,4 +77,11 @@ public class HospitalManagementController {
     public CommonResult<List<GetHospitalListInfoDTO>> getHospitalListInfo(@RequestBody GetHospitalListInfoVO getHospitalListInfoVO) {
         return CommonResult.success(hospitalManagementFacade.getHospitalListInfo(getHospitalListInfoVO));
     }
+
+    @ApiOperation(value = "重置密码 [by:songxl]")
+    @PostMapping("/resetPassword")
+    @Transactional
+    public CommonResult<Boolean> resetPassword(@RequestParam @Valid @NotNull(message = "组织编号为空") Long HospitalId) {
+        return CommonResult.success(hospitalManagementFacade.resetPassword(HospitalId));
+    }
 }