Browse Source

DSP联调完成

tags/v1.1.0
qiujinyang 2 years ago
parent
commit
7e10e780ef
3 changed files with 27 additions and 15 deletions
  1. +1
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/Question.java
  2. +5
    -8
      tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AiAnalyseStatusEnum.java
  3. +21
    -7
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java

+ 1
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/domain/Question.java View File

@@ -38,6 +38,7 @@ public class Question extends BaseEntity implements Serializable {
}
setUpdateUser(ShiroUtils.getUserId());
setUpdateTime(new Date());
setTenantId(ShiroUtils.getTenantId());
}

/**

+ 5
- 8
tuoheng-admin/src/main/java/com/tuoheng/admin/enums/AiAnalyseStatusEnum.java View File

@@ -6,19 +6,16 @@ import lombok.Getter;
* Ai分析状态
*/
public enum AiAnalyseStatusEnum {
UPLOADED(1,"uploaded"),

WAITING(2,"waiting"),
WAITING(5,"waiting"),

RUNNING(3,"running"),
RUNNING(10,"running"),

SUCCESS(4,"success"),
SUCCESS(15,"success"),

SUCCESS_TIMEOUT(5,"success_timeout"),
SUCCESS_TIMEOUT(20,"success_timeout"),

FAILED(6,"failed"),

DEFAULT(0,"default");
FAILED(25,"failed");

AiAnalyseStatusEnum(int code, String description){
this.code = code;

+ 21
- 7
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java View File

@@ -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(), "获取无人机飞行坐标失败!");
}

Loading…
Cancel
Save