退料时保证数据的一致性

This commit is contained in:
xiaofajia 2024-11-25 18:08:41 +08:00
parent 15798022e3
commit 21ae569ccd

View File

@ -392,10 +392,15 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
@DSTransactional
public void confirmBack(String id, String image) {
// 更新主表
baseMapper.update(new LambdaUpdateWrapper<DlRepairSo>()
int update = baseMapper.update(new LambdaUpdateWrapper<DlRepairSo>()
.set(DlRepairSo::getSoStatus, SoStatusEnum.RETURNED.getCode())
.eq(DlRepairSo::getId, id)
.and(i -> i.eq(DlRepairSo::getId, id)
.ne(DlRepairSo::getSoStatus, SoStatusEnum.RETURNED.getCode())
.ne(DlRepairSo::getSoStatus, SoStatusEnum.DEPRECATED.getCode()))
);
if (update == 0){
throw exception0(500, "该退料单已有其他人操作");
}
// 查主表
DlRepairSo newSo = baseMapper.selectById(id);
// 通知仓库