审批流异常回滚

This commit is contained in:
syruan 2025-12-18 18:57:23 +08:00
parent aa62bca380
commit e7059dde1e
4 changed files with 10 additions and 5 deletions

View File

@ -56,13 +56,14 @@ public class EquipmentScrapCallback implements IApprovalCallback {
// 4. 调用原有的审批业务逻辑
AjaxResult result = toBeScrapService.auditData(bean);
if (result.get("code").equals(200)) {
log.info("设备报废审批通过业务逻辑执行成功业务ID{}", instance.getBusinessId());
} else {
log.error("设备报废审批通过但业务逻辑执行失败业务ID{},错误信息:{}", instance.getBusinessId(), result.get("msg"));
throw new RuntimeException("报废业务逻辑执行失败:" + result.get("msg"));
}
} catch (Exception e) {
log.error("设备报废审批通过回调执行失败业务ID{}", instance.getBusinessId(), e);
throw new RuntimeException("审批通过回调执行失败:" + e.getMessage());

View File

@ -404,7 +404,7 @@ public class BackChangeServiceImpl implements BackChangeService {
}
// 判断在用数量是否有为0的若有不予审核通过
if (csDeviceDetails.getUseNum().compareTo(BigDecimal.ZERO) == 0) {
return AjaxResult.warn("该条单据中存在在用数量为0的设备无法审核通过请驳回后进行修改");
throw new RuntimeException("该条单据中存在在用数量为0的设备无法审核通过请驳回后进行修改");
}
}
}

View File

@ -518,10 +518,14 @@ public class DevChangeServiceImpl implements DevChangeService {
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult approve(CsDeviceInfo csDeviceInfo) {
csDeviceInfo.setUpdateBy(SecurityUtils.getLoginUser().getUserid().toString());
int num = mapper.approve(csDeviceInfo);
return num > 0 ? AjaxResult.success("审核成功") : AjaxResult.error("审核失败");
if (num <= 0) {
throw new RuntimeException("审核失败,更新数据库失败");
}
return AjaxResult.success("审核成功");
}
/**

View File

@ -55,7 +55,7 @@ public class ToBeScrapServiceImpl implements ToBeScrapService {
public AjaxResult auditData(ToBeScrap bean) {
try {
if (Objects.isNull(bean)) {
return AjaxResult.error("请求参数异常!");
throw new ServiceException("请求参数异常!");
}
if (Objects.isNull(bean.getId())) {
throw new ServiceException("任务ID不能为空");