|
@@ -3,9 +3,11 @@ 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.RelationNameDTO;
|
|
|
import com.diagbot.dto.RelationNamesDTO;
|
|
|
import com.diagbot.dto.RelationNodeDTO;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.entity.KlConcept;
|
|
|
import com.diagbot.entity.KlRelation;
|
|
|
import com.diagbot.entity.KlRelationOrder;
|
|
@@ -25,7 +27,6 @@ import com.diagbot.vo.KlRelationVO;
|
|
|
import com.diagbot.vo.RelationContactDetailVO;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
-import io.swagger.models.auth.In;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
@@ -45,6 +46,8 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Component
|
|
|
public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
+ @Autowired
|
|
|
+ private UserServiceClient userServiceClient;
|
|
|
@Autowired
|
|
|
private KlConceptFacade klConceptFacade;
|
|
|
@Autowired
|
|
@@ -135,6 +138,7 @@ public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
|
|
|
return relationNodeDTOList;
|
|
|
}
|
|
|
+
|
|
|
@DS("med")
|
|
|
@DSTransactional
|
|
|
public Boolean addRelation(List<KlRelationSaveVO> klRelationSaveVOs) {
|
|
@@ -171,14 +175,12 @@ public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
}
|
|
|
List<List<KlRelation>> relationGroupList = relationDataForAdd(klRelationSaveVOs);
|
|
|
|
|
|
-// String currentUser = UserUtils.getCurrentPrincipleID();
|
|
|
Date now = DateUtil.now();
|
|
|
List<KlRelation> relationLists = Lists.newArrayList();
|
|
|
relationGroupList.forEach(i -> {
|
|
|
i.forEach(j -> {
|
|
|
-// j.setCreator(currentUser);
|
|
|
j.setGmtCreate(now);
|
|
|
-// j.setModifier(currentUser);
|
|
|
+// j.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
j.setGmtModified(now);
|
|
|
relationLists.add(j);
|
|
|
});
|
|
@@ -196,7 +198,7 @@ public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
relationOrder.setGmtCreate(now);
|
|
|
relationOrder.setGmtModified(now);
|
|
|
// relationOrder.setCreator(currentUser);
|
|
|
-// relationOrder.setModifier(currentUser);
|
|
|
+// relationOrder.setModifier(UserUtils.getCurrentPrincipleID());
|
|
|
relationOrderList.add(relationOrder);
|
|
|
}
|
|
|
});
|
|
@@ -207,6 +209,73 @@ public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
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();
|
|
@@ -218,7 +287,7 @@ public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
Long eid = kls.getEid();
|
|
|
Integer srid = kls.getSrid();
|
|
|
List<Long> eids = kls.getEids();
|
|
|
- if(relationMap.containsKey(sid.toString()+"&"+rid.toString())){
|
|
|
+ if (relationMap.containsKey(sid.toString() + "&" + rid.toString())) {
|
|
|
List<KlRelation> klRelations_big = relationMap.get(sid.toString() + "&" + rid.toString());
|
|
|
KlRelation klRelation = new KlRelation();
|
|
|
klRelation.setStartId(sid);
|
|
@@ -226,8 +295,8 @@ public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
klRelation.setEndId(eid);
|
|
|
klRelation.setStatus(1);
|
|
|
klRelations_big.add(klRelation);
|
|
|
- relationMap.put(sid.toString() + "&" + rid.toString(),klRelations_big);
|
|
|
- }else {
|
|
|
+ relationMap.put(sid.toString() + "&" + rid.toString(), klRelations_big);
|
|
|
+ } else {
|
|
|
List<KlRelation> klRelations_big = Lists.newArrayList();
|
|
|
KlRelation klRelation = new KlRelation();
|
|
|
klRelation.setStartId(sid);
|
|
@@ -235,11 +304,11 @@ public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
klRelation.setEndId(eid);
|
|
|
klRelation.setStatus(1);
|
|
|
klRelations_big.add(klRelation);
|
|
|
- relationMap.put(sid.toString() + "&" + rid.toString(),klRelations_big);
|
|
|
+ relationMap.put(sid.toString() + "&" + rid.toString(), klRelations_big);
|
|
|
}
|
|
|
- if(srid != null && ListUtil.isNotEmpty(eids)){
|
|
|
+ if (srid != null && ListUtil.isNotEmpty(eids)) {
|
|
|
List<KlRelation> klRelations_sub = Lists.newArrayList();
|
|
|
- for (Long id:eids) {
|
|
|
+ for (Long id : eids) {
|
|
|
KlRelation klRelation = new KlRelation();
|
|
|
klRelation.setStartId(eid);
|
|
|
klRelation.setRelationId(srid);
|
|
@@ -247,12 +316,12 @@ public class RelationContactFacade extends KlRelationServiceImpl {
|
|
|
klRelation.setStatus(1);
|
|
|
klRelations_sub.add(klRelation);
|
|
|
}
|
|
|
- relationMap.put(eid.toString() + "&" + srid.toString(),klRelations_sub);
|
|
|
+ relationMap.put(eid.toString() + "&" + srid.toString(), klRelations_sub);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(MapUtils.isNotEmpty(relationMap)){
|
|
|
- relationMap.forEach((x,y)->{
|
|
|
+ if (MapUtils.isNotEmpty(relationMap)) {
|
|
|
+ relationMap.forEach((x, y) -> {
|
|
|
relationList.add(y);
|
|
|
});
|
|
|
}
|