|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.diagbot.client.CdssCoreClient;
|
|
|
+import com.diagbot.dto.DictionaryInfoDTO;
|
|
|
import com.diagbot.dto.HosRelationNumDTO;
|
|
|
import com.diagbot.dto.RespDTO;
|
|
|
import com.diagbot.entity.DrugConfig;
|
|
@@ -50,6 +51,8 @@ public class DrugConfigFacade {
|
|
|
private DrugConfigService drugConfigService;
|
|
|
@Autowired
|
|
|
private CdssCoreClient cdssCoreClient;
|
|
|
+ @Autowired
|
|
|
+ private DictionaryFacade dictionaryFacade;
|
|
|
|
|
|
/**
|
|
|
* 判断是否已存在
|
|
@@ -282,13 +285,43 @@ public class DrugConfigFacade {
|
|
|
|
|
|
//1、数据完整性校验
|
|
|
//2、去除前后空格
|
|
|
+ //过滤空数据,保留重复数据,方便计行
|
|
|
+ drugConfigList = drugConfigList.stream()
|
|
|
+ .filter(i -> StringUtil.isNotBlank(i.getHisName())
|
|
|
+ || StringUtil.isNotBlank(i.getForm())
|
|
|
+ || StringUtil.isNotBlank(i.getUniqueCode())
|
|
|
+ || StringUtil.isNotBlank(i.getUniqueName()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (ListUtil.isEmpty(drugConfigList)) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "校验失败,导入数据不能为空");
|
|
|
+ }
|
|
|
+ List<String> emptyNumList = Lists.newLinkedList();
|
|
|
+ //药品剂型
|
|
|
+ List<DictionaryInfoDTO> dicTypeMappingList = dictionaryFacade.getListByGroupType(9);
|
|
|
+ List<String> formList = dicTypeMappingList.stream()
|
|
|
+ .filter(i -> StringUtil.isNotBlank(i.getName()))
|
|
|
+ .map(i -> i.getName())
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<String> formErrNumList = Lists.newLinkedList();
|
|
|
for (int i = 0; i < drugConfigList.size(); i++) {
|
|
|
if (StringUtil.isBlank(drugConfigList.get(i).getHisName())
|
|
|
|| StringUtil.isBlank(drugConfigList.get(i).getUniqueName())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "第" + (i + 2) + "行存在不完整数据,导入失败,请修改后再试");
|
|
|
+ emptyNumList.add(String.valueOf(i + 2));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(drugConfigList.get(i).getHisName())) {
|
|
|
+ drugConfigList.get(i).setHisName(drugConfigList.get(i).getHisName().trim());
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(drugConfigList.get(i).getUniqueName())) {
|
|
|
+ drugConfigList.get(i).setUniqueName(drugConfigList.get(i).getUniqueName().trim());
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(drugConfigList.get(i).getForm())) {
|
|
|
+ if (!formList.contains(drugConfigList.get(i).getForm())) {
|
|
|
+ formErrNumList.add(String.valueOf(i + 2));
|
|
|
+ } else {
|
|
|
+ drugConfigList.get(i).setForm(drugConfigList.get(i).getForm().trim());
|
|
|
+ }
|
|
|
}
|
|
|
- drugConfigList.get(i).setHisName(drugConfigList.get(i).getHisName().trim());
|
|
|
- drugConfigList.get(i).setUniqueName(drugConfigList.get(i).getUniqueName().trim());
|
|
|
if (StringUtil.isNotBlank(drugConfigList.get(i).getUniqueCode())) {
|
|
|
drugConfigList.get(i).setUniqueCode(drugConfigList.get(i).getUniqueCode().trim());
|
|
|
} else {
|
|
@@ -296,6 +329,17 @@ public class DrugConfigFacade {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (ListUtil.isNotEmpty(emptyNumList)) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "以下行数(不计入空行)存在不完整数据:"
|
|
|
+ + emptyNumList.stream().collect(Collectors.joining("、"))
|
|
|
+ + "。导入取消,请修改后再试。\n");
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(formErrNumList)) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "以下行数(不计入空行)药品剂型与数据库药品剂型不匹配:"
|
|
|
+ + formErrNumList.stream().collect(Collectors.joining("、"))
|
|
|
+ + "。导入取消,请修改后再试。\n");
|
|
|
+ }
|
|
|
+
|
|
|
List<String> hisNames = drugConfigList
|
|
|
.stream()
|
|
|
.map(i -> i.getHisName())
|
|
@@ -330,6 +374,7 @@ public class DrugConfigFacade {
|
|
|
});
|
|
|
|
|
|
//标准术语校验
|
|
|
+ List<String> errorNumList = Lists.newLinkedList();
|
|
|
ConceptVO conceptVO = new ConceptVO();
|
|
|
conceptVO.setNames(uniqueNames);
|
|
|
conceptVO.setType(ConceptTypeEnum.Drug.getKey());
|
|
@@ -338,10 +383,15 @@ public class DrugConfigFacade {
|
|
|
List<String> names = respDTO.data;
|
|
|
for (int i = 0; i < drugConfigList.size(); i++) {
|
|
|
if (!names.contains(drugConfigList.get(i).getUniqueName())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "【" + drugConfigList.get(i).getUniqueName() + "】不是标准术语,导入失败,请修改后再试");
|
|
|
+ errorNumList.add(String.valueOf(i + 2));
|
|
|
}
|
|
|
}
|
|
|
+ if (ListUtil.isNotEmpty(errorNumList)) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
+ "以下行数(不计入空行)标准术语与数据库术语不匹配:"
|
|
|
+ + errorNumList.stream().collect(Collectors.joining("、"))
|
|
|
+ + "。导入取消,请修改后再试。");
|
|
|
+ }
|
|
|
|
|
|
//重复数据过滤
|
|
|
drugConfigList = drugConfigList
|