| | |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.execl.StockInRecordExportData; |
| | | import com.ruoyi.production.mapper.ProductionOrderPickMapper; |
| | | import com.ruoyi.production.pojo.ProductionOrderPick; |
| | | import com.ruoyi.stock.mapper.StockInRecordMapper; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.mapper.StockUninventoryMapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | private StockInRecordMapper stockInRecordMapper; |
| | | private StockInventoryMapper stockInventoryMapper; |
| | | private StockUninventoryMapper stockUninventoryMapper; |
| | | private ProductionOrderPickMapper productionOrderPickMapper; |
| | | |
| | | @Override |
| | | public IPage<StockInRecordDto> listPage(Page page, StockInRecordDto stockInRecordDto) { |
| | |
| | | } |
| | | stockInRecord.setApprovalStatus(approvalStatus); |
| | | stockInRecordMapper.updateById(stockInRecord); |
| | | |
| | | // 审批驳回时,如果是生产退料入库,需要回滚领料记录的退料数量 |
| | | if (ReviewStatusEnum.REJECTED.getCode().equals(approvalStatus) && |
| | | StockInQualifiedRecordTypeEnum.FEED_RETURN_IN.getCode().equals(stockInRecord.getRecordType())) { |
| | | // 找到对应的领料记录 |
| | | ProductionOrderPick productionOrderPick = productionOrderPickMapper.selectById(stockInRecord.getRecordId()); |
| | | if (productionOrderPick != null) { |
| | | // 回滚退料数量 |
| | | BigDecimal returnQty = productionOrderPick.getReturnQty(); |
| | | if (returnQty == null) { |
| | | returnQty = BigDecimal.ZERO; |
| | | } |
| | | BigDecimal newReturnQty = returnQty.subtract(stockInRecord.getStockInNum()); |
| | | if (newReturnQty.compareTo(BigDecimal.ZERO) < 0) { |
| | | newReturnQty = BigDecimal.ZERO; |
| | | } |
| | | productionOrderPick.setReturnQty(newReturnQty); |
| | | // 重新计算实际用量 |
| | | BigDecimal actualQty = productionOrderPick.getQuantity().add( |
| | | productionOrderPick.getFeedingQty() != null ? productionOrderPick.getFeedingQty() : BigDecimal.ZERO) |
| | | .subtract(newReturnQty); |
| | | productionOrderPick.setActualQty(actualQty); |
| | | productionOrderPick.setReturned(newReturnQty.compareTo(BigDecimal.ZERO) > 0); |
| | | productionOrderPickMapper.updateById(productionOrderPick); |
| | | } |
| | | } |
| | | |
| | | // 审批通过时,库存增加 |
| | | if (ReviewStatusEnum.APPROVED.getCode().equals(approvalStatus)) { |
| | | if ("0".equals(stockInRecord.getType())) { |