|
|
|
|
@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import io.swagger.models.auth.In; |
|
|
|
|
import lombok.NoArgsConstructor; |
|
|
|
|
import org.apache.commons.lang3.RandomUtils; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
@ -427,6 +428,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> |
|
|
|
|
if (simple != null) { |
|
|
|
|
resultVo.setOriginalNum(simple.getOriginalNum()); |
|
|
|
|
resultVo.setNum(simple.getExperieNum()); |
|
|
|
|
resultVo.setRecessiveNum(simple.getRecessiveNum()); |
|
|
|
|
resultVo.setIndex(i); |
|
|
|
|
resultVo.setValue(excel.getValue()); |
|
|
|
|
resultVo.setResult(excel.getResult()); |
|
|
|
|
@ -451,6 +453,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> |
|
|
|
|
resultVo.setIndex(i); |
|
|
|
|
resultVo.setValue(excel.getCtValue()); |
|
|
|
|
resultVo.setResult(excel.getValue()); |
|
|
|
|
resultVo.setRecessiveNum(simple.getRecessiveNum()); |
|
|
|
|
resultList.add(resultVo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -468,6 +471,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> |
|
|
|
|
Simple simple = simpleService.getOne(wrapper1); |
|
|
|
|
if (simple != null) { |
|
|
|
|
resultVo.setOriginalNum(simple.getOriginalNum()); |
|
|
|
|
resultVo.setRecessiveNum(simple.getRecessiveNum()); |
|
|
|
|
resultVo.setNum(simple.getExperieNum()); |
|
|
|
|
resultVo.setIndex(i); |
|
|
|
|
resultVo.setValue(excel.getCtValue()); |
|
|
|
|
@ -513,6 +517,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> |
|
|
|
|
Simple simple = simpleService.getOne(wrapper1); |
|
|
|
|
if (simple != null) { |
|
|
|
|
resultVo.setOriginalNum(simple.getOriginalNum()); |
|
|
|
|
resultVo.setRecessiveNum(simple.getRecessiveNum()); |
|
|
|
|
resultVo.setNum(simple.getExperieNum()); |
|
|
|
|
resultVo.setIndex(i); |
|
|
|
|
resultVo.setValue(excel.getValue()); |
|
|
|
|
@ -546,6 +551,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> |
|
|
|
|
Simple simple = simpleService.getOne(wrapper1); |
|
|
|
|
if (simple != null) { |
|
|
|
|
resultVo.setOriginalNum(simple.getOriginalNum()); |
|
|
|
|
resultVo.setRecessiveNum(simple.getRecessiveNum()); |
|
|
|
|
resultVo.setNum(simple.getExperieNum()); |
|
|
|
|
resultVo.setIndex(i); |
|
|
|
|
resultVo.setValue(excel.getValue()); |
|
|
|
|
@ -579,6 +585,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> |
|
|
|
|
Simple simple = simpleService.getOne(wrapper1); |
|
|
|
|
if (simple != null) { |
|
|
|
|
resultVo.setOriginalNum(simple.getOriginalNum()); |
|
|
|
|
resultVo.setRecessiveNum(simple.getRecessiveNum()); |
|
|
|
|
resultVo.setNum(simple.getExperieNum()); |
|
|
|
|
resultVo.setIndex(i); |
|
|
|
|
resultVo.setValue(excel.getValue()); |
|
|
|
|
@ -644,6 +651,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> |
|
|
|
|
Simple simple = simpleService.getOne(wrapper1); |
|
|
|
|
if (simple != null) { |
|
|
|
|
resultVo.setOriginalNum(simple.getOriginalNum()); |
|
|
|
|
resultVo.setRecessiveNum(simple.getRecessiveNum()); |
|
|
|
|
resultVo.setNum(simple.getExperieNum()); |
|
|
|
|
resultVo.setIndex(i); |
|
|
|
|
resultVo.setValue(excel.getValue()); |
|
|
|
|
@ -657,36 +665,100 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 转换可展示的list
|
|
|
|
|
List<Map<String, Object>> resultResultList = new ArrayList<>(); |
|
|
|
|
// 根据检测编号分组
|
|
|
|
|
Map<String, List<ExamineResultVo>> collect = resultList.stream().collect(Collectors.groupingBy(ExamineResultVo::getNum)); |
|
|
|
|
Set<String> keys = collect.keySet(); |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
List<Map<String, String>> tempResultList = new ArrayList<>(); |
|
|
|
|
List<Map<String, String>> resultResultList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
// 1.生成坐标(给每一个数据单元赋予坐标)
|
|
|
|
|
|
|
|
|
|
for (String key : keyList) { |
|
|
|
|
Map<String, Object> temp = new HashMap<>(); |
|
|
|
|
List<ExamineResultVo> everyExamines = collect.get(key); |
|
|
|
|
temp.put("num", key); |
|
|
|
|
temp.put("originalNum", everyExamines.get(0).getOriginalNum()); |
|
|
|
|
for (int i = 0; i < everyExamines.size(); i++) { |
|
|
|
|
ExamineResultVo everyObj = everyExamines.get(i); |
|
|
|
|
int index = everyObj.getIndex(); |
|
|
|
|
temp.put("value" + index, everyObj.getValue()); |
|
|
|
|
temp.put("result" + index, everyObj.getResult()); |
|
|
|
|
// 1.1.根据原始编号分组
|
|
|
|
|
Map<String, List<ExamineResultVo>> collect = resultList.stream().collect(Collectors.groupingBy(ExamineResultVo::getOriginalNum)); |
|
|
|
|
|
|
|
|
|
Set<String> keys = collect.keySet(); |
|
|
|
|
List<String> originalNumList = new ArrayList<>(); |
|
|
|
|
originalNumList.addAll(keys); |
|
|
|
|
// TODO 排序方式不对,现在是:1,10,11,12...,会有中文的情况
|
|
|
|
|
Collections.sort(originalNumList); |
|
|
|
|
// Collections.sort(recessiveNumList, new Comparator<String>() {
|
|
|
|
|
// @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
|
|
|
|
|
reportMainBody.put("list", resultResultList); |
|
|
|
|
reportMainBody.put("list", tempResultList); |
|
|
|
|
|
|
|
|
|
// 打印相关流操作
|
|
|
|
|
dealAboutPrintStream(response, reportMainBody, entrust, currTemplate); |
|
|
|
|
|