| | |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.stock.enums.StockInventorySourceEnum; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.domain.R; |
| | |
| | | |
| | | @Override |
| | | public IPage<StockInventoryDto> pageListCombinedStockInventory(Page page, StockInventoryDto stockInventoryDto) { |
| | | return stockInventoryMapper.pageListCombinedStockInventory(page, stockInventoryDto); |
| | | IPage<StockInventoryDto> result = stockInventoryMapper.pageListCombinedStockInventory(page, stockInventoryDto); |
| | | // 转换来源编码为来源名称 |
| | | for (StockInventoryDto dto : result.getRecords()) { |
| | | // 合格库存来源 |
| | | if (StringUtils.isNotBlank(dto.getQualifiedSource())) { |
| | | StockInventorySourceEnum qualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getQualifiedSource()); |
| | | if (qualifiedSourceEnum != null) { |
| | | dto.setQualifiedSourceText(qualifiedSourceEnum.getValue()); |
| | | } |
| | | } |
| | | // 不合格库存来源 |
| | | if (StringUtils.isNotBlank(dto.getUnQualifiedSource())) { |
| | | StockInventorySourceEnum unQualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getUnQualifiedSource()); |
| | | if (unQualifiedSourceEnum != null) { |
| | | dto.setUnQualifiedSourceText(unQualifiedSourceEnum.getValue()); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | //入库调用 |
| | |
| | | eq.eq(StockInventory::getBatchNo, stockInventoryDto.getBatchNo()); |
| | | //新增入库记录再添加库存 |
| | | StockInRecordDto stockInRecordDto = new StockInRecordDto(); |
| | | stockInRecordDto.setRecordId(stockInventoryDto.getRecordId()); |
| | | stockInRecordDto.setRecordType(stockInventoryDto.getRecordType()); |
| | | stockInRecordDto.setStockInNum(stockInventoryDto.getQualitity()); |
| | | stockInRecordDto.setBatchNo(stockInventoryDto.getBatchNo()); |
| | | stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId()); |
| | | stockInRecordDto.setType("0"); |
| | | populateStockInRecord(stockInventoryDto, stockInRecordDto); |
| | | stockInRecordService.add(stockInRecordDto); |
| | | //再进行新增库存数量库存 |
| | | //先查询库存表中的产品是否存在,不存在新增,存在更新 |
| | |
| | | newStockInventory.setBatchNo(stockInventoryDto.getBatchNo()); |
| | | newStockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity()); |
| | | newStockInventory.setWarnNum(stockInventoryDto.getWarnNum()); |
| | | applySourceBindingFields(newStockInventory, stockInventoryDto); |
| | | stockInventoryMapper.insert(newStockInventory); |
| | | } else { |
| | | applySourceBindingFields(stockInventoryDto, stockInventoryDto); |
| | | stockInventoryMapper.updateAddStockInventory(stockInventoryDto); |
| | | } |
| | | return true; |
| | |
| | | stockInventoryDto.setBatchNo(batchNo); |
| | | |
| | | StockInRecordDto stockInRecordDto = new StockInRecordDto(); |
| | | populateStockInRecord(stockInventoryDto, stockInRecordDto); |
| | | stockInRecordService.add(stockInRecordDto); |
| | | return true; |
| | | } |
| | | |
| | | private void applySourceBindingFields(StockInventory target, StockInventoryDto source) { |
| | | if (target == null || source == null) { |
| | | return; |
| | | } |
| | | target.setSource(source.getSource()); |
| | | if (StockInventorySourceEnum.PURCHASE_RECEIPT.getCode().equals(source.getSource())) { |
| | | target.setSupplierId(source.getSupplierId()); |
| | | target.setManufacturerId(null); |
| | | return; |
| | | } |
| | | if (StockInventorySourceEnum.OUTSOURCED_RECEIPT.getCode().equals(source.getSource())) { |
| | | target.setManufacturerId(source.getManufacturerId()); |
| | | target.setSupplierId(null); |
| | | return; |
| | | } |
| | | target.setManufacturerId(null); |
| | | target.setSupplierId(null); |
| | | } |
| | | |
| | | private void populateStockInRecord(StockInventoryDto stockInventoryDto, StockInRecordDto stockInRecordDto) { |
| | | stockInRecordDto.setRecordId(stockInventoryDto.getRecordId()); |
| | | stockInRecordDto.setRecordType(stockInventoryDto.getRecordType()); |
| | | stockInRecordDto.setStockInNum(stockInventoryDto.getQualitity()); |
| | | stockInRecordDto.setBatchNo(batchNo); |
| | | stockInRecordDto.setBatchNo(stockInventoryDto.getBatchNo()); |
| | | stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId()); |
| | | stockInRecordDto.setType("0"); |
| | | stockInRecordDto.setRemark(stockInventoryDto.getRemark()); |
| | | stockInRecordService.add(stockInRecordDto); |
| | | return true; |
| | | stockInRecordDto.setWarnNum(stockInventoryDto.getWarnNum()); |
| | | stockInRecordDto.setSource(stockInventoryDto.getSource()); |
| | | if (StockInventorySourceEnum.PURCHASE_RECEIPT.getCode().equals(stockInventoryDto.getSource())) { |
| | | stockInRecordDto.setSupplierId(stockInventoryDto.getSupplierId()); |
| | | } else if (StockInventorySourceEnum.OUTSOURCED_RECEIPT.getCode().equals(stockInventoryDto.getSource())) { |
| | | stockInRecordDto.setManufacturerId(stockInventoryDto.getManufacturerId()); |
| | | } |
| | | // 设置含水量相关信息 |
| | | stockInRecordDto.setIsContainsWater(stockInventoryDto.getIsContainsWater()); |
| | | stockInRecordDto.setWaterContent(stockInventoryDto.getWaterContent()); |
| | | stockInRecordDto.setTheoryStockInNum(stockInventoryDto.getTheoryStockInNum()); |
| | | stockInRecordDto.setDifferenceNum(stockInventoryDto.getDifferenceNum()); |
| | | } |
| | | |
| | | //规则生成:20260424-产品编号-001 |
| | |
| | | |
| | | @Override |
| | | public IPage<StockInventoryDto> getBatchNoQty(Page page, StockInventoryDto stockInventoryDto) { |
| | | return stockInventoryMapper.getBatchNoQty(page, stockInventoryDto); |
| | | IPage<StockInventoryDto> resultPage = stockInventoryMapper.getBatchNoQty(page, stockInventoryDto); |
| | | |
| | | // 遍历结果,设置来源中文名 |
| | | resultPage.getRecords().forEach(dto -> { |
| | | // 设置合格库存来源中文名 |
| | | if (StringUtils.isNotEmpty(dto.getQualifiedSource())) { |
| | | System.out.println("合格库存来源:" + dto.getQualifiedSource()); |
| | | StockInventorySourceEnum qualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getQualifiedSource()); |
| | | if (qualifiedSourceEnum != null) { |
| | | dto.setQualifiedSourceText(qualifiedSourceEnum.getValue()); |
| | | System.out.println("合格库存来源值:" + qualifiedSourceEnum.getValue()); |
| | | } |
| | | } |
| | | |
| | | // 设置不合格库存来源中文名 |
| | | if (StringUtils.isNotEmpty(dto.getUnQualifiedSource())) { |
| | | StockInventorySourceEnum unQualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getUnQualifiedSource()); |
| | | if (unQualifiedSourceEnum != null) { |
| | | dto.setUnQualifiedSourceText(unQualifiedSourceEnum.getValue()); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | return resultPage; |
| | | } |
| | | } |