| | |
| | | @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(); |
| | |
| | | stockInRecordDto.setQualitity(stockInRecord.getStockInNum()); |
| | | stockInventoryMapper.updateSubtractStockInventory(stockInRecordDto); |
| | | } |
| | | }else if (stockInRecord.getType().equals("1")) { |
| | | String uninventoryType = resolveUninventoryTypeByInRecordType(stockInRecord.getRecordType()); |
| | | }else if (stockInRecord.getType().equals("1") || stockInRecord.getType().equals("2")) { |
| | | String uninventoryType = resolveUninventoryTypeByInRecordType(stockInRecord.getType()); |
| | | LambdaQueryWrapper<StockUninventory> eq = new LambdaQueryWrapper<StockUninventory>() |
| | | .eq(StockUninventory::getProductModelId, stockInRecord.getProductModelId()) |
| | | .eq(StockUninventory::getType, uninventoryType); |
| | |
| | | } else { |
| | | stockInventoryMapper.updateAddStockInventory(stockInventoryDto); |
| | | } |
| | | } else if ("1".equals(stockInRecord.getType())) { |
| | | } else if ("1".equals(stockInRecord.getType()) || "2".equals(stockInRecord.getType())) { |
| | | // 不合格入库 -> 先查库存,存在则更新,不存在则新增 |
| | | String uninventoryType = resolveUninventoryTypeByInRecordType(stockInRecord.getRecordType()); |
| | | String uninventoryType = resolveUninventoryTypeByInRecordType(stockInRecord.getType()); |
| | | StockUninventory stockUninventory = getStockUninventory(stockInRecord.getProductModelId(), stockInRecord.getBatchNo(), uninventoryType); |
| | | StockUninventoryDto stockUninventoryDto = new StockUninventoryDto(); |
| | | stockUninventoryDto.setProductModelId(stockInRecord.getProductModelId()); |
| | |
| | | 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 items.size(); |
| | | } |
| | | |
| | | private String resolveUninventoryTypeByInRecordType(String recordType) { |
| | | if (StockInQualifiedRecordTypeEnum.PRODUCTION_SCRAP.getCode().equals(recordType)) { |
| | | private String resolveUninventoryTypeByInRecordType(String stockInType) { |
| | | if ("2".equals(stockInType)) { |
| | | return WASTE_TYPE; |
| | | } |
| | | return UNQUALIFIED_TYPE; |