增加了推送数据至情报平台的功能
This commit is contained in:
@@ -42,6 +42,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -243,19 +244,22 @@ public class CaseEventController {
|
||||
.set(StrUtil.isNotBlank(dto.getOldIdentificationResult()), Entrustment::getOldIdentificationResult, dto.getOldIdentificationResult())
|
||||
);
|
||||
}
|
||||
// 把嫌疑人数组重新保存以便,以每次前端传来的数据为准
|
||||
if (ObjectUtil.isNotNull(dto.getSuspects())) {
|
||||
for (Suspect suspect : dto.getSuspects()) {
|
||||
if (StringUtils.isBlank(suspect.getIdNumber())||suspect.getIdNumber().length()!=18){
|
||||
throw new RuntimeException("请输入正确的身份证号码");
|
||||
}
|
||||
}
|
||||
List<Suspect> list = suspectService.list(Wrappers.<Suspect>lambdaQuery().eq(Suspect::getEntrustId, dto.getEntrustId()));
|
||||
suspectService.addSuspectList(dto.getSuspects(), dto.getEntrustId());
|
||||
suspectService.removeBatchByIds(list);
|
||||
|
||||
Entrustment entrustment = entrustmentService.getById(dto.getEntrustId());
|
||||
if (entrustment.getEntrustmentType() == 1) {
|
||||
|
||||
}
|
||||
if (entrustment.getEntrustmentType() == 1 && (dto.getSuspects() == null || dto.getSuspects().isEmpty())) {
|
||||
throw new RuntimeException("生物样本案件必须提供嫌疑人信息!");
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(dto.getSuspects())) {
|
||||
List<Suspect> oldList = suspectService.list(Wrappers.<Suspect>lambdaQuery().eq(Suspect::getEntrustId, dto.getEntrustId()));
|
||||
suspectService.addSuspectList(dto.getSuspects(), dto.getEntrustId());
|
||||
if (oldList != null && !oldList.isEmpty()) {
|
||||
suspectService.removeBatchByIds(oldList.stream().map(Suspect::getId).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
return R.ok(caseEvent, "保存案件信息成功");
|
||||
} else {
|
||||
return R.failed(caseEvent, "保存案件信息失败");
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import digital.laboratory.platform.common.core.exception.CheckedException;
|
||||
import digital.laboratory.platform.common.core.util.R;
|
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
|
||||
import digital.laboratory.platform.common.security.util.SecurityUtils;
|
||||
import digital.laboratory.platform.entrustment.convert.EntrustMaterialCheckoutResultConvert;
|
||||
import digital.laboratory.platform.entrustment.dto.EntrustMaterialCheckoutResultDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.ResultExcelDTO;
|
||||
@@ -22,6 +24,7 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@@ -96,4 +99,19 @@ public class EntrustMaterialCheckoutResultController {
|
||||
public R getResultData(HttpServletResponse response, @RequestBody ResultExcelDTO excelDTO) throws IOException {
|
||||
return entrustMaterialCheckoutResultService.getExcelByResult(response, excelDTO);
|
||||
}
|
||||
|
||||
@GetMapping("/pushSuspectDetectionResult")
|
||||
@ApiOperation("推送检出结果")
|
||||
public R pushSuspectDetectionResult(String entrustId) throws SQLException {
|
||||
DLPUser dlpUser = SecurityUtils.getUser();
|
||||
return R.ok(entrustMaterialCheckoutResultService.pushSuspectDetectionResult(entrustId, dlpUser));
|
||||
}
|
||||
|
||||
@GetMapping("/pushSuspectDetectionResultTask")
|
||||
@ApiOperation("推送历史检出结果")
|
||||
public R pushSuspectDetectionResultTask() {
|
||||
DLPUser dlpUser = SecurityUtils.getUser();
|
||||
return R.ok(entrustMaterialCheckoutResultService.pushSuspectDetectionResultTask(dlpUser));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ 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;
|
||||
@@ -1351,6 +1352,8 @@ public class EntrustmentController {
|
||||
@PreAuthorize("@pms.hasPermission('EntrustmentEdit')")
|
||||
public R bizSubmitter_Apply(@RequestBody Entrustment entrust, HttpServletRequest theHttpServletRequest) {
|
||||
|
||||
|
||||
System.out.println("开始提交~~~~~~~~~~~~~~~");
|
||||
// System.out.println(String.format("theHttpServletRequest.toString()=%s", theHttpServletRequest.toString()));
|
||||
Principal principal = theHttpServletRequest.getUserPrincipal();
|
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal();
|
||||
@@ -2400,4 +2403,5 @@ public class EntrustmentController {
|
||||
entrustmentService.previewEntrustPDF(entrustId, servletResponse);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import digital.laboratory.platform.common.feign.RemoteTemplate2htmlService;
|
||||
import digital.laboratory.platform.common.log.annotation.SysLog;
|
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
|
||||
import digital.laboratory.platform.common.oss.service.OssFile;
|
||||
import digital.laboratory.platform.common.security.annotation.Inner;
|
||||
import digital.laboratory.platform.entrustment.dto.MaterialDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.PrintDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.SampleBoxDTO;
|
||||
import digital.laboratory.platform.entrustment.entity.CaseEvent;
|
||||
@@ -649,6 +651,8 @@ public class EntrustmentIdentificationMaterialController {
|
||||
if (im != null) {
|
||||
try {
|
||||
ossFile.fileGet(OSSDirectoryConstants.ACCEPT_DIRECTORY + "/" + im.getEntrustmentId() + "/" + identificationMaterialId + "/" + fileName, httpServletResponse.getOutputStream());
|
||||
String fileGetPreUrl = ossFile.fileGetPreUrl(OSSDirectoryConstants.ACCEPT_DIRECTORY + "/" + im.getEntrustmentId() + "/" + identificationMaterialId + "/" + fileName);
|
||||
System.out.println("~~~~~~~~~~~~图片的路径:" + fileGetPreUrl);
|
||||
httpServletResponse.setContentType(new MimetypesFileTypeMap().getContentType(fileName));
|
||||
} catch (AmazonS3Exception s3e) {
|
||||
httpServletResponse.sendError(s3e.getStatusCode(), s3e.toString());
|
||||
@@ -1184,4 +1188,23 @@ public class EntrustmentIdentificationMaterialController {
|
||||
String path = entrustmentIdentificationMaterialService.printMaterialArchives(entrustmentId);
|
||||
return StringUtils.isNotBlank(path) ? R.ok(path, "生成成功!") : R.failed("生成失败!");
|
||||
}
|
||||
|
||||
@PostMapping("/generateEvidenceBySuspect")
|
||||
@ApiOperation(value = "根据嫌疑人列表自动创建生物样本案件的检材信息")
|
||||
public R generateEvidenceBySuspect(@RequestBody MaterialDTO dto, HttpServletRequest servletRequest) {
|
||||
Principal principal = servletRequest.getUserPrincipal();
|
||||
DLPUser dlpUser = (DLPUser) ((OAuth2Authentication) principal).getUserAuthentication().getPrincipal();
|
||||
return entrustmentIdentificationMaterialService.generateEvidenceBySuspect(dto, dlpUser) != null ? R.ok("生成成功") : R.failed("生成失败");
|
||||
}
|
||||
|
||||
@GetMapping("/getMaterialPDF/{acceptNo}")
|
||||
@ApiOperation(value = "查看检材图片")
|
||||
@Inner(value = false)
|
||||
public void getMaterialPDF(@PathVariable String acceptNo, HttpServletResponse response) {
|
||||
try {
|
||||
entrustmentIdentificationMaterialService.getMaterialPDF(acceptNo, response);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package digital.laboratory.platform.entrustment.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import digital.laboratory.platform.entrustment.entity.Suspect;
|
||||
import digital.laboratory.platform.entrustment.json.DynamicBigDecimalSerializer;
|
||||
import digital.laboratory.platform.sys.entity.DrugLite;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@@ -55,4 +56,13 @@ public class MaterialDTO {
|
||||
|
||||
@ApiModelProperty(value = "检材类别")
|
||||
private String typeName;
|
||||
|
||||
@ApiModelProperty(value = "检材的嫌疑人列表")
|
||||
private List<Suspect>suspects;
|
||||
|
||||
@ApiModelProperty(value = "案件ID")
|
||||
private String caseId;
|
||||
|
||||
@ApiModelProperty(value = "委托ID")
|
||||
private String entrustmentId;
|
||||
}
|
||||
@@ -755,4 +755,7 @@ public class Entrustment extends BaseEntity {
|
||||
"如果这个字段为空则表示失败,如果两个推送都成功,以英文逗号分隔")
|
||||
private String pushFlag;
|
||||
|
||||
@ApiModelProperty("是否推送数据到情报平台数据库的标识,true代表推送成功,false或null代表未推送或推送失败!")
|
||||
private Boolean platformFlag;
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import digital.laboratory.platform.common.core.util.R;
|
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
|
||||
import digital.laboratory.platform.entrustment.dto.EntrustMaterialCheckoutResultDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.ResultExcelDTO;
|
||||
import digital.laboratory.platform.entrustment.entity.EntrustMaterialCheckoutResult;
|
||||
@@ -11,9 +12,11 @@ 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 javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@@ -75,4 +78,8 @@ public interface EntrustMaterialCheckoutResultService extends IService<EntrustMa
|
||||
|
||||
|
||||
R getExcelByResult(HttpServletResponse response, ResultExcelDTO excelDTO) throws IOException;
|
||||
|
||||
boolean pushSuspectDetectionResult(String entrustmentId, DLPUser user) throws SQLException;
|
||||
|
||||
R pushSuspectDetectionResultTask(DLPUser dlpUser);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package digital.laboratory.platform.entrustment.service;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
|
||||
import digital.laboratory.platform.entrustment.dto.MaterialDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.PrintDTO;
|
||||
import digital.laboratory.platform.entrustment.entity.CaseEvent;
|
||||
import digital.laboratory.platform.entrustment.entity.CaseEvidence;
|
||||
@@ -10,6 +11,7 @@ import digital.laboratory.platform.entrustment.entity.EntrustmentIdentificationM
|
||||
import digital.laboratory.platform.entrustment.vo.EntrustmentIdentificationMaterialVO;
|
||||
import digital.laboratory.platform.entrustment.vo.SampleBoxVO;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -131,4 +133,14 @@ public interface EntrustmentIdentificationMaterialService extends IService<Entru
|
||||
List<EntrustmentIdentificationMaterial> handleMaterialWeightRounding(String entrustId);
|
||||
|
||||
List<EntrustmentIdentificationMaterialVO> sortVoByAcceptNo(List<EntrustmentIdentificationMaterialVO> materials);
|
||||
|
||||
/**
|
||||
* 根据嫌疑人信息生成委托检材信息
|
||||
* @param dto 含嫌疑人、案件、委托等信息的数据传输对象
|
||||
* @param user 当前操作用户
|
||||
* @return 创建成功后的委托检材列表,若创建失败返回 null
|
||||
*/
|
||||
List<EntrustmentIdentificationMaterial> generateEvidenceBySuspect(MaterialDTO dto, DLPUser user);
|
||||
|
||||
void getMaterialPDF(String acceptNo, HttpServletResponse response) ;
|
||||
}
|
||||
|
||||
@@ -10,4 +10,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface SuspectService extends IService<Suspect> {
|
||||
List<Suspect> addSuspectList(List<Suspect> suspectList, String entrustId);
|
||||
|
||||
boolean isNotNull(Suspect suspect);
|
||||
}
|
||||
@@ -5,35 +5,31 @@ import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.beust.ah.A;
|
||||
import digital.laboratory.platform.common.core.exception.CheckedException;
|
||||
import digital.laboratory.platform.common.core.util.R;
|
||||
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
|
||||
import digital.laboratory.platform.entrustment.convert.DrugLiteConvert;
|
||||
import digital.laboratory.platform.entrustment.convert.EntrustMaterialCheckoutResultConvert;
|
||||
import digital.laboratory.platform.entrustment.dto.CheckoutResultExcelDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.EntrustMaterialCheckoutResultDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.ResultExcelDTO;
|
||||
import digital.laboratory.platform.entrustment.entity.EntrustMaterialCheckoutResult;
|
||||
import digital.laboratory.platform.entrustment.entity.Entrustment;
|
||||
import digital.laboratory.platform.entrustment.entity.EntrustmentIdentificationMaterial;
|
||||
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.CommonFeignService;
|
||||
import digital.laboratory.platform.entrustment.service.EntrustMaterialCheckoutResultService;
|
||||
import digital.laboratory.platform.entrustment.service.EntrustmentIdentificationMaterialService;
|
||||
import digital.laboratory.platform.entrustment.service.EntrustmentService;
|
||||
import digital.laboratory.platform.entrustment.service.*;
|
||||
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 digital.laboratory.platform.sys.entity.Area;
|
||||
import digital.laboratory.platform.sys.entity.DrugLite;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
@@ -47,6 +43,7 @@ import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URLEncoder;
|
||||
import java.sql.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
@@ -74,6 +71,12 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
@Resource
|
||||
private EntrustmentIdentificationMaterialMapper entrustmentIdentificationMaterialMapper;
|
||||
|
||||
@Resource
|
||||
private SuspectService suspectService;
|
||||
|
||||
@Resource
|
||||
private CaseEventService caseEventService;
|
||||
|
||||
/**
|
||||
* 构建委托材料检验结果字符串
|
||||
*
|
||||
@@ -776,6 +779,7 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取结果数据失败: ", e);
|
||||
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
@@ -1018,6 +1022,272 @@ public class EntrustMaterialCheckoutResultServiceImpl extends ServiceImpl<Entrus
|
||||
// return entrusts.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pushSuspectDetectionResult(String entrustmentId, DLPUser user) {
|
||||
// 参数校验
|
||||
if (StringUtils.isBlank(entrustmentId)) {
|
||||
throw new IllegalArgumentException("entrustmentId不能为空");
|
||||
}
|
||||
|
||||
// 获取委托信息
|
||||
Entrustment entrustment = entrustmentService.getById(entrustmentId);
|
||||
if (entrustment == null) {
|
||||
throw new IllegalArgumentException("未找到委托信息:" + entrustmentId);
|
||||
}
|
||||
|
||||
// 获取案件信息
|
||||
CaseEvent caseEvent = caseEventService.getById(entrustment.getCaseId());
|
||||
if (caseEvent == null) {
|
||||
throw new IllegalArgumentException("未找到案件信息:" + entrustment.getCaseId());
|
||||
}
|
||||
|
||||
// 获取检验结果
|
||||
List<EntrustMaterialCheckoutResult> results = this.lambdaQuery()
|
||||
.eq(EntrustMaterialCheckoutResult::getEntrustId, entrustmentId)
|
||||
.isNotNull(EntrustMaterialCheckoutResult::getQualitativeResult)
|
||||
.list();
|
||||
|
||||
if (CollectionUtils.isEmpty(results)){
|
||||
throw new IllegalArgumentException("没有阳性的检验结果:" + entrustmentId+",无需进行推送!");
|
||||
}
|
||||
|
||||
// 获取嫌疑人信息
|
||||
List<Suspect> suspects = suspectService.lambdaQuery()
|
||||
.eq(Suspect::getEntrustId, entrustmentId)
|
||||
.list();
|
||||
|
||||
if (CollectionUtils.isEmpty(suspects)){
|
||||
throw new IllegalArgumentException("未找到嫌疑人信息:" + entrustmentId+",请先添加嫌疑人信息!");
|
||||
}
|
||||
// 构造物证材料映射
|
||||
Map<String, EntrustmentIdentificationMaterial> materialMap = entrustmentIdentificationMaterialService.lambdaQuery()
|
||||
.eq(EntrustmentIdentificationMaterial::getEntrustmentId, entrustmentId)
|
||||
.orderByAsc(EntrustmentIdentificationMaterial::getOrderNo)
|
||||
.list()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(EntrustmentIdentificationMaterial::getId, Function.identity(), (a, b) -> a));
|
||||
|
||||
// 构造检验结果VO
|
||||
List<EntrustMaterialCheckoutResultVO> resultVOS = results.stream()
|
||||
.map(r -> buildResultVO(r, materialMap))
|
||||
.sorted(Comparator.comparingInt(EntrustMaterialCheckoutResultVO::getOrderNo))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
// 数据推送至目标数据库
|
||||
return pushToDatabase(suspects, resultVOS, entrustment, caseEvent, user);
|
||||
}
|
||||
|
||||
private EntrustMaterialCheckoutResultVO buildResultVO(EntrustMaterialCheckoutResult result, Map<String, EntrustmentIdentificationMaterial> materialMap) {
|
||||
EntrustMaterialCheckoutResultVO vo = new EntrustMaterialCheckoutResultVO();
|
||||
BeanUtils.copyProperties(result, vo);
|
||||
|
||||
EntrustmentIdentificationMaterial material = materialMap.get(result.getId());
|
||||
if (material != null) {
|
||||
vo.setName(material.getName());
|
||||
vo.setOrderNo(material.getOrderNo());
|
||||
vo.setForm(material.getForm());
|
||||
vo.setDrawTime(material.getDrawTime());
|
||||
vo.setDrawPlace(material.getDrawPlace());
|
||||
vo.setAcceptNo(material.getAcceptNo());
|
||||
}
|
||||
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||||
System.out.println("结果的毒品列表:"+result.getQualitativeResult());
|
||||
|
||||
vo.setQualitativeResult(
|
||||
DrugLiteConvert.getDrugLites(result.getQualitativeResult())
|
||||
.stream().map(DrugLite::getName)
|
||||
.collect(Collectors.joining("、"))
|
||||
);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
private SuspectDetectionVO buildSuspectVO(Suspect suspect, CaseEvent caseEvent, Entrustment entrustment, List<EntrustMaterialCheckoutResultVO> resultVOS, DLPUser user) {
|
||||
SuspectDetectionVO vo = new SuspectDetectionVO();
|
||||
BeanUtils.copyProperties(suspect, vo);
|
||||
vo.setCaseName(caseEvent.getCaseName());
|
||||
vo.setCaseBrief(caseEvent.getCaseBrief());
|
||||
vo.setHappenTime(caseEvent.getHappenTime());
|
||||
vo.setPushTime(LocalDateTime.now());
|
||||
vo.setAcceptNo(entrustment.getAcceptNo());
|
||||
vo.setResults(resultVOS);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
地址:83.103.24.236
|
||||
端口:43306
|
||||
数据库:znyp
|
||||
数据库账号:wsjc
|
||||
密码:wsjc9985
|
||||
*/
|
||||
private boolean pushToDatabase(List<Suspect> suspects, List<EntrustMaterialCheckoutResultVO> resultVOS, Entrustment entrustment, CaseEvent caseEvent, DLPUser user) {
|
||||
String url = "jdbc:mysql://localhost:3306/dlp_inspection?characterEncoding=utf8&serverTimezone=Asia/Shanghai";
|
||||
String username = "root";
|
||||
String password = "123456";
|
||||
|
||||
try (Connection connection = DriverManager.getConnection(url, username, password)) {
|
||||
|
||||
// 推送嫌疑人信息
|
||||
String sql1 = "INSERT INTO b_suspect (id, name, id_number, phone_number, sex, age, accept_no, order_no, case_name, case_brief, happen_time, push_time, push_user, accept_time,client_org_name) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE name=VALUES(name), id_number=VALUES(id_number), phone_number=VALUES(phone_number), " +
|
||||
"sex=VALUES(sex), age=VALUES(age), accept_no=VALUES(accept_no), order_no=VALUES(order_no), case_name=VALUES(case_name), " +
|
||||
"case_brief=VALUES(case_brief), happen_time=VALUES(happen_time), push_time=VALUES(push_time), push_user=VALUES(push_user), " +
|
||||
"accept_time=VALUES(accept_time) , client_org_name = VALUES(client_org_name)";
|
||||
|
||||
try (PreparedStatement pstmt = connection.prepareStatement(sql1)) {
|
||||
for (Suspect s : suspects) {
|
||||
pstmt.setString(1, s.getId());
|
||||
pstmt.setString(2, s.getName());
|
||||
pstmt.setString(3, s.getIdNumber());
|
||||
pstmt.setString(4, s.getPhoneNumber());
|
||||
pstmt.setString(5, s.getSex());
|
||||
pstmt.setInt(6, s.getAge());
|
||||
pstmt.setString(7, entrustment.getAcceptNo());
|
||||
pstmt.setInt(8, s.getOrderNo());
|
||||
pstmt.setString(9, caseEvent.getCaseName());
|
||||
pstmt.setString(10, caseEvent.getCaseBrief());
|
||||
pstmt.setDate(11, java.sql.Date.valueOf(caseEvent.getHappenTime()));
|
||||
pstmt.setTimestamp(12, Timestamp.valueOf(LocalDateTime.now()));
|
||||
pstmt.setString(13, user.getName());
|
||||
System.out.println(entrustment);
|
||||
pstmt.setDate(14, java.sql.Date.valueOf(entrustment.getAcceptTime().toLocalDate()));
|
||||
pstmt.setString(15, entrustment.getClientOrgName());
|
||||
pstmt.addBatch();
|
||||
}
|
||||
pstmt.executeBatch();
|
||||
}
|
||||
|
||||
// 推送检验结果
|
||||
String sql2 = "INSERT INTO b_result (id, case_accept_no, name, qualitative_result, quantitative_result, other_result, checkout_remark, order_no, form, draw_time, draw_place) " +
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE case_accept_no=VALUES(case_accept_no), name=VALUES(name), qualitative_result=VALUES(qualitative_result), " +
|
||||
"quantitative_result=VALUES(quantitative_result), other_result=VALUES(other_result), checkout_remark=VALUES(checkout_remark), " +
|
||||
"order_no=VALUES(order_no), form=VALUES(form), draw_time=VALUES(draw_time), draw_place=VALUES(draw_place)";
|
||||
|
||||
try (PreparedStatement pstmt2 = connection.prepareStatement(sql2)) {
|
||||
for (EntrustMaterialCheckoutResultVO r : resultVOS) {
|
||||
pstmt2.setString(1, r.getId());
|
||||
pstmt2.setString(2, entrustment.getAcceptNo());
|
||||
pstmt2.setString(3, r.getName());
|
||||
pstmt2.setString(4, r.getQualitativeResult());
|
||||
pstmt2.setString(5, r.getQuantitativeResult());
|
||||
pstmt2.setString(6, r.getOtherResult());
|
||||
pstmt2.setString(7, r.getCheckoutRemark());
|
||||
pstmt2.setInt(8, r.getOrderNo());
|
||||
pstmt2.setString(9, r.getForm());
|
||||
pstmt2.setDate(10, java.sql.Date.valueOf(r.getDrawTime().toLocalDate()));
|
||||
pstmt2.setString(11, r.getDrawPlace());
|
||||
pstmt2.addBatch();
|
||||
}
|
||||
pstmt2.executeBatch();
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
entrustment.setPlatformFlag(true);
|
||||
entrustmentService.updateById(entrustment);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送嫌疑人毒检结果任务
|
||||
*
|
||||
* @param dlpUser 当前操作用户
|
||||
* @return 推送结果
|
||||
*/
|
||||
@Override
|
||||
public R pushSuspectDetectionResultTask(DLPUser dlpUser) {
|
||||
// 查询所有嫌疑人列表
|
||||
List<Suspect> suspectList = suspectService.lambdaQuery()
|
||||
.list();
|
||||
|
||||
// 将嫌疑人按委托ID分组
|
||||
Map<String, List<Suspect>> susMap = suspectList.stream()
|
||||
.collect(Collectors.groupingBy(Suspect::getEntrustId));
|
||||
|
||||
Set<String> entrustSet = susMap.keySet();
|
||||
|
||||
List<Entrustment> entrusts = entrustmentService.lambdaQuery()
|
||||
.in(Entrustment::getId, entrustSet)
|
||||
.ge(Entrustment::getStatus, EntrustStatusConstants.ENTRUST_STATUS_ACCEPTED.getStatus()) // status >= 9
|
||||
.and(qw ->qw
|
||||
.eq(Entrustment::getPlatformFlag,false)
|
||||
.or()
|
||||
.isNull(Entrustment::getPlatformFlag))
|
||||
.list();
|
||||
|
||||
// 提取委托ID列表
|
||||
List<String> entrustIds = entrusts.stream()
|
||||
.map(Entrustment::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查询案件信息,并构造以案件ID为键的映射
|
||||
Map<String, CaseEvent> caseMap = caseEventService.lambdaQuery()
|
||||
.in(CaseEvent::getId, entrusts.stream().map(Entrustment::getCaseId).collect(Collectors.toList()))
|
||||
.list()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(CaseEvent::getId, Function.identity()));
|
||||
|
||||
Map<String, Entrustment> entrustMap = entrusts.stream()
|
||||
.collect(Collectors.toMap(Entrustment::getId, Function.identity()));
|
||||
|
||||
|
||||
// 查询毒检结果:必须存在定性结果
|
||||
List<EntrustMaterialCheckoutResult> resultList = this.lambdaQuery()
|
||||
.in(EntrustMaterialCheckoutResult::getEntrustId, entrustIds)
|
||||
.notLike(EntrustMaterialCheckoutResult::getQualitativeResult, "null")
|
||||
.isNotNull(EntrustMaterialCheckoutResult::getQualitativeResult)
|
||||
.list();
|
||||
|
||||
if (resultList.isEmpty()) {
|
||||
return R.failed("未查询到有定性结果的检材检出结果!");
|
||||
}
|
||||
|
||||
// 查询委托检材信息,并按ID去重(按顺序号升序排序)
|
||||
Map<String, EntrustmentIdentificationMaterial> materialMap = entrustmentIdentificationMaterialService.lambdaQuery()
|
||||
.in(EntrustmentIdentificationMaterial::getEntrustmentId, entrustIds)
|
||||
.orderByAsc(EntrustmentIdentificationMaterial::getOrderNo)
|
||||
.list()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(EntrustmentIdentificationMaterial::getId, Function.identity()));
|
||||
|
||||
if (materialMap.isEmpty()){
|
||||
return R.failed("未查询到有检材信息!");
|
||||
}
|
||||
// 构造结果VO列表
|
||||
List<EntrustMaterialCheckoutResultVO> resultVOS = resultList.stream()
|
||||
.map(result -> this.buildResultVO(result, materialMap))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 将VO按委托ID分组
|
||||
Map<String, List<EntrustMaterialCheckoutResultVO>> resutlMap = resultVOS.stream()
|
||||
.collect(Collectors.groupingBy(EntrustMaterialCheckoutResultVO::getEntrustId));
|
||||
|
||||
Set<String> entrustResultIds = resutlMap.keySet();
|
||||
|
||||
// 按有数据的委托进行推送
|
||||
for (String entrustId : entrustResultIds) {
|
||||
Entrustment entrust = entrustMap.get(entrustId);
|
||||
List<EntrustMaterialCheckoutResultVO> vos = resutlMap.get(entrust.getId());
|
||||
List<Suspect> suspects = susMap.get(entrust.getId());
|
||||
CaseEvent caseEvent = caseMap.get(entrust.getCaseId());
|
||||
boolean ret = this.pushToDatabase(suspects, vos, entrust, caseEvent, dlpUser);
|
||||
if (!ret) {
|
||||
return R.failed("推送失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return R.ok("推送成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,9 +19,11 @@ import digital.laboratory.platform.common.core.constant.OSSDirectoryConstants;
|
||||
import digital.laboratory.platform.common.core.util.BusinessCodeUtils;
|
||||
import digital.laboratory.platform.common.core.util.R;
|
||||
import digital.laboratory.platform.common.feign.RemoteTemplate2htmlService;
|
||||
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.dto.MaterialDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.PrintDTO;
|
||||
import digital.laboratory.platform.entrustment.entity.*;
|
||||
import digital.laboratory.platform.entrustment.enums.AnalysisOptionEnums;
|
||||
@@ -42,17 +44,26 @@ import digital.laboratory.platform.sys.enums.entrust.EntrustBiologyType;
|
||||
import digital.laboratory.platform.sys.feign.RemoteEquipmentService;
|
||||
import digital.laboratory.platform.sys.feign.RemoteSampleService;
|
||||
import digital.laboratory.platform.sys.feign.RemoteUserService;
|
||||
import feign.Response;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
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;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
@@ -111,6 +122,12 @@ public class EntrustmentIdentificationMaterialServiceImpl extends ServiceImpl<En
|
||||
@Resource
|
||||
private SynchronizeMaterialVoService synchronizeMaterialVoService;
|
||||
|
||||
@Resource
|
||||
private RemoteWord2PDFService remoteWord2PDFService;
|
||||
|
||||
@Resource
|
||||
private SuspectService suspectService;
|
||||
|
||||
/**
|
||||
* ## 检材编码
|
||||
* JC1020250001001
|
||||
@@ -1618,6 +1635,7 @@ public class EntrustmentIdentificationMaterialServiceImpl extends ServiceImpl<En
|
||||
/**
|
||||
* 处理检材重量四舍五入
|
||||
* 设置检材列表, 对检材的重量进行处理 小于100的保留两位小数,100以上保留一位小数
|
||||
*
|
||||
* @param entrustId 委托ID
|
||||
* @return 处理后的检材列表
|
||||
*/
|
||||
@@ -1643,7 +1661,7 @@ public class EntrustmentIdentificationMaterialServiceImpl extends ServiceImpl<En
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntrustmentIdentificationMaterialVO> sortVoByAcceptNo(List<EntrustmentIdentificationMaterialVO> materials){
|
||||
public List<EntrustmentIdentificationMaterialVO> sortVoByAcceptNo(List<EntrustmentIdentificationMaterialVO> materials) {
|
||||
materials.sort(Comparator.comparing((EntrustmentIdentificationMaterial m) -> {
|
||||
String[] parts = m.getAcceptNo().split("-");
|
||||
return new int[]{Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2])};
|
||||
@@ -1652,4 +1670,158 @@ public class EntrustmentIdentificationMaterialServiceImpl extends ServiceImpl<En
|
||||
.thenComparingInt(arr -> arr[2]))); // 按子流水号排序
|
||||
return materials;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 根据嫌疑人信息生成委托检材信息
|
||||
* @param dto 含嫌疑人、案件、委托等信息的数据传输对象
|
||||
* @param user 当前操作用户
|
||||
* @return 创建成功后的委托检材列表,若创建失败返回 null
|
||||
*/
|
||||
public List<EntrustmentIdentificationMaterial> generateEvidenceBySuspect(MaterialDTO dto, DLPUser user) {
|
||||
List<Suspect> suspects = dto.getSuspects();
|
||||
|
||||
// 空判断:至少需要一个嫌疑人
|
||||
if (suspects == null || suspects.isEmpty()) {
|
||||
throw new RuntimeException("请至少选择一个嫌疑人后再进行自动创建!");
|
||||
}
|
||||
|
||||
List<EntrustmentIdentificationMaterial> materialList = new ArrayList<>();
|
||||
String typeName = dto.getTypeName(); // "毛发" 或其他(默认尿液)
|
||||
Integer materialNumber = 1;
|
||||
|
||||
for (Suspect suspect : suspects) {
|
||||
EntrustmentIdentificationMaterial material = new EntrustmentIdentificationMaterial();
|
||||
|
||||
// 公共属性赋值
|
||||
material.setName(suspect.getName() + ("毛发".equals(typeName) ? "头发" : "尿液"));
|
||||
material.setColor(""); // 颜色字段预留
|
||||
material.setImEntrustNumber(materialNumber.toString());
|
||||
material.setCaseId(dto.getCaseId());
|
||||
material.setEntrustmentId(dto.getEntrustmentId());
|
||||
material.setDataSources(0);
|
||||
material.setCandidateDrugs(dto.getCandidateDrugs());
|
||||
material.setRtSampleQuantity(0);
|
||||
material.setDrawTime(dto.getDrawTime());
|
||||
material.setDrawPlace(dto.getDrawPlace());
|
||||
material.setPackComplete(true);
|
||||
material.setAnalysisOption(1);
|
||||
material.setType("1"); // 委托类型:生物样本
|
||||
material.setTypeName("生物样本");
|
||||
material.setDrawWay("");
|
||||
material.setStorageMethod("");
|
||||
material.setProvidedSample1Quantity(BigDecimal.ZERO);
|
||||
material.setMaterialAge(suspect.getAge());
|
||||
material.setBiologyGender(suspect.getSex());
|
||||
material.setQuantity(BigDecimal.valueOf(50.00));
|
||||
|
||||
// 根据样本类型分别设置属性
|
||||
if ("毛发".equals(typeName)) {
|
||||
material.setUnit("mg");
|
||||
material.setForm("黑色头发");
|
||||
material.setFormName("黑色头发");
|
||||
material.setBiologyType("毛发");
|
||||
} else {
|
||||
material.setUnit("ml");
|
||||
material.setForm("黄色尿液");
|
||||
material.setFormName("黄色尿液");
|
||||
material.setBiologyType("尿液");
|
||||
}
|
||||
|
||||
materialList.add(material);
|
||||
materialNumber++;
|
||||
}
|
||||
|
||||
// 保存检材信息
|
||||
List<EntrustmentIdentificationMaterial> savedMaterials = this.createNewIm(materialList, user);
|
||||
|
||||
return (savedMaterials != null && !savedMaterials.isEmpty()) ? savedMaterials : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMaterialPDF(String acceptNo, HttpServletResponse response) {
|
||||
|
||||
Entrustment entrustment = entrustmentService.lambdaQuery()
|
||||
.eq(Entrustment::getAcceptNo, acceptNo)
|
||||
.one();
|
||||
|
||||
if (entrustment == null) {
|
||||
throw new RuntimeException("委托不存在");
|
||||
}
|
||||
String entrustId = entrustment.getId();
|
||||
|
||||
String pdfPath = "document/accept/" + entrustId + "/materialPhoto/materialallpic.pdf";
|
||||
List<String> list = ossFile.fileList("document/accept/" + entrustId + "/materialPhoto");
|
||||
System.out.println("获取到的URL:" + list);
|
||||
if (list != null && list.size() > 0) {
|
||||
for (String fileName : list) {
|
||||
if (fileName.endsWith(".pdf")) {
|
||||
try {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
ossFile.fileGet(pdfPath, bos);
|
||||
byte[] pdfBytes = bos.toByteArray();
|
||||
String filename = URLEncoder.encode("material.pdf", StandardCharsets.UTF_8.toString());
|
||||
response.setContentType("application/pdf");
|
||||
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + filename);
|
||||
response.setContentLength(pdfBytes.length);
|
||||
|
||||
// === 7. 输出 PDF 文件到客户端 ===
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
os.write(pdfBytes);
|
||||
os.flush();
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// === 2. 构造 OSS 文件路径 ===
|
||||
String path = "document/accept/" + entrustId + "/materialPhoto/materialallpic.docx";
|
||||
|
||||
// === 3. 从 OSS 读取 docx 模板流 ===
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
try {
|
||||
ossFile.fileGet(path, bos);
|
||||
byte[] templateArray = bos.toByteArray();
|
||||
|
||||
if (templateArray.length == 0) {
|
||||
throw new IOException("未读取到文件内容,请确认文件存在");
|
||||
}
|
||||
|
||||
// === 4. 调用远程 PDF 转换服务 ===
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(templateArray);
|
||||
MockMultipartFile mockMultipartFile = new MockMultipartFile(
|
||||
"file",
|
||||
"material.docx",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
bis
|
||||
);
|
||||
|
||||
Response word2pdfResponse = remoteWord2PDFService.word2pdf(mockMultipartFile);
|
||||
if (word2pdfResponse == null || word2pdfResponse.body() == null) {
|
||||
throw new IOException("PDF 转换服务失败,未返回有效响应");
|
||||
}
|
||||
|
||||
// === 5. 获取 PDF 内容并写入 response ===
|
||||
ByteArrayOutputStream outPDF = new ByteArrayOutputStream();
|
||||
IOUtils.copy(word2pdfResponse.body().asInputStream(), outPDF);
|
||||
byte[] pdfBytes = outPDF.toByteArray();
|
||||
|
||||
ossFile.fileSave(pdfPath, new ByteArrayInputStream(pdfBytes));
|
||||
|
||||
// === 6. 设置响应头,支持中文文件名 ===
|
||||
String filename = URLEncoder.encode("material.pdf", StandardCharsets.UTF_8.toString());
|
||||
response.setContentType("application/pdf");
|
||||
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + filename);
|
||||
response.setContentLength(pdfBytes.length);
|
||||
|
||||
// === 7. 输出 PDF 文件到客户端 ===
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
os.write(pdfBytes);
|
||||
os.flush();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("文件读取失败或未存在图片信息", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3058,13 +3058,40 @@ public class EntrustmentServiceImpl extends ServiceImpl<EntrustmentMapper, Entru
|
||||
entrustment.setId(IdWorker.get32UUID().toUpperCase());
|
||||
entrustment.setCaseId(caseEvent.getId());
|
||||
|
||||
// 创建嫌疑人信息
|
||||
this.save(entrustment);
|
||||
|
||||
List<Suspect> suspects = entrustmentDTO.getSuspects();
|
||||
if (suspects!=null&&suspects.size()>0){
|
||||
suspectService.addSuspectList(suspects,entrustment.getId());
|
||||
Integer type = entrustment.getEntrustmentType();
|
||||
|
||||
// 过滤掉所有字段为空或默认值的“空壳对象”
|
||||
List<Suspect> validSuspects = suspects == null ? new ArrayList<>() :
|
||||
suspects.stream()
|
||||
.filter(suspectService::isNotNull) // 保留至少一个字段非空的嫌疑人
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (suspects.size()!=validSuspects.size()){
|
||||
throw new RuntimeException("嫌疑人信息有误,请检查后重新填写!");
|
||||
}
|
||||
|
||||
if (type == 1) {
|
||||
// type 为 1 必须提供至少一个有效的嫌疑人
|
||||
if (validSuspects.isEmpty()) {
|
||||
throw new RuntimeException("生物样本的案件嫌疑人信息不能为空,请至少填写一位有效嫌疑人!");
|
||||
}
|
||||
} else {
|
||||
// type 不为 1,如果有填有效对象,就要做字段校验
|
||||
for (Suspect suspect : validSuspects) {
|
||||
if (!suspectService.isNotNull(suspect)) {
|
||||
throw new RuntimeException("嫌疑人信息有误,请检查后重新填写!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加有效的嫌疑人(可为空,addSuspectList 内部做判断也可以)
|
||||
if (!validSuspects.isEmpty()) {
|
||||
suspectService.addSuspectList(validSuspects, entrustment.getId());
|
||||
}
|
||||
|
||||
this.save(entrustment);
|
||||
return entrustment;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package digital.laboratory.platform.entrustment.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import digital.laboratory.platform.common.core.exception.CheckedException;
|
||||
import digital.laboratory.platform.common.core.util.R;
|
||||
import digital.laboratory.platform.entrustment.entity.CaseEvent;
|
||||
import digital.laboratory.platform.entrustment.entity.EntrustMaterialCheckoutResult;
|
||||
import digital.laboratory.platform.entrustment.entity.Entrustment;
|
||||
import digital.laboratory.platform.entrustment.entity.EntrustmentIdentificationMaterial;
|
||||
import digital.laboratory.platform.entrustment.entity.*;
|
||||
import digital.laboratory.platform.entrustment.enums.AnalysisOptionEnums;
|
||||
import digital.laboratory.platform.entrustment.enums.EntrustIdentificationSituationType;
|
||||
import digital.laboratory.platform.entrustment.service.*;
|
||||
@@ -17,9 +16,13 @@ import digital.laboratory.platform.sys.enums.entrust.EntrustBiologyType;
|
||||
import digital.laboratory.platform.sys.feign.RemoteCommDrugService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -53,88 +56,175 @@ public class ExcelUploadServiceImpl implements ExcelUploadService {
|
||||
@Resource
|
||||
private EntrustMaterialCheckoutResultService entrustMaterialCheckoutResultService;
|
||||
|
||||
@Resource
|
||||
private SuspectService suspectService;
|
||||
|
||||
/**
|
||||
* 上传两社人员名单excel文件
|
||||
* 上传两社人员名单Excel文件,并自动生成检材与检测结果数据
|
||||
*
|
||||
* @param file
|
||||
* @param entrustId
|
||||
* @return
|
||||
* @param file Excel文件(包含人员信息)
|
||||
* @param entrustId 委托ID
|
||||
* @return 是否成功导入
|
||||
* @throws Exception 发生异常时抛出
|
||||
*/
|
||||
@Override
|
||||
public Boolean uploadHairInspectExcel(MultipartFile file, String entrustId) throws Exception {
|
||||
|
||||
// 校验委托是否合法
|
||||
// 1. 校验委托合法性
|
||||
Entrustment entrustment = entrustmentService.getById(entrustId);
|
||||
if (entrustment == null) {
|
||||
throw new CheckedException(String.format("委托id为 %s 的委托信息不存在!"));
|
||||
throw new CheckedException(String.format("委托id为 %s 的委托信息不存在!", entrustId));
|
||||
}
|
||||
if (!entrustment.getOldIdentificationResult().equals(EntrustIdentificationSituationType.TWO_AGENCY.getDesc())) {
|
||||
throw new CheckedException("当前不支持两社人员之外的委托信息进行导入!");
|
||||
}
|
||||
|
||||
|
||||
// 校验案件信息是否合法
|
||||
// 2. 获取案件与毒品信息
|
||||
// 2.1 校验案件信息
|
||||
CaseEvent cj = caseEventService.validateCaseInfo(entrustment.getCaseId());
|
||||
// 默认取海洛因的毒品信息
|
||||
R<DrugLite> drugLiteR = remoteCommDrugService.getByName("海洛因");
|
||||
DrugLite heroin = drugLiteR.getData(); // 获取默认的海洛因数据
|
||||
R<List<DrugLite>> innerGetAllR = remoteCommDrugService.innerGetAll(); // 获取所有的毒品信息
|
||||
|
||||
// 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()));
|
||||
// 防止检材列表d
|
||||
List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterialList = new ArrayList<>();
|
||||
// 读取excel数据
|
||||
// 表头从第一行后开始读取
|
||||
Map<String, DrugLite> drugLiteMap = drugLiteList.stream()
|
||||
.collect(Collectors.toMap(DrugLite::getName, Function.identity()));
|
||||
|
||||
// 3. 读取Excel内容(从第一行数据开始读取)
|
||||
int headIndex = 1;
|
||||
List<Map<String, String>> data = ExcelUtils.readExcel(file, headIndex);
|
||||
|
||||
// 3.1 获取当前委托下已有检材数,作为orderNo起始编号
|
||||
int orderNo = entrustmentIdentificationMaterialService.lambdaQuery()
|
||||
.eq(EntrustmentIdentificationMaterial::getEntrustmentId, entrustId)
|
||||
.list()
|
||||
.size() + 1;
|
||||
List<EntrustMaterialCheckoutResult> results = new ArrayList<>();
|
||||
for (Map<String, String> datum : data) {
|
||||
EntrustmentIdentificationMaterial entrustmentIdentificationMaterial = new EntrustmentIdentificationMaterial();
|
||||
entrustmentIdentificationMaterial.setEntrustmentId(entrustment.getId());
|
||||
entrustmentIdentificationMaterial.setCaseId(entrustment.getCaseId());
|
||||
// 读取excel的值到检材实体
|
||||
entrustmentIdentificationMaterial.setName(datum.get("姓名") + "毛发");
|
||||
entrustmentIdentificationMaterial.setBiologyGender(datum.get("性别"));
|
||||
entrustmentIdentificationMaterial.setMaterialAge(Integer.valueOf(datum.get("年龄")));
|
||||
entrustmentIdentificationMaterial.setRemark(datum.get("身份证号"));
|
||||
entrustmentIdentificationMaterial.setDrawPlace(datum.get("采样单位"));
|
||||
entrustmentIdentificationMaterial.setCandidateDrugs(CollUtil.newArrayList(drugLiteMap.containsKey(datum.get("检测结果")) ? drugLiteMap.get(datum.get("检测结果")) : heroin));
|
||||
entrustmentIdentificationMaterial.setId(IdWorker.get32UUID().toUpperCase());
|
||||
.list().size() + 1;
|
||||
|
||||
List<DrugLite> candidateDrugs = entrustmentIdentificationMaterial.getCandidateDrugs();
|
||||
if (candidateDrugs.size() > 0) {
|
||||
EntrustMaterialCheckoutResult result = new EntrustMaterialCheckoutResult();
|
||||
result.setId(entrustmentIdentificationMaterial.getId());
|
||||
result.setQualitativeResult(JSON.toJSONString(candidateDrugs));
|
||||
result.setEntrustId(entrustId);
|
||||
results.add(result);
|
||||
// 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 (CollUtil.isNotEmpty(suspects)){
|
||||
suspectService.remove(Wrappers.<Suspect>lambdaQuery()
|
||||
.eq(Suspect::getEntrustId, entrustId));
|
||||
suspectService.addSuspectList(suspects, entrustId);
|
||||
}
|
||||
List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterialList = new ArrayList<>();
|
||||
|
||||
// 4. 遍历Excel数据行,构建检材与检测结果
|
||||
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)));
|
||||
}
|
||||
|
||||
// 设置默认值
|
||||
entrustmentIdentificationMaterial.setBiologyType(EntrustBiologyType.HAIR.getDesc()); // 生物样本检材类型
|
||||
entrustmentIdentificationMaterial.setType("1");
|
||||
entrustmentIdentificationMaterial.setTypeName("生物样本"); // 检材类型
|
||||
entrustmentIdentificationMaterial.setQuantity(new BigDecimal(50)); // 检材重量
|
||||
entrustmentIdentificationMaterial.setUnit("mg"); // 检材重量 单位
|
||||
entrustmentIdentificationMaterial.setForm("黑色头发"); // 检材性状
|
||||
entrustmentIdentificationMaterial.setFormName("黑色头发"); // 检材性状
|
||||
entrustmentIdentificationMaterial.setOrderNo(orderNo);
|
||||
entrustmentIdentificationMaterial.setImEntrustNumber(String.valueOf(orderNo));
|
||||
// 叠加
|
||||
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 {
|
||||
boolean matched = false;
|
||||
for (String drugName : drugs) {
|
||||
if (drugLiteMap.containsKey(drugName)) {
|
||||
matchedDrugs.add(drugLiteMap.get(drugName));
|
||||
matched = true;
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
matchedDrugs.add(drugLiteMap.get("海洛因"));
|
||||
}
|
||||
}
|
||||
material.setCandidateDrugs(matchedDrugs);
|
||||
// if (!matchedDrugs.isEmpty()) {
|
||||
// EntrustMaterialCheckoutResult result = new EntrustMaterialCheckoutResult();
|
||||
// result.setId(material.getId());
|
||||
// result.setQualitativeResult(JSON.toJSONString(matchedDrugs));
|
||||
// result.setEntrustId(entrustId);
|
||||
// results.add(result);
|
||||
// }
|
||||
|
||||
// 设置检材默认属性
|
||||
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++;
|
||||
entrustmentIdentificationMaterial.setPackComplete(true); //
|
||||
entrustmentIdentificationMaterial.setRtSampleQuantity(0); // 留存样个数 ->
|
||||
entrustmentIdentificationMaterial.setDrawTime(LocalDateTime.now()); // 提取时间 -> 当前时间
|
||||
entrustmentIdentificationMaterial.setAnalysisOption(AnalysisOptionEnums.QUALITATIVE.getCode()); // 默认设置检测项目 -> 定性
|
||||
// 设置检材编号
|
||||
entrustmentIdentificationMaterialService.setMaterialIdentificationNo(entrustmentIdentificationMaterial, cj);
|
||||
entrustmentIdentificationMaterial.setSample1No(sampleService.getNewSampleNo(entrustmentIdentificationMaterial.getImNo(), 1));
|
||||
entrustmentIdentificationMaterialList.add(entrustmentIdentificationMaterial);
|
||||
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 entrustmentIdentificationMaterialService.saveBatch(entrustmentIdentificationMaterialList) && entrustMaterialCheckoutResultService.saveBatch(results);
|
||||
// entrustMaterialCheckoutResultService.saveBatch(results);
|
||||
boolean isSave = entrustmentIdentificationMaterialService.saveBatch(entrustmentIdentificationMaterialList);
|
||||
String entrustReq = entrustmentService.buildEntrustReq(entrustmentIdentificationMaterialList);
|
||||
entrustment.setEntrustRequirement(entrustReq);
|
||||
entrustmentService.updateById(entrustment);
|
||||
// 5. 批量保存检材信息和检测结果
|
||||
return isSave;
|
||||
}
|
||||
|
||||
|
||||
public String getSexByIdNum(String idNumber) {
|
||||
// 去除空格并转换为大写
|
||||
idNumber = idNumber.trim().toUpperCase();
|
||||
|
||||
// 校验身份证长度
|
||||
if (idNumber.length() == 18) {
|
||||
try {
|
||||
// 提取性别
|
||||
int genderCode = Integer.parseInt(idNumber.substring(16, 17));
|
||||
return genderCode % 2 == 0 ? "女" : "男";
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public String getAgeByIdNum(String idNumber) {
|
||||
if (idNumber.length() == 18) {
|
||||
try {
|
||||
// 提取出生日期并计算年龄
|
||||
String birthDateStr = idNumber.substring(6, 14);
|
||||
LocalDate birthDate = LocalDate.parse(birthDateStr, DateTimeFormatter.BASIC_ISO_DATE);
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
long age = ChronoUnit.YEARS.between(birthDate, currentDate);
|
||||
return String.valueOf(age);
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,4 +85,12 @@ public class SuspectServiceImpl extends ServiceImpl<SuspectMapper, Suspect> impl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotNull(Suspect suspect){
|
||||
if (StringUtils.isEmpty(suspect.getName())||StringUtils.isEmpty(suspect.getIdNumber())){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
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;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 委托检材--检出定性定量结果信息
|
||||
*
|
||||
* @TableName b_entrust_material_checkout_result
|
||||
*/
|
||||
@Data
|
||||
@@ -60,4 +64,18 @@ public class EntrustMaterialCheckoutResultVO {
|
||||
@ApiModelProperty(value = "委托检材顺序号,由系统根据录入顺序生成")
|
||||
private Integer orderNo;
|
||||
|
||||
@ApiModelProperty(value = "检材性状")
|
||||
private String form;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "提取时间--贵阳新增需求")
|
||||
private LocalDateTime drawTime;
|
||||
|
||||
@ApiModelProperty(value = "提取地点--贵阳新增需求")
|
||||
private String drawPlace;
|
||||
|
||||
@ApiModelProperty(value = "嫌疑人身份证号码")
|
||||
private String suspectIdNum;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package digital.laboratory.platform.entrustment.vo;
|
||||
|
||||
import digital.laboratory.platform.entrustment.entity.Suspect;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SuspectDetectionVO extends Suspect {
|
||||
/**
|
||||
* 案件名称任务名称
|
||||
*/
|
||||
@ApiModelProperty(value="案件名称")
|
||||
private String caseName;
|
||||
|
||||
/**
|
||||
* 案情简要
|
||||
*/
|
||||
@ApiModelProperty(value="案情简要")
|
||||
private String caseBrief;
|
||||
|
||||
/**
|
||||
* 案件编号
|
||||
*/
|
||||
@ApiModelProperty(value="案件编号")
|
||||
private String acceptNo;
|
||||
|
||||
|
||||
/**
|
||||
* 案发时间
|
||||
*/
|
||||
@ApiModelProperty(value="案发时间")
|
||||
private LocalDate happenTime;
|
||||
|
||||
/**
|
||||
* 推送时间
|
||||
*/
|
||||
@ApiModelProperty(value="推送时间")
|
||||
private LocalDateTime pushTime;
|
||||
|
||||
/**
|
||||
* 检材检出结果
|
||||
*/
|
||||
@ApiModelProperty(value = "检材检测结果")
|
||||
List<EntrustMaterialCheckoutResultVO> results;
|
||||
|
||||
}
|
||||
@@ -274,7 +274,8 @@
|
||||
e.return_or_not,
|
||||
e.is_trans,
|
||||
e.material_image_flag,
|
||||
e.push_flag
|
||||
e.push_flag,
|
||||
e.platform_flag
|
||||
</sql>
|
||||
|
||||
<sql id="getEntrustmentVOSQL">
|
||||
|
||||
Reference in New Issue
Block a user