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

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.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<ExamineExcel> list,Integer order){
private String getCode(List<ExamineExcel> 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<Map<String, List<Map<String, Map<String, Object>>>>> ptExcelReview(
MultipartFile file,
String examineId,
Map<String,String> info, //变量对应的标版的孔位,一行行的逐渐递增
Map<String, String> info, //变量对应的标版的孔位,一行行的逐渐递增
String reg //计算公式
) throws Exception{
) throws Exception {
try {
List<ExamineExcel> read = ExcelUtil.read(file, ExamineExcel.class);
Map<String, List<ExamineExcel>> map = new HashMap<>();
@ -360,455 +363,455 @@ public class ExamineResultController extends BladeController {
* 常规Excel解析数据
*/
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);
Map<String, List<ExamineExcel>> 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<ExamineExcel> read = ExcelUtil.read(file, ExamineExcel.class);
Map<String, List<ExamineExcel>> 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<ExamineExcel> 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<ExamineExcel> 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<Map<String, Object>> list = new ArrayList<>();
// 按照公式计算实验数据并返回
Map<String, List<Map<String, Map<String, Object>>>> map1 = new HashMap<>();
for (int i = 0; i < group; i++) {
List<Map<String, Map<String, Object>>> mapList = new ArrayList<>();
List<ExamineExcel> 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<Map<String, Object>> list = new ArrayList<>();
// 按照公式计算实验数据并返回
Map<String, List<Map<String, Map<String, Object>>>> map1 = new HashMap<>();
for (int i = 0; i < group; i++) {
List<Map<String, Map<String, Object>>> mapList = new ArrayList<>();
List<ExamineExcel> 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<String, Map<String, Object>> 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<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) {
Map<String, Map<String, Object>> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<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 + 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<String, Object> 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<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 + 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<String, Object> 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<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 + 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<String, Object> 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<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 + 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<String, Object> 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<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 + 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<String, Object> 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<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 + 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<String, Object> 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<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 + 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<String, Object> 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<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 + 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<String, Object> 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<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 + 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<String, Object> 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<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 + 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<String, Object> 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<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 + 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<String, Object> 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<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 + 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<String, Object> 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<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);
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<String, Object> 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<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 + 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<String, Object> 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<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);
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<String, Object> 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<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 + 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<String, Object> 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<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);
map3.put("result", "阴性");
}
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);
}
Collections.sort(list, new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> o1, Map<String, Object> 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<String, Object> 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<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);
}
});
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 (excels.get(j).getCode12() != null) {
if ((v2 - v1) != 0) {
SP = df.format((Double.parseDouble(excels.get(j).getCode12()) - v1) / (v2 - v1));
}
Map<String, Object> 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<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<>();
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<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> o1, Map<String, Object> 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<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")
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