| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.google.common.math.LongMath; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | |
| | | import com.ruoyi.procurementrecord.pojo.ProcurementRecordStorage; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordOutService; |
| | | import com.ruoyi.procurementrecord.service.ProcurementRecordService; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.sales.mapper.ShipmentApprovalMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | |
| | | private ProcurementRecordOutService procurementRecordOutService; |
| | | @Autowired |
| | | private ProcurementRecordService procurementRecordStorageService; |
| | | @Autowired |
| | | private StockUtils stockUtils; |
| | | |
| | | @GetMapping("/listPage") |
| | | @ApiOperation("发货审批列表") |
| | |
| | | |
| | | // 审批通过 |
| | | if (req.getApproveStatus() == 3) { |
| | | // 查询采购入库记录 |
| | | LambdaQueryWrapper<ProcurementRecordStorage> lambdaQueryWrapper = new LambdaQueryWrapper<ProcurementRecordStorage>() |
| | | .eq(ProcurementRecordStorage::getSalesLedgerProductId, req.getSalesLedgerProductId()); |
| | | ProcurementRecordStorage procurementRecordStorage = procurementRecordStorageService.getOne(lambdaQueryWrapper); |
| | | |
| | | if (procurementRecordStorage == null) { |
| | | // 保证前面的修改全部回滚 |
| | | throw new ServiceException("采购记录不存在,审批回滚"); |
| | | } |
| | | // // 查询采购入库记录 |
| | | // LambdaQueryWrapper<ProcurementRecordStorage> lambdaQueryWrapper = new LambdaQueryWrapper<ProcurementRecordStorage>() |
| | | // .eq(ProcurementRecordStorage::getSalesLedgerProductId, req.getSalesLedgerProductId()); |
| | | // ProcurementRecordStorage procurementRecordStorage = procurementRecordStorageService.getOne(lambdaQueryWrapper); |
| | | // |
| | | // if (procurementRecordStorage == null) { |
| | | // // 保证前面的修改全部回滚 |
| | | // throw new ServiceException("采购记录不存在,审批回滚"); |
| | | // } |
| | | |
| | | // 生成出库记录 |
| | | ProcurementRecordOutAdd procurementRecordOutAdd = new ProcurementRecordOutAdd(); |
| | | procurementRecordOutAdd.setId(procurementRecordStorage.getId()); |
| | | procurementRecordOutAdd.setSalesLedgerProductId(Math.toIntExact(salesLedgerProduct.getId())); |
| | | procurementRecordOutAdd.setType(2); |
| | | procurementRecordOutAdd.setUserId(Math.toIntExact(getUserId())); |
| | | procurementRecordOutAdd.setQuantity(salesLedgerProduct.getQuantity().toPlainString()); |
| | | procurementRecordOutAdd.setTime(LocalDate.now().toString()); |
| | | |
| | | procurementRecordOutService.stockout(procurementRecordOutAdd); |
| | | stockUtils.substractStock(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), shipmentApproval.getId()); |
| | | } |
| | | |
| | | return AjaxResult.success(); |