|
@@ -1,18 +1,30 @@
|
|
package com.diagbot.facade;
|
|
package com.diagbot.facade;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.diagbot.dto.RelationDTO;
|
|
import com.diagbot.dto.RelationDTO;
|
|
import com.diagbot.dto.TreeAllDTO;
|
|
import com.diagbot.dto.TreeAllDTO;
|
|
import com.diagbot.dto.TreeDTO;
|
|
import com.diagbot.dto.TreeDTO;
|
|
|
|
+import com.diagbot.entity.CommonParam;
|
|
|
|
+import com.diagbot.entity.KlRelation;
|
|
|
|
+import com.diagbot.entity.KlRelationOrder;
|
|
|
|
+import com.diagbot.enums.RelationLibTypeEnum;
|
|
|
|
+import com.diagbot.service.KlRelationOrderService;
|
|
|
|
+import com.diagbot.service.KlRelationService;
|
|
import com.diagbot.service.impl.KlRelationServiceImpl;
|
|
import com.diagbot.service.impl.KlRelationServiceImpl;
|
|
import com.diagbot.util.EntityUtil;
|
|
import com.diagbot.util.EntityUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
|
|
+import com.diagbot.vo.KlDiseaseVO;
|
|
import com.diagbot.vo.RelationVO;
|
|
import com.diagbot.vo.RelationVO;
|
|
import com.diagbot.vo.TreeVO;
|
|
import com.diagbot.vo.TreeVO;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description:
|
|
* @Description:
|
|
@@ -21,6 +33,15 @@ import java.util.Map;
|
|
*/
|
|
*/
|
|
@Component
|
|
@Component
|
|
public class KlRelationFacade extends KlRelationServiceImpl {
|
|
public class KlRelationFacade extends KlRelationServiceImpl {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ @Qualifier("klRelationOrderServiceImpl")
|
|
|
|
+ KlRelationOrderService klRelationOrderService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ @Qualifier("klRelationServiceImpl")
|
|
|
|
+ KlRelationService klRelationService;
|
|
|
|
+
|
|
public TreeAllDTO getTree(TreeVO treeVO) {
|
|
public TreeAllDTO getTree(TreeVO treeVO) {
|
|
List<Long[]> pList = new ArrayList<>();
|
|
List<Long[]> pList = new ArrayList<>();
|
|
pList.add(new Long[] { 402L, 600L, 301L, 600L, 101L });//药品化学物质类别
|
|
pList.add(new Long[] { 402L, 600L, 301L, 600L, 101L });//药品化学物质类别
|
|
@@ -78,4 +99,90 @@ public class KlRelationFacade extends KlRelationServiceImpl {
|
|
}
|
|
}
|
|
return treeAllDTO;
|
|
return treeAllDTO;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 疾病扩展
|
|
|
|
+ *
|
|
|
|
+ * @param commonParam
|
|
|
|
+ * @param klDiseaseVO
|
|
|
|
+ */
|
|
|
|
+ public void saveKlDisease(CommonParam commonParam, KlDiseaseVO klDiseaseVO) {
|
|
|
|
+ // 疾病关联科室,部位,关联系统统一处理。先查找全部数据,删除关联排序表,再删除关联表
|
|
|
|
+ List<Integer> relationIdList = Lists.newArrayList(
|
|
|
|
+ RelationLibTypeEnum.relationDept.getKey(),
|
|
|
|
+ RelationLibTypeEnum.relationPart.getKey(),
|
|
|
|
+ RelationLibTypeEnum.relationSystem.getKey()
|
|
|
|
+ );
|
|
|
|
+ klRelationRemove(commonParam, relationIdList);
|
|
|
|
+
|
|
|
|
+ if (klDiseaseVO != null) {
|
|
|
|
+ // 【科室关联】
|
|
|
|
+ klRelationSave(commonParam, klDiseaseVO.getDeptList(), RelationLibTypeEnum.relationDept.getKey());
|
|
|
|
+ // 【部位关联】
|
|
|
|
+ klRelationSave(commonParam, klDiseaseVO.getPartList(), RelationLibTypeEnum.relationPart.getKey());
|
|
|
|
+ // 【疾病系统分类关联】
|
|
|
|
+ klRelationSave(commonParam, klDiseaseVO.getSystemTypeList(), RelationLibTypeEnum.relationSystem.getKey());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除关联表和关联排序表
|
|
|
|
+ *
|
|
|
|
+ * @param commonParam 通用参数
|
|
|
|
+ * @param relationList 关联类型列表
|
|
|
|
+ */
|
|
|
|
+ public void klRelationRemove(CommonParam commonParam, List<Integer> relationList) {
|
|
|
|
+ List<KlRelation> klRelationList = this.list(new QueryWrapper<KlRelation>()
|
|
|
|
+ .eq("start_id", commonParam.getConceptId())
|
|
|
|
+ .in("relation_id", relationList)
|
|
|
|
+ );
|
|
|
|
+ if (ListUtil.isNotEmpty(klRelationList)) {
|
|
|
|
+ List<Long> idList = klRelationList.stream().map(r -> r.getId()).collect(Collectors.toList());
|
|
|
|
+ // 删除关联排序表
|
|
|
|
+ klRelationOrderService.remove(new QueryWrapper<KlRelationOrder>().in("t_relation_id", idList));
|
|
|
|
+ // 删除关联表
|
|
|
|
+ this.remove(new QueryWrapper<KlRelation>().in("id", idList));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存关联表和关联排序表
|
|
|
|
+ *
|
|
|
|
+ * @param commonParam
|
|
|
|
+ * @param idList
|
|
|
|
+ * @param relationId
|
|
|
|
+ */
|
|
|
|
+ public void klRelationSave(CommonParam commonParam, List<Long> idList, Integer relationId) {
|
|
|
|
+ if (ListUtil.isEmpty(idList)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ List<KlRelation> relationSaveList = Lists.newArrayList();
|
|
|
|
+ for (Long endId : idList) {
|
|
|
|
+ KlRelation klRelation = new KlRelation();
|
|
|
|
+ klRelation.setStartId(commonParam.getConceptId());
|
|
|
|
+ klRelation.setRelationId(relationId);
|
|
|
|
+ klRelation.setEndId(endId);
|
|
|
|
+ klRelation.setGmtModified(commonParam.getNow());
|
|
|
|
+ klRelation.setGmtCreate(commonParam.getNow());
|
|
|
|
+ klRelation.setCreator(commonParam.getPerson());
|
|
|
|
+ klRelation.setModifier(commonParam.getPerson());
|
|
|
|
+ relationSaveList.add(klRelation);
|
|
|
|
+ }
|
|
|
|
+ klRelationService.saveBatch(relationSaveList);
|
|
|
|
+
|
|
|
|
+ // 【科室关联排序】
|
|
|
|
+ List<KlRelationOrder> OrderSaveList = Lists.newArrayList();
|
|
|
|
+ int i = 1;
|
|
|
|
+ for (KlRelation klRelation : relationSaveList) {
|
|
|
|
+ KlRelationOrder klRelationOrder = new KlRelationOrder();
|
|
|
|
+ klRelationOrder.settRelationId(klRelation.getId());
|
|
|
|
+ klRelationOrder.setOrderNo(i++);
|
|
|
|
+ klRelation.setGmtModified(commonParam.getNow());
|
|
|
|
+ klRelation.setGmtCreate(commonParam.getNow());
|
|
|
|
+ klRelation.setCreator(commonParam.getPerson());
|
|
|
|
+ klRelation.setModifier(commonParam.getPerson());
|
|
|
|
+ OrderSaveList.add(klRelationOrder);
|
|
|
|
+ }
|
|
|
|
+ klRelationOrderService.saveBatch(OrderSaveList);
|
|
|
|
+ }
|
|
}
|
|
}
|