|
|
@@ -329,6 +329,82 @@ public class AicdsGatewayService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // ==================== 视频路径能力(ai.aiyunyi.detectVideo,S-cfc-473) ====================
|
|
|
+
|
|
|
+ private static final String PATH_GET_PATH = "/detection/package/getPath";
|
|
|
+ private static final String PATH_PACKAGE_PAGE = "/detection/package/page";
|
|
|
+ private static final String PATH_REPORT_GET = "/detection/report/get";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 能力键 {@code ai.aiyunyi.detectVideo}(S-cfc-473):契约 §A.5
|
|
|
+ * {@code GET /detection/package/getPath}。两个 ID 均为必填,原样透传,响应中的
|
|
|
+ * {@code data.path} 由 {@link AicdsDetectionService} 提取,网关只做转发。
|
|
|
+ *
|
|
|
+ * @param detectionPackageItemId 检测套餐子项 ID(必填)
|
|
|
+ * @param detectionReportUserId 检测报告关联用户 ID(必填)
|
|
|
+ * @return 爱云医原始响应(Map:code/data.path/msg)
|
|
|
+ */
|
|
|
+ public Object getPath(long detectionPackageItemId, long detectionReportUserId) {
|
|
|
+ if (detectionPackageItemId <= 0) {
|
|
|
+ throw new IllegalArgumentException("爱云医 getPath 缺少 detectionPackageItemId(§A.5 必填)");
|
|
|
+ }
|
|
|
+ if (detectionReportUserId <= 0) {
|
|
|
+ throw new IllegalArgumentException("爱云医 getPath 缺少 detectionReportUserId(§A.5 必填)");
|
|
|
+ }
|
|
|
+ String path = PATH_GET_PATH + "?detectionPackageItemId=" + detectionPackageItemId
|
|
|
+ + "&detectionReportUserId=" + detectionReportUserId;
|
|
|
+ return exchangeGet(path, Object.class, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 带业务头(accessToken/userId)的 getPath,供已登录的真实检测调用使用。 */
|
|
|
+ public Object getPath(long detectionPackageItemId, long detectionReportUserId,
|
|
|
+ String accessToken, String userId) {
|
|
|
+ if (detectionPackageItemId <= 0) {
|
|
|
+ throw new IllegalArgumentException("爱云医 getPath 缺少 detectionPackageItemId(§A.5 必填)");
|
|
|
+ }
|
|
|
+ if (detectionReportUserId <= 0) {
|
|
|
+ throw new IllegalArgumentException("爱云医 getPath 缺少 detectionReportUserId(§A.5 必填)");
|
|
|
+ }
|
|
|
+ String path = PATH_GET_PATH + "?detectionPackageItemId=" + detectionPackageItemId
|
|
|
+ + "&detectionReportUserId=" + detectionReportUserId;
|
|
|
+ return exchangeGet(path, Object.class, accessToken, userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 视频采集完成后的轮询:{@code GET /detection/package/page},确认检测状态后再取报告。
|
|
|
+ * 只做 HTTP 转发,不在此处吞错(§4.5 错误归一由编排层负责)。
|
|
|
+ */
|
|
|
+ public Object getPackagePage(long packageId) {
|
|
|
+ return exchangeGet(PATH_PACKAGE_PAGE + "?detectionPackageId=" + packageId,
|
|
|
+ Object.class, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 轮询确认完成后拉取报告:{@code GET /detection/report/get}。 */
|
|
|
+ public Object getReport(long packageId) {
|
|
|
+ return exchangeGet(PATH_REPORT_GET + "?detectionPackageId=" + packageId,
|
|
|
+ Object.class, null, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** GET 版统一转发入口:与 {@link #exchange} 共用鉴权头与熔断状态。 */
|
|
|
+ private <T> T exchangeGet(String path, Class<T> responseType,
|
|
|
+ String accessToken, String userId) {
|
|
|
+ if (isCircuitOpen()) {
|
|
|
+ throw new IllegalStateException("爱云医网关熔断中,拒绝发起请求: " + path);
|
|
|
+ }
|
|
|
+ HttpHeaders headers = buildGatewayHeaders(accessToken, userId);
|
|
|
+ HttpEntity<Object> entity = new HttpEntity<Object>(headers);
|
|
|
+ String url = resolveBaseUrl() + (path == null ? "" : path);
|
|
|
+ try {
|
|
|
+ ResponseEntity<T> response = restTemplate.exchange(url, HttpMethod.GET, entity,
|
|
|
+ responseType, new Object[0]);
|
|
|
+ consecutiveFailures.set(0);
|
|
|
+ return response.getBody();
|
|
|
+ } catch (RestClientException e) {
|
|
|
+ recordFailure();
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* AC11:错误归一。
|
|
|
* <ul>
|