Merge branch 'master' of http://222.85.191.97:5000/Dlp-Gyjd/dlp-entrustment
# Conflicts: # src/main/java/digital/laboratory/platform/entrustment/service/impl/ExcelOperationServiceImpl.java
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
//package digital.laboratory.platform.entrustment.config;
|
||||
//
|
||||
//import digital.laboratory.platform.entrustment.enums.EntrustEvent;
|
||||
//import digital.laboratory.platform.entrustment.enums.EntrustStatusConstants;
|
||||
//import org.springframework.beans.factory.annotation.Value;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
|
||||
//import org.springframework.statemachine.config.builders.StateMachineStateConfigurer;
|
||||
//
|
||||
///**
|
||||
// * @author ChenJiangBao
|
||||
// * @version 1.0
|
||||
// * @description: 委托状态机配置类
|
||||
// * @date 2025/3/14 11:47
|
||||
// */
|
||||
//@Configuration
|
||||
//public class EntrustStateMachineConfig extends EnumStateMachineConfigurerAdapter<EntrustStatusConstants, EntrustEvent> {
|
||||
//
|
||||
// @Value("${dlp.entrustment.isApprovalRequired}")
|
||||
// private boolean isApprovalRequired; // 动态标志判断是否需要审批
|
||||
//
|
||||
// @Override
|
||||
// public void configure(StateMachineStateConfigurer<EntrustStatusConstants, EntrustEvent> states) throws Exception {
|
||||
// states.withStates()
|
||||
// .initial(EntrustStatusConstants.ENTRUST_STATUS_CREATED)
|
||||
// .state(EntrustStatusConstants.ENTRUST_STATUS_WAITING_CHECK_CLAIM)
|
||||
// .state(EntrustStatusConstants.ENTRUST_STATUS_WAITING_CHECK)
|
||||
// .state(EntrustStatusConstants.ENTRUST_STATUS_WAITING_CONFIRM)
|
||||
// .state(EntrustStatusConstants.ENTRUST_STATUS_WAITING_DELIVER)
|
||||
// .state(EntrustStatusConstants.ENTRUST_STATUS_WAITING_ACCEPT)
|
||||
// .state(EntrustStatusConstants.ENTRUST_STATUS_ACCEPTED)
|
||||
// .state(EntrustStatusConstants.ENTRUST_STATUS_TEST_FINISH)
|
||||
// .state(EntrustStatusConstants.ENTRUST_STATUS_COMPLETED)
|
||||
// .state(EntrustStatusConstants.ENTRUST_STATUS_TERMINATED)
|
||||
// .state(EntrustStatusConstants.ENTRUST_STATUS_ABORTED)
|
||||
// .end(EntrustStatusConstants.ENTRUST_STATUS_COMPLETED);
|
||||
// }
|
||||
//}
|
||||
@@ -1,71 +0,0 @@
|
||||
package digital.laboratory.platform.entrustment.config;
|
||||
|
||||
import digital.laboratory.platform.common.core.util.R;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Spring Boot 自定义异常处理
|
||||
* 所有的异常都派生自 Exception, 如果我们定义了某个异常的处理 Handler, Spring Boot 会调用用对应的异常 Handler, 否则会调用 Exception Handler.
|
||||
* 有一个前提是在 application.yml 中定义两个属性, 让 springboot 在没有找到 url 的处理器触发异常; 让 springboot 不要自作多情加 /error 这个 map
|
||||
* mvc:
|
||||
* throw-exception-if-no-handler-found: true
|
||||
* web:
|
||||
* resources:
|
||||
* add-mappings: false
|
||||
* 只有如此, springboot 才会触发异常。
|
||||
*/
|
||||
|
||||
|
||||
@ControllerAdvice
|
||||
public class ErrorController {
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseBody
|
||||
public ResponseEntity error(Exception ex) {
|
||||
System.out.println("ErrorController.error Exception");
|
||||
ex.printStackTrace();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("Exception", ex.getClass().getName());
|
||||
map.put("message", ex.getMessage());
|
||||
map.put("localizedMessage", ex.getLocalizedMessage());
|
||||
map.put("toString", ex.toString());
|
||||
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(R.failed(map, "发生异常 " + ex.getMessage()));
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler(value = {NoHandlerFoundException.class})
|
||||
@ResponseBody
|
||||
public ResponseEntity error(NoHandlerFoundException ex) {
|
||||
//System.out.println("ErrorController.error NoHandlerFoundException");
|
||||
//ex.printStackTrace();
|
||||
// //ex.getRawStatusCode()
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("Exception", ex.getClass().getName());
|
||||
map.put("message", ex.getMessage());
|
||||
map.put("localizedMessage", ex.getLocalizedMessage());
|
||||
map.put("requestURL", ex.getRequestURL());
|
||||
map.put("httpMethod", ex.getHttpMethod());
|
||||
// map.put("cause", ex.getCause().toString());
|
||||
map.put("toString", ex.toString());
|
||||
// map.put("comments", "单独的 ExceptionHandler, 系统管理捕获的全局异常 NoHandlerFoundException");
|
||||
// //return map;
|
||||
// //ResponseEntity<Map<String,Object>> r = new ResponseEntity<Map<String,Object>>(map, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
// //ResponseEntity<Map<String,Object>> r = new ResponseEntity<Map<String,Object>>(map, HttpStatus.NOT_FOUND);
|
||||
// //return r;
|
||||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(map);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(R.failed(map, "没有找到"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package digital.laboratory.platform.entrustment.constant;
|
||||
/**
|
||||
* 统计的各个中文名称常量接口
|
||||
*/
|
||||
public interface EntrustMarkConstants {
|
||||
public interface EntrustConstants {
|
||||
|
||||
String CASE_ACCEPT = "案件受理";
|
||||
|
||||
@@ -19,6 +19,4 @@ public interface EntrustMarkConstants {
|
||||
Integer LOCAL_SYSTEM = 0; // 本系统数据
|
||||
|
||||
Integer THIRD_PARTY_SYSTEM = 1; // 大数据平台同步过来的数据
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package digital.laboratory.platform.entrustment.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.laboratory.platform.common.core.exception.CheckedException;
|
||||
@@ -11,11 +10,9 @@ import digital.laboratory.platform.entrustment.convert.EntrustMaterialCheckoutRe
|
||||
import digital.laboratory.platform.entrustment.dto.EntrustMaterialCheckoutResultDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.GenerateQuarterlyReportDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.ResultExcelDTO;
|
||||
import digital.laboratory.platform.entrustment.query.BaseQuery;
|
||||
import digital.laboratory.platform.entrustment.query.EntrustMaterialCheckoutResultQuery;
|
||||
import digital.laboratory.platform.entrustment.service.EntrustMaterialCheckoutResultService;
|
||||
import digital.laboratory.platform.entrustment.vo.EntrustMaterialCheckoutResultVO;
|
||||
import digital.laboratory.platform.entrustment.vo.EntrustmentIdentificationMaterialVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -26,11 +23,8 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.sql.Array;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 委托检材--检出定性定量结果信息
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.laboratory.platform.common.aop.annotation.DlpAccessLimit;
|
||||
import digital.laboratory.platform.common.aop.annotation.DlpRepeatSubmit;
|
||||
import digital.laboratory.platform.common.core.constant.OSSDirectoryConstants;
|
||||
import digital.laboratory.platform.common.core.exception.CheckedException;
|
||||
@@ -21,7 +20,6 @@ import digital.laboratory.platform.common.oss.service.OssFile;
|
||||
import digital.laboratory.platform.common.security.annotation.Inner;
|
||||
import digital.laboratory.platform.common.security.util.SecurityUtils;
|
||||
import digital.laboratory.platform.entrustment.dto.EntrustmentDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.MaterialDTO;
|
||||
import digital.laboratory.platform.entrustment.entity.CaseEvent;
|
||||
import digital.laboratory.platform.entrustment.entity.Entrustment;
|
||||
import digital.laboratory.platform.entrustment.enums.EntrustStatusConstants;
|
||||
@@ -2197,53 +2195,6 @@ public class EntrustmentController {
|
||||
return R.ok(entrustmentService.updateImportData(excuteType));
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// 测试, 为现有的案件创建一些委托
|
||||
@GetMapping("/create100")
|
||||
public R xxx_TestCreate100() {
|
||||
List<CaseEventVO> cjs = caseEventService.getCaseVoList(null, null, null, null);
|
||||
for (CaseEvent cj : cjs) {
|
||||
int num = RandomUtil.randomInt(1, 4);
|
||||
for (int i = 0; i < num; i++) {
|
||||
List<Entrustment> ces = entrustmentService.list(Wrappers.<Entrustment>query()
|
||||
.eq("case_id", cj.getId()));
|
||||
|
||||
if (ces.size() >= num) {
|
||||
break;
|
||||
}
|
||||
Entrustment entrustment = new Entrustment();
|
||||
|
||||
entrustment.setCaseId(cj.getId());
|
||||
//entrustment.setEntrustmentNo(entrustmentService.getNewEntrustmentNo(cj.getCaseNo()));
|
||||
entrustment.setEntrustmentNo(entrustmentService.getNewEntrustmentNo());
|
||||
//entrustment.setEntrustmentTime(LocalDateTime.now());
|
||||
entrustment.setClientOrgId("");
|
||||
//entrustment.setClientOrgName("");
|
||||
entrustment.setDeliverer1Name("李宏亮");
|
||||
entrustment.setDeliverer1Phone("13985001001");
|
||||
entrustment.setDeliverer1Id("522122199504042035");
|
||||
entrustment.setDeliverer2Name("西门吹雪");
|
||||
entrustment.setDeliverer2Phone("13985001002");
|
||||
entrustment.setDeliverer2Id("522122190504042031");
|
||||
|
||||
//entrustment.setIdentificationOrgName("国家毒品实验室陕西分中心"); // 鉴定机构名称
|
||||
entrustment.setIdentificationDomain("毒品检验"); // 鉴定专业
|
||||
entrustment.setQualitativeAnalysis(true); // 定性分析
|
||||
entrustment.setQuantitativeAnalysis(true); // 定量分析
|
||||
entrustment.setOtherIdentificationRequests("无"); // 鉴定要求
|
||||
entrustment.setId(IdWorker.get32UUID().toUpperCase());
|
||||
|
||||
if (entrustmentService.save(entrustment)) {
|
||||
System.out.println("新增委托成功");
|
||||
} else {
|
||||
System.out.println("新增委托失败");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return R.ok("已经为每个案件创建了 一些 委托");
|
||||
}
|
||||
|
||||
@GetMapping("/get/quantity/for/Inspection")
|
||||
@ApiOperation(value = "送检系统统计当前用户(机构)送检且已受理的所有检材数量", notes = "送检系统统计当前用户(机构)送检且已受理的所有检材数量")
|
||||
public R<List<MarkersVO>> getQuantityForInspection(HttpServletRequest httpServletRequest) {
|
||||
|
||||
@@ -4,9 +4,6 @@ import digital.laboratory.platform.common.core.util.R;
|
||||
import digital.laboratory.platform.entrustment.service.ExcelOperationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -28,6 +25,17 @@ public class ExcelOperationController {
|
||||
@Resource
|
||||
private ExcelOperationService excelOperationService;
|
||||
|
||||
@ApiOperation("检材信息导入接口")
|
||||
@PostMapping("/importMaterialInfo")
|
||||
public R importMaterialInfo(@RequestPart("file") MultipartFile file, @RequestParam("entrustId") String entrustId) {
|
||||
try {
|
||||
return excelOperationService.importMaterialInfo(file, entrustId) ? R.ok("检材信息导入成功!") : R.failed("检材信息导入失败!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return R.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("上传两社人员名单excel文件")
|
||||
@PostMapping("/uploadHairInspect")
|
||||
public R<Boolean> uploadHairInspectExcel(@RequestPart("file") MultipartFile file, @RequestParam("entrustId") String entrustId) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
@@ -27,6 +27,10 @@ public class DrugLiteConvert {
|
||||
}
|
||||
|
||||
public static List<DrugLite> getDrugLites(String drugToString) {
|
||||
// 判断参数是否为空
|
||||
if (drugToString == null || drugToString.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<DrugLite> drugLiteList = JSONArray.parseArray(drugToString, DrugLite.class).stream().sorted(Comparator.comparing(DrugLite::getName)).collect(Collectors.toList());
|
||||
return drugLiteList;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package digital.laboratory.platform.entrustment.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class GenerateQuarterlyReportDTO {
|
||||
|
||||
@@ -1,20 +1,31 @@
|
||||
package digital.laboratory.platform.entrustment.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class
|
||||
@ApiModel(value = "ResultExcelDTO对象", description = "导出检材信息excel的参数")
|
||||
public class ResultExcelDTO {
|
||||
|
||||
@ApiModelProperty(value = "委托类型")
|
||||
private Integer entrustType;
|
||||
|
||||
@ApiModelProperty(value = "鉴定情况")
|
||||
private List<String> oldResult;
|
||||
|
||||
@ApiModelProperty(value = "开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
ResultExcelDTO {
|
||||
Integer entrustType;
|
||||
List<String> oldResult;
|
||||
LocalDateTime startTime;
|
||||
LocalDateTime endTime;
|
||||
Boolean isMetabolite;
|
||||
@ApiModelProperty(value = "结束时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@ApiModelProperty(value = "是否代谢物")
|
||||
private Boolean isMetabolite;
|
||||
|
||||
@ApiModelProperty(value = "是否导出可上传至禁毒大数据平台文件")
|
||||
private Boolean exportForBigDataPlatform;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class EntrustMaterialCheckoutResult extends BaseEntity {
|
||||
private String qualitativeResult;
|
||||
|
||||
/**
|
||||
* 定量结果
|
||||
* 定量结果,多个则是通过 、分隔
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String quantitativeResult;
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -46,4 +46,14 @@ public enum AnalysisOptionEnums {
|
||||
}
|
||||
throw new IllegalArgumentException("No enum constant with code: " + code);
|
||||
}
|
||||
|
||||
// 根据描述获取枚举值
|
||||
public static AnalysisOptionEnums fromDesc(String desc) {
|
||||
for (AnalysisOptionEnums analysisOption : values()) {
|
||||
if (analysisOption.getChineseName().equals(desc)) {
|
||||
return analysisOption;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No enum constant with description: " + desc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package digital.laboratory.platform.entrustment.enums;
|
||||
|
||||
/**
|
||||
* @author ChenJiangBao
|
||||
* @version 1.0
|
||||
* @description: 委托事件枚举
|
||||
* @date 2025/3/14 16:11
|
||||
*/
|
||||
public enum EntrustEvent {
|
||||
SUBMIT, // 提交委托事件
|
||||
CLAIM_CHECK, // 认领审核
|
||||
APPROVE, // 审批
|
||||
CLAIM_APPROVE, // 审核通过后审批
|
||||
CONFIRM, // 送检确认
|
||||
DELIVER, // 送检
|
||||
ACCEPT, // 受理
|
||||
TEST_FINISH, // 检验完成
|
||||
TERMINATE, // 终止
|
||||
ABORT; // 中止
|
||||
}
|
||||
@@ -3,11 +3,10 @@ package digital.laboratory.platform.entrustment.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import digital.laboratory.platform.entrustment.entity.Suspect;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 委托嫌疑人数据访问接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface SuspectMapper extends BaseMapper<Suspect> {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,16 +14,13 @@ import digital.laboratory.platform.entrustment.query.EntrustMaterialCheckoutResu
|
||||
import digital.laboratory.platform.entrustment.vo.DetectionRateVO;
|
||||
import digital.laboratory.platform.entrustment.vo.EntrustMaterialCheckoutResultVO;
|
||||
import digital.laboratory.platform.entrustment.vo.EntrustmentIdentificationMaterialVO;
|
||||
import digital.laboratory.platform.entrustment.vo.SuspectDetectionVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ChenJiangBao
|
||||
@@ -49,12 +46,12 @@ public interface EntrustMaterialCheckoutResultService extends IService<EntrustMa
|
||||
boolean save(EntrustMaterialCheckoutResultDTO dto);
|
||||
|
||||
/**
|
||||
* 根据委托id导出检出结果excel文件
|
||||
* 导出可上传至禁毒大数据平台文件
|
||||
*
|
||||
* @param entrustIds 委托id列表,包含需要导出的委托的id
|
||||
* @param excelDTO 导出参数
|
||||
* @param response HttpServletResponse对象,用于将生成的excel文件写入响应中
|
||||
*/
|
||||
void exportExcel(List<String> entrustIds, HttpServletResponse response) throws IOException;
|
||||
void exportForBigDataPlatform(ResultExcelDTO excelDTO, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* vo 分页对象
|
||||
@@ -84,7 +81,13 @@ public interface EntrustMaterialCheckoutResultService extends IService<EntrustMa
|
||||
*/
|
||||
DetectionRateVO getDetectionRateByMaterial(Integer year, String orgId);
|
||||
|
||||
|
||||
/**
|
||||
* 导出Excel
|
||||
* @param response
|
||||
* @param excelDTO
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
R getExcelByResult(HttpServletResponse response, ResultExcelDTO excelDTO) throws IOException;
|
||||
|
||||
boolean pushSuspectDetectionResult(String entrustmentId) throws SQLException;
|
||||
|
||||
@@ -29,4 +29,11 @@ public interface ExcelOperationService {
|
||||
*/
|
||||
void exportByEntrustOrg(Integer year, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 导入检材信息
|
||||
* @param file
|
||||
* @param entrustId
|
||||
* @return
|
||||
*/
|
||||
Boolean importMaterialInfo(MultipartFile file, String entrustId) throws Exception;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import digital.laboratory.platform.entrustment.dto.ResultExcelDTO;
|
||||
import digital.laboratory.platform.entrustment.entity.*;
|
||||
import digital.laboratory.platform.entrustment.enums.EntrustStatusConstants;
|
||||
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.service.*;
|
||||
import digital.laboratory.platform.entrustment.utils.ExcelUtils;
|
||||
@@ -82,9 +81,6 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
@Resource
|
||||
private CommonFeignService commonFeignService;
|
||||
|
||||
@Resource
|
||||
private EntrustmentIdentificationMaterialMapper entrustmentIdentificationMaterialMapper;
|
||||
|
||||
@Resource
|
||||
private SuspectService suspectService;
|
||||
|
||||
@@ -190,17 +186,27 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据委托id导出检出结果excel文件
|
||||
* 导出可上传至禁毒大数据平台文件
|
||||
*
|
||||
* @param entrustIds 委托id列表,包含需要导出的委托的id
|
||||
* @param excelDTO 导出参数
|
||||
* @param response HttpServletResponse对象,用于将生成的excel文件写入响应中
|
||||
*/
|
||||
@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(
|
||||
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())
|
||||
.in(Entrustment::getStatus, EntrustStatusConstants.ENTRUST_STATUS_ACCEPTED.getStatus(), EntrustStatusConstants.ENTRUST_STATUS_TEST_FINISH.getStatus(), EntrustStatusConstants.ENTRUST_STATUS_COMPLETED.getStatus())
|
||||
);
|
||||
List<String> entrustIds = entrustmentList.stream().map(Entrustment::getId).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(entrustIds)) {
|
||||
throw new CheckedException("没有查询到符合条件的委托信息!");
|
||||
}
|
||||
// 获取检材信息, 排序的原因是需要数据是有序的
|
||||
List<EntrustmentIdentificationMaterial> materialList = entrustmentIdentificationMaterialService.list(
|
||||
Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery()
|
||||
@@ -218,10 +224,10 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
Map<String, EntrustMaterialCheckoutResult> checkoutResultMap = checkoutResultList.stream().collect(Collectors.toMap(EntrustMaterialCheckoutResult::getId, Function.identity()));
|
||||
List<CheckoutResultExcelDTO> checkoutResultExcelDTOS = fetchCheckoutResultExcelDTOList(entrustmentList, materialGroupByEntrustMap, checkoutResultMap);
|
||||
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
String fileName = URLEncoder.encode("检材检出结果excel表", "UTF-8").replaceAll("\\+", "%20");
|
||||
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
// response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
// response.setCharacterEncoding("utf-8");
|
||||
// String fileName = URLEncoder.encode("检材检出结果excel表", "UTF-8").replaceAll("\\+", "%20");
|
||||
// response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||
|
||||
// 不使用默认样式
|
||||
// 空的头部样式
|
||||
@@ -251,25 +257,6 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
*/
|
||||
@Override
|
||||
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(
|
||||
new Page<>(query.getCurrent(), query.getSize()),
|
||||
Wrappers.<EntrustMaterialCheckoutResultVO>query()
|
||||
@@ -333,8 +320,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("检材类型");
|
||||
@@ -379,16 +366,20 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
excelDTO.setAcceptNo(entrust.getAcceptNo());
|
||||
excelDTO.setOrderNo(material.getOrderNo());
|
||||
excelDTO.setTypeName(typeName);
|
||||
excelDTO.setColor(material.getColor());
|
||||
excelDTO.setFormName(material.getFormName());
|
||||
String formName = 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());
|
||||
excelDTO.setQualitativeResult(
|
||||
DrugLiteConvert.getDrugLites(entrustMaterialCheckoutResult.getQualitativeResult())
|
||||
.stream().map(DrugLite::getName).collect(Collectors.joining("、"))
|
||||
);
|
||||
excelDTO.setQuantitativeResult(entrustMaterialCheckoutResult.getQuantitativeResult());
|
||||
excelDTO.setOtherResult(entrustMaterialCheckoutResult.getOtherResult());
|
||||
excelDTO.setRemark(entrustMaterialCheckoutResult.getCheckoutRemark());
|
||||
if (entrustMaterialCheckoutResult != null) {
|
||||
excelDTO.setQualitativeResult(
|
||||
DrugLiteConvert.getDrugLites(entrustMaterialCheckoutResult.getQualitativeResult())
|
||||
.stream().map(DrugLite::getName).collect(Collectors.joining("、"))
|
||||
);
|
||||
excelDTO.setQuantitativeResult(entrustMaterialCheckoutResult.getQuantitativeResult());
|
||||
excelDTO.setOtherResult(entrustMaterialCheckoutResult.getOtherResult());
|
||||
excelDTO.setRemark(entrustMaterialCheckoutResult.getCheckoutRemark());
|
||||
}
|
||||
checkoutResultExcelDTOList.add(excelDTO);
|
||||
}
|
||||
}
|
||||
@@ -578,18 +569,7 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
} else {
|
||||
wrapper.ge(Entrustment::getAcceptTime, this.getStartTime(null));
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> allResults = getOriginalIdentificationList(oldResults);
|
||||
|
||||
if (!allResults.isEmpty()) {
|
||||
wrapper.in(Entrustment::getOldIdentificationResult, allResults);
|
||||
@@ -682,6 +662,27 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
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(
|
||||
ResultExcelDTO excelDTO) {
|
||||
@@ -701,19 +702,7 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
qw.ge(Entrustment::getAcceptTime, this.getStartTime(null));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> allResults = getOriginalIdentificationList(oldResults);
|
||||
if (!allResults.isEmpty()) {
|
||||
qw.in(Entrustment::getOldIdentificationResult, allResults);
|
||||
}
|
||||
@@ -854,28 +843,46 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出Excel
|
||||
* @param response
|
||||
* @param excelDTO
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
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();
|
||||
LocalDateTime endTime = excelDTO.getEndTime();
|
||||
Integer entrustType = excelDTO.getEntrustType();
|
||||
List<String> oldResults = excelDTO.getOldResult();
|
||||
if (excelDTO.getExportForBigDataPlatform() != null && excelDTO.getExportForBigDataPlatform()) {
|
||||
try {
|
||||
// 导出可上传至禁毒大数据平台文件
|
||||
exportForBigDataPlatform(excelDTO, response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return R.failed(e.getMessage());
|
||||
}
|
||||
} else {
|
||||
// 获取查询数据
|
||||
List<EntrustmentIdentificationMaterialVO> resultData = this.getResultData(excelDTO);
|
||||
Map<String, List<EntrustmentIdentificationMaterialVO>> resultDataMap = this.getResultDataMap(excelDTO);
|
||||
|
||||
if (resultData.isEmpty() || resultDataMap.isEmpty()) {
|
||||
return R.failed("没有符合条件的数据!");
|
||||
LocalDateTime startTime = excelDTO.getStartTime();
|
||||
LocalDateTime endTime = excelDTO.getEndTime();
|
||||
Integer entrustType = excelDTO.getEntrustType();
|
||||
List<String> oldResults = excelDTO.getOldResult();
|
||||
|
||||
if (resultData.isEmpty() || resultDataMap.isEmpty()) {
|
||||
return R.failed("没有符合条件的数据!");
|
||||
}
|
||||
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
|
||||
createDataSheet(workbook, entrustType, resultData);
|
||||
createStatisticsSheet(workbook, resultDataMap, oldResults, entrustType, startTime, endTime);
|
||||
createDrugSheets(workbook, resultDataMap, entrustType);
|
||||
|
||||
workbook.write(response.getOutputStream());
|
||||
}
|
||||
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
|
||||
createDataSheet(workbook, entrustType, resultData);
|
||||
createStatisticsSheet(workbook, resultDataMap, oldResults, entrustType, startTime, endTime);
|
||||
createDrugSheets(workbook, resultDataMap, entrustType);
|
||||
|
||||
workbook.write(response.getOutputStream());
|
||||
return R.ok("导出成功!");
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
@@ -33,7 +33,7 @@ import digital.laboratory.platform.common.feign.RemoteWord2PDFService;
|
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
|
||||
import digital.laboratory.platform.common.oss.service.OssFile;
|
||||
import digital.laboratory.platform.common.security.util.SecurityUtils;
|
||||
import digital.laboratory.platform.entrustment.constant.EntrustMarkConstants;
|
||||
import digital.laboratory.platform.entrustment.constant.EntrustConstants;
|
||||
import digital.laboratory.platform.entrustment.convert.DrugLiteConvert;
|
||||
import digital.laboratory.platform.entrustment.dto.EntrustmentDTO;
|
||||
import digital.laboratory.platform.entrustment.entity.*;
|
||||
@@ -3309,34 +3309,34 @@ public class EntrustmentServiceImpl extends ServiceImpl<EntrustmentMapper, Entru
|
||||
log.error("通过查询接口调用获取污水系统统计数据失败!失败原因:{}", statisticsDiffStatusJobDTOR.getMsg());
|
||||
}
|
||||
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.CASE_ACCEPT,
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.CASE_ACCEPT,
|
||||
entrustListMap.getOrDefault(
|
||||
StrUtil.join("_", EntrustMarkConstants.LOCAL_SYSTEM, EntrustStatusConstants.ENTRUST_STATUS_WAITING_ACCEPT.getStatus()),
|
||||
StrUtil.join("_", EntrustConstants.LOCAL_SYSTEM, EntrustStatusConstants.ENTRUST_STATUS_WAITING_ACCEPT.getStatus()),
|
||||
Collections.EMPTY_LIST
|
||||
).size(),
|
||||
String.format("待受理(%s)", EntrustMarkConstants.PUBLIC_SECURITY_BUREAU)));
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.CASE_ACCEPT,
|
||||
String.format("待受理(%s)", EntrustConstants.PUBLIC_SECURITY_BUREAU)));
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.CASE_ACCEPT,
|
||||
entrustListMap.getOrDefault(
|
||||
StrUtil.join("_", EntrustMarkConstants.THIRD_PARTY_SYSTEM, EntrustStatusConstants.ENTRUST_STATUS_WAITING_ACCEPT.getStatus()),
|
||||
StrUtil.join("_", EntrustConstants.THIRD_PARTY_SYSTEM, EntrustStatusConstants.ENTRUST_STATUS_WAITING_ACCEPT.getStatus()),
|
||||
Collections.EMPTY_LIST
|
||||
).size(),
|
||||
"待受理 (大数据平台)"));
|
||||
List<Entrustment> entrustListMapOrDefault = entrustListMap.getOrDefault(
|
||||
StrUtil.join("_", EntrustMarkConstants.LOCAL_SYSTEM, EntrustStatusConstants.ENTRUST_STATUS_ACCEPTED.getStatus()), Collections.EMPTY_LIST
|
||||
StrUtil.join("_", EntrustConstants.LOCAL_SYSTEM, EntrustStatusConstants.ENTRUST_STATUS_ACCEPTED.getStatus()), Collections.EMPTY_LIST
|
||||
);
|
||||
// o.getAcceptTime().isAfter(LocalDateTime.of(LocalDate.now().withDayOfYear(1), LocalTime.MIN)) 筛选出当年的数据
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.CASE_ACCEPT,
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.CASE_ACCEPT,
|
||||
entrustListMapOrDefault.stream().filter(o ->
|
||||
o.getAcceptTime().isAfter(LocalDateTime.of(LocalDate.now().withDayOfYear(1), LocalTime.MIN))
|
||||
&& EntrustStatusConstants.geAcceptedStatus(o.getStatus())
|
||||
).collect(Collectors.toList()).size(),
|
||||
String.format("已受理 (%s)", EntrustMarkConstants.PUBLIC_SECURITY_BUREAU)));
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.CASE_ACCEPT,
|
||||
String.format("已受理 (%s)", EntrustConstants.PUBLIC_SECURITY_BUREAU)));
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.CASE_ACCEPT,
|
||||
entrustListMap.getOrDefault(
|
||||
StrUtil.join("_", EntrustMarkConstants.THIRD_PARTY_SYSTEM, EntrustStatusConstants.ENTRUST_STATUS_ACCEPTED.getStatus()), Collections.EMPTY_LIST
|
||||
StrUtil.join("_", EntrustConstants.THIRD_PARTY_SYSTEM, EntrustStatusConstants.ENTRUST_STATUS_ACCEPTED.getStatus()), Collections.EMPTY_LIST
|
||||
).size(),
|
||||
"已受理 (大数据平台)"));
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.CASE_ACCEPT,
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.CASE_ACCEPT,
|
||||
this.list(Wrappers.<Entrustment>lambdaQuery()
|
||||
.ge(Entrustment::getStatus, EntrustStatusConstants.ENTRUST_STATUS_ACCEPTED.getStatus())
|
||||
.inSql(Entrustment::getId, "SELECT entrust_id FROM b_entrust_material_checkout_result"))
|
||||
@@ -3349,34 +3349,34 @@ public class EntrustmentServiceImpl extends ServiceImpl<EntrustmentMapper, Entru
|
||||
.size(),
|
||||
"检测结果")
|
||||
);
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.REVIEW_OR_APPROVAL,
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.REVIEW_OR_APPROVAL,
|
||||
REVIEW_STATUS_GROUP1.stream()
|
||||
.mapToInt(status -> entrustListMap.getOrDefault(EntrustMarkConstants.LOCAL_SYSTEM + "_" + status, Collections.emptyList()).size())
|
||||
.mapToInt(status -> entrustListMap.getOrDefault(EntrustConstants.LOCAL_SYSTEM + "_" + status, Collections.emptyList()).size())
|
||||
.sum(),
|
||||
String.format("委托审核(%s)", EntrustMarkConstants.PUBLIC_SECURITY_BUREAU)));
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.REVIEW_OR_APPROVAL,
|
||||
String.format("委托审核(%s)", EntrustConstants.PUBLIC_SECURITY_BUREAU)));
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.REVIEW_OR_APPROVAL,
|
||||
REVIEW_STATUS_GROUP2.stream()
|
||||
.mapToInt(status -> entrustListMap.getOrDefault(EntrustMarkConstants.LOCAL_SYSTEM + "_" + status, Collections.emptyList()).size())
|
||||
.mapToInt(status -> entrustListMap.getOrDefault(EntrustConstants.LOCAL_SYSTEM + "_" + status, Collections.emptyList()).size())
|
||||
.sum(),
|
||||
String.format("委托审批(%s)", EntrustMarkConstants.PUBLIC_SECURITY_BUREAU)));
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.REVIEW_OR_APPROVAL,
|
||||
String.format("委托审批(%s)", EntrustConstants.PUBLIC_SECURITY_BUREAU)));
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.REVIEW_OR_APPROVAL,
|
||||
REVIEW_STATUS_GROUP1.stream()
|
||||
.mapToInt(status -> entrustListMap.getOrDefault(EntrustMarkConstants.THIRD_PARTY_SYSTEM + "_" + status, Collections.emptyList()).size())
|
||||
.mapToInt(status -> entrustListMap.getOrDefault(EntrustConstants.THIRD_PARTY_SYSTEM + "_" + status, Collections.emptyList()).size())
|
||||
.sum(),
|
||||
"委托审核(大数据平台)"));
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.REVIEW_OR_APPROVAL,
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.REVIEW_OR_APPROVAL,
|
||||
REVIEW_STATUS_GROUP2.stream()
|
||||
.mapToInt(status -> entrustListMap.getOrDefault(EntrustMarkConstants.LOCAL_SYSTEM + "_" + status, Collections.emptyList()).size())
|
||||
.mapToInt(status -> entrustListMap.getOrDefault(EntrustConstants.LOCAL_SYSTEM + "_" + status, Collections.emptyList()).size())
|
||||
.sum(),
|
||||
"委托审批(大数据平台)"));
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.REVIEW_OR_APPROVAL,
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.REVIEW_OR_APPROVAL,
|
||||
(int) entrustAlterApplyService.count(Wrappers.<EntrustAlterApply>lambdaQuery()
|
||||
.eq(EntrustAlterApply::getStatus, EntrustAlterApplyStatus.SUBMITTED_WAIT_APPROVE.getStatus())),
|
||||
"委托修改审核"));
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.SEWAGE_JOB_ACCEPT, statisticsDiffStatusSewageJobDTO.getJobStatusCreatedNum(), "污水任务待发布"));
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.SEWAGE_JOB_ACCEPT, statisticsDiffStatusSewageJobDTO.getJobStatusClaimNum(), "污水任务已发布"));
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.SEWAGE_JOB_ACCEPT, statisticsDiffStatusSewageJobDTO.getJobStatusClaimNum(), "污水受理"));
|
||||
markersVOS.add(new MarkersVO(EntrustMarkConstants.SEWAGE_JOB_ACCEPT, statisticsDiffStatusSewageJobDTO.getSewageTreatmentPlantNum(), "污水厂管理"));
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.SEWAGE_JOB_ACCEPT, statisticsDiffStatusSewageJobDTO.getJobStatusCreatedNum(), "污水任务待发布"));
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.SEWAGE_JOB_ACCEPT, statisticsDiffStatusSewageJobDTO.getJobStatusClaimNum(), "污水任务已发布"));
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.SEWAGE_JOB_ACCEPT, statisticsDiffStatusSewageJobDTO.getJobStatusClaimNum(), "污水受理"));
|
||||
markersVOS.add(new MarkersVO(EntrustConstants.SEWAGE_JOB_ACCEPT, statisticsDiffStatusSewageJobDTO.getSewageTreatmentPlantNum(), "污水厂管理"));
|
||||
|
||||
return markersVOS;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package digital.laboratory.platform.entrustment.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import digital.laboratory.platform.common.core.constant.CommonConstants;
|
||||
import digital.laboratory.platform.common.core.exception.CheckedException;
|
||||
@@ -26,6 +26,7 @@ import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -36,13 +37,12 @@ import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -89,154 +89,71 @@ public class ExcelOperationServiceImpl implements ExcelOperationService {
|
||||
* @throws Exception 发生异常时抛出
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean uploadHairInspectExcel(MultipartFile file, String entrustId) throws Exception {
|
||||
|
||||
// 1. 校验委托合法性
|
||||
// ---------- 1. 校验委托合法性 ----------
|
||||
Entrustment entrustment = entrustmentService.getById(entrustId);
|
||||
if (entrustment == null) {
|
||||
throw new CheckedException(String.format("委托id为 %s 的委托信息不存在!", entrustId));
|
||||
}
|
||||
if (!entrustment.getOldIdentificationResult().equals(EntrustIdentificationSituationType.TWO_AGENCY.getDesc())) {
|
||||
throw new CheckedException("当前不支持两社人员之外的委托信息进行导入!");
|
||||
throw new CheckedException(String.format("委托ID为 %s 的委托信息不存在!", entrustId));
|
||||
}
|
||||
|
||||
// 2. 获取案件与毒品信息
|
||||
// 2.1 校验案件信息
|
||||
CaseEvent cj = caseEventService.validateCaseInfo(entrustment.getCaseId());
|
||||
|
||||
// 2.2 获取默认毒品(海洛因)
|
||||
|
||||
|
||||
// 2.3 获取所有毒品名称映射(便于匹配检测结果)
|
||||
R<List<DrugLite>> innerGetAllR = remoteCommDrugService.innerGetAll();
|
||||
List<DrugLite> drugLiteList = innerGetAllR.getData();
|
||||
Map<String, DrugLite> drugLiteMap = drugLiteList.stream()
|
||||
.collect(Collectors.toMap(DrugLite::getName, Function.identity()));
|
||||
|
||||
// 3. 读取Excel内容(从第一行数据开始读取)
|
||||
int headIndex = 0;
|
||||
List<Map<String, String>> data = ExcelUtils.readExcel(file, headIndex);
|
||||
|
||||
// 3.1 获取当前委托下已有检材数,作为orderNo起始编号
|
||||
int orderNo = entrustmentIdentificationMaterialService.lambdaQuery()
|
||||
.eq(EntrustmentIdentificationMaterial::getEntrustmentId, entrustId)
|
||||
.list().size() + 1;
|
||||
|
||||
// 3.2 初始化结果对象集合
|
||||
List<EntrustMaterialCheckoutResult> results = new ArrayList<>();
|
||||
|
||||
ArrayList<Suspect> suspects = new ArrayList<>();
|
||||
for (Map<String, String> datum : data) {
|
||||
Suspect suspect = new Suspect();
|
||||
suspect.setName(datum.get("姓名"));
|
||||
suspect.setIdNumber(datum.get("身份证号"));
|
||||
suspects.add(suspect);
|
||||
if (!EntrustIdentificationSituationType.TWO_AGENCY.getDesc().equals(entrustment.getOldIdentificationResult())) {
|
||||
throw new CheckedException("当前仅支持‘两社人员’类型的委托信息进行导入!");
|
||||
}
|
||||
|
||||
// ---------- 2. 校验案件信息 ----------
|
||||
CaseEvent caseEvent = caseEventService.validateCaseInfo(entrustment.getCaseId());
|
||||
|
||||
// ---------- 3. 获取毒品名称映射 ----------
|
||||
Map<String, DrugLite> drugMap = getDrugLiteMap();
|
||||
|
||||
// ---------- 4. 读取 Excel 数据 ----------
|
||||
final int headerRowIndex = 0;
|
||||
List<Map<String, String>> excelData = ExcelUtils.readExcel(file, headerRowIndex);
|
||||
if (CollUtil.isEmpty(excelData)) {
|
||||
throw new CheckedException("Excel 文件内容为空!");
|
||||
}
|
||||
|
||||
// ---------- 5. 处理嫌疑人信息 ----------
|
||||
List<Suspect> suspects = excelData.stream()
|
||||
.map(row -> {
|
||||
Suspect s = new Suspect();
|
||||
s.setName(row.get("姓名"));
|
||||
s.setIdNumber(row.get("身份证号"));
|
||||
return s;
|
||||
})
|
||||
.filter(s -> StrUtil.isNotBlank(s.getName()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(suspects)) {
|
||||
// 删除旧嫌疑人信息
|
||||
suspectService.remove(Wrappers.<Suspect>lambdaQuery()
|
||||
.eq(Suspect::getEntrustId, entrustId));
|
||||
// 保存新嫌疑人信息
|
||||
suspectService.addSuspectList(suspects, entrustId);
|
||||
}
|
||||
List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterialList = new ArrayList<>();
|
||||
|
||||
// 4. 遍历Excel数据行,构建检材与检测结果
|
||||
processExcelDataToMaterialEntity(data, entrustment, drugLiteMap, orderNo, cj, entrustmentIdentificationMaterialList);
|
||||
// entrustMaterialCheckoutResultService.saveBatch(results);
|
||||
boolean isSave = entrustmentIdentificationMaterialService.saveBatch(entrustmentIdentificationMaterialList);
|
||||
String entrustReq = entrustmentService.buildEntrustReq(entrustmentIdentificationMaterialList);
|
||||
entrustment.setEntrustRequirement(entrustReq);
|
||||
entrustmentService.updateById(entrustment);
|
||||
// 5. 批量保存检材信息和检测结果
|
||||
return isSave;
|
||||
}
|
||||
// ---------- 6. 构建检材与检测结果 ----------
|
||||
Long existingMaterialCount = entrustmentIdentificationMaterialService.lambdaQuery()
|
||||
.eq(EntrustmentIdentificationMaterial::getEntrustmentId, entrustId)
|
||||
.count();
|
||||
int startOrderNo = Math.toIntExact(existingMaterialCount + 1);
|
||||
|
||||
/**
|
||||
* 处理Excel数据,构建检材对象并设置相关属性
|
||||
*
|
||||
* @param data Excel数据列表
|
||||
* @param entrustment 委托信息对象
|
||||
* @param drugLiteMap 毒品名称映射表
|
||||
* @param orderNo 检材序号起始值
|
||||
* @param cj 案件信息对象
|
||||
* @param entrustmentIdentificationMaterialList 检材列表对象集合
|
||||
*/
|
||||
private void processExcelDataToMaterialEntity(List<Map<String, String>> data, Entrustment entrustment, Map<String, DrugLite> drugLiteMap, int orderNo, CaseEvent cj, List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterialList) {
|
||||
for (Map<String, String> datum : data) {
|
||||
// 构建检材对象
|
||||
EntrustmentIdentificationMaterial material = new EntrustmentIdentificationMaterial();
|
||||
material.setEntrustmentId(entrustment.getId());
|
||||
material.setCaseId(entrustment.getCaseId());
|
||||
material.setName(datum.get("姓名") + "毛发");
|
||||
material.setRemark(datum.get("身份证号"));
|
||||
List<EntrustmentIdentificationMaterial> materialList = processHairExcelDataToMaterialEntity(excelData, entrustment, drugMap, startOrderNo, caseEvent);
|
||||
|
||||
// 解析身份证号
|
||||
String idNum = datum.get("身份证号");
|
||||
if (idNum != null && idNum.length() == 18) {
|
||||
material.setBiologyGender(this.getSexByIdNum(idNum));
|
||||
material.setMaterialAge(Integer.valueOf(this.getAgeByIdNum(idNum)));
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(datum.get("提取地点"))) {
|
||||
material.setDrawPlace("贵阳市");
|
||||
} else {
|
||||
material.setDrawPlace(datum.get("提取地点"));
|
||||
}
|
||||
|
||||
material.setId(IdWorker.get32UUID().toUpperCase());
|
||||
|
||||
// 检测结果解析
|
||||
ArrayList<DrugLite> matchedDrugs = new ArrayList<>();
|
||||
String[] drugs = datum.get("曾吸毒种类").split("、");
|
||||
if (drugs.length == 0 || (drugs.length == 1 && drugs[0].trim().isEmpty())) {
|
||||
matchedDrugs.add(drugLiteMap.get("海洛因"));
|
||||
} else {
|
||||
for (String drugName : drugs) {
|
||||
if (drugLiteMap.containsKey(drugName)) {
|
||||
matchedDrugs.add(drugLiteMap.get(drugName));
|
||||
} else {
|
||||
// 未匹配到任何已知毒品,则调用接口保存
|
||||
DrugLite newDrug = new DrugLite();
|
||||
newDrug.setId(IdWorker.get32UUID().toUpperCase());
|
||||
newDrug.setName(drugName);
|
||||
R<Boolean> booleanR = remoteCommDrugService.innerSaveDrug(newDrug);
|
||||
if (booleanR.getCode() == CommonConstants.FAIL) {
|
||||
throw new CheckedException("新增未知毒品失败!");
|
||||
}
|
||||
// 更新缓存 Map,避免重复插入
|
||||
drugLiteMap.put(drugName, newDrug);
|
||||
matchedDrugs.add(newDrug);
|
||||
}
|
||||
}
|
||||
}
|
||||
material.setCandidateDrugs(matchedDrugs);
|
||||
|
||||
// 设置检材默认属性
|
||||
material.setBiologyType(EntrustBiologyType.HAIR.getDesc());
|
||||
material.setType("1");
|
||||
material.setTypeName("生物样本");
|
||||
material.setQuantity(new BigDecimal(50));
|
||||
material.setUnit("mg");
|
||||
material.setForm("黑色头发");
|
||||
material.setFormName("黑色头发");
|
||||
material.setOrderNo(orderNo);
|
||||
material.setImEntrustNumber(String.valueOf(orderNo));
|
||||
orderNo++;
|
||||
material.setPackComplete(true);
|
||||
material.setRtSampleQuantity(0);
|
||||
// 定义格式化器(注意 M 和 d 不要补0)
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
|
||||
LocalDateTime drawTime = LocalDateTime.parse(datum.get("提取时间"), formatter.withZone(ZoneId.systemDefault()));
|
||||
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||
System.out.println("提取时间为" + drawTime);
|
||||
// 转 LocalDate
|
||||
material.setDrawTime(drawTime);
|
||||
material.setAnalysisOption(AnalysisOptionEnums.QUALITATIVE.getCode());
|
||||
|
||||
entrustmentIdentificationMaterialService.setMaterialIdentificationNo(material, cj);
|
||||
material.setSample1No(sampleService.getNewSampleNo(material.getImNo(), 1));
|
||||
|
||||
entrustmentIdentificationMaterialList.add(material);
|
||||
// ---------- 7. 保存检材信息 ----------
|
||||
boolean saveSuccess = entrustmentIdentificationMaterialService.saveBatch(materialList);
|
||||
if (!saveSuccess) {
|
||||
throw new CheckedException("批量保存检材信息失败!");
|
||||
}
|
||||
|
||||
// ---------- 8. 更新委托要求 ----------
|
||||
String entrustRequirement = entrustmentService.buildEntrustReq(materialList);
|
||||
entrustment.setEntrustRequirement(entrustRequirement);
|
||||
entrustmentService.updateById(entrustment);
|
||||
|
||||
// ---------- 9. 返回执行结果 ----------
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,6 +281,233 @@ public class ExcelOperationServiceImpl implements ExcelOperationService {
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入检材信息
|
||||
*
|
||||
* @param file
|
||||
* @param entrustId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean importMaterialInfo(MultipartFile file, String entrustId) throws Exception {
|
||||
// ---------- 1. 校验委托合法性 ----------
|
||||
Entrustment entrustment = entrustmentService.getById(entrustId);
|
||||
if (entrustment == null) {
|
||||
throw new CheckedException(String.format("委托ID为 %s 的委托信息不存在!", entrustId));
|
||||
}
|
||||
|
||||
// ---------- 2. 校验案件信息 ----------
|
||||
CaseEvent caseEvent = caseEventService.validateCaseInfo(entrustment.getCaseId());
|
||||
|
||||
// ---------- 3. 获取毒品名称映射 ----------
|
||||
Map<String, DrugLite> drugMap = getDrugLiteMap();
|
||||
|
||||
// ---------- 4. 读取 Excel 数据 ----------
|
||||
final int headerRowIndex = 0;
|
||||
List<Map<String, String>> excelData = ExcelUtils.readExcel(file, headerRowIndex);
|
||||
if (CollUtil.isEmpty(excelData)) {
|
||||
throw new CheckedException("Excel 文件内容为空!");
|
||||
}
|
||||
|
||||
|
||||
// ---------- 6. 构建检材与检测结果 ----------
|
||||
Long existingMaterialCount = entrustmentIdentificationMaterialService.lambdaQuery()
|
||||
.eq(EntrustmentIdentificationMaterial::getEntrustmentId, entrustId)
|
||||
.count();
|
||||
int startOrderNo = Math.toIntExact(existingMaterialCount + 1);
|
||||
|
||||
List<EntrustmentIdentificationMaterial> materialList = processExcelDataToMaterialEntity(excelData, entrustment, drugMap, startOrderNo, caseEvent);
|
||||
|
||||
// ---------- 7. 保存检材信息 ----------
|
||||
boolean saveSuccess = entrustmentIdentificationMaterialService.saveBatch(materialList);
|
||||
if (!saveSuccess) {
|
||||
throw new CheckedException("批量保存检材信息失败!");
|
||||
}
|
||||
|
||||
// ---------- 8. 更新委托要求 ----------
|
||||
String entrustRequirement = entrustmentService.buildEntrustReq(materialList);
|
||||
entrustment.setEntrustRequirement(entrustRequirement);
|
||||
entrustmentService.updateById(entrustment);
|
||||
|
||||
// ---------- 9. 返回执行结果 ----------
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取毒品清单信息,并转成map
|
||||
* @return
|
||||
*/
|
||||
private Map<String, DrugLite> getDrugLiteMap() {
|
||||
R<List<DrugLite>> drugResponse = remoteCommDrugService.innerGetAll();
|
||||
List<DrugLite> drugList = Optional
|
||||
.ofNullable(drugResponse.getData())
|
||||
.orElseThrow(
|
||||
() -> new CheckedException("获取毒品信息失败!")
|
||||
);
|
||||
Map<String, DrugLite> drugMap = drugList.stream()
|
||||
.collect(Collectors.toMap(DrugLite::getName, Function.identity()));
|
||||
return drugMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理毛发两社人员Excel数据,构建检材对象并设置相关属性
|
||||
*
|
||||
* @param data Excel数据列表
|
||||
* @param entrustment 委托信息对象
|
||||
* @param drugLiteMap 毒品名称映射表
|
||||
* @param orderNo 检材序号起始值
|
||||
* @param cj 案件信息对象
|
||||
* @return
|
||||
*/
|
||||
private List<EntrustmentIdentificationMaterial> processHairExcelDataToMaterialEntity(List<Map<String, String>> data, Entrustment entrustment, Map<String, DrugLite> drugLiteMap, int orderNo, CaseEvent cj) {
|
||||
List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterialList = new ArrayList<>();
|
||||
for (Map<String, String> datum : data) {
|
||||
// 构建检材对象
|
||||
EntrustmentIdentificationMaterial material = new EntrustmentIdentificationMaterial();
|
||||
material.setEntrustmentId(entrustment.getId());
|
||||
material.setCaseId(entrustment.getCaseId());
|
||||
material.setName(datum.get("姓名") + "毛发");
|
||||
material.setRemark(datum.get("身份证号"));
|
||||
|
||||
// 解析身份证号
|
||||
String idNum = datum.get("身份证号");
|
||||
if (idNum != null && idNum.length() == 18) {
|
||||
material.setBiologyGender(this.getSexByIdNum(idNum));
|
||||
material.setMaterialAge(Integer.valueOf(this.getAgeByIdNum(idNum)));
|
||||
}
|
||||
|
||||
material.setDrawPlace(datum.get("采样单位"));
|
||||
material.setId(IdWorker.get32UUID().toUpperCase());
|
||||
|
||||
// 检测结果解析
|
||||
String[] drugs = datum.get("检测结果").split("、");
|
||||
buildMatchedDrugs(drugLiteMap, material, drugs);
|
||||
|
||||
// 设置检材默认属性
|
||||
material.setBiologyType(EntrustBiologyType.HAIR.getDesc());
|
||||
material.setType("1");
|
||||
material.setTypeName("生物样本");
|
||||
material.setQuantity(new BigDecimal(50));
|
||||
material.setUnit("mg");
|
||||
material.setForm("黑色头发");
|
||||
material.setFormName("黑色头发");
|
||||
material.setOrderNo(orderNo);
|
||||
material.setImEntrustNumber(String.valueOf(orderNo));
|
||||
orderNo++;
|
||||
material.setPackComplete(true);
|
||||
material.setRtSampleQuantity(0);
|
||||
material.setDrawTime(LocalDateTime.now());
|
||||
material.setAnalysisOption(AnalysisOptionEnums.QUALITATIVE.getCode());
|
||||
|
||||
entrustmentIdentificationMaterialService.setMaterialIdentificationNo(material, cj);
|
||||
material.setSample1No(sampleService.getNewSampleNo(material.getImNo(), 1));
|
||||
|
||||
entrustmentIdentificationMaterialList.add(material);
|
||||
}
|
||||
return entrustmentIdentificationMaterialList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理委托检材Excel数据,构建检材对象并设置相关属性
|
||||
*
|
||||
* @param data Excel数据列表
|
||||
* @param entrustment 委托信息对象
|
||||
* @param drugLiteMap 毒品名称映射表
|
||||
* @param orderNo 检材序号起始值
|
||||
* @param cj 案件信息对象
|
||||
* @return
|
||||
*/
|
||||
private List<EntrustmentIdentificationMaterial> processExcelDataToMaterialEntity(List<Map<String, String>> data, Entrustment entrustment, Map<String, DrugLite> drugLiteMap, int orderNo, CaseEvent cj) {
|
||||
List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterialList = new ArrayList<>();
|
||||
for (Map<String, String> datum : data) {
|
||||
// 构建检材对象
|
||||
EntrustmentIdentificationMaterial material = new EntrustmentIdentificationMaterial();
|
||||
material.setId(IdWorker.get32UUID().toUpperCase());
|
||||
material.setEntrustmentId(entrustment.getId());
|
||||
material.setCaseId(entrustment.getCaseId());
|
||||
material.setName(datum.get("疑似物种类"));
|
||||
material.setRtSampleQuantity(Integer.valueOf(datum.get("留存样个数")));
|
||||
material.setQuantity(new BigDecimal(datum.get("重量/体积")));
|
||||
material.setUnit(datum.get("单位"));
|
||||
String formDesc = datum.get("性状描述");
|
||||
material.setForm(formDesc);
|
||||
material.setFormName(formDesc);
|
||||
// 提取颜色
|
||||
if (StrUtil.isNotBlank(formDesc) && formDesc.contains("色")) {
|
||||
// 截取“色”之前的部分(包含“色”)
|
||||
material.setColor(formDesc.substring(0, formDesc.indexOf("色") + 1));
|
||||
}
|
||||
material.setDrawTime(LocalDate.parse(datum.get("提取时间"), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay());
|
||||
material.setDrawPlace(datum.get("提取地点"));
|
||||
|
||||
// 检测结果解析
|
||||
String[] drugs = datum.get("筛查目标物").split("、");
|
||||
buildMatchedDrugs(drugLiteMap, material, drugs);
|
||||
// 设置委托类型
|
||||
material.setType(String.valueOf(entrustment.getEntrustmentType()));
|
||||
if (entrustment.getEntrustmentType() == 0) {
|
||||
material.setTypeName("常规毒品");
|
||||
} else {
|
||||
material.setTypeName("生物样本");
|
||||
material.setBiologyType(EntrustBiologyType.isExist(formDesc).getDesc());
|
||||
}
|
||||
material.setOrderNo(orderNo);
|
||||
material.setImEntrustNumber(String.valueOf(orderNo));
|
||||
orderNo++;
|
||||
String packageInfo = datum.get("包装信息");
|
||||
if (packageInfo.equals("完整")) {
|
||||
material.setPackComplete(true);
|
||||
} else {
|
||||
material.setPackComplete(false);
|
||||
}
|
||||
String age = datum.get("年龄");
|
||||
if (StrUtil.isNotBlank(age)) {
|
||||
material.setMaterialAge(Integer.valueOf(age));
|
||||
}
|
||||
material.setBiologyGender(datum.get("性别"));
|
||||
material.setAnalysisOption(AnalysisOptionEnums.fromDesc(datum.get("检验项目")).getCode());
|
||||
entrustmentIdentificationMaterialService.setMaterialIdentificationNo(material, cj);
|
||||
material.setSample1No(sampleService.getNewSampleNo(material.getImNo(), 1));
|
||||
|
||||
entrustmentIdentificationMaterialList.add(material);
|
||||
}
|
||||
return entrustmentIdentificationMaterialList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建匹配筛查目标物毒品列表
|
||||
*
|
||||
* @param drugLiteMap 毒品信息缓存Map
|
||||
* @param material 委托鉴定检材对象
|
||||
* @param drugs 待匹配毒品名称数组
|
||||
* @throws CheckedException 抛出检查异常
|
||||
*/
|
||||
private void buildMatchedDrugs(Map<String, DrugLite> drugLiteMap, EntrustmentIdentificationMaterial material,String[] drugs) {
|
||||
ArrayList<DrugLite> matchedDrugs = new ArrayList<>();
|
||||
if (drugs.length == 0 || (drugs.length == 1 && drugs[0].trim().isEmpty())) {
|
||||
matchedDrugs.add(drugLiteMap.get("海洛因"));
|
||||
} else {
|
||||
for (String drugName : drugs) {
|
||||
if (drugLiteMap.containsKey(drugName)) {
|
||||
matchedDrugs.add(drugLiteMap.get(drugName));
|
||||
} else {
|
||||
// 未匹配到任何已知毒品,则调用接口保存
|
||||
DrugLite newDrug = new DrugLite();
|
||||
newDrug.setId(IdWorker.get32UUID().toUpperCase());
|
||||
newDrug.setName(drugName);
|
||||
R<Boolean> booleanR = remoteCommDrugService.innerSaveDrug(newDrug);
|
||||
if (booleanR.getCode() == CommonConstants.FAIL) {
|
||||
throw new CheckedException("新增未知毒品失败!");
|
||||
}
|
||||
// 更新缓存 Map,避免重复插入
|
||||
drugLiteMap.put(drugName, newDrug);
|
||||
matchedDrugs.add(newDrug);
|
||||
}
|
||||
}
|
||||
}
|
||||
material.setCandidateDrugs(matchedDrugs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据委托id分组,拼接嫌疑人姓名和身份证
|
||||
*
|
||||
|
||||
@@ -5,7 +5,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ChenJiangBao
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package digital.laboratory.platform.entrustment.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package digital.laboratory.platform.entrustment.vo;
|
||||
|
||||
import digital.laboratory.platform.common.aop.annotation.DlpFeign;
|
||||
import digital.laboratory.platform.entrustment.entity.Entrustment;
|
||||
import digital.laboratory.platform.entrustment.entity.EntrustmentIdentificationMaterial;
|
||||
import digital.laboratory.platform.entrustment.entity.Suspect;
|
||||
|
||||
Reference in New Issue
Block a user