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

dev
litao 3 years ago
parent 54d574c464
commit 866a4992b2
  1. 23
      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,7 +363,6 @@ 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<>();
// 组数 // 组数
@ -788,6 +790,10 @@ public class ExamineResultController extends BladeController {
numIndex++; numIndex++;
} }
} }
// 判断分配样品数量与检测样品数量是否一致
if (split.length != numIndex) {
throw new Exception("分配样品数量与检测样品数量不一致!");
}
LambdaQueryWrapper<ExamineResult> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ExamineResult> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ExamineResult::getExamineId, examineId); wrapper.eq(ExamineResult::getExamineId, examineId);
@ -806,9 +812,6 @@ public class ExamineResultController extends BladeController {
service.save(examineResult); service.save(examineResult);
} }
return R.data(map1); return R.data(map1);
} catch (ArrayIndexOutOfBoundsException e) {
throw new RuntimeException("分配样品数量与检测样品数量不一致!");
}
} }
/** /**
@ -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