|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.tuoheng.admin.enums.code.inspection.EditInspectionStatusCodeEnum; |
|
|
import com.tuoheng.admin.enums.code.inspection.EditInspectionStatusCodeEnum; |
|
|
import com.tuoheng.admin.request.inspection.MissionStatusRequest; |
|
|
import com.tuoheng.admin.request.inspection.MissionStatusRequest; |
|
|
|
|
|
import com.tuoheng.common.core.exception.ServiceException; |
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
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.beans.factory.annotation.Value; |
|
|
|
|
|
import org.springframework.http.*; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
|
|
|
|
|
import java.util.Locale; |
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${tuoheng.dsp-callback-url:}") |
|
|
@Value("${tuoheng.dsp-callback-url:}") |
|
|
private String dspCallbackUrl; |
|
|
private String dspCallbackUrl; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
@Qualifier("restTemplate") |
|
|
|
|
|
private RestTemplate restTemplate; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 调用DSP接口 |
|
|
* 调用DSP接口 |
|
|
* |
|
|
* |
|
|
|
|
|
|
|
|
String url = String.format(Locale.ENGLISH, "%s/api/web/serviceInst/%s/application", dspDomainUrl, dspServiceInstId); |
|
|
String url = String.format(Locale.ENGLISH, "%s/api/web/serviceInst/%s/application", dspDomainUrl, dspServiceInstId); |
|
|
log.info("调用DSP服务, url:{}", url); |
|
|
log.info("调用DSP服务, url:{}", url); |
|
|
log.info("调用DSP服务, jsonObject:{}", jsonObject); |
|
|
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)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |