| | |
| | | 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; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Arrays; |
| | | import java.util.Comparator; |
| | |
| | | purchaseLedger.setApprovalStatus(3); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(new QueryWrapper<SalesLedgerProduct>() |
| | | .lambda().eq(SalesLedgerProduct::getSalesLedgerId, purchaseLedger.getId()).eq(SalesLedgerProduct::getType, 2)); |
| | | boolean hasCheckedProduct = false; |
| | | for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) { |
| | | // 质检 |
| | | if (salesLedgerProduct.getIsChecked()) { |
| | | hasCheckedProduct = true; |
| | | purchaseLedgerServiceImpl.addQualityInspect(purchaseLedger, salesLedgerProduct); |
| | | }else { |
| | | //直接入库 |
| | | stockUtils.addStock(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(), purchaseLedger.getId()); |
| | | stockUtils.addStock(null, salesLedgerProduct.getId(), salesLedgerProduct.getProductModelId(), |
| | | salesLedgerProduct.getQuantity(), StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(), salesLedgerProduct.getId()); |
| | | BigDecimal oldStocked = salesLedgerProduct.getStockedQuantity() == null ? BigDecimal.ZERO : salesLedgerProduct.getStockedQuantity(); |
| | | BigDecimal orderQty = salesLedgerProduct.getQuantity() == null ? BigDecimal.ZERO : salesLedgerProduct.getQuantity(); |
| | | BigDecimal newStocked = oldStocked.add(orderQty); |
| | | salesLedgerProduct.setStockedQuantity(newStocked); |
| | | salesLedgerProduct.setProductStockStatus(2); |
| | | salesLedgerProduct.fillRemainingQuantity(); |
| | | salesLedgerProductMapper.updateById(salesLedgerProduct); |
| | | } |
| | | } |
| | | purchaseLedger.setStockStatus(hasCheckedProduct ? 0 : 2); |
| | | } else if (status.equals(3)) { |
| | | // 拒绝 |
| | | purchaseLedger.setApprovalStatus(4); |
| | |
| | | SalesLedger salesLedger = salesLedgerMapper.selectOne(new LambdaQueryWrapper<SalesLedger>() |
| | | .eq(SalesLedger::getSalesContractNo, identifier) |
| | | .last("limit 1")); |
| | | |
| | | |
| | | if (salesLedger != null) { |
| | | if(status.equals(2)){ |
| | | // 审批完成 -> 自动扣除库存 |
| | | try { |
| | | shippingInfoService.deductStockByOrder(salesLedger.getId(), null); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("自动扣除库存失败: " + e.getMessage()); |
| | | } |
| | | // 审批完成 -> 修改状态为审核通过,不扣除库存 (扣除库存移至发货台账补充信息阶段) |
| | | updateSalesLedgerDeliveryStatus(salesLedger.getId(), 4); |
| | | updateShippingInfoStatusByOrder(salesLedger.getId(), "审核通过"); |
| | | } else if(status.equals(3)){ |
| | | updateSalesLedgerDeliveryStatus(salesLedger.getId(), 3); |
| | | // 更新关联的发货记录为审核拒绝 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 绑定附件 |
| | | if(!CollectionUtils.isEmpty(approveNode.getTempFileIds()) && approveNode.getApproveNodeStatus() == 1){ |
| | | tempFileService.migrateTempFilesToFormal(approveNode.getId(), approveNode.getTempFileIds(), FileNameType.ApproveNode.getValue()); |