|
|
|
@ -694,136 +694,135 @@ public class EntrustmentIdentificationMaterialServiceImpl extends ServiceImpl<En |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public EntrustmentIdentificationMaterial bizAccept_Apply(EntrustmentIdentificationMaterial identificationMaterial, Integer opCode, DLPUser dlpUser) { |
|
|
|
|
public List<EntrustmentIdentificationMaterial> bizAccept_Apply_Batch(List<EntrustmentIdentificationMaterial> identificationMaterials, Integer opCode, DLPUser dlpUser) { |
|
|
|
|
if (opCode == null) { |
|
|
|
|
throw new RuntimeException(String.format("受理结果必须提供 opCode")); |
|
|
|
|
throw new RuntimeException("受理结果必须提供 opCode"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 检查委托原来的状态
|
|
|
|
|
EntrustmentIdentificationMaterial im = this.getById(identificationMaterial.getId()); |
|
|
|
|
if (im == null) { |
|
|
|
|
throw new RuntimeException(String.format("没有找到 id 为 %s 的检材", identificationMaterial.getId())); |
|
|
|
|
} |
|
|
|
|
// 用于存储处理后的检材信息
|
|
|
|
|
List<EntrustmentIdentificationMaterial> processedMaterials = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
Entrustment entrustment = entrustmentService.getById(im.getEntrustmentId()); |
|
|
|
|
if (entrustment == null) { |
|
|
|
|
throw new RuntimeException(String.format("没有找到 id 为 %s 的委托", im.getEntrustmentId())); |
|
|
|
|
} |
|
|
|
|
// 开始事务
|
|
|
|
|
try { |
|
|
|
|
for (EntrustmentIdentificationMaterial identificationMaterial : identificationMaterials) { |
|
|
|
|
// 检查委托原来的状态
|
|
|
|
|
EntrustmentIdentificationMaterial im = this.getById(identificationMaterial.getId()); |
|
|
|
|
if (im == null) { |
|
|
|
|
throw new RuntimeException(String.format("没有找到 id 为 %s 的检材", identificationMaterial.getId())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (entrustment.getStatus() != EntrustmentStatusConstants.ENTRUSTMENT_STATUS_WAITING_ACCEPT.getStatus()) { |
|
|
|
|
throw new RuntimeException("委托不在正在受理状态"); |
|
|
|
|
} |
|
|
|
|
Entrustment entrustment = entrustmentService.getById(im.getEntrustmentId()); |
|
|
|
|
if (entrustment == null) { |
|
|
|
|
throw new RuntimeException(String.format("没有找到 id 为 %s 的委托", im.getEntrustmentId())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//-------------------
|
|
|
|
|
// 更新数据库表数据
|
|
|
|
|
//-------------------
|
|
|
|
|
if (opCode == 1) { |
|
|
|
|
// 受理通过, 修改属性
|
|
|
|
|
String entrustAcceptNo = com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(entrustment.getAcceptNo()) ? entrustment.getAcceptNo() : ""; |
|
|
|
|
String acceptNo = ""; |
|
|
|
|
List<EntrustmentIdentificationMaterial> materialList = this.list(Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery() |
|
|
|
|
.eq(EntrustmentIdentificationMaterial::getEntrustmentId, im.getEntrustmentId()) |
|
|
|
|
.isNotNull(EntrustmentIdentificationMaterial::getAcceptNo)); |
|
|
|
|
//2024-3-26 修改:我们已经不需要在受理检材时生成受理编号,我们这时会生成受理顺序号,检材编号到最后受理完成的时候再生成!
|
|
|
|
|
if (entrustment.getDataSources() != 1) { |
|
|
|
|
if (materialList.size() > 0) { |
|
|
|
|
//说明该委托下,已经有受理的检材了,我们需要取出最大的那个编号生成新的编号
|
|
|
|
|
entrustAcceptNo = materialList.get(0).getAcceptNo(); |
|
|
|
|
entrustAcceptNo = entrustAcceptNo.substring(0, entrustAcceptNo.lastIndexOf("-")); |
|
|
|
|
log.info("该检材对应的委托下,已经有检材被受理,我们根据已受理的检材读取出的受理编号是{}", entrustAcceptNo); |
|
|
|
|
if (entrustment.getStatus() != EntrustmentStatusConstants.ENTRUSTMENT_STATUS_WAITING_ACCEPT.getStatus()) { |
|
|
|
|
throw new RuntimeException("委托不在正在受理状态"); |
|
|
|
|
} |
|
|
|
|
acceptNo = this.getNewMaterialAcceptNo(entrustAcceptNo); |
|
|
|
|
} else { |
|
|
|
|
if (materialList.size() > 0) { |
|
|
|
|
if (materialList.size() + 1 != im.getOrderNo()) { |
|
|
|
|
throw new RuntimeException(String.format("请按照当前页面检材的顺序进行受理,因为这会涉及到同步到大数据平台中的检材顺序!")); |
|
|
|
|
|
|
|
|
|
//-------------------
|
|
|
|
|
// 更新数据库表数据
|
|
|
|
|
//-------------------
|
|
|
|
|
if (opCode == 1) { |
|
|
|
|
// 受理通过, 修改属性
|
|
|
|
|
String entrustAcceptNo = com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(entrustment.getAcceptNo()) ? entrustment.getAcceptNo() : ""; |
|
|
|
|
String acceptNo = ""; |
|
|
|
|
|
|
|
|
|
List<EntrustmentIdentificationMaterial> materialList = this.list(Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery() |
|
|
|
|
.eq(EntrustmentIdentificationMaterial::getEntrustmentId, im.getEntrustmentId()) |
|
|
|
|
.isNotNull(EntrustmentIdentificationMaterial::getAcceptNo)); |
|
|
|
|
|
|
|
|
|
if (entrustment.getDataSources() != 1) { |
|
|
|
|
if (materialList.size() > 0) { |
|
|
|
|
entrustAcceptNo = materialList.get(0).getAcceptNo(); |
|
|
|
|
entrustAcceptNo = entrustAcceptNo.substring(0, entrustAcceptNo.lastIndexOf("-")); |
|
|
|
|
log.info("该检材对应的委托下,已经有检材被受理,我们根据已受理的检材读取出的受理编号是{}", entrustAcceptNo); |
|
|
|
|
} |
|
|
|
|
acceptNo = this.getNewMaterialAcceptNo(entrustAcceptNo); |
|
|
|
|
} else { |
|
|
|
|
acceptNo = String.valueOf(materialList.size() + 1); |
|
|
|
|
if (materialList.size() > 0) { |
|
|
|
|
if (materialList.size() + 1 != im.getOrderNo()) { |
|
|
|
|
throw new RuntimeException(String.format("请按照当前页面检材的顺序进行受理,因为这会涉及到同步到大数据平台中的检材顺序!")); |
|
|
|
|
} else { |
|
|
|
|
acceptNo = String.valueOf(materialList.size() + 1); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
acceptNo = "1"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
acceptNo = "1"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//设置受理编号
|
|
|
|
|
im.setAcceptNo(acceptNo); |
|
|
|
|
im.setProvidedSample1No(identificationMaterial.getProvidedSample1No()); |
|
|
|
|
im.setProvidedSample1FundQuantity(identificationMaterial.getProvidedSample1FundQuantity()); |
|
|
|
|
im.setProvidedSample1Quantity(identificationMaterial.getProvidedSample1Quantity()); |
|
|
|
|
|
|
|
|
|
im.setProvidedSample2Present(identificationMaterial.getProvidedSample2Present()); |
|
|
|
|
im.setProvidedSample2No(identificationMaterial.getProvidedSample2No()); |
|
|
|
|
im.setProvidedSample2FundQuantity(identificationMaterial.getProvidedSample2FundQuantity()); |
|
|
|
|
im.setProvidedSample2Quantity(identificationMaterial.getProvidedSample2Quantity()); |
|
|
|
|
|
|
|
|
|
im.setSplitedSample(identificationMaterial.getSplitedSample()); |
|
|
|
|
|
|
|
|
|
im.setFundQuantity(identificationMaterial.getFundQuantity()); |
|
|
|
|
im.setQuantity(identificationMaterial.getQuantity()); |
|
|
|
|
im.setSample1No(identificationMaterial.getSample1No()); |
|
|
|
|
im.setSample1FundQuantity(identificationMaterial.getSample1FundQuantity()); |
|
|
|
|
im.setSample1Quantity(identificationMaterial.getSample1Quantity()); |
|
|
|
|
im.setSample1BoxId(identificationMaterial.getSample1BoxId()); |
|
|
|
|
|
|
|
|
|
im.setSample2No(identificationMaterial.getSample2No()); |
|
|
|
|
im.setSample2FundQuantity(identificationMaterial.getSample2FundQuantity()); |
|
|
|
|
im.setSample2Quantity(identificationMaterial.getSample2Quantity()); |
|
|
|
|
im.setSample2BoxId(identificationMaterial.getSample2BoxId()); |
|
|
|
|
|
|
|
|
|
SampleBox sb1 = null; |
|
|
|
|
SampleBox sb2 = null; |
|
|
|
|
// 如果之前没有生成过样本编号, 现在填写样本重量了, 那么就生成样本编号
|
|
|
|
|
//if ((identificationMaterial.getSample1Present() != null) && (identificationMaterial.getSample1Present())) {
|
|
|
|
|
//12-4日我们不再将承载物信息设置成必填了
|
|
|
|
|
// if ((identificationMaterial.getSample1FundQuantity() == null) ||
|
|
|
|
|
// (identificationMaterial.getSample1FundQuantity().compareTo(0) == 0)) {
|
|
|
|
|
// throw new RuntimeException(String.format("样本1的承载物数量不能为空, 也不能为 0"));
|
|
|
|
|
// }
|
|
|
|
|
if ((identificationMaterial.getSample1Quantity() == null) || |
|
|
|
|
(identificationMaterial.getSample1Quantity().equals(BigDecimal.ZERO))) { |
|
|
|
|
throw new RuntimeException(String.format("样本1的数量不能为空, 也不能为 0")); |
|
|
|
|
} |
|
|
|
|
if (StrUtil.isBlank(identificationMaterial.getSample1No())) { |
|
|
|
|
im.setSample1No(sampleService.getNewSampleNo(im.getImNo(), 1)); |
|
|
|
|
} |
|
|
|
|
// 设置受理编号
|
|
|
|
|
im.setAcceptNo(acceptNo); |
|
|
|
|
im.setProvidedSample1No(identificationMaterial.getProvidedSample1No()); |
|
|
|
|
im.setProvidedSample1FundQuantity(identificationMaterial.getProvidedSample1FundQuantity()); |
|
|
|
|
im.setProvidedSample1Quantity(identificationMaterial.getProvidedSample1Quantity()); |
|
|
|
|
|
|
|
|
|
im.setProvidedSample2Present(identificationMaterial.getProvidedSample2Present()); |
|
|
|
|
im.setProvidedSample2No(identificationMaterial.getProvidedSample2No()); |
|
|
|
|
im.setProvidedSample2FundQuantity(identificationMaterial.getProvidedSample2FundQuantity()); |
|
|
|
|
im.setProvidedSample2Quantity(identificationMaterial.getProvidedSample2Quantity()); |
|
|
|
|
|
|
|
|
|
im.setSplitedSample(identificationMaterial.getSplitedSample()); |
|
|
|
|
|
|
|
|
|
im.setFundQuantity(identificationMaterial.getFundQuantity()); |
|
|
|
|
im.setQuantity(identificationMaterial.getQuantity()); |
|
|
|
|
im.setSample1No(identificationMaterial.getSample1No()); |
|
|
|
|
im.setSample1FundQuantity(identificationMaterial.getSample1FundQuantity()); |
|
|
|
|
im.setSample1Quantity(identificationMaterial.getSample1Quantity()); |
|
|
|
|
im.setSample1BoxId(identificationMaterial.getSample1BoxId()); |
|
|
|
|
|
|
|
|
|
im.setSample2No(identificationMaterial.getSample2No()); |
|
|
|
|
im.setSample2FundQuantity(identificationMaterial.getSample2FundQuantity()); |
|
|
|
|
im.setSample2Quantity(identificationMaterial.getSample2Quantity()); |
|
|
|
|
im.setSample2BoxId(identificationMaterial.getSample2BoxId()); |
|
|
|
|
|
|
|
|
|
if ((identificationMaterial.getSample1Quantity() == null) || |
|
|
|
|
(identificationMaterial.getSample1Quantity().equals(BigDecimal.ZERO))) { |
|
|
|
|
throw new RuntimeException(String.format("样本1的数量不能为空, 也不能为 0")); |
|
|
|
|
} |
|
|
|
|
if (StrUtil.isBlank(identificationMaterial.getSample1No())) { |
|
|
|
|
im.setSample1No(sampleService.getNewSampleNo(im.getImNo(), 1)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((identificationMaterial.getSample2Present() != null) && (identificationMaterial.getSample2Present())) { |
|
|
|
|
if ((identificationMaterial.getSample2Quantity() == null) || |
|
|
|
|
(identificationMaterial.getSample2Quantity().compareTo(BigDecimal.ZERO) == 0)) { |
|
|
|
|
throw new RuntimeException(String.format("样本2的数量不能为空, 也不能为 0")); |
|
|
|
|
} |
|
|
|
|
if (StrUtil.isBlank(identificationMaterial.getSample2No())) { |
|
|
|
|
im.setSample2No(sampleService.getNewSampleNo(im.getImNo(), 2)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ((identificationMaterial.getSample2Present() != null) && (identificationMaterial.getSample2Present())) { |
|
|
|
|
//12-4日我们不再将承载物信息设置成必填了
|
|
|
|
|
// if ((identificationMaterial.getSample2FundQuantity() == null) ||
|
|
|
|
|
// (identificationMaterial.getSample2FundQuantity().compareTo(0) == 0)) {
|
|
|
|
|
// throw new RuntimeException(String.format("样本2的承载物数量不能为空, 也不能为 0"));
|
|
|
|
|
// }
|
|
|
|
|
if ((identificationMaterial.getSample2Quantity() == null) || |
|
|
|
|
(identificationMaterial.getSample2Quantity().compareTo(BigDecimal.ZERO) == 0)) { |
|
|
|
|
throw new RuntimeException(String.format("样本2的数量不能为空, 也不能为 0")); |
|
|
|
|
} |
|
|
|
|
if (StrUtil.isBlank(identificationMaterial.getSample2No())) { |
|
|
|
|
im.setSample2No(sampleService.getNewSampleNo(im.getImNo(), 2)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
im.setAcceptPassed(opCode); |
|
|
|
|
im.setAcceptTime(LocalDateTime.now()); |
|
|
|
|
|
|
|
|
|
im.setAcceptPassed(opCode); |
|
|
|
|
im.setAcceptTime(LocalDateTime.now()); |
|
|
|
|
if (!this.updateById(im)) { |
|
|
|
|
throw new RuntimeException("保存检材信息失败"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// 受理未通过, 不修改属性
|
|
|
|
|
im.setAcceptPassed(opCode); |
|
|
|
|
im.setAcceptTime(LocalDateTime.now()); |
|
|
|
|
im.setAcceptNo(""); |
|
|
|
|
if (!this.updateById(im)) { |
|
|
|
|
throw new RuntimeException("保存检材信息失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!this.updateById(im)) { |
|
|
|
|
throw new RuntimeException("保存检材信息失败"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// 受理未通过, 不修改属性
|
|
|
|
|
im.setAcceptPassed(opCode); |
|
|
|
|
im.setAcceptTime(LocalDateTime.now()); |
|
|
|
|
im.setAcceptNo("");//如果拒绝受理
|
|
|
|
|
if (!this.updateById(im)) { |
|
|
|
|
throw new RuntimeException("保存检材信息失败"); |
|
|
|
|
// 从数据库表中取出保存的委托对象, 后续的操作我们以此为准
|
|
|
|
|
im = this.getById(identificationMaterial.getId()); |
|
|
|
|
if (im == null) { |
|
|
|
|
throw new RuntimeException(String.format("没有找到 id 为 %s 的检材", identificationMaterial.getId())); |
|
|
|
|
} |
|
|
|
|
processedMaterials.add(im); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
// 回滚事务
|
|
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
// 从数据库表中取出保存的委托对象, 后续的操作我们以此为准
|
|
|
|
|
im = this.getById(identificationMaterial.getId()); |
|
|
|
|
if (im == null) { |
|
|
|
|
throw new RuntimeException(String.format("没有找到 id 为 %s 的检材", identificationMaterial.getId())); |
|
|
|
|
} |
|
|
|
|
return im; |
|
|
|
|
|
|
|
|
|
return processedMaterials; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|