@cpzxrobot/sdk 1.3.125 → 1.3.126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/aiform_gateway.ts CHANGED
@@ -12,6 +12,14 @@ import type {
12
12
  AiformReplyDetailResponse,
13
13
  AiformConfirmResponse,
14
14
  AiformReplyListResponse,
15
+ AiformTemplateReplyResponse,
16
+ AiformTemplateReplyDetailResponse,
17
+ AiformTemplateConfirmResponse,
18
+ AiformRecordConfirmResponse,
19
+ AiformRecordHistoryResponse,
20
+ AiformStructTypeResponse,
21
+ AiformStructListResponse,
22
+ AiformStructDetailResponse,
15
23
  } from ".";
16
24
 
17
25
  export class AiformGateway extends Object {
@@ -151,6 +159,7 @@ export class AiformGateway extends Object {
151
159
 
152
160
  /**
153
161
  * 按版本号将历史发布到主表
162
+ * POST /api/v2/aiform/template/{templateId}/history/publish
154
163
  * @param templateId 模板ID
155
164
  * @param snapshotVersion 解析版本号
156
165
  * @returns Promise 包含更新后的模板
@@ -165,13 +174,138 @@ export class AiformGateway extends Object {
165
174
  throw new Error('解析版本号必须大于0');
166
175
  }
167
176
 
168
- return axios.post(`/api/v2/aiform/template/${templateId}/history/${snapshotVersion}/publish`).then((res) => {
177
+ return axios.post(`/api/v2/aiform/template/${templateId}/history/publish`, {
178
+ snapshotVersion
179
+ }).then((res) => {
169
180
  if (res.data.code !== 200) {
170
181
  throw new Error(res.data.message || '发布历史失败');
171
182
  }
172
183
  return res.data;
173
184
  });
174
185
  },
186
+
187
+ /**
188
+ * 提交模板 Reply(异步)
189
+ * POST /api/v2/aiform/template/reply
190
+ * @param templateId 模板ID
191
+ * @param reply 用户修改意见
192
+ * @param replyId 链式调整的 replyId(可选)
193
+ * @returns Promise 包含 replyId、templateId 和 status
194
+ */
195
+ reply: async (templateId: number, reply: string, replyId?: number): Promise<AiformTemplateReplyResponse> => {
196
+ const axios = await this.context.ready;
197
+
198
+ if (!templateId) {
199
+ throw new Error('模板ID不能为空');
200
+ }
201
+ if (!reply) {
202
+ throw new Error('反馈内容不能为空');
203
+ }
204
+
205
+ const data: any = {
206
+ templateId,
207
+ reply
208
+ };
209
+
210
+ if (replyId) {
211
+ data.replyId = replyId;
212
+ }
213
+
214
+ return axios.post(`/api/v2/aiform/template/reply`, data).then((res) => {
215
+ if (res.data.code !== 200) {
216
+ throw new Error(res.data.message || '提交反馈失败');
217
+ }
218
+ return res.data;
219
+ });
220
+ },
221
+
222
+ /**
223
+ * 查询模板 Reply 历史列表
224
+ * GET /api/v2/aiform/template/reply/list/{templateId}
225
+ * @param templateId 模板ID
226
+ * @returns Promise 包含 reply 记录列表
227
+ */
228
+ getReplyList: async (templateId: number): Promise<any> => {
229
+ const axios = await this.context.ready;
230
+
231
+ if (!templateId) {
232
+ throw new Error('模板ID不能为空');
233
+ }
234
+
235
+ return axios.get(`/api/v2/aiform/template/reply/list/${templateId}`).then((res) => {
236
+ if (res.data.code !== 200) {
237
+ throw new Error(res.data.message || '获取reply历史失败');
238
+ }
239
+ return res.data;
240
+ });
241
+ },
242
+
243
+ /**
244
+ * 按 ReplyId 轮询模板 Reply 结果
245
+ * GET /api/v2/aiform/template/reply/detail/{replyId}
246
+ * @param replyId reply记录ID
247
+ * @returns Promise 包含 replyId、templateId、status 和 result
248
+ */
249
+ getReplyDetail: async (replyId: number): Promise<AiformTemplateReplyDetailResponse> => {
250
+ const axios = await this.context.ready;
251
+
252
+ if (!replyId) {
253
+ throw new Error('reply记录ID不能为空');
254
+ }
255
+
256
+ return axios.get(`/api/v2/aiform/template/reply/detail/${replyId}`).then((res) => {
257
+ if (res.data.code !== 200) {
258
+ throw new Error(res.data.message || '获取解析结果失败');
259
+ }
260
+ return res.data;
261
+ });
262
+ },
263
+
264
+ /**
265
+ * 确认 Reply 写入历史快照(可带手工润色)
266
+ * POST /api/v2/aiform/template/{templateId}/reply/confirm
267
+ * @param templateId 模板ID
268
+ * @param replyId 要确认的 replyId
269
+ * @param name 手工覆盖名称(可选)
270
+ * @param content 手工覆盖模板说明(可选)
271
+ * @param parsePrompt 手工覆盖解析提示词(可选)
272
+ * @param attention 手工覆盖注意事项(可选)
273
+ * @returns Promise 包含历史快照
274
+ */
275
+ confirmReply: async (templateId: number, replyId: number, name?: string, content?: string, parsePrompt?: string, attention?: any): Promise<AiformTemplateConfirmResponse> => {
276
+ const axios = await this.context.ready;
277
+
278
+ if (!templateId) {
279
+ throw new Error('模板ID不能为空');
280
+ }
281
+ if (!replyId) {
282
+ throw new Error('reply记录ID不能为空');
283
+ }
284
+
285
+ const data: any = {
286
+ replyId
287
+ };
288
+
289
+ if (name !== undefined) {
290
+ data.name = name;
291
+ }
292
+ if (content !== undefined) {
293
+ data.content = content;
294
+ }
295
+ if (parsePrompt !== undefined) {
296
+ data.parsePrompt = parsePrompt;
297
+ }
298
+ if (attention !== undefined) {
299
+ data.attention = attention;
300
+ }
301
+
302
+ return axios.post(`/api/v2/aiform/template/${templateId}/reply/confirm`, data).then((res) => {
303
+ if (res.data.code !== 200) {
304
+ throw new Error(res.data.message || '确认保存失败');
305
+ }
306
+ return res.data;
307
+ });
308
+ },
175
309
  };
176
310
  }
177
311
 
@@ -269,14 +403,15 @@ export class AiformGateway extends Object {
269
403
  },
270
404
 
271
405
  /**
272
- * 根据解析结果提交反馈(reply)
406
+ * 提交文件 Reply(异步)
273
407
  * POST /api/v2/aiform/file/reply
274
408
  * @param code 文件业务编码
275
409
  * @param reply 用户的修改意见/反馈内容
410
+ * @param replyId 链式调整的 replyId(可选)
276
411
  * @returns Promise 包含 replyId、status 和 accessUrl
277
412
  * 注意:接口为异步,立即返回 replyId 与 status=1,需使用 getReplyDetail 按 replyId 轮询直至 status=2 或 0
278
413
  */
279
- reply: async (code: string, reply: string): Promise<AiformReplyResponse> => {
414
+ reply: async (code: string, reply: string, replyId?: number): Promise<AiformReplyResponse> => {
280
415
  const axios = await this.context.ready;
281
416
 
282
417
  if (!code) {
@@ -286,10 +421,16 @@ export class AiformGateway extends Object {
286
421
  throw new Error('反馈内容不能为空');
287
422
  }
288
423
 
289
- return axios.post(`/api/v2/aiform/file/reply`, {
424
+ const data: any = {
290
425
  code,
291
426
  reply
292
- }).then((res) => {
427
+ };
428
+
429
+ if (replyId) {
430
+ data.replyId = replyId;
431
+ }
432
+
433
+ return axios.post(`/api/v2/aiform/file/reply`, data).then((res) => {
293
434
  if (res.data.code !== 200) {
294
435
  throw new Error(res.data.message || '提交反馈失败');
295
436
  }
@@ -298,42 +439,76 @@ export class AiformGateway extends Object {
298
439
  },
299
440
 
300
441
  /**
301
- * 用户确认并保存
302
- * @param id 解析结果记录ID
303
- * @param content 表格文本,markdown表格格式
304
- * @param headerRowCount 表头行数(可选)
305
- * @param headers 表头单元格列表(可选)
442
+ * 用户确认并保存(Markdown)
443
+ * POST /api/v2/aiform/file/confirm
444
+ * @param code 文件业务编码
445
+ * @param replyId 已成功的 replyId(可选)
446
+ * @param content 确认的 Markdown 全文(可选)
306
447
  * @returns Promise 包含保存结果
307
448
  */
308
- confirm: async (id: number, content: string, headerRowCount?: number, headers?: any[]): Promise<AiformConfirmResponse> => {
449
+ confirm: async (code: string, replyId?: number, content?: string): Promise<AiformConfirmResponse> => {
309
450
  const axios = await this.context.ready;
310
451
 
311
- if (!id) {
312
- throw new Error('解析结果记录ID不能为空');
313
- }
314
- if (!content) {
315
- throw new Error('表格内容不能为空');
452
+ if (!code) {
453
+ throw new Error('文件业务编码不能为空');
316
454
  }
317
455
 
318
456
  const data: any = {
319
- content,
457
+ code
320
458
  };
321
459
 
322
- if (headerRowCount !== undefined) {
323
- data.headerRowCount = headerRowCount;
460
+ if (replyId) {
461
+ data.replyId = replyId;
324
462
  }
463
+ if (content !== undefined) {
464
+ data.content = content;
465
+ }
466
+
467
+ return axios.post(`/api/v2/aiform/file/confirm`, data).then((res) => {
468
+ if (res.data.code !== 200) {
469
+ throw new Error(res.data.message || '确认保存失败');
470
+ }
471
+ return res.data;
472
+ });
473
+ },
474
+
475
+ /**
476
+ * 查询确认主表当前快照
477
+ * GET /api/v2/aiform/file/confirm/current/{code}
478
+ * @param code 文件业务编码
479
+ * @returns Promise 包含当前确认快照
480
+ */
481
+ getConfirmCurrent: async (code: string): Promise<AiformRecordConfirmResponse> => {
482
+ const axios = await this.context.ready;
325
483
 
326
- if (headers) {
327
- data.headers = headers;
484
+ if (!code) {
485
+ throw new Error('文件业务编码不能为空');
328
486
  }
329
487
 
330
- return axios.post(`/api/v2/aiform/file/confirm?id=${id}`, data, {
331
- headers: {
332
- 'Content-Type': 'application/json'
488
+ return axios.get(`/api/v2/aiform/file/confirm/current/${code}`).then((res) => {
489
+ if (res.data.code !== 200) {
490
+ throw new Error(res.data.message || '获取确认快照失败');
333
491
  }
334
- }).then((res) => {
492
+ return res.data;
493
+ });
494
+ },
495
+
496
+ /**
497
+ * 查询确认内容历史快照
498
+ * GET /api/v2/aiform/file/confirm/history/{code}
499
+ * @param code 文件业务编码
500
+ * @returns Promise 包含确认历史快照列表
501
+ */
502
+ getConfirmHistory: async (code: string): Promise<AiformRecordHistoryResponse> => {
503
+ const axios = await this.context.ready;
504
+
505
+ if (!code) {
506
+ throw new Error('文件业务编码不能为空');
507
+ }
508
+
509
+ return axios.get(`/api/v2/aiform/file/confirm/history/${code}`).then((res) => {
335
510
  if (res.data.code !== 200) {
336
- throw new Error(res.data.message || '确认保存失败');
511
+ throw new Error(res.data.message || '获取确认历史失败');
337
512
  }
338
513
  return res.data;
339
514
  });
@@ -380,4 +555,107 @@ export class AiformGateway extends Object {
380
555
  },
381
556
  };
382
557
  }
558
+
559
+ get data() {
560
+ return {
561
+ /**
562
+ * 按工厂 + structType 查询已落库表头列表
563
+ * GET /api/v2/form/pigfarm/list
564
+ * @param factoryId 工厂ID
565
+ * @param structType 报表结构化类型
566
+ * @returns Promise 包含表头列表
567
+ */
568
+ list: async (factoryId: number, structType: string): Promise<AiformStructListResponse> => {
569
+ const axios = await this.context.ready;
570
+
571
+ if (!factoryId) {
572
+ throw new Error('工厂ID不能为空');
573
+ }
574
+ if (!structType) {
575
+ throw new Error('结构化类型不能为空');
576
+ }
577
+
578
+ return axios.get(`/api/v2/form/pigfarm/list`, {
579
+ params: {
580
+ factoryId,
581
+ structType
582
+ }
583
+ }).then((res) => {
584
+ if (res.data.code !== 200) {
585
+ throw new Error(res.data.message || '获取结构化列表失败');
586
+ }
587
+ return res.data;
588
+ });
589
+ },
590
+
591
+ /**
592
+ * 按表头 id 查询完整结构化内容
593
+ * GET /api/v2/form/pigfarm/detail
594
+ * @param id 表头ID
595
+ * @returns Promise 包含完整结构化内容
596
+ */
597
+ detail: async (id: number): Promise<AiformStructDetailResponse> => {
598
+ const axios = await this.context.ready;
599
+
600
+ if (!id) {
601
+ throw new Error('表头ID不能为空');
602
+ }
603
+
604
+ return axios.get(`/api/v2/form/pigfarm/detail`, {
605
+ params: {
606
+ id
607
+ }
608
+ }).then((res) => {
609
+ if (res.data.code !== 200) {
610
+ throw new Error(res.data.message || '获取结构化详情失败');
611
+ }
612
+ return res.data;
613
+ });
614
+ },
615
+
616
+ /**
617
+ * 查询标准化支持的 structType 枚举
618
+ * GET /api/v2/form/pigfarm/standardize/struct-types
619
+ * @returns Promise 包含 structType 列表
620
+ */
621
+ getStructTypes: async (): Promise<AiformStructTypeResponse> => {
622
+ const axios = await this.context.ready;
623
+
624
+ return axios.get(`/api/v2/form/pigfarm/standardize/struct-types`).then((res) => {
625
+ if (res.data.code !== 200) {
626
+ throw new Error(res.data.message || '获取结构化类型失败');
627
+ }
628
+ return res.data;
629
+ });
630
+ },
631
+
632
+ /**
633
+ * 从已确认 Markdown 写入结构化表
634
+ * POST /api/v2/form/pigfarm/standardize
635
+ * @param code 文件业务编码
636
+ * @param structType 报表结构化类型
637
+ * @returns Promise 包含保存结果
638
+ */
639
+ standardize: async (code: string, structType: string): Promise<any> => {
640
+ const axios = await this.context.ready;
641
+
642
+ if (!code) {
643
+ throw new Error('文件业务编码不能为空');
644
+ }
645
+ if (!structType) {
646
+ throw new Error('结构化类型不能为空');
647
+ }
648
+
649
+ return axios.post(`/api/v2/form/pigfarm/standardize`, {
650
+ code,
651
+ structType
652
+ }).then((res) => {
653
+ if (res.data.code !== 200) {
654
+ throw new Error(res.data.message || '标准化失败');
655
+ }
656
+ return res.data;
657
+ });
658
+ },
659
+ };
660
+ }
383
661
  }
@@ -125,6 +125,7 @@ class AiformGateway extends Object {
125
125
  }),
126
126
  /**
127
127
  * 按版本号将历史发布到主表
128
+ * POST /api/v2/aiform/template/{templateId}/history/publish
128
129
  * @param templateId 模板ID
129
130
  * @param snapshotVersion 解析版本号
130
131
  * @returns Promise 包含更新后的模板
@@ -137,13 +138,122 @@ class AiformGateway extends Object {
137
138
  if (!snapshotVersion || snapshotVersion <= 0) {
138
139
  throw new Error('解析版本号必须大于0');
139
140
  }
140
- return axios.post(`/api/v2/aiform/template/${templateId}/history/${snapshotVersion}/publish`).then((res) => {
141
+ return axios.post(`/api/v2/aiform/template/${templateId}/history/publish`, {
142
+ snapshotVersion
143
+ }).then((res) => {
141
144
  if (res.data.code !== 200) {
142
145
  throw new Error(res.data.message || '发布历史失败');
143
146
  }
144
147
  return res.data;
145
148
  });
146
149
  }),
150
+ /**
151
+ * 提交模板 Reply(异步)
152
+ * POST /api/v2/aiform/template/reply
153
+ * @param templateId 模板ID
154
+ * @param reply 用户修改意见
155
+ * @param replyId 链式调整的 replyId(可选)
156
+ * @returns Promise 包含 replyId、templateId 和 status
157
+ */
158
+ reply: (templateId, reply, replyId) => __awaiter(this, void 0, void 0, function* () {
159
+ const axios = yield this.context.ready;
160
+ if (!templateId) {
161
+ throw new Error('模板ID不能为空');
162
+ }
163
+ if (!reply) {
164
+ throw new Error('反馈内容不能为空');
165
+ }
166
+ const data = {
167
+ templateId,
168
+ reply
169
+ };
170
+ if (replyId) {
171
+ data.replyId = replyId;
172
+ }
173
+ return axios.post(`/api/v2/aiform/template/reply`, data).then((res) => {
174
+ if (res.data.code !== 200) {
175
+ throw new Error(res.data.message || '提交反馈失败');
176
+ }
177
+ return res.data;
178
+ });
179
+ }),
180
+ /**
181
+ * 查询模板 Reply 历史列表
182
+ * GET /api/v2/aiform/template/reply/list/{templateId}
183
+ * @param templateId 模板ID
184
+ * @returns Promise 包含 reply 记录列表
185
+ */
186
+ getReplyList: (templateId) => __awaiter(this, void 0, void 0, function* () {
187
+ const axios = yield this.context.ready;
188
+ if (!templateId) {
189
+ throw new Error('模板ID不能为空');
190
+ }
191
+ return axios.get(`/api/v2/aiform/template/reply/list/${templateId}`).then((res) => {
192
+ if (res.data.code !== 200) {
193
+ throw new Error(res.data.message || '获取reply历史失败');
194
+ }
195
+ return res.data;
196
+ });
197
+ }),
198
+ /**
199
+ * 按 ReplyId 轮询模板 Reply 结果
200
+ * GET /api/v2/aiform/template/reply/detail/{replyId}
201
+ * @param replyId reply记录ID
202
+ * @returns Promise 包含 replyId、templateId、status 和 result
203
+ */
204
+ getReplyDetail: (replyId) => __awaiter(this, void 0, void 0, function* () {
205
+ const axios = yield this.context.ready;
206
+ if (!replyId) {
207
+ throw new Error('reply记录ID不能为空');
208
+ }
209
+ return axios.get(`/api/v2/aiform/template/reply/detail/${replyId}`).then((res) => {
210
+ if (res.data.code !== 200) {
211
+ throw new Error(res.data.message || '获取解析结果失败');
212
+ }
213
+ return res.data;
214
+ });
215
+ }),
216
+ /**
217
+ * 确认 Reply 写入历史快照(可带手工润色)
218
+ * POST /api/v2/aiform/template/{templateId}/reply/confirm
219
+ * @param templateId 模板ID
220
+ * @param replyId 要确认的 replyId
221
+ * @param name 手工覆盖名称(可选)
222
+ * @param content 手工覆盖模板说明(可选)
223
+ * @param parsePrompt 手工覆盖解析提示词(可选)
224
+ * @param attention 手工覆盖注意事项(可选)
225
+ * @returns Promise 包含历史快照
226
+ */
227
+ confirmReply: (templateId, replyId, name, content, parsePrompt, attention) => __awaiter(this, void 0, void 0, function* () {
228
+ const axios = yield this.context.ready;
229
+ if (!templateId) {
230
+ throw new Error('模板ID不能为空');
231
+ }
232
+ if (!replyId) {
233
+ throw new Error('reply记录ID不能为空');
234
+ }
235
+ const data = {
236
+ replyId
237
+ };
238
+ if (name !== undefined) {
239
+ data.name = name;
240
+ }
241
+ if (content !== undefined) {
242
+ data.content = content;
243
+ }
244
+ if (parsePrompt !== undefined) {
245
+ data.parsePrompt = parsePrompt;
246
+ }
247
+ if (attention !== undefined) {
248
+ data.attention = attention;
249
+ }
250
+ return axios.post(`/api/v2/aiform/template/${templateId}/reply/confirm`, data).then((res) => {
251
+ if (res.data.code !== 200) {
252
+ throw new Error(res.data.message || '确认保存失败');
253
+ }
254
+ return res.data;
255
+ });
256
+ }),
147
257
  };
148
258
  }
149
259
  get record() {
@@ -228,14 +338,15 @@ class AiformGateway extends Object {
228
338
  });
229
339
  }),
230
340
  /**
231
- * 根据解析结果提交反馈(reply)
341
+ * 提交文件 Reply(异步)
232
342
  * POST /api/v2/aiform/file/reply
233
343
  * @param code 文件业务编码
234
344
  * @param reply 用户的修改意见/反馈内容
345
+ * @param replyId 链式调整的 replyId(可选)
235
346
  * @returns Promise 包含 replyId、status 和 accessUrl
236
347
  * 注意:接口为异步,立即返回 replyId 与 status=1,需使用 getReplyDetail 按 replyId 轮询直至 status=2 或 0
237
348
  */
238
- reply: (code, reply) => __awaiter(this, void 0, void 0, function* () {
349
+ reply: (code, reply, replyId) => __awaiter(this, void 0, void 0, function* () {
239
350
  const axios = yield this.context.ready;
240
351
  if (!code) {
241
352
  throw new Error('文件业务编码不能为空');
@@ -243,10 +354,14 @@ class AiformGateway extends Object {
243
354
  if (!reply) {
244
355
  throw new Error('反馈内容不能为空');
245
356
  }
246
- return axios.post(`/api/v2/aiform/file/reply`, {
357
+ const data = {
247
358
  code,
248
359
  reply
249
- }).then((res) => {
360
+ };
361
+ if (replyId) {
362
+ data.replyId = replyId;
363
+ }
364
+ return axios.post(`/api/v2/aiform/file/reply`, data).then((res) => {
250
365
  if (res.data.code !== 200) {
251
366
  throw new Error(res.data.message || '提交反馈失败');
252
367
  }
@@ -254,41 +369,70 @@ class AiformGateway extends Object {
254
369
  });
255
370
  }),
256
371
  /**
257
- * 用户确认并保存
258
- * @param id 解析结果记录ID
259
- * @param content 表格文本,markdown表格格式
260
- * @param headerRowCount 表头行数(可选)
261
- * @param headers 表头单元格列表(可选)
372
+ * 用户确认并保存(Markdown)
373
+ * POST /api/v2/aiform/file/confirm
374
+ * @param code 文件业务编码
375
+ * @param replyId 已成功的 replyId(可选)
376
+ * @param content 确认的 Markdown 全文(可选)
262
377
  * @returns Promise 包含保存结果
263
378
  */
264
- confirm: (id, content, headerRowCount, headers) => __awaiter(this, void 0, void 0, function* () {
379
+ confirm: (code, replyId, content) => __awaiter(this, void 0, void 0, function* () {
265
380
  const axios = yield this.context.ready;
266
- if (!id) {
267
- throw new Error('解析结果记录ID不能为空');
268
- }
269
- if (!content) {
270
- throw new Error('表格内容不能为空');
381
+ if (!code) {
382
+ throw new Error('文件业务编码不能为空');
271
383
  }
272
384
  const data = {
273
- content,
385
+ code
274
386
  };
275
- if (headerRowCount !== undefined) {
276
- data.headerRowCount = headerRowCount;
387
+ if (replyId) {
388
+ data.replyId = replyId;
277
389
  }
278
- if (headers) {
279
- data.headers = headers;
390
+ if (content !== undefined) {
391
+ data.content = content;
280
392
  }
281
- return axios.post(`/api/v2/aiform/file/confirm?id=${id}`, data, {
282
- headers: {
283
- 'Content-Type': 'application/json'
284
- }
285
- }).then((res) => {
393
+ return axios.post(`/api/v2/aiform/file/confirm`, data).then((res) => {
286
394
  if (res.data.code !== 200) {
287
395
  throw new Error(res.data.message || '确认保存失败');
288
396
  }
289
397
  return res.data;
290
398
  });
291
399
  }),
400
+ /**
401
+ * 查询确认主表当前快照
402
+ * GET /api/v2/aiform/file/confirm/current/{code}
403
+ * @param code 文件业务编码
404
+ * @returns Promise 包含当前确认快照
405
+ */
406
+ getConfirmCurrent: (code) => __awaiter(this, void 0, void 0, function* () {
407
+ const axios = yield this.context.ready;
408
+ if (!code) {
409
+ throw new Error('文件业务编码不能为空');
410
+ }
411
+ return axios.get(`/api/v2/aiform/file/confirm/current/${code}`).then((res) => {
412
+ if (res.data.code !== 200) {
413
+ throw new Error(res.data.message || '获取确认快照失败');
414
+ }
415
+ return res.data;
416
+ });
417
+ }),
418
+ /**
419
+ * 查询确认内容历史快照
420
+ * GET /api/v2/aiform/file/confirm/history/{code}
421
+ * @param code 文件业务编码
422
+ * @returns Promise 包含确认历史快照列表
423
+ */
424
+ getConfirmHistory: (code) => __awaiter(this, void 0, void 0, function* () {
425
+ const axios = yield this.context.ready;
426
+ if (!code) {
427
+ throw new Error('文件业务编码不能为空');
428
+ }
429
+ return axios.get(`/api/v2/aiform/file/confirm/history/${code}`).then((res) => {
430
+ if (res.data.code !== 200) {
431
+ throw new Error(res.data.message || '获取确认历史失败');
432
+ }
433
+ return res.data;
434
+ });
435
+ }),
292
436
  /**
293
437
  * 查询文件的reply调整历史
294
438
  * @param code 文件业务编码
@@ -325,5 +469,97 @@ class AiformGateway extends Object {
325
469
  }),
326
470
  };
327
471
  }
472
+ get data() {
473
+ return {
474
+ /**
475
+ * 按工厂 + structType 查询已落库表头列表
476
+ * GET /api/v2/form/pigfarm/list
477
+ * @param factoryId 工厂ID
478
+ * @param structType 报表结构化类型
479
+ * @returns Promise 包含表头列表
480
+ */
481
+ list: (factoryId, structType) => __awaiter(this, void 0, void 0, function* () {
482
+ const axios = yield this.context.ready;
483
+ if (!factoryId) {
484
+ throw new Error('工厂ID不能为空');
485
+ }
486
+ if (!structType) {
487
+ throw new Error('结构化类型不能为空');
488
+ }
489
+ return axios.get(`/api/v2/form/pigfarm/list`, {
490
+ params: {
491
+ factoryId,
492
+ structType
493
+ }
494
+ }).then((res) => {
495
+ if (res.data.code !== 200) {
496
+ throw new Error(res.data.message || '获取结构化列表失败');
497
+ }
498
+ return res.data;
499
+ });
500
+ }),
501
+ /**
502
+ * 按表头 id 查询完整结构化内容
503
+ * GET /api/v2/form/pigfarm/detail
504
+ * @param id 表头ID
505
+ * @returns Promise 包含完整结构化内容
506
+ */
507
+ detail: (id) => __awaiter(this, void 0, void 0, function* () {
508
+ const axios = yield this.context.ready;
509
+ if (!id) {
510
+ throw new Error('表头ID不能为空');
511
+ }
512
+ return axios.get(`/api/v2/form/pigfarm/detail`, {
513
+ params: {
514
+ id
515
+ }
516
+ }).then((res) => {
517
+ if (res.data.code !== 200) {
518
+ throw new Error(res.data.message || '获取结构化详情失败');
519
+ }
520
+ return res.data;
521
+ });
522
+ }),
523
+ /**
524
+ * 查询标准化支持的 structType 枚举
525
+ * GET /api/v2/form/pigfarm/standardize/struct-types
526
+ * @returns Promise 包含 structType 列表
527
+ */
528
+ getStructTypes: () => __awaiter(this, void 0, void 0, function* () {
529
+ const axios = yield this.context.ready;
530
+ return axios.get(`/api/v2/form/pigfarm/standardize/struct-types`).then((res) => {
531
+ if (res.data.code !== 200) {
532
+ throw new Error(res.data.message || '获取结构化类型失败');
533
+ }
534
+ return res.data;
535
+ });
536
+ }),
537
+ /**
538
+ * 从已确认 Markdown 写入结构化表
539
+ * POST /api/v2/form/pigfarm/standardize
540
+ * @param code 文件业务编码
541
+ * @param structType 报表结构化类型
542
+ * @returns Promise 包含保存结果
543
+ */
544
+ standardize: (code, structType) => __awaiter(this, void 0, void 0, function* () {
545
+ const axios = yield this.context.ready;
546
+ if (!code) {
547
+ throw new Error('文件业务编码不能为空');
548
+ }
549
+ if (!structType) {
550
+ throw new Error('结构化类型不能为空');
551
+ }
552
+ return axios.post(`/api/v2/form/pigfarm/standardize`, {
553
+ code,
554
+ structType
555
+ }).then((res) => {
556
+ if (res.data.code !== 200) {
557
+ throw new Error(res.data.message || '标准化失败');
558
+ }
559
+ return res.data;
560
+ });
561
+ }),
562
+ };
563
+ }
328
564
  }
329
565
  exports.AiformGateway = AiformGateway;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.125",
3
+ "version": "1.3.126",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -813,6 +813,8 @@ interface AiformTemplate {
813
813
  id: number;
814
814
  /** 工厂ID */
815
815
  factoryId: number;
816
+ /** 报表结构化类型(如 WEANING) */
817
+ structType?: string;
816
818
  /** 模板名称 */
817
819
  name: string;
818
820
  /** 模板内容 */
@@ -829,10 +831,12 @@ interface AiformTemplate {
829
831
  columnContent: string;
830
832
  otherNotes: string;
831
833
  };
832
- /** 解析状态:null-未上传 0-已上传 1-解析中 2-已解析 */
834
+ /** 解析状态:null-未上传 0-已上传 1-解析中 2-已解析且与主表版本一致 3-历史中存在高于 curVersion 的快照待发布 */
833
835
  status?: number;
834
836
  /** 从表格图片提炼的解析提示词 */
835
837
  parsePrompt?: string;
838
+ /** 创建人用户ID */
839
+ createUserId?: number;
836
840
  /** 当前解析版本号 */
837
841
  curVersion?: number;
838
842
  /** 创建时间 */
@@ -1003,6 +1007,227 @@ interface AiformReplyListResponse {
1003
1007
  data: AiformRecordReply[];
1004
1008
  }
1005
1009
 
1010
+ /**
1011
+ * 模板 Reply 响应接口
1012
+ */
1013
+ interface AiformTemplateReplyResponse {
1014
+ /** 响应码 */
1015
+ code: number;
1016
+ /** 提示信息 */
1017
+ message: string;
1018
+ /** 提交结果 */
1019
+ data: {
1020
+ /** 用于轮询的 replyId */
1021
+ replyId: number;
1022
+ /** 模板 ID */
1023
+ templateId: number;
1024
+ /** 提交后固定为 1 */
1025
+ status: number;
1026
+ };
1027
+ }
1028
+
1029
+ /**
1030
+ * 模板 Reply 详情响应接口
1031
+ */
1032
+ interface AiformTemplateReplyDetailResponse {
1033
+ /** 响应码 */
1034
+ code: number;
1035
+ /** 提示信息 */
1036
+ message: string;
1037
+ /** 轮询结果 */
1038
+ data: {
1039
+ /** 本条 reply 主键 */
1040
+ replyId: number;
1041
+ /** 模板 ID */
1042
+ templateId: number;
1043
+ /** 状态:0/1/2 */
1044
+ status: number;
1045
+ /** 仅成功时非空 */
1046
+ result?: {
1047
+ /** 与路径 replyId 一致 */
1048
+ id: number;
1049
+ /** 模板 ID */
1050
+ templateId: number;
1051
+ /** 调整后名称 */
1052
+ name: string;
1053
+ /** 调整后内容 */
1054
+ content: string;
1055
+ /** 调整后解析提示词 */
1056
+ parsePrompt: string;
1057
+ /** 调整后注意事项 */
1058
+ attention: any;
1059
+ };
1060
+ };
1061
+ }
1062
+
1063
+ /**
1064
+ * 模板确认响应接口
1065
+ */
1066
+ interface AiformTemplateConfirmResponse {
1067
+ /** 响应码 */
1068
+ code: number;
1069
+ /** 提示信息 */
1070
+ message: string;
1071
+ /** 历史快照 */
1072
+ data: AiformTemplateHistory;
1073
+ }
1074
+
1075
+ /**
1076
+ * 记录确认响应接口
1077
+ */
1078
+ interface AiformRecordConfirmResponse {
1079
+ /** 响应码 */
1080
+ code: number;
1081
+ /** 提示信息 */
1082
+ message: string;
1083
+ /** 当前确认快照 */
1084
+ data: {
1085
+ /** aiform_record.id */
1086
+ id: number;
1087
+ /** 该次确认依据的 aiform_parse_result.id */
1088
+ parseResultId: number;
1089
+ /** 确认的 Markdown */
1090
+ content: string;
1091
+ /** 当前确认版本号 */
1092
+ curVersion: number;
1093
+ /** 创建时间 */
1094
+ createTime: string;
1095
+ /** 更新时间 */
1096
+ updateTime: string;
1097
+ };
1098
+ }
1099
+
1100
+ /**
1101
+ * 记录历史响应接口
1102
+ */
1103
+ interface AiformRecordHistoryResponse {
1104
+ /** 响应码 */
1105
+ code: number;
1106
+ /** 提示信息 */
1107
+ message: string;
1108
+ /** 确认历史快照列表 */
1109
+ data: {
1110
+ /** 历史行主键 */
1111
+ id: number;
1112
+ /** aiform_record.id */
1113
+ recordId: number;
1114
+ /** 被归档时的确认版本号 */
1115
+ snapshotVersion: number;
1116
+ /** Markdown 快照 */
1117
+ content: string;
1118
+ /** 该快照对应的解析结果 ID */
1119
+ parseResultId: number;
1120
+ /** 归档操作人用户 ID */
1121
+ createUserId: number;
1122
+ /** 归档时间 */
1123
+ createTime: string;
1124
+ }[];
1125
+ }
1126
+
1127
+ /**
1128
+ * 结构化类型响应接口
1129
+ */
1130
+ interface AiformStructTypeResponse {
1131
+ /** 响应码 */
1132
+ code: number;
1133
+ /** 提示信息 */
1134
+ message: string;
1135
+ /** structType 列表 */
1136
+ data: {
1137
+ /** 与库表 struct_type 一致 */
1138
+ code: string;
1139
+ /** 展示名 */
1140
+ label: string;
1141
+ }[];
1142
+ }
1143
+
1144
+ /**
1145
+ * 结构化列表响应接口
1146
+ */
1147
+ interface AiformStructListResponse {
1148
+ /** 响应码 */
1149
+ code: number;
1150
+ /** 提示信息 */
1151
+ message: string;
1152
+ /** 表头列表 */
1153
+ data: {
1154
+ /** aiform_record_struct_header.id */
1155
+ id: number;
1156
+ /** aiform_record.id */
1157
+ recordId: number;
1158
+ /** 模板 ID */
1159
+ templateId: number;
1160
+ /** 工厂/猪场 ID */
1161
+ factoryId: number;
1162
+ /** 关联文件 code */
1163
+ fileCode: string;
1164
+ /** 如 WEANING */
1165
+ structType: string;
1166
+ /** 业务日期 */
1167
+ businessDate: string;
1168
+ /** 签字人/场长等 */
1169
+ signatory: string;
1170
+ /** 创建时间 */
1171
+ createTime: string;
1172
+ }[];
1173
+ }
1174
+
1175
+ /**
1176
+ * 结构化详情响应接口
1177
+ */
1178
+ interface AiformStructDetailResponse {
1179
+ /** 响应码 */
1180
+ code: number;
1181
+ /** 提示信息 */
1182
+ message: string;
1183
+ /** 完整结构化内容 */
1184
+ data: {
1185
+ /** 与列表 fileCode 一致 */
1186
+ fileCode: string;
1187
+ /** aiform_record.id */
1188
+ recordId: number;
1189
+ /** aiform_record_struct_header.id */
1190
+ headerId: number;
1191
+ /** 与表头一致 */
1192
+ structType: string;
1193
+ /** 模板 ID */
1194
+ templateId: number;
1195
+ /** 工厂 ID */
1196
+ factoryId: number;
1197
+ /** 业务日期 */
1198
+ businessDate: string;
1199
+ /** 签字人 */
1200
+ signatory: string;
1201
+ /** 大模型抽取的扩展 JSON */
1202
+ headerExtra: string;
1203
+ /** aiform_record.content,已确认 Markdown */
1204
+ confirmedContent: string;
1205
+ /** 表头创建时间 */
1206
+ headerCreateTime: string;
1207
+ /** 仅 WEANING 时有数据 */
1208
+ weaningRows: {
1209
+ /** 序号 */
1210
+ serialNo: string;
1211
+ /** 栋舍 */
1212
+ building: string;
1213
+ /** 栏位 */
1214
+ pen: string;
1215
+ /** 母猪耳号 */
1216
+ sowEarTag: string;
1217
+ /** 品种代码 */
1218
+ breedCode: string;
1219
+ /** 公猪数 */
1220
+ maleCount: number;
1221
+ /** 母猪数 */
1222
+ femaleCount: number;
1223
+ /** 总数 */
1224
+ totalCount: number;
1225
+ /** 创建时间 */
1226
+ createTime: string;
1227
+ }[];
1228
+ };
1229
+ }
1230
+
1006
1231
  /**
1007
1232
  * AI报表模板列表响应接口
1008
1233
  */
@@ -1267,6 +1492,14 @@ declare module "@cpzxrobot/sdk" {
1267
1492
  AiformConfirmResponse,
1268
1493
  AiformRecordReply,
1269
1494
  AiformReplyListResponse,
1495
+ AiformTemplateReplyResponse,
1496
+ AiformTemplateReplyDetailResponse,
1497
+ AiformTemplateConfirmResponse,
1498
+ AiformRecordConfirmResponse,
1499
+ AiformRecordHistoryResponse,
1500
+ AiformStructTypeResponse,
1501
+ AiformStructListResponse,
1502
+ AiformStructDetailResponse,
1270
1503
  AlarmRuleDetail,
1271
1504
  AlarmRuleListResponse,
1272
1505
  AlarmRuleDetailResponse,