|
@@ -1,305 +1,309 @@
|
|
|
-package com.diagbot.facade;
|
|
|
-
|
|
|
-import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
-import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.diagbot.client.UserServiceClient;
|
|
|
-import com.diagbot.dto.*;
|
|
|
-import com.diagbot.entity.KlConcept;
|
|
|
-import com.diagbot.entity.KlRelation;
|
|
|
-import com.diagbot.entity.KlRelationOrder;
|
|
|
-import com.diagbot.enums.IsDeleteEnum;
|
|
|
-import com.diagbot.enums.LexiconEnum;
|
|
|
-import com.diagbot.service.KlRelationService;
|
|
|
-import com.diagbot.service.impl.KlRelationOrderServiceImpl;
|
|
|
-import com.diagbot.service.impl.KlRelationServiceImpl;
|
|
|
-import com.diagbot.util.DateUtil;
|
|
|
-import com.diagbot.util.ListUtil;
|
|
|
-import com.diagbot.util.UserUtils;
|
|
|
-import com.diagbot.vo.*;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
-import com.google.common.collect.Maps;
|
|
|
-import org.apache.commons.collections4.MapUtils;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import javax.validation.constraints.NotBlank;
|
|
|
-import javax.validation.constraints.NotNull;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author kwz
|
|
|
- * @date 2021/3/3
|
|
|
- * @time 15:42
|
|
|
- */
|
|
|
-@Component
|
|
|
-public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
- @Autowired
|
|
|
- private UserServiceClient userServiceClient;
|
|
|
- @Autowired
|
|
|
- private KlConceptFacade klConceptFacade;
|
|
|
- @Autowired
|
|
|
- private KlRelationOrderFacade klRelationOrderFacade;
|
|
|
- @Autowired
|
|
|
- @Qualifier("klRelationServiceImpl")
|
|
|
- private KlRelationService klRelationService;
|
|
|
- @Autowired
|
|
|
- @Qualifier("klRelationOrderServiceImpl")
|
|
|
- private KlRelationOrderServiceImpl klRelationOrderServiceImpl;
|
|
|
- @Autowired
|
|
|
- KlDiseaseFacade klDiseaseFacade;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @DS("med")
|
|
|
- @DSTransactional
|
|
|
- public Boolean addRelation(List<KlRelationSaveVO> klRelationSaveVOs) {
|
|
|
- if (ListUtil.isNotEmpty(klRelationSaveVOs)) {
|
|
|
- KlRelationSaveVO klRelationSaveVO = klRelationSaveVOs.get(0);
|
|
|
- Long sid = klRelationSaveVO.getSid();
|
|
|
- List<Long> conceptid = Lists.newArrayList(sid);
|
|
|
- Integer rid = klRelationSaveVO.getRid();
|
|
|
- List<Long> sids = new ArrayList<>();
|
|
|
- List<RelationNameDTO> relationNameDTOs = this.getRelationNameDTOs(conceptid, rid);
|
|
|
- if (ListUtil.isNotEmpty(relationNameDTOs)) {
|
|
|
- for (RelationNameDTO red : relationNameDTOs) {
|
|
|
- Long startId = red.getStartId();
|
|
|
- Long medId = red.getEndId();
|
|
|
- if (!sids.contains(startId)) {
|
|
|
- sids.add(startId);
|
|
|
- }
|
|
|
- if (!sids.contains(medId)) {
|
|
|
- sids.add(medId);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- List<KlRelation> relationList = this.list(new QueryWrapper<KlRelation>()
|
|
|
- .in("start_id", sids)
|
|
|
- .eq("relation_id", rid));
|
|
|
- List<Long> ids = relationList.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
- //先删除
|
|
|
- if (ListUtil.isNotEmpty(ids)) {
|
|
|
- this.removeByIds(ids);
|
|
|
-
|
|
|
- QueryWrapper<KlRelationOrder> relationOrderQe = new QueryWrapper<>();
|
|
|
- relationOrderQe.in("t_relation_id", ids);
|
|
|
- klRelationOrderFacade.remove(relationOrderQe);
|
|
|
- }
|
|
|
- List<List<KlRelation>> relationGroupList = relationDataForAdd(klRelationSaveVOs);
|
|
|
-
|
|
|
- Date now = DateUtil.now();
|
|
|
- List<KlRelation> relationLists = Lists.newArrayList();
|
|
|
- relationGroupList.forEach(i -> {
|
|
|
- i.forEach(j -> {
|
|
|
- j.setGmtCreate(now);
|
|
|
- j.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
- j.setGmtModified(now);
|
|
|
- relationLists.add(j);
|
|
|
- });
|
|
|
- });
|
|
|
- klRelationService.saveBatch(relationLists);
|
|
|
-
|
|
|
- List<KlRelationOrder> relationOrderList = Lists.newArrayList();
|
|
|
- relationGroupList.forEach(i -> {
|
|
|
- int orderNo = 0;
|
|
|
- for (KlRelation j : i) {
|
|
|
- orderNo++;
|
|
|
- KlRelationOrder relationOrder = new KlRelationOrder();
|
|
|
- relationOrder.setOrderNo(orderNo);
|
|
|
- relationOrder.settRelationId(j.getId());
|
|
|
- relationOrder.setGmtCreate(now);
|
|
|
- relationOrder.setGmtModified(now);
|
|
|
-// relationOrder.setCreator(currentUser);
|
|
|
- relationOrder.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
- relationOrderList.add(relationOrder);
|
|
|
- }
|
|
|
- });
|
|
|
- klRelationOrderServiceImpl.saveBatch(relationOrderList);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @DS("med")
|
|
|
- @DSTransactional
|
|
|
- public Boolean saveRelation(List<KlRelationSaveVO> klRelationSaveVOs) {
|
|
|
- if (ListUtil.isNotEmpty(klRelationSaveVOs)) {
|
|
|
- List<List<KlRelation>> relationGroupList = Lists.newArrayList();
|
|
|
- KlRelationSaveVO klRelationSaveVO = klRelationSaveVOs.get(0);
|
|
|
- Long sid = klRelationSaveVO.getSid();
|
|
|
- List<KlRelation> klRelations = this.list(new QueryWrapper<KlRelation>()
|
|
|
- .eq("start_id", sid));
|
|
|
- List<Long> ids = klRelations.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
- //先删除
|
|
|
- if (ListUtil.isNotEmpty(ids)) {
|
|
|
- this.removeByIds(ids);
|
|
|
- QueryWrapper<KlRelationOrder> relationOrderQe = new QueryWrapper<>();
|
|
|
- relationOrderQe.in("t_relation_id", ids);
|
|
|
- klRelationOrderFacade.remove(relationOrderQe);
|
|
|
- }
|
|
|
- for (KlRelationSaveVO kls : klRelationSaveVOs) {
|
|
|
- @NotNull(message = "概念开始id必传") Long sid1 = kls.getSid();
|
|
|
- @NotNull(message = "关系id必传") Integer rid = kls.getRid();
|
|
|
- List<Long> eids = kls.getEids();
|
|
|
- if (ListUtil.isNotEmpty(eids)) {
|
|
|
- List<KlRelation> collect = eids.stream().map(x -> {
|
|
|
- KlRelation klRelation = new KlRelation();
|
|
|
- klRelation.setEndId(x);
|
|
|
- klRelation.setRelationId(rid);
|
|
|
- klRelation.setStartId(sid1);
|
|
|
- klRelation.setStatus(1);
|
|
|
- return klRelation;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- relationGroupList.add(collect);
|
|
|
- }
|
|
|
- }
|
|
|
- Date now = DateUtil.now();
|
|
|
- List<KlRelation> relationLists = Lists.newArrayList();
|
|
|
- relationGroupList.forEach(i -> {
|
|
|
- i.forEach(j -> {
|
|
|
- j.setGmtCreate(now);
|
|
|
- j.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
- j.setGmtModified(now);
|
|
|
- relationLists.add(j);
|
|
|
- });
|
|
|
- });
|
|
|
- klRelationService.saveBatch(relationLists);
|
|
|
-
|
|
|
- List<KlRelationOrder> relationOrderList = Lists.newArrayList();
|
|
|
- relationGroupList.forEach(i -> {
|
|
|
- int orderNo = 0;
|
|
|
- for (KlRelation j : i) {
|
|
|
- orderNo++;
|
|
|
- KlRelationOrder relationOrder = new KlRelationOrder();
|
|
|
- relationOrder.setOrderNo(orderNo);
|
|
|
- relationOrder.settRelationId(j.getId());
|
|
|
- relationOrder.setGmtCreate(now);
|
|
|
- relationOrder.setGmtModified(now);
|
|
|
- relationOrder.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
- relationOrderList.add(relationOrder);
|
|
|
- }
|
|
|
- });
|
|
|
- klRelationOrderServiceImpl.saveBatch(relationOrderList);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- private List<List<KlRelation>> relationDataForAdd(List<KlRelationSaveVO> klRelationSaveVOs) {
|
|
|
- List<List<KlRelation>> relationList = Lists.newArrayList();
|
|
|
- Map<String, List<KlRelation>> relationMap = Maps.newHashMap();
|
|
|
- if (ListUtil.isNotEmpty(klRelationSaveVOs)) {
|
|
|
-
|
|
|
- for (KlRelationSaveVO kls : klRelationSaveVOs) {
|
|
|
- Long sid = kls.getSid();
|
|
|
- Integer rid = kls.getRid();
|
|
|
- Long eid = kls.getEid();
|
|
|
- Integer srid = kls.getSrid();
|
|
|
- List<Long> eids = kls.getEids();
|
|
|
- if (relationMap.containsKey(sid.toString() + "&" + rid.toString())) {
|
|
|
- List<KlRelation> klRelations_big = relationMap.get(sid.toString() + "&" + rid.toString());
|
|
|
- KlRelation klRelation = new KlRelation();
|
|
|
- klRelation.setStartId(sid);
|
|
|
- klRelation.setRelationId(rid);
|
|
|
- klRelation.setEndId(eid);
|
|
|
- klRelation.setStatus(1);
|
|
|
- klRelations_big.add(klRelation);
|
|
|
- relationMap.put(sid.toString() + "&" + rid.toString(), klRelations_big);
|
|
|
- } else {
|
|
|
- List<KlRelation> klRelations_big = Lists.newArrayList();
|
|
|
- KlRelation klRelation = new KlRelation();
|
|
|
- klRelation.setStartId(sid);
|
|
|
- klRelation.setRelationId(rid);
|
|
|
- klRelation.setEndId(eid);
|
|
|
- klRelation.setStatus(1);
|
|
|
- klRelations_big.add(klRelation);
|
|
|
- relationMap.put(sid.toString() + "&" + rid.toString(), klRelations_big);
|
|
|
- }
|
|
|
- if (srid != null && ListUtil.isNotEmpty(eids)) {
|
|
|
- List<KlRelation> klRelations_sub = Lists.newArrayList();
|
|
|
- for (Long id : eids) {
|
|
|
- KlRelation klRelation = new KlRelation();
|
|
|
- klRelation.setStartId(eid);
|
|
|
- klRelation.setRelationId(srid);
|
|
|
- klRelation.setEndId(id);
|
|
|
- klRelation.setStatus(1);
|
|
|
- klRelations_sub.add(klRelation);
|
|
|
- }
|
|
|
- relationMap.put(eid.toString() + "&" + srid.toString(), klRelations_sub);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (MapUtils.isNotEmpty(relationMap)) {
|
|
|
- relationMap.forEach((x, y) -> {
|
|
|
- relationList.add(y);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- return relationList;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除某个诊断依据
|
|
|
- * @param diseaseDeleteVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- @DS("med")
|
|
|
- @DSTransactional
|
|
|
- public Boolean deleteRelation(DiseaseDeleteVO diseaseDeleteVO) {
|
|
|
- String disName = diseaseDeleteVO.getDisName();
|
|
|
- if(StringUtils.isNotBlank(disName)){
|
|
|
- List<KlConcept> klConcepts = klConceptFacade.list(new QueryWrapper<KlConcept>()
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("lib_name", disName.trim())
|
|
|
- .eq("lib_type", 100));
|
|
|
- List<Long> ids = klConcepts.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
- List<Integer> relations = Lists.newArrayList(501, 502, 503, 504, 505, 506, 507, 508);
|
|
|
- List<KlRelation> klRelations = this.list(new QueryWrapper<KlRelation>()
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .in(ListUtil.isNotEmpty(ids),"start_id", ids)
|
|
|
- .in(ListUtil.isNotEmpty(relations),"relation_id", relations));
|
|
|
- List<Long> kids = klRelations.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
- this.removeByIds(kids);
|
|
|
- QueryWrapper<KlRelationOrder> relationOrderQe = new QueryWrapper<>();
|
|
|
- relationOrderQe.in(ListUtil.isNotEmpty(kids),"t_relation_id", kids);
|
|
|
- klRelationOrderFacade.remove(relationOrderQe);
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 新增诊断依据
|
|
|
- * @param diseaseDeleteVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<KlConcept> addDisease(DiseaseDeleteVO diseaseDeleteVO) {
|
|
|
- List<KlConcept> diseaseAll = klDiseaseFacade.getDiseaseAll(diseaseDeleteVO);
|
|
|
- return diseaseAll;
|
|
|
- }
|
|
|
-
|
|
|
- public List<String> searchAndPosition(GetAllForRelationVO getAllForRelationVO) {
|
|
|
- List<String> names = Lists.newArrayList();
|
|
|
- String name = getAllForRelationVO.getName();
|
|
|
- Long typeId = getAllForRelationVO.getTypeId();
|
|
|
- List<KlConcept> klConcepts = klConceptFacade.list(new QueryWrapper<KlConcept>()
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .like("lib_name", name.trim())
|
|
|
- .eq("lib_type", typeId));
|
|
|
- names = klConcepts.stream().map(x -> x.getLibName()).collect(Collectors.toList());
|
|
|
-
|
|
|
- return names;
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.client.UserServiceClient;
|
|
|
+import com.diagbot.dto.*;
|
|
|
+import com.diagbot.entity.KlConcept;
|
|
|
+import com.diagbot.entity.KlRelation;
|
|
|
+import com.diagbot.entity.KlRelationOrder;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.enums.LexiconEnum;
|
|
|
+import com.diagbot.service.KlRelationService;
|
|
|
+import com.diagbot.service.impl.KlRelationOrderServiceImpl;
|
|
|
+import com.diagbot.service.impl.KlRelationServiceImpl;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.UserUtils;
|
|
|
+import com.diagbot.vo.*;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import org.apache.commons.collections4.MapUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.validation.constraints.NotBlank;
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author kwz
|
|
|
+ * @date 2021/3/3
|
|
|
+ * @time 15:42
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
+ @Autowired
|
|
|
+ private UserServiceClient userServiceClient;
|
|
|
+ @Autowired
|
|
|
+ private KlConceptFacade klConceptFacade;
|
|
|
+ @Autowired
|
|
|
+ private KlRelationOrderFacade klRelationOrderFacade;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("klRelationServiceImpl")
|
|
|
+ private KlRelationService klRelationService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("klRelationOrderServiceImpl")
|
|
|
+ private KlRelationOrderServiceImpl klRelationOrderServiceImpl;
|
|
|
+ @Autowired
|
|
|
+ KlDiseaseFacade klDiseaseFacade;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @DS("med")
|
|
|
+ @DSTransactional
|
|
|
+ public Boolean addRelation(List<KlRelationSaveVO> klRelationSaveVOs) {
|
|
|
+ if (ListUtil.isNotEmpty(klRelationSaveVOs)) {
|
|
|
+ KlRelationSaveVO klRelationSaveVO = klRelationSaveVOs.get(0);
|
|
|
+ Long sid = klRelationSaveVO.getSid();
|
|
|
+ List<Long> conceptid = Lists.newArrayList(sid);
|
|
|
+ Integer rid = klRelationSaveVO.getRid();
|
|
|
+ List<Long> sids = new ArrayList<>();
|
|
|
+ List<RelationNameDTO> relationNameDTOs = this.getRelationNameDTOs(conceptid, rid);
|
|
|
+ if (ListUtil.isNotEmpty(relationNameDTOs)) {
|
|
|
+ for (RelationNameDTO red : relationNameDTOs) {
|
|
|
+ Long startId = red.getStartId();
|
|
|
+ Long medId = red.getEndId();
|
|
|
+ if (!sids.contains(startId)) {
|
|
|
+ sids.add(startId);
|
|
|
+ }
|
|
|
+ if (!sids.contains(medId)) {
|
|
|
+ sids.add(medId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<KlRelation> relationList = this.list(new QueryWrapper<KlRelation>()
|
|
|
+ .in("start_id", sids)
|
|
|
+ .eq("relation_id", rid));
|
|
|
+ List<Long> ids = relationList.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
+ //先删除
|
|
|
+ if (ListUtil.isNotEmpty(ids)) {
|
|
|
+ this.removeByIds(ids);
|
|
|
+
|
|
|
+ QueryWrapper<KlRelationOrder> relationOrderQe = new QueryWrapper<>();
|
|
|
+ relationOrderQe.in("t_relation_id", ids);
|
|
|
+ klRelationOrderFacade.remove(relationOrderQe);
|
|
|
+ }
|
|
|
+ List<List<KlRelation>> relationGroupList = relationDataForAdd(klRelationSaveVOs);
|
|
|
+
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ List<KlRelation> relationLists = Lists.newArrayList();
|
|
|
+ relationGroupList.forEach(i -> {
|
|
|
+ i.forEach(j -> {
|
|
|
+ j.setGmtCreate(now);
|
|
|
+ j.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
+ j.setGmtModified(now);
|
|
|
+ relationLists.add(j);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ klRelationService.saveBatch(relationLists);
|
|
|
+
|
|
|
+ List<KlRelationOrder> relationOrderList = Lists.newArrayList();
|
|
|
+ relationGroupList.forEach(i -> {
|
|
|
+ int orderNo = 0;
|
|
|
+ for (KlRelation j : i) {
|
|
|
+ orderNo++;
|
|
|
+ KlRelationOrder relationOrder = new KlRelationOrder();
|
|
|
+ relationOrder.setOrderNo(orderNo);
|
|
|
+ relationOrder.settRelationId(j.getId());
|
|
|
+ relationOrder.setGmtCreate(now);
|
|
|
+ relationOrder.setGmtModified(now);
|
|
|
+// relationOrder.setCreator(currentUser);
|
|
|
+ relationOrder.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
+ relationOrderList.add(relationOrder);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ klRelationOrderServiceImpl.saveBatch(relationOrderList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @DS("med")
|
|
|
+ @DSTransactional
|
|
|
+ public Boolean saveRelation(List<KlRelationSaveVO> klRelationSaveVOs) {
|
|
|
+ if (ListUtil.isNotEmpty(klRelationSaveVOs)) {
|
|
|
+ List<List<KlRelation>> relationGroupList = Lists.newArrayList();
|
|
|
+ KlRelationSaveVO klRelationSaveVO = klRelationSaveVOs.get(0);
|
|
|
+ Long sid = klRelationSaveVO.getSid();
|
|
|
+ List<KlRelation> klRelations = this.list(new QueryWrapper<KlRelation>()
|
|
|
+ .eq("start_id", sid));
|
|
|
+ List<Long> ids = klRelations.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
+ //先删除
|
|
|
+ if (ListUtil.isNotEmpty(ids)) {
|
|
|
+ this.removeByIds(ids);
|
|
|
+ QueryWrapper<KlRelationOrder> relationOrderQe = new QueryWrapper<>();
|
|
|
+ relationOrderQe.in("t_relation_id", ids);
|
|
|
+ klRelationOrderFacade.remove(relationOrderQe);
|
|
|
+ }
|
|
|
+ for (KlRelationSaveVO kls : klRelationSaveVOs) {
|
|
|
+ @NotNull(message = "概念开始id必传") Long sid1 = kls.getSid();
|
|
|
+ @NotNull(message = "关系id必传") Integer rid = kls.getRid();
|
|
|
+ List<Long> eids = kls.getEids();
|
|
|
+ if (ListUtil.isNotEmpty(eids)) {
|
|
|
+ List<KlRelation> collect = eids.stream().map(x -> {
|
|
|
+ KlRelation klRelation = new KlRelation();
|
|
|
+ klRelation.setEndId(x);
|
|
|
+ klRelation.setRelationId(rid);
|
|
|
+ klRelation.setStartId(sid1);
|
|
|
+ klRelation.setStatus(1);
|
|
|
+ return klRelation;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ relationGroupList.add(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ List<KlRelation> relationLists = Lists.newArrayList();
|
|
|
+ relationGroupList.forEach(i -> {
|
|
|
+ i.forEach(j -> {
|
|
|
+ j.setGmtCreate(now);
|
|
|
+ j.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
+ j.setGmtModified(now);
|
|
|
+ relationLists.add(j);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ klRelationService.saveBatch(relationLists);
|
|
|
+
|
|
|
+ List<KlRelationOrder> relationOrderList = Lists.newArrayList();
|
|
|
+ relationGroupList.forEach(i -> {
|
|
|
+ int orderNo = 0;
|
|
|
+ for (KlRelation j : i) {
|
|
|
+ orderNo++;
|
|
|
+ KlRelationOrder relationOrder = new KlRelationOrder();
|
|
|
+ relationOrder.setOrderNo(orderNo);
|
|
|
+ relationOrder.settRelationId(j.getId());
|
|
|
+ relationOrder.setGmtCreate(now);
|
|
|
+ relationOrder.setGmtModified(now);
|
|
|
+ relationOrder.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
+ relationOrderList.add(relationOrder);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ klRelationOrderServiceImpl.saveBatch(relationOrderList);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<List<KlRelation>> relationDataForAdd(List<KlRelationSaveVO> klRelationSaveVOs) {
|
|
|
+ List<List<KlRelation>> relationList = Lists.newArrayList();
|
|
|
+ Map<String, List<KlRelation>> relationMap = Maps.newHashMap();
|
|
|
+ if (ListUtil.isNotEmpty(klRelationSaveVOs)) {
|
|
|
+
|
|
|
+ for (KlRelationSaveVO kls : klRelationSaveVOs) {
|
|
|
+ Long sid = kls.getSid();
|
|
|
+ Integer rid = kls.getRid();
|
|
|
+ Long eid = kls.getEid();
|
|
|
+ Integer srid = kls.getSrid();
|
|
|
+ List<Long> eids = kls.getEids();
|
|
|
+ if (relationMap.containsKey(sid.toString() + "&" + rid.toString())) {
|
|
|
+ List<KlRelation> klRelations_big = relationMap.get(sid.toString() + "&" + rid.toString());
|
|
|
+ KlRelation klRelation = new KlRelation();
|
|
|
+ klRelation.setStartId(sid);
|
|
|
+ klRelation.setRelationId(rid);
|
|
|
+ klRelation.setEndId(eid);
|
|
|
+ klRelation.setStatus(1);
|
|
|
+ klRelations_big.add(klRelation);
|
|
|
+ relationMap.put(sid.toString() + "&" + rid.toString(), klRelations_big);
|
|
|
+ } else {
|
|
|
+ List<KlRelation> klRelations_big = Lists.newArrayList();
|
|
|
+ KlRelation klRelation = new KlRelation();
|
|
|
+ klRelation.setStartId(sid);
|
|
|
+ klRelation.setRelationId(rid);
|
|
|
+ klRelation.setEndId(eid);
|
|
|
+ klRelation.setStatus(1);
|
|
|
+ klRelations_big.add(klRelation);
|
|
|
+ relationMap.put(sid.toString() + "&" + rid.toString(), klRelations_big);
|
|
|
+ }
|
|
|
+ if (srid != null && ListUtil.isNotEmpty(eids)) {
|
|
|
+ List<KlRelation> klRelations_sub = Lists.newArrayList();
|
|
|
+ for (Long id : eids) {
|
|
|
+ KlRelation klRelation = new KlRelation();
|
|
|
+ klRelation.setStartId(eid);
|
|
|
+ klRelation.setRelationId(srid);
|
|
|
+ klRelation.setEndId(id);
|
|
|
+ klRelation.setStatus(1);
|
|
|
+ klRelations_sub.add(klRelation);
|
|
|
+ }
|
|
|
+ relationMap.put(eid.toString() + "&" + srid.toString(), klRelations_sub);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (MapUtils.isNotEmpty(relationMap)) {
|
|
|
+ relationMap.forEach((x, y) -> {
|
|
|
+ relationList.add(y);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return relationList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除某个诊断依据
|
|
|
+ * @param diseaseDeleteVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @DS("med")
|
|
|
+ @DSTransactional
|
|
|
+ public Boolean deleteRelation(DiseaseDeleteVO diseaseDeleteVO) {
|
|
|
+ String disName = diseaseDeleteVO.getDisName();
|
|
|
+ if(StringUtils.isNotBlank(disName)){
|
|
|
+ List<KlConcept> klConcepts = klConceptFacade.list(new QueryWrapper<KlConcept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("lib_name", disName.trim())
|
|
|
+ .eq("lib_type", 100));
|
|
|
+ List<Long> ids = klConcepts.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
+ List<Integer> relations = Lists.newArrayList(501, 502, 503, 504, 505, 506, 507, 508);
|
|
|
+ List<KlRelation> klRelations = this.list(new QueryWrapper<KlRelation>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .in(ListUtil.isNotEmpty(ids),"start_id", ids)
|
|
|
+ .in(ListUtil.isNotEmpty(relations),"relation_id", relations));
|
|
|
+ List<Long> kids = klRelations.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
+ this.removeByIds(kids);
|
|
|
+ QueryWrapper<KlRelationOrder> relationOrderQe = new QueryWrapper<>();
|
|
|
+ relationOrderQe.in(ListUtil.isNotEmpty(kids),"t_relation_id", kids);
|
|
|
+ klRelationOrderFacade.remove(relationOrderQe);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增诊断依据
|
|
|
+ * @param diseaseDeleteVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<KlConcept> addDisease(DiseaseDeleteVO diseaseDeleteVO) {
|
|
|
+ List<KlConcept> diseaseAll = klDiseaseFacade.getDiseaseAll(diseaseDeleteVO);
|
|
|
+ return diseaseAll;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<String> searchAndPosition(GetAllForRelationVO getAllForRelationVO) {
|
|
|
+ List<String> names = Lists.newArrayList();
|
|
|
+ String name = getAllForRelationVO.getName();
|
|
|
+ Long typeId = getAllForRelationVO.getTypeId();
|
|
|
+ List<KlConcept> klConcepts = klConceptFacade.list(new QueryWrapper<KlConcept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .like("lib_name", name.trim())
|
|
|
+ .eq("lib_type", typeId));
|
|
|
+ names = klConcepts.stream().map(x -> x.getLibName()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ return names;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<GetAllForRelationDTO> findDisNameAlls(DisNameFindVO disNameFindVO) {
|
|
|
+ return findDisNameAll(disNameFindVO);
|
|
|
+ }
|
|
|
+}
|