更新
This commit is contained in:
@@ -32,7 +32,7 @@ public class ApprovedUpdateEntrustDTO {
|
||||
// 使用内部类MaterialDTO
|
||||
@Data
|
||||
@ApiModel(value = "MaterialDTO", description = "委托检材")
|
||||
class MaterialDTO {
|
||||
public class MaterialDTO {
|
||||
|
||||
@ApiModelProperty(value = "检材id")
|
||||
private String id;
|
||||
|
||||
@@ -62,6 +62,11 @@ public class EntrustAlterApply extends BaseEntity {
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 更新操作记录,记录着更改前的信息和更改后的信息
|
||||
*/
|
||||
private String updateRecord;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -6,25 +6,35 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import digital.laboratory.platform.common.core.constant.OSSDirectoryConstants;
|
||||
import digital.laboratory.platform.common.core.exception.ValidateCodeException;
|
||||
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.convert.DrugLiteConvert;
|
||||
import digital.laboratory.platform.entrustment.dto.ApprovedUpdateEntrustDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.EntrustAlterApplyApproveDTO;
|
||||
import digital.laboratory.platform.entrustment.dto.EntrustAlterApplyDTO;
|
||||
import digital.laboratory.platform.entrustment.entity.CaseEvent;
|
||||
import digital.laboratory.platform.entrustment.entity.EntrustAlterApply;
|
||||
import digital.laboratory.platform.entrustment.entity.Entrustment;
|
||||
import digital.laboratory.platform.entrustment.entity.EntrustmentIdentificationMaterial;
|
||||
import digital.laboratory.platform.entrustment.enums.EntrustAlterApplyStatus;
|
||||
import digital.laboratory.platform.entrustment.query.EntrustAlterApplyQuery;
|
||||
import digital.laboratory.platform.entrustment.service.CommonFeignService;
|
||||
import digital.laboratory.platform.entrustment.service.EntrustAlterApplyService;
|
||||
import digital.laboratory.platform.entrustment.mapper.EntrustAlterApplyMapper;
|
||||
import digital.laboratory.platform.entrustment.query.EntrustAlterApplyQuery;
|
||||
import digital.laboratory.platform.entrustment.service.*;
|
||||
import digital.laboratory.platform.entrustment.utils.EntrustUtils;
|
||||
import digital.laboratory.platform.entrustment.vo.EntrustAlterApplyVO;
|
||||
import digital.laboratory.platform.sys.feign.RemoteUserService;
|
||||
import digital.laboratory.platform.sys.entity.DrugLite;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -36,9 +46,21 @@ import java.util.stream.Collectors;
|
||||
public class EntrustAlterApplyServiceImpl extends ServiceImpl<EntrustAlterApplyMapper, EntrustAlterApply>
|
||||
implements EntrustAlterApplyService{
|
||||
|
||||
@Resource
|
||||
private OssFile ossFile;
|
||||
|
||||
@Resource
|
||||
private CommonFeignService commonFeignService;
|
||||
|
||||
@Resource
|
||||
private CaseEventService caseEventService;
|
||||
|
||||
@Resource
|
||||
private EntrustmentService entrustmentService;
|
||||
|
||||
@Resource
|
||||
private EntrustmentIdentificationMaterialService entrustmentIdentificationMaterialService;
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<EntrustAlterApplyVO> voPage(EntrustAlterApplyQuery query) {
|
||||
@@ -48,15 +70,13 @@ public class EntrustAlterApplyServiceImpl extends ServiceImpl<EntrustAlterApplyM
|
||||
query.setIsStaff(false);
|
||||
}
|
||||
IPage<EntrustAlterApplyVO> entrustAlterApplyVOPage = baseMapper.getEntrustAlterApplyVOPage(new Page<>(query.getCurrent(), query.getSize()), query);
|
||||
entrustAlterApplyVOPage.getRecords().forEach(e -> {
|
||||
fillVOInfo(e);
|
||||
});
|
||||
entrustAlterApplyVOPage.getRecords().forEach(this::fillVOInfo);
|
||||
return entrustAlterApplyVOPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存消息
|
||||
* @param dto
|
||||
* @param dto 保存的参数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@@ -167,9 +187,155 @@ public class EntrustAlterApplyServiceImpl extends ServiceImpl<EntrustAlterApplyM
|
||||
return super.remove(Wrappers.<EntrustAlterApply>lambdaUpdate().in(EntrustAlterApply::getId,ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改委托案件简要、鉴定要求, 并删除已生成的鉴定事项确认书和委托书
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateEntrust(ApprovedUpdateEntrustDTO dto) {
|
||||
return null;
|
||||
Entrustment entrustment = validUpdateInfoAndGetEntrustInfo(dto);
|
||||
// 提取委托id
|
||||
StringBuilder updateRecordBuilder = new StringBuilder();
|
||||
String entrustmentId = entrustment.getId();
|
||||
CaseEvent oldCaseInfo = caseEventService.getById(entrustment.getCaseId());
|
||||
caseEventService.update(Wrappers.<CaseEvent>lambdaUpdate().eq(CaseEvent::getId, entrustment.getCaseId()).set(CaseEvent::getCaseBrief, dto.getCaseBrief()));
|
||||
// 添加更新记录
|
||||
updateRecordBuilder.append("操作记录:\\n").append("该委托案件的案件简要由 [").append(oldCaseInfo.getCaseBrief()).append("] 更改为 [").append(dto.getCaseBrief()).append("] 。");
|
||||
updateRecordBuilder.append("检材信息的更新记录:");
|
||||
// 2.修改检材 信息
|
||||
// 这里之所以要取未更新前的信息是为了留痕
|
||||
Map<String, EntrustmentIdentificationMaterial> oldInfoMap = entrustmentIdentificationMaterialService.list(Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery()
|
||||
.eq(EntrustmentIdentificationMaterial::getEntrustmentId, entrustmentId)
|
||||
.orderByAsc(EntrustmentIdentificationMaterial::getOrderNo))
|
||||
.stream().collect(Collectors.toMap(EntrustmentIdentificationMaterial::getId, Function.identity()));
|
||||
List<ApprovedUpdateEntrustDTO.MaterialDTO> materialList = dto.getMaterialList();
|
||||
Integer index = 1;
|
||||
List<EntrustmentIdentificationMaterial> entrustmentIdentificationMaterialList = new ArrayList<>();
|
||||
for (ApprovedUpdateEntrustDTO.MaterialDTO item : materialList) {
|
||||
String materialId = item.getId();
|
||||
String name = item.getName();
|
||||
List<DrugLite> candidateDrugs = item.getCandidateDrugs();
|
||||
String renewDrugsStr = candidateDrugs.stream().map(DrugLite::getName).collect(Collectors.joining("、"));
|
||||
Integer analysisOption = item.getAnalysisOption();
|
||||
EntrustmentIdentificationMaterial oldMaterial = oldInfoMap.get(materialId);
|
||||
String oldDrugsStr = DrugLiteConvert.convertDirtyLiteByJSON(oldMaterial.getCandidateDrugs()).stream().map(DrugLite::getName).collect(Collectors.joining("、"));
|
||||
// 判断有没有对这个检材进行修改oldMaterial.getName().equals(name) && oldMaterial.getAnalysisOption().equals(analysisOption) && oldDrugsStr.equals(renewDrugsStr)
|
||||
|
||||
boolean equalsName = oldMaterial.getName().equals(name);
|
||||
boolean equalsAnalysisOption = oldMaterial.getAnalysisOption().equals(analysisOption);
|
||||
boolean equalsDrugInfo = oldDrugsStr.equals(renewDrugsStr);
|
||||
if (equalsName && equalsAnalysisOption && equalsDrugInfo) {
|
||||
// 信息并没有修改,不操作
|
||||
continue;
|
||||
}
|
||||
updateRecordBuilder
|
||||
.append("\\n")
|
||||
.append(index++)
|
||||
.append(".原检材编号为 [")
|
||||
.append(oldMaterial.getImNo())
|
||||
.append("] 的检材信息");
|
||||
if (!equalsName) {
|
||||
updateRecordBuilder
|
||||
.append(" 疑似物种类由 [")
|
||||
.append(oldMaterial.getName())
|
||||
.append("] 更改为 [")
|
||||
.append(name).append("]");
|
||||
}
|
||||
if (!equalsAnalysisOption) {
|
||||
updateRecordBuilder
|
||||
.append(" 分析项目由 [")
|
||||
.append(EntrustUtils.getZhCnName(oldMaterial.getAnalysisOption()))
|
||||
.append("] 更改为 [")
|
||||
.append(EntrustUtils.getZhCnName(analysisOption)).append("]");
|
||||
}
|
||||
if (!equalsDrugInfo) {
|
||||
updateRecordBuilder
|
||||
.append(" 候选毒品列表由 [")
|
||||
.append(oldDrugsStr)
|
||||
.append("] 更改为 [")
|
||||
.append(renewDrugsStr).append("]");
|
||||
}
|
||||
updateRecordBuilder.append("。");
|
||||
EntrustmentIdentificationMaterial entrustmentIdentificationMaterial = new EntrustmentIdentificationMaterial();
|
||||
entrustmentIdentificationMaterial.setId(materialId);
|
||||
entrustmentIdentificationMaterial.setName(name);
|
||||
entrustmentIdentificationMaterial.setCandidateDrugs(candidateDrugs);
|
||||
entrustmentIdentificationMaterial.setAnalysisOption(analysisOption);
|
||||
entrustmentIdentificationMaterialList.add(entrustmentIdentificationMaterial);
|
||||
}
|
||||
entrustmentIdentificationMaterialService.updateBatchById(entrustmentIdentificationMaterialList);
|
||||
// 3. 更新委托鉴定要求
|
||||
updateEntrustmentRequirement(entrustmentId, entrustment);
|
||||
// 如果确认完成,则删除鉴定事项确认书和委托书,并更新申请状态为已完成
|
||||
if (dto.getFinished()) {
|
||||
// 4.删除鉴定事项确认书和委托书
|
||||
deleteConfirmEntrustLetter(entrustment.getEntrustmentNo(), entrustmentId);
|
||||
}
|
||||
return super.update(Wrappers.<EntrustAlterApply>lambdaUpdate().eq(EntrustAlterApply::getId, entrustment.getId())
|
||||
.set(EntrustAlterApply::getUpdateRecord, updateRecordBuilder.toString())
|
||||
.set(dto.getFinished(), EntrustAlterApply::getStatus, EntrustAlterApplyStatus.FINISHED.getStatus()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新鉴定要求
|
||||
* @param entrustmentId
|
||||
* @param entrustment
|
||||
*/
|
||||
private void updateEntrustmentRequirement(String entrustmentId, Entrustment entrustment) {
|
||||
List<EntrustmentIdentificationMaterial> renewList = entrustmentIdentificationMaterialService.list(Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery()
|
||||
.eq(EntrustmentIdentificationMaterial::getEntrustmentId, entrustmentId)
|
||||
.orderByAsc(EntrustmentIdentificationMaterial::getOrderNo));
|
||||
entrustment.setEntrustRequirement(entrustmentService.buildEntrustReq(renewList));
|
||||
entrustmentService.updateById(entrustment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除委托书和鉴定事项确认书
|
||||
* @param entrustmentNo
|
||||
* @param entrustmentId
|
||||
*/
|
||||
private void deleteConfirmEntrustLetter(String entrustmentNo, String entrustmentId) {
|
||||
String identifyItemsConfirmLetterFileName = "鉴定事项确认书-" + entrustmentNo;
|
||||
// 鉴定确认书存储路径
|
||||
String identifyItemsConfirmLetterPdfFilePath = OSSDirectoryConstants.IDENTIFY_BOOK_DIRECTORY + "/" + entrustmentId + "/" + identifyItemsConfirmLetterFileName + ".pdf";
|
||||
String identifyItemsConfirmLetterWordFilePath = OSSDirectoryConstants.IDENTIFY_BOOK_DIRECTORY + "/" + entrustmentId + "/" + identifyItemsConfirmLetterFileName + ".docx";
|
||||
String entrustmentLetterFileName = "鉴定委托书" + "-" + entrustmentNo;
|
||||
// 转换临时目录中的 word 文档为 PDF
|
||||
String entrustmentLetterFileNamePdfFilePath = OSSDirectoryConstants.DOCUMENT_ENTRUSTMENT_DIRECTORY + "/" + entrustmentId + "/" + entrustmentLetterFileName + ".docx";
|
||||
|
||||
try {
|
||||
ossFile.fileDelete(identifyItemsConfirmLetterWordFilePath);
|
||||
ossFile.fileDelete(identifyItemsConfirmLetterPdfFilePath);
|
||||
ossFile.fileDelete(entrustmentLetterFileNamePdfFilePath);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ValidateCodeException("删除鉴定委托书和鉴定事项确认书失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验更新数据是否合法,并且返回委托信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
private Entrustment validUpdateInfoAndGetEntrustInfo(ApprovedUpdateEntrustDTO dto) {
|
||||
// 判断当前申请状态是否审核通过
|
||||
EntrustAlterApply entrustAlterApply = super.getById(dto.getId());
|
||||
if (entrustAlterApply == null) {
|
||||
throw new ValidateCodeException("申请记录不存在!");
|
||||
}
|
||||
if (!entrustAlterApply.getStatus().equals(EntrustAlterApplyStatus.APPLY_SUCCESS.getStatus())) {
|
||||
throw new ValidateCodeException("状态不合法,当前申请状态不允许修改委托信息!");
|
||||
}
|
||||
// 状态合法,开始修改委托信息
|
||||
// 1. 修改委托案件简要
|
||||
Entrustment entrustment = entrustmentService.getById(dto.getId());
|
||||
if (entrustment == null) {
|
||||
throw new ValidateCodeException("修改的委托记录不存在!");
|
||||
}
|
||||
return entrustment;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,7 @@ import digital.laboratory.platform.entrustment.handler.AppStartupRunner;
|
||||
import digital.laboratory.platform.entrustment.mapper.EntrustmentMapper;
|
||||
import digital.laboratory.platform.entrustment.misc.ProcessFlowMapper;
|
||||
import digital.laboratory.platform.entrustment.service.*;
|
||||
import digital.laboratory.platform.entrustment.utils.EntrustUtils;
|
||||
import digital.laboratory.platform.entrustment.vo.EntrustmentIdentificationMaterialVO;
|
||||
import digital.laboratory.platform.entrustment.vo.EntrustmentVO;
|
||||
import digital.laboratory.platform.entrustment.vo.MaterialListForBookVo;
|
||||
@@ -833,7 +834,7 @@ public class EntrustmentServiceImpl extends ServiceImpl<EntrustmentMapper, Entru
|
||||
sbDrugDes.append(item.getName()).append("、");
|
||||
});
|
||||
sbDrugDes.delete(sbDrugDes.length() - 1, sbDrugDes.length());//删除多余的连接号
|
||||
sbAnalysisDes.append(getZhCnName(materialObj.getAnalysisOption()));
|
||||
sbAnalysisDes.append(EntrustUtils.getZhCnName(materialObj.getAnalysisOption()));
|
||||
}
|
||||
executeCount++;
|
||||
}
|
||||
@@ -864,7 +865,7 @@ public class EntrustmentServiceImpl extends ServiceImpl<EntrustmentMapper, Entru
|
||||
sbDrugDes.append(item.getName()).append("、");
|
||||
});
|
||||
sbDrugDes.delete(sbDrugDes.length() - 1, sbDrugDes.length());//删除多余的连接号
|
||||
sbAnalysisDes.append(getZhCnName(materialObj.getAnalysisOption()));
|
||||
sbAnalysisDes.append(EntrustUtils.getZhCnName(materialObj.getAnalysisOption()));
|
||||
}
|
||||
executeCount++;
|
||||
}
|
||||
@@ -876,29 +877,6 @@ public class EntrustmentServiceImpl extends ServiceImpl<EntrustmentMapper, Entru
|
||||
return req1 + req2 + req3;
|
||||
}
|
||||
|
||||
//获取分析项目的中文名字
|
||||
private String getZhCnName(int value) {
|
||||
String retName = "";
|
||||
switch (value) {
|
||||
case 1:
|
||||
retName = "定性";
|
||||
break;
|
||||
case 2:
|
||||
retName = "定量";
|
||||
break;
|
||||
case 3:
|
||||
retName = "定性定量";
|
||||
break;
|
||||
case 4:
|
||||
retName = "关联性";
|
||||
break;
|
||||
case 5:
|
||||
retName = "其他";
|
||||
break;
|
||||
}
|
||||
return retName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取毒品筛查列表
|
||||
*
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package digital.laboratory.platform.entrustment.utils;
|
||||
|
||||
// 委托系统工具类
|
||||
public class EntrustUtils {
|
||||
|
||||
//获取分析项目的中文名字
|
||||
public static String getZhCnName(int value) {
|
||||
String retName = "";
|
||||
switch (value) {
|
||||
case 1:
|
||||
retName = "定性";
|
||||
break;
|
||||
case 2:
|
||||
retName = "定量";
|
||||
break;
|
||||
case 3:
|
||||
retName = "定性定量";
|
||||
break;
|
||||
case 4:
|
||||
retName = "关联性";
|
||||
break;
|
||||
case 5:
|
||||
retName = "其他";
|
||||
break;
|
||||
}
|
||||
return retName;
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,12 @@ public class EntrustAlterApplyVO {
|
||||
@ApiModelProperty(value = "原因")
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 更新操作记录,记录着更改前的信息和更改后的信息
|
||||
*/
|
||||
@ApiModelProperty(value = "更新操作记录,记录着更改前的信息和更改后的信息")
|
||||
private String updateRecord;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
<result property="applicant" column="applicant" jdbcType="VARCHAR"/>
|
||||
<result property="applyDate" column="apply_date" jdbcType="TIMESTAMP"/>
|
||||
<result property="applyOrgId" column="apply_org_id" jdbcType="VARCHAR"/>
|
||||
<result property="applyReason" column="apply_reason" jdbcType="VARCHAR"/>
|
||||
<result property="reviewer" column="reviewer" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="status" jdbcType="TINYINT"/>
|
||||
<result property="reason" column="reason" jdbcType="VARCHAR"/>
|
||||
<result property="updateRecord" column="update_record" jdbcType="VARCHAR"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
@@ -21,9 +23,10 @@
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,entrust_id,applicant,
|
||||
apply_date,apply_org_id,reviewer,
|
||||
status,reason,create_time,
|
||||
create_by,update_time,update_by
|
||||
apply_date,apply_org_id,apply_reason,
|
||||
reviewer,status,reason,
|
||||
update_record,create_time,create_by,
|
||||
update_time,update_by
|
||||
</sql>
|
||||
|
||||
<!-- 连接委托表查询委托案件名称-->
|
||||
|
||||
Reference in New Issue
Block a user