|
@@ -30,9 +30,7 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -116,7 +114,9 @@ public class KlDiagnoseImportFacade {
|
|
|
}
|
|
|
// 校验其他行数据、格式
|
|
|
List<ImportDiagnoseVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, sheetNum.intValue(), ImportDiagnoseVO.class);
|
|
|
- dealVerify(currentErrMsg, diagtypes, data, concept_map);
|
|
|
+ //处理公式(确诊)
|
|
|
+ List<String> orderList = processFormula(data, diagtypes);
|
|
|
+ dealVerify(currentErrMsg, orderList, diagtypes, data, concept_map);
|
|
|
|
|
|
// 数据赋值
|
|
|
if (ListUtil.isEmpty(currentErrMsg)) {
|
|
@@ -132,6 +132,48 @@ public class KlDiagnoseImportFacade {
|
|
|
return allFlag;
|
|
|
}
|
|
|
|
|
|
+ private List<String> processFormula(List<ImportDiagnoseVO> data,List<String> diagtypes) {
|
|
|
+ List<String> orderList = Lists.newArrayList();
|
|
|
+ Map<String,List<String>> typeCollect = Maps.newHashMap();
|
|
|
+ if(ListUtil.isNotEmpty(data)){
|
|
|
+ ListIterator<ImportDiagnoseVO> it = data.listIterator();
|
|
|
+ while (it.hasNext()){
|
|
|
+ ImportDiagnoseVO next = it.next();
|
|
|
+ String type = next.getType();
|
|
|
+ String orderNo = next.getOrderNo();
|
|
|
+ Integer rowNum = next.getRowNum()-1;
|
|
|
+ if(!diagtypes.contains(type)){
|
|
|
+ orderList.add(orderNo);
|
|
|
+ }
|
|
|
+ if("拟诊".equals(type) && StringUtils.isNotBlank(orderNo)){
|
|
|
+ if(typeCollect.containsKey(type)){
|
|
|
+ List<String> gongsi = typeCollect.get(type);
|
|
|
+ gongsi.add(orderNo);
|
|
|
+ typeCollect.put(type,gongsi);
|
|
|
+ }else {
|
|
|
+ List<String> gongsi = Lists.newArrayList();
|
|
|
+ gongsi.add(orderNo);
|
|
|
+ typeCollect.put(type,gongsi);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if("确诊".equals(type) && StringUtils.isNotBlank(orderNo)){
|
|
|
+ if(orderNo.contains("拟诊") && typeCollect.containsKey("拟诊")){
|
|
|
+ it.remove();
|
|
|
+ for (String nizhen:typeCollect.get("拟诊")) {
|
|
|
+ ImportDiagnoseVO importDiagnoseVO = new ImportDiagnoseVO();
|
|
|
+ importDiagnoseVO.setParentRule(next.getOrderNo());
|
|
|
+ importDiagnoseVO.setType(type);
|
|
|
+ importDiagnoseVO.setRowNum(rowNum);
|
|
|
+ importDiagnoseVO.setOrderNo(orderNo.replace("拟诊",nizhen));
|
|
|
+ it.add(importDiagnoseVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return orderList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取sheet名称和序号的对应关系
|
|
|
*
|
|
@@ -179,12 +221,14 @@ public class KlDiagnoseImportFacade {
|
|
|
}
|
|
|
|
|
|
//数据及格式校验
|
|
|
- private void dealVerify(List<String> currentErrMsg, List<String> diagtypes, List<ImportDiagnoseVO> data, Map<String, KlConcept> concept_map) {
|
|
|
-
|
|
|
- //所有序号
|
|
|
- List<String> orderNums = Lists.newArrayList();
|
|
|
- //所有公式
|
|
|
- List<String> verifies = Lists.newArrayList();
|
|
|
+ private void dealVerify(List<String> currentErrMsg,List<String> orderNums, List<String> diagtypes, List<ImportDiagnoseVO> data, Map<String, KlConcept> concept_map) {
|
|
|
+ //list元素计数
|
|
|
+ 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) {
|
|
|
+ currentErrMsg.add(String.format("%s序号重复", "【" + on.getKey() + "】"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if (ListUtil.isNotEmpty(data)) {
|
|
|
for (ImportDiagnoseVO imd : data) {
|
|
@@ -195,12 +239,9 @@ public class KlDiagnoseImportFacade {
|
|
|
String eq = imd.getEq();
|
|
|
String maxSymbol = imd.getMaxSymbol();
|
|
|
String minSymbol = imd.getMinSymbol();
|
|
|
+ String parentRule = imd.getParentRule();
|
|
|
|
|
|
- if (diagtypes.contains(type) && StringUtil.isNotBlank(orderNo)) {
|
|
|
- verifies.add(orderNo.trim());
|
|
|
- }
|
|
|
if (StringUtil.isNotBlank(type) && StringUtil.isNotBlank(rule) && StringUtil.isNotBlank(orderNo)) {
|
|
|
- orderNums.add(orderNo);
|
|
|
if (!type.contains("正则") &&
|
|
|
!concept_map.containsKey(rule + "_" + String.valueOf(LexiconExtEnum.getEnum(type).getKey()))) {
|
|
|
currentErrMsg.add(String.format("第%d行【%s】不是标准词", rowNum, rule));
|
|
@@ -232,25 +273,28 @@ public class KlDiagnoseImportFacade {
|
|
|
if (StringUtils.isNotBlank(type) && !diagtypes.contains(type) && StringUtils.isBlank(rule)) {
|
|
|
currentErrMsg.add(String.format("第%d行【规则】不能为空", rowNum));
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- //list元素计数
|
|
|
- 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) {
|
|
|
- currentErrMsg.add(String.format("%s序号重复", "【" + on.getKey() + "】"));
|
|
|
+ if (diagtypes.contains(type) && StringUtil.isNotBlank(orderNo)) {
|
|
|
+ String s = VerifyUtil.verifyFormula(orderNums, orderNo);
|
|
|
+ if (StringUtil.isNotBlank(s)) {
|
|
|
+ if(StringUtil.isNotBlank(parentRule)){
|
|
|
+ s = s.replace(orderNo,parentRule);
|
|
|
+ }
|
|
|
+ currentErrMsg.add(s);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//格式校验
|
|
|
- if (ListUtil.isNotEmpty(verifies)) {
|
|
|
+ /*if (ListUtil.isNotEmpty(verifies)) {
|
|
|
for (String vef : verifies) {
|
|
|
String s = VerifyUtil.verifyFormula(orderNums, vef);
|
|
|
if (StringUtil.isNotBlank(s)) {
|
|
|
currentErrMsg.add(s);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
}
|
|
|
|