库存不足时触发回滚
This commit is contained in:
parent
0093b9c698
commit
aa62bca380
|
|
@ -98,8 +98,7 @@ public class ApprovalEngineServiceImpl implements IApprovalEngineService {
|
|||
|
||||
instanceMapper.insertInstance(instance);
|
||||
|
||||
log.info("创建审批实例成功,实例编号:{},业务类型:{},业务ID:{}",
|
||||
instance.getInstanceCode(), businessType, businessId);
|
||||
log.info("创建审批实例成功,实例编号:{},业务类型:{},业务ID:{}", instance.getInstanceCode(), businessType, businessId);
|
||||
|
||||
// 4. 检查第一个节点是否自动通过
|
||||
if ("1".equals(firstNode.getAutoPass())) {
|
||||
|
|
@ -329,6 +328,7 @@ public class ApprovalEngineServiceImpl implements IApprovalEngineService {
|
|||
|
||||
/**
|
||||
* 执行审批回调
|
||||
* 注意:如果回调执行失败,会抛出异常,触发事务回滚
|
||||
*/
|
||||
private void executeCallback(ApprovalInstance instance, String status) {
|
||||
try {
|
||||
|
|
@ -343,6 +343,8 @@ public class ApprovalEngineServiceImpl implements IApprovalEngineService {
|
|||
} catch (Exception e) {
|
||||
log.error("执行审批回调失败,实例编号:{},业务类型:{}",
|
||||
instance.getInstanceCode(), instance.getBusinessType(), e);
|
||||
// 重新抛出异常,触发事务回滚
|
||||
throw new RuntimeException("审批回调执行失败:" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -352,12 +352,12 @@ public class RepairServiceImpl implements RepairService {
|
|||
if ("装备".equals(toBeRepair.getType())){
|
||||
ToBeRepair bean1 = mapper.selectMaDevInfoByTypeIdAndCode(toBeRepair);
|
||||
if (bean1==null || !"5".equals(bean1.getStatus())){
|
||||
return AjaxResult.error(toBeRepair.getCode()+"编码设备已经处理过");
|
||||
throw new RuntimeException(toBeRepair.getCode()+"编码设备已经处理过");
|
||||
}
|
||||
} else if ("工具".equals(toBeRepair.getType())){
|
||||
ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair);
|
||||
if (bean1==null || !"2".equals(bean1.getStatus())){
|
||||
return AjaxResult.error(toBeRepair.getCode()+"编码设备已经处理过");
|
||||
throw new RuntimeException(toBeRepair.getCode()+"编码设备已经处理过");
|
||||
}
|
||||
}
|
||||
} else if ("数量管理".equals(toBeRepair.getManageMode())){
|
||||
|
|
@ -365,7 +365,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
//todo 目前数量管理的设备都是工具
|
||||
ToBeRepair bean1 = mapper.selectByTypeIdAndCode(toBeRepair);
|
||||
if (bean1==null || bean1.getRepairNum().compareTo(toBeRepair.getRepairNum())<0){
|
||||
return AjaxResult.error(toBeRepair.getTypeModelName()+"剩余维修设备数量不足");
|
||||
throw new RuntimeException(toBeRepair.getTypeModelName()+"剩余维修设备数量不足");
|
||||
}
|
||||
}
|
||||
if (!StringHelper.isNullOrEmptyString(toBeRepair.getAuditStatus())){
|
||||
|
|
@ -424,9 +424,7 @@ public class RepairServiceImpl implements RepairService {
|
|||
}
|
||||
return AjaxResult.success("审核成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error("审核失败");
|
||||
throw new RuntimeException("审批通过回调执行失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue