|
|
@@ -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); |
|
|
|
} |
|
|
|
} |