|
@@ -40,7 +40,6 @@ import com.diagbot.service.LibraryInfoService;
|
|
|
import com.diagbot.service.impl.ConceptServiceImpl;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
-import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.AddConceptInfoDetailVO;
|
|
@@ -109,7 +108,7 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
|
medicalQe.in("concept_id", libraryInfoList.stream().map(i->i.getConceptId()).collect(Collectors.toList()));
|
|
|
Map<Long,Medical> medicalMap =medicalFacade.list(medicalQe).stream().collect(Collectors.toMap(Medical::getConceptId, i->i));
|
|
|
libraryInfoList = libraryInfoList.stream().filter(i->{
|
|
|
- if(medicalMap.get(i.getConceptId())!=null){
|
|
|
+ if(medicalMap.get(i.getConceptId())==null){
|
|
|
return true;
|
|
|
}else{
|
|
|
return false;
|
|
@@ -180,13 +179,18 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
|
String currentUser = UserUtils.getCurrentPrincipleID();
|
|
|
Date now = DateUtil.now();
|
|
|
|
|
|
- QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<LibraryInfo>();
|
|
|
- libraryInfoQe.eq("concept_id", removeConceptInfoVO.getConceptId());
|
|
|
+ QueryWrapper<LibraryInfo> libraryInfoQe1 = new QueryWrapper<>();
|
|
|
+ libraryInfoQe1.eq("concept_id", removeConceptInfoVO.getConceptId());
|
|
|
+ libraryInfoQe1.eq("is_concept", 0);
|
|
|
+ libraryinfoFacade.remove(libraryInfoQe1);
|
|
|
+
|
|
|
+ QueryWrapper<LibraryInfo> libraryInfoQe2 = new QueryWrapper<>();
|
|
|
+ libraryInfoQe2.eq("concept_id", removeConceptInfoVO.getConceptId());
|
|
|
LibraryInfo libraryInfo = new LibraryInfo();
|
|
|
libraryInfo.setIsDeleted("Y");
|
|
|
libraryInfo.setGmtModified(now);
|
|
|
libraryInfo.setModifier(currentUser);
|
|
|
- libraryinfoFacade.update(libraryInfo, libraryInfoQe);
|
|
|
+ libraryinfoFacade.update(libraryInfo, libraryInfoQe2);
|
|
|
|
|
|
Concept concept = new Concept();
|
|
|
concept.setId(removeConceptInfoVO.getConceptId());
|
|
@@ -201,7 +205,7 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
|
/**
|
|
|
* 获取医学术语命名详情
|
|
|
* @param getConceptInfoDetailVO
|
|
|
- * @return 1-标准术语,0-同义词
|
|
|
+ * @return libName-标准术语,otherNames-同义词
|
|
|
*/
|
|
|
public Map<String,List<GetConceptInfoDetailDTO>> getConceptInfoDetail(GetConceptInfoDetailVO getConceptInfoDetailVO){
|
|
|
QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<LibraryInfo>();
|
|
@@ -219,127 +223,159 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
|
|
|
|
/**
|
|
|
* 医学术语命名添加或者编辑
|
|
|
+ * 说明:1、不允许单个非标准术语添加
|
|
|
+ *
|
|
|
* @param addConceptInfoVO
|
|
|
* @return
|
|
|
*/
|
|
|
- @SuppressWarnings("unchecked")
|
|
|
public Boolean addConceptInfo(AddConceptInfoVO addConceptInfoVO){
|
|
|
- Map<String,Object> ckMap = checkAddConceptInfoVO(addConceptInfoVO);
|
|
|
- Object message = ckMap.get("message");
|
|
|
- if(message!=null){
|
|
|
- throw new CommonException(CommonErrorCode.RPC_ERROR,message.toString());
|
|
|
- }
|
|
|
-
|
|
|
- saveConceptInfos((List<LibraryInfo>)ckMap.get("libraryInfoList"));
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 医学术语命名保存
|
|
|
- * @param libraryInfoList
|
|
|
- * @return
|
|
|
- */
|
|
|
- private void saveConceptInfos(List<LibraryInfo> saveOrUpdateLibraryInfoList){
|
|
|
- if(ListUtil.isNotEmpty(saveOrUpdateLibraryInfoList)){
|
|
|
- libraryInfoService.saveOrUpdateBatch(saveOrUpdateLibraryInfoList);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 校验即将添加的数据
|
|
|
- * @param addConceptInfoVO
|
|
|
- * @return 返回map中,包含2个字段:message和libraryInfoList,message-为空时,表示正常,取LibraryInfo的集合libraryInfoList
|
|
|
- */
|
|
|
- private Map<String,Object> checkAddConceptInfoVO(AddConceptInfoVO addConceptInfoVO){
|
|
|
- Map<String,Object> retMap = new HashMap<>();
|
|
|
-
|
|
|
+ if(addConceptInfoVO.getDetailList().stream().distinct().count()!=addConceptInfoVO.getDetailList().size()){
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR,"存在重复数据("+addConceptInfoVO.getName()+")");
|
|
|
+ }
|
|
|
+
|
|
|
List<AddConceptInfoDetailVO> addConceptInfoDetailVOMainList = addConceptInfoVO.getDetailList().stream().filter(i->i.getIsConcept()==1).collect(Collectors.toList());
|
|
|
if(addConceptInfoDetailVOMainList.size()==0){
|
|
|
- retMap.put("message", "无标准术语");
|
|
|
- return retMap;
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR,"无标准术语("+addConceptInfoVO.getName()+")");
|
|
|
}
|
|
|
if(addConceptInfoDetailVOMainList.size()>1){
|
|
|
- retMap.put("message", "标准术语只能有一个");
|
|
|
- return retMap;
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR,"标准术语只能有一个("+addConceptInfoVO.getName()+")");
|
|
|
}
|
|
|
|
|
|
List<LibraryInfo> saveOrUpdateLibraryInfoList = new ArrayList<>();
|
|
|
|
|
|
AddConceptInfoDetailVO addConceptInfoDetailVOMain = addConceptInfoDetailVOMainList.get(0);//提交过来的标准术语
|
|
|
|
|
|
- StringBuffer sbf = new StringBuffer();
|
|
|
+ //查询当前添加的术语是否已经在数据库中
|
|
|
+ QueryWrapper<LibraryInfo> libraryInfoQe1 = new QueryWrapper<>();
|
|
|
+ libraryInfoQe1.eq("type", addConceptInfoVO.getType());
|
|
|
+ libraryInfoQe1.in("name", addConceptInfoVO.getDetailList().stream().map(i->i.getName()).collect(Collectors.toList()));
|
|
|
+ List<LibraryInfo> libraryInfoList = libraryinfoFacade.list(libraryInfoQe1);
|
|
|
|
|
|
- QueryWrapper<LibraryInfo> libraryInfoQe = new QueryWrapper<LibraryInfo>();
|
|
|
- libraryInfoQe.eq("type", addConceptInfoVO.getType());
|
|
|
- libraryInfoQe.in("name", addConceptInfoVO.getDetailList().stream().map(i->i.getName()).collect(Collectors.toList()));
|
|
|
- Map<String,LibraryInfo> libraryInfoMap = libraryinfoFacade.list(libraryInfoQe).stream().collect(Collectors.toMap(LibraryInfo::getName, i->i));
|
|
|
+ String currentUser = UserUtils.getCurrentPrincipleID();
|
|
|
+ Date now = DateUtil.now();
|
|
|
|
|
|
+ Map<String,LibraryInfo> libraryInfoMap = libraryInfoList.stream().collect(Collectors.toMap(LibraryInfo::getName, i->i));
|
|
|
LibraryInfo libraryInfoMain = libraryInfoMap.get(addConceptInfoDetailVOMain.getName());
|
|
|
- if(libraryInfoMain!=null&&libraryInfoMain.getIsDeleted().equals("N")&&libraryInfoMain.getIsConcept()==0){
|
|
|
- retMap.put("message", "标准术语已被占用");
|
|
|
- return retMap;
|
|
|
+ Concept concept = new Concept();
|
|
|
+ Long conceptId = null;
|
|
|
+ int oldlibraryInfoCount = 0;
|
|
|
+ boolean isUpdateConcept = false;
|
|
|
+ if(libraryInfoMain==null){
|
|
|
+ libraryInfoMain = new LibraryInfo();
|
|
|
+ BeanUtil.copyProperties(addConceptInfoDetailVOMain, libraryInfoMain);
|
|
|
+ libraryInfoMain.setGmtCreated(now);
|
|
|
+ libraryInfoMain.setCreator(currentUser);
|
|
|
+ libraryInfoMain.setGmtModified(now);
|
|
|
+ libraryInfoMain.setModifier(currentUser);
|
|
|
+ libraryInfoMain.setType(addConceptInfoVO.getType());
|
|
|
+ libraryinfoFacade.save(libraryInfoMain);
|
|
|
+ concept.setLibId(libraryInfoMain.getId());
|
|
|
+ concept.setGmtCreated(now);
|
|
|
+ concept.setCreator(currentUser);
|
|
|
+ concept.setGmtModified(now);
|
|
|
+ concept.setModifier(currentUser);
|
|
|
+ save(concept);
|
|
|
+ conceptId = concept.getId();
|
|
|
+ libraryInfoMain.setConceptId(conceptId);
|
|
|
+ }else{
|
|
|
+ if(libraryInfoMain.getIsDeleted().equals("N")&&libraryInfoMain.getIsConcept()==0
|
|
|
+ &&(libraryInfoList.stream().filter(i->i.getIsDeleted().equals("N")).count()==1||libraryInfoList.stream().filter(i->i.getIsDeleted().equals("N")).map(i->i.getConceptId()).distinct().count()>1)){
|
|
|
+ QueryWrapper<LibraryInfo> libraryInfoQe2 = new QueryWrapper<>();
|
|
|
+ libraryInfoQe2.eq("is_deleted", "N");
|
|
|
+ libraryInfoQe2.eq("is_concept", 1);
|
|
|
+ libraryInfoQe2.eq("concept_id", libraryInfoMain.getConceptId());
|
|
|
+ LibraryInfo libraryInfo = libraryinfoFacade.getOne(libraryInfoQe2);
|
|
|
+ if(libraryInfo!=null){
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR,"标准术语已作为同义词被概念"+libraryInfo.getName()+"-"+libraryInfo.getType()+"占用");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ conceptId = libraryInfoMain.getConceptId();
|
|
|
+ concept.setId(conceptId);
|
|
|
+
|
|
|
+ if(libraryInfoMain.getIsDeleted().equals("Y")
|
|
|
+ ||(libraryInfoMain.getIsDeleted().equals("N")&&libraryInfoMain.getIsConcept()==0)
|
|
|
+ ||!(StringUtil.isBlank(libraryInfoMain.getRemark())?"":libraryInfoMain.getRemark()).equals((StringUtil.isBlank(addConceptInfoDetailVOMain.getRemark())?"":addConceptInfoDetailVOMain.getRemark()))){
|
|
|
+ concept.setLibId(libraryInfoMain.getId());
|
|
|
+ concept.setIsDeleted("N");
|
|
|
+ concept.setGmtModified(now);
|
|
|
+ concept.setModifier(currentUser);
|
|
|
+
|
|
|
+ libraryInfoMain.setIsDeleted("N");
|
|
|
+ libraryInfoMain.setIsConcept(1);
|
|
|
+ libraryInfoMain.setGmtModified(now);
|
|
|
+ libraryInfoMain.setModifier(currentUser);
|
|
|
+ libraryInfoMain.setRemark(addConceptInfoDetailVOMain.getRemark());
|
|
|
+
|
|
|
+ isUpdateConcept = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<LibraryInfo> libraryInfoQe2 = new QueryWrapper<>();
|
|
|
+ libraryInfoQe2.eq("concept_id", conceptId);
|
|
|
+ libraryInfoQe2.ne("id", libraryInfoMain.getId());
|
|
|
+ oldlibraryInfoCount = libraryinfoFacade.count(libraryInfoQe2);
|
|
|
+ libraryinfoFacade.remove(libraryInfoQe2);
|
|
|
}
|
|
|
|
|
|
+ StringBuffer sbf = new StringBuffer();
|
|
|
for(AddConceptInfoDetailVO i:addConceptInfoVO.getDetailList()){
|
|
|
if(i.getIsConcept()==1){
|
|
|
continue;
|
|
|
}
|
|
|
LibraryInfo libraryInfo = libraryInfoMap.get(i.getName());
|
|
|
- if(libraryInfo!=null){
|
|
|
- if(libraryInfo.getIsDeleted().equals("N")&&(libraryInfoMain == null||libraryInfo.getConceptId()!=libraryInfoMain.getConceptId())){
|
|
|
- sbf.append(i.getName()).append(" ");
|
|
|
- continue;
|
|
|
- }
|
|
|
- libraryInfo.setIsDeleted("N");
|
|
|
- libraryInfo.setRemark(i.getRemark());
|
|
|
- }else{
|
|
|
+ if(libraryInfo==null){
|
|
|
libraryInfo = new LibraryInfo();
|
|
|
- BeanUtil.copyProperties(i, libraryInfo);
|
|
|
+ libraryInfo.setGmtCreated(now);
|
|
|
+ libraryInfo.setCreator(currentUser);
|
|
|
+ libraryInfo.setGmtModified(now);
|
|
|
+ libraryInfo.setModifier(currentUser);
|
|
|
+ isUpdateConcept = true;
|
|
|
+ }else if(libraryInfo.getIsDeleted().equals("Y")){
|
|
|
+ libraryInfo.setGmtModified(now);
|
|
|
+ libraryInfo.setModifier(currentUser);
|
|
|
+ isUpdateConcept = true;
|
|
|
+ }else if(libraryInfo.getConceptId().intValue()!=conceptId.intValue()){
|
|
|
+ sbf.append(i.getName()).append(" ");
|
|
|
+ continue;
|
|
|
+ }else if(!(StringUtil.isBlank(i.getRemark())?"":i.getRemark()).equals((StringUtil.isBlank(libraryInfo.getRemark())?"":libraryInfo.getRemark()))){
|
|
|
+ libraryInfo.setGmtModified(now);
|
|
|
+ libraryInfo.setModifier(currentUser);
|
|
|
+ isUpdateConcept = true;
|
|
|
}
|
|
|
+
|
|
|
+ libraryInfo.setName(i.getName());
|
|
|
+ libraryInfo.setIsConcept(0);
|
|
|
+ libraryInfo.setIsDeleted("N");
|
|
|
+ libraryInfo.setRemark(i.getRemark());
|
|
|
saveOrUpdateLibraryInfoList.add(libraryInfo);
|
|
|
}
|
|
|
|
|
|
if(sbf.length()>0){
|
|
|
sbf.append("已被占用");
|
|
|
- retMap.put("message", sbf.toString());
|
|
|
- return retMap;
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR,sbf.toString());
|
|
|
}
|
|
|
|
|
|
- Long conceptId = null;
|
|
|
- if(libraryInfoMain==null){
|
|
|
- libraryInfoMain = new LibraryInfo();
|
|
|
- BeanUtil.copyProperties(addConceptInfoDetailVOMain, libraryInfoMain);
|
|
|
- libraryInfoMain.setType(addConceptInfoVO.getType());
|
|
|
- libraryinfoFacade.save(libraryInfoMain);
|
|
|
- Concept concept = new Concept();
|
|
|
- concept.setLibId(libraryInfoMain.getId());
|
|
|
- save(concept);
|
|
|
- conceptId = concept.getId();
|
|
|
- }else{
|
|
|
- libraryInfoMain.setRemark(addConceptInfoDetailVOMain.getRemark());
|
|
|
- Concept concept = new Concept();
|
|
|
- if(libraryInfoMain.getIsDeleted().equals("N")){
|
|
|
- conceptId = libraryInfoMain.getConceptId();
|
|
|
- }else{
|
|
|
- libraryInfoMain.setIsDeleted("N");
|
|
|
- if(libraryInfoMain.getIsConcept()==1){
|
|
|
- concept.setIsDeleted("N");
|
|
|
- }else{
|
|
|
- concept.setLibId(libraryInfoMain.getId());
|
|
|
- }
|
|
|
- }
|
|
|
+ //更新前后同义词个数不一样,修改更新时间
|
|
|
+ if(oldlibraryInfoCount!=saveOrUpdateLibraryInfoList.size()){
|
|
|
+ isUpdateConcept = true;
|
|
|
}
|
|
|
|
|
|
- saveOrUpdateLibraryInfoList.add(libraryInfoMain);
|
|
|
for(LibraryInfo i : saveOrUpdateLibraryInfoList){
|
|
|
+ i.setId(null);
|
|
|
i.setConceptId(conceptId);
|
|
|
i.setType(addConceptInfoVO.getType());
|
|
|
}
|
|
|
+ saveOrUpdateLibraryInfoList.add(libraryInfoMain);
|
|
|
|
|
|
- retMap.put("libraryInfoList", saveOrUpdateLibraryInfoList);
|
|
|
+ libraryInfoService.saveOrUpdateBatch(saveOrUpdateLibraryInfoList);
|
|
|
|
|
|
- return retMap;
|
|
|
+ if(isUpdateConcept){
|
|
|
+ concept.setGmtModified(now);
|
|
|
+ concept.setModifier(currentUser);
|
|
|
+ updateById(concept);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -456,7 +492,9 @@ public class ConceptFacade extends ConceptServiceImpl {
|
|
|
throw new CommonException(CommonErrorCode.RPC_ERROR,sbf.toString());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ addConceptInfoVOList.forEach(i->{
|
|
|
+ addConceptInfo(i);
|
|
|
+ });
|
|
|
|
|
|
return true;
|
|
|
}
|