@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.tuoheng.admin.entity.domain.ThMission; | |||
import com.tuoheng.admin.entity.request.MissionQuery; | |||
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.service.IMissionService; | |||
import com.tuoheng.common.exception.ServiceException; | |||
@@ -91,4 +92,13 @@ public class MissionController { | |||
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)); | |||
} | |||
} |
@@ -48,7 +48,7 @@ public class QuestionController { | |||
*/ | |||
@PostMapping("/{requestId}/callback") | |||
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) { | |||
return questionService.process(requestId, callbackRequest); | |||
} |
@@ -100,12 +100,6 @@ public class MissionRequest { | |||
@ApiModelProperty(value = "巡检结束时间") | |||
private Date executionEndTime; | |||
/** | |||
* 视频地址 | |||
*/ | |||
@ApiModelProperty(value = "视频地址") | |||
private String videoUrl; | |||
@ApiModelProperty(value = "任务飞行状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成") | |||
private Integer status; |
@@ -0,0 +1,27 @@ | |||
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; | |||
} |
@@ -72,12 +72,18 @@ public class MissionVO implements Serializable { | |||
private String aipullUrl; | |||
//回放的两个通道 | |||
//直播的视频地址 | |||
@ApiModelProperty(value = "视频地址") | |||
private String playUrl; | |||
@ApiModelProperty(value = "AI识别后视频地址") | |||
private String aiplayUrl; | |||
//回放视频的两个地址 | |||
@ApiModelProperty(value = "原视频地址") | |||
private String videoUrl; | |||
@ApiModelProperty(value = "AI识别后视频地址") | |||
private String aiVideoUrl; | |||
@ApiModelProperty(value = "任务飞行状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成") | |||
private Integer status; | |||
@@ -6,6 +6,7 @@ import com.tuoheng.admin.entity.domain.ThMission; | |||
import com.tuoheng.admin.entity.request.MissionQuery; | |||
import com.tuoheng.admin.entity.request.MissionRequest; | |||
import com.tuoheng.admin.entity.request.MissionStatusRequest; | |||
import com.tuoheng.admin.entity.vo.MissionLiveVO; | |||
import com.tuoheng.admin.entity.vo.MissionVO; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.common.OperationEnum; | |||
@@ -57,4 +58,6 @@ public interface IMissionService extends IBaseService<ThMission> { | |||
* @date: 2021/9/2 | |||
*/ | |||
boolean deleteBatch(List<Integer> idList); | |||
MissionLiveVO live(Integer id); | |||
} |
@@ -13,6 +13,7 @@ import com.tuoheng.admin.entity.domain.*; | |||
import com.tuoheng.admin.entity.request.MissionRequest; | |||
import com.tuoheng.admin.entity.request.MissionQuery; | |||
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.enums.*; | |||
import com.tuoheng.admin.mapper.*; | |||
@@ -203,7 +204,7 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi | |||
queryInspectionRequest.setTenantId(ShiroUtils.getTenantId()); | |||
LambdaQueryWrapper<ThMission> queryInspection=new LambdaQueryWrapper<>(); | |||
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); | |||
@@ -254,4 +255,22 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi | |||
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; | |||
} | |||
} |
@@ -64,8 +64,7 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio | |||
List<ThMission> thMissions = missionMapper.selectList(new LambdaQueryWrapper<ThMission>() | |||
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode()) | |||
.orderByDesc(ThMission::getUpdateTime)); | |||
List<Question> questionList = getQuestions(query, thMissions); | |||
return questionList; | |||
return getQuestions(query, thMissions); | |||
} | |||
private List<Question> getQuestions(QuestionQuery query, List<ThMission> thMissions) { | |||
@@ -170,8 +169,11 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio | |||
} | |||
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); | |||
//这边存回放的视频地址 | |||
thMissionUpdate.setVideoUrl(callbackRequest.getVideoUrl()); | |||
thMissionUpdate.setAiVideoUrl(callbackRequest.getAiVideoUrl()); | |||
} | |||
} | |||
@@ -52,7 +52,7 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper, | |||
public List<InspectionVO> track(Integer id) { | |||
LambdaQueryWrapper<ThInspection> lambdaQueryWrapper=new LambdaQueryWrapper<>(); | |||
lambdaQueryWrapper.eq(ThInspection::getMissionId,id); | |||
lambdaQueryWrapper.eq(ThInspection::getMissionId,id).orderByDesc(ThInspection::getTimestamp); | |||
//lambdaQueryWrapper.eq(ThInspection::getTenantId, ShiroUtils.getTenantId()); | |||
List<InspectionVO> result=new ArrayList<>(); | |||
List<ThInspection> thInspections = inspectionMapper.selectList(lambdaQueryWrapper); | |||
@@ -80,7 +80,7 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper, | |||
String param="page=1&limit=10"; | |||
String airPortStr = HttpUtils.sendGet(url, param); | |||
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(), "获取机场信息失败,请重试"); | |||
} | |||
return JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("records").toString(), AirPortVO.class); | |||
@@ -94,7 +94,7 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper, | |||
String param="page=1&limit=10&droneId="+droneId; | |||
String airPortStr = HttpUtils.sendGet(url, param); | |||
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(), "获取航线信息失败,请重试"); | |||
} | |||
return JSONObject.parseArray(JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData())).get("records").toString(), AirLineVO.class); | |||
@@ -111,7 +111,7 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper, | |||
String param="taskId="+taskId; | |||
String airPortStr = HttpUtils.sendPost(url, param); | |||
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),"执行任务失败!"); | |||
}else if(ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0){ | |||
return JsonResult.error(jsonResult.getMsg()); | |||
@@ -131,7 +131,7 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper, | |||
String param="airportId="+airportId; | |||
String weatherStr = HttpUtils.sendGet(url, param); | |||
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(), "获取天气信息失败,请重试"); | |||
} | |||
return JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData()),AirWeatherVO.class); |