|
@@ -100,6 +100,21 @@ public class StockDamageReportManagerImpl extends ServiceImpl<StockDamageReportM
|
|
|
if (aDo.getActualStock() < dto.getReportNum()) {
|
|
|
throw new ServiceException("报损数量不能能大于库存数量");
|
|
|
}
|
|
|
+
|
|
|
+ ProductDO manager = productManager.getById(dto.getProductId());
|
|
|
+ if (manager.getHaveSn()) {
|
|
|
+ if (CollUtil.isEmpty(dto.getSnCodeList())) {
|
|
|
+ throw new ServiceException(manager.getId() + ":有序列号的商品出库需要录入序列号");
|
|
|
+ }
|
|
|
+ if (dto.getReportNum() != dto.getSnCodeList().size()) {
|
|
|
+ throw new ServiceException(manager.getId() + ":出库的数量须和序列号的个数相等");
|
|
|
+ }
|
|
|
+ Set<Long> set = dto.getSnCodeList().stream().map(GoodsSnDO::getId).collect(Collectors.toSet());
|
|
|
+ if (set.size() != dto.getSnCodeList().size()){
|
|
|
+ throw new ServiceException("序列号重复");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
//生成库存报损单编号
|
|
|
String sn = noGenerateManager.generate(NoBusinessTypeEnum.StockDamageReport);
|
|
@@ -108,6 +123,30 @@ public class StockDamageReportManagerImpl extends ServiceImpl<StockDamageReportM
|
|
|
List<StockDamageReportProduct> bean = BeanUtils.toBean(stockDamageReportDTO.getProductList(), StockDamageReportProduct.class);
|
|
|
bean.forEach(item -> item.setReportId(report.getId()));
|
|
|
stockDamageReportProductManager.saveBatch(bean);
|
|
|
+
|
|
|
+ List<ItemSnCodeDO> itemSnCodeDOS = new ArrayList<>();
|
|
|
+ //更爱序列号的状态
|
|
|
+ List<GoodsSnDO> snList = new ArrayList<>();
|
|
|
+ //如果有序列号,保存序列号和入库单的关系,更爱序列号的状态
|
|
|
+ for (StockDamageReportProductDTO aDo : stockDamageReportDTO.getProductList()) {
|
|
|
+ if (CollUtil.isNotEmpty(aDo.getSnCodeList())) {
|
|
|
+ aDo.getSnCodeList().forEach(item -> {
|
|
|
+ ItemSnCodeDO itemSnCodeDO = new ItemSnCodeDO();
|
|
|
+ itemSnCodeDO.setItemId(aDo.getId());
|
|
|
+ itemSnCodeDO.setEntryOutHouseId(report.getWarehouseId());
|
|
|
+ itemSnCodeDO.setType("damage");
|
|
|
+ itemSnCodeDO.setSnCodeId(item.getId());
|
|
|
+ itemSnCodeDOS.add(itemSnCodeDO);
|
|
|
+ item.setStatus(SnCodeStatusEnum.DISABLE_USE);
|
|
|
+ item.setOutHouseId(null);
|
|
|
+ item.setEntryHouseId(null);
|
|
|
+ snList.add(item);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存序列号和子表的关系
|
|
|
+ itemSnCodeManager.saveBatch(itemSnCodeDOS);
|
|
|
+ goodsSnManager.updateBatchById(snList);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -166,22 +205,6 @@ public class StockDamageReportManagerImpl extends ServiceImpl<StockDamageReportM
|
|
|
productStockManager.updateBatchById(list);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 编辑库存报损单
|
|
|
- *
|
|
|
- * @param id 主键ID
|
|
|
- * @param stockDamageReportDTO 库存报损单信息
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional(value = "goodsTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
- public void edit(Long id, StockDamageReportDTO stockDamageReportDTO) {
|
|
|
- //获取库存报损单旧数据
|
|
|
- StockDamageReport stockDamageReport = this.getById(id);
|
|
|
- //复制修改后的数据
|
|
|
- //修改库存报损单信息
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 删除库存报损单
|
|
|
*
|
|
@@ -221,17 +244,7 @@ public class StockDamageReportManagerImpl extends ServiceImpl<StockDamageReportM
|
|
|
}
|
|
|
report.setStatus(DamageinventoryEnum.HAS_HANDLE);
|
|
|
updateById(report);
|
|
|
- for (StockDamageReportProductDTO aDo : stockDamageReportDTO.getProductList()) {
|
|
|
- ProductDO manager = productManager.getById(aDo.getProductId());
|
|
|
- if (manager.getHaveSn()) {
|
|
|
- if (CollUtil.isEmpty(aDo.getSnCodeList())) {
|
|
|
- throw new ServiceException(manager.getId() + ":有序列号的商品出库需要录入序列号");
|
|
|
- }
|
|
|
- if (aDo.getReportNum() != aDo.getSnCodeList().size()) {
|
|
|
- throw new ServiceException(manager.getId() + ":出库的数量须和序列号的个数相等");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
List<StockDTO> arrayList = new ArrayList<>();
|
|
|
//减实际库存
|
|
|
for (StockDamageReportProductDTO dto : stockDamageReportDTO.getProductList()) {
|
|
@@ -260,29 +273,6 @@ public class StockDamageReportManagerImpl extends ServiceImpl<StockDamageReportM
|
|
|
item.setOutNum(num);
|
|
|
});
|
|
|
warehouseOutItemManager.saveBatch(beanList);
|
|
|
- List<ItemSnCodeDO> itemSnCodeDOS = new ArrayList<>();
|
|
|
- //更爱序列号的状态
|
|
|
- List<GoodsSnDO> list = new ArrayList<>();
|
|
|
- //如果有序列号,保存序列号和入库单的关系,更爱序列号的状态
|
|
|
- for (StockDamageReportProductDTO aDo : stockDamageReportDTO.getProductList()) {
|
|
|
- if (CollUtil.isNotEmpty(aDo.getSnCodeList())) {
|
|
|
- aDo.getSnCodeList().forEach(item -> {
|
|
|
- ItemSnCodeDO itemSnCodeDO = new ItemSnCodeDO();
|
|
|
- itemSnCodeDO.setItemId(aDo.getId());
|
|
|
- itemSnCodeDO.setEntryOutHouseId(report.getWarehouseId());
|
|
|
- itemSnCodeDO.setType("damage");
|
|
|
- itemSnCodeDO.setSnCodeId(item.getId());
|
|
|
- itemSnCodeDOS.add(itemSnCodeDO);
|
|
|
- item.setStatus(SnCodeStatusEnum.DISABLE_USE);
|
|
|
- item.setOutHouseId(outDO.getId());
|
|
|
- item.setEntryHouseId(null);
|
|
|
- list.add(item);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- //保存序列号和子表的关系
|
|
|
- itemSnCodeManager.saveBatch(itemSnCodeDOS);
|
|
|
- goodsSnManager.updateBatchById(list);
|
|
|
redisTemplate.delete(id.toString());
|
|
|
}
|
|
|
|