fix: 修复后端竞态/安全/数据处理问题并移除冗余 outImage 列
首次激活改条件更新消除并发竞态;备份恢复补模型全集与版本校验防清库; 审核列表分页总数、操作日志未捕获 Promise、出库导入重复码、加密密钥可编辑、 溯源码盐以 env 为准、证书按 originKey reconcile、env 加载去重等修复; 新增 parseBigId 防非法入参 500、全局安全响应头、去除 SVG 上传、接入 throttler 限流、 入队失败补偿、hashData 稳定序列化、无效码负缓存、看板已激活口径调整; 移除冗余 TraceCode.outImage 列统一 outImages(迁移 drop_trace_code_out_image)。
This commit is contained in:
@@ -6,7 +6,7 @@ import * as ExcelJS from 'exceljs';
|
||||
import AdmZip from 'adm-zip';
|
||||
import sharp from 'sharp';
|
||||
import { Prisma, RoleType } from '@prisma/client';
|
||||
import { ErrorCode, JobType, OUTBOUND_IMPORT_COLUMNS, QUEUE_NAMES } from '@artveris/shared';
|
||||
import { ErrorCode, JobStatus, JobType, OUTBOUND_IMPORT_COLUMNS, QUEUE_NAMES } from '@artveris/shared';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { StorageService } from '../storage/storage.service';
|
||||
import { JobsService } from '../jobs/jobs.service';
|
||||
@@ -37,10 +37,10 @@ export class OutboundService {
|
||||
const data: Prisma.TraceCodeUpdateInput = {};
|
||||
if ('outTime' in dto) data.outTime = dto.outTime ? new Date(dto.outTime) : null;
|
||||
if ('outImageKeys' in dto || 'outImageKey' in dto) {
|
||||
data.outImage = imageKeys[0] || null;
|
||||
// 无图时写 DB NULL(而非 JSON null),保证出库状态筛选一致
|
||||
data.outImages = imageKeys.length
|
||||
? imageKeys.map((key) => ({ key, type: 'image', name: key.split('/').pop() || '出库实况图' }))
|
||||
: Prisma.JsonNull;
|
||||
: Prisma.DbNull;
|
||||
}
|
||||
if ('remark' in dto) data.remark = dto.remark || null;
|
||||
return this.prisma.traceCode.update({
|
||||
@@ -184,7 +184,14 @@ export class OutboundService {
|
||||
where: { id },
|
||||
data: { status: 'IMPORTING', committedAt: new Date() },
|
||||
});
|
||||
await this.importQueue.add('import', { jobId: job.id, sessionId: id });
|
||||
// 入队失败时回退会话状态为 READY,避免卡在 IMPORTING 且无对应队列任务
|
||||
try {
|
||||
await this.importQueue.add('import', { jobId: job.id, sessionId: id });
|
||||
} catch (e) {
|
||||
await this.prisma.outboundImportSession.update({ where: { id }, data: { status: 'READY', committedAt: null } });
|
||||
await this.jobs.finish(job.id, { status: JobStatus.FAILED, error: (e as Error).message });
|
||||
throw new BusinessException(ErrorCode.INTERNAL_ERROR, '导入任务入队失败,请稍后重试');
|
||||
}
|
||||
return { jobId: job.id, sessionId: id };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user