Browse Source

添加回调问题的问题坐标

tags/v1.1.0
qiujinyang 2 years ago
parent
commit
8b7002be55
2 changed files with 47 additions and 3 deletions
  1. +45
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java
  2. +2
    -2
      tuoheng-common/src/main/java/com/tuoheng/common/utils/JsonResult.java

+ 45
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java View File

@@ -7,12 +7,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.common.ServiceExceptionEnum;
import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.domain.ThInspection;
import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.request.*;
import com.tuoheng.admin.entity.vo.QuestionCountVO;
import com.tuoheng.admin.entity.vo.QuestionTypeCountVO;
import com.tuoheng.admin.enums.*;
import com.tuoheng.admin.mapper.QuestionMapper;
import com.tuoheng.admin.mapper.ThInspectionMapper;
import com.tuoheng.admin.mapper.ThMissionMapper;
import com.tuoheng.admin.service.IQuestionService;
import com.tuoheng.common.common.BaseServiceImpl;
@@ -23,8 +25,11 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
* 巡检问题表 服务实现类
@@ -41,6 +46,9 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
@Autowired
private ThMissionMapper missionMapper;

@Autowired
private ThInspectionMapper inspectionMapper;

@Override
public IPage<Question> queryPage(QuestionQuery query) {
if(null == query.getPage() || null == query.getLimit()){
@@ -181,17 +189,33 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
List<CallbackRequest.QuestionFilesDTO> questionFiles = callbackRequest.getQuestionFiles();

//获取当前飞行坐标,存问题的经纬度
List<ThInspection> flightDataList = getThInspections(mission);


List<Question> questionList = getQuestionList(mission, questionFiles, flightDataList);
return saveBatch(questionList);
}

private List<ThInspection> getThInspections(ThMission mission) {
return inspectionMapper.selectList(new LambdaQueryWrapper<ThInspection>()
.eq(ThInspection::getMissionId, mission.getId())
.eq(ThInspection::getMark, MarkTypeEnum.VALID.getCode())
.orderByDesc(ThInspection::getTimestamp));
}

private List<Question> getQuestionList(ThMission mission, List<CallbackRequest.QuestionFilesDTO> questionFiles, List<ThInspection> flightDataList) {
List<Question> questionList=new ArrayList<>();
for (CallbackRequest.QuestionFilesDTO questionFile : questionFiles) {
Question question=new Question(UpdateOrCreateEnum.CREATE.getCode());
ThInspection flightDataByTime = getFlightDataByTime(flightDataList, questionFile.getAnalyseTime().getTime());
question.setMissionId(mission.getId());
question.setMissionName(mission.getName());
question.setLat(flightDataByTime.getLat());
question.setLng(flightDataByTime.getLng());
BeanUtils.copyProperties(questionFile,question);
questionList.add(question);
}
return saveBatch(questionList);
return questionList;
}

private ThMission getThMission(String requestId) {
@@ -205,4 +229,24 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
}
return thMissions.get(0);
}


/**
* 获取飞行坐标
*
* @param inspectionList 飞行坐标集合
* @param time 当前时间
* @return 当前飞行对象
*/
private ThInspection getFlightDataByTime(List<ThInspection> inspectionList, long time) {
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());
if (CollectionUtils.isEmpty(inspectionData)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取无人机飞行坐标失败!");
}
return inspectionData.get(0);
}
}

+ 2
- 2
tuoheng-common/src/main/java/com/tuoheng/common/utils/JsonResult.java View File

@@ -28,12 +28,12 @@ public class JsonResult<T> implements Serializable {

private String msg;

private T data;

public static <T> JsonResult<T> success() {
return jsonResult(null, SUCCESS, "操作成功");
}

private T data;

public static <T> JsonResult<T> success(T data) {
return jsonResult(data, SUCCESS, "操作成功");
}

Loading…
Cancel
Save