| | |
| | | if (dto == null || dto.getInsOrder() == null || dto.getStandardTreeId() == null) { |
| | | throw new ErrorException("下单信息或标准不能为空"); |
| | | } |
| | | String sampleCode = StringUtils.trim(dto.getSampleCode()); |
| | | if (StringUtils.isBlank(sampleCode) || sampleCode.length() < 2) { |
| | | throw new ErrorException("样品编号不能为空且不能少于2位"); |
| | | } |
| | | StandardTree standard = standardTreeService.getById(dto.getStandardTreeId()); |
| | | if (standard == null || StringUtils.isBlank(standard.getSample()) |
| | | || standard.getSampleType() != null || standard.getModel() != null) { |
| | |
| | | |
| | | InsSample sample = new InsSample(); |
| | | sample.setInsOrderId(order.getId()); |
| | | sample.setSampleCode(dto.getSampleCode()); |
| | | sample.setSampleCode(sampleCode); |
| | | sample.setFactory(null); |
| | | sample.setLaboratory(standard.getLaboratory()); |
| | | sample.setSampleType(null); |
| | |
| | | if (insOrder.getState() == 1) { |
| | | //审核通过才会生成委托编号 |
| | | InsOrder order = this.getById(insOrder.getId()); |
| | | // 委托编号按送样日期独立流水,例如:LMSY-20260909-01。 |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() |
| | | .eq(InsSample::getInsOrderId, insOrder.getId()) |
| | | .orderByAsc(InsSample::getId)); |
| | | // 委托编号按送样日期生成;新聚单样品订单的末两位取样品编号末两位。 |
| | | // 历史/外部订单未填写送样日期时回退到当天,避免影响原有流程。 |
| | | LocalDate entrustDate = order.getSampleDate() == null ? LocalDate.now() : order.getSampleDate(); |
| | | String entrustCodePrefix = "LMSY-" |
| | | + entrustDate.format(DateTimeFormatter.BASIC_ISO_DATE) |
| | | + "-"; |
| | | String no = numberGenerator.generateNumberWithPrefix(2, |
| | | String no; |
| | | if (isDirectTemplateOrder(order, insSamples)) { |
| | | String sampleCode = insSamples.get(0).getSampleCode(); |
| | | if (StringUtils.isBlank(sampleCode) || sampleCode.trim().length() < 2) { |
| | | throw new ErrorException("样品编号不能为空且不能少于2位"); |
| | | } |
| | | sampleCode = sampleCode.trim(); |
| | | no = entrustCodePrefix + sampleCode.substring(sampleCode.length() - 2); |
| | | } else { |
| | | no = numberGenerator.generateNumberWithPrefix(2, |
| | | entrustCodePrefix, |
| | | InsOrder::getEntrustCode); |
| | | } |
| | | // 判断是否是季度检验, 是季度检验取消原材料季度检验下单 |
| | | if (InsOrderTypeConstants.QUARTERLY_TEST.equals(order.getOrderType())) { |
| | | ifsInventoryQuantityMapper.update(null, Wrappers.<IfsInventoryQuantity>lambdaUpdate() |
| | |
| | | } |
| | | |
| | | int count = 1; |
| | | // 查询样品表 |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() |
| | | .eq(InsSample::getInsOrderId, insOrder.getId())); |
| | | for (InsSample insSample : insSamples) { |
| | | if (StringUtils.isBlank(insSample.getSampleCode())) { |
| | | // 如果只有一个样品就不需要拼接数字 |