更新代码

This commit is contained in:
xiaofajia 2024-10-26 11:42:33 +08:00
parent 83a341e541
commit d42b25596a
2 changed files with 17 additions and 23 deletions

View File

@ -21,7 +21,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
* @date 9:13 2024/9/13
**/
@RestController
@RequestMapping("/repair/so/page")
@RequestMapping("/repair/so")
public class DlRepairSoController {
/**
* 服务对象

View File

@ -133,7 +133,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
}
// 新增主表
// 如果是采购单就把状态变为采购中
// 如果是采购单就把状态变为部分入库
if (repairSoRespVO.getSoType() != null && repairSoRespVO.getSoType().equals("01")){
repairSoRespVO.setSoStatus("02");
}
@ -149,26 +149,6 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
repairSoiService.saveBatch(repairSoRespVO.getGoodsList());
// 操作配件库存表
// 获取所有需要操作的数据
List<DlRepairSoi> goodsList = repairSoRespVO.getGoodsList();
List<String> ids = goodsList.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList());
List<RepairWares> repairWares = waresService.listByIds(ids);
// 更新库存和进价
List<RepairWares> newWares = repairWares.stream().map(item -> {
// 取数据
DlRepairSoi repairSoi = goodsList.stream().filter(i -> i.getGoodsId().equals(item.getId())).collect(Collectors.toList()).get(0);
// 设置新值
// 如果是采购入库数量+如果是领料出库数量-
// 01, 03 是采购 02 是领料
BigDecimal count = new BigDecimal(repairSoi.getGoodsCount());
RepairWares wares = new RepairWares();
wares.setId(item.getId());
wares.setStock("02".equals(repairSoRespVO.getSoType()) ? item.getStock().subtract(count) : item.getStock().add(count));
// 更新进价
wares.setPurPrice(repairSoi.getGoodsPrice());
return wares;
}).collect(Collectors.toList());
waresService.updateBatchById(newWares);
// 获取所有需要操作的数据----生成采购单的时候不直接操作库存放到下面的inWares方法去操作
if (repairSoRespVO.getSoType() != null && !repairSoRespVO.getSoType().equals("01")){
List<DlRepairSoi> goodsList = repairSoRespVO.getGoodsList();
@ -186,7 +166,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
wares.setId(item.getId());
wares.setStock("02".equals(repairSoRespVO.getSoType()) ? item.getStock().subtract(count) : item.getStock().add(count));
// 更新进价
wares.setPurPrice(repairSoi.getGoodsPrice().toString());
wares.setPurPrice(repairSoi.getGoodsPrice());
return wares;
}).collect(Collectors.toList());
waresService.updateBatchById(newWares);
@ -570,6 +550,20 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
item.setStock((item.getStock() == null ? new BigDecimal(0) : item.getStock()).add(new BigDecimal(filterSoi.getInCount())));
});
waresService.updateBatchById(waresList);
// 更新采购单的状态如果是全部入库完了就是03已入库反之不变
// 查该采购单的所有采购配件
List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().eq(DlRepairSoi::getSoId, reqVO.getId()));
// 过滤出入库数量等于采购数量的数据
List<DlRepairSoi> allInSois = sois.stream().filter(item -> item.getInCount().equals(item.getGoodsCount())).collect(Collectors.toList());
// 如果allInSois的size就是sois的size那就是全部都入库了
if (CollectionUtil.isNotEmpty(allInSois) && allInSois.size() == sois.size()) {
// 更新采购单的状态为已入库
baseMapper.update(new LambdaUpdateWrapper<DlRepairSo>()
.set(DlRepairSo::getSoStatus, "03")
.eq(DlRepairSo::getId, reqVO.getId())
);
}
}
}