|
@@ -98,13 +98,41 @@ public class StockInventoryManagerImpl extends ServiceImpl<StockInventoryMapper,
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 编辑库存盘点单
|
|
|
|
+ *
|
|
|
|
+ * @param id 主键ID
|
|
|
|
+ * @param stockInventoryDTO 库存盘点单信息
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(value = "goodsTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
|
+ public void edit(Long id, StockInventoryDTO stockInventoryDTO) {
|
|
|
|
+ //获取库存盘点单旧数据
|
|
|
|
+ StockInventory stockInventory = this.getById(id);
|
|
|
|
+ if (DamageinventoryEnum.HAS_HANDLE.equals(stockInventory.getStatus())) {
|
|
|
|
+ throw new ServiceException("该盘点单已同步数据,不允许操作");
|
|
|
|
+ }
|
|
|
|
+ stockInventoryProductManager.remove(new LambdaQueryWrapper<StockInventoryProduct>().eq(StockInventoryProduct::getInventoryId, id));
|
|
|
|
+ List<StockInventoryProduct> list = BeanUtils.toBean(stockInventoryDTO.getProductList(), StockInventoryProduct.class);
|
|
|
|
+ list.forEach(item -> item.setInventoryId(id));
|
|
|
|
+ this.stockInventoryProductManager.saveBatch(list);
|
|
|
|
+ //如果这个商品有序列号补习不全序列号关系
|
|
|
|
+ for (StockInventoryProductDTO dto : stockInventoryDTO.getProductList()) {
|
|
|
|
+ StockInventoryProduct product = list.stream().filter(item -> item.getProductId().equals(dto.getProductId())).findFirst().get();
|
|
|
|
+ dto.setId(product.getId());
|
|
|
|
+ }
|
|
|
|
+ itemSnCodeManager.remove(new LambdaQueryWrapper<ItemSnCodeDO>().eq(ItemSnCodeDO::getEntryOutHouseId, id));
|
|
|
|
+ saveSnCode(id, stockInventoryDTO.getProductList());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
private void saveSnCode(Long stockInventoryId, List<StockInventoryProductDTO> productList) {
|
|
private void saveSnCode(Long stockInventoryId, List<StockInventoryProductDTO> productList) {
|
|
List<ItemSnCodeDO> itemSnCodeDOS = new ArrayList<>();
|
|
List<ItemSnCodeDO> itemSnCodeDOS = new ArrayList<>();
|
|
//如果有序列号,保存序列号和入库单的关系,更爱序列号的状态
|
|
//如果有序列号,保存序列号和入库单的关系,更爱序列号的状态
|
|
List<String> arrayList = new ArrayList<>();
|
|
List<String> arrayList = new ArrayList<>();
|
|
for (StockInventoryProductDTO aDo : productList) {
|
|
for (StockInventoryProductDTO aDo : productList) {
|
|
ProductDO byId = productManager.getById(aDo.getProductId());
|
|
ProductDO byId = productManager.getById(aDo.getProductId());
|
|
- if (byId.getHaveSn() && CollUtil.isEmpty(aDo.getSnCodeList())){
|
|
|
|
|
|
+ if (byId.getHaveSn() && CollUtil.isEmpty(aDo.getSnCodeList())) {
|
|
throw new ServiceException("有序列号的商品序列号不能为空");
|
|
throw new ServiceException("有序列号的商品序列号不能为空");
|
|
}
|
|
}
|
|
if (CollUtil.isNotEmpty(aDo.getSnCodeList())) {
|
|
if (CollUtil.isNotEmpty(aDo.getSnCodeList())) {
|
|
@@ -122,7 +150,7 @@ public class StockInventoryManagerImpl extends ServiceImpl<StockInventoryMapper,
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(CollUtil.isNotEmpty(arrayList)){
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(arrayList)) {
|
|
long count = goodsSnManager.count(new LambdaQueryWrapper<GoodsSnDO>().in(GoodsSnDO::getSnCode, arrayList));
|
|
long count = goodsSnManager.count(new LambdaQueryWrapper<GoodsSnDO>().in(GoodsSnDO::getSnCode, arrayList));
|
|
if (count != arrayList.size()) {
|
|
if (count != arrayList.size()) {
|
|
throw new ServiceException("部分序列号不存在");
|
|
throw new ServiceException("部分序列号不存在");
|
|
@@ -166,7 +194,7 @@ public class StockInventoryManagerImpl extends ServiceImpl<StockInventoryMapper,
|
|
//找到这个订单关联的所有序列号
|
|
//找到这个订单关联的所有序列号
|
|
List<ItemSnCodeDO> listed = itemSnCodeManager.list(new LambdaQueryWrapper<ItemSnCodeDO>()
|
|
List<ItemSnCodeDO> listed = itemSnCodeManager.list(new LambdaQueryWrapper<ItemSnCodeDO>()
|
|
.eq(ItemSnCodeDO::getType, "inventory").eq(ItemSnCodeDO::getEntryOutHouseId, id));
|
|
.eq(ItemSnCodeDO::getType, "inventory").eq(ItemSnCodeDO::getEntryOutHouseId, id));
|
|
- if (CollUtil.isNotEmpty(listed)){
|
|
|
|
|
|
+ if (CollUtil.isNotEmpty(listed)) {
|
|
List<GoodsSnDO> goodsSnDOS = goodsSnManager.list(new LambdaQueryWrapper<GoodsSnDO>().in(GoodsSnDO::getId, listed.stream().map(ItemSnCodeDO::getSnCodeId).collect(Collectors.toList())));
|
|
List<GoodsSnDO> goodsSnDOS = goodsSnManager.list(new LambdaQueryWrapper<GoodsSnDO>().in(GoodsSnDO::getId, listed.stream().map(ItemSnCodeDO::getSnCodeId).collect(Collectors.toList())));
|
|
//更爱序列号状态
|
|
//更爱序列号状态
|
|
for (GoodsSnDO aDo : goodsSnDOS) {
|
|
for (GoodsSnDO aDo : goodsSnDOS) {
|
|
@@ -215,56 +243,25 @@ public class StockInventoryManagerImpl extends ServiceImpl<StockInventoryMapper,
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- * 编辑库存盘点单
|
|
|
|
- *
|
|
|
|
- * @param id 主键ID
|
|
|
|
- * @param stockInventoryDTO 库存盘点单信息
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- @Transactional(value = "goodsTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
|
- public void edit(Long id, StockInventoryDTO stockInventoryDTO) {
|
|
|
|
- //获取库存盘点单旧数据
|
|
|
|
- StockInventory stockInventory = this.getById(id);
|
|
|
|
- if (!StockInventoryStatusEnum.NEW.name().equals(stockInventory.getStatus())
|
|
|
|
- && !StockInventoryStatusEnum.REJECT.name().equals(stockInventory.getStatus())) {
|
|
|
|
- throw new ServiceException("只有状态为未提交或审核驳回的库存盘点单才可以进行编辑操作");
|
|
|
|
- }
|
|
|
|
- //复制修改后的数据
|
|
|
|
- //修改库存盘点单信息
|
|
|
|
- this.updateById(stockInventory);
|
|
|
|
- //入库库存报损单商品
|
|
|
|
- this.stockInventoryProductManager.saveProduct(id, stockInventoryDTO.getProductList());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 删除库存盘点单
|
|
* 删除库存盘点单
|
|
*
|
|
*
|
|
- * @param ids 库存盘点单主键ID集合
|
|
|
|
|
|
+ * @param id 库存盘点单主键ID集合
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional(value = "goodsTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
@Transactional(value = "goodsTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
- public void delete(List<Long> ids) {
|
|
|
|
- List<StockInventory> inventories = this.lambdaQuery()
|
|
|
|
- .in(StockInventory::getId, ids)
|
|
|
|
- .list();
|
|
|
|
- if (inventories == null || inventories.size() == 0) {
|
|
|
|
- throw new ServiceException("要删除的库存盘点单不存在");
|
|
|
|
|
|
+ public void delete(Long id) {
|
|
|
|
+ StockInventory inventory = getById(id);
|
|
|
|
+ if (DamageinventoryEnum.HAS_HANDLE.equals(inventory.getStatus())) {
|
|
|
|
+ throw new ServiceException("该盘点单已同步数据,不允许操作");
|
|
}
|
|
}
|
|
- //验证库存盘点单状态是否可以删除
|
|
|
|
- for (StockInventory inventory : inventories) {
|
|
|
|
- if (!StockInventoryStatusEnum.NEW.name().equals(inventory.getStatus())
|
|
|
|
- && !StockInventoryStatusEnum.REJECT.name().equals(inventory.getStatus())) {
|
|
|
|
- throw new ServiceException("只有状态为未提交或审核驳回的库存盘点单才可进行删除操作");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //批量删除库存盘点单
|
|
|
|
- this.removeByIds(ids);
|
|
|
|
- //删除库存盘点单商品信息
|
|
|
|
- this.stockInventoryProductManager.deleteProduct(ids);
|
|
|
|
|
|
+ removeById(id);
|
|
|
|
+ stockInventoryProductManager.remove(new LambdaQueryWrapper<StockInventoryProduct>().eq(StockInventoryProduct::getInventoryId, id));
|
|
|
|
+ itemSnCodeManager.remove(new LambdaQueryWrapper<ItemSnCodeDO>().eq(ItemSnCodeDO::getEntryOutHouseId, id));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 库存盘点单提交审核
|
|
* 库存盘点单提交审核
|
|
*
|
|
*
|