打印最终报告时附表相关操作

dev
swj 3 years ago
parent 8edffdb2dc
commit 4c7ea6a52b
  1. 7
      lab-service-api/lab-lims-api/src/main/java/org/springblade/lims/entry/ExamineResultVo.java
  2. 15
      lab-service/lab-lims/src/main/java/org/springblade/lims/controller/EntrustController.java
  3. 2
      lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineItemController.java
  4. 44
      lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineResultController.java
  5. 124
      lab-service/lab-lims/src/main/java/org/springblade/lims/service/impl/EntrustServiceImpl.java
  6. 56
      lab-service/lab-lims/src/main/java/org/springblade/lims/service/impl/ExamineResultServiceImpl.java

@ -14,6 +14,8 @@ public class ExamineResultVo extends BaseEntity implements Serializable {
private String originalNum; private String originalNum;
private String recessiveNum;
private String num; private String num;
private int index; private int index;
@ -22,4 +24,9 @@ public class ExamineResultVo extends BaseEntity implements Serializable {
private String result; private String result;
/**
* 坐标信息(2-1-3)
*/
private String pos;
} }

@ -453,6 +453,16 @@ public class EntrustController extends BladeController {
} }
return R.data(page); return R.data(page);
} }
// 待编制报告状态
if (entry != null && entry.getEntrustStatus() != null && "5".equals(entry.getEntrustStatus())) {
QueryWrapper<Entrust> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("entrust_status", "4").or();
queryWrapper.eq("entrust_status", "5").or();
queryWrapper.eq("entrust_status", "6");
query.setDescs("create_time");
IPage<Entrust> page = service.page(Condition.getPage(query), queryWrapper);
return R.data(page);
}
// 全部 // 全部
query.setDescs("create_time"); query.setDescs("create_time");
LambdaQueryWrapper<Entrust> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Entrust> queryWrapper = new LambdaQueryWrapper<>();
@ -832,6 +842,11 @@ public class EntrustController extends BladeController {
map.put("yzf", service.count(queryWrapper)); map.put("yzf", service.count(queryWrapper));
queryWrapper.clear(); queryWrapper.clear();
queryWrapper.eq("entrust_status", "5").or();
queryWrapper.eq("entrust_status", "6");
map.put("dbz", service.count(queryWrapper));
queryWrapper.clear();
// queryWrapper.eq("entrust_status", "-1"); // queryWrapper.eq("entrust_status", "-1");
// map.put("sb", service.count(queryWrapper)); // map.put("sb", service.count(queryWrapper));
// } // }

@ -181,7 +181,7 @@ public class ExamineItemController extends BladeController {
for (String s : split) { for (String s : split) {
List<Instrument> instrumentList = new ArrayList<>(); List<Instrument> instrumentList = new ArrayList<>();
Reagent reagent = reagentService.getById(s); Reagent reagent = reagentService.getById(s);
if (reagent.getInstrumentId() != null && !"".equals(reagent.getInstrumentId())) { if (reagent != null && reagent.getInstrumentId() != null && !"".equals(reagent.getInstrumentId())) {
String[] split1 = reagent.getInstrumentId().split(","); String[] split1 = reagent.getInstrumentId().split(",");
for (String s1 : split1) { for (String s1 : split1) {
Instrument instrument = instrumentService.getById(s1); Instrument instrument = instrumentService.getById(s1);

@ -99,18 +99,16 @@ public class ExamineResultController extends BladeController {
} }
/** /**
* 普通Excel解析数据 * 常规Excel解析数据
*/ */
private R<Map<String, List<Map<String, Map<String, Object>>>>> ptExcel(MultipartFile file, String examineId) { private R<Map<String, List<Map<String, Map<String, Object>>>>> ptExcel(MultipartFile file, String examineId) 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<>();
// int index = 0;
// 组数 // 组数
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 {
@ -145,31 +143,10 @@ public class ExamineResultController extends BladeController {
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++) {
String a = "";
if (j == 0) { // 行标头:前端渲染需要A、B、C....
a = "A"; String a = String.valueOf((char) (j + 65));
}
if (j == 1) {
a = "B";
}
if (j == 2) {
a = "C";
}
if (j == 3) {
a = "D";
}
if (j == 4) {
a = "E";
}
if (j == 5) {
a = "F";
}
if (j == 6) {
a = "G";
}
if (j == 7) {
a = "H";
}
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";
@ -576,6 +553,15 @@ public class ExamineResultController extends BladeController {
} }
} }
/**
* 计算常规检验的阴或阳性对照平均值
*/
private double getConventionalAvg(String i, String j) {
double v1 = Double.parseDouble(i);
double v2 = Double.parseDouble(j);
return (v1 + v2) / 2;
}
/** /**
* 布鲁氏杆菌Excel解析数据 * 布鲁氏杆菌Excel解析数据
*/ */

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.common.utils.CollectionUtils; import com.alibaba.nacos.common.utils.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.models.auth.In;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -427,6 +428,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
if (simple != null) { if (simple != null) {
resultVo.setOriginalNum(simple.getOriginalNum()); resultVo.setOriginalNum(simple.getOriginalNum());
resultVo.setNum(simple.getExperieNum()); resultVo.setNum(simple.getExperieNum());
resultVo.setRecessiveNum(simple.getRecessiveNum());
resultVo.setIndex(i); resultVo.setIndex(i);
resultVo.setValue(excel.getValue()); resultVo.setValue(excel.getValue());
resultVo.setResult(excel.getResult()); resultVo.setResult(excel.getResult());
@ -451,6 +453,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
resultVo.setIndex(i); resultVo.setIndex(i);
resultVo.setValue(excel.getCtValue()); resultVo.setValue(excel.getCtValue());
resultVo.setResult(excel.getValue()); resultVo.setResult(excel.getValue());
resultVo.setRecessiveNum(simple.getRecessiveNum());
resultList.add(resultVo); resultList.add(resultVo);
} }
} }
@ -468,6 +471,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
Simple simple = simpleService.getOne(wrapper1); Simple simple = simpleService.getOne(wrapper1);
if (simple != null) { if (simple != null) {
resultVo.setOriginalNum(simple.getOriginalNum()); resultVo.setOriginalNum(simple.getOriginalNum());
resultVo.setRecessiveNum(simple.getRecessiveNum());
resultVo.setNum(simple.getExperieNum()); resultVo.setNum(simple.getExperieNum());
resultVo.setIndex(i); resultVo.setIndex(i);
resultVo.setValue(excel.getCtValue()); resultVo.setValue(excel.getCtValue());
@ -513,6 +517,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
Simple simple = simpleService.getOne(wrapper1); Simple simple = simpleService.getOne(wrapper1);
if (simple != null) { if (simple != null) {
resultVo.setOriginalNum(simple.getOriginalNum()); resultVo.setOriginalNum(simple.getOriginalNum());
resultVo.setRecessiveNum(simple.getRecessiveNum());
resultVo.setNum(simple.getExperieNum()); resultVo.setNum(simple.getExperieNum());
resultVo.setIndex(i); resultVo.setIndex(i);
resultVo.setValue(excel.getValue()); resultVo.setValue(excel.getValue());
@ -546,6 +551,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
Simple simple = simpleService.getOne(wrapper1); Simple simple = simpleService.getOne(wrapper1);
if (simple != null) { if (simple != null) {
resultVo.setOriginalNum(simple.getOriginalNum()); resultVo.setOriginalNum(simple.getOriginalNum());
resultVo.setRecessiveNum(simple.getRecessiveNum());
resultVo.setNum(simple.getExperieNum()); resultVo.setNum(simple.getExperieNum());
resultVo.setIndex(i); resultVo.setIndex(i);
resultVo.setValue(excel.getValue()); resultVo.setValue(excel.getValue());
@ -579,6 +585,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
Simple simple = simpleService.getOne(wrapper1); Simple simple = simpleService.getOne(wrapper1);
if (simple != null) { if (simple != null) {
resultVo.setOriginalNum(simple.getOriginalNum()); resultVo.setOriginalNum(simple.getOriginalNum());
resultVo.setRecessiveNum(simple.getRecessiveNum());
resultVo.setNum(simple.getExperieNum()); resultVo.setNum(simple.getExperieNum());
resultVo.setIndex(i); resultVo.setIndex(i);
resultVo.setValue(excel.getValue()); resultVo.setValue(excel.getValue());
@ -644,6 +651,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
Simple simple = simpleService.getOne(wrapper1); Simple simple = simpleService.getOne(wrapper1);
if (simple != null) { if (simple != null) {
resultVo.setOriginalNum(simple.getOriginalNum()); resultVo.setOriginalNum(simple.getOriginalNum());
resultVo.setRecessiveNum(simple.getRecessiveNum());
resultVo.setNum(simple.getExperieNum()); resultVo.setNum(simple.getExperieNum());
resultVo.setIndex(i); resultVo.setIndex(i);
resultVo.setValue(excel.getValue()); resultVo.setValue(excel.getValue());
@ -657,36 +665,100 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
} }
} }
// 转换可展示的list // 转换可展示的list
List<Map<String, Object>> resultResultList = new ArrayList<>(); List<Map<String, String>> tempResultList = new ArrayList<>();
// 根据检测编号分组 List<Map<String, String>> resultResultList = new ArrayList<>();
Map<String, List<ExamineResultVo>> collect = resultList.stream().collect(Collectors.groupingBy(ExamineResultVo::getNum));
Set<String> keys = collect.keySet(); // 1.生成坐标(给每一个数据单元赋予坐标)
List<String> keyList = new ArrayList<>();
keyList.addAll(keys);
Collections.sort(keyList, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
Integer expirNum1 = Integer.valueOf(o1.split("-")[2]);
Integer expirNum2 = Integer.valueOf(o2.split("-")[2]);
return expirNum1 - expirNum2;
}
});
for (String key : keyList) { // 1.1.根据原始编号分组
Map<String, Object> temp = new HashMap<>(); Map<String, List<ExamineResultVo>> collect = resultList.stream().collect(Collectors.groupingBy(ExamineResultVo::getOriginalNum));
List<ExamineResultVo> everyExamines = collect.get(key);
temp.put("num", key); Set<String> keys = collect.keySet();
temp.put("originalNum", everyExamines.get(0).getOriginalNum()); List<String> originalNumList = new ArrayList<>();
for (int i = 0; i < everyExamines.size(); i++) { originalNumList.addAll(keys);
ExamineResultVo everyObj = everyExamines.get(i); // TODO 排序方式不对,现在是:1,10,11,12...,会有中文的情况
int index = everyObj.getIndex(); Collections.sort(originalNumList);
temp.put("value" + index, everyObj.getValue()); // Collections.sort(recessiveNumList, new Comparator<String>() {
temp.put("result" + index, everyObj.getResult()); // @Override
// public int compare(String o1, String o2) {
// Integer expirNum1 = Integer.valueOf(o1);
// Integer expirNum2 = Integer.valueOf(o2);
// return expirNum1 - expirNum2;
// }
// });
// 循环分组后的数据给到每个单元的的值 (例如:2-1-3)
// 定义行数
int rowCount = 0;
for (String originalNum : originalNumList) {
Map<String, String> row = new HashMap<>();
row.put("originalNum", originalNum);
rowCount ++;
List<ExamineResultVo> everyResultUnit = collect.get(originalNum);
// 对检测按照index分组
Map<Integer, List<ExamineResultVo>> voGroupByIndex = everyResultUnit.stream().collect(Collectors.groupingBy(ExamineResultVo::getIndex));
Set<Integer> indexKeys = voGroupByIndex.keySet();
List<Integer> indexList = new ArrayList<>();
indexList.addAll(indexKeys);
Collections.sort(indexList);
for (Integer index : indexList) {
// 当前每一个index对应的检验
List<ExamineResultVo> currExamResVoList = voGroupByIndex.get(index);//W-2022-1,W-2022-2
// 按照检测编号排序
Collections.sort(currExamResVoList, new Comparator<ExamineResultVo>() {
@Override
public int compare(ExamineResultVo o1, ExamineResultVo o2) {
Integer expirNum1 = Integer.valueOf(o1.getNum().split("-")[2]);
Integer expirNum2 = Integer.valueOf(o2.getNum().split("-")[2]);
return expirNum1 - expirNum2;
}
});
String num = "";
String value = "";
String result = "";
for (int i = 0; i < currExamResVoList.size(); i++) {
ExamineResultVo resultVo = currExamResVoList.get(i);
num += resultVo.getNum() + ",";
value += resultVo.getValue() + ",";
result += resultVo.getResult() + ",";
}
row.put("num" + index, num);
row.put("value" + index, value);
row.put("result" + index,result);
} }
resultResultList.add(temp); // 将每一行加入到模板循环列表
tempResultList.add(row);
// TODO 需要将 W-2022-1,W-2022-2 和原始编号在同一行的数据拆分成两行
// for (int i = 0; i < tempResultList.size(); i++) {
// Map<String, String> map = tempResultList.get(i);
// // 如果有一行里有多个检验的情况,如:W-2022-1,W-2022-2
// // TODO 不对↓
// String[] split = map.get("num1").split(",");
// if (split.length > 1) {
// // 除去原始编号、备注,再除以3,就是组数
// Set<Map.Entry<String, String>> entries = map.entrySet();
// int groups = (entries.size() - 2) / 3;
// // 得到每一组的数据
// for (int j = 1; j <= groups; j++) {
// // 每一组的在一行里的没个单元数据
// for (int y = 0; y < split.length; y++) {
//
// }
// Map<String, String> tempRow = new HashMap<>();
//
// resultResultList.add(tempRow);
// }
// } else {
// resultResultList.add(map);
// }
// }
} }
// 将附表所需list加进最终map // 将附表所需list加进最终map
reportMainBody.put("list", resultResultList); reportMainBody.put("list", tempResultList);
// 打印相关流操作 // 打印相关流操作
dealAboutPrintStream(response, reportMainBody, entrust, currTemplate); dealAboutPrintStream(response, reportMainBody, entrust, currTemplate);

@ -307,13 +307,34 @@ public class ExamineResultServiceImpl extends BaseServiceImpl<ExamineResultMappe
// 上传图片文件名 // 上传图片文件名
List<String> path = entry.getPath(); List<String> path = entry.getPath();
// 所有上传过的照片 // 所有上传过的照片
String[] split = examineResult.getPicturePath().split(","); if (examineResult.getPicturePath() != null) {
if (CollectionUtils.isNotEmpty(path)) { String[] split = examineResult.getPicturePath().split(",");
String picturePath = ""; if (CollectionUtils.isNotEmpty(path)) {
// 过滤无用照片并删除 String picturePath = "";
for (String s : split) { // 过滤无用照片并删除
boolean contains = path.contains(s); for (String s : split) {
if (!contains) { boolean contains = path.contains(s);
if (!contains) {
// 获取图片路径
String realPath1 = realPath + s;
File file = new File(realPath1);
if (file.exists()) {
file.delete();
}
}
}
if (path.size() > 1) {
for (String s : path) {
String s1 = s + ",";
picturePath += s1;
}
} else {
picturePath = path.get(0);
}
entry.setPicturePath(picturePath);
} else {
for (String s : split) {
// 获取图片路径 // 获取图片路径
String realPath1 = realPath + s; String realPath1 = realPath + s;
File file = new File(realPath1); File file = new File(realPath1);
@ -321,27 +342,8 @@ public class ExamineResultServiceImpl extends BaseServiceImpl<ExamineResultMappe
file.delete(); file.delete();
} }
} }
entry.setPicturePath("");
} }
if (path.size() > 1) {
for (String s : path) {
String s1 = s + ",";
picturePath += s1;
}
} else {
picturePath = path.get(0);
}
entry.setPicturePath(picturePath);
} else {
for (String s : split) {
// 获取图片路径
String realPath1 = realPath + s;
File file = new File(realPath1);
if (file.exists()) {
file.delete();
}
}
entry.setPicturePath("");
} }
return this.updateById(entry); return this.updateById(entry);
} }

Loading…
Cancel
Save