|
|
@ -26,7 +26,6 @@ import digital.laboratory.platform.entrustment.dto.ResultExcelDTO; |
|
|
|
import digital.laboratory.platform.entrustment.entity.*; |
|
|
|
import digital.laboratory.platform.entrustment.entity.*; |
|
|
|
import digital.laboratory.platform.entrustment.enums.EntrustStatusConstants; |
|
|
|
import digital.laboratory.platform.entrustment.enums.EntrustStatusConstants; |
|
|
|
import digital.laboratory.platform.entrustment.mapper.EntrustMaterialCheckoutResultMapper; |
|
|
|
import digital.laboratory.platform.entrustment.mapper.EntrustMaterialCheckoutResultMapper; |
|
|
|
import digital.laboratory.platform.entrustment.mapper.EntrustmentIdentificationMaterialMapper; |
|
|
|
|
|
|
|
import digital.laboratory.platform.entrustment.query.EntrustMaterialCheckoutResultQuery; |
|
|
|
import digital.laboratory.platform.entrustment.query.EntrustMaterialCheckoutResultQuery; |
|
|
|
import digital.laboratory.platform.entrustment.service.*; |
|
|
|
import digital.laboratory.platform.entrustment.service.*; |
|
|
|
import digital.laboratory.platform.entrustment.utils.ExcelUtils; |
|
|
|
import digital.laboratory.platform.entrustment.utils.ExcelUtils; |
|
|
@ -82,9 +81,6 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private CommonFeignService commonFeignService; |
|
|
|
private CommonFeignService commonFeignService; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private EntrustmentIdentificationMaterialMapper entrustmentIdentificationMaterialMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private SuspectService suspectService; |
|
|
|
private SuspectService suspectService; |
|
|
|
|
|
|
|
|
|
|
@ -190,17 +186,23 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 根据委托id导出检出结果excel文件 |
|
|
|
* 导出可上传至禁毒大数据平台文件 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param entrustIds 委托id列表,包含需要导出的委托的id |
|
|
|
* @param excelDTO 导出参数 |
|
|
|
* @param response HttpServletResponse对象,用于将生成的excel文件写入响应中 |
|
|
|
* @param response HttpServletResponse对象,用于将生成的excel文件写入响应中 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void exportExcel(List<String> entrustIds, HttpServletResponse response) throws IOException { |
|
|
|
public void exportForBigDataPlatform(ResultExcelDTO excelDTO, HttpServletResponse response) throws IOException { |
|
|
|
// 获取委托信息
|
|
|
|
// 获取委托信息
|
|
|
|
|
|
|
|
List<String> allResults = getOriginalIdentificationList(excelDTO.getOldResult()); |
|
|
|
List<Entrustment> entrustmentList = entrustmentService.list( |
|
|
|
List<Entrustment> entrustmentList = entrustmentService.list( |
|
|
|
Wrappers.<Entrustment>lambdaQuery().in(Entrustment::getId, entrustIds) |
|
|
|
Wrappers.<Entrustment>lambdaQuery() |
|
|
|
|
|
|
|
.eq(excelDTO.getEntrustType() != null, Entrustment::getEntrustmentType, excelDTO.getEntrustType()) |
|
|
|
|
|
|
|
.in(CollUtil.isNotEmpty(allResults), Entrustment::getOldIdentificationResult, allResults) |
|
|
|
|
|
|
|
.ge(excelDTO.getStartTime() != null, Entrustment::getAcceptTime, excelDTO.getStartTime()) |
|
|
|
|
|
|
|
.le(excelDTO.getEndTime() != null, Entrustment::getAcceptTime, excelDTO.getEndTime()) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
List<String> entrustIds = entrustmentList.stream().map(Entrustment::getId).collect(Collectors.toList()); |
|
|
|
// 获取检材信息, 排序的原因是需要数据是有序的
|
|
|
|
// 获取检材信息, 排序的原因是需要数据是有序的
|
|
|
|
List<EntrustmentIdentificationMaterial> materialList = entrustmentIdentificationMaterialService.list( |
|
|
|
List<EntrustmentIdentificationMaterial> materialList = entrustmentIdentificationMaterialService.list( |
|
|
|
Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery() |
|
|
|
Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery() |
|
|
@ -251,25 +253,6 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<EntrustMaterialCheckoutResultVO> voiPage(EntrustMaterialCheckoutResultQuery query) { |
|
|
|
public IPage<EntrustMaterialCheckoutResultVO> voiPage(EntrustMaterialCheckoutResultQuery query) { |
|
|
|
// IPage<EntrustMaterialCheckoutResult> page = this.page(
|
|
|
|
|
|
|
|
// new Page<>(query.getCurrent(), query.getSize()),
|
|
|
|
|
|
|
|
// Wrappers.<EntrustMaterialCheckoutResult>lambdaQuery()
|
|
|
|
|
|
|
|
// .eq(StrUtil.isNotBlank(query.getEntrustId()), EntrustMaterialCheckoutResult::getEntrustId, query.getEntrustId())
|
|
|
|
|
|
|
|
// .orderByDesc(EntrustMaterialCheckoutResult::getUpdateTime)
|
|
|
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
// IPage<EntrustMaterialCheckoutResultVO> voPage = new Page<>();
|
|
|
|
|
|
|
|
// BeanUtils.copyProperties(page, voPage, "records");
|
|
|
|
|
|
|
|
// List<EntrustMaterialCheckoutResult> records = page.getRecords();
|
|
|
|
|
|
|
|
// if (CollUtil.isNotEmpty(records)) {
|
|
|
|
|
|
|
|
// List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterials = entrustmentIdentificationMaterialService.list(Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery().in(EntrustmentIdentificationMaterial::getId, records.stream().map(EntrustMaterialCheckoutResult::getId).collect(Collectors.toSet())));
|
|
|
|
|
|
|
|
// Map<String, EntrustmentIdentificationMaterial> materialMap = entrustmentIdentificationMaterials.stream().collect(Collectors.toMap(EntrustmentIdentificationMaterial::getId, Function.identity()));
|
|
|
|
|
|
|
|
// List<EntrustMaterialCheckoutResultVO> entrustMaterialCheckoutResultVOS = records.stream().map(record -> {
|
|
|
|
|
|
|
|
// EntrustMaterialCheckoutResultVO entrustMaterialCheckoutResultVO = EntrustMaterialCheckoutResultConvert.entityToVO(record);
|
|
|
|
|
|
|
|
// entrustMaterialCheckoutResultVO.setName(materialMap.get(record.getId()).getName());
|
|
|
|
|
|
|
|
// return entrustMaterialCheckoutResultVO;
|
|
|
|
|
|
|
|
// }).collect(Collectors.toList());
|
|
|
|
|
|
|
|
// voPage.setRecords(entrustMaterialCheckoutResultVOS);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
return baseMapper.getEntrustMaterialCheckoutResultVOPage( |
|
|
|
return baseMapper.getEntrustMaterialCheckoutResultVOPage( |
|
|
|
new Page<>(query.getCurrent(), query.getSize()), |
|
|
|
new Page<>(query.getCurrent(), query.getSize()), |
|
|
|
Wrappers.<EntrustMaterialCheckoutResultVO>query() |
|
|
|
Wrappers.<EntrustMaterialCheckoutResultVO>query() |
|
|
@ -333,8 +316,8 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
headList.add("序号"); |
|
|
|
headList.add("序号"); |
|
|
|
headList.add("送检日期"); |
|
|
|
headList.add("送检日期"); |
|
|
|
headList.add("送检单位"); |
|
|
|
headList.add("送检单位"); |
|
|
|
headList.add("检材采集地"); |
|
|
|
headList.add("检材采集地(省)"); |
|
|
|
headList.add("检材采集地"); |
|
|
|
headList.add("检材采集地(市)"); |
|
|
|
headList.add("受理编号"); |
|
|
|
headList.add("受理编号"); |
|
|
|
headList.add("检材编号"); |
|
|
|
headList.add("检材编号"); |
|
|
|
headList.add("检材类型"); |
|
|
|
headList.add("检材类型"); |
|
|
@ -379,8 +362,10 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
excelDTO.setAcceptNo(entrust.getAcceptNo()); |
|
|
|
excelDTO.setAcceptNo(entrust.getAcceptNo()); |
|
|
|
excelDTO.setOrderNo(material.getOrderNo()); |
|
|
|
excelDTO.setOrderNo(material.getOrderNo()); |
|
|
|
excelDTO.setTypeName(typeName); |
|
|
|
excelDTO.setTypeName(typeName); |
|
|
|
excelDTO.setColor(material.getColor()); |
|
|
|
String formName = material.getFormName(); |
|
|
|
excelDTO.setFormName(material.getFormName()); |
|
|
|
// 从检材性状描述中提取,因为贵阳没有填颜色, 匹配有色字的信息,例如“白色粉末”中的“白色”,否则取检材形态描述字段的值。
|
|
|
|
|
|
|
|
excelDTO.setColor(StrUtil.isBlank(material.getColor()) ? formName.substring(0, formName.indexOf("色") + 1) : material.getColor()); |
|
|
|
|
|
|
|
excelDTO.setFormName(formName); |
|
|
|
EntrustMaterialCheckoutResult entrustMaterialCheckoutResult = checkoutResultMap.get(material.getId()); |
|
|
|
EntrustMaterialCheckoutResult entrustMaterialCheckoutResult = checkoutResultMap.get(material.getId()); |
|
|
|
excelDTO.setQualitativeResult( |
|
|
|
excelDTO.setQualitativeResult( |
|
|
|
DrugLiteConvert.getDrugLites(entrustMaterialCheckoutResult.getQualitativeResult()) |
|
|
|
DrugLiteConvert.getDrugLites(entrustMaterialCheckoutResult.getQualitativeResult()) |
|
|
@ -578,18 +563,7 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
wrapper.ge(Entrustment::getAcceptTime, this.getStartTime(null)); |
|
|
|
wrapper.ge(Entrustment::getAcceptTime, this.getStartTime(null)); |
|
|
|
} |
|
|
|
} |
|
|
|
List<String> allResults = new ArrayList<>(); |
|
|
|
List<String> allResults = getOriginalIdentificationList(oldResults); |
|
|
|
for (String oldResult : oldResults) { |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(oldResult)) { |
|
|
|
|
|
|
|
if ("委托".equals(oldResult)) { |
|
|
|
|
|
|
|
allResults.add("首次鉴定"); |
|
|
|
|
|
|
|
allResults.add("补充鉴定"); |
|
|
|
|
|
|
|
allResults.add("重新鉴定"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
allResults.add(oldResult); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!allResults.isEmpty()) { |
|
|
|
if (!allResults.isEmpty()) { |
|
|
|
wrapper.in(Entrustment::getOldIdentificationResult, allResults); |
|
|
|
wrapper.in(Entrustment::getOldIdentificationResult, allResults); |
|
|
@ -682,6 +656,27 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
return entrustmentIdentificationMaterialService.sortVoByAcceptNo(voList); |
|
|
|
return entrustmentIdentificationMaterialService.sortVoByAcceptNo(voList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 根据原始鉴定结果获取所有可能的鉴定结果,包括委托、首次鉴定、补充鉴定和重新鉴定的情形。 |
|
|
|
|
|
|
|
* @param oldResults |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private List<String> getOriginalIdentificationList(List<String> oldResults) { |
|
|
|
|
|
|
|
List<String> allResults = new ArrayList<>(); |
|
|
|
|
|
|
|
for (String oldResult : oldResults) { |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(oldResult)) { |
|
|
|
|
|
|
|
if ("委托".equals(oldResult)) { |
|
|
|
|
|
|
|
allResults.add("首次鉴定"); |
|
|
|
|
|
|
|
allResults.add("补充鉴定"); |
|
|
|
|
|
|
|
allResults.add("重新鉴定"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
allResults.add(oldResult); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return allResults; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String, List<EntrustmentIdentificationMaterialVO>> getResultDataMap( |
|
|
|
public Map<String, List<EntrustmentIdentificationMaterialVO>> getResultDataMap( |
|
|
|
ResultExcelDTO excelDTO) { |
|
|
|
ResultExcelDTO excelDTO) { |
|
|
@ -701,19 +696,7 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
qw.ge(Entrustment::getAcceptTime, this.getStartTime(null)); |
|
|
|
qw.ge(Entrustment::getAcceptTime, this.getStartTime(null)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<String> allResults = new ArrayList<>(); |
|
|
|
List<String> allResults = getOriginalIdentificationList(oldResults); |
|
|
|
for (String oldResult : oldResults) { |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(oldResult)) { |
|
|
|
|
|
|
|
if ("委托".equals(oldResult)) { |
|
|
|
|
|
|
|
allResults.add("首次鉴定"); |
|
|
|
|
|
|
|
allResults.add("补充鉴定"); |
|
|
|
|
|
|
|
allResults.add("重新鉴定"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
allResults.add(oldResult); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!allResults.isEmpty()) { |
|
|
|
if (!allResults.isEmpty()) { |
|
|
|
qw.in(Entrustment::getOldIdentificationResult, allResults); |
|
|
|
qw.in(Entrustment::getOldIdentificationResult, allResults); |
|
|
|
} |
|
|
|
} |
|
|
@ -854,28 +837,41 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 导出Excel |
|
|
|
|
|
|
|
* @param response |
|
|
|
|
|
|
|
* @param excelDTO |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
* @throws IOException |
|
|
|
|
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public R getExcelByResult(HttpServletResponse response, ResultExcelDTO excelDTO) throws IOException { |
|
|
|
public R getExcelByResult(HttpServletResponse response, ResultExcelDTO excelDTO) throws IOException { |
|
|
|
// 获取查询数据
|
|
|
|
|
|
|
|
List<EntrustmentIdentificationMaterialVO> resultData = this.getResultData(excelDTO); |
|
|
|
|
|
|
|
Map<String, List<EntrustmentIdentificationMaterialVO>> resultDataMap = this.getResultDataMap(excelDTO); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocalDateTime startTime = excelDTO.getStartTime(); |
|
|
|
if (excelDTO.getExportForBigDataPlatform() != null && excelDTO.getExportForBigDataPlatform()) { |
|
|
|
LocalDateTime endTime = excelDTO.getEndTime(); |
|
|
|
// 导出可上传至禁毒大数据平台文件
|
|
|
|
Integer entrustType = excelDTO.getEntrustType(); |
|
|
|
exportForBigDataPlatform(excelDTO, response); |
|
|
|
List<String> oldResults = excelDTO.getOldResult(); |
|
|
|
} else { |
|
|
|
|
|
|
|
// 获取查询数据
|
|
|
|
|
|
|
|
List<EntrustmentIdentificationMaterialVO> resultData = this.getResultData(excelDTO); |
|
|
|
|
|
|
|
Map<String, List<EntrustmentIdentificationMaterialVO>> resultDataMap = this.getResultDataMap(excelDTO); |
|
|
|
|
|
|
|
|
|
|
|
if (resultData.isEmpty() || resultDataMap.isEmpty()) { |
|
|
|
LocalDateTime startTime = excelDTO.getStartTime(); |
|
|
|
return R.failed("没有符合条件的数据!"); |
|
|
|
LocalDateTime endTime = excelDTO.getEndTime(); |
|
|
|
} |
|
|
|
Integer entrustType = excelDTO.getEntrustType(); |
|
|
|
|
|
|
|
List<String> oldResults = excelDTO.getOldResult(); |
|
|
|
|
|
|
|
|
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
if (resultData.isEmpty() || resultDataMap.isEmpty()) { |
|
|
|
|
|
|
|
return R.failed("没有符合条件的数据!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
createDataSheet(workbook, entrustType, resultData); |
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
createStatisticsSheet(workbook, resultDataMap, oldResults, entrustType, startTime, endTime); |
|
|
|
|
|
|
|
createDrugSheets(workbook, resultDataMap, entrustType); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workbook.write(response.getOutputStream()); |
|
|
|
createDataSheet(workbook, entrustType, resultData); |
|
|
|
|
|
|
|
createStatisticsSheet(workbook, resultDataMap, oldResults, entrustType, startTime, endTime); |
|
|
|
|
|
|
|
createDrugSheets(workbook, resultDataMap, entrustType); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workbook.write(response.getOutputStream()); |
|
|
|
|
|
|
|
} |
|
|
|
return R.ok("导出成功!"); |
|
|
|
return R.ok("导出成功!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|