|
@@ -1,5 +1,16 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -18,20 +29,11 @@ import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.RespDTOUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
+import com.diagbot.vo.ConceptSearchVO;
|
|
|
import com.diagbot.vo.IndexConfigDiseaseIdVO;
|
|
|
import com.diagbot.vo.IndexConfigDiseaseNameVO;
|
|
|
import com.diagbot.vo.IndexConfigListVO;
|
|
|
import com.diagbot.vo.IndexConfigVO;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
-import org.springframework.stereotype.Component;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author wangfeng
|
|
@@ -41,138 +43,148 @@ import java.util.stream.Collectors;
|
|
|
@Component
|
|
|
public class IndexConfigFacade extends IndexConfigServiceImpl {
|
|
|
|
|
|
- @Autowired
|
|
|
- @Qualifier("indexConfigServiceImpl")
|
|
|
- IndexConfigService indexConfigService;
|
|
|
- @Autowired
|
|
|
- UserServiceClient userServiceClient;
|
|
|
-
|
|
|
- /**
|
|
|
- * @param indexConfigDiseaseNameVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public IPage<IndexConfigDTO> queryIndexConfigPage(IndexConfigDiseaseNameVO indexConfigDiseaseNameVO) {
|
|
|
- IPage<IndexConfigDTO> datas = this.queryIndexConfigPageAlls(indexConfigDiseaseNameVO);
|
|
|
- List<IndexConfigDTO> data = datas.getRecords();
|
|
|
- List<String> modifierid
|
|
|
- = data.stream().map(ac -> ac.getModifier()).collect(Collectors.toList());
|
|
|
- Map<String, String> userNames = new HashMap<>();
|
|
|
- if (ListUtil.isNotEmpty(modifierid)) {
|
|
|
- RespDTO<Map<String, String>> userNamesDTO = userServiceClient.getUserInfoByIds(modifierid);
|
|
|
- if (RespDTOUtil.respIsNG(userNamesDTO)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "获取所有用户信息失败");
|
|
|
- }
|
|
|
- userNames = userNamesDTO.data;
|
|
|
- }
|
|
|
-
|
|
|
- for (IndexConfigDTO evalua : data) {
|
|
|
- evalua.setModifier(userNames.get(evalua.getModifier()));
|
|
|
- }
|
|
|
- return datas;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param indexConfigDiseaseIdVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<IndexConfigAllDTO> getIndexConfigLists(IndexConfigDiseaseIdVO indexConfigDiseaseIdVO) {
|
|
|
- QueryWrapper<IndexConfig> IndexConfigQuery = new QueryWrapper<IndexConfig>();
|
|
|
- IndexConfigQuery.eq("disease_id", indexConfigDiseaseIdVO.getDiseaseId())
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
- List<IndexConfig> datas = list(IndexConfigQuery);
|
|
|
- //过滤
|
|
|
- List<IndexConfigAllDTO> data = BeanUtil.listCopyTo(datas, IndexConfigAllDTO.class);
|
|
|
- return data;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param indexConfigListVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public boolean updateIndexConfigList(IndexConfigListVO indexConfigListVO) {
|
|
|
- boolean res = false;
|
|
|
- if (indexConfigListVO != null && ListUtil.isNotEmpty(indexConfigListVO.getIndexConfigData())) {
|
|
|
- IndexConfigDiseaseIdVO indexConfigDiseaseIdVO = new IndexConfigDiseaseIdVO();
|
|
|
- indexConfigDiseaseIdVO.setDiseaseId(indexConfigListVO.getDiseaseId());
|
|
|
- res = cancelIndexConfigAlls(indexConfigDiseaseIdVO);
|
|
|
- List<IndexConfig> IndexConfigLsit = new ArrayList<IndexConfig>();
|
|
|
- List<IndexConfigVO> data = indexConfigListVO.getIndexConfigData();
|
|
|
- Date optDate = DateUtil.now();
|
|
|
- String operator = UserUtils.getCurrentPrincipleID();
|
|
|
- for (IndexConfigVO dataNew : data) {
|
|
|
- IndexConfig IndexConfig = new IndexConfig();
|
|
|
- BeanUtil.copyProperties(dataNew, IndexConfig);
|
|
|
- IndexConfig.setGmtCreate(optDate);
|
|
|
- IndexConfig.setGmtModified(optDate);
|
|
|
- IndexConfig.setCreator(operator);
|
|
|
- IndexConfig.setModifier(operator);
|
|
|
- IndexConfigLsit.add(IndexConfig);
|
|
|
- }
|
|
|
-
|
|
|
- res = indexConfigService.saveBatch(IndexConfigLsit);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return res;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param indexConfigListVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public boolean saveIndexConfigList(IndexConfigListVO indexConfigListVO) {
|
|
|
- boolean res = false;
|
|
|
- if (indexConfigListVO != null
|
|
|
- && ListUtil.isNotEmpty(indexConfigListVO.getIndexConfigData())) {
|
|
|
- List<IndexConfigVO> indexConfigData = indexConfigListVO.getIndexConfigData();
|
|
|
- List<String> indexUnique = new ArrayList<>();
|
|
|
- for (IndexConfigVO e : indexConfigData) {
|
|
|
- indexUnique.add(e.getIndexUnique());
|
|
|
- }
|
|
|
-
|
|
|
- QueryWrapper<IndexConfig> IndexConfigQuery = new QueryWrapper<>();
|
|
|
-
|
|
|
- IndexConfigQuery.eq("disease_id", indexConfigListVO.getDiseaseId())
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .in("index_unique", indexUnique);
|
|
|
- List<IndexConfig> dataUnique = list(IndexConfigQuery);
|
|
|
- if (ListUtil.isNotEmpty(dataUnique)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
- "该'" + dataUnique.get(0).getConceptId() + "'已存在");
|
|
|
- }
|
|
|
-
|
|
|
- List<IndexConfig> IndexConfigLsit = new ArrayList<IndexConfig>();
|
|
|
- List<IndexConfigVO> data = indexConfigListVO.getIndexConfigData();
|
|
|
- Date optDate = DateUtil.now();
|
|
|
- String operator = UserUtils.getCurrentPrincipleID();
|
|
|
- for (IndexConfigVO dataNew : data) {
|
|
|
- IndexConfig IndexConfig = new IndexConfig();
|
|
|
- BeanUtil.copyProperties(dataNew, IndexConfig);
|
|
|
- IndexConfig.setGmtCreate(optDate);
|
|
|
- IndexConfig.setGmtModified(optDate);
|
|
|
- IndexConfig.setCreator(operator);
|
|
|
- IndexConfig.setModifier(operator);
|
|
|
- IndexConfigLsit.add(IndexConfig);
|
|
|
- }
|
|
|
- res = indexConfigService.saveBatch(IndexConfigLsit);
|
|
|
- }
|
|
|
-
|
|
|
- return res;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param indexConfigDiseaseIdVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public boolean cancelIndexConfigAlls(IndexConfigDiseaseIdVO indexConfigDiseaseIdVO) {
|
|
|
-
|
|
|
- UpdateWrapper<IndexConfig> IndexConfigNew = new UpdateWrapper<>();
|
|
|
- IndexConfigNew.eq("disease_id", indexConfigDiseaseIdVO.getDiseaseId())
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
- .set("modifier", UserUtils.getCurrentPrincipleID())
|
|
|
- .set("gmt_modified", DateUtil.now());
|
|
|
- return update(new IndexConfig(), IndexConfigNew);
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("indexConfigServiceImpl")
|
|
|
+ IndexConfigService indexConfigService;
|
|
|
+ @Autowired
|
|
|
+ UserServiceClient userServiceClient;
|
|
|
+ @Autowired
|
|
|
+ ConceptFacade conceptFacade;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param indexConfigDiseaseNameVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public IPage<IndexConfigDTO> queryIndexConfigPage(IndexConfigDiseaseNameVO indexConfigDiseaseNameVO) {
|
|
|
+ IPage<IndexConfigDTO> datas = this.queryIndexConfigPageAlls(indexConfigDiseaseNameVO);
|
|
|
+ List<IndexConfigDTO> data = datas.getRecords();
|
|
|
+ List<String> modifierid = data.stream().map(ac -> ac.getModifier()).collect(Collectors.toList());
|
|
|
+ Map<String, String> userNames = new HashMap<>();
|
|
|
+ if (ListUtil.isNotEmpty(modifierid)) {
|
|
|
+ RespDTO<Map<String, String>> userNamesDTO = userServiceClient.getUserInfoByIds(modifierid);
|
|
|
+ if (RespDTOUtil.respIsNG(userNamesDTO)) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "获取所有用户信息失败");
|
|
|
+ }
|
|
|
+ userNames = userNamesDTO.data;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (IndexConfigDTO evalua : data) {
|
|
|
+ evalua.setModifier(userNames.get(evalua.getModifier()));
|
|
|
+ }
|
|
|
+ return datas;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param indexConfigDiseaseIdVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IndexConfigAllDTO> getIndexConfigLists(IndexConfigDiseaseIdVO indexConfigDiseaseIdVO) {
|
|
|
+ QueryWrapper<IndexConfig> IndexConfigQuery = new QueryWrapper<IndexConfig>();
|
|
|
+ IndexConfigQuery.eq("disease_id", indexConfigDiseaseIdVO.getDiseaseId()).eq("is_deleted",
|
|
|
+ IsDeleteEnum.N.getKey());
|
|
|
+ List<IndexConfig> datas = list(IndexConfigQuery);
|
|
|
+ // 过滤
|
|
|
+ List<IndexConfigAllDTO> data = BeanUtil.listCopyTo(datas, IndexConfigAllDTO.class);
|
|
|
+
|
|
|
+ List<Long> conceptIds = data.stream().map(ac -> ac.getConceptId()).collect(Collectors.toList());
|
|
|
+ ConceptSearchVO conceptSearchVO = new ConceptSearchVO();
|
|
|
+ conceptSearchVO.setConceptIds(conceptIds);
|
|
|
+ Map<Long, String> indexUniques = new HashMap<>();
|
|
|
+ if (ListUtil.isNotEmpty(conceptIds)) {
|
|
|
+ indexUniques = conceptFacade.getConceptNameMap(conceptSearchVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (IndexConfigAllDTO evalua : data) {
|
|
|
+ evalua.setIndexUnique(indexUniques.get(evalua.getConceptId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param indexConfigListVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean updateIndexConfigList(IndexConfigListVO indexConfigListVO) {
|
|
|
+ boolean res = false;
|
|
|
+ if (indexConfigListVO != null && ListUtil.isNotEmpty(indexConfigListVO.getIndexConfigData())) {
|
|
|
+ IndexConfigDiseaseIdVO indexConfigDiseaseIdVO = new IndexConfigDiseaseIdVO();
|
|
|
+ indexConfigDiseaseIdVO.setDiseaseId(indexConfigListVO.getDiseaseId());
|
|
|
+ res = cancelIndexConfigAlls(indexConfigDiseaseIdVO);
|
|
|
+ List<IndexConfig> IndexConfigLsit = new ArrayList<IndexConfig>();
|
|
|
+ List<IndexConfigVO> data = indexConfigListVO.getIndexConfigData();
|
|
|
+ Date optDate = DateUtil.now();
|
|
|
+ String operator = UserUtils.getCurrentPrincipleID();
|
|
|
+ for (IndexConfigVO dataNew : data) {
|
|
|
+ IndexConfig IndexConfig = new IndexConfig();
|
|
|
+ BeanUtil.copyProperties(dataNew, IndexConfig);
|
|
|
+ IndexConfig.setGmtCreate(optDate);
|
|
|
+ IndexConfig.setGmtModified(optDate);
|
|
|
+ IndexConfig.setCreator(operator);
|
|
|
+ IndexConfig.setModifier(operator);
|
|
|
+ IndexConfigLsit.add(IndexConfig);
|
|
|
+ }
|
|
|
+
|
|
|
+ res = indexConfigService.saveBatch(IndexConfigLsit);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param indexConfigListVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean saveIndexConfigList(IndexConfigListVO indexConfigListVO) {
|
|
|
+ boolean res = false;
|
|
|
+ if (indexConfigListVO != null && ListUtil.isNotEmpty(indexConfigListVO.getIndexConfigData())) {
|
|
|
+ List<IndexConfigVO> indexConfigData = indexConfigListVO.getIndexConfigData();
|
|
|
+ List<Long> conceptId = new ArrayList<>();
|
|
|
+ for (IndexConfigVO e : indexConfigData) {
|
|
|
+ conceptId.add(e.getConceptId());
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<IndexConfig> IndexConfigQuery = new QueryWrapper<>();
|
|
|
+
|
|
|
+ IndexConfigQuery.eq("disease_id", indexConfigListVO.getDiseaseId())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()).in("concept_id", conceptId);
|
|
|
+ List<IndexConfig> dataUnique = list(IndexConfigQuery);
|
|
|
+ if (ListUtil.isNotEmpty(dataUnique)) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "该'" + dataUnique.get(0).getConceptId() + "'已存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<IndexConfig> IndexConfigLsit = new ArrayList<IndexConfig>();
|
|
|
+ List<IndexConfigVO> data = indexConfigListVO.getIndexConfigData();
|
|
|
+ Date optDate = DateUtil.now();
|
|
|
+ String operator = UserUtils.getCurrentPrincipleID();
|
|
|
+ for (IndexConfigVO dataNew : data) {
|
|
|
+ IndexConfig IndexConfig = new IndexConfig();
|
|
|
+ BeanUtil.copyProperties(dataNew, IndexConfig);
|
|
|
+ IndexConfig.setGmtCreate(optDate);
|
|
|
+ IndexConfig.setGmtModified(optDate);
|
|
|
+ IndexConfig.setCreator(operator);
|
|
|
+ IndexConfig.setModifier(operator);
|
|
|
+ IndexConfigLsit.add(IndexConfig);
|
|
|
+ }
|
|
|
+ res = indexConfigService.saveBatch(IndexConfigLsit);
|
|
|
+ }
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param indexConfigDiseaseIdVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean cancelIndexConfigAlls(IndexConfigDiseaseIdVO indexConfigDiseaseIdVO) {
|
|
|
+
|
|
|
+ UpdateWrapper<IndexConfig> IndexConfigNew = new UpdateWrapper<>();
|
|
|
+ IndexConfigNew.eq("disease_id", indexConfigDiseaseIdVO.getDiseaseId()).eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey()).set("modifier", UserUtils.getCurrentPrincipleID())
|
|
|
+ .set("gmt_modified", DateUtil.now());
|
|
|
+ return update(new IndexConfig(), IndexConfigNew);
|
|
|
+ }
|
|
|
|
|
|
}
|