|
@@ -15,17 +15,23 @@ import com.diagbot.enums.LexiconEnum;
|
|
|
import com.diagbot.enums.StatusEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.KlConceptDetailService;
|
|
|
import com.diagbot.service.impl.KlConceptStaticServiceImpl;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.vo.KlConceptStaticPageVO;
|
|
|
+import com.diagbot.vo.KlConceptStaticVO;
|
|
|
import com.diagbot.vo.StaticKnowledgeVO;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -47,6 +53,10 @@ public class KlConceptStaticFacade extends KlConceptStaticServiceImpl {
|
|
|
@Autowired
|
|
|
private DictionaryFacade dictionaryFacade;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("klConceptDetailServiceImpl")
|
|
|
+ private KlConceptDetailService klConceptDetailService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取静态知识
|
|
|
*
|
|
@@ -208,6 +218,81 @@ public class KlConceptStaticFacade extends KlConceptStaticServiceImpl {
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存记录(新增or修改)
|
|
|
+ *
|
|
|
+ * @param klConceptStaticVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean saveOrUpdateRecord(KlConceptStaticVO klConceptStaticVO) {
|
|
|
+ //String userId = SysUserUtils.getCurrentPrincipleID();
|
|
|
+ if (klConceptStaticVO.getUserId() == null) {
|
|
|
+ klConceptStaticVO.setUserId(0L);
|
|
|
+ }
|
|
|
+ Date now = DateUtil.now();
|
|
|
+
|
|
|
+ Integer type = convertType(klConceptStaticVO.getType(), 1);
|
|
|
+ klConceptStaticVO.setType(type);
|
|
|
+
|
|
|
+ KlConcept concept = new KlConcept();
|
|
|
+ if (klConceptStaticVO.getId() != null) {
|
|
|
+ concept = klConceptFacade.getById(klConceptStaticVO.getId());
|
|
|
+ } else {
|
|
|
+ concept = klConceptFacade.getOne(new QueryWrapper<KlConcept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("lib_name", klConceptStaticVO.getName())
|
|
|
+ .eq("lib_type", type), false);
|
|
|
+ }
|
|
|
+ if (concept == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "标准术语不存在");
|
|
|
+ }
|
|
|
+ if (!concept.getLibName().equals(klConceptStaticVO.getName())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "标准术语名称不允许修改");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long conceptId = concept.getId();
|
|
|
+ KlConceptStatic staticInfo = this.getOne(new QueryWrapper<KlConceptStatic>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("concept_id", concept.getId()), false);
|
|
|
+
|
|
|
+ if (staticInfo == null) {
|
|
|
+ staticInfo = new KlConceptStatic();
|
|
|
+ staticInfo.setId(null);
|
|
|
+ staticInfo.setConceptId(concept.getId());
|
|
|
+ staticInfo.setStatus(StatusEnum.Enable.getKey());
|
|
|
+ staticInfo.setCreator(klConceptStaticVO.getUserId().toString());
|
|
|
+ staticInfo.setGmtCreate(now);
|
|
|
+ }
|
|
|
+ staticInfo.setClinicalPathwayName(klConceptStaticVO.getClinicalPathwayName());
|
|
|
+ staticInfo.setNoticeName(klConceptStaticVO.getNoticeName());
|
|
|
+ staticInfo.setModifier(klConceptStaticVO.getUserId().toString());
|
|
|
+ staticInfo.setGmtModified(now);
|
|
|
+
|
|
|
+ List<KlConceptDetail> details = Lists.newLinkedList();
|
|
|
+ if (ListUtil.isNotEmpty(klConceptStaticVO.getDetails())) {
|
|
|
+ details = BeanUtil.listCopyTo(klConceptStaticVO.getDetails(), KlConceptDetail.class);
|
|
|
+ }
|
|
|
+ details.forEach(detail -> {
|
|
|
+ detail.setConceptId(conceptId);
|
|
|
+ detail.setCreator(klConceptStaticVO.getUserId().toString());
|
|
|
+ detail.setGmtCreate(now);
|
|
|
+ detail.setModifier(klConceptStaticVO.getUserId().toString());
|
|
|
+ detail.setGmtModified(now);
|
|
|
+ });
|
|
|
+
|
|
|
+ //保存静态知识基础信息
|
|
|
+ this.saveOrUpdate(staticInfo);
|
|
|
+
|
|
|
+ //删除已有明细
|
|
|
+ klConceptDetailService.remove(new QueryWrapper<KlConceptDetail>()
|
|
|
+ .eq("concept_id", concept.getId()));
|
|
|
+
|
|
|
+ //保存新的明细
|
|
|
+ klConceptDetailService.saveBatch(details);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public Integer convertType(Integer type, Integer flag) {
|
|
|
Integer retType = null;
|
|
@@ -257,4 +342,4 @@ public class KlConceptStaticFacade extends KlConceptStaticServiceImpl {
|
|
|
}
|
|
|
return retType;
|
|
|
}
|
|
|
-}
|
|
|
+}
|