上菜时间完善

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