|
@@ -22,6 +22,7 @@ import com.diagbot.vo.KlDiagnoseTypeVO;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import org.apache.commons.collections4.map.LinkedMap;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
@@ -82,17 +83,17 @@ public class KlDiagnoseImportFacade {
|
|
|
// 指定诊断列表
|
|
|
List<String> diags = diagnoseImportVO.getDiags();
|
|
|
if (ListUtil.isNotEmpty(diags)) {
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
+ List<String> allErrMsg = Lists.newArrayList();
|
|
|
Map<String, Integer> inputNumNameMap = new LinkedMap<>();
|
|
|
for (String diag : diags) {
|
|
|
if (!sheetNumNameMap.containsKey(diag)) {
|
|
|
- sb.append(String.format("输入的诊断: %s不在下面的sheet中; ", "【" + diag + "】"));
|
|
|
+ allErrMsg.add(String.format("输入的诊断: %s不在下面的sheet中", "【" + diag + "】"));
|
|
|
} else {
|
|
|
inputNumNameMap.put(diag, sheetNumNameMap.get(diag));
|
|
|
}
|
|
|
}
|
|
|
- if (StringUtil.isNotBlank(sb.toString())) {
|
|
|
- diagMessage.put("输入校验", sb.toString());
|
|
|
+ if (ListUtil.isNotEmpty(allErrMsg)) {
|
|
|
+ diagMessage.put("输入校验", StringUtils.join(allErrMsg, "; "));
|
|
|
allFlag = false;
|
|
|
return allFlag;
|
|
|
} else {
|
|
@@ -100,7 +101,7 @@ public class KlDiagnoseImportFacade {
|
|
|
}
|
|
|
}
|
|
|
for (Map.Entry<String, Integer> sheet : sheetNumNameMap.entrySet()) {
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
+ List<String> currentErrMsg = Lists.newArrayList();
|
|
|
String sheetName = sheet.getKey();
|
|
|
Integer sheetNum = sheet.getValue();
|
|
|
ImportDiagnoseResVO importDiagnoseResVO = new ImportDiagnoseResVO();
|
|
@@ -111,21 +112,21 @@ public class KlDiagnoseImportFacade {
|
|
|
importDiagnoseResVO.setDiseaseName(sheetName);
|
|
|
importDiagnoseResVO.setDiseaseId(klConcept.getId());
|
|
|
} else {
|
|
|
- sb.append(String.format("sheetName: %s不是标准词; ", "【" + sheetName + "】"));
|
|
|
+ currentErrMsg.add(String.format("sheetName: %s不是标准词", "【" + sheetName + "】"));
|
|
|
}
|
|
|
// 校验其他行数据、格式
|
|
|
List<ImportDiagnoseVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, sheetNum.intValue(), ImportDiagnoseVO.class);
|
|
|
- sb = dealVerify(sb, diagtypes, data, concept_map);
|
|
|
+ dealVerify(currentErrMsg, diagtypes, data, concept_map);
|
|
|
|
|
|
// 数据赋值
|
|
|
- if (StringUtil.isBlank(sb.toString())) {
|
|
|
+ if (ListUtil.isEmpty(currentErrMsg)) {
|
|
|
data = dealImportDiagnose(diagtypes, data, concept_map);
|
|
|
// 添加到正确数据列表
|
|
|
importDiagnoseResVO.setImportDiagnoseVOList(data);
|
|
|
allData.add(importDiagnoseResVO);
|
|
|
} else {
|
|
|
allFlag = false;
|
|
|
- diagMessage.put(sheetName, sb.toString());
|
|
|
+ diagMessage.put(sheetName, StringUtils.join(currentErrMsg, "; "));
|
|
|
}
|
|
|
}
|
|
|
return allFlag;
|
|
@@ -178,7 +179,7 @@ public class KlDiagnoseImportFacade {
|
|
|
}
|
|
|
|
|
|
//数据及格式校验
|
|
|
- private StringBuilder dealVerify(StringBuilder sb, List<String> diagtypes, List<ImportDiagnoseVO> data, Map<String, KlConcept> concept_map) {
|
|
|
+ private void dealVerify(List<String> currentErrMsg, List<String> diagtypes, List<ImportDiagnoseVO> data, Map<String, KlConcept> concept_map) {
|
|
|
|
|
|
//所有序号
|
|
|
List<String> orderNums = Lists.newArrayList();
|
|
@@ -200,16 +201,16 @@ public class KlDiagnoseImportFacade {
|
|
|
orderNums.add(orderNo);
|
|
|
if (!type.contains("正则") &&
|
|
|
!concept_map.containsKey(rule + "_" + String.valueOf(LexiconExtEnum.getEnum(type).getKey()))) {
|
|
|
- sb.append(String.format("%s不是标准词; ", rule));
|
|
|
+ currentErrMsg.add(String.format("%s不是标准词", rule));
|
|
|
}
|
|
|
}
|
|
|
if (StringUtil.isNotBlank(maxSymbol) &&
|
|
|
!"<=".equals(maxSymbol) && !"<".equals(maxSymbol)) {
|
|
|
- sb.append(String.format("%s的最大符号%s不正确; ", rule, maxSymbol));
|
|
|
+ currentErrMsg.add(String.format("%s的最大符号%s不正确; ", rule, maxSymbol));
|
|
|
}
|
|
|
if (StringUtil.isNotBlank(minSymbol) &&
|
|
|
!">=".equals(minSymbol) && !">".equals(minSymbol)) {
|
|
|
- sb.append(String.format("%s的最小符号%s不正确; ", rule, minSymbol));
|
|
|
+ currentErrMsg.add(String.format("%s的最小符号%s不正确; ", rule, minSymbol));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -217,7 +218,7 @@ public class KlDiagnoseImportFacade {
|
|
|
Map<String, Long> orderNumMap = orderNums.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
|
|
for (Map.Entry<String, Long> on : orderNumMap.entrySet()) {
|
|
|
if (on.getValue() > 1) {
|
|
|
- sb.append(String.format("%s序号重复; ", "【" + on.getKey() + "】"));
|
|
|
+ currentErrMsg.add(String.format("%s序号重复; ", "【" + on.getKey() + "】"));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -225,11 +226,12 @@ public class KlDiagnoseImportFacade {
|
|
|
if (ListUtil.isNotEmpty(verifies)) {
|
|
|
for (String vef : verifies) {
|
|
|
String s = VerifyUtil.verifyFormula(orderNums, vef);
|
|
|
- sb.append(s);
|
|
|
+ if (StringUtil.isNotBlank(s)) {
|
|
|
+ currentErrMsg.add(s);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return sb;
|
|
|
}
|
|
|
|
|
|
private Map<String, KlConcept> getConceptMap() {
|