Parcourir la source

Merge branch 'develop' of gitadmin/tuoheng_freeway into release

pull/352/head
wanjing il y a 11 mois
Parent
révision
a7b9a473b5
1 fichiers modifiés avec 27 ajouts et 3 suppressions
  1. +27
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/StartAIService.java

+ 27
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/StartAIService.java Voir le fichier

@@ -4,10 +4,15 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.enums.code.inspection.EditInspectionStatusCodeEnum;
import com.tuoheng.admin.request.inspection.MissionStatusRequest;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.Locale;

@@ -27,6 +32,10 @@ public class StartAIService {
@Value("${tuoheng.dsp-callback-url:}")
private String dspCallbackUrl;

@Autowired
@Qualifier("restTemplate")
private RestTemplate restTemplate;

/**
* 调用DSP接口
*
@@ -76,9 +85,24 @@ public class StartAIService {
String url = String.format(Locale.ENGLISH, "%s/api/web/serviceInst/%s/application", dspDomainUrl, dspServiceInstId);
log.info("调用DSP服务, url:{}", url);
log.info("调用DSP服务, jsonObject:{}", jsonObject);
String result = SendPost.doPost(url, jsonObject, null);
log.info("调用DSP服务, result:{}", result);
return JSONObject.parseObject(result);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity httpEntity = new HttpEntity(jsonObject, headers);
ResponseEntity<JsonResult> response;
try {
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class);
} catch (Exception e) {
log.error("调用DSP服务:DSP返回异常, url:{}", url);
log.error("调用DSP服务:DSP返回异常, httpEntity:{}", httpEntity);
throw new ServiceException("调用DSP服务:DSP返回异常");
}
JsonResult jsonResult = response.getBody();
if (0 != jsonResult.getCode()) {
log.info("调用DSP服务:DSP返回失败,jsonResult:{}", jsonResult.getMsg());
throw new ServiceException("调用DSP服务:DSP返回失败");
}
log.info("调用DSP服务, result:{}", jsonResult);
return JSONObject.parseObject(JSONObject.toJSONString(jsonResult));
}

}

Chargement…
Annuler
Enregistrer