1
This commit is contained in:
@@ -485,8 +485,9 @@ class PlaAccountService {
|
||||
finalParams.keyword = account.keyword;
|
||||
}
|
||||
|
||||
// get_job_list:command 只约定 pageCount + tabLabel(与前端一致),入库 keyword 由 jobManager 用 tabLabel 推导
|
||||
// get_job_list:优先使用调用方显式传入的 tabLabel;仅在未传时回退到 resume_info.deliver_tab_label
|
||||
if (commandTypeSnake === 'get_job_list') {
|
||||
const passedTabLabel = finalParams.tabLabel != null ? String(finalParams.tabLabel).trim() : '';
|
||||
try {
|
||||
const resume_info = db.getModel('resume_info');
|
||||
const resume = await resume_info.findOne({
|
||||
@@ -494,7 +495,7 @@ class PlaAccountService {
|
||||
order: [['last_modify_time', 'DESC']],
|
||||
attributes: ['deliver_tab_label']
|
||||
});
|
||||
if (resume && resume.deliver_tab_label) {
|
||||
if (!passedTabLabel && resume && resume.deliver_tab_label) {
|
||||
finalParams.tabLabel = String(resume.deliver_tab_label).trim();
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -639,6 +640,35 @@ class PlaAccountService {
|
||||
command_params: JSON.stringify(commandParams)
|
||||
};
|
||||
|
||||
// 防止 result 超长导致 "Data too long for column 'result'"
|
||||
const serialize_retry_result_for_db = (value) => {
|
||||
const max_length = 60000;
|
||||
try {
|
||||
let text = JSON.stringify(value || {});
|
||||
if (text.length <= max_length) {
|
||||
return text;
|
||||
}
|
||||
const summary = {
|
||||
success: !!(value && value.success),
|
||||
message: (value && value.message) ? String(value.message) : '重试结果过长,已摘要存储',
|
||||
truncated: true,
|
||||
raw_length: text.length,
|
||||
preview: text.substring(0, 1000)
|
||||
};
|
||||
text = JSON.stringify(summary);
|
||||
if (text.length > max_length) {
|
||||
return text.substring(0, max_length - 12) + '...[已截断]';
|
||||
}
|
||||
return text;
|
||||
} catch (error) {
|
||||
return JSON.stringify({
|
||||
success: false,
|
||||
message: '结果序列化失败',
|
||||
error: error.message || 'unknown'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 执行指令并同步更新当前指令记录状态
|
||||
const start_time = new Date();
|
||||
try {
|
||||
@@ -650,7 +680,7 @@ class PlaAccountService {
|
||||
start_time: start_time,
|
||||
end_time: end_time,
|
||||
duration: end_time.getTime() - start_time.getTime(),
|
||||
result: JSON.stringify(result || {})
|
||||
result: serialize_retry_result_for_db(result)
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user