| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.stock.enums.StockInventorySourceEnum; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int add(StockInRecordDto stockInRecordDto) { |
| | | if (stockInRecordDto.getCreateTime() == null) { |
| | | stockInRecordDto.setCreateTime(LocalDateTime.now()); |
| | | } |
| | | String no = OrderUtils.countTodayByCreateTime(stockInRecordMapper, "RK","inbound_batches", stockInRecordDto.getCreateTime() != null ? stockInRecordDto.getCreateTime() : LocalDateTime.now()); |
| | | stockInRecordDto.setInboundBatches(no); |
| | | StockInRecord stockInRecord = new StockInRecord(); |
| | |
| | | throw new BaseException("只有待审批状态的记录才能审批,入库批次:" + stockInRecord.getInboundBatches()); |
| | | } |
| | | |
| | | // 兼容历史数据或上游漏传场景,审批时补齐来源,避免废品库存台账来源为空 |
| | | String resolvedSource = resolveStockSource(stockInRecord); |
| | | if (StringUtils.isNotEmpty(resolvedSource)) { |
| | | stockInRecord.setSource(resolvedSource); |
| | | } |
| | | |
| | | // 获取审批时修改的入库数量,如果没有修改则使用原数量 |
| | | final BigDecimal finalStockInNum; |
| | | if (item.getStockInNum() != null && item.getStockInNum().compareTo(BigDecimal.ZERO) > 0) { |
| | |
| | | stockUninventoryDto.setManufacturerId(stockInRecord.getManufacturerId()); |
| | | stockUninventoryDto.setSource(stockInRecord.getSource()); |
| | | stockUninventoryDto.setType(uninventoryType); |
| | | stockUninventoryDto.setSource(stockInRecord.getSource()); |
| | | if (stockUninventory == null) { |
| | | stockUninventoryMapper.insert(new StockUninventory() {{ |
| | | setProductModelId(stockInRecord.getProductModelId()); |
| | |
| | | return stockInventoryDto; |
| | | } |
| | | |
| | | private String resolveStockSource(StockInRecord stockInRecord) { |
| | | if (stockInRecord == null || StringUtils.isNotEmpty(stockInRecord.getSource())) { |
| | | return stockInRecord == null ? null : stockInRecord.getSource(); |
| | | } |
| | | if (StockInQualifiedRecordTypeEnum.DEFECTIVE_SCRAP.getCode().equals(stockInRecord.getRecordType()) |
| | | || StockInQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode().equals(stockInRecord.getRecordType())) { |
| | | if (StockInQualifiedRecordTypeEnum.DEFECTIVE_SCRAP.getCode().equals(stockInRecord.getRecordType())) { |
| | | return StockInventorySourceEnum.DEFECTIVE_SCRAP.getCode(); |
| | | } |
| | | return StockInventorySourceEnum.PROD_GENERATED.getCode(); |
| | | } |
| | | if (StockInQualifiedRecordTypeEnum.RETURN_WASTE_IN.getCode().equals(stockInRecord.getRecordType())) { |
| | | return StockInventorySourceEnum.RETURN_GENERATED.getCode(); |
| | | } |
| | | return stockInRecord.getSource(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int batchReAudit(List<Long> ids) { |