|
|
@ -6,25 +6,35 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
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.core.exception.ValidateCodeException; |
|
|
|
import digital.laboratory.platform.common.mybatis.security.service.DLPUser; |
|
|
|
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.common.security.util.SecurityUtils; |
|
|
|
|
|
|
|
import digital.laboratory.platform.entrustment.convert.DrugLiteConvert; |
|
|
|
import digital.laboratory.platform.entrustment.dto.ApprovedUpdateEntrustDTO; |
|
|
|
import digital.laboratory.platform.entrustment.dto.ApprovedUpdateEntrustDTO; |
|
|
|
import digital.laboratory.platform.entrustment.dto.EntrustAlterApplyApproveDTO; |
|
|
|
import digital.laboratory.platform.entrustment.dto.EntrustAlterApplyApproveDTO; |
|
|
|
import digital.laboratory.platform.entrustment.dto.EntrustAlterApplyDTO; |
|
|
|
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.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.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.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.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.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDate; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -36,9 +46,21 @@ import java.util.stream.Collectors; |
|
|
|
public class EntrustAlterApplyServiceImpl extends ServiceImpl<EntrustAlterApplyMapper, EntrustAlterApply> |
|
|
|
public class EntrustAlterApplyServiceImpl extends ServiceImpl<EntrustAlterApplyMapper, EntrustAlterApply> |
|
|
|
implements EntrustAlterApplyService{ |
|
|
|
implements EntrustAlterApplyService{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private OssFile ossFile; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private CommonFeignService commonFeignService; |
|
|
|
private CommonFeignService commonFeignService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private CaseEventService caseEventService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private EntrustmentService entrustmentService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private EntrustmentIdentificationMaterialService entrustmentIdentificationMaterialService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<EntrustAlterApplyVO> voPage(EntrustAlterApplyQuery query) { |
|
|
|
public IPage<EntrustAlterApplyVO> voPage(EntrustAlterApplyQuery query) { |
|
|
@ -48,15 +70,13 @@ public class EntrustAlterApplyServiceImpl extends ServiceImpl<EntrustAlterApplyM |
|
|
|
query.setIsStaff(false); |
|
|
|
query.setIsStaff(false); |
|
|
|
} |
|
|
|
} |
|
|
|
IPage<EntrustAlterApplyVO> entrustAlterApplyVOPage = baseMapper.getEntrustAlterApplyVOPage(new Page<>(query.getCurrent(), query.getSize()), query); |
|
|
|
IPage<EntrustAlterApplyVO> entrustAlterApplyVOPage = baseMapper.getEntrustAlterApplyVOPage(new Page<>(query.getCurrent(), query.getSize()), query); |
|
|
|
entrustAlterApplyVOPage.getRecords().forEach(e -> { |
|
|
|
entrustAlterApplyVOPage.getRecords().forEach(this::fillVOInfo); |
|
|
|
fillVOInfo(e); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return entrustAlterApplyVOPage; |
|
|
|
return entrustAlterApplyVOPage; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 保存消息 |
|
|
|
* 保存消息 |
|
|
|
* @param dto |
|
|
|
* @param dto 保存的参数 |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -167,9 +187,155 @@ public class EntrustAlterApplyServiceImpl extends ServiceImpl<EntrustAlterApplyM |
|
|
|
return super.remove(Wrappers.<EntrustAlterApply>lambdaUpdate().in(EntrustAlterApply::getId,ids)); |
|
|
|
return super.remove(Wrappers.<EntrustAlterApply>lambdaUpdate().in(EntrustAlterApply::getId,ids)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 修改委托案件简要、鉴定要求, 并删除已生成的鉴定事项确认书和委托书 |
|
|
|
|
|
|
|
* @param dto |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Boolean updateEntrust(ApprovedUpdateEntrustDTO dto) { |
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|