| | |
| | | import com.ruoyi.approve.service.IApproveNodeService; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.device.mapper.DeviceRepairMapper; |
| | | import com.ruoyi.device.pojo.DeviceRepair; |
| | |
| | | } |
| | | // 出库审批修改 (订单级别) |
| | | if(approveProcess.getApproveType().equals(7)){ |
| | | String[] split = approveProcess.getApproveReason().split(":"); |
| | | if (split.length > 1) { |
| | | String identifier = split[1]; |
| | | // 查找销售台账 |
| | | SalesLedger salesLedger = salesLedgerMapper.selectOne(new LambdaQueryWrapper<SalesLedger>() |
| | | .eq(SalesLedger::getSalesContractNo, identifier) |
| | | .last("limit 1")); |
| | | String scanRemark = approveProcess.getApproveRemark(); |
| | | if (org.springframework.util.StringUtils.hasText(scanRemark) && scanRemark.startsWith("SCAN_SHIP_DELIVERY_JSON:")) { |
| | | salesLedgerService.onScanShipDeliveryApproveOutcome(approveProcess, status); |
| | | } else { |
| | | String[] split = approveProcess.getApproveReason().split(":"); |
| | | if (split.length > 1) { |
| | | String identifier = split[1]; |
| | | SalesLedger salesLedger = salesLedgerMapper.selectOne(new LambdaQueryWrapper<SalesLedger>() |
| | | .eq(SalesLedger::getSalesContractNo, identifier) |
| | | .last("limit 1")); |
| | | |
| | | if (salesLedger != null) { |
| | | if(status.equals(2)){ |
| | | // 审批完成 -> 修改状态为审核通过,不扣除库存(扣除库存在发货台账补充信息) |
| | | updateSalesLedgerDeliveryStatus(salesLedger.getId(), 4); |
| | | updateShippingInfoStatusByOrder(salesLedger.getId(), "审核通过"); |
| | | } else if(status.equals(3)){ |
| | | updateSalesLedgerDeliveryStatus(salesLedger.getId(), 3); |
| | | // 更新关联的发货记录为审核拒绝 |
| | | updateShippingInfoStatusByOrder(salesLedger.getId(), "审核拒绝"); |
| | | } else if(status.equals(1)){ |
| | | updateSalesLedgerDeliveryStatus(salesLedger.getId(), 2); |
| | | updateShippingInfoStatusByOrder(salesLedger.getId(), "审核中"); |
| | | if (salesLedger != null) { |
| | | if(status.equals(2)){ |
| | | executeStandardShipmentApproved(salesLedger.getId()); |
| | | } else if(status.equals(3)){ |
| | | updateSalesLedgerDeliveryStatus(salesLedger.getId(), 3); |
| | | updateShippingInfoStatusByOrder(salesLedger.getId(), "审核拒绝"); |
| | | } else if(status.equals(1)){ |
| | | updateSalesLedgerDeliveryStatus(salesLedger.getId(), 2); |
| | | updateShippingInfoStatusByOrder(salesLedger.getId(), "审核中"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | .eq(ShippingInfo::getSalesLedgerId, salesLedgerId)); |
| | | } |
| | | |
| | | private void executeStandardShipmentApproved(Long salesLedgerId) { |
| | | if (salesLedgerId == null) return; |
| | | List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getSalesLedgerId, salesLedgerId) |
| | | .ne(ShippingInfo::getStatus, "已发货")); |
| | | |
| | | Date now = new Date(); |
| | | for (ShippingInfo byId : shippingInfos) { |
| | | SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(byId.getSalesLedgerProductId()); |
| | | if (salesLedgerProduct != null) { |
| | | stockUtils.substractStock(salesLedgerProduct.getSalesLedgerId(), salesLedgerProduct.getId(), salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), byId.getId()); |
| | | BigDecimal shipped = salesLedgerProduct.getShippedQuantity() == null ? BigDecimal.ZERO : salesLedgerProduct.getShippedQuantity(); |
| | | salesLedgerProduct.setShippedQuantity(shipped.add(salesLedgerProduct.getQuantity() == null ? BigDecimal.ZERO : salesLedgerProduct.getQuantity())); |
| | | salesLedgerProductMapper.updateById(salesLedgerProduct); |
| | | } |
| | | byId.setStatus("已发货"); |
| | | if (byId.getShippingDate() == null) { |
| | | byId.setShippingDate(now); |
| | | } |
| | | shippingInfoMapper.updateById(byId); |
| | | } |
| | | updateSalesLedgerDeliveryStatus(salesLedgerId, 5); |
| | | } |
| | | |
| | | private void updateSalesLedgerDeliveryStatus(Long salesLedgerId, Integer status) { |
| | | if (salesLedgerId == null) return; |
| | | SalesLedger salesLedger = salesLedgerMapper.selectById(salesLedgerId); |