| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.ruoyi.common.enums.ReviewStatusEnum; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import com.ruoyi.stock.pojo.StockOutRecord; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | |
| | | private final StockInventoryService stockInventoryService; |
| | | private final StockInRecordService stockInRecordService; |
| | | private final StockOutRecordService stockOutRecordService; |
| | | private final StockInventoryMapper stockInventoryMapper; |
| | | |
| | | /** |
| | | * 不合格入库 |
| | |
| | | stockUninventoryDto.setRecordType(String.valueOf(recordType)); |
| | | stockUninventoryDto.setQualitity(quantity); |
| | | stockUninventoryDto.setProductModelId(productModelId); |
| | | stockUninventoryService.addStockInRecordOnly(stockUninventoryDto); |
| | | } |
| | | |
| | | /** |
| | | * 不合格入库带批次号 |
| | | * |
| | | * @param productModelId |
| | | * @param quantity |
| | | * @param recordType |
| | | * @param recordId |
| | | */ |
| | | public void addUnStockWithBatchNo(Long productModelId, BigDecimal quantity, String recordType, Long recordId, String batchNo) { |
| | | StockUninventoryDto stockUninventoryDto = new StockUninventoryDto(); |
| | | stockUninventoryDto.setRecordId(recordId); |
| | | stockUninventoryDto.setRecordType(String.valueOf(recordType)); |
| | | stockUninventoryDto.setQualitity(quantity); |
| | | stockUninventoryDto.setProductModelId(productModelId); |
| | | stockUninventoryDto.setBatchNo(batchNo); |
| | | stockUninventoryService.addStockInRecordOnly(stockUninventoryDto); |
| | | } |
| | | |
| | |
| | | public void deleteStockInRecord(Long recordId, String recordType) { |
| | | StockInRecord one = stockInRecordService.getOne(new QueryWrapper<StockInRecord>() |
| | | .lambda().eq(StockInRecord::getRecordId, recordId) |
| | | .eq(StockInRecord::getRecordType, recordType)); |
| | | .eq(StockInRecord::getRecordType, recordType), false); |
| | | if (ObjectUtils.isNotEmpty(one)) { |
| | | stockInRecordService.batchDelete(Collections.singletonList(one.getId())); |
| | | //将库存减回来 |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setRecordId(recordId); |
| | | stockInventoryDto.setRecordType(recordType); |
| | | stockInventoryDto.setQualitity(one.getStockInNum()); |
| | | stockInventoryMapper.updateSubtractStockInventory((stockInventoryDto)); |
| | | if (ReviewStatusEnum.APPROVED.getCode().equals(one.getApprovalStatus())) { |
| | | stockInRecordService.batchDelete(Collections.singletonList(one.getId())); |
| | | } else { |
| | | stockInRecordService.removeById(one.getId()); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | public void deleteStockOutRecord(Long recordId, String recordType) { |
| | | StockOutRecord one = stockOutRecordService.getOne(new QueryWrapper<StockOutRecord>() |
| | | .lambda().eq(StockOutRecord::getRecordId, recordId) |
| | | .eq(StockOutRecord::getRecordType, recordType)); |
| | | .eq(StockOutRecord::getRecordType, recordType), false); |
| | | if (ObjectUtils.isNotEmpty(one)) { |
| | | stockOutRecordService.batchDelete(Collections.singletonList(one.getId())); |
| | | //将库存加回来 |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setRecordId(recordId); |
| | | stockInventoryDto.setRecordType(recordType); |
| | | stockInventoryDto.setQualitity(one.getStockOutNum()); |
| | | stockInventoryMapper.updateAddStockInventory((stockInventoryDto)); |
| | | if (ReviewStatusEnum.APPROVED.getCode().equals(one.getApprovalStatus())) { |
| | | stockOutRecordService.batchDelete(Collections.singletonList(one.getId())); |
| | | } else { |
| | | stockOutRecordService.removeById(one.getId()); |
| | | } |
| | | } |
| | | |
| | | } |