上菜时间完善

This commit is contained in:
张松
2025-11-27 14:14:20 +08:00
parent d483fa0ddc
commit 3718d5e5b5

View File

@@ -86,30 +86,32 @@
List<ConsStockFlow> entityList = BeanUtil.copyToList(param.getBodyList(), ConsStockFlow.class);
List<ConsStockFlow> insertList = new ArrayList<>();
List<ConsInfo> updateStockList = new ArrayList<>();
for (ConsStockFlow entity : entityList) {
for (ConsInOutStockBodyParam entity : param.getBodyList()) {
ConsStockFlow consStockFlow = BeanUtil.copyProperties(entity, ConsStockFlow.class);
BeanUtil.copyProperties(head, entity, CopyOptions.create().ignoreNullValue());
entity.setShopId(shopId);
entity.setInOutType(InOutTypeEnum.IN.value());
entity.setInOutItem(InOutItemEnum.MANUAL_IN.value());
entity.setCreateUserId(createUserId);
entity.setCreateUserName(createUserName);
Long conId = entity.getConId();
consStockFlow.setShopId(shopId);
consStockFlow.setInOutType(InOutTypeEnum.IN.value());
consStockFlow.setInOutItem(InOutItemEnum.MANUAL_IN.value());
consStockFlow.setCreateUserId(createUserId);
consStockFlow.setCreateUserName(createUserName);
String conId = entity.getConId();
ConsInfo consInfo;
if (entity.getId() == null) {
if (entity.getConId() == null) {
consInfo = consInfoMapper.selectOneByQuery(new QueryWrapper().like(ConsInfo::getConName, entity.getConName())
.eq(ConsInfo::getShopId, shopId).limit(1));
entity.setConId(consInfo == null ? null : consInfo.getId());
entity.setConId(consInfo == null ? null : consInfo.getId().toString());
consStockFlow.setConId(consInfo == null ? null : consInfo.getId());
}else {
consInfo = consInfoMapper.selectOneById(conId);
}
if (consInfo == null) {
continue;
}
entity.setBeforeNumber(consInfo.getStockNumber());
entity.setAfterNumber(NumberUtil.add(entity.getBeforeNumber(), entity.getInOutNumber()));
insertList.add(entity);
consInfo.setStockNumber(entity.getAfterNumber());
consStockFlow.setBeforeNumber(consInfo.getStockNumber());
consStockFlow.setAfterNumber(NumberUtil.add(consStockFlow.getBeforeNumber(), entity.getInOutNumber()));
insertList.add(consStockFlow);
consInfo.setStockNumber(consStockFlow.getAfterNumber());
updateStockList.add(consInfo);
}
super.saveBatch(insertList);