| | |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.word.WeighbridgeDocGenerator; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | public class ConsumablesInventoryServiceImpl extends ServiceImpl<ConsumablesInventoryMapper, ConsumablesInventory> implements ConsumablesInventoryService { |
| | | |
| | | private final ConsumablesInventoryMapper ConsumablesInventoryMapper; |
| | | private final ConsumablesInRecordService ConsumablesInRecordService; |
| | | private final ConsumablesOutRecordService ConsumablesOutRecordService; |
| | | private final ConsumablesInventoryMapper consumablesInventoryMapper; |
| | | private final ConsumablesInRecordService consumablesInRecordService; |
| | | private final ConsumablesOutRecordService consumablesOutRecordService; |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private final WeighbridgeDocGenerator weighbridgeDocGenerator; |
| | | |
| | | @Override |
| | | public IPage<ConsumablesInventoryDto> pageConsumablesInventory(Page page, ConsumablesInventoryDto ConsumablesInventoryDto) { |
| | | return ConsumablesInventoryMapper.pageConsumablesInventory(page, ConsumablesInventoryDto); |
| | | public IPage<ConsumablesInventoryDto> pageConsumablesInventory(Page page, ConsumablesInventoryDto consumablesInventoryDto) { |
| | | return consumablesInventoryMapper.pageConsumablesInventory(page, consumablesInventoryDto); |
| | | } |
| | | |
| | | //入库调用 |
| | |
| | | ConsumablesInRecordDto consumablesInRecordDto = new ConsumablesInRecordDto(); |
| | | consumablesInRecordDto.setRecordId(consumablesInventoryDto.getRecordId()); |
| | | consumablesInRecordDto.setRecordType(consumablesInventoryDto.getRecordType()); |
| | | consumablesInRecordDto.setConsumablesInNum(consumablesInventoryDto.getNetWeight()); |
| | | consumablesInRecordDto.setStockInNum(consumablesInventoryDto.getNetWeight()); |
| | | consumablesInRecordDto.setWeighingDate(consumablesInventoryDto.getWeighingDate()); |
| | | consumablesInRecordDto.setNetWeight(consumablesInventoryDto.getNetWeight()); |
| | | consumablesInRecordDto.setGrossWeight(consumablesInventoryDto.getGrossWeight()); |
| | |
| | | consumablesInRecordDto.setProductModelId(consumablesInventoryDto.getProductModelId()); |
| | | consumablesInRecordDto.setProductId(consumablesInventoryDto.getProductId()); |
| | | consumablesInRecordDto.setType("0"); |
| | | ConsumablesInRecordService.add(consumablesInRecordDto); |
| | | //生成磅单 |
| | | StockInRecordDto stockInRecordDto = new StockInRecordDto(); |
| | | BeanUtils.copyProperties(consumablesInventoryDto, stockInRecordDto); |
| | | String absoluteDocPath = weighbridgeDocGenerator.generateWeighbridgeDoc(stockInRecordDto); |
| | | consumablesInRecordDto.setWeighbridgeDocPath(absoluteDocPath); |
| | | consumablesInRecordService.add(consumablesInRecordDto); |
| | | //再进行新增库存数量库存 |
| | | //先查询库存表中的产品是否存在,不存在新增,存在更新 |
| | | ConsumablesInventory oldConsumablesInventory = ConsumablesInventoryMapper.selectOne(new QueryWrapper<ConsumablesInventory>().lambda().eq(ConsumablesInventory::getProductModelId, consumablesInventoryDto.getProductModelId())); |
| | | ConsumablesInventory oldConsumablesInventory = consumablesInventoryMapper.selectOne(new QueryWrapper<ConsumablesInventory>().lambda().eq(ConsumablesInventory::getProductModelId, consumablesInventoryDto.getProductModelId())); |
| | | if (ObjectUtils.isEmpty(oldConsumablesInventory)) { |
| | | ConsumablesInventory newConsumablesInventory = new ConsumablesInventory(); |
| | | newConsumablesInventory.setProductModelId(consumablesInventoryDto.getProductModelId()); |
| | |
| | | newConsumablesInventory.setRemark(consumablesInventoryDto.getRemark()); |
| | | newConsumablesInventory.setLockedQuantity(consumablesInventoryDto.getLockedQuantity()); |
| | | newConsumablesInventory.setWarnNum(consumablesInventoryDto.getWarnNum()); |
| | | ConsumablesInventoryMapper.insert(newConsumablesInventory); |
| | | newConsumablesInventory.setProductId(consumablesInventoryDto.getProductId()); |
| | | consumablesInventoryMapper.insert(newConsumablesInventory); |
| | | } else { |
| | | consumablesInventoryDto.setQualitity(consumablesInventoryDto.getNetWeight()); |
| | | ConsumablesInventoryMapper.updateAddConsumablesInventory(consumablesInventoryDto); |
| | | consumablesInventoryMapper.updateAddConsumablesInventory(consumablesInventoryDto); |
| | | } |
| | | return true; |
| | | } |
| | |
| | | consumablesOutRecordDto.setRecordId(consumablesInventoryDto.getRecordId()); |
| | | consumablesOutRecordDto.setRecordType(consumablesInventoryDto.getRecordType()); |
| | | consumablesOutRecordDto.setWeighingDate(consumablesInventoryDto.getWeighingDate()); |
| | | consumablesOutRecordDto.setConsumablesOutNum(consumablesInventoryDto.getNetWeight()); |
| | | consumablesOutRecordDto.setStockOutNum(consumablesInventoryDto.getNetWeight()); |
| | | consumablesOutRecordDto.setNetWeight(consumablesInventoryDto.getNetWeight()); |
| | | consumablesOutRecordDto.setGrossWeight(consumablesInventoryDto.getGrossWeight()); |
| | | consumablesOutRecordDto.setTareWeight(consumablesInventoryDto.getTareWeight()); |
| | |
| | | consumablesOutRecordDto.setLicensePlateNo(consumablesInventoryDto.getLicensePlateNo()); |
| | | consumablesOutRecordDto.setProductId(consumablesInventoryDto.getProductId()); |
| | | consumablesOutRecordDto.setType("0"); |
| | | ConsumablesOutRecordService.add(consumablesOutRecordDto); |
| | | ConsumablesInventory oldConsumablesInventory = ConsumablesInventoryMapper.selectOne(new QueryWrapper<ConsumablesInventory>().lambda().eq(ConsumablesInventory::getProductModelId, consumablesInventoryDto.getProductModelId())); |
| | | //生成磅单 |
| | | StockInRecordDto stockInRecordDto = new StockInRecordDto(); |
| | | BeanUtils.copyProperties(consumablesInventoryDto, stockInRecordDto); |
| | | String absoluteDocPath = weighbridgeDocGenerator.generateWeighbridgeDoc(stockInRecordDto); |
| | | consumablesOutRecordDto.setWeighbridgeDocPath(absoluteDocPath); |
| | | consumablesOutRecordService.add(consumablesOutRecordDto); |
| | | ConsumablesInventory oldConsumablesInventory = consumablesInventoryMapper.selectOne(new QueryWrapper<ConsumablesInventory>().lambda().eq(ConsumablesInventory::getProductModelId, consumablesInventoryDto.getProductModelId())); |
| | | if (ObjectUtils.isEmpty(oldConsumablesInventory)) { |
| | | throw new RuntimeException("产品库存不存在"); |
| | | } |
| | |
| | | throw new RuntimeException("库存不足无法出库"); |
| | | } |
| | | |
| | | ConsumablesInventoryMapper.updateSubtractConsumablesInventory(consumablesInventoryDto); |
| | | consumablesInventoryMapper.updateSubtractConsumablesInventory(consumablesInventoryDto); |
| | | return true; |
| | | } |
| | | |
| | |
| | | for (SalesLedgerProduct item : salesLedgerProducts) { |
| | | if (item.getProductCategory().equals(dto.getProductName()) && |
| | | item.getSpecificationModel().equals(dto.getModel())) { |
| | | ConsumablesInventoryDto ConsumablesInventoryDto = new ConsumablesInventoryDto(); |
| | | ConsumablesInventoryDto.setRecordId(0L); |
| | | ConsumablesInventoryDto.setRecordType(StockInQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode()); |
| | | ConsumablesInventoryDto.setQualitity(dto.getQualitity()); |
| | | ConsumablesInventoryDto.setRemark(dto.getRemark()); |
| | | ConsumablesInventoryDto.setWarnNum(dto.getWarnNum()); |
| | | ConsumablesInventoryDto consumablesInventoryDto = new ConsumablesInventoryDto(); |
| | | consumablesInventoryDto.setRecordId(0L); |
| | | consumablesInventoryDto.setRecordType(StockInQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode()); |
| | | consumablesInventoryDto.setQualitity(dto.getQualitity()); |
| | | consumablesInventoryDto.setRemark(dto.getRemark()); |
| | | consumablesInventoryDto.setNetWeight(dto.getNetWeight()); |
| | | if (ObjectUtils.isNotEmpty(dto.getLockedQuantity()) && dto.getLockedQuantity().compareTo(dto.getQualitity()) > 0) { |
| | | throw new RuntimeException("冻结数量不能超过本次导入的库存数量"); |
| | | } |
| | | ConsumablesInventoryDto.setLockedQuantity(dto.getLockedQuantity()); |
| | | ConsumablesInventoryDto.setProductModelId(item.getProductModelId()); |
| | | this.addConsumablesInventory(ConsumablesInventoryDto); |
| | | consumablesInventoryDto.setLockedQuantity(dto.getLockedQuantity()); |
| | | consumablesInventoryDto.setProductModelId(item.getProductModelId()); |
| | | this.addConsumablesInventory(consumablesInventoryDto); |
| | | matched = true; |
| | | break; // 找到匹配项后跳出循环 |
| | | } |
| | |
| | | |
| | | |
| | | @Override |
| | | public void exportConsumablesInventory(HttpServletResponse response, ConsumablesInventoryDto ConsumablesInventoryDto) { |
| | | public void exportConsumablesInventory(HttpServletResponse response, ConsumablesInventoryDto consumablesInventoryDto) { |
| | | |
| | | List<ConsumablesInventoryExportData> list = ConsumablesInventoryMapper.listConsumablesInventoryExportData(ConsumablesInventoryDto); |
| | | List<ConsumablesInventoryExportData> list = consumablesInventoryMapper.listConsumablesInventoryExportData(consumablesInventoryDto); |
| | | ExcelUtil<ConsumablesInventoryExportData> util = new ExcelUtil<>(ConsumablesInventoryExportData.class); |
| | | util.exportExcel(response, list, "库存信息"); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<ConsumablesInRecordDto> consumablesInventoryPage(ConsumablesInventoryDto consumablesInventoryDto, Page page) { |
| | | return ConsumablesInventoryMapper.ConsumablesInventoryPage(consumablesInventoryDto, page); |
| | | return consumablesInventoryMapper.consumablesInventoryPage(consumablesInventoryDto, page); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<ConsumablesInventoryDto> consumablesInAndOutRecord(ConsumablesInventoryDto consumablesInventoryDto, Page page) { |
| | | return ConsumablesInventoryMapper.ConsumablesInAndOutRecord(consumablesInventoryDto, page); |
| | | return consumablesInventoryMapper.consumablesInAndOutRecord(consumablesInventoryDto, page); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean frozenConsumables(ConsumablesInventoryDto ConsumablesInventoryDto) { |
| | | ConsumablesInventory ConsumablesInventory = ConsumablesInventoryMapper.selectById(ConsumablesInventoryDto.getId()); |
| | | if (ConsumablesInventory.getQualitity().compareTo(ConsumablesInventoryDto.getLockedQuantity()) < 0) { |
| | | public Boolean frozenConsumables(ConsumablesInventoryDto consumablesInventoryDto) { |
| | | ConsumablesInventory consumablesInventory = consumablesInventoryMapper.selectById(consumablesInventoryDto.getId()); |
| | | if (consumablesInventory.getQualitity().compareTo(consumablesInventoryDto.getLockedQuantity()) < 0) { |
| | | throw new RuntimeException("冻结数量不能超过库存数量"); |
| | | } |
| | | if (ObjectUtils.isEmpty(ConsumablesInventory.getLockedQuantity())) { |
| | | ConsumablesInventory.setLockedQuantity(ConsumablesInventoryDto.getLockedQuantity()); |
| | | if (ObjectUtils.isEmpty(consumablesInventory.getLockedQuantity())) { |
| | | consumablesInventory.setLockedQuantity(consumablesInventoryDto.getLockedQuantity()); |
| | | } else { |
| | | ConsumablesInventory.setLockedQuantity(ConsumablesInventory.getLockedQuantity().add(ConsumablesInventoryDto.getLockedQuantity())); |
| | | consumablesInventory.setLockedQuantity(consumablesInventory.getLockedQuantity().add(consumablesInventoryDto.getLockedQuantity())); |
| | | } |
| | | return this.updateById(ConsumablesInventory); |
| | | return this.updateById(consumablesInventory); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean thawConsumables(ConsumablesInventoryDto ConsumablesInventoryDto) { |
| | | ConsumablesInventory ConsumablesInventory = ConsumablesInventoryMapper.selectById(ConsumablesInventoryDto.getId()); |
| | | if (ConsumablesInventory.getLockedQuantity().compareTo(ConsumablesInventoryDto.getLockedQuantity()) < 0) { |
| | | public Boolean thawConsumables(ConsumablesInventoryDto consumablesInventoryDto) { |
| | | ConsumablesInventory consumablesInventory = consumablesInventoryMapper.selectById(consumablesInventoryDto.getId()); |
| | | if (consumablesInventory.getLockedQuantity().compareTo(consumablesInventoryDto.getLockedQuantity()) < 0) { |
| | | throw new RuntimeException("解冻数量不能超过冻结数量"); |
| | | } |
| | | ConsumablesInventory.setLockedQuantity(ConsumablesInventory.getLockedQuantity().subtract(ConsumablesInventoryDto.getLockedQuantity())); |
| | | return this.updateById(ConsumablesInventory); |
| | | consumablesInventory.setLockedQuantity(consumablesInventory.getLockedQuantity().subtract(consumablesInventoryDto.getLockedQuantity())); |
| | | return this.updateById(consumablesInventory); |
| | | } |
| | | } |