feat(shipping): 1.发货的时候需要填出库批号,选入库批号
2.可以按批号,批量入库
3.销售退货将发货单号改成出库批号
| | |
| | | |
| | | import com.ruoyi.approve.pojo.ApprovalInstance; |
| | | import com.ruoyi.basic.dto.StorageBlobDTO; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | |
| | | private String createTimeStart; |
| | | |
| | | private List<StorageBlobDTO> storageBlobDTOs; |
| | | |
| | | @Schema(description = "出库批号") |
| | | private String outboundBatches; |
| | | } |
| | |
| | | private void handleShippingApprovalFinished(ApprovalInstance instance, String status) { |
| | | ShippingInfo shippingInfo = shippingInfoMapper.selectOne( |
| | | new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getId, instance.getTitle()) |
| | | .orderByDesc(ShippingInfo::getCreateTime) |
| | | .eq(ShippingInfo::getId, instance.getBusinessId()) |
| | | .last("limit 1") |
| | | ); |
| | | if (shippingInfo == null) { |
| | |
| | | * @param recordId |
| | | */ |
| | | public void substractStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo) { |
| | | substractStock(productModelId, quantity, recordType, recordId, batchNo, null); |
| | | } |
| | | |
| | | /** |
| | | * 合格出库(带出库批号) |
| | | * |
| | | * @param productModelId |
| | | * @param quantity |
| | | * @param recordType |
| | | * @param recordId |
| | | * @param batchNo |
| | | * @param outboundBatches 出库批号,如果为空则自动生成 |
| | | */ |
| | | public void substractStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo, String outboundBatches) { |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setRecordId(recordId); |
| | | stockInventoryDto.setRecordType(String.valueOf(recordType)); |
| | | stockInventoryDto.setQualitity(quantity); |
| | | stockInventoryDto.setProductModelId(productModelId); |
| | | stockInventoryDto.setBatchNo(batchNo); |
| | | stockInventoryDto.setOutboundBatches(outboundBatches); |
| | | stockInventoryService.addStockOutRecordOnly(stockInventoryDto); |
| | | } |
| | | |
| | |
| | | @Excel(name = "发货车牌号") |
| | | private String shippingCarNumber; |
| | | |
| | | @Schema(description = "出库批号") |
| | | @Excel(name = "出库批号") |
| | | private String outboundBatches; |
| | | |
| | | @Schema(description = "创建时间") |
| | | private LocalDateTime createTime; |
| | | |
| | |
| | | |
| | | @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()); |
| | |
| | | @Override |
| | | public boolean addReq(ShippingInfoDto req) { |
| | | |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String sh = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SH","shipping_no",req.getCreateTime()); |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | // 设置创建时间为当前时间,确保编号查询正确 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | req.setCreateTime(now); |
| | | String sh = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SH", "shipping_no", now); |
| | | // 先保存发货单,再发起审批;无审核人自动通过时需要按发货编号回写发货状态。 |
| | | req.setShippingNo(sh); |
| | | req.setStatus("待审核"); |
| | | boolean save = this.add(req); |
| | | // 发货审批 |
| | | ApprovalInstanceDto approvalInstance = new ApprovalInstanceDto(); |
| | | approvalInstance.setTemplateId(approvalTemplateMapper.selectOne(new LambdaQueryWrapper<ApprovalTemplate>().eq(ApprovalTemplate::getBusinessType,7L).orderByDesc(ApprovalTemplate::getId).last("LIMIT 1")).getId()); |
| | | approvalInstance.setTemplateName(approvalTemplateMapper.selectOne(new LambdaQueryWrapper<ApprovalTemplate>().eq(ApprovalTemplate::getBusinessType,7L).orderByDesc(ApprovalTemplate::getId).last("LIMIT 1")).getTemplateName()); |
| | | approvalInstance.setTemplateId(approvalTemplateMapper.selectOne(new LambdaQueryWrapper<ApprovalTemplate>().eq(ApprovalTemplate::getBusinessType, 7L).orderByDesc(ApprovalTemplate::getId).last("LIMIT 1")).getId()); |
| | | approvalInstance.setTemplateName(approvalTemplateMapper.selectOne(new LambdaQueryWrapper<ApprovalTemplate>().eq(ApprovalTemplate::getBusinessType, 7L).orderByDesc(ApprovalTemplate::getId).last("LIMIT 1")).getTemplateName()); |
| | | approvalInstance.setBusinessId(req.getId()); |
| | | approvalInstance.setBusinessType(7L); |
| | | approvalInstance.setCurrentLevel(1); |
| | | approvalInstance.setTitle(sh+"审批"); |
| | | approvalInstance.setTitle(sh + "审批"); |
| | | approvalInstance.setApplicantId(loginUser.getUserId()); |
| | | approvalInstance.setApplicantName(loginUser.getNickName()); |
| | | approvalInstance.setApplyTime(LocalDateTime.now()); |
| | |
| | | |
| | | @Schema(description = "产品id") |
| | | private Long productId; |
| | | |
| | | @Schema(description = "出库批号") |
| | | private String outboundBatches; |
| | | } |
| | |
| | | stockOutRecordDto.setProductModelId(stockInventoryDto.getProductModelId()); |
| | | stockOutRecordDto.setType("0"); |
| | | stockOutRecordDto.setRemark(stockInventoryDto.getRemark()); |
| | | stockOutRecordDto.setOutboundBatches(stockInventoryDto.getOutboundBatches()); |
| | | stockOutRecordService.add(stockOutRecordDto); |
| | | return true; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public int add(StockOutRecordDto stockOutRecordDto) { |
| | | String no = OrderUtils.countTodayByCreateTime(stockOutRecordMapper, "CK","outbound_batches", stockOutRecordDto.getCreateTime() != null ? stockOutRecordDto.getCreateTime() : LocalDateTime.now()); |
| | | stockOutRecordDto.setOutboundBatches(no); |
| | | // 如果传入了outboundBatches则使用,否则自动生成 |
| | | if (stockOutRecordDto.getOutboundBatches() == null || stockOutRecordDto.getOutboundBatches().isEmpty()) { |
| | | String no = OrderUtils.countTodayByCreateTime(stockOutRecordMapper, "CK","outbound_batches", stockOutRecordDto.getCreateTime() != null ? stockOutRecordDto.getCreateTime() : LocalDateTime.now()); |
| | | stockOutRecordDto.setOutboundBatches(no); |
| | | } |
| | | if (StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode().equals(stockOutRecordDto.getRecordType())){ |
| | | stockOutRecordDto.setApprovalStatus(3); |
| | | } |
| | |
| | | s.update_user, |
| | | s.tenant_id, |
| | | sl.sales_contract_no, |
| | | s.outbound_batches, |
| | | pm.model as specification_model, |
| | | pm.unit, |
| | | p.product_name, |