整车绑定:库存逻辑优化

This commit is contained in:
attiya 2025-11-28 09:53:30 +08:00
parent 34fdf8cffc
commit 9ff710aaec

View File

@ -105,6 +105,10 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
throw new EbikeException("该中控不存在");
}
if (ecuInfo.getIsClaim()) {
throw new EbikeException("该中控暂时不在库中");
}
//判断中控与电池关系
if (ecuInfo.getBindBattery() && StringUtil.hasText(bindVo.getBatteryCode())) {
throw new EbikeException("该中控与电池一体无需额外绑定电池");
@ -162,13 +166,10 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
List<EbikeInventoryRecord> list = new ArrayList<>();
//TODO优化封装
for (int i = 1; i < 4; i++) {
if (i != 2) {
if (i == 1 && !ecuInfo.getBindBattery()) {
if (!ecuInfo.getBindBattery()){
EbikeInventoryVo inventoryVo = EbikeInventoryVo.builder()
.operatorId(operatorId)
.inventoryType(i)
.inventoryType(1)
.inventoryNum(-1)
.build();
EbikeInventoryRecord inventoryRecord = EbikeInventoryRecord.builder()
@ -179,10 +180,15 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
.build();
list.add(inventoryRecord);
inventoryService.reduceInventory(inventoryVo);
} else if (i == 3) {
}else {
ecuInfo.setIsClaim(Boolean.TRUE);
ebikeEcuInfoService.updateById(ecuInfo);
}
if (bindVo.getHasHelme()){
EbikeInventoryVo inventoryVo = EbikeInventoryVo.builder()
.operatorId(operatorId)
.inventoryType(i)
.inventoryType(2)
.inventoryNum(-1)
.build();
EbikeInventoryRecord inventoryRecord = EbikeInventoryRecord.builder()
@ -194,10 +200,10 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
list.add(inventoryRecord);
inventoryService.reduceInventory(inventoryVo);
}
} else if (bindVo.getHasHelme()) {
EbikeInventoryVo inventoryVo = EbikeInventoryVo.builder()
.operatorId(operatorId)
.inventoryType(i)
.inventoryType(3)
.inventoryNum(-1)
.build();
EbikeInventoryRecord inventoryRecord = EbikeInventoryRecord.builder()
@ -208,8 +214,7 @@ public class EbikeBikeInfoServiceImpl extends ServiceImpl<EbikeBikeInfoMapper, E
.build();
list.add(inventoryRecord);
inventoryService.reduceInventory(inventoryVo);
}
}
recordService.saveBatch(list);
//录入最终数据