Commit 39a65541 by lijingjing

样品编号不一致问题修改;

parent a7d78e6d
...@@ -96,7 +96,10 @@ public class ContractSamplingServiceImpl extends BaseServiceImpl<ContractSamplin ...@@ -96,7 +96,10 @@ public class ContractSamplingServiceImpl extends BaseServiceImpl<ContractSamplin
sampleList.forEach(t -> { sampleList.forEach(t -> {
RestAssert.fail(null == t.getType(), "样品类型为空"); RestAssert.fail(null == t.getType(), "样品类型为空");
RestAssert.fail(StringUtils.isBlank(t.getName()), "样品名称为空"); RestAssert.fail(StringUtils.isBlank(t.getName()), "样品名称为空");
initSamplingCode(t); // 编号不为空,赋值
if (StringUtils.isBlank(t.getCode())) {
initSamplingCode(t);
}
t.setMaterialId(contractSample.getMaterialId()); t.setMaterialId(contractSample.getMaterialId());
}); });
return saveOrUpdateBatch(sampleList); return saveOrUpdateBatch(sampleList);
......
...@@ -113,6 +113,9 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> ...@@ -113,6 +113,9 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
@Autowired @Autowired
private IMaterialService materialService; private IMaterialService materialService;
@Autowired
private IContractSamplingService contractSamplingService;
@Override @Override
public Page<Entrust> page(Page<Entrust> page, Entrust entrust) { public Page<Entrust> page(Page<Entrust> page, Entrust entrust) {
...@@ -316,15 +319,29 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> ...@@ -316,15 +319,29 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
* 样品编号处理 * 样品编号处理
*/ */
private void handleSampleCode(Entrust entrust, EntrustSample sample) { private void handleSampleCode(Entrust entrust, EntrustSample sample) {
String sampleCode = sample.getCode(); String sampleCode = sample.getCode(), secondCode = sample.getSecondCode(), thirdCode = sample.getThirdCode();
if (isExistSampleCode(sample) && StringUtils.isBlank(sampleCode)) { if (isExistSampleCode(sample) && StringUtils.isBlank(sampleCode)) {
throw new PatznException("样品编号为空"); throw new PatznException("样品编号为空");
} }
// 非已有编码物质为空时,需要生成样品编号 // 非已有编码物质为空时,需要生成样品编号
// 生成样品编号 // 若有采样ID,样品编号自动获取
initSampleCode(entrust, sample); Long samplingId = sample.getSamplingId();
if (StringUtils.isNotBlank(sampleCode)) { if (null != samplingId) {
sample.setCode(sampleCode); ContractSampling sampling = contractSamplingService.getById(samplingId);
sample.setCode(sampling.getCode()).setFirstCode(sampling.getFirstCode())
.setSecondCode(sampling.getSecondCode()).setThirdCode(sampling.getThirdCode());
} else {
initSampleCode(entrust, sample);
if (StringUtils.isNotBlank(sampleCode)) {
sample.setCode(sampleCode);
sample.setFirstCode(sampleCode);
}
if (StringUtils.isNotBlank(secondCode)) {
sample.setSecondCode(secondCode);
}
if (StringUtils.isNotBlank(thirdCode)) {
sample.setThirdCode(thirdCode);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment