常规检验解析判断样品数量是否一致

dev
litao 3 years ago
parent 54d574c464
commit 866a4992b2
  1. 799
      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.springblade.lims.utils.FormulaTool;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.*; import java.util.*;
@ -94,13 +95,15 @@ public class ExamineResultController extends BladeController {
} }
} }
/** 普通Excel解析数据 review start **/ /**
* 普通Excel解析数据 review start
**/
//获取单元格的值 //获取单元格的值
private String getCode(List<ExamineExcel> list,Integer order){ private String getCode(List<ExamineExcel> list, Integer order) {
String result; String result;
ExamineExcel examineExcel = (order % 8 - 1 >= 0) ? list.get(order % 8 - 1) : list.get(list.size() - 1); ExamineExcel examineExcel = (order % 8 - 1 >= 0) ? list.get(order % 8 - 1) : list.get(list.size() - 1);
Integer re = order / 8 + 1; Integer re = order / 8 + 1;
switch (re){ switch (re) {
case 1: case 1:
result = examineExcel.getCode1(); result = examineExcel.getCode1();
break; break;
@ -146,9 +149,9 @@ public class ExamineResultController extends BladeController {
private R<Map<String, List<Map<String, Map<String, Object>>>>> ptExcelReview( private R<Map<String, List<Map<String, Map<String, Object>>>>> ptExcelReview(
MultipartFile file, MultipartFile file,
String examineId, String examineId,
Map<String,String> info, //变量对应的标版的孔位,一行行的逐渐递增 Map<String, String> info, //变量对应的标版的孔位,一行行的逐渐递增
String reg //计算公式 String reg //计算公式
) throws Exception{ ) throws Exception {
try { try {
List<ExamineExcel> read = ExcelUtil.read(file, ExamineExcel.class); List<ExamineExcel> read = ExcelUtil.read(file, ExamineExcel.class);
Map<String, List<ExamineExcel>> map = new HashMap<>(); Map<String, List<ExamineExcel>> map = new HashMap<>();
@ -360,455 +363,455 @@ public class ExamineResultController extends BladeController {
* 常规Excel解析数据 * 常规Excel解析数据
*/ */
private R<Map<String, List<Map<String, Map<String, Object>>>>> ptExcel(MultipartFile file, String examineId) throws Exception { private R<Map<String, List<Map<String, Map<String, Object>>>>> ptExcel(MultipartFile file, String examineId) throws Exception {
try { List<ExamineExcel> read = ExcelUtil.read(file, ExamineExcel.class);
List<ExamineExcel> read = ExcelUtil.read(file, ExamineExcel.class); Map<String, List<ExamineExcel>> map = new HashMap<>();
Map<String, List<ExamineExcel>> map = new HashMap<>(); // 组数
// 组数 int group = 0;
int group = 0; // 除9是否有余数
// 除9是否有余数 int size = (read.size() + 1) % 9;
int size = (read.size() + 1) % 9; if (size == 0) {
if (size == 0) { group = (read.size() + 1) / 9;
group = (read.size() + 1) / 9; } else {
} else { group = (read.size() + 1) / 9 + 1;
group = (read.size() + 1) / 9 + 1; }
}
for (int i = 0; i < group; i++) { for (int i = 0; i < group; i++) {
List<ExamineExcel> excels = new ArrayList<>(); List<ExamineExcel> excels = new ArrayList<>();
for (int j = i * 8 + i; j < (i + 1) * 8 + i; j++) { for (int j = i * 8 + i; j < (i + 1) * 8 + i; j++) {
ExamineExcel excel = read.get(j); ExamineExcel excel = read.get(j);
excels.add(excel); excels.add(excel);
}
map.put((i + 1) + "", excels);
} }
map.put((i + 1) + "", excels);
}
Examine examine = examineService.getById(examineId); Examine examine = examineService.getById(examineId);
String experieNum = examine.getExperieNum(); String experieNum = examine.getExperieNum();
String[] split = experieNum.split(","); String[] split = experieNum.split(",");
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
// 按照公式计算实验数据并返回 // 按照公式计算实验数据并返回
Map<String, List<Map<String, Map<String, Object>>>> map1 = new HashMap<>(); Map<String, List<Map<String, Map<String, Object>>>> map1 = new HashMap<>();
for (int i = 0; i < group; i++) { for (int i = 0; i < group; i++) {
List<Map<String, Map<String, Object>>> mapList = new ArrayList<>(); List<Map<String, Map<String, Object>>> mapList = new ArrayList<>();
List<ExamineExcel> excels = map.get(i + 1 + ""); List<ExamineExcel> excels = map.get(i + 1 + "");
double code1 = Double.parseDouble(excels.get(0).getCode1()); double code1 = Double.parseDouble(excels.get(0).getCode1());
double code2 = Double.parseDouble(excels.get(1).getCode1()); double code2 = Double.parseDouble(excels.get(1).getCode1());
double code3 = Double.parseDouble(excels.get(2).getCode1()); double code3 = Double.parseDouble(excels.get(2).getCode1());
double code4 = Double.parseDouble(excels.get(3).getCode1()); double code4 = Double.parseDouble(excels.get(3).getCode1());
double v1 = (code1 + code2) / 2; double v1 = (code1 + code2) / 2;
double v2 = (code3 + code4) / 2; double v2 = (code3 + code4) / 2;
DecimalFormat df = new DecimalFormat("#0.000"); DecimalFormat df = new DecimalFormat("#0.000");
for (int j = 0; j < excels.size(); j++) { for (int j = 0; j < excels.size(); j++) {
// 行标头:前端渲染需要A、B、C.... // 行标头:前端渲染需要A、B、C....
String a = String.valueOf((char) (j + 65)); String a = String.valueOf((char) (j + 65));
Map<String, Map<String, Object>> map2 = new HashMap<>(); Map<String, Map<String, Object>> map2 = new HashMap<>();
int u = 1; int u = 1;
String SP = "0.00"; String SP = "0.00";
if (j > 5) { if (j > 5) {
if (excels.get(j).getCode1() != null) { if (excels.get(j).getCode1() != null) {
if ((v2 - v1) != 0) {
SP = df.format((Double.parseDouble(excels.get(j).getCode1()) - v1) / (v2 - v1));
}
Map<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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) {
if ((v2 - v1) != 0) { 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<String, Object> map3 = new HashMap<>(); Map<String, Object> map3 = new HashMap<>();
map3.put("originResult", excels.get(j).getCode2()); map3.put("originResult", excels.get(j).getCode1());
map3.put("value", SP); map3.put("value", SP);
// int b = (i * 90) + j + 2 + (u * 8); // int b = (i * 90) + j - 6;
int b = (i * 96) + j + (u * 8); int b = (i * 96) + j;
// map3.put("num", split[b - ((i + 1) * 6)]);
map3.put("num", "1"); map3.put("num", "1");
map3.put("order", b + 1); map3.put("order", b + 1);
u++;
if (Double.parseDouble(SP) >= 0.4) { if (Double.parseDouble(SP) >= 0.4) {
map3.put("result", "阳性"); map3.put("result", "阳性");
} else { } else {
map3.put("result", "阴性"); map3.put("result", "阴性");
} }
map2.put(a + 2, map3); map2.put(a + 1, map3);
list.add(map3); list.add(map3);
} else { } else {
Map<String, Object> map3 = new HashMap<>(); Map<String, Object> map3 = new HashMap<>();
map3.put("originResult", ""); map3.put("originResult", "");
int b = (i * 96) + j + (u * 8); int b = (i * 96) + j;
map3.put("num", "");
map3.put("order", b + 1); map3.put("order", b + 1);
u++; map3.put("num", "");
map2.put(a + 2, map3); map2.put(a + 1, map3);
list.add(map3); list.add(map3);
} }
if (excels.get(j).getCode3() != null) { } else {
if ((v2 - v1) != 0) { if (excels.get(j).getCode1() != null) {
SP = df.format((Double.parseDouble(excels.get(j).getCode3()) - v1) / (v2 - v1));
}
Map<String, Object> map3 = new HashMap<>(); Map<String, Object> map3 = new HashMap<>();
map3.put("originResult", excels.get(j).getCode3()); map3.put("originResult", excels.get(j).getCode1());
map3.put("value", SP); int b = (i * 96) + j;
int b = (i * 96) + j + (u * 8);
map3.put("num", "1");
map3.put("order", b + 1); map3.put("order", b + 1);
u++; map2.put(a + 1, map3);
if (Double.parseDouble(SP) >= 0.4) {
map3.put("result", "阳性");
} else {
map3.put("result", "阴性");
}
map2.put(a + 3, map3);
list.add(map3); list.add(map3);
} else { } else {
Map<String, Object> map3 = new HashMap<>(); Map<String, Object> map3 = new HashMap<>();
map3.put("originResult", ""); map3.put("originResult", "");
int b = (i * 96) + j + (u * 8); int b = (i * 96) + j;
map3.put("num", "");
map3.put("order", b + 1); map3.put("order", b + 1);
u++; map3.put("num", "");
map2.put(a + 3, map3); map2.put(a + 1, map3);
list.add(map3); list.add(map3);
} }
if (excels.get(j).getCode4() != null) { }
if ((v2 - v1) != 0) { if (excels.get(j).getCode2() != null) {
SP = df.format((Double.parseDouble(excels.get(j).getCode4()) - v1) / (v2 - v1)); if ((v2 - v1) != 0) {
} SP = df.format((Double.parseDouble(excels.get(j).getCode2()) - v1) / (v2 - v1));
Map<String, Object> map3 = new HashMap<>(); }
map3.put("originResult", excels.get(j).getCode4()); Map<String, Object> map3 = new HashMap<>();
map3.put("value", SP); map3.put("originResult", excels.get(j).getCode2());
int b = (i * 96) + j + (u * 8); map3.put("value", SP);
map3.put("num", "1"); // int b = (i * 90) + j + 2 + (u * 8);
map3.put("order", b + 1); int b = (i * 96) + j + (u * 8);
u++; map3.put("num", "1");
if (Double.parseDouble(SP) >= 0.4) { map3.put("order", b + 1);
map3.put("result", "阳性"); u++;
} else { if (Double.parseDouble(SP) >= 0.4) {
map3.put("result", "阴性"); map3.put("result", "阳性");
}
map2.put(a + 4, map3);
list.add(map3);
} else { } else {
Map<String, Object> map3 = new HashMap<>(); map3.put("result", "阴性");
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) { map2.put(a + 2, map3);
if ((v2 - v1) != 0) { list.add(map3);
SP = df.format((Double.parseDouble(excels.get(j).getCode5()) - v1) / (v2 - v1)); } else {
} Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>(); map3.put("originResult", "");
map3.put("originResult", excels.get(j).getCode5()); int b = (i * 96) + j + (u * 8);
map3.put("value", SP); map3.put("num", "");
int b = (i * 96) + j + (u * 8); map3.put("order", b + 1);
map3.put("num", "1"); u++;
map3.put("order", b + 1); map2.put(a + 2, map3);
u++; list.add(map3);
if (Double.parseDouble(SP) >= 0.4) { }
map3.put("result", "阳性"); if (excels.get(j).getCode3() != null) {
} else { if ((v2 - v1) != 0) {
map3.put("result", "阴性"); SP = df.format((Double.parseDouble(excels.get(j).getCode3()) - v1) / (v2 - v1));
} }
map2.put(a + 5, map3); Map<String, Object> map3 = new HashMap<>();
list.add(map3); 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 { } else {
Map<String, Object> map3 = new HashMap<>(); map3.put("result", "阴性");
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) { map2.put(a + 3, map3);
if ((v2 - v1) != 0) { list.add(map3);
SP = df.format((Double.parseDouble(excels.get(j).getCode6()) - v1) / (v2 - v1)); } else {
} Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>(); map3.put("originResult", "");
map3.put("originResult", excels.get(j).getCode6()); int b = (i * 96) + j + (u * 8);
map3.put("value", SP); map3.put("num", "");
int b = (i * 96) + j + (u * 8); map3.put("order", b + 1);
map3.put("num", "1"); u++;
map3.put("order", b + 1); map2.put(a + 3, map3);
u++; list.add(map3);
if (Double.parseDouble(SP) >= 0.4) { }
map3.put("result", "阳性"); if (excels.get(j).getCode4() != null) {
} else { if ((v2 - v1) != 0) {
map3.put("result", "阴性"); SP = df.format((Double.parseDouble(excels.get(j).getCode4()) - v1) / (v2 - v1));
} }
map2.put(a + 6, map3); Map<String, Object> map3 = new HashMap<>();
list.add(map3); 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 { } else {
Map<String, Object> map3 = new HashMap<>(); map3.put("result", "阴性");
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) { map2.put(a + 4, map3);
if ((v2 - v1) != 0) { list.add(map3);
SP = df.format((Double.parseDouble(excels.get(j).getCode7()) - v1) / (v2 - v1)); } else {
} Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>(); map3.put("originResult", "");
map3.put("originResult", excels.get(j).getCode7()); int b = (i * 96) + j + (u * 8);
map3.put("value", SP); map3.put("num", "");
int b = (i * 96) + j + (u * 8); map3.put("order", b + 1);
map3.put("num", "1"); u++;
map3.put("order", b + 1); map2.put(a + 4, map3);
u++; list.add(map3);
if (Double.parseDouble(SP) >= 0.4) { }
map3.put("result", "阳性"); if (excels.get(j).getCode5() != null) {
} else { if ((v2 - v1) != 0) {
map3.put("result", "阴性"); SP = df.format((Double.parseDouble(excels.get(j).getCode5()) - v1) / (v2 - v1));
} }
map2.put(a + 7, map3); Map<String, Object> map3 = new HashMap<>();
list.add(map3); 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 { } else {
Map<String, Object> map3 = new HashMap<>(); map3.put("result", "阴性");
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) { map2.put(a + 5, map3);
if ((v2 - v1) != 0) { list.add(map3);
SP = df.format((Double.parseDouble(excels.get(j).getCode8()) - v1) / (v2 - v1)); } else {
} Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>(); map3.put("originResult", "");
map3.put("originResult", excels.get(j).getCode8()); int b = (i * 96) + j + (u * 8);
map3.put("value", SP); map3.put("num", "");
int b = (i * 96) + j + (u * 8); map3.put("order", b + 1);
map3.put("num", "1"); u++;
map3.put("order", b + 1); map2.put(a + 5, map3);
u++; list.add(map3);
if (Double.parseDouble(SP) >= 0.4) { }
map3.put("result", "阳性"); if (excels.get(j).getCode6() != null) {
} else { if ((v2 - v1) != 0) {
map3.put("result", "阴性"); SP = df.format((Double.parseDouble(excels.get(j).getCode6()) - v1) / (v2 - v1));
} }
map2.put(a + 8, map3); Map<String, Object> map3 = new HashMap<>();
list.add(map3); 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 { } else {
Map<String, Object> map3 = new HashMap<>(); map3.put("result", "阴性");
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) { map2.put(a + 6, map3);
if ((v2 - v1) != 0) { list.add(map3);
SP = df.format((Double.parseDouble(excels.get(j).getCode9()) - v1) / (v2 - v1)); } else {
} Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>(); map3.put("originResult", "");
map3.put("originResult", excels.get(j).getCode9()); int b = (i * 96) + j + (u * 8);
map3.put("value", SP); map3.put("num", "");
int b = (i * 96) + j + (u * 8); map3.put("order", b + 1);
map3.put("num", "1"); u++;
map3.put("order", b + 1); map2.put(a + 6, map3);
u++; list.add(map3);
if (Double.parseDouble(SP) >= 0.4) { }
map3.put("result", "阳性"); if (excels.get(j).getCode7() != null) {
} else { if ((v2 - v1) != 0) {
map3.put("result", "阴性"); SP = df.format((Double.parseDouble(excels.get(j).getCode7()) - v1) / (v2 - v1));
} }
map2.put(a + 9, map3); Map<String, Object> map3 = new HashMap<>();
list.add(map3); 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 { } else {
Map<String, Object> map3 = new HashMap<>(); map3.put("result", "阴性");
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) { map2.put(a + 7, map3);
if ((v2 - v1) != 0) { list.add(map3);
SP = df.format((Double.parseDouble(excels.get(j).getCode10()) - v1) / (v2 - v1)); } else {
} Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>(); map3.put("originResult", "");
map3.put("originResult", excels.get(j).getCode10()); int b = (i * 96) + j + (u * 8);
map3.put("value", SP); map3.put("num", "");
int b = (i * 96) + j + (u * 8); map3.put("order", b + 1);
map3.put("num", "1"); u++;
map3.put("order", b + 1); map2.put(a + 7, map3);
u++; list.add(map3);
if (Double.parseDouble(SP) >= 0.4) { }
map3.put("result", "阳性"); if (excels.get(j).getCode8() != null) {
} else { if ((v2 - v1) != 0) {
map3.put("result", "阴性"); SP = df.format((Double.parseDouble(excels.get(j).getCode8()) - v1) / (v2 - v1));
} }
map2.put(a + 10, map3); Map<String, Object> map3 = new HashMap<>();
list.add(map3); 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 { } else {
Map<String, Object> map3 = new HashMap<>(); map3.put("result", "阴性");
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);
} }
if (excels.get(j).getCode11() != null) { map2.put(a + 8, map3);
if ((v2 - v1) != 0) { list.add(map3);
SP = df.format((Double.parseDouble(excels.get(j).getCode11()) - v1) / (v2 - v1)); } else {
} Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>(); map3.put("originResult", "");
map3.put("originResult", excels.get(j).getCode11()); int b = (i * 96) + j + (u * 8);
map3.put("value", SP); map3.put("num", "");
int b = (i * 96) + j + (u * 8); map3.put("order", b + 1);
map3.put("num", "1"); u++;
map3.put("order", b + 1); map2.put(a + 8, map3);
u++; list.add(map3);
if (Double.parseDouble(SP) >= 0.4) { }
map3.put("result", "阳性"); if (excels.get(j).getCode9() != null) {
} else { if ((v2 - v1) != 0) {
map3.put("result", "阴性"); SP = df.format((Double.parseDouble(excels.get(j).getCode9()) - v1) / (v2 - v1));
} }
map2.put(a + 11, map3); Map<String, Object> map3 = new HashMap<>();
list.add(map3); 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 { } else {
Map<String, Object> map3 = new HashMap<>(); map3.put("result", "阴性");
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);
} }
if (excels.get(j).getCode12() != null) { map2.put(a + 9, map3);
if ((v2 - v1) != 0) { list.add(map3);
SP = df.format((Double.parseDouble(excels.get(j).getCode12()) - v1) / (v2 - v1)); } else {
} Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map3 = new HashMap<>(); map3.put("originResult", "");
map3.put("originResult", excels.get(j).getCode12()); int b = (i * 96) + j + (u * 8);
map3.put("value", SP); map3.put("num", "");
int b = (i * 96) + j + (u * 8); map3.put("order", b + 1);
map3.put("num", "1"); u++;
map3.put("order", b + 1); map2.put(a + 9, map3);
u++; list.add(map3);
if (Double.parseDouble(SP) >= 0.4) { }
map3.put("result", "阳性"); if (excels.get(j).getCode10() != null) {
} else { if ((v2 - v1) != 0) {
map3.put("result", "阴性"); SP = df.format((Double.parseDouble(excels.get(j).getCode10()) - v1) / (v2 - v1));
} }
map2.put(a + 12, map3); Map<String, Object> map3 = new HashMap<>();
list.add(map3); 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 { } else {
Map<String, Object> map3 = new HashMap<>(); map3.put("result", "阴性");
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); map2.put(a + 10, map3);
list.add(map3);
} else {
Map<String, Object> 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); if (excels.get(j).getCode11() != null) {
} if ((v2 - v1) != 0) {
SP = df.format((Double.parseDouble(excels.get(j).getCode11()) - v1) / (v2 - v1));
Collections.sort(list, new Comparator<Map<String, Object>>() { }
@Override Map<String, Object> map3 = new HashMap<>();
public int compare(Map<String, Object> o1, Map<String, Object> o2) { map3.put("originResult", excels.get(j).getCode11());
Integer id1 = (Integer) o1.get("order"); map3.put("value", SP);
Integer id2 = (Integer) o2.get("order"); int b = (i * 96) + j + (u * 8);
// 升序 map3.put("num", "1");
return id1.compareTo(id2); 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<String, Object> 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);
} }
}); if (excels.get(j).getCode12() != null) {
if ((v2 - v1) != 0) {
int numIndex = 0; SP = df.format((Double.parseDouble(excels.get(j).getCode12()) - v1) / (v2 - v1));
for (Map<String, Object> stringObjectMap : list) { }
String num = (String) stringObjectMap.get("num"); Map<String, Object> map3 = new HashMap<>();
if (num != null && !"".equals(num)) { map3.put("originResult", excels.get(j).getCode12());
num = split[numIndex]; map3.put("value", SP);
stringObjectMap.put("num", num); int b = (i * 96) + j + (u * 8);
numIndex++; 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<String, Object> 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<ExamineResult> wrapper = new LambdaQueryWrapper<>(); Collections.sort(list, new Comparator<Map<String, Object>>() {
wrapper.eq(ExamineResult::getExamineId, examineId); @Override
ExamineResult result = service.getOne(wrapper); public int compare(Map<String, Object> o1, Map<String, Object> o2) {
if (result != null) { Integer id1 = (Integer) o1.get("order");
result.setOriginRecordData(JSON.toJSONString(map)); Integer id2 = (Integer) o2.get("order");
result.setOriginRecordResult(JSON.toJSONString(map1)); // 升序
result.setExamineDataArr(JSON.toJSONString(list)); return id1.compareTo(id2);
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("分配样品数量与检测样品数量不一致!"); int numIndex = 0;
for (Map<String, Object> 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<ExamineResult> 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") @PostMapping("/resultPicture")
public R<String> resultPicture(@RequestParam MultipartFile file, @RequestParam String examineId) { public R<String> resultPicture(@RequestParam MultipartFile file, @RequestParam String examineId) {
return R.data(service.resultPicture(file,examineId)); return R.data(service.resultPicture(file, examineId));
} }
} }
Loading…
Cancel
Save