|
|
@@ -27,6 +27,7 @@ import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
@@ -49,6 +50,8 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
@Autowired |
|
|
|
private ThInspectionMapper inspectionMapper; |
|
|
|
|
|
|
|
private final static SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
@Override |
|
|
|
public IPage<Question> queryPage(QuestionQuery query) { |
|
|
|
if(null == query.getPage() || null == query.getLimit()){ |
|
|
@@ -163,8 +166,12 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
//如果任务已经完成就修改任务状态 |
|
|
|
ThMission thMissionUpdate=new ThMission(UpdateOrCreateEnum.UPDATE.getCode()); |
|
|
|
if(aBoolean){ |
|
|
|
//添加进度 |
|
|
|
thMissionUpdate.setProgressbar(callbackRequest.getProgress()); |
|
|
|
setComplate(callbackRequest, mission, thMissionUpdate); |
|
|
|
}else{ |
|
|
|
//添加进度 |
|
|
|
thMissionUpdate.setProgressbar(callbackRequest.getProgress()); |
|
|
|
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FAIL, mission); |
|
|
|
} |
|
|
|
return JsonResult.success(); |
|
|
@@ -178,20 +185,19 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
|
|
|
|
private void setComplate(CallbackRequest callbackRequest, ThMission mission, ThMission thMissionUpdate) { |
|
|
|
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()); |
|
|
|
}else if(callbackRequest.getAnalyseStatus()== AiAnalyseStatusEnum.FAILED.getCode()){ |
|
|
|
thMissionUpdate.setStatus(TaskStatusEnum.FAIL.getCode()); |
|
|
|
} |
|
|
|
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.COMPLETE, mission); |
|
|
|
} |
|
|
|
|
|
|
|
private Boolean saveQuestion(CallbackRequest callbackRequest, ThMission mission) { |
|
|
|
List<CallbackRequest.QuestionFilesDTO> questionFiles = callbackRequest.getQuestionFiles(); |
|
|
|
|
|
|
|
//获取当前飞行坐标,存问题的经纬度 |
|
|
|
List<ThInspection> flightDataList = getThInspections(mission); |
|
|
|
|
|
|
|
|
|
|
|
List<Question> questionList = getQuestionList(mission, questionFiles, flightDataList); |
|
|
|
return saveBatch(questionList); |
|
|
|
} |
|
|
@@ -224,7 +230,7 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
.eq(ThMission::getRequestId, requestId) |
|
|
|
.eq(ThMission::getStatus,TaskStatusEnum.FLIGHT.getCode()).orderByDesc(ThMission::getCreateTime); |
|
|
|
List<ThMission> thMissions = missionMapper.selectList(lambdaQueryWrapper); |
|
|
|
if(ObjectUtil.isNotEmpty(thMissions) || thMissions.size()==0){ |
|
|
|
if(ObjectUtil.isEmpty(thMissions) || thMissions.size()==0){ |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(),"正在执行的任务不存在!"); |
|
|
|
} |
|
|
|
return thMissions.get(0); |
|
|
@@ -242,8 +248,16 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio |
|
|
|
if (CollectionUtils.isEmpty(inspectionList)) { |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取无人机飞行坐标失败!"); |
|
|
|
} |
|
|
|
List<ThInspection> inspectionData = inspectionList.stream().filter(inspection -> Long.parseLong(inspection.getTimestamp()) <= time) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
List<ThInspection> inspectionData =new ArrayList<>(); |
|
|
|
try { |
|
|
|
for (ThInspection thInspection : inspectionList) { |
|
|
|
if(dateformat.parse(thInspection.getTimestamp()).getTime() <= time){ |
|
|
|
inspectionData.add(thInspection); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (ParseException e) { |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(),"巡检时间格式错误!"); |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(inspectionData)) { |
|
|
|
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取无人机飞行坐标失败!"); |
|
|
|
} |