diff --git a/src/qc/qc.service.spec.ts b/src/qc/qc.service.spec.ts index b2cbb10..826808a 100644 --- a/src/qc/qc.service.spec.ts +++ b/src/qc/qc.service.spec.ts @@ -658,12 +658,16 @@ describe('QcService.handleAbnormal', () => { expect(recordAbnormalUpdate).not.toHaveBeenCalled(); }); - it('处理 → 更新 handle_status/handle_result', async () => { + it('处理 → 更新 handle_status/handle_result + 坐标 Decimal → string', async () => { const recordAbnormalFindUnique = vi.fn().mockResolvedValue({ id: 'a1', handleStatus: 'open' }); - const recordAbnormalUpdate = vi.fn().mockResolvedValue({ id: 'a1' }); + const recordAbnormalUpdate = vi.fn().mockResolvedValue({ + id: 'a1', + visitLat: { toString: () => '25.010000' }, + visitLng: null, + }); const { service } = makeService({ recordAbnormalFindUnique, recordAbnormalUpdate }); - await runWithRequestContext(ctx, () => + const res = await runWithRequestContext(ctx, () => service.handleAbnormal('a1', { handleStatus: 'closed', handleResult: '已通知家属' }), ); @@ -672,6 +676,7 @@ describe('QcService.handleAbnormal', () => { where: { id: 'a1' }, data: { handleStatus: 'closed', handleResult: '已通知家属' }, }); + expect(res).toMatchObject({ id: 'a1', visitLat: '25.010000', visitLng: null }); }); it('handleResult 缺省 → 更新为 null', async () => { diff --git a/src/qc/qc.service.ts b/src/qc/qc.service.ts index dd96bfb..0ed7982 100644 --- a/src/qc/qc.service.ts +++ b/src/qc/qc.service.ts @@ -241,16 +241,17 @@ export class QcService { }); } - /** 异常处理:质控员更新 handle_status/handle_result。 */ + /** 异常处理:质控员更新 handle_status/handle_result;返回前坐标 Decimal → string。 */ async handleAbnormal(id: string, dto: HandleAbnormalDto) { const abnormal = await this.prisma.client.recordAbnormal.findUnique({ where: { id } }); if (!abnormal) { throw new BusinessException(ErrorCodes.ABNORMAL_NOT_FOUND, '异常上报不存在', HttpStatus.NOT_FOUND); } - return this.prisma.client.recordAbnormal.update({ + const updated = await this.prisma.client.recordAbnormal.update({ where: { id }, data: { handleStatus: dto.handleStatus, handleResult: dto.handleResult ?? null }, }); + return this.serializeAbnormal(updated); } /** 批量放行:安全边界(异常/未执行/加项/时长过短/已补正)任一命中 → QC_BATCH_UNSAFE;否则逐条 pass。 */ @@ -334,6 +335,15 @@ export class QcService { } } + /** 异常到访坐标 Decimal → string(null 保持 null),复用 abnormal 模块 list/report 口径。 */ + private serializeAbnormal(abnormal: Record): Record { + return { + ...abnormal, + visitLat: abnormal.visitLat != null ? abnormal.visitLat.toString() : null, + visitLng: abnormal.visitLng != null ? abnormal.visitLng.toString() : null, + }; + } + /** Prisma Decimal 坐标转字符串(null 保持 null),复用 C3 口径,含异常到访坐标。 */ private serializeRecord(record: Record): Record { const serialized: Record = {