import com.tuoheng.admin.entity.domain.ThMission; | import com.tuoheng.admin.entity.domain.ThMission; | ||||
import com.tuoheng.admin.entity.request.MissionQuery; | import com.tuoheng.admin.entity.request.MissionQuery; | ||||
import com.tuoheng.admin.entity.request.MissionRequest; | import com.tuoheng.admin.entity.request.MissionRequest; | ||||
import com.tuoheng.admin.entity.vo.MissionLiveVO; | |||||
import com.tuoheng.admin.entity.vo.MissionVO; | import com.tuoheng.admin.entity.vo.MissionVO; | ||||
import com.tuoheng.admin.service.IMissionService; | import com.tuoheng.admin.service.IMissionService; | ||||
import com.tuoheng.common.exception.ServiceException; | import com.tuoheng.common.exception.ServiceException; | ||||
return JsonResult.success(missionService.findById(id)); | return JsonResult.success(missionService.findById(id)); | ||||
} | } | ||||
/** | |||||
* 根据机场Id获取正在直播中的任务 | |||||
*/ | |||||
@GetMapping("/live/{airportId}") | |||||
@ApiImplicitParam(name="id",value = "任务的Id,missionId") | |||||
public JsonResult<MissionLiveVO> live(@PathVariable("airportId")Integer id) { | |||||
return JsonResult.success(missionService.live(id)); | |||||
} | |||||
} | } |
*/ | */ | ||||
@PostMapping("/{requestId}/callback") | @PostMapping("/{requestId}/callback") | ||||
public JsonResult callback(@Valid @Pattern(regexp = "^[a-zA-Z0-9]{0,36}$") | public JsonResult callback(@Valid @Pattern(regexp = "^[a-zA-Z0-9]{0,36}$") | ||||
@NotBlank @PathVariable String requestId, | |||||
@NotBlank @PathVariable("requestId") String requestId, | |||||
@Valid @RequestBody CallbackRequest callbackRequest) { | @Valid @RequestBody CallbackRequest callbackRequest) { | ||||
return questionService.process(requestId, callbackRequest); | return questionService.process(requestId, callbackRequest); | ||||
} | } |
@ApiModelProperty(value = "巡检结束时间") | @ApiModelProperty(value = "巡检结束时间") | ||||
private Date executionEndTime; | private Date executionEndTime; | ||||
/** | |||||
* 视频地址 | |||||
*/ | |||||
@ApiModelProperty(value = "视频地址") | |||||
private String videoUrl; | |||||
@ApiModelProperty(value = "任务飞行状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成") | @ApiModelProperty(value = "任务飞行状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成") | ||||
private Integer status; | private Integer status; |
package com.tuoheng.admin.entity.vo; | |||||
import com.fasterxml.jackson.annotation.JsonFormat; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import org.springframework.format.annotation.DateTimeFormat; | |||||
import java.io.Serializable; | |||||
import java.util.Date; | |||||
/** | |||||
* 巡检任务 新增或修改请求参数 2022/7/27 | |||||
* @author : qiujinyang | |||||
*/ | |||||
@Data | |||||
public class MissionLiveVO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
@ApiModelProperty(value = "任务id") | |||||
private Integer id; | |||||
//直播的视频地址 | |||||
@ApiModelProperty(value = "视频地址") | |||||
private String playUrl; | |||||
@ApiModelProperty(value = "AI识别后视频地址") | |||||
private String aiplayUrl; | |||||
} |
private String aipullUrl; | private String aipullUrl; | ||||
//回放的两个通道 | |||||
//直播的视频地址 | |||||
@ApiModelProperty(value = "视频地址") | @ApiModelProperty(value = "视频地址") | ||||
private String playUrl; | private String playUrl; | ||||
@ApiModelProperty(value = "AI识别后视频地址") | @ApiModelProperty(value = "AI识别后视频地址") | ||||
private String aiplayUrl; | private String aiplayUrl; | ||||
//回放视频的两个地址 | |||||
@ApiModelProperty(value = "原视频地址") | |||||
private String videoUrl; | |||||
@ApiModelProperty(value = "AI识别后视频地址") | |||||
private String aiVideoUrl; | |||||
@ApiModelProperty(value = "任务飞行状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成") | @ApiModelProperty(value = "任务飞行状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成") | ||||
private Integer status; | private Integer status; | ||||
import com.tuoheng.admin.entity.request.MissionQuery; | import com.tuoheng.admin.entity.request.MissionQuery; | ||||
import com.tuoheng.admin.entity.request.MissionRequest; | import com.tuoheng.admin.entity.request.MissionRequest; | ||||
import com.tuoheng.admin.entity.request.MissionStatusRequest; | import com.tuoheng.admin.entity.request.MissionStatusRequest; | ||||
import com.tuoheng.admin.entity.vo.MissionLiveVO; | |||||
import com.tuoheng.admin.entity.vo.MissionVO; | import com.tuoheng.admin.entity.vo.MissionVO; | ||||
import com.tuoheng.common.common.IBaseService; | import com.tuoheng.common.common.IBaseService; | ||||
import com.tuoheng.common.common.OperationEnum; | import com.tuoheng.common.common.OperationEnum; | ||||
* @date: 2021/9/2 | * @date: 2021/9/2 | ||||
*/ | */ | ||||
boolean deleteBatch(List<Integer> idList); | boolean deleteBatch(List<Integer> idList); | ||||
MissionLiveVO live(Integer id); | |||||
} | } |
import com.tuoheng.admin.entity.request.MissionRequest; | import com.tuoheng.admin.entity.request.MissionRequest; | ||||
import com.tuoheng.admin.entity.request.MissionQuery; | import com.tuoheng.admin.entity.request.MissionQuery; | ||||
import com.tuoheng.admin.entity.request.MissionStatusRequest; | import com.tuoheng.admin.entity.request.MissionStatusRequest; | ||||
import com.tuoheng.admin.entity.vo.MissionLiveVO; | |||||
import com.tuoheng.admin.entity.vo.MissionVO; | import com.tuoheng.admin.entity.vo.MissionVO; | ||||
import com.tuoheng.admin.enums.*; | import com.tuoheng.admin.enums.*; | ||||
import com.tuoheng.admin.mapper.*; | import com.tuoheng.admin.mapper.*; | ||||
queryInspectionRequest.setTenantId(ShiroUtils.getTenantId()); | queryInspectionRequest.setTenantId(ShiroUtils.getTenantId()); | ||||
LambdaQueryWrapper<ThMission> queryInspection=new LambdaQueryWrapper<>(); | LambdaQueryWrapper<ThMission> queryInspection=new LambdaQueryWrapper<>(); | ||||
queryParam(queryInspectionRequest, queryInspection); | queryParam(queryInspectionRequest, queryInspection); | ||||
queryInspection.eq(ThMission::getMark,MarkTypeEnum.VALID.getCode()); | |||||
queryInspection.eq(ThMission::getMark,MarkTypeEnum.VALID.getCode()).orderByDesc(ThMission::getCreateTime); | |||||
IPage<ThMission> thMissionIPage = thMissionMapper.selectPage(page, queryInspection); | IPage<ThMission> thMissionIPage = thMissionMapper.selectPage(page, queryInspection); | ||||
return thMissionMapper.update(mission,new LambdaUpdateWrapper<ThMission>().in(ThMission::getId,idList))>0; | return thMissionMapper.update(mission,new LambdaUpdateWrapper<ThMission>().in(ThMission::getId,idList))>0; | ||||
} | } | ||||
@Override | |||||
public MissionLiveVO live(Integer id) { | |||||
//根据机场的Id查询出来直播的对象 | |||||
LambdaQueryWrapper<ThMission> lambdaQueryWrapper=new LambdaQueryWrapper<>(); | |||||
lambdaQueryWrapper.eq(ThMission::getMark,MarkTypeEnum.VALID.getCode()); | |||||
lambdaQueryWrapper.eq(ThMission::getAirportId,id); | |||||
lambdaQueryWrapper.eq(ThMission::getStatus,TaskStatusEnum.FLIGHT.getCode()).orderByDesc(ThMission::getExecutionStartTime); | |||||
List<ThMission> thMissions = thMissionMapper.selectList(lambdaQueryWrapper); | |||||
//一般不会出现多条,如果出现,就说明有问题,应该取最后执行的那一条 | |||||
ThMission thMission= ObjectUtil.isEmpty(thMissions)? null :thMissions.get(0); | |||||
MissionLiveVO missionLiveVO=null; | |||||
if(ObjectUtil.isNotEmpty(thMission)){ | |||||
missionLiveVO=new MissionLiveVO(); | |||||
BeanUtils.copyProperties(thMission,missionLiveVO); | |||||
} | |||||
return missionLiveVO; | |||||
} | |||||
} | } |
List<ThMission> thMissions = missionMapper.selectList(new LambdaQueryWrapper<ThMission>() | List<ThMission> thMissions = missionMapper.selectList(new LambdaQueryWrapper<ThMission>() | ||||
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode()) | .eq(ThMission::getMark, MarkTypeEnum.VALID.getCode()) | ||||
.orderByDesc(ThMission::getUpdateTime)); | .orderByDesc(ThMission::getUpdateTime)); | ||||
List<Question> questionList = getQuestions(query, thMissions); | |||||
return questionList; | |||||
return getQuestions(query, thMissions); | |||||
} | } | ||||
private List<Question> getQuestions(QuestionQuery query, List<ThMission> thMissions) { | private List<Question> getQuestions(QuestionQuery query, List<ThMission> thMissions) { | ||||
} | } | ||||
private void setComplate(CallbackRequest callbackRequest, ThMission mission, ThMission thMissionUpdate) { | private void setComplate(CallbackRequest callbackRequest, ThMission mission, ThMission thMissionUpdate) { | ||||
if(callbackRequest.getAnalyseStatus()== AiAnalyseStatusEnum.SUCCESS.getCode()){ | |||||
if(callbackRequest.getAnalyseStatus()== AiAnalyseStatusEnum.SUCCESS.getCode() || callbackRequest.getAnalyseStatus()== AiAnalyseStatusEnum.SUCCESS_TIMEOUT.getCode()){ | |||||
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.COMPLETE, mission); | setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.COMPLETE, mission); | ||||
//这边存回放的视频地址 | |||||
thMissionUpdate.setVideoUrl(callbackRequest.getVideoUrl()); | |||||
thMissionUpdate.setAiVideoUrl(callbackRequest.getAiVideoUrl()); | |||||
} | } | ||||
} | } | ||||
public List<InspectionVO> track(Integer id) { | public List<InspectionVO> track(Integer id) { | ||||
LambdaQueryWrapper<ThInspection> lambdaQueryWrapper=new LambdaQueryWrapper<>(); | LambdaQueryWrapper<ThInspection> lambdaQueryWrapper=new LambdaQueryWrapper<>(); | ||||
lambdaQueryWrapper.eq(ThInspection::getMissionId,id); | |||||
lambdaQueryWrapper.eq(ThInspection::getMissionId,id).orderByDesc(ThInspection::getTimestamp); | |||||
//lambdaQueryWrapper.eq(ThInspection::getTenantId, ShiroUtils.getTenantId()); | //lambdaQueryWrapper.eq(ThInspection::getTenantId, ShiroUtils.getTenantId()); | ||||
List<InspectionVO> result=new ArrayList<>(); | List<InspectionVO> result=new ArrayList<>(); | ||||
List<ThInspection> thInspections = inspectionMapper.selectList(lambdaQueryWrapper); | List<ThInspection> thInspections = inspectionMapper.selectList(lambdaQueryWrapper); | ||||
String param="page=1&limit=10"; | String param="page=1&limit=10"; | ||||
String airPortStr = HttpUtils.sendGet(url, param); | String airPortStr = HttpUtils.sendGet(url, param); | ||||
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | ||||
if(!ObjectUtil.isEmpty(jsonResult.getData()) &&jsonResult.getCode() != 0) { | |||||
if(ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(jsonResult.getData()) &&jsonResult.getCode() != 0)) { | |||||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取机场信息失败,请重试"); | throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取机场信息失败,请重试"); | ||||
} | } | ||||
return JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("records").toString(), AirPortVO.class); | return JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("records").toString(), AirPortVO.class); | ||||
String param="page=1&limit=10&droneId="+droneId; | String param="page=1&limit=10&droneId="+droneId; | ||||
String airPortStr = HttpUtils.sendGet(url, param); | String airPortStr = HttpUtils.sendGet(url, param); | ||||
JsonResult<AirLineVO> jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | JsonResult<AirLineVO> jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | ||||
if(!ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0) { | |||||
if(ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0)) { | |||||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取航线信息失败,请重试"); | throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取航线信息失败,请重试"); | ||||
} | } | ||||
return JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("records").toString(), AirLineVO.class); | return JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("records").toString(), AirLineVO.class); | ||||
String param="taskId="+taskId; | String param="taskId="+taskId; | ||||
String airPortStr = HttpUtils.sendPost(url, param); | String airPortStr = HttpUtils.sendPost(url, param); | ||||
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | ||||
if(!ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0) { | |||||
if(ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0)) { | |||||
return JsonResult.error(JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("data").toString(), AirExecuteTaskVO.class),"执行任务失败!"); | return JsonResult.error(JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("data").toString(), AirExecuteTaskVO.class),"执行任务失败!"); | ||||
}else if(ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0){ | }else if(ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0){ | ||||
return JsonResult.error(jsonResult.getMsg()); | return JsonResult.error(jsonResult.getMsg()); | ||||
String param="airportId="+airportId; | String param="airportId="+airportId; | ||||
String weatherStr = HttpUtils.sendGet(url, param); | String weatherStr = HttpUtils.sendGet(url, param); | ||||
JsonResult jsonResult = JacksonUtil.json2pojo(weatherStr, JsonResult.class); | JsonResult jsonResult = JacksonUtil.json2pojo(weatherStr, JsonResult.class); | ||||
if(jsonResult.getCode() != 0) { | |||||
if(ObjectUtil.isEmpty(jsonResult) || jsonResult.getCode() != 0) { | |||||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取天气信息失败,请重试"); | throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取天气信息失败,请重试"); | ||||
} | } | ||||
return JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData()),AirWeatherVO.class); | return JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData()),AirWeatherVO.class); |