|
@@ -32,6 +32,25 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
public class ProjectService {
|
|
|
|
|
|
+ /*
|
|
|
+ algorithm-platform:
|
|
|
+ appid: 2af6f44d98104dc5adcbfb49809ff9d5
|
|
|
+ secret: db129a741fde1e9f474199dea24f3901
|
|
|
+ token-uri: https://open.zoogooy.com.cn/cgi-bin/token/token?grant_type=client_credential
|
|
|
+ algorithm-list-uri: https://open.zoogooy.com.cn/cgi-bin/api/icv-algorithm-agg/simulation/evaluation
|
|
|
+ algorithm-addr-uri: https://open.zoogooy.com.cn/cgi-bin/api/icv-algorithm-agg/simulation/download
|
|
|
+ */
|
|
|
+
|
|
|
+ @Value("${algorithm-platform.appid}")
|
|
|
+ String algorithmPlatformAppid;
|
|
|
+ @Value("${algorithm-platform.secret}")
|
|
|
+ String algorithmPlatformSecret;
|
|
|
+ @Value("${algorithm-platform.token-uri}")
|
|
|
+ String algorithmPlatformTokenUri;
|
|
|
+ @Value("${algorithm-platform.algorithm-addr-uri}")
|
|
|
+ String algorithmPlatformAlgorithmAddrUri;
|
|
|
+
|
|
|
+
|
|
|
@Value("${scheduler.minio-path.project-result}")
|
|
|
String projectResultPathOfMinio;
|
|
|
@Value("${scheduler.linux-path.temp}")
|
|
@@ -296,6 +315,14 @@ public class ProjectService {
|
|
|
* "code" : 1,
|
|
|
* "nowTime" : "2022-04-22 10:14:40"
|
|
|
* }
|
|
|
+ * <p>
|
|
|
+ * {
|
|
|
+ * "data": "https://sysware-icv-algo-pri.obs.cn-north-4.myhuaweicloud.com:443/1658730835935/jybdc_0712_01.tar?AccessKeyId=0ZFICI4CB04DFHQTPDBF&Expires=1658917777&Signature=bPUT%2FnFwlHcAqOFsskYVPKOdnYs%3D",
|
|
|
+ * "success": true,
|
|
|
+ * "message": "ok",
|
|
|
+ * "code": 1,
|
|
|
+ * "nowTime": "2022-07-27 18:14:37"
|
|
|
+ * }
|
|
|
*
|
|
|
* @param projectId 项目 id
|
|
|
* @param algorithmId 算法 id
|
|
@@ -338,21 +365,14 @@ public class ProjectService {
|
|
|
dockerImage = "algorithm_" + algorithmId + ":latest";
|
|
|
algorithmTarLinuxTempPath = linuxTempPath + "algorithm/" + algorithmId + ".tar";
|
|
|
//1 获取 token
|
|
|
- String tokenUri = "http://open-api.zoogooy.com/cgi-bin/token/token?grant_type=client_credential";
|
|
|
- String appid = "3e64be4a29e5478f9717d53c11ab26ad";
|
|
|
- String secret = "f183079f97ac9ed81a864619a83fc17a";
|
|
|
- String tokenUrl = tokenUri + "&appid=" + appid + "&secret=" + secret;
|
|
|
- String result = HttpUtil.get(closeableHttpClient, requestConfig, tokenUrl);
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
- JsonNode jsonNode = objectMapper.readTree(result);
|
|
|
- JsonNode dataNode = jsonNode.path("data");
|
|
|
- String token = dataNode.path("access_token").asText();
|
|
|
+ String tokenUrl = algorithmPlatformTokenUri + "?grant_type=client_credential&appid=" + algorithmPlatformAppid + "&secret=" + algorithmPlatformSecret;
|
|
|
+ String tokenJson = HttpUtil.get(closeableHttpClient, requestConfig, tokenUrl);
|
|
|
+ String token = new ObjectMapper().readTree(tokenJson).path("data").path("access_token").asText();
|
|
|
//2 获取 下载地址
|
|
|
- String downloadUrl = "http://open-api.zoogooy.com/cgi-bin/api/icv-algorithm-agg/simulation/download"
|
|
|
- + "?access_token=" + token
|
|
|
- + "&id=" + algorithmId;
|
|
|
+ String downloadUrl = algorithmPlatformAlgorithmAddrUri + "?access_token=" + token + "&id=" + algorithmId;
|
|
|
//3 下载算法包
|
|
|
- String tempDownloadUrl = HttpUtil.get(closeableHttpClient, requestConfig, downloadUrl);
|
|
|
+ String downloadUrlJson = HttpUtil.get(closeableHttpClient, requestConfig, downloadUrl);
|
|
|
+ String tempDownloadUrl = new ObjectMapper().readTree(downloadUrlJson).path("data").asText();
|
|
|
InputStream inputStream = HttpUtil.getInputStream(closeableHttpClient, requestConfig, tempDownloadUrl);
|
|
|
FileUtil.writeInputStreamToLocalFile(inputStream, algorithmTarLinuxTempPath);
|
|
|
}
|
|
@@ -397,8 +417,7 @@ public class ProjectService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @param projectId 手动项目 id 或自动项目子id
|
|
|
+ * @param projectId 手动项目 id 或自动项目子id
|
|
|
* @param projectType
|
|
|
*/
|
|
|
@SneakyThrows
|