Pārlūkot izejas kodu

更新和保存接口

wangfeng 4 gadi atpakaļ
vecāks
revīzija
6328668ff4

+ 3 - 1
cdssman-service/src/main/java/com/diagbot/dto/KlConceptAllDTO.java

@@ -13,9 +13,10 @@ import lombok.Setter;
 @Getter
 public class KlConceptAllDTO {
     private Long conceptId;
+    private Long libId;
     private String libName;
     private String spell;
-    private String libType;
+    private Integer libType;
     private String typeName;
     private String synonymName;
     private Integer status;
@@ -28,4 +29,5 @@ public class KlConceptAllDTO {
     private Double maxVal;
     private Integer scopeType;
     private String  icdCode;
+    private String remark;
 }

+ 217 - 6
cdssman-service/src/main/java/com/diagbot/facade/KlConceptFacade.java

@@ -1,34 +1,49 @@
 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.diagbot.dto.GetAllForRelationDTO;
+import com.diagbot.client.UserServiceClient;
 import com.diagbot.dto.KlConceptAllDTO;
 import com.diagbot.dto.KlConceptInfoDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.KlConcept;
 import com.diagbot.entity.KlRelation;
+import com.diagbot.entity.KlConceptCommon;
+import com.diagbot.entity.KlDisease;
+import com.diagbot.entity.KlLibraryInfo;
+import com.diagbot.entity.KlLis;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.enums.LexiconEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.service.KlConceptService;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.KlConceptCommonService;
+import com.diagbot.service.KlDiseaseService;
+import com.diagbot.service.KlLisService;
 import com.diagbot.service.impl.KlConceptServiceImpl;
-import com.diagbot.util.BeanUtil;
-import com.diagbot.util.CryptUtil;
+import com.diagbot.util.DateUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.RespDTOUtil;
+import com.diagbot.util.UserUtils;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.GetAllForRelationVO;
 import com.diagbot.vo.KlConceptAllVO;
 import com.diagbot.vo.KlConceptInfoVO;
+import com.diagbot.vo.KlConceptSaveSubVO;
+import com.diagbot.vo.KlConceptSaveVO;
+import org.springframework.beans.factory.annotation.Autowired;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import javax.management.relation.Relation;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -40,23 +55,219 @@ import java.util.stream.Collectors;
  */
 @Component
 public class KlConceptFacade extends KlConceptServiceImpl {
+    @Autowired
+    private UserServiceClient userServiceClient;
+    @Autowired
+    private KlLibraryInfoFacade klLibraryInfoFacade;
+    @Autowired
+    private KlConceptCommonService klConceptCommonService;
+    @Autowired
+    KlLisService klLisService;
+    @Autowired
+    KlDiseaseService klDiseaseService;
 
     /**
-     *
      * @param klConceptInfoVO
      * @return
      */
     public IPage<KlConceptInfoDTO> getConceptInfoPage(KlConceptInfoVO klConceptInfoVO) {
-     return  getConceptPage(klConceptInfoVO);
+        IPage<KlConceptInfoDTO> conceptPage = getConceptPage(klConceptInfoVO);
+        List<String> userIds = conceptPage.getRecords().stream()
+                .map(i -> i.getModifierId()).distinct().collect(Collectors.toList());
+        RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(userIds);
+        RespDTOUtil.respNGDealCover(respDTO, "获取用户信息失败");
+        conceptPage.getRecords().forEach(i -> {
+            i.setModifierName(respDTO.data.get(i.getModifierId()));
+        });
+        return conceptPage;
     }
 
     /**
-     *
      * @param klConceptAllVO
      * @return
      */
     public List<KlConceptAllDTO> getConceptAlls(KlConceptAllVO klConceptAllVO) {
-        return  getConceptAll(klConceptAllVO);
+        return getConceptAll(klConceptAllVO);
+    }
+
+    /**
+     * @param klConceptSaveVO
+     * @return
+     */
+    public Boolean saveConceptInfo(KlConceptSaveVO klConceptSaveVO) {
+        Date now = DateUtil.now();
+        boolean res = false;
+        // 校验名称是否相同
+        int count = this.count(new QueryWrapper<KlConcept>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("lib_type", klConceptSaveVO.getLibType())
+                .eq("lib_name", klConceptSaveVO.getLibName())
+                .ne("id", klConceptSaveVO.getConceptId() == null ? -1 : klConceptSaveVO.getConceptId()));
+        if (count > 0) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该基础术语名称已存在");
+        }
+        //校验
+        KlConceptSaveSubVO paesubVO = new KlConceptSaveSubVO();
+        paesubVO.setConceptId(klConceptSaveVO.getConceptId());
+        paesubVO.setIsConcept(klConceptSaveVO.getIsConcept());
+        paesubVO.setLibId(klConceptSaveVO.getLibId());
+        paesubVO.setSynonymName(klConceptSaveVO.getSynonymName());
+        klLibraryInfoFacade.checkLibraryInfoData(paesubVO);
+        //先判断是新加的,还是修改
+        if (null != klConceptSaveVO.getConceptId() && null != klConceptSaveVO.getLibId()) {
+            //更新标准词
+            res = updateAll(klConceptSaveVO);
+            //更新同义词
+            List<KlConceptSaveSubVO> klConceptAllSub = klConceptSaveVO.getKlConceptSub();
+            if (klConceptAllSub.size() > 0) {
+                for (KlConceptSaveSubVO subVO : klConceptAllSub) {
+                    if (subVO.getLibId() == null) {
+                        //校验
+                        klLibraryInfoFacade.checkLibraryInfoData(subVO);
+
+                        KlLibraryInfo klLibraryInfoSub = new KlLibraryInfo();
+                        klLibraryInfoSub.setConceptId(subVO.getConceptId());
+                        klLibraryInfoSub.setName(subVO.getSynonymName());
+                        klLibraryInfoSub.setSpell(subVO.getSpell());
+                        klLibraryInfoSub.setIsConcept(subVO.getIsConcept());
+                        klLibraryInfoSub.setRemark(subVO.getRemark());
+                        res = klLibraryInfoFacade.save(klLibraryInfoSub);
+                    } else {
+                        UpdateWrapper<KlLibraryInfo> klLibraryInfoQuerySub = new UpdateWrapper<>();
+                        klLibraryInfoQuerySub.eq("is_deleted", IsDeleteEnum.N.getKey())
+                                .eq("id", klConceptSaveVO.getLibId())
+                                .set("gmt_modified", now)
+                                .set("modifier", UserUtils.getCurrentPrincipleID())
+                                .set("name", klConceptSaveVO.getLibName())
+                                .set("spell", klConceptSaveVO.getLibName())
+                                .set("remark", klConceptSaveVO.getLibName());
+                        res = klLibraryInfoFacade.update(new KlLibraryInfo(), klLibraryInfoQuerySub);
+                    }
+
+                }
+            }
+        } else {
+            //1.先保存标准词,生成conceptId
+            KlConcept KlConceptPare = new KlConcept();
+            KlConceptPare.setLibName(klConceptSaveVO.getLibName());
+            KlConceptPare.setLibType(klConceptSaveVO.getLibType());
+            KlConceptPare.setStatus(klConceptSaveVO.getStatus());
+            res = save(KlConceptPare);
+            if (res) {
+                //2.再把标准词d的conceptId保存到kl_library_info表 生成libId,
+                Long conceptId = KlConceptPare.getId();
+                KlLibraryInfo klLibraryInfoSub = new KlLibraryInfo();
+                klLibraryInfoSub.setConceptId(conceptId);
+                klLibraryInfoSub.setName(klConceptSaveVO.getSynonymName());
+                klLibraryInfoSub.setSpell(klConceptSaveVO.getSpell());
+                klLibraryInfoSub.setIsConcept(klConceptSaveVO.getIsConcept());
+                klLibraryInfoSub.setRemark(klConceptSaveVO.getRemark());
+                res = klLibraryInfoFacade.save(klLibraryInfoSub);
+                if (res) {
+                    //3.最后更新回concept表里得lid_id字段
+                    UpdateWrapper<KlConcept> klConceptQuerySub = new UpdateWrapper<>();
+                    klConceptQuerySub.eq("is_deleted", IsDeleteEnum.N.getKey())
+                            .eq("id", klConceptSaveVO.getConceptId())
+                            .set("lib_Id", klLibraryInfoSub.getId());
+                    res = update(new KlConcept(), klConceptQuerySub);
+                }
+            }
+            //KlConceptCommon
+            KlConceptCommon conceptCommon= new KlConceptCommon();
+            conceptCommon.setSexType(klConceptSaveVO.getSexType());
+            conceptCommon.setMaxAge(klConceptSaveVO.getMaxAge());
+            conceptCommon.setMinAge(klConceptSaveVO.getMinAge());
+            conceptCommon.setConceptId(KlConceptPare.getId());
+            klConceptCommonService.save(conceptCommon);
+            //更新kl_disease
+            KlDisease kllDiseaseSub = new KlDisease();
+            kllDiseaseSub.setConceptId(klConceptSaveVO.getConceptId());
+            kllDiseaseSub.setGmtModified(now);
+            kllDiseaseSub.setModifier(UserUtils.getCurrentPrincipleID());
+            kllDiseaseSub.setIcd10Code(klConceptSaveVO.getIcdCode());
+            res = klDiseaseService.saveOrUpdate(kllDiseaseSub);
+            //更新kl_lis
+            KlLis klLisSub = new KlLis();
+            klLisSub.setConceptId(klConceptSaveVO.getConceptId());
+            klLisSub.setGmtModified(now);
+            klLisSub.setModifier(UserUtils.getCurrentPrincipleID());
+            klLisSub.setMinValue(klConceptSaveVO.getMinVal());
+            klLisSub.setMaxValue(klConceptSaveVO.getMaxVal());
+            klLisSub.setType(klConceptSaveVO.getScopeType());
+            res = klLisService.saveOrUpdate(klLisSub);
+            //增加
+            List<KlConceptSaveSubVO> klConceptSub = klConceptSaveVO.getKlConceptSub();
+            for (KlConceptSaveSubVO subVO : klConceptSub) {
+                if (subVO.getLibId() == null) {
+                    klLibraryInfoFacade.checkLibraryInfoData(subVO);
+                    KlLibraryInfo klLibraryInfoSub = new KlLibraryInfo();
+                    klLibraryInfoSub.setConceptId(subVO.getConceptId());
+                    klLibraryInfoSub.setName(subVO.getSynonymName());
+                    klLibraryInfoSub.setSpell(subVO.getSpell());
+                    klLibraryInfoSub.setIsConcept(subVO.getIsConcept());
+                    klLibraryInfoSub.setRemark(subVO.getRemark());
+                    res = klLibraryInfoFacade.save(klLibraryInfoSub);
+                }
+            }
+
+        }
+        return res;
+    }
+
+    public Boolean updateAll(KlConceptSaveVO klConceptSaveVO) {
+        Date now = DateUtil.now();
+        boolean res = false;
+        UpdateWrapper<KlConcept> klConceptQuerySub = new UpdateWrapper<>();
+        klConceptQuerySub.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("id", klConceptSaveVO.getConceptId())
+                .set("gmt_modified", now)
+                .set("modifier", UserUtils.getCurrentPrincipleID())
+                .set("lib_name", klConceptSaveVO.getLibName());
+        res = update(new KlConcept(), klConceptQuerySub);
+
+        UpdateWrapper<KlLibraryInfo> klLibraryInfoQuerySub = new UpdateWrapper<>();
+        klLibraryInfoQuerySub.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("id", klConceptSaveVO.getLibId())
+                .set("gmt_modified", now)
+                .set("modifier", UserUtils.getCurrentPrincipleID())
+                .set("name", klConceptSaveVO.getLibName())
+                .set("spell", klConceptSaveVO.getLibName())
+                .set("remark", klConceptSaveVO.getLibName());
+
+        res = klLibraryInfoFacade.update(new KlLibraryInfo(), klLibraryInfoQuerySub);
+        //更新kl_concept_common表
+        UpdateWrapper<KlConceptCommon> klConceptCommonQuerySub = new UpdateWrapper<>();
+        klConceptCommonQuerySub.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("concept_id", klConceptSaveVO.getConceptId())
+                .set("gmt_modified", now)
+                .set("modifier", UserUtils.getCurrentPrincipleID())
+                .set("sex_type", klConceptSaveVO.getLibName())
+                .set("min_age", klConceptSaveVO.getLibName())
+                .set("max_age", klConceptSaveVO.getLibName());
+        KlConceptCommon klConceptCommonSub = new KlConceptCommon();
+        klConceptCommonSub.setConceptId(klConceptSaveVO.getConceptId());
+        klConceptCommonSub.setMaxAge(klConceptSaveVO.getMaxAge());
+        klConceptCommonSub.setMinAge(klConceptSaveVO.getMinAge());
+        klConceptCommonSub.setGmtModified(now);
+        klConceptCommonSub.setModifier(UserUtils.getCurrentPrincipleID());
+        res = klConceptCommonService.saveOrUpdate(klConceptCommonSub);
+        //更新kl_disease
+        KlDisease kllDiseaseSub = new KlDisease();
+        kllDiseaseSub.setConceptId(klConceptSaveVO.getConceptId());
+        kllDiseaseSub.setGmtModified(now);
+        kllDiseaseSub.setModifier(UserUtils.getCurrentPrincipleID());
+        kllDiseaseSub.setIcd10Code(klConceptSaveVO.getIcdCode());
+        res = klDiseaseService.saveOrUpdate(kllDiseaseSub);
+        //更新kl_lis
+        KlLis klLisSub = new KlLis();
+        klLisSub.setConceptId(klConceptSaveVO.getConceptId());
+        klLisSub.setGmtModified(now);
+        klLisSub.setModifier(UserUtils.getCurrentPrincipleID());
+        klLisSub.setMinValue(klConceptSaveVO.getMinVal());
+        klLisSub.setMaxValue(klConceptSaveVO.getMaxVal());
+        klLisSub.setType(klConceptSaveVO.getScopeType());
+        res = klLisService.saveOrUpdate(klLisSub);
+        return res;
     }
 
     /**

+ 36 - 0
cdssman-service/src/main/java/com/diagbot/facade/KlLibraryInfoFacade.java

@@ -0,0 +1,36 @@
+package com.diagbot.facade;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.entity.KlLibraryInfo;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.impl.KlLibraryInfoServiceImpl;
+import com.diagbot.vo.KlConceptSaveSubVO;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-03 17:13
+ */
+@Component
+public class KlLibraryInfoFacade extends KlLibraryInfoServiceImpl {
+
+    /**
+     *
+     * @param subVO
+     */
+    public void checkLibraryInfoData(KlConceptSaveSubVO subVO){
+        //校验
+        int countLib = this.count(new QueryWrapper<KlLibraryInfo>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("concept_id", subVO.getConceptId())
+                .eq("name", subVO.getSynonymName())
+                .eq("type_id", subVO.getTypeId())
+                .ne("id", subVO.getLibId() == null ? -1 : subVO.getLibId()));
+        if (countLib > 0) {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该基础术语同义词名称已存在");
+        }
+    }
+}

+ 23 - 0
cdssman-service/src/main/java/com/diagbot/vo/KlConceptSaveSubVO.java

@@ -0,0 +1,23 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author wangfeng
+ * @Description: 同义词
+ * @date 2021-03-03 9:55
+ */
+@Setter
+@Getter
+public class KlConceptSaveSubVO {
+    private Long conceptId;
+    private Long libId;
+    private String synonymName;
+    private String spell;
+    //词性id
+    private String TypeId;
+    //是否标准词,1:是,0:否
+    private Integer isConcept;
+    private String remark;
+}

+ 35 - 0
cdssman-service/src/main/java/com/diagbot/vo/KlConceptSaveVO.java

@@ -0,0 +1,35 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2021-03-03 9:49
+ */
+@Setter
+@Getter
+public class KlConceptSaveVO {
+    private Long conceptId;
+    private Long libId;
+    private String libName;
+    private String spell;
+    private Integer libType;
+    private String typeName;
+    private String synonymName;
+    private Integer status;
+    private Integer isConcept;
+    private Integer sexType;
+    private Integer isHasCommon;
+    private Double minAge;
+    private Double maxAge;
+    private Double minVal;
+    private Double maxVal;
+    private Integer scopeType;
+    private String icdCode;
+    private String remark;
+    private List<KlConceptSaveSubVO> klConceptSub;
+}

+ 7 - 0
cdssman-service/src/main/java/com/diagbot/web/KlConceptController.java

@@ -11,6 +11,7 @@ import com.diagbot.facade.KlConceptFacade;
 import com.diagbot.vo.GetAllForRelationVO;
 import com.diagbot.vo.KlConceptAllVO;
 import com.diagbot.vo.KlConceptInfoVO;
+import com.diagbot.vo.KlConceptSaveVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -51,6 +52,12 @@ public class KlConceptController {
     public RespDTO<List<KlConceptAllDTO>> getConceptInfoAll(@RequestBody @Valid KlConceptAllVO klConceptAllVO) {
         return RespDTO.onSuc(klConceptFacade.getConceptAlls(klConceptAllVO));
     }
+    @ApiOperation(value = "新增和修改基础术语详情[by:wangfeng]")
+    @PostMapping("/saveConceptInfo")
+    @SysLogger("saveConceptInfo")
+    public RespDTO<Boolean> saveConceptInfos(@RequestBody KlConceptSaveVO klConceptSaveVO) {
+        return RespDTO.onSuc(klConceptFacade.saveConceptInfo(klConceptSaveVO));
+    }
 
     @ApiOperation(value = "知识库标准化-获取所有概念(术语关系维护时筛选使用)[by:kongwz]")
     @PostMapping("/getAllForRelation")

+ 3 - 1
cdssman-service/src/main/resources/mapper/KlConceptMapper.xml

@@ -56,6 +56,7 @@
     <select id="getConceptAll" resultType="com.diagbot.dto.KlConceptAllDTO">
         SELECT
         a.concept_id AS conceptId,
+        a.id AS libId,
         b.lib_name AS libName,
         a.spell AS spell,
         b.lib_type AS libType,
@@ -70,7 +71,8 @@
         g.min_value AS minVal,
         g.max_value AS maxVal,
         g.type AS scopeType,
-        h.icd10_code AS icdCode
+        h.icd10_code AS icdCode,
+        a.remark
         FROM
         kl_library_info a
         INNER JOIN kl_concept b