|
@@ -13,6 +13,8 @@ import com.diagbot.entity.ConceptDetail;
|
|
|
import com.diagbot.entity.ConceptInfo;
|
|
|
import com.diagbot.enums.ConceptTypeEnum;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.ConceptDetailService;
|
|
|
import com.diagbot.service.impl.ConceptInfoServiceImpl;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
@@ -23,6 +25,7 @@ import com.diagbot.util.RespDTOUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.ChangeStatusVO;
|
|
|
+import com.diagbot.vo.ConceptDetailVO;
|
|
|
import com.diagbot.vo.ConceptInfoPageVO;
|
|
|
import com.diagbot.vo.ConceptInfoVO;
|
|
|
import com.diagbot.vo.HasStaticKnowledgeVO;
|
|
@@ -121,8 +124,8 @@ public class ConceptInfoFacade extends ConceptInfoServiceImpl {
|
|
|
.collect(Collectors.toList());
|
|
|
if (ListUtil.isNotEmpty(conceptIdList)) {
|
|
|
QueryWrapper<ConceptDetail> conceptDetailQueryWrapper = new QueryWrapper<>();
|
|
|
- conceptDetailQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .in("concept_id", conceptIdList);
|
|
|
+ //conceptDetailQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
+ conceptDetailQueryWrapper.in("concept_id", conceptIdList);
|
|
|
List<ConceptDetail> conceptDetailList = conceptDetailFacade.list(conceptDetailQueryWrapper);
|
|
|
Map<Long, List<ConceptDetail>> detailMap
|
|
|
= EntityUtil.makeEntityListMap(conceptDetailList, "conceptId");
|
|
@@ -138,6 +141,9 @@ public class ConceptInfoFacade extends ConceptInfoServiceImpl {
|
|
|
}
|
|
|
for (ConceptDetail detail : detailMap.get(item.getId())) {
|
|
|
item.setHasInfo(1);
|
|
|
+ if (detail.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
List<String> contentTypeList = Arrays.asList(detail.getContentType().split(","));
|
|
|
if (contentTypeList.contains("1")) {
|
|
|
item.setHasStaticKnowledge(1);
|
|
@@ -238,7 +244,14 @@ public class ConceptInfoFacade extends ConceptInfoServiceImpl {
|
|
|
String typeName = convertTypeName(ConceptTypeEnum.getName(Integer.valueOf(conceptInfoVO.getType())), 1, dicList);
|
|
|
conceptInfoVO.setTypeName(typeName);
|
|
|
ConceptInfo conceptInfo = new ConceptInfo();
|
|
|
- if (conceptInfoVO.getId() == null) {
|
|
|
+
|
|
|
+ if (conceptInfoVO.getId() != null) {
|
|
|
+ conceptInfo = this.getById(conceptInfoVO.getId());
|
|
|
+ if (conceptInfo != null
|
|
|
+ && !conceptInfo.getName().equals(conceptInfoVO.getName())) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "标准术语名称不允许修改");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
QueryWrapper<ConceptInfo> conceptInfoQueryWrapper = new QueryWrapper<>();
|
|
|
conceptInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
.eq("name", conceptInfoVO.getName())
|
|
@@ -257,12 +270,18 @@ public class ConceptInfoFacade extends ConceptInfoServiceImpl {
|
|
|
conceptInfo.setType(typeName);
|
|
|
conceptInfo.setModifier(userId);
|
|
|
conceptInfo.setGmtModified(now);
|
|
|
- this.saveOrUpdate(conceptInfo);
|
|
|
- conceptInfoVO.setId(conceptInfo.getId());
|
|
|
+
|
|
|
//是否包含静态信息,包含启用和禁用
|
|
|
+ List<ConceptDetail> oldDetails = null;
|
|
|
QueryWrapper<ConceptDetail> conceptDetailQueryWrapper = new QueryWrapper<>();
|
|
|
- conceptDetailQueryWrapper.eq("concept_id",conceptInfo.getId());
|
|
|
- List<ConceptDetail> oldDetails = conceptDetailFacade.list(conceptDetailQueryWrapper);
|
|
|
+ if (conceptInfo.getId() != null) {
|
|
|
+ conceptDetailQueryWrapper.eq("concept_id", conceptInfo.getId());
|
|
|
+ oldDetails = conceptDetailFacade.list(conceptDetailQueryWrapper);
|
|
|
+ }
|
|
|
+ if (conceptInfoVO.getId() == null
|
|
|
+ && ListUtil.isNotEmpty(oldDetails)) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "静态信息已添加,不允许重复添加");
|
|
|
+ }
|
|
|
if (ListUtil.isEmpty(oldDetails)
|
|
|
&& ListUtil.isNotEmpty(conceptInfoVO.getDetails())) {
|
|
|
//TODO 更新图谱是否有静态信息
|
|
@@ -278,20 +297,26 @@ public class ConceptInfoFacade extends ConceptInfoServiceImpl {
|
|
|
}
|
|
|
|
|
|
//删除已有静态信息
|
|
|
- conceptDetailFacade.remove(conceptDetailQueryWrapper);
|
|
|
+ if (conceptInfo.getId() != null) {
|
|
|
+ conceptDetailFacade.remove(conceptDetailQueryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新术语信息
|
|
|
+ this.saveOrUpdate(conceptInfo);
|
|
|
+
|
|
|
//插入新的静态信息
|
|
|
List<ConceptDetail> conceptDetailList = Lists.newLinkedList();
|
|
|
if (ListUtil.isNotEmpty(conceptInfoVO.getDetails())) {
|
|
|
- conceptInfoVO.getDetails().forEach(detail -> {
|
|
|
+ for (ConceptDetailVO detailVO : conceptInfoVO.getDetails()) {
|
|
|
ConceptDetail conceptDetail = new ConceptDetail();
|
|
|
- BeanUtil.copyProperties(detail, conceptDetail);
|
|
|
- conceptDetail.setConceptId(conceptInfoVO.getId());
|
|
|
+ BeanUtil.copyProperties(detailVO, conceptDetail);
|
|
|
+ conceptDetail.setConceptId(conceptInfo.getId());
|
|
|
conceptDetail.setCreator(userId);
|
|
|
conceptDetail.setGmtCreate(now);
|
|
|
conceptDetail.setModifier(userId);
|
|
|
conceptDetail.setGmtModified(now);
|
|
|
conceptDetailList.add(conceptDetail);
|
|
|
- });
|
|
|
+ }
|
|
|
conceptDetailService.saveBatch(conceptDetailList);
|
|
|
}
|
|
|
return true;
|