| | |
| | | |
| | | @Override |
| | | public boolean add(ShippingInfoDto req) { |
| | | // 校验outboundBatches唯一性 |
| | | if (req.getOutboundBatches() != null && !req.getOutboundBatches().isEmpty()) { |
| | | long count = this.count(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getOutboundBatches, req.getOutboundBatches())); |
| | | if (count > 0) { |
| | | throw new RuntimeException("出库批号已存在,请重新输入"); |
| | | } |
| | | } |
| | | this.save(req); |
| | | req.getBatchNoDetailList().forEach(item -> item.setShippingInfoId(req.getId())); |
| | | shippingProductDetailMapper.insert(req.getBatchNoDetailList()); |
| | | for (ShippingProductDetail shippingProductDetail : req.getBatchNoDetailList()) { |
| | | stockUtils.substractStock(shippingProductDetail.getProductModelId(), shippingProductDetail.getQuantity(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId(), shippingProductDetail.getBatchNo()); |
| | | stockUtils.substractStock(shippingProductDetail.getProductModelId(), shippingProductDetail.getQuantity(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), req.getId(), shippingProductDetail.getBatchNo(), req.getOutboundBatches()); |
| | | } |
| | | // 保存文件 |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.IMAGE, RecordTypeEnum.SHIPPING_INFO, req.getId(), req.getStorageBlobDTOs()); |
| | |
| | | public boolean addReq(ShippingInfoDto req) { |
| | | |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String sh = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SH","shipping_no",req.getCreateTime()); |
| | | // 设置创建时间为当前时间,确保编号查询正确 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | req.setCreateTime(now); |
| | | String sh = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SH", "shipping_no", now); |
| | | // 先保存发货单,再发起审批;无审核人自动通过时需要按发货编号回写发货状态。 |
| | | req.setShippingNo(sh); |
| | | req.setStatus("待审核"); |