|
|
|
@ -3,6 +3,7 @@ package digital.laboratory.platform.entrustment.service.impl; |
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
@ -38,6 +39,7 @@ import org.apache.poi.ss.util.CellRangeAddress; |
|
|
|
|
import org.apache.poi.xssf.usermodel.*; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import springfox.documentation.spring.web.json.Json; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
@ -542,6 +544,7 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
|
LocalDateTime endTime = excelDTO.getEndTime(); |
|
|
|
|
List<String> oldResults = excelDTO.getOldResult(); |
|
|
|
|
Integer entrustType = excelDTO.getEntrustType(); |
|
|
|
|
|
|
|
|
|
// 创建查询条件包装器
|
|
|
|
|
LambdaQueryWrapper<Entrustment> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
|
|
|
@ -611,6 +614,18 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
|
.in(EntrustMaterialCheckoutResult::getId, materialIds) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
Boolean isMetabolite = excelDTO.getIsMetabolite(); |
|
|
|
|
|
|
|
|
|
if (isMetabolite) { |
|
|
|
|
resultList.forEach(result -> { |
|
|
|
|
if (StringUtils.isNotBlank(result.getMetaboliteResult())) { |
|
|
|
|
List<DrugLite> drugLites = DrugLiteConvert.getDrugLites(result.getMetaboliteResult()); |
|
|
|
|
List<DrugLite> drugLites1 = DrugLiteConvert.getDrugLites(result.getQualitativeResult()); |
|
|
|
|
drugLites.addAll(drugLites1); |
|
|
|
|
result.setQualitativeResult(JSONArray.toJSONString(drugLites)); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
// 将检测结果转换为 Map
|
|
|
|
|
Map<String, EntrustMaterialCheckoutResult> resultMap = resultList.stream() |
|
|
|
|
.collect(Collectors.toMap(EntrustMaterialCheckoutResult::getId, Function.identity())); |
|
|
|
@ -651,7 +666,7 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
|
LocalDateTime endTime = excelDTO.getEndTime(); |
|
|
|
|
List<String> oldResults = excelDTO.getOldResult(); |
|
|
|
|
Integer entrustType = excelDTO.getEntrustType(); |
|
|
|
|
boolean metabolite = excelDTO.isMetabolite(); |
|
|
|
|
boolean isMetabolite = excelDTO.getIsMetabolite(); |
|
|
|
|
try { |
|
|
|
|
// 1. 构建查询条件
|
|
|
|
|
LambdaQueryWrapper<Entrustment> qw = new LambdaQueryWrapper<>(); |
|
|
|
@ -712,6 +727,14 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
|
for (DrugLite drugLite : drugLites) { |
|
|
|
|
drugNames.add(drugLite.getName()); |
|
|
|
|
} |
|
|
|
|
if (isMetabolite && StringUtils.isNotBlank(result.getMetaboliteResult())) { |
|
|
|
|
List<DrugLite> drugLites1 = DrugLiteConvert.getDrugLites(result.getMetaboliteResult()); |
|
|
|
|
for (DrugLite drugLite : drugLites1) { |
|
|
|
|
if (!drugNames.contains(drugLite.getName())) { |
|
|
|
|
drugNames.add(drugLite.getName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 5. 处理不同毒品名称的数据
|
|
|
|
@ -720,13 +743,27 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
|
for (String drugName : drugNames) { |
|
|
|
|
// 5.1 查询所有含有该毒品的检验结果
|
|
|
|
|
List<EntrustMaterialCheckoutResult> resultList = this.list(Wrappers.<EntrustMaterialCheckoutResult>lambdaQuery() |
|
|
|
|
.like(EntrustMaterialCheckoutResult::getQualitativeResult, drugName) |
|
|
|
|
.and(queryWrapper -> queryWrapper |
|
|
|
|
.like(EntrustMaterialCheckoutResult::getMetaboliteResult, drugName) |
|
|
|
|
.or() |
|
|
|
|
.like(EntrustMaterialCheckoutResult::getQualitativeResult, drugName)) |
|
|
|
|
.in(EntrustMaterialCheckoutResult::getEntrustId, entrustIdList)); |
|
|
|
|
|
|
|
|
|
if (resultList.isEmpty()) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isMetabolite) { |
|
|
|
|
resultList.forEach(item -> { |
|
|
|
|
if (StringUtils.isNotBlank(item.getMetaboliteResult())) { |
|
|
|
|
List<DrugLite> drugLites = DrugLiteConvert.getDrugLites(item.getMetaboliteResult()); |
|
|
|
|
List<DrugLite> drugLites1 = DrugLiteConvert.getDrugLites(item.getQualitativeResult()); |
|
|
|
|
drugLites.addAll(drugLites1); |
|
|
|
|
item.setQualitativeResult(JSONArray.toJSONString(drugLites)); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 转换为 Map,方便后续查找
|
|
|
|
|
Map<String, EntrustMaterialCheckoutResult> checkoutResultMap = resultList.stream() |
|
|
|
|
.collect(Collectors.toMap(EntrustMaterialCheckoutResult::getId, Function.identity())); |
|
|
|
@ -1733,7 +1770,7 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
|
Integer val = entry.getValue().get(i - 1); |
|
|
|
|
if (val != null && val != 0) { |
|
|
|
|
cell.setCellValue(val); |
|
|
|
|
ints[i-1] += entry.getValue().get(i - 1); |
|
|
|
|
ints[i - 1] += entry.getValue().get(i - 1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1756,10 +1793,10 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
|
|
|
|
|
|
rowIndex += 2; |
|
|
|
|
} |
|
|
|
|
XSSFRow lastRow = sheet.createRow(rowIndex-1); |
|
|
|
|
XSSFRow lastRow = sheet.createRow(rowIndex - 1); |
|
|
|
|
lastRow.setHeight((short) (14.25 * 20)); |
|
|
|
|
for (int i = 0; i < nameRows.length; i++) { |
|
|
|
|
if (i == 0){ |
|
|
|
|
if (i == 0) { |
|
|
|
|
Cell cell = lastRow.createCell(i); |
|
|
|
|
cell.setCellStyle(blackStyle); |
|
|
|
|
} |
|
|
|
|