修复中介库
This commit is contained in:
@@ -39,6 +39,7 @@ public class CcdiBankTagServiceImpl implements ICcdiBankTagService {
|
||||
private static final String STATUS_RUNNING = "RUNNING";
|
||||
private static final String STATUS_SUCCESS = "SUCCESS";
|
||||
private static final String STATUS_FAILED = "FAILED";
|
||||
private static final String TASK_ERROR_MESSAGE_FALLBACK = "任务失败,详细异常请查看后端日志";
|
||||
private static final String RESULT_TYPE_STATEMENT = "STATEMENT";
|
||||
private static final String OBJECT_TYPE_STAFF_ID_CARD = "STAFF_ID_CARD";
|
||||
|
||||
@@ -147,12 +148,11 @@ public class CcdiBankTagServiceImpl implements ICcdiBankTagService {
|
||||
return task.getId();
|
||||
} catch (Exception ex) {
|
||||
task.setStatus(STATUS_FAILED);
|
||||
task.setErrorMessage(ex.getMessage());
|
||||
task.setEndTime(new Date());
|
||||
task.setNeedRerun(null);
|
||||
task.setUpdateBy(operator);
|
||||
task.setUpdateTime(new Date());
|
||||
taskMapper.updateTask(task);
|
||||
updateFailedTaskSafely(task, ex);
|
||||
projectService.updateProjectStatus(projectId, CcdiProjectStatusConstants.PROCESSING, operator);
|
||||
log.error("【流水标签】任务执行失败: taskId={}, projectId={}, modelCode={}, triggerType={}, error={}",
|
||||
task.getId(), projectId, modelCode, triggerType, ex.getMessage(), ex);
|
||||
@@ -359,4 +359,44 @@ public class CcdiBankTagServiceImpl implements ICcdiBankTagService {
|
||||
}
|
||||
return Integer.parseInt(value);
|
||||
}
|
||||
|
||||
private void updateFailedTaskSafely(CcdiBankTagTask task, Exception ex) {
|
||||
task.setErrorMessage(buildSafeTaskErrorMessage(ex));
|
||||
try {
|
||||
taskMapper.updateTask(task);
|
||||
} catch (Exception updateEx) {
|
||||
log.error("【流水标签】写入任务失败状态异常: taskId={}, error={}",
|
||||
task.getId(), updateEx.getMessage(), updateEx);
|
||||
task.setErrorMessage(TASK_ERROR_MESSAGE_FALLBACK);
|
||||
taskMapper.updateTask(task);
|
||||
}
|
||||
}
|
||||
|
||||
private static String buildSafeTaskErrorMessage(Throwable throwable) {
|
||||
if (throwable == null) {
|
||||
return TASK_ERROR_MESSAGE_FALLBACK;
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (throwable.getMessage() != null && !throwable.getMessage().isBlank()) {
|
||||
builder.append(throwable.getMessage().trim());
|
||||
}
|
||||
|
||||
Throwable rootCause = throwable;
|
||||
while (rootCause.getCause() != null && rootCause.getCause() != rootCause) {
|
||||
rootCause = rootCause.getCause();
|
||||
}
|
||||
|
||||
if (rootCause != throwable && rootCause.getMessage() != null && !rootCause.getMessage().isBlank()) {
|
||||
String rootMessage = rootCause.getMessage().trim();
|
||||
if (!builder.toString().contains(rootMessage)) {
|
||||
if (!builder.isEmpty()) {
|
||||
builder.append(" | rootCause=");
|
||||
}
|
||||
builder.append(rootMessage);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.isEmpty() ? TASK_ERROR_MESSAGE_FALLBACK : builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -924,7 +924,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from ccdi_purchase_transaction pt
|
||||
inner join (
|
||||
<include refid="projectScopedDirectStaffSql"/>
|
||||
) project_staff on project_staff.staffId = pt.applicant_id
|
||||
) project_staff on project_staff.staffId COLLATE utf8mb4_general_ci = pt.applicant_id COLLATE utf8mb4_general_ci
|
||||
where IFNULL(pt.actual_amount, 0) > 100000
|
||||
union
|
||||
select distinct
|
||||
@@ -935,7 +935,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from ccdi_purchase_transaction pt
|
||||
inner join (
|
||||
<include refid="projectScopedDirectStaffSql"/>
|
||||
) project_staff on project_staff.staffId = pt.purchase_leader_id
|
||||
) project_staff on project_staff.staffId COLLATE utf8mb4_general_ci = pt.purchase_leader_id COLLATE utf8mb4_general_ci
|
||||
where pt.purchase_leader_id is not null
|
||||
and IFNULL(pt.actual_amount, 0) > 100000
|
||||
) t
|
||||
@@ -975,7 +975,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from ccdi_purchase_transaction pt
|
||||
inner join (
|
||||
<include refid="projectScopedDirectStaffSql"/>
|
||||
) project_staff on project_staff.staffId = pt.applicant_id
|
||||
) project_staff on project_staff.staffId COLLATE utf8mb4_general_ci = pt.applicant_id COLLATE utf8mb4_general_ci
|
||||
where IFNULL(pt.actual_amount, 0) > 0
|
||||
and IFNULL(pt.supplier_name, '') <> ''
|
||||
|
||||
@@ -989,7 +989,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from ccdi_purchase_transaction pt
|
||||
inner join (
|
||||
<include refid="projectScopedDirectStaffSql"/>
|
||||
) project_staff on project_staff.staffId = pt.purchase_leader_id
|
||||
) project_staff on project_staff.staffId COLLATE utf8mb4_general_ci = pt.purchase_leader_id COLLATE utf8mb4_general_ci
|
||||
where pt.purchase_leader_id is not null
|
||||
and IFNULL(pt.actual_amount, 0) > 0
|
||||
and IFNULL(pt.supplier_name, '') <> ''
|
||||
@@ -1006,7 +1006,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from ccdi_purchase_transaction pt
|
||||
inner join (
|
||||
<include refid="projectScopedDirectStaffSql"/>
|
||||
) project_staff on project_staff.staffId = pt.applicant_id
|
||||
) project_staff on project_staff.staffId COLLATE utf8mb4_general_ci = pt.applicant_id COLLATE utf8mb4_general_ci
|
||||
where IFNULL(pt.actual_amount, 0) > 0
|
||||
|
||||
union
|
||||
@@ -1018,7 +1018,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from ccdi_purchase_transaction pt
|
||||
inner join (
|
||||
<include refid="projectScopedDirectStaffSql"/>
|
||||
) project_staff on project_staff.staffId = pt.purchase_leader_id
|
||||
) project_staff on project_staff.staffId COLLATE utf8mb4_general_ci = pt.purchase_leader_id COLLATE utf8mb4_general_ci
|
||||
where pt.purchase_leader_id is not null
|
||||
and IFNULL(pt.actual_amount, 0) > 0
|
||||
) source_total
|
||||
|
||||
Reference in New Issue
Block a user