From 866a4992b24a65beaa2874219a78bd3bcf1f0493 Mon Sep 17 00:00:00 2001 From: litao Date: Thu, 22 Sep 2022 18:15:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=B8=E8=A7=84=E6=A3=80=E9=AA=8C=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=88=A4=E6=96=AD=E6=A0=B7=E5=93=81=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ExamineResultController.java | 799 +++++++++--------- 1 file changed, 401 insertions(+), 398 deletions(-) diff --git a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineResultController.java b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineResultController.java index 59e7485..79741fa 100644 --- a/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineResultController.java +++ b/lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineResultController.java @@ -21,6 +21,7 @@ import org.springblade.lims.service.*; import org.springblade.lims.utils.FormulaTool; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; + import javax.servlet.http.HttpServletResponse; import java.text.DecimalFormat; import java.util.*; @@ -94,13 +95,15 @@ public class ExamineResultController extends BladeController { } } - /** 普通Excel解析数据 review start **/ + /** + * 普通Excel解析数据 review start + **/ //获取单元格的值 - private String getCode(List list,Integer order){ + private String getCode(List list, Integer order) { String result; ExamineExcel examineExcel = (order % 8 - 1 >= 0) ? list.get(order % 8 - 1) : list.get(list.size() - 1); Integer re = order / 8 + 1; - switch (re){ + switch (re) { case 1: result = examineExcel.getCode1(); break; @@ -146,9 +149,9 @@ public class ExamineResultController extends BladeController { private R>>>> ptExcelReview( MultipartFile file, String examineId, - Map info, //变量对应的标版的孔位,一行行的逐渐递增 + Map info, //变量对应的标版的孔位,一行行的逐渐递增 String reg //计算公式 - ) throws Exception{ + ) throws Exception { try { List read = ExcelUtil.read(file, ExamineExcel.class); Map> map = new HashMap<>(); @@ -360,455 +363,455 @@ public class ExamineResultController extends BladeController { * 常规Excel解析数据 */ private R>>>> ptExcel(MultipartFile file, String examineId) throws Exception { - try { - List read = ExcelUtil.read(file, ExamineExcel.class); - Map> map = new HashMap<>(); - // 组数 - int group = 0; - // 除9是否有余数 - int size = (read.size() + 1) % 9; - if (size == 0) { - group = (read.size() + 1) / 9; - } else { - group = (read.size() + 1) / 9 + 1; - } + List read = ExcelUtil.read(file, ExamineExcel.class); + Map> map = new HashMap<>(); + // 组数 + int group = 0; + // 除9是否有余数 + int size = (read.size() + 1) % 9; + if (size == 0) { + group = (read.size() + 1) / 9; + } else { + group = (read.size() + 1) / 9 + 1; + } - for (int i = 0; i < group; i++) { - List excels = new ArrayList<>(); - for (int j = i * 8 + i; j < (i + 1) * 8 + i; j++) { - ExamineExcel excel = read.get(j); - excels.add(excel); - } - map.put((i + 1) + "", excels); + for (int i = 0; i < group; i++) { + List excels = new ArrayList<>(); + for (int j = i * 8 + i; j < (i + 1) * 8 + i; j++) { + ExamineExcel excel = read.get(j); + excels.add(excel); } + map.put((i + 1) + "", excels); + } - Examine examine = examineService.getById(examineId); - String experieNum = examine.getExperieNum(); - String[] split = experieNum.split(","); - - List> list = new ArrayList<>(); - // 按照公式计算实验数据并返回 - Map>>> map1 = new HashMap<>(); - - for (int i = 0; i < group; i++) { - List>> mapList = new ArrayList<>(); - List excels = map.get(i + 1 + ""); - double code1 = Double.parseDouble(excels.get(0).getCode1()); - double code2 = Double.parseDouble(excels.get(1).getCode1()); - double code3 = Double.parseDouble(excels.get(2).getCode1()); - double code4 = Double.parseDouble(excels.get(3).getCode1()); - double v1 = (code1 + code2) / 2; - double v2 = (code3 + code4) / 2; - DecimalFormat df = new DecimalFormat("#0.000"); - for (int j = 0; j < excels.size(); j++) { + Examine examine = examineService.getById(examineId); + String experieNum = examine.getExperieNum(); + String[] split = experieNum.split(","); + + List> list = new ArrayList<>(); + // 按照公式计算实验数据并返回 + Map>>> map1 = new HashMap<>(); + + for (int i = 0; i < group; i++) { + List>> mapList = new ArrayList<>(); + List excels = map.get(i + 1 + ""); + double code1 = Double.parseDouble(excels.get(0).getCode1()); + double code2 = Double.parseDouble(excels.get(1).getCode1()); + double code3 = Double.parseDouble(excels.get(2).getCode1()); + double code4 = Double.parseDouble(excels.get(3).getCode1()); + double v1 = (code1 + code2) / 2; + double v2 = (code3 + code4) / 2; + DecimalFormat df = new DecimalFormat("#0.000"); + for (int j = 0; j < excels.size(); j++) { - // 行标头:前端渲染需要A、B、C.... - String a = String.valueOf((char) (j + 65)); + // 行标头:前端渲染需要A、B、C.... + String a = String.valueOf((char) (j + 65)); - Map> map2 = new HashMap<>(); - int u = 1; - String SP = "0.00"; - if (j > 5) { - if (excels.get(j).getCode1() != null) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode1()) - v1) / (v2 - v1)); - } - Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode1()); - map3.put("value", SP); -// int b = (i * 90) + j - 6; - int b = (i * 96) + j; -// map3.put("num", split[b - ((i + 1) * 6)]); - map3.put("num", "1"); - map3.put("order", b + 1); - if (Double.parseDouble(SP) >= 0.4) { - map3.put("result", "阳性"); - } else { - map3.put("result", "阴性"); - } - map2.put(a + 1, map3); - list.add(map3); - } else { - Map map3 = new HashMap<>(); - map3.put("originResult", ""); - int b = (i * 96) + j; - map3.put("order", b + 1); - map3.put("num", ""); - map2.put(a + 1, map3); - list.add(map3); - } - } else { - if (excels.get(j).getCode1() != null) { - Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode1()); - int b = (i * 96) + j; - map3.put("order", b + 1); - map2.put(a + 1, map3); - list.add(map3); - } else { - Map map3 = new HashMap<>(); - map3.put("originResult", ""); - int b = (i * 96) + j; - map3.put("order", b + 1); - map3.put("num", ""); - map2.put(a + 1, map3); - list.add(map3); - } - } - if (excels.get(j).getCode2() != null) { + Map> map2 = new HashMap<>(); + int u = 1; + String SP = "0.00"; + if (j > 5) { + if (excels.get(j).getCode1() != null) { if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode2()) - v1) / (v2 - v1)); + SP = df.format((Double.parseDouble(excels.get(j).getCode1()) - v1) / (v2 - v1)); } Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode2()); + map3.put("originResult", excels.get(j).getCode1()); map3.put("value", SP); -// int b = (i * 90) + j + 2 + (u * 8); - int b = (i * 96) + j + (u * 8); +// int b = (i * 90) + j - 6; + int b = (i * 96) + j; +// map3.put("num", split[b - ((i + 1) * 6)]); map3.put("num", "1"); map3.put("order", b + 1); - u++; if (Double.parseDouble(SP) >= 0.4) { map3.put("result", "阳性"); } else { map3.put("result", "阴性"); } - map2.put(a + 2, map3); + map2.put(a + 1, map3); list.add(map3); } else { Map map3 = new HashMap<>(); map3.put("originResult", ""); - int b = (i * 96) + j + (u * 8); - map3.put("num", ""); + int b = (i * 96) + j; map3.put("order", b + 1); - u++; - map2.put(a + 2, map3); + map3.put("num", ""); + map2.put(a + 1, map3); list.add(map3); } - if (excels.get(j).getCode3() != null) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode3()) - v1) / (v2 - v1)); - } + } else { + if (excels.get(j).getCode1() != null) { Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode3()); - map3.put("value", SP); - int b = (i * 96) + j + (u * 8); - map3.put("num", "1"); + map3.put("originResult", excels.get(j).getCode1()); + int b = (i * 96) + j; map3.put("order", b + 1); - u++; - if (Double.parseDouble(SP) >= 0.4) { - map3.put("result", "阳性"); - } else { - map3.put("result", "阴性"); - } - map2.put(a + 3, map3); + map2.put(a + 1, map3); list.add(map3); } else { Map map3 = new HashMap<>(); map3.put("originResult", ""); - int b = (i * 96) + j + (u * 8); - map3.put("num", ""); + int b = (i * 96) + j; map3.put("order", b + 1); - u++; - map2.put(a + 3, map3); + map3.put("num", ""); + map2.put(a + 1, map3); list.add(map3); } - if (excels.get(j).getCode4() != null) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode4()) - v1) / (v2 - v1)); - } - Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode4()); - map3.put("value", SP); - int b = (i * 96) + j + (u * 8); - map3.put("num", "1"); - map3.put("order", b + 1); - u++; - if (Double.parseDouble(SP) >= 0.4) { - map3.put("result", "阳性"); - } else { - map3.put("result", "阴性"); - } - map2.put(a + 4, map3); - list.add(map3); + } + if (excels.get(j).getCode2() != null) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(excels.get(j).getCode2()) - v1) / (v2 - v1)); + } + Map map3 = new HashMap<>(); + map3.put("originResult", excels.get(j).getCode2()); + map3.put("value", SP); +// int b = (i * 90) + j + 2 + (u * 8); + int b = (i * 96) + j + (u * 8); + map3.put("num", "1"); + map3.put("order", b + 1); + u++; + if (Double.parseDouble(SP) >= 0.4) { + map3.put("result", "阳性"); } else { - Map map3 = new HashMap<>(); - map3.put("originResult", ""); - int b = (i * 96) + j + (u * 8); - map3.put("num", ""); - map3.put("order", b + 1); - u++; - map2.put(a + 4, map3); - list.add(map3); + map3.put("result", "阴性"); } - if (excels.get(j).getCode5() != null) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode5()) - v1) / (v2 - v1)); - } - Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode5()); - map3.put("value", SP); - int b = (i * 96) + j + (u * 8); - map3.put("num", "1"); - map3.put("order", b + 1); - u++; - if (Double.parseDouble(SP) >= 0.4) { - map3.put("result", "阳性"); - } else { - map3.put("result", "阴性"); - } - map2.put(a + 5, map3); - list.add(map3); + map2.put(a + 2, map3); + list.add(map3); + } else { + Map map3 = new HashMap<>(); + map3.put("originResult", ""); + int b = (i * 96) + j + (u * 8); + map3.put("num", ""); + map3.put("order", b + 1); + u++; + map2.put(a + 2, map3); + list.add(map3); + } + if (excels.get(j).getCode3() != null) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(excels.get(j).getCode3()) - v1) / (v2 - v1)); + } + Map map3 = new HashMap<>(); + map3.put("originResult", excels.get(j).getCode3()); + map3.put("value", SP); + int b = (i * 96) + j + (u * 8); + map3.put("num", "1"); + map3.put("order", b + 1); + u++; + if (Double.parseDouble(SP) >= 0.4) { + map3.put("result", "阳性"); } else { - Map map3 = new HashMap<>(); - map3.put("originResult", ""); - int b = (i * 96) + j + (u * 8); - map3.put("num", ""); - map3.put("order", b + 1); - u++; - map2.put(a + 5, map3); - list.add(map3); + map3.put("result", "阴性"); } - if (excels.get(j).getCode6() != null) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode6()) - v1) / (v2 - v1)); - } - Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode6()); - map3.put("value", SP); - int b = (i * 96) + j + (u * 8); - map3.put("num", "1"); - map3.put("order", b + 1); - u++; - if (Double.parseDouble(SP) >= 0.4) { - map3.put("result", "阳性"); - } else { - map3.put("result", "阴性"); - } - map2.put(a + 6, map3); - list.add(map3); + map2.put(a + 3, map3); + list.add(map3); + } else { + Map map3 = new HashMap<>(); + map3.put("originResult", ""); + int b = (i * 96) + j + (u * 8); + map3.put("num", ""); + map3.put("order", b + 1); + u++; + map2.put(a + 3, map3); + list.add(map3); + } + if (excels.get(j).getCode4() != null) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(excels.get(j).getCode4()) - v1) / (v2 - v1)); + } + Map map3 = new HashMap<>(); + map3.put("originResult", excels.get(j).getCode4()); + map3.put("value", SP); + int b = (i * 96) + j + (u * 8); + map3.put("num", "1"); + map3.put("order", b + 1); + u++; + if (Double.parseDouble(SP) >= 0.4) { + map3.put("result", "阳性"); } else { - Map map3 = new HashMap<>(); - map3.put("originResult", ""); - int b = (i * 96) + j + (u * 8); - map3.put("num", ""); - map3.put("order", b + 1); - u++; - map2.put(a + 6, map3); - list.add(map3); + map3.put("result", "阴性"); } - if (excels.get(j).getCode7() != null) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode7()) - v1) / (v2 - v1)); - } - Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode7()); - map3.put("value", SP); - int b = (i * 96) + j + (u * 8); - map3.put("num", "1"); - map3.put("order", b + 1); - u++; - if (Double.parseDouble(SP) >= 0.4) { - map3.put("result", "阳性"); - } else { - map3.put("result", "阴性"); - } - map2.put(a + 7, map3); - list.add(map3); + map2.put(a + 4, map3); + list.add(map3); + } else { + Map map3 = new HashMap<>(); + map3.put("originResult", ""); + int b = (i * 96) + j + (u * 8); + map3.put("num", ""); + map3.put("order", b + 1); + u++; + map2.put(a + 4, map3); + list.add(map3); + } + if (excels.get(j).getCode5() != null) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(excels.get(j).getCode5()) - v1) / (v2 - v1)); + } + Map map3 = new HashMap<>(); + map3.put("originResult", excels.get(j).getCode5()); + map3.put("value", SP); + int b = (i * 96) + j + (u * 8); + map3.put("num", "1"); + map3.put("order", b + 1); + u++; + if (Double.parseDouble(SP) >= 0.4) { + map3.put("result", "阳性"); } else { - Map map3 = new HashMap<>(); - map3.put("originResult", ""); - int b = (i * 96) + j + (u * 8); - map3.put("num", ""); - map3.put("order", b + 1); - u++; - map2.put(a + 7, map3); - list.add(map3); + map3.put("result", "阴性"); } - if (excels.get(j).getCode8() != null) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode8()) - v1) / (v2 - v1)); - } - Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode8()); - map3.put("value", SP); - int b = (i * 96) + j + (u * 8); - map3.put("num", "1"); - map3.put("order", b + 1); - u++; - if (Double.parseDouble(SP) >= 0.4) { - map3.put("result", "阳性"); - } else { - map3.put("result", "阴性"); - } - map2.put(a + 8, map3); - list.add(map3); + map2.put(a + 5, map3); + list.add(map3); + } else { + Map map3 = new HashMap<>(); + map3.put("originResult", ""); + int b = (i * 96) + j + (u * 8); + map3.put("num", ""); + map3.put("order", b + 1); + u++; + map2.put(a + 5, map3); + list.add(map3); + } + if (excels.get(j).getCode6() != null) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(excels.get(j).getCode6()) - v1) / (v2 - v1)); + } + Map map3 = new HashMap<>(); + map3.put("originResult", excels.get(j).getCode6()); + map3.put("value", SP); + int b = (i * 96) + j + (u * 8); + map3.put("num", "1"); + map3.put("order", b + 1); + u++; + if (Double.parseDouble(SP) >= 0.4) { + map3.put("result", "阳性"); } else { - Map map3 = new HashMap<>(); - map3.put("originResult", ""); - int b = (i * 96) + j + (u * 8); - map3.put("num", ""); - map3.put("order", b + 1); - u++; - map2.put(a + 8, map3); - list.add(map3); + map3.put("result", "阴性"); } - if (excels.get(j).getCode9() != null) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode9()) - v1) / (v2 - v1)); - } - Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode9()); - map3.put("value", SP); - int b = (i * 96) + j + (u * 8); - map3.put("num", "1"); - map3.put("order", b + 1); - u++; - if (Double.parseDouble(SP) >= 0.4) { - map3.put("result", "阳性"); - } else { - map3.put("result", "阴性"); - } - map2.put(a + 9, map3); - list.add(map3); + map2.put(a + 6, map3); + list.add(map3); + } else { + Map map3 = new HashMap<>(); + map3.put("originResult", ""); + int b = (i * 96) + j + (u * 8); + map3.put("num", ""); + map3.put("order", b + 1); + u++; + map2.put(a + 6, map3); + list.add(map3); + } + if (excels.get(j).getCode7() != null) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(excels.get(j).getCode7()) - v1) / (v2 - v1)); + } + Map map3 = new HashMap<>(); + map3.put("originResult", excels.get(j).getCode7()); + map3.put("value", SP); + int b = (i * 96) + j + (u * 8); + map3.put("num", "1"); + map3.put("order", b + 1); + u++; + if (Double.parseDouble(SP) >= 0.4) { + map3.put("result", "阳性"); } else { - Map map3 = new HashMap<>(); - map3.put("originResult", ""); - int b = (i * 96) + j + (u * 8); - map3.put("num", ""); - map3.put("order", b + 1); - u++; - map2.put(a + 9, map3); - list.add(map3); + map3.put("result", "阴性"); } - if (excels.get(j).getCode10() != null) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode10()) - v1) / (v2 - v1)); - } - Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode10()); - map3.put("value", SP); - int b = (i * 96) + j + (u * 8); - map3.put("num", "1"); - map3.put("order", b + 1); - u++; - if (Double.parseDouble(SP) >= 0.4) { - map3.put("result", "阳性"); - } else { - map3.put("result", "阴性"); - } - map2.put(a + 10, map3); - list.add(map3); + map2.put(a + 7, map3); + list.add(map3); + } else { + Map map3 = new HashMap<>(); + map3.put("originResult", ""); + int b = (i * 96) + j + (u * 8); + map3.put("num", ""); + map3.put("order", b + 1); + u++; + map2.put(a + 7, map3); + list.add(map3); + } + if (excels.get(j).getCode8() != null) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(excels.get(j).getCode8()) - v1) / (v2 - v1)); + } + Map map3 = new HashMap<>(); + map3.put("originResult", excels.get(j).getCode8()); + map3.put("value", SP); + int b = (i * 96) + j + (u * 8); + map3.put("num", "1"); + map3.put("order", b + 1); + u++; + if (Double.parseDouble(SP) >= 0.4) { + map3.put("result", "阳性"); } else { - Map map3 = new HashMap<>(); - map3.put("originResult", ""); - int b = (i * 96) + j + (u * 8); - map3.put("num", ""); - map3.put("order", b + 1); - u++; - map2.put(a + 10, map3); - list.add(map3); + map3.put("result", "阴性"); } - if (excels.get(j).getCode11() != null) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode11()) - v1) / (v2 - v1)); - } - Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode11()); - map3.put("value", SP); - int b = (i * 96) + j + (u * 8); - map3.put("num", "1"); - map3.put("order", b + 1); - u++; - if (Double.parseDouble(SP) >= 0.4) { - map3.put("result", "阳性"); - } else { - map3.put("result", "阴性"); - } - map2.put(a + 11, map3); - list.add(map3); + map2.put(a + 8, map3); + list.add(map3); + } else { + Map map3 = new HashMap<>(); + map3.put("originResult", ""); + int b = (i * 96) + j + (u * 8); + map3.put("num", ""); + map3.put("order", b + 1); + u++; + map2.put(a + 8, map3); + list.add(map3); + } + if (excels.get(j).getCode9() != null) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(excels.get(j).getCode9()) - v1) / (v2 - v1)); + } + Map map3 = new HashMap<>(); + map3.put("originResult", excels.get(j).getCode9()); + map3.put("value", SP); + int b = (i * 96) + j + (u * 8); + map3.put("num", "1"); + map3.put("order", b + 1); + u++; + if (Double.parseDouble(SP) >= 0.4) { + map3.put("result", "阳性"); } else { - Map map3 = new HashMap<>(); - map3.put("originResult", ""); - int b = (i * 96) + j + (u * 8); - map3.put("num", ""); - map3.put("order", b + 1); - u++; - map2.put(a + 11, map3); - list.add(map3); + map3.put("result", "阴性"); } - if (excels.get(j).getCode12() != null) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(excels.get(j).getCode12()) - v1) / (v2 - v1)); - } - Map map3 = new HashMap<>(); - map3.put("originResult", excels.get(j).getCode12()); - map3.put("value", SP); - int b = (i * 96) + j + (u * 8); - map3.put("num", "1"); - map3.put("order", b + 1); - u++; - if (Double.parseDouble(SP) >= 0.4) { - map3.put("result", "阳性"); - } else { - map3.put("result", "阴性"); - } - map2.put(a + 12, map3); - list.add(map3); + map2.put(a + 9, map3); + list.add(map3); + } else { + Map map3 = new HashMap<>(); + map3.put("originResult", ""); + int b = (i * 96) + j + (u * 8); + map3.put("num", ""); + map3.put("order", b + 1); + u++; + map2.put(a + 9, map3); + list.add(map3); + } + if (excels.get(j).getCode10() != null) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(excels.get(j).getCode10()) - v1) / (v2 - v1)); + } + Map map3 = new HashMap<>(); + map3.put("originResult", excels.get(j).getCode10()); + map3.put("value", SP); + int b = (i * 96) + j + (u * 8); + map3.put("num", "1"); + map3.put("order", b + 1); + u++; + if (Double.parseDouble(SP) >= 0.4) { + map3.put("result", "阳性"); } else { - Map map3 = new HashMap<>(); - map3.put("originResult", ""); - int b = (i * 96) + j + (u * 8); - map3.put("num", ""); - map3.put("order", b + 1); - u++; - map2.put(a + 12, map3); - list.add(map3); + map3.put("result", "阴性"); } - mapList.add(map2); + map2.put(a + 10, map3); + list.add(map3); + } else { + Map map3 = new HashMap<>(); + map3.put("originResult", ""); + int b = (i * 96) + j + (u * 8); + map3.put("num", ""); + map3.put("order", b + 1); + u++; + map2.put(a + 10, map3); + list.add(map3); } - map1.put("g" + (i + 1), mapList); - } - - Collections.sort(list, new Comparator>() { - @Override - public int compare(Map o1, Map o2) { - Integer id1 = (Integer) o1.get("order"); - Integer id2 = (Integer) o2.get("order"); - // 升序 - return id1.compareTo(id2); + if (excels.get(j).getCode11() != null) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(excels.get(j).getCode11()) - v1) / (v2 - v1)); + } + Map map3 = new HashMap<>(); + map3.put("originResult", excels.get(j).getCode11()); + map3.put("value", SP); + int b = (i * 96) + j + (u * 8); + map3.put("num", "1"); + map3.put("order", b + 1); + u++; + if (Double.parseDouble(SP) >= 0.4) { + map3.put("result", "阳性"); + } else { + map3.put("result", "阴性"); + } + map2.put(a + 11, map3); + list.add(map3); + } else { + Map map3 = new HashMap<>(); + map3.put("originResult", ""); + int b = (i * 96) + j + (u * 8); + map3.put("num", ""); + map3.put("order", b + 1); + u++; + map2.put(a + 11, map3); + list.add(map3); } - }); - - int numIndex = 0; - for (Map stringObjectMap : list) { - String num = (String) stringObjectMap.get("num"); - if (num != null && !"".equals(num)) { - num = split[numIndex]; - stringObjectMap.put("num", num); - numIndex++; + if (excels.get(j).getCode12() != null) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(excels.get(j).getCode12()) - v1) / (v2 - v1)); + } + Map map3 = new HashMap<>(); + map3.put("originResult", excels.get(j).getCode12()); + map3.put("value", SP); + int b = (i * 96) + j + (u * 8); + map3.put("num", "1"); + map3.put("order", b + 1); + u++; + if (Double.parseDouble(SP) >= 0.4) { + map3.put("result", "阳性"); + } else { + map3.put("result", "阴性"); + } + map2.put(a + 12, map3); + list.add(map3); + } else { + Map map3 = new HashMap<>(); + map3.put("originResult", ""); + int b = (i * 96) + j + (u * 8); + map3.put("num", ""); + map3.put("order", b + 1); + u++; + map2.put(a + 12, map3); + list.add(map3); } + mapList.add(map2); } + map1.put("g" + (i + 1), mapList); + } - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(ExamineResult::getExamineId, examineId); - ExamineResult result = service.getOne(wrapper); - if (result != null) { - result.setOriginRecordData(JSON.toJSONString(map)); - result.setOriginRecordResult(JSON.toJSONString(map1)); - result.setExamineDataArr(JSON.toJSONString(list)); - service.updateById(result); - } else { - ExamineResult examineResult = new ExamineResult(); - examineResult.setExamineId(Long.valueOf(examineId)); - examineResult.setOriginRecordData(JSON.toJSONString(map)); - examineResult.setOriginRecordResult(JSON.toJSONString(map1)); - examineResult.setExamineDataArr(JSON.toJSONString(list)); - service.save(examineResult); + Collections.sort(list, new Comparator>() { + @Override + public int compare(Map o1, Map o2) { + Integer id1 = (Integer) o1.get("order"); + Integer id2 = (Integer) o2.get("order"); + // 升序 + return id1.compareTo(id2); } - return R.data(map1); - } catch (ArrayIndexOutOfBoundsException e) { - throw new RuntimeException("分配样品数量与检测样品数量不一致!"); + }); + + int numIndex = 0; + for (Map stringObjectMap : list) { + String num = (String) stringObjectMap.get("num"); + if (num != null && !"".equals(num)) { + num = split[numIndex]; + stringObjectMap.put("num", num); + numIndex++; + } + } + // 判断分配样品数量与检测样品数量是否一致 + if (split.length != numIndex) { + throw new Exception("分配样品数量与检测样品数量不一致!"); + } + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(ExamineResult::getExamineId, examineId); + ExamineResult result = service.getOne(wrapper); + if (result != null) { + result.setOriginRecordData(JSON.toJSONString(map)); + result.setOriginRecordResult(JSON.toJSONString(map1)); + result.setExamineDataArr(JSON.toJSONString(list)); + service.updateById(result); + } else { + ExamineResult examineResult = new ExamineResult(); + examineResult.setExamineId(Long.valueOf(examineId)); + examineResult.setOriginRecordData(JSON.toJSONString(map)); + examineResult.setOriginRecordResult(JSON.toJSONString(map1)); + examineResult.setExamineDataArr(JSON.toJSONString(list)); + service.save(examineResult); } + return R.data(map1); } /** @@ -1635,6 +1638,6 @@ public class ExamineResultController extends BladeController { */ @PostMapping("/resultPicture") public R resultPicture(@RequestParam MultipartFile file, @RequestParam String examineId) { - return R.data(service.resultPicture(file,examineId)); + return R.data(service.resultPicture(file, examineId)); } } \ No newline at end of file