From 2d888dcb5225409b1270f341b0f6b960b9535802 Mon Sep 17 00:00:00 2001 From: litao Date: Mon, 24 Oct 2022 15:34:03 +0800 Subject: [PATCH] =?UTF-8?q?1.PCR=E7=B1=BB=E5=9E=8B=E7=9A=84=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E6=94=B9=E4=B8=BA=E5=9C=A8=E9=A1=B5=E9=9D=A2=E5=A1=AB?= =?UTF-8?q?=E5=86=99=E6=95=B0=E6=8D=AE=E4=B8=8A=E4=BC=A0=202.=E5=8A=A0?= =?UTF-8?q?=E4=BA=866=E4=B8=AA=E8=AF=95=E5=89=82=E5=85=AC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springblade/lims/entry/ExamineResult.java | 3 + .../controller/ExamineResultController.java | 997 ++++++++++++++---- 2 files changed, 814 insertions(+), 186 deletions(-) diff --git a/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/ExamineResult.java b/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/ExamineResult.java index 80db963..c124ef1 100644 --- a/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/ExamineResult.java +++ b/lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/ExamineResult.java @@ -162,4 +162,7 @@ public class ExamineResult extends BaseEntity implements Serializable { // 如果是口蹄疫,1单板,2多版,3非兰所 private String lansuo; + + @TableField(exist = false) + private String jsonDatas; } \ No newline at end of file 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 1ef4f3d..7db921e 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 @@ -91,9 +91,11 @@ public class ExamineResultController extends BladeController { return blsExcel(file, examineId); } else if ("3".equals(examineItem.getInputMode())) { return ktyExcel(file, examineId); - } else if ("4".equals(examineItem.getInputMode())) { - return pcrExcel(file, examineId); - } else if ("5".equals(examineItem.getInputMode())) { + } +// else if ("4".equals(examineItem.getInputMode())) { +// return pcrExcel(file, examineId); +// } + else if ("5".equals(examineItem.getInputMode())) { return xnExcel(file, examineId); } else { return ptExcel(file, examineId, reagentId); @@ -303,116 +305,688 @@ public class ExamineResultController extends BladeController { } else { mapResult.put("result", "阴性"); } - } - } else { - if (xStart <= index && index <= xEnd) { - mapResult.put("originResult", ""); + } + } else { + if (xStart <= index && index <= xEnd) { + mapResult.put("originResult", ""); + mapResult.put("num", ""); + } + } + mapResult.put("order", index + i * 96); + map2.put(a + n, mapResult); + list.add(mapResult); + mapList.add(map2); + } + 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); + } + }); + + 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++; + } + } + + 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); + } catch (ArrayIndexOutOfBoundsException e) { + throw new RuntimeException("分配样品数量与检测样品数量不一致!"); + } catch (Exception e1) { + throw new RuntimeException("算术异常,请检查实验数据!"); + } + } + /** 普通Excel解析数据 review stop **/ + + /** + * 常规Excel解析数据 + */ + private R>>>> ptExcel(MultipartFile file, String examineId, String reagentId) throws Exception { + // 判断试剂是否选了一个 + if (reagentId.split(",").length > 1) { + throw new Exception("该检验只能选择一个试剂!"); + } + + 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); + } + + Examine examine = examineService.getById(examineId); + String experieNum = examine.getExperieNum(); + String[] split = experieNum.split(","); + + List> list = new ArrayList<>(); + // 按照公式计算实验数据并返回 + Map>>> map1 = new HashMap<>(); + + // 不同试剂计算公式不同 + // 猪繁殖与呼吸综合征病毒抗体ELISA检测试剂盒---山东百邦世纪科技有限公司 + if ("1580030700969861121".equals(reagentId)) { + for (int i = 0; i < group; i++) { + DecimalFormat df = new DecimalFormat("#0.000"); + List>> mapList = new ArrayList<>(); + List excels = map.get(i + 1 + ""); + double code3 = Double.parseDouble(excels.get(2).getCode1()); + double code4 = Double.parseDouble(excels.get(3).getCode1()); + String v1 = df.format((code3 + code4) / 2 * 0.3); + String v2 = df.format((code3 + code4) / 2 * 0.25); + for (int j = 0; j < excels.size(); j++) { + // 行标头:前端渲染需要A、B、C.... + String a = String.valueOf((char) (j + 65)); + + ExamineExcel examineExcel = excels.get(j);//取到一行记录 + int filedsLength = examineExcel.getClass().getDeclaredFields().length - 1; + + Map> map2 = new HashMap<>(); + + for (int n = 1; n <= filedsLength; n++) { + String code; + switch (n) { + case 1: + code = examineExcel.getCode1(); + break; + case 2: + code = examineExcel.getCode2(); + break; + case 3: + code = examineExcel.getCode3(); + break; + case 4: + code = examineExcel.getCode4(); + break; + case 5: + code = examineExcel.getCode5(); + break; + case 6: + code = examineExcel.getCode6(); + break; + case 7: + code = examineExcel.getCode7(); + break; + case 8: + code = examineExcel.getCode8(); + break; + case 9: + code = examineExcel.getCode9(); + break; + case 10: + code = examineExcel.getCode10(); + break; + case 11: + code = examineExcel.getCode11(); + break; + case 12: + code = examineExcel.getCode12(); + break; + default: + code = "0"; + } + + Map mapResult = new HashMap<>(); + int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 + if (StringUtil.isNoneBlank(code)) { + if (j > 5 || n > 1) { + mapResult.put("originResult", code); + // 直接给原始数据值,因为没有SP值 + mapResult.put("value", code); + mapResult.put("num", "1"); + if (Double.parseDouble(code) > Double.parseDouble(v1)) { + mapResult.put("result", "阳性"); + } else if (Double.parseDouble(code) >= Double.parseDouble(v2) && Double.parseDouble(code) <= Double.parseDouble(v1)) { + mapResult.put("result", "可疑"); + } else if (Double.parseDouble(code) < Double.parseDouble(v2)) { + mapResult.put("result", "阴性"); + } + } else { + mapResult.put("originResult", code); + mapResult.put("num", ""); + } + } else { + mapResult.put("originResult", ""); + mapResult.put("num", ""); + } + mapResult.put("order", index + i * 96); + map2.put(a + n, mapResult); + list.add(mapResult); + } + mapList.add(map2); + } + map1.put("g" + (i + 1), mapList); + } + } + // 伪狂犬病毒gE蛋白lgG抗体ELISA检测试剂盒---山东百邦世纪科技有限公司 + else if ("1580733683995009026".equals(reagentId)) { + 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()); + if (code1 < 0.05) { + code1 = 0.05; + } + if (code2 < 0.05) { + code2 = 0.05; + } + double v = (code1 + code2) / 2 + 0.18; + DecimalFormat df = new DecimalFormat("#0.000"); + for (int j = 0; j < excels.size(); j++) { + // 行标头:前端渲染需要A、B、C.... + String a = String.valueOf((char) (j + 65)); + + ExamineExcel examineExcel = excels.get(j);//取到一行记录 + int filedsLength = examineExcel.getClass().getDeclaredFields().length - 1; + + Map> map2 = new HashMap<>(); + + for (int n = 1; n <= filedsLength; n++) { + String code; + switch (n) { + case 1: + code = examineExcel.getCode1(); + break; + case 2: + code = examineExcel.getCode2(); + break; + case 3: + code = examineExcel.getCode3(); + break; + case 4: + code = examineExcel.getCode4(); + break; + case 5: + code = examineExcel.getCode5(); + break; + case 6: + code = examineExcel.getCode6(); + break; + case 7: + code = examineExcel.getCode7(); + break; + case 8: + code = examineExcel.getCode8(); + break; + case 9: + code = examineExcel.getCode9(); + break; + case 10: + code = examineExcel.getCode10(); + break; + case 11: + code = examineExcel.getCode11(); + break; + case 12: + code = examineExcel.getCode12(); + break; + default: + code = "0"; + } + + Map mapResult = new HashMap<>(); + int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 + if (StringUtil.isNoneBlank(code)) { + if (j > 5 || n > 1) { + mapResult.put("originResult", code); + mapResult.put("value", code); + mapResult.put("num", "1"); + if (Double.parseDouble(code) >= v) { + mapResult.put("result", "阳性"); + } else { + mapResult.put("result", "阴性"); + } + } else { + mapResult.put("originResult", code); + mapResult.put("num", ""); + } + } else { + mapResult.put("originResult", ""); + mapResult.put("num", ""); + } + mapResult.put("order", index + i * 96); + map2.put(a + n, mapResult); + list.add(mapResult); + } + mapList.add(map2); + } + map1.put("g" + (i + 1), mapList); + } + } + // 非洲猪瘟病毒ELISA抗体检测试剂盒(哈尔滨维科生物技术有限公司) + else if ("1580730163250188290".equals(reagentId)) { + 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)); + + ExamineExcel examineExcel = excels.get(j);//取到一行记录 + int filedsLength = examineExcel.getClass().getDeclaredFields().length - 1; + + Map> map2 = new HashMap<>(); + + String SP = "0.00"; + for (int n = 1; n <= filedsLength; n++) { + String code; + switch (n) { + case 1: + code = examineExcel.getCode1(); + break; + case 2: + code = examineExcel.getCode2(); + break; + case 3: + code = examineExcel.getCode3(); + break; + case 4: + code = examineExcel.getCode4(); + break; + case 5: + code = examineExcel.getCode5(); + break; + case 6: + code = examineExcel.getCode6(); + break; + case 7: + code = examineExcel.getCode7(); + break; + case 8: + code = examineExcel.getCode8(); + break; + case 9: + code = examineExcel.getCode9(); + break; + case 10: + code = examineExcel.getCode10(); + break; + case 11: + code = examineExcel.getCode11(); + break; + case 12: + code = examineExcel.getCode12(); + break; + default: + code = "0"; + } + + Map mapResult = new HashMap<>(); + int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 + if (StringUtil.isNoneBlank(code)) { + if (j > 5 || n > 1) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(code) - v1) / (v2 - v1)); + } + mapResult.put("originResult", code); + mapResult.put("value", SP); + mapResult.put("num", "1"); + if (Double.parseDouble(SP) >= 0.2) { + mapResult.put("result", "阳性"); + } else if (Double.parseDouble(SP) < 0.1) { + mapResult.put("result", "阴性"); + } else { + mapResult.put("result", "可疑"); + } + } else { + mapResult.put("originResult", code); + mapResult.put("num", ""); + } + } else { + mapResult.put("originResult", ""); + mapResult.put("num", ""); + } + mapResult.put("order", index + i * 96); + map2.put(a + n, mapResult); + list.add(mapResult); + } + mapList.add(map2); + } + map1.put("g" + (i + 1), mapList); + } + } + // 小反刍兽疫病毒阻断ELISA抗体检测试剂盒---青岛立见生物科技有限公司 + else if ("1570666183341043714".equals(reagentId)) { + for (int i = 0; i < group; i++) { + List>> mapList = new ArrayList<>(); + List excels = map.get(i + 1 + ""); + double code1 = Double.parseDouble(excels.get(4).getCode1()); + double code2 = Double.parseDouble(excels.get(5).getCode1()); + double v1 = (code1 + code2) / 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)); + + ExamineExcel examineExcel = excels.get(j);//取到一行记录 + int filedsLength = examineExcel.getClass().getDeclaredFields().length - 1; + + Map> map2 = new HashMap<>(); + + for (int n = 1; n <= filedsLength; n++) { + String code; + switch (n) { + case 1: + code = examineExcel.getCode1(); + break; + case 2: + code = examineExcel.getCode2(); + break; + case 3: + code = examineExcel.getCode3(); + break; + case 4: + code = examineExcel.getCode4(); + break; + case 5: + code = examineExcel.getCode5(); + break; + case 6: + code = examineExcel.getCode6(); + break; + case 7: + code = examineExcel.getCode7(); + break; + case 8: + code = examineExcel.getCode8(); + break; + case 9: + code = examineExcel.getCode9(); + break; + case 10: + code = examineExcel.getCode10(); + break; + case 11: + code = examineExcel.getCode11(); + break; + case 12: + code = examineExcel.getCode12(); + break; + default: + code = "0"; + } + + Map mapResult = new HashMap<>(); + int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 + if (StringUtil.isNoneBlank(code)) { + if (j > 5 || n > 1) { + String PB = df.format(100 - Double.parseDouble(code) / v1 * 100); + mapResult.put("originResult", code); + mapResult.put("value", PB); + mapResult.put("num", "1"); + if (Double.parseDouble(PB) > 50) { + mapResult.put("result", "阳性"); + } else { + mapResult.put("result", "阴性"); + } + } else { + mapResult.put("originResult", code); + mapResult.put("num", ""); + } + } else { + mapResult.put("originResult", ""); + mapResult.put("num", ""); + } + mapResult.put("order", index + i * 96); + map2.put(a + n, mapResult); + list.add(mapResult); + } + mapList.add(map2); + } + map1.put("g" + (i + 1), mapList); + } + } + // 非洲猪瘟病毒cELISA抗体检测试剂盒 + else if ("1580815808211578882".equals(reagentId)) { + 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 v1 = (code1 + code2) / 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)); + + ExamineExcel examineExcel = excels.get(j);//取到一行记录 + int filedsLength = examineExcel.getClass().getDeclaredFields().length - 1; + + Map> map2 = new HashMap<>(); + + String PI = "0.00"; + for (int n = 1; n <= filedsLength; n++) { + String code; + switch (n) { + case 1: + code = examineExcel.getCode1(); + break; + case 2: + code = examineExcel.getCode2(); + break; + case 3: + code = examineExcel.getCode3(); + break; + case 4: + code = examineExcel.getCode4(); + break; + case 5: + code = examineExcel.getCode5(); + break; + case 6: + code = examineExcel.getCode6(); + break; + case 7: + code = examineExcel.getCode7(); + break; + case 8: + code = examineExcel.getCode8(); + break; + case 9: + code = examineExcel.getCode9(); + break; + case 10: + code = examineExcel.getCode10(); + break; + case 11: + code = examineExcel.getCode11(); + break; + case 12: + code = examineExcel.getCode12(); + break; + default: + code = "0"; + } + + Map mapResult = new HashMap<>(); + int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 + if (StringUtil.isNoneBlank(code)) { + if (j > 5 || n > 1) { + if (v1 != 0) { + PI = df.format((v1 - Double.parseDouble(code)) / v1); + } + mapResult.put("originResult", code); + mapResult.put("value", PI); + mapResult.put("num", "1"); + if (Double.parseDouble(PI) >= 0.5) { + mapResult.put("result", "阳性"); + } else { + mapResult.put("result", "阴性"); + } + } else { + mapResult.put("originResult", code); + mapResult.put("num", ""); + } + } else { + mapResult.put("originResult", ""); + mapResult.put("num", ""); + } + mapResult.put("order", index + i * 96); + map2.put(a + n, mapResult); + list.add(mapResult); + } + mapList.add(map2); + } + map1.put("g" + (i + 1), mapList); + } + } + // 非洲猪瘟病毒ELISA抗体检测试剂盒(北京金诺百泰生物技术有限公司) + else if ("1570667729797705730".equals(reagentId)) { + 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)); + + ExamineExcel examineExcel = excels.get(j);//取到一行记录 + int filedsLength = examineExcel.getClass().getDeclaredFields().length - 1; + + Map> map2 = new HashMap<>(); + + String SP = "0.00"; + for (int n = 1; n <= filedsLength; n++) { + String code; + switch (n) { + case 1: + code = examineExcel.getCode1(); + break; + case 2: + code = examineExcel.getCode2(); + break; + case 3: + code = examineExcel.getCode3(); + break; + case 4: + code = examineExcel.getCode4(); + break; + case 5: + code = examineExcel.getCode5(); + break; + case 6: + code = examineExcel.getCode6(); + break; + case 7: + code = examineExcel.getCode7(); + break; + case 8: + code = examineExcel.getCode8(); + break; + case 9: + code = examineExcel.getCode9(); + break; + case 10: + code = examineExcel.getCode10(); + break; + case 11: + code = examineExcel.getCode11(); + break; + case 12: + code = examineExcel.getCode12(); + break; + default: + code = "0"; + } + + Map mapResult = new HashMap<>(); + int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 + if (StringUtil.isNoneBlank(code)) { + if (j > 5 || n > 1) { + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(code) - v1) / (v2 - v1)); + } + mapResult.put("originResult", code); + mapResult.put("value", SP); + mapResult.put("num", "1"); + if (Double.parseDouble(SP) >= 0.4) { + mapResult.put("result", "阳性"); + } else if (Double.parseDouble(SP) <= 0.3) { + mapResult.put("result", "阴性"); + } else { + mapResult.put("result", "可疑"); + } + } else { + mapResult.put("originResult", code); mapResult.put("num", ""); } + } else { + mapResult.put("originResult", ""); + mapResult.put("num", ""); } mapResult.put("order", index + i * 96); map2.put(a + n, mapResult); list.add(mapResult); - mapList.add(map2); } - 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); - } - }); - - 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++; + 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); - } - return R.data(map1); - } catch (ArrayIndexOutOfBoundsException e) { - throw new RuntimeException("分配样品数量与检测样品数量不一致!"); - } catch (Exception e1) { - throw new RuntimeException("算术异常,请检查实验数据!"); - } - } - /** 普通Excel解析数据 review stop **/ - - /** - * 常规Excel解析数据 - */ - private R>>>> ptExcel(MultipartFile file, String examineId, String reagentId) throws Exception { - // 判断试剂是否选了一个 - if (reagentId.split(",").length > 1) { - throw new Exception("该检验只能选择一个试剂!"); - } - - 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); } - - Examine examine = examineService.getById(examineId); - String experieNum = examine.getExperieNum(); - String[] split = experieNum.split(","); - - List> list = new ArrayList<>(); - // 按照公式计算实验数据并返回 - Map>>> map1 = new HashMap<>(); - - // 不同试剂计算公式不同 - // 猪繁殖与呼吸综合征病毒抗体ELISA检测试剂盒 - if ("1580030700969861121".equals(reagentId)) { + // 猪繁殖与呼吸综合征病毒间接ELISA抗体检测试剂盒 + else if ("1582988982068027393".equals(reagentId)) { for (int i = 0; i < group; i++) { - DecimalFormat df = new DecimalFormat("#0.000"); List>> mapList = new ArrayList<>(); List excels = map.get(i + 1 + ""); double code3 = Double.parseDouble(excels.get(2).getCode1()); double code4 = Double.parseDouble(excels.get(3).getCode1()); - String v1 = df.format((code3 + code4) / 2 * 0.3); - String v2 = df.format((code3 + code4) / 2 * 0.25); + 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)); @@ -422,6 +996,7 @@ public class ExamineResultController extends BladeController { Map> map2 = new HashMap<>(); + String SP = "0.00"; for (int n = 1; n <= filedsLength; n++) { String code; switch (n) { @@ -469,15 +1044,15 @@ public class ExamineResultController extends BladeController { int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 if (StringUtil.isNoneBlank(code)) { if (j > 5 || n > 1) { + if (v2 != 0) { + SP = df.format((Double.parseDouble(code) / v2)); + } mapResult.put("originResult", code); - // 直接给原始数据值,因为没有SP值 - mapResult.put("value", code); + mapResult.put("value", SP); mapResult.put("num", "1"); - if (Double.parseDouble(code) > Double.parseDouble(v1)) { + if (Double.parseDouble(SP) >= 0.4) { mapResult.put("result", "阳性"); - } else if (Double.parseDouble(code) >= Double.parseDouble(v2) && Double.parseDouble(code) <= Double.parseDouble(v1)) { - mapResult.put("result", "可疑"); - } else if (Double.parseDouble(code) < Double.parseDouble(v2)) { + } else { mapResult.put("result", "阴性"); } } else { @@ -497,20 +1072,14 @@ public class ExamineResultController extends BladeController { map1.put("g" + (i + 1), mapList); } } - // 伪狂犬病毒gE蛋白lgG抗体ELISA检测试剂盒 - else if ("1580733683995009026".equals(reagentId)) { + // 猪瘟病毒阻断ELISA抗体检测试剂盒(武汉科前生物股份有限公司) + else if ("1570283733628678145".equals(reagentId)) { 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()); - if (code1 < 0.05) { - code1 = 0.05; - } - if (code2 < 0.05) { - code2 = 0.05; - } - double v = (code1 + code2) / 2 + 0.18; + double v1 = (code1 + code2) / 2; DecimalFormat df = new DecimalFormat("#0.000"); for (int j = 0; j < excels.size(); j++) { // 行标头:前端渲染需要A、B、C.... @@ -521,6 +1090,7 @@ public class ExamineResultController extends BladeController { Map> map2 = new HashMap<>(); + String SP = "0.00"; for (int n = 1; n <= filedsLength; n++) { String code; switch (n) { @@ -568,13 +1138,18 @@ public class ExamineResultController extends BladeController { int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 if (StringUtil.isNoneBlank(code)) { if (j > 5 || n > 1) { + if (v1 != 0) { + SP = df.format(1 - (Double.parseDouble(code) / v1)); + } mapResult.put("originResult", code); - mapResult.put("value", code); + mapResult.put("value", df.format(Double.parseDouble(SP) * 100) + "%"); mapResult.put("num", "1"); - if (Double.parseDouble(code) >= v) { + if (Double.parseDouble(SP) >= 0.4) { mapResult.put("result", "阳性"); - } else { + } else if (Double.parseDouble(SP) <= 0.3) { mapResult.put("result", "阴性"); + } else { + mapResult.put("result", "可疑"); } } else { mapResult.put("originResult", code); @@ -593,17 +1168,14 @@ public class ExamineResultController extends BladeController { map1.put("g" + (i + 1), mapList); } } - // 非洲猪瘟病毒ELISA抗体检测试剂盒(哈尔滨维科生物技术有限公司) - else if ("1580730163250188290".equals(reagentId)) { + // 猪伪狂犬病病毒gE蛋白ELISA抗体检测试剂盒(武汉科前生物股份有限公司) + else if ("1570296117147660290".equals(reagentId)) { 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.... @@ -614,7 +1186,7 @@ public class ExamineResultController extends BladeController { Map> map2 = new HashMap<>(); - String SP = "0.00"; + String SN = "0.00"; for (int n = 1; n <= filedsLength; n++) { String code; switch (n) { @@ -662,15 +1234,15 @@ public class ExamineResultController extends BladeController { int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 if (StringUtil.isNoneBlank(code)) { if (j > 5 || n > 1) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(code) - v1) / (v2 - v1)); + if (v1 != 0) { + SN = df.format(Double.parseDouble(code) / v1); } mapResult.put("originResult", code); - mapResult.put("value", SP); + mapResult.put("value", Double.parseDouble(SN)); mapResult.put("num", "1"); - if (Double.parseDouble(SP) >= 0.2) { + if (Double.parseDouble(SN) <= 0.35) { mapResult.put("result", "阳性"); - } else if (Double.parseDouble(SP) < 0.1) { + } else if (Double.parseDouble(SN) > 0.4) { mapResult.put("result", "阴性"); } else { mapResult.put("result", "可疑"); @@ -692,14 +1264,17 @@ public class ExamineResultController extends BladeController { map1.put("g" + (i + 1), mapList); } } - // 小反刍兽疫病毒阻断ELISA抗体检测试剂盒 - else if ("1570666183341043714".equals(reagentId)) { + // 猪瘟病毒间接ELISA抗体检测试剂盒---北京明日达科技发展有限责任公司 + else if ("1".equals(reagentId)) { for (int i = 0; i < group; i++) { List>> mapList = new ArrayList<>(); List excels = map.get(i + 1 + ""); - double code1 = Double.parseDouble(excels.get(4).getCode1()); - double code2 = Double.parseDouble(excels.get(5).getCode1()); + 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.... @@ -710,6 +1285,7 @@ public class ExamineResultController extends BladeController { Map> map2 = new HashMap<>(); + String SP = "0.00"; for (int n = 1; n <= filedsLength; n++) { String code; switch (n) { @@ -757,14 +1333,18 @@ public class ExamineResultController extends BladeController { int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 if (StringUtil.isNoneBlank(code)) { if (j > 5 || n > 1) { - String PB = df.format(100 - Double.parseDouble(code) / v1 * 100); + if ((v2 - v1) != 0) { + SP = df.format((Double.parseDouble(code) - v1) / (v2 - v1)); + } mapResult.put("originResult", code); - mapResult.put("value", PB); + mapResult.put("value", SP); mapResult.put("num", "1"); - if (Double.parseDouble(PB) > 50) { + if (Double.parseDouble(SP) > 0.45) { mapResult.put("result", "阳性"); - } else { + } else if (Double.parseDouble(SP) < 0.35) { mapResult.put("result", "阴性"); + } else { + mapResult.put("result", "可疑"); } } else { mapResult.put("originResult", code); @@ -783,14 +1363,17 @@ public class ExamineResultController extends BladeController { map1.put("g" + (i + 1), mapList); } } - // 非洲猪瘟病毒cELISA抗体检测试剂盒 - else if ("1580815808211578882".equals(reagentId)) { + // 猪繁殖与呼吸综合征病毒ELISA抗体检测试剂盒---武汉科前生物股份有限公司 + else if ("2".equals(reagentId)) { 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.... @@ -801,7 +1384,7 @@ public class ExamineResultController extends BladeController { Map> map2 = new HashMap<>(); - String PI = "0.00"; + String KQ = "0.00"; for (int n = 1; n <= filedsLength; n++) { String code; switch (n) { @@ -849,13 +1432,13 @@ public class ExamineResultController extends BladeController { int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 if (StringUtil.isNoneBlank(code)) { if (j > 5 || n > 1) { - if (v1 != 0) { - PI = df.format((v1 - Double.parseDouble(code)) / v1); + if (v2 != 0) { + KQ = df.format(Double.parseDouble(code) / v2 * 100); } mapResult.put("originResult", code); - mapResult.put("value", PI); + mapResult.put("value", KQ); mapResult.put("num", "1"); - if (Double.parseDouble(PI) >= 0.5) { + if (Double.parseDouble(KQ) >= 20) { mapResult.put("result", "阳性"); } else { mapResult.put("result", "阴性"); @@ -877,17 +1460,14 @@ public class ExamineResultController extends BladeController { map1.put("g" + (i + 1), mapList); } } - // 非洲猪瘟病毒ELISA抗体检测试剂盒(北京金诺百泰生物技术有限公司) - else if ("1570667729797705730".equals(reagentId)) { + // 猪伪狂犬病病毒ELISA抗体检测试剂盒---武汉科前生物股份有限公司 + else if ("3".equals(reagentId)) { 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.... @@ -898,7 +1478,7 @@ public class ExamineResultController extends BladeController { Map> map2 = new HashMap<>(); - String SP = "0.00"; + String SN = "0.00"; for (int n = 1; n <= filedsLength; n++) { String code; switch (n) { @@ -946,15 +1526,15 @@ public class ExamineResultController extends BladeController { int index = (n - 1) * 8 + j + 1; //n是列,j是行 ,我们定义index是一列列的定义 if (StringUtil.isNoneBlank(code)) { if (j > 5 || n > 1) { - if ((v2 - v1) != 0) { - SP = df.format((Double.parseDouble(code) - v1) / (v2 - v1)); + if (v1 != 0) { + SN = df.format(Double.parseDouble(code) / v1); } mapResult.put("originResult", code); - mapResult.put("value", SP); + mapResult.put("value", Double.parseDouble(SN)); mapResult.put("num", "1"); - if (Double.parseDouble(SP) >= 0.4) { + if (Double.parseDouble(SN) <= 0.6) { mapResult.put("result", "阳性"); - } else if (Double.parseDouble(SP) <= 0.3) { + } else if (Double.parseDouble(SN) > 0.7) { mapResult.put("result", "阴性"); } else { mapResult.put("result", "可疑"); @@ -976,14 +1556,14 @@ public class ExamineResultController extends BladeController { map1.put("g" + (i + 1), mapList); } } - // 猪繁殖与呼吸综合征病毒间接ELISA抗体检测试剂盒 - else if ("1582988982068027393".equals(reagentId)) { + // 牛布鲁氏菌间接ELISA抗体检测试剂盒---浙江迪恩生物科技股份有限公司 + else if ("4".equals(reagentId)) { for (int i = 0; i < group; i++) { List>> mapList = new ArrayList<>(); List excels = map.get(i + 1 + ""); - double code3 = Double.parseDouble(excels.get(2).getCode1()); - double code4 = Double.parseDouble(excels.get(3).getCode1()); - double v2 = (code3 + code4) / 2; + double code1 = Double.parseDouble(excels.get(2).getCode1()); + double code2 = Double.parseDouble(excels.get(3).getCode1()); + double v2 = (code1 + code2) / 2; DecimalFormat df = new DecimalFormat("#0.000"); for (int j = 0; j < excels.size(); j++) { // 行标头:前端渲染需要A、B、C.... @@ -1043,12 +1623,12 @@ public class ExamineResultController extends BladeController { if (StringUtil.isNoneBlank(code)) { if (j > 5 || n > 1) { if (v2 != 0) { - SP = df.format((Double.parseDouble(code) / v2)); + SP = df.format(Double.parseDouble(code) / v2); } mapResult.put("originResult", code); - mapResult.put("value", SP); + mapResult.put("value", df.format(Double.parseDouble(SP) * 100) + "%"); mapResult.put("num", "1"); - if (Double.parseDouble(SP) >= 0.4) { + if (Double.parseDouble(SP) >= 0.2) { mapResult.put("result", "阳性"); } else { mapResult.put("result", "阴性"); @@ -1070,8 +1650,8 @@ public class ExamineResultController extends BladeController { map1.put("g" + (i + 1), mapList); } } - // 猪瘟病毒阻断ELISA抗体检测试剂盒(武汉科前生物股份有限公司) - else if ("1570283733628678145".equals(reagentId)) { + // 牛布鲁氏菌竞争ELISA抗体检测试剂盒---洛阳莱普生信息科技有限公司 + else if ("5".equals(reagentId)) { for (int i = 0; i < group; i++) { List>> mapList = new ArrayList<>(); List excels = map.get(i + 1 + ""); @@ -1088,7 +1668,7 @@ public class ExamineResultController extends BladeController { Map> map2 = new HashMap<>(); - String SP = "0.00"; + String SN = "0.00"; for (int n = 1; n <= filedsLength; n++) { String code; switch (n) { @@ -1137,17 +1717,15 @@ public class ExamineResultController extends BladeController { if (StringUtil.isNoneBlank(code)) { if (j > 5 || n > 1) { if (v1 != 0) { - SP = df.format(1 - (Double.parseDouble(code) / v1)); + SN = df.format(Double.parseDouble(code) / v1); } mapResult.put("originResult", code); - mapResult.put("value", df.format(Double.parseDouble(SP) * 100) + "%"); + mapResult.put("value", Double.parseDouble(SN)); mapResult.put("num", "1"); - if (Double.parseDouble(SP) >= 0.4) { + if (Double.parseDouble(SN) < 0.5) { mapResult.put("result", "阳性"); - } else if (Double.parseDouble(SP) <= 0.3) { - mapResult.put("result", "阴性"); } else { - mapResult.put("result", "可疑"); + mapResult.put("result", "阴性"); } } else { mapResult.put("originResult", code); @@ -1166,8 +1744,8 @@ public class ExamineResultController extends BladeController { map1.put("g" + (i + 1), mapList); } } - // 猪伪狂犬病病毒gE蛋白ELISA抗体检测试剂盒(武汉科前生物股份有限公司) - else if ("1570296117147660290".equals(reagentId)) { + // 口蹄疫病毒非结构蛋白3ABC阻断ELISA抗体检测试剂盒---兰州兽研生物科技有限公司 + else if ("6".equals(reagentId)) { for (int i = 0; i < group; i++) { List>> mapList = new ArrayList<>(); List excels = map.get(i + 1 + ""); @@ -1184,7 +1762,7 @@ public class ExamineResultController extends BladeController { Map> map2 = new HashMap<>(); - String SN = "0.00"; + String PI = "0.00"; for (int n = 1; n <= filedsLength; n++) { String code; switch (n) { @@ -1233,17 +1811,15 @@ public class ExamineResultController extends BladeController { if (StringUtil.isNoneBlank(code)) { if (j > 5 || n > 1) { if (v1 != 0) { - SN = df.format(Double.parseDouble(code) / v1); + PI = df.format((v1 - Double.parseDouble(code)) / v1); } mapResult.put("originResult", code); - mapResult.put("value", Double.parseDouble(SN)); + mapResult.put("value", df.format(Double.parseDouble(PI) * 100) + "%"); mapResult.put("num", "1"); - if (Double.parseDouble(SN) <= 0.35) { + if (Double.parseDouble(PI) >= 0.5) { mapResult.put("result", "阳性"); - } else if (Double.parseDouble(SN) > 0.4) { - mapResult.put("result", "阴性"); } else { - mapResult.put("result", "可疑"); + mapResult.put("result", "阴性"); } } else { mapResult.put("originResult", code); @@ -1264,7 +1840,6 @@ public class ExamineResultController extends BladeController { } - // for (int i = 0; i < group; i++) { // List>> mapList = new ArrayList<>(); // List excels = map.get(i + 1 + ""); @@ -3394,8 +3969,58 @@ public class ExamineResultController extends BladeController { /** * PCRExcel解析数据 */ - private R pcrExcel(MultipartFile file, String examineId) { - List read = ExcelUtil.read(file, PCR2Excel.class); +// private R pcrExcel(MultipartFile file, String examineId) { +// List read = ExcelUtil.read(file, PCR2Excel.class); +// if (read != null && read.size() > 0) { +// for (int i = 0; i < read.size(); i++) { +// String ctValue = read.get(i).getCtValue(); +// String length = ""; +// if (ctValue != null && !"".equals(ctValue)) { +// int length1 = 10 - ctValue.length(); +// for (int i1 = 0; i1 < length1; i1++) { +// length += " "; +// } +// } +// +// if (i == (read.size() - 1)) { +// read.get(i).setCtValue(length + ctValue); +// read.get(i).setResult(" 阳 性"); +// } else if (i == (read.size() - 2)) { +// read.get(i).setCtValue("/"); +// read.get(i).setResult("阴 性"); +// } else { +// if ("".equals(read.get(i).getCtValue()) || read.get(i).getCtValue() == null) { +// read.get(i).setCtValue("/"); +// read.get(i).setResult("阴性"); +// } else { +// read.get(i).setCtValue(length + ctValue); +// read.get(i).setResult(" 阳性"); +// } +// } +// } +// LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); +// wrapper.eq(ExamineResult::getExamineId, examineId); +// ExamineResult result = service.getOne(wrapper); +// if (result != null) { +// result.setOriginRecordData(JSON.toJSONString(read)); +// result.setOriginRecordResult(JSON.toJSONString(read)); +// result.setExamineDataArr(JSON.toJSONString(read)); +// service.updateById(result); +// } else { +// ExamineResult examineResult = new ExamineResult(); +// examineResult.setExamineId(Long.valueOf(examineId)); +// examineResult.setOriginRecordData(JSON.toJSONString(read)); +// examineResult.setOriginRecordResult(JSON.toJSONString(read)); +// examineResult.setExamineDataArr(JSON.toJSONString(read)); +// service.save(examineResult); +// } +// } +// return R.data(read); +// } + + @PostMapping("/pcrExcel") + public R pcrExcel(@RequestBody ExamineResult entry) { + List read = JSON.parseArray(entry.getJsonDatas(), PCR2Excel.class); if (read != null && read.size() > 0) { for (int i = 0; i < read.size(); i++) { String ctValue = read.get(i).getCtValue(); @@ -3414,17 +4039,17 @@ public class ExamineResultController extends BladeController { read.get(i).setCtValue("/"); read.get(i).setResult("阴 性"); } else { - if ("".equals(read.get(i).getCtValue()) || read.get(i).getCtValue() == null) { + if ("".equals(read.get(i).getCtValue()) || "/".equals(read.get(i).getCtValue()) || read.get(i).getCtValue() == null) { read.get(i).setCtValue("/"); read.get(i).setResult("阴性"); } else { read.get(i).setCtValue(length + ctValue); - read.get(i).setResult(" 阳性"); + read.get(i).setResult(" 阳性"); } } } LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(ExamineResult::getExamineId, examineId); + wrapper.eq(ExamineResult::getExamineId, entry.getExamineId().toString()); ExamineResult result = service.getOne(wrapper); if (result != null) { result.setOriginRecordData(JSON.toJSONString(read)); @@ -3433,7 +4058,7 @@ public class ExamineResultController extends BladeController { service.updateById(result); } else { ExamineResult examineResult = new ExamineResult(); - examineResult.setExamineId(Long.valueOf(examineId)); + examineResult.setExamineId(Long.valueOf(entry.getExamineId())); examineResult.setOriginRecordData(JSON.toJSONString(read)); examineResult.setOriginRecordResult(JSON.toJSONString(read)); examineResult.setExamineDataArr(JSON.toJSONString(read));