瀏覽代碼

术语关系维护修改

rgb 6 年之前
父節點
當前提交
73e3fe5346

+ 5 - 1
knowledgeman-service/src/main/java/com/diagbot/dto/GetRelationInfoListDTO.java

@@ -84,7 +84,11 @@ public class GetRelationInfoListDTO {
 	@ApiModelProperty(value="操作时间")
     private Date operTime;
     
-    
+	/**
+     * 状态:Y-已删除,N-启用中
+     */
+	@ApiModelProperty(value="状态:Y-已删除,N-启用中")
+	private String isDeleted;
     
     
     

+ 19 - 33
knowledgeman-service/src/main/java/com/diagbot/facade/RelationFacade.java

@@ -75,32 +75,12 @@ public class RelationFacade extends RelationServiceImpl {
     	if(ids.size()>0){
     		RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
         	if (respDTO == null || !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
-                throw new CommonException(CommonErrorCode.RPC_ERROR,
-                        "获取用户信息失败");
+                throw new CommonException(CommonErrorCode.RPC_ERROR,"获取用户信息失败");
             }
         	ipage.getRecords().forEach(i->{
         		i.setOperName(respDTO.data.get(i.getOperName()));
         	});
     	}
-    	
-    	List<Long> conceptIds = new ArrayList<>();
-    	conceptIds.addAll(ipage.getRecords().stream().map(i->i.getStartId()).collect(Collectors.toList()));
-    	conceptIds.addAll(ipage.getRecords().stream().map(i->i.getEndId()).collect(Collectors.toList()));
-    	conceptIds = conceptIds.stream().distinct().collect(Collectors.toList());
-    	QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<LibraryInfo>();
-    	libraryInfoQe.eq("is_deleted", "N");
-    	libraryInfoQe.eq("is_concept", 1);
-    	libraryInfoQe.in("concept_id", conceptIds);
-    	Map<Long,LibraryInfo> libraryInfoMap = libraryInfoFacade.list(libraryInfoQe).stream().collect(Collectors.toMap(LibraryInfo::getConceptId, i->i));
-    	
-    	ipage.getRecords().forEach(i->{
-    		if(libraryInfoMap.get(i.getStartId())!=null){
-    			i.setStartType(libraryInfoMap.get(i.getStartId()).getType());
-    		}
-    		if(libraryInfoMap.get(i.getEndId())!=null){
-    			i.setEndType(libraryInfoMap.get(i.getEndId()).getType());
-    		}
-    	});
     	return ipage;
     }
     
@@ -111,11 +91,19 @@ public class RelationFacade extends RelationServiceImpl {
      */
     public Boolean removeRelationInfo(RemoveRelationInfoVO removeRelationInfoVO) {
     	Relation relation = this.getById(removeRelationInfoVO.getId());
-    	if(relation==null||relation.getIsDeleted().equals("Y")){
+    	if(relation==null){
     		throw new CommonException(CommonErrorCode.NOT_EXISTS);
     	}
+    	if(relation.getIsDeleted().equals(removeRelationInfoVO.getIsDeleted())){
+    		if(removeRelationInfoVO.getIsDeleted().equals("Y")){
+    			throw new CommonException(CommonErrorCode.RPC_ERROR,"该数据已删除!");
+    		}
+    		if(removeRelationInfoVO.getIsDeleted().equals("N")){
+    			throw new CommonException(CommonErrorCode.RPC_ERROR,"该数据已恢复!");
+    		}
+    	}
     	
-    	relation.setIsDeleted("Y");
+    	relation.setIsDeleted(removeRelationInfoVO.getIsDeleted());
     	relation.setModifier(UserUtils.getCurrentPrincipleID());
     	relation.setGmtModified(DateUtil.now());
         return updateById(relation);
@@ -205,12 +193,12 @@ public class RelationFacade extends RelationServiceImpl {
 		libraryInfoQe1.eq("type", addRelationInfoVO.getStartType());
 		LibraryInfo startLibraryInfo = libraryInfoFacade.getOne(libraryInfoQe1);
 		if(startLibraryInfo==null){
-			retMap.put("message", "关系起点术语不存在");
+			retMap.put("message", "数据库中无该起始术语");
 			return retMap;
 		}
 		Concept startConcept = conceptFacade.getById(startLibraryInfo.getConceptId());
 		if(startConcept==null||startConcept.getIsDeleted().equals("Y")||startConcept.getLibId().intValue()!=startLibraryInfo.getId().intValue()){
-			retMap.put("message", "关系起点术语不存在");
+			retMap.put("message", "数据库中无该起始术语");
 			return retMap;
 		}
 
@@ -221,12 +209,12 @@ public class RelationFacade extends RelationServiceImpl {
 		libraryInfoQe2.eq("type", addRelationInfoVO.getEndType());
 		LibraryInfo endLibraryInfo = libraryInfoFacade.getOne(libraryInfoQe2);
 		if(endLibraryInfo==null){
-			retMap.put("message", "关系终点术语不存在");
+			retMap.put("message", "数据库中无该终点术语");
 			return retMap;
 		}
 		Concept endConcept = conceptFacade.getById(endLibraryInfo.getConceptId());
 		if(endConcept==null||endConcept.getIsDeleted().equals("Y")||endConcept.getLibId().intValue()!=endLibraryInfo.getId().intValue()){
-			retMap.put("message", "关系终点术语不存在");
+			retMap.put("message", "数据库中无该终点术语");
 			return retMap;
 		}
 		
@@ -235,7 +223,7 @@ public class RelationFacade extends RelationServiceImpl {
 		lexiconRelationshipQe.eq("name", addRelationInfoVO.getRelationName());
 		LexiconRelationship lexiconRelationship = lexiconRelationshipFacade.getOne(lexiconRelationshipQe);
 		if(lexiconRelationship==null){
-			retMap.put("message", "术语关系类型不存在");
+			retMap.put("message", "该关系信息在数据库中不存在");
 			return retMap;
 		}
 		
@@ -326,7 +314,7 @@ public class RelationFacade extends RelationServiceImpl {
                                     continue;
                                 }
                                 
-                                addRelationInfoVOList.add(new AddRelationInfoVO(startName,startType,endName,endType,relationName));
+                                addRelationInfoVOList.add(new AddRelationInfoVO(startName,startType,endName,endType,relationName,count));
                             }
                         } else {
                             sbf.append("非excel文件无法解析!").append("<br/>");
@@ -367,7 +355,7 @@ public class RelationFacade extends RelationServiceImpl {
         }
         
         if(addRelationInfoVOList.size()==0){
-        	throw new CommonException(CommonErrorCode.RPC_ERROR,"导入数据不能为空");
+        	throw new CommonException(CommonErrorCode.RPC_ERROR,"导入数据不能为空");
         }
         
         /****************excel文件中数据存在重复提示---数据一模一样即重复***********************/
@@ -389,13 +377,11 @@ public class RelationFacade extends RelationServiceImpl {
         List<Relation> saveOrUpdateRelationList = new ArrayList<>();
         Map<String,Object> ckMap = null;
     	Object message = null;
-    	int count = 0;
     	for(AddRelationInfoVO i : addRelationInfoVOList){
-    		count++;
     		ckMap = checkAddRelationInfoVO(i);
     		message = ckMap.get("message");
     		if(message!=null){
-    			sbf.append(message.toString()).append("(第").append(count).append("行)").append("<br/>");
+    			sbf.append("第").append(i.getLineNum()).append("行数据有误,").append(message.toString()).append("<br/>");
     		}else if(ckMap.get("relation")!=null){
     			saveOrUpdateRelationList.add((Relation)(ckMap.get("relation")));
     		}

+ 6 - 2
knowledgeman-service/src/main/java/com/diagbot/vo/AddRelationInfoVO.java

@@ -50,21 +50,25 @@ public class AddRelationInfoVO {
 	@ApiModelProperty(value = "关系名称", required = true)
 	private String relationName;
 	
+	private int lineNum;
+	
 	public AddRelationInfoVO() {
 		super();
 	}
 	
 	public AddRelationInfoVO(@NotBlank(message = "关系起点术语名称必填") String startName,
 			@NotBlank(message = "关系起点术语类型必填") String startType, @NotBlank(message = "关系终点术语名称必填") String endName,
-			@NotBlank(message = "关系终点术语类型必填") String endType, @NotBlank(message = "关系名称必填") String relationName) {
+			@NotBlank(message = "关系终点术语类型必填") String endType, @NotBlank(message = "关系名称必填") String relationName,
+			int lineNum) {
 		super();
 		this.startName = startName;
 		this.startType = startType;
 		this.endName = endName;
 		this.endType = endType;
 		this.relationName = relationName;
+		this.lineNum = lineNum;
 	}
-
+	
 	@Override
 	public int hashCode() {
 		final int prime = 31;

+ 6 - 0
knowledgeman-service/src/main/java/com/diagbot/vo/GetRelationInfoListVO.java

@@ -33,5 +33,11 @@ public class GetRelationInfoListVO extends Page {
      */
 	@ApiModelProperty(value="关系终点术语名称")
     private String endName;
+	
+	/**
+     * 状态:Y-已删除,N-启用中
+     */
+	@ApiModelProperty(value="状态:Y-已删除,N-启用中")
+	private String isDeleted;
     
 }

+ 8 - 0
knowledgeman-service/src/main/java/com/diagbot/vo/RemoveRelationInfoVO.java

@@ -1,5 +1,6 @@
 package com.diagbot.vo;
 
+import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 
 import io.swagger.annotations.ApiModelProperty;
@@ -21,5 +22,12 @@ public class RemoveRelationInfoVO {
 	@ApiModelProperty(value="医学术语关系id",required=true)
 	@NotNull(message="医学术语关系id必传")
     private Long id;
+	
+	/**
+     * 状态:Y-删除,N-恢复
+     */
+	@NotBlank(message="状态必填")
+	@ApiModelProperty(value="状态:Y-删除,N-恢复",required=true)
+	private String isDeleted;
     
 }

+ 1 - 1
knowledgeman-service/src/main/java/com/diagbot/web/RelationController.java

@@ -50,7 +50,7 @@ public class RelationController {
         return RespDTO.onSuc(relationFacade.getRelationInfoList(getRelationInfoListVO));
     }
     
-    @ApiOperation(value = "医学术语关系删除[by:rengb]")
+    @ApiOperation(value = "医学术语关系删除或者恢复[by:rengb]")
     @PostMapping("/removeRelationInfo")
     @SysLogger("removeRelationInfo")
     @Transactional

+ 11 - 4
knowledgeman-service/src/main/resources/mapper/RelationMapper.xml

@@ -21,15 +21,22 @@
 		a.id,
 		a.start_id as startId,
 		(SELECT name FROM library_info where concept_id=a.start_id and is_concept=1 and is_deleted='N') as startName,
+		(SELECT type FROM library_info where concept_id=a.start_id and is_concept=1 and is_deleted='N') as startType,
 		a.end_id as endId,
 		(SELECT name FROM library_info where concept_id=a.end_id and is_concept=1 and is_deleted='N') as endName,
+		(SELECT type FROM library_info where concept_id=a.end_id and is_concept=1 and is_deleted='N') as endType,
 		a.relation_id as relationId,
 		(SELECT name FROM lexicon_relationship where id=a.relation_id and is_deleted='N') as relationName,
 		a.gmt_modified as operTime,
-		a.modifier as operName
-		from relation a
-		where a.is_deleted='N') t
+		a.modifier as operName,
+		a.is_deleted as isDeleted
+		from relation a) t
 		where 1=1 
+		and startName is not null 
+		and endName is not null
+		<if test="isDeleted!=null and isDeleted!=''">
+			and isDeleted=#{isDeleted}
+		</if>
 		<if test="relationId!=null">
 			and relationId=#{relationId}
 		</if>
@@ -39,7 +46,7 @@
 		<if test="endName!=null and endName!=''">
 			and endName like concat('%',#{endName},'%')
 		</if>
-		ORDER BY operTime desc
+		ORDER BY isDeleted asc, operTime desc
     </select>
 
 </mapper>