HttpHeaders headers = new HttpHeaders(); | HttpHeaders headers = new HttpHeaders(); | ||||
headers.add("Authorization", properties); | headers.add("Authorization", properties); | ||||
HttpEntity<Object> httpEntity = new HttpEntity<>(request, headers); | |||||
log.info("泰州海陵区城管,url:{}", url); | |||||
log.info("泰州海陵区城管,request:{}", request); | |||||
HttpEntity<Object> httpEntity = new HttpEntity<>(request, headers); | |||||
ResponseEntity<JsonResult> response; | ResponseEntity<JsonResult> response; | ||||
try { | try { | ||||
response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JsonResult.class); | response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JsonResult.class); | ||||
log.info("泰州海陵区城管,接口返回失败, request:{}", request); | log.info("泰州海陵区城管,接口返回失败, request:{}", request); | ||||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败"); | throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败"); | ||||
} | } | ||||
log.info("泰州海陵区城管,接口返回, response={}", response); | |||||
return JSONObject.toJSONString(response.getBody().getData()); | return JSONObject.toJSONString(response.getBody().getData()); | ||||
} | } | ||||
log.info("泰州海陵区城管,接口返回失败, request:{}", request); | log.info("泰州海陵区城管,接口返回失败, request:{}", request); | ||||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败"); | throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败"); | ||||
} | } | ||||
log.info("泰州海陵区城管,接口返回, response={}", response); | |||||
return JSONObject.toJSONString(response.getBody().getData()); | return JSONObject.toJSONString(response.getBody().getData()); | ||||
} | } | ||||
TZHLOnlineUavResponse tzhlOnlineUavResponse = onlineUavService.getOnlineUav(); | TZHLOnlineUavResponse tzhlOnlineUavResponse = onlineUavService.getOnlineUav(); | ||||
if (ObjectUtil.isEmpty(tzhlOnlineUavResponse)) { | if (ObjectUtil.isEmpty(tzhlOnlineUavResponse)) { | ||||
log.info("泰州海陵区城管,执行任务,获取推流地址失败"); | |||||
log.info("泰州海陵区城管,执行任务,获取推流地址失败,inspectionId={}", inspection.getId()); | |||||
return; | return; | ||||
} | } | ||||
package com.tuoheng.admin.tzhl.service.fly.onlineuav; | package com.tuoheng.admin.tzhl.service.fly.onlineuav; | ||||
import cn.hutool.core.util.ObjectUtil; | |||||
import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
import com.tuoheng.admin.entity.Inspection; | import com.tuoheng.admin.entity.Inspection; | ||||
import com.tuoheng.admin.tzhl.constant.TZHLConstant; | import com.tuoheng.admin.tzhl.constant.TZHLConstant; | ||||
import com.tuoheng.admin.tzhl.response.TZHLOnlineUavResponse; | import com.tuoheng.admin.tzhl.response.TZHLOnlineUavResponse; | ||||
import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService; | import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService; | ||||
import com.tuoheng.common.core.utils.RedisUtils; | import com.tuoheng.common.core.utils.RedisUtils; | ||||
import com.tuoheng.common.core.utils.StringUtils; | |||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.beans.factory.annotation.Qualifier; | import org.springframework.beans.factory.annotation.Qualifier; | ||||
public TZHLOnlineUavResponse getOnlineUav() { | public TZHLOnlineUavResponse getOnlineUav() { | ||||
String apiPath = TZHLConstant.TIAN_YI_API_FLIGHT_SCREEN; | String apiPath = TZHLConstant.TIAN_YI_API_FLIGHT_SCREEN; | ||||
String dataJson = callTianYiPlatformService.callGet(apiPath, null); | String dataJson = callTianYiPlatformService.callGet(apiPath, null); | ||||
if (StringUtils.isEmpty(dataJson)) { | |||||
return null; | |||||
} | |||||
TZHLOnlineUavResponse onlineUavResponse = JSON.parseObject(dataJson, TZHLOnlineUavResponse.class); | TZHLOnlineUavResponse onlineUavResponse = JSON.parseObject(dataJson, TZHLOnlineUavResponse.class); | ||||
if (ObjectUtil.isEmpty(onlineUavResponse)) { | |||||
return null; | |||||
} | |||||
return onlineUavResponse; | return onlineUavResponse; | ||||
} | } | ||||