|
@@ -6,14 +6,12 @@ import com.diagbot.entity.KlDiagnoseDetail;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.service.impl.KlDiagnoseDetailServiceImpl;
|
|
|
import com.diagbot.util.*;
|
|
|
+import org.apache.commons.collections.MapUtils;
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -40,6 +38,7 @@ public class KlDiagnoseDetailFacade extends KlDiagnoseDetailServiceImpl {
|
|
|
Map<String, List<KlDiagnoseDetail>> diagnoseDetailMap = EntityUtil.makeEntityListMap(klDiagnoseDetailList, "disName");
|
|
|
// TODO 获取公式,分隔编码,替换编码,组装导出数据 Map<String, List<ExportDiagnoseDTO>>
|
|
|
Map<String, List<ExportDiagnoseDTO>> diagnoseDetails = processDiagnoseDetail(diagnoseDetailMap);
|
|
|
+ System.out.println();
|
|
|
|
|
|
|
|
|
// TODO 导出数据
|
|
@@ -76,7 +75,8 @@ public class KlDiagnoseDetailFacade extends KlDiagnoseDetailServiceImpl {
|
|
|
* @param klDiagnoseDetails
|
|
|
*/
|
|
|
public void removeKlDiagnoseDetail(List<KlDiagnoseDetail> klDiagnoseDetails){
|
|
|
- List<String> regexData = getCodes(klDiagnoseDetails);
|
|
|
+ Map<String, List<String>> allFormula = getAllFormula(klDiagnoseDetails);
|
|
|
+ List<String> regexData = getCodes(allFormula);
|
|
|
Iterator<KlDiagnoseDetail> iterator = klDiagnoseDetails.iterator();
|
|
|
while (iterator.hasNext()){
|
|
|
KlDiagnoseDetail next = iterator.next();
|
|
@@ -87,19 +87,48 @@ public class KlDiagnoseDetailFacade extends KlDiagnoseDetailServiceImpl {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * 获取公式中的所有编码
|
|
|
+ * 获取每个诊断依据的公式
|
|
|
* @param klDiagnoseDetails
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<String> getCodes(List<KlDiagnoseDetail> klDiagnoseDetails) {
|
|
|
+ private Map<String,List<String>> getAllFormula(List<KlDiagnoseDetail> klDiagnoseDetails){
|
|
|
+ Map<String,List<String>> typeFormulaMap = new HashMap<>();
|
|
|
+ for (KlDiagnoseDetail klDiagnoseDetail : klDiagnoseDetails) {
|
|
|
+ Integer type = klDiagnoseDetail.getType();
|
|
|
+ String formula = klDiagnoseDetail.getFormula();
|
|
|
+ if((type == 91 || type == 92 || type == 93)&& StringUtil.isNotBlank(formula)){
|
|
|
+ if(typeFormulaMap.containsKey(type.toString())){
|
|
|
+ List<String> formulas = typeFormulaMap.get(type.toString());
|
|
|
+ formulas.add(formula);
|
|
|
+ typeFormulaMap.put(type.toString(),formulas);
|
|
|
+ }else {
|
|
|
+ List<String> formulas = Lists.newArrayList();
|
|
|
+ formulas.add(formula);
|
|
|
+ typeFormulaMap.put(type.toString(),formulas);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return typeFormulaMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取公式中的所有编码
|
|
|
+ * @param getAllFormula
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<String> getCodes(Map<String,List<String>> getAllFormula) {
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
String pateern = "([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])";
|
|
|
- List<String> collect = klDiagnoseDetails.stream().filter(x -> (x.getType().equals(91)
|
|
|
- || x.getType().equals(92)|| x.getType().equals(93))&& StringUtil.isNotBlank(x.getFormula()))
|
|
|
- .map(y -> y.getFormula()).collect(Collectors.toList());
|
|
|
- String content = collect.stream().collect(Collectors.joining(","));
|
|
|
+ if(MapUtils.isNotEmpty(getAllFormula)){
|
|
|
+ getAllFormula.forEach((x,y) ->{
|
|
|
+ String collect = y.stream().collect(Collectors.joining(","));
|
|
|
+ sb.append(collect);
|
|
|
+ });
|
|
|
+ }
|
|
|
//获取公式中的编码
|
|
|
- return RegexUtil.getRegexDatas(content, pateern);
|
|
|
+ return RegexUtil.getRegexDatas(sb.toString(), pateern);
|
|
|
}
|
|
|
|
|
|
}
|