| | |
| | | batchInsertInventories(masterId, dto.getProductionInventoryList()); |
| | | |
| | | // 插入待入库数据 |
| | | insertPendingInventory(dto.getProductionList()); |
| | | // insertPendingInventory(dto.getProductionList()); |
| | | |
| | | return 1; |
| | | } |
| | |
| | | BeanUtils.copyProperties(p, copy); |
| | | copy.setId(null); |
| | | copy.setProductionMasterId(masterId); |
| | | copy.setStatus(1); |
| | | productionMapper.insert(copy); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 将加工产生的产品记录到待入库表 |
| | | */ |
| | | private void insertPendingInventory(List<Production> list) { |
| | | public void insertPendingInventory(List<Production> list) { |
| | | LocalDate currentDate = LocalDate.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | String formattedDate = currentDate.format(formatter); |
| | |
| | | } |
| | | |
| | | // 批量更新官方库存 |
| | | for (Map.Entry<Long, BigDecimal> entry : inventoryAdjustMap.entrySet()) { |
| | | OfficialInventory official = officialInventoryMapper.selectById(entry.getKey()); |
| | | if (official == null) { |
| | | throw new BaseException("官方库存不存在,ID: " + entry.getKey()); |
| | | } |
| | | |
| | | // 使用线程安全的BigDecimal操作 |
| | | official.setInventoryQuantity( |
| | | Optional.ofNullable(official.getInventoryQuantity()) |
| | | .orElse(BigDecimal.ZERO) |
| | | .add(entry.getValue()) |
| | | ); |
| | | officialInventoryMapper.updateById(official); |
| | | } |
| | | // for (Map.Entry<Long, BigDecimal> entry : inventoryAdjustMap.entrySet()) { |
| | | // OfficialInventory official = officialInventoryMapper.selectById(entry.getKey()); |
| | | // if (official == null) { |
| | | // throw new BaseException("官方库存不存在,ID: " + entry.getKey()); |
| | | // } |
| | | // |
| | | // // 使用线程安全的BigDecimal操作 |
| | | // official.setInventoryQuantity( |
| | | // Optional.ofNullable(official.getInventoryQuantity()) |
| | | // .orElse(BigDecimal.ZERO) |
| | | // .add(entry.getValue()) |
| | | // ); |
| | | // officialInventoryMapper.updateById(official); |
| | | // } |
| | | |
| | | // 批量删除生产库存 |
| | | if (!productionIdsToDelete.isEmpty()) { |