瀏覽代碼

科室模板维护

gaodm 6 年之前
父節點
當前提交
fa294c1614

+ 3 - 2
icssman-service/src/main/java/com/diagbot/dto/DeptVitalDTO.java

@@ -1,6 +1,5 @@
 package com.diagbot.dto;
 
-import com.diagbot.entity.DeptInfo;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -14,7 +13,9 @@ import java.util.List;
  */
 @Getter
 @Setter
-public class DeptVitalDTO extends DeptInfo {
+public class DeptVitalDTO {
+    private Long deptId; // 科室概念id
+    private String name;    //概念名称
     private String operator;
     private String operatorName;
     private Date gmtOperate;

+ 110 - 23
icssman-service/src/main/java/com/diagbot/facade/DeptVitalFacade.java

@@ -3,12 +3,13 @@ package com.diagbot.facade;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.diagbot.client.KnowledgemanServiceClient;
 import com.diagbot.client.UserServiceClient;
+import com.diagbot.dto.ConceptBaseDTO;
 import com.diagbot.dto.DeptShortDTO;
 import com.diagbot.dto.DeptVitalDTO;
 import com.diagbot.dto.QuestionShortDTO;
 import com.diagbot.dto.RespDTO;
-import com.diagbot.entity.DeptInfo;
 import com.diagbot.entity.DeptVital;
 import com.diagbot.entity.QuestionInfo;
 import com.diagbot.enums.IsDeleteEnum;
@@ -20,7 +21,11 @@ import com.diagbot.service.impl.DeptVitalServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.EntityUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.RespDTOUtil;
 import com.diagbot.util.UserUtils;
+import com.diagbot.vo.ConceptSearchVO;
+import com.diagbot.vo.ConceptTypeVO;
 import com.diagbot.vo.DVDetailVO;
 import com.diagbot.vo.DeptVitalPageVO;
 import com.diagbot.vo.DeptVitalVO;
@@ -29,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -45,12 +51,12 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
     @Autowired
     private QuestionFacade questionFacade;
     @Autowired
-    private DeptInfoFacade deptInfoFacade;
-    @Autowired
     @Qualifier("deptVitalServiceImpl")
     private DeptVitalService deptVitalService;
     @Autowired
     private UserServiceClient userServiceClient;
+    @Autowired
+    private KnowledgemanServiceClient klmServiceClient;
 
     /**
      * 保存查体模板
@@ -59,10 +65,16 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
      * @return
      */
     public Boolean saveDeptVitals(DeptVitalVO deptVitalVO) {
-        DeptInfo deptInfo = deptInfoFacade.getById(deptVitalVO.getDeptId());
-        if (deptInfo == null) {
-            throw new CommonException(CommonErrorCode.NOT_EXISTS, "科室不存在");
+        //科室存在性验证
+        isExist(deptVitalVO.getDeptId());
+        //验证模板是否已存在
+        QueryWrapper<DeptVital> deptVitalQueryWrapper = new QueryWrapper<>();
+        deptVitalQueryWrapper.eq("dept_id", deptVitalVO.getDeptId()).
+                eq("is_deleted", IsDeleteEnum.N.getKey());
+        if (this.count(deptVitalQueryWrapper) > 0) {
+            throw new CommonException(CommonErrorCode.IS_EXISTS, "该科室模板已经存在!");
         }
+
         //先删除该科室原有模板
         UpdateWrapper<DeptVital> deptVitalUpdateWrapper = new UpdateWrapper<>();
         deptVitalUpdateWrapper.eq("dept_id", deptVitalVO.getDeptId()).
@@ -151,14 +163,11 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
      * @return
      */
     public DeptVitalDTO getModuleByDeptId(Long deptId) {
+        //科室存在性验证
+        Map<Long, String> deptMap = isExist(deptId);
         DeptVitalDTO deptVitalDTO = new DeptVitalDTO();
-        DeptInfo deptInfo = deptInfoFacade.getById(deptId);
-        if (deptInfo == null) {
-            throw new CommonException(CommonErrorCode.NOT_EXISTS, "科室不存在");
-        } else if (deptInfo.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
-            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "科室已删除");
-        }
-        BeanUtil.copyProperties(deptInfo, deptVitalDTO);
+        deptVitalDTO.setDeptId(deptId);
+        deptVitalDTO.setName(deptMap.get(deptId));
 
         //已关联查体
         QueryWrapper<DeptVital> deptVitalQueryWrapper = new QueryWrapper<>();
@@ -205,13 +214,24 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
     public IPage<DeptVitalDTO> getDeptVitalPageByMap(DeptVitalPageVO deptVitalPageVO) {
         IPage<DeptVitalDTO> page = this.getDeptVitalPage(deptVitalPageVO);
         List<DeptVitalDTO> deptVitalDTOList = page.getRecords();
+        //操作人信息
         List<String> userIds = deptVitalDTOList.stream().map(deptVitalDTO -> deptVitalDTO.getOperator()).collect(Collectors.toList());
         RespDTO<Map<String, String>> data = userServiceClient.getUserInfoByIds(userIds);
         Map<String, String> userInfos = data.data;
+        //科室信息
+        List<Long> deptIds = deptVitalDTOList.stream().map(deptVitalDTO -> deptVitalDTO.getDeptId()).collect(Collectors.toList());
+        ConceptSearchVO conceptSearchVO = new ConceptSearchVO();
+        conceptSearchVO.setConceptIds(deptIds);
+        RespDTO<Map<Long, String>> deptMap = klmServiceClient.getConceptMap(conceptSearchVO);
+        Map<Long, String> depts = deptMap.data;
+
         for (DeptVitalDTO deptVitalDTO : deptVitalDTOList) {
-            if (userInfos.get(deptVitalDTO.getOperator()) != null) {
+            if (null != userInfos.get(deptVitalDTO.getOperator())) {
                 deptVitalDTO.setOperatorName(userInfos.get(deptVitalDTO.getOperator()));
             }
+            if (null != depts.get(deptVitalDTO.getDeptId())) {
+                deptVitalDTO.setName(depts.get(deptVitalDTO.getDeptId()));
+            }
         }
         page.setRecords(deptVitalDTOList);
         return page;
@@ -223,11 +243,23 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
      * @return
      */
     public List<DeptShortDTO> getDeptShortList(List<Long> deptIds) {
-        QueryWrapper<DeptInfo> deptInfoQueryWrapper = new QueryWrapper<>();
-        deptInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
-                notIn("id", deptIds);
-        List<DeptInfo> deptInfoList = deptInfoFacade.list(deptInfoQueryWrapper);
-        List<DeptShortDTO> deptShortDTOList = BeanUtil.listCopyTo(deptInfoList, DeptShortDTO.class);
+        //获取所有科室
+        ConceptTypeVO conceptTypeVO = new ConceptTypeVO();
+        conceptTypeVO.setType(1);
+        RespDTO<List<ConceptBaseDTO>> deptList = klmServiceClient.getConceptListByType(conceptTypeVO);
+        RespDTOUtil.respNGDealCover(deptList, "科室不存在");
+        //去除已经存在的科室
+        List<DeptShortDTO> deptShortDTOList = new ArrayList<>();
+        if (ListUtil.isNotEmpty(deptList.data)) {
+            for (ConceptBaseDTO conceptBaseDTO : deptList.data) {
+                if (!deptIds.contains(conceptBaseDTO.getConceptId())) {
+                    DeptShortDTO deptShortDTO = new DeptShortDTO();
+                    deptShortDTO.setId(conceptBaseDTO.getConceptId());
+                    deptShortDTO.setName(conceptBaseDTO.getName());
+                    deptShortDTOList.add(deptShortDTO);
+                }
+            }
+        }
         return deptShortDTOList;
     }
 
@@ -252,16 +284,71 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
      * @return
      */
     public List<DeptShortDTO> getDeptShortLisModify(Long expId) {
+        List<Long> deptIds = this.getAllExist();
+        if (deptIds.contains(expId)) {
+            deptIds.remove(expId);
+            deptIds.size();
+        }
+        return getDeptShortList(deptIds);
+    }
+
+    /**
+     * 获取科室下拉列表-查询
+     *
+     * @return
+     */
+    public List<DeptShortDTO> getDeptShortListSearch() {
+        List<Long> deptIds = this.getAllExist();
+        List<DeptShortDTO> res = ListUtil.newArrayList();
+        if (ListUtil.isNotEmpty(deptIds)) {
+            ConceptSearchVO conceptSearchVO = new ConceptSearchVO();
+            List<Long> conceptIds = ListUtil.newArrayList();
+            conceptSearchVO.setConceptIds(deptIds);
+            RespDTO<Map<Long, String>> deptMap = klmServiceClient.getConceptMap(conceptSearchVO);
+            for (Long deptId : deptIds) {
+                if (null != deptMap.data.get(deptId)) {
+                    DeptShortDTO deptShortDTO = new DeptShortDTO();
+                    deptShortDTO.setId(deptId);
+                    deptShortDTO.setName(deptMap.data.get(deptId));
+                    res.add(deptShortDTO);
+                }
+            }
+        }
+
+        return res;
+    }
+
+    /**
+     * 获取所有已经存在的科室
+     *
+     * @return 已经存在的科室的Id列表
+     */
+    private List<Long> getAllExist() {
         QueryWrapper<DeptVital> deptVitalQueryWrapper = new QueryWrapper<>();
         deptVitalQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
                 select("dept_id").
                 groupBy("dept_id");
         List<DeptVital> deptVitalList = this.list(deptVitalQueryWrapper);
         List<Long> deptIds = deptVitalList.stream().map(deptVital -> deptVital.getDeptId()).collect(Collectors.toList());
-        if (deptIds.contains(expId)) {
-            deptIds.remove(expId);
-            deptIds.size();
+        return deptIds;
+    }
+
+    /**
+     * 存在性验证
+     *
+     * @param deptId 科室id
+     * @return 科室信息Map
+     */
+    private Map<Long, String> isExist(Long deptId) {
+        ConceptSearchVO conceptSearchVO = new ConceptSearchVO();
+        List<Long> conceptIds = ListUtil.newArrayList();
+        conceptIds.add(deptId);
+        conceptSearchVO.setConceptIds(conceptIds);
+        RespDTO<Map<Long, String>> deptMap = klmServiceClient.getConceptMap(conceptSearchVO);
+        RespDTOUtil.respNGDealCover(deptMap, "科室不存在");
+        if (null == deptMap.data.get(deptId)) {
+            throw new CommonException(CommonErrorCode.NOT_EXISTS, "科室不存在");
         }
-        return getDeptShortList(deptIds);
+        return deptMap.data;
     }
 }

+ 1 - 1
icssman-service/src/main/java/com/diagbot/vo/DeptVitalPageVO.java

@@ -12,5 +12,5 @@ import lombok.Setter;
 @Getter
 @Setter
 public class DeptVitalPageVO extends Page {
-    private String deptName;
+    private Long deptId;
 }

+ 15 - 6
icssman-service/src/main/java/com/diagbot/web/DeptVitalController.java

@@ -34,13 +34,13 @@ import java.util.List;
 @RestController
 @RequestMapping("/deptVital")
 @SuppressWarnings("unchecked")
-@Api(value = "查体模板相关API", tags = { "查体模板相关API" })
+@Api(value = "查体模板相关API", tags = { "知识库标准化-查体模板相关API" })
 public class DeptVitalController {
 
     @Autowired
     private DeptVitalFacade deptVitalFacade;
 
-    @ApiOperation(value = "保存查体模板[by:zhaops]",
+    @ApiOperation(value = "知识库标准化-保存查体模板[by:zhaops]",
             notes = "deptId:科室ID,必填<br>" +
                     "dvDetailVOList:查体标签明细,必填<br>" +
                     "vitalId:查体标签id,必填<br>" +
@@ -76,7 +76,7 @@ public class DeptVitalController {
         return RespDTO.onSuc(data);
     }
 
-    @ApiOperation(value = "根据科室ID获取查体模板[by:zhaops]",
+    @ApiOperation(value = "知识库标准化-根据科室ID获取查体模板[by:zhaops]",
             notes = "deptId:科室ID,必填<br>")
     @PostMapping("/getModuleByDeptId")
     @SysLogger("getModuleByDeptId")
@@ -91,7 +91,7 @@ public class DeptVitalController {
      * @param deptVitalPageVO
      * @return
      */
-    @ApiOperation(value = "分页查询查体模板,可带过滤条件[by:zhaops]",
+    @ApiOperation(value = "知识库标准化-分页查询查体模板,可带过滤条件[by:zhaops]",
             notes = "current:页码,必填<br>" +
                     "size:每页显示条数,必填<br>" +
                     "deptName:科室名称<br>")
@@ -102,7 +102,7 @@ public class DeptVitalController {
         return RespDTO.onSuc(infoIPage);
     }
 
-    @ApiOperation(value = "查询科室下拉列表-新增[by:zhaops]")
+    @ApiOperation(value = "知识库标准化-查询科室下拉列表-新增[by:zhaops]")
     @PostMapping("/getDeptShortList_create")
     @SysLogger("getDeptShortList_create")
     public RespDTO<DeptShortDTO> getDeptShortListCreate() {
@@ -110,7 +110,7 @@ public class DeptVitalController {
         return RespDTO.onSuc(data);
     }
 
-    @ApiOperation(value = "查询科室下拉列表-修改[by:zhaops]",
+    @ApiOperation(value = "知识库标准化-查询科室下拉列表-修改[by:zhaops]",
             notes = "deptId:科室ID,必填<br>")
     @PostMapping("/getDeptShortList_modify")
     @SysLogger("getDeptShortList_modify")
@@ -118,4 +118,13 @@ public class DeptVitalController {
         List<DeptShortDTO> data = deptVitalFacade.getDeptShortLisModify(deptIdVO.getDeptId());
         return RespDTO.onSuc(data);
     }
+
+    @ApiOperation(value = "知识库标准化-查询科室下拉列表-查询[by:zhaops]",
+            notes = "deptId:科室ID,必填<br>")
+    @PostMapping("/getDeptShortList_Searh")
+    @SysLogger("getDeptShortList_Searh")
+    public RespDTO<DeptShortDTO> getDeptShortListSearch() {
+        List<DeptShortDTO> data = deptVitalFacade.getDeptShortListSearch();
+        return RespDTO.onSuc(data);
+    }
 }

+ 5 - 7
icssman-service/src/main/resources/mapper/DeptVitalMapper.xml

@@ -32,13 +32,11 @@
 
     <!--查询已有模板分页-->
     <select id="getDeptVitalPage" resultMap="DeptVitalDTOMap">
-        SELECT DISTINCT a.*, b.modifier AS operator,b.gmt_modified AS gmt_operate
-        FROM icss_dept_info a,icss_dept_vital b
-        WHERE a.id = b.dept_id
-          AND a.is_deleted = 'N'
-          AND b.is_deleted = 'N'
-          <if test="deptVitalPageVO.deptName!=null and deptVitalPageVO.deptName!=''">
-              AND a.name like CONCAT("%",#{deptVitalPageVO.deptName},"%")
+        SELECT DISTINCT b.dept_id AS deptId, b.modifier AS operator,b.gmt_modified AS gmt_operate
+        FROM icss_dept_vital b
+        WHERE b.is_deleted = 'N'
+          <if test="deptVitalPageVO.deptId != null">
+              AND b.dept_id = #{deptVitalPageVO.deptId}
           </if>
         order by b.gmt_modified desc
     </select>

+ 7 - 2
knowledgeman-service/src/main/java/com/diagbot/facade/ConceptFacade.java

@@ -669,8 +669,13 @@ public class ConceptFacade extends ConceptServiceImpl {
      */
     public List<Concept> getListByIds(List<Long> ids) {
         QueryWrapper<Concept> conceptQueryWrapper = new QueryWrapper<>();
-        conceptQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
-                .in("id", ids);
+        conceptQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
+        if (ids.size() == 1){
+            conceptQueryWrapper.eq("id", ids.get(0));
+        } else {
+            conceptQueryWrapper.in("id", ids);
+        }
+
         List<Concept> list = this.list(conceptQueryWrapper);
         return list;
     }