@@ -1,18 +1,23 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.admin.dto.InspectionDto; | |||
import com.tuoheng.admin.entity.FlightData; | |||
import com.tuoheng.admin.query.InspectionFileQuery; | |||
import com.tuoheng.admin.request.inspection.AddInspectionRequest; | |||
import com.tuoheng.admin.request.inspection.EditInspectionRequest; | |||
import com.tuoheng.admin.request.inspection.InspectionRequest; | |||
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest; | |||
import com.tuoheng.admin.service.inspection.IInspectionService; | |||
import com.tuoheng.common.core.common.OperationEnum; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
import javax.validation.Valid; | |||
/** | |||
* 巡检任务前端控制器 | |||
* | |||
@@ -123,6 +128,15 @@ public class InspectionController { | |||
return iInspectionService.getFlightDataByInspectionId(inspectionId); | |||
} | |||
/** | |||
* 被硬件调用,存飞行轨迹 | |||
*/ | |||
@PostMapping("/track") | |||
public OperationEnum track(@RequestBody @Valid InspectionRequest inspectionRequest) { | |||
log.info("被硬件调用,存飞行轨迹:{}", JSONObject.toJSONString(inspectionRequest)); | |||
return iInspectionService.track(inspectionRequest); | |||
} | |||
/** | |||
* 重新提交巡检任务 | |||
*/ |
@@ -0,0 +1,55 @@ | |||
package com.tuoheng.admin.request.inspection; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotNull; | |||
import java.io.Serializable; | |||
/** | |||
* @User qiujinyang | |||
* @Description | |||
* @Date Created by 2022/7/28 9:51 | |||
*/ | |||
@Data | |||
public class InspectionRequest implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
private String requestId; | |||
/** | |||
* 巡检的ID,跟硬件对接的时候,硬件的巡检ID,对应th_inspection表inspection_line字段 | |||
*/ | |||
@NotNull(message = "巡检的ID不能为空!") | |||
private Integer inspectionId; | |||
/** | |||
* 飞行高度 | |||
*/ | |||
@NotNull(message = "飞行高度不能为空!") | |||
private String altitude; | |||
/** | |||
* 经度 | |||
*/ | |||
@NotNull(message = "经度不能为空!") | |||
private String lng; | |||
/** | |||
* 纬度 | |||
*/ | |||
@NotNull(message = "纬度不能为空!") | |||
private String lat; | |||
/** | |||
* 地面基站 | |||
*/ | |||
private String hostIp; | |||
/** | |||
* 时间戳 | |||
*/ | |||
@NotNull(message = "时间戳不能为空!") | |||
private String timestamp; | |||
} |
@@ -6,7 +6,9 @@ import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.query.InspectionFileQuery; | |||
import com.tuoheng.admin.request.inspection.AddInspectionRequest; | |||
import com.tuoheng.admin.request.inspection.EditInspectionRequest; | |||
import com.tuoheng.admin.request.inspection.InspectionRequest; | |||
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest; | |||
import com.tuoheng.common.core.common.OperationEnum; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
/** | |||
@@ -114,4 +116,10 @@ public interface IInspectionService { | |||
*/ | |||
JsonResult getNewInspectionList(); | |||
/** | |||
* 被硬件调用,存飞行轨迹 | |||
* @param inspectionRequest | |||
* @return | |||
*/ | |||
OperationEnum track(InspectionRequest inspectionRequest); | |||
} |
@@ -6,6 +6,7 @@ import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.query.InspectionFileQuery; | |||
import com.tuoheng.admin.request.inspection.AddInspectionRequest; | |||
import com.tuoheng.admin.request.inspection.EditInspectionRequest; | |||
import com.tuoheng.admin.request.inspection.InspectionRequest; | |||
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest; | |||
import com.tuoheng.admin.service.inspection.add.AddInspectionService; | |||
import com.tuoheng.admin.service.inspection.execute.ExecuteInspectionService; | |||
@@ -13,6 +14,7 @@ import com.tuoheng.admin.service.inspection.resubmit.ResubmitInspectionService; | |||
import com.tuoheng.admin.service.inspection.delete.DeleteInspectionService; | |||
import com.tuoheng.admin.service.inspection.query.*; | |||
import com.tuoheng.admin.service.inspection.update.UpdateInspectionService; | |||
import com.tuoheng.common.core.common.OperationEnum; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -71,6 +73,9 @@ public class InspectionServiceImpl implements IInspectionService { | |||
@Autowired | |||
private QueryNewInspectionListService queryNewInspectionListService; | |||
@Autowired | |||
private QueryFlightDataTrackService queryFlightDataTrackService; | |||
/** | |||
* 查询巡检任务分页分页列表 | |||
@@ -223,4 +228,14 @@ public class InspectionServiceImpl implements IInspectionService { | |||
return queryNewInspectionListService.getList(); | |||
} | |||
/** | |||
* 被硬件调用,存飞行轨迹 | |||
* @param inspectionRequest | |||
* @return | |||
*/ | |||
@Override | |||
public OperationEnum track(InspectionRequest inspectionRequest) { | |||
return queryFlightDataTrackService.track(inspectionRequest); | |||
} | |||
} |
@@ -0,0 +1,55 @@ | |||
package com.tuoheng.admin.service.inspection.query; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.admin.entity.FlightData; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.mapper.FlightDataMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.request.inspection.InspectionRequest; | |||
import com.tuoheng.common.core.common.OperationEnum; | |||
import com.tuoheng.common.core.enums.ServiceExceptionEnum; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.RedisUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/12/13 | |||
*/ | |||
@Service | |||
@Slf4j | |||
public class QueryFlightDataTrackService { | |||
@Autowired | |||
private RedisUtils redisUtils; | |||
@Autowired | |||
private FlightDataMapper flightDataMapper; | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
public OperationEnum track(InspectionRequest inspectionRequest) { | |||
Inspection inspection = inspectionMapper.selectById(inspectionRequest.getRequestId()); | |||
if (ObjectUtil.isEmpty(inspection)) { | |||
throw new ServiceException(ServiceExceptionEnum.TASK_DOES_NOT_EXIST); | |||
} | |||
FlightData flightData = new FlightData(); | |||
BeanUtils.copyProperties(inspectionRequest, flightData); | |||
flightData.setTenantId(inspection.getTenantId()); | |||
flightData.setInspectionId(inspection.getId()); | |||
flightData.setAltitude(null); | |||
//机场传过来的高度是相对高度 | |||
flightData.setUltrasonic(inspectionRequest.getAltitude()); | |||
//将最新一条数据放入缓存,并设置过期时间 | |||
redisUtils.set(String.valueOf(inspection.getId()), flightData, 10); | |||
flightDataMapper.insert(flightData); | |||
return OperationEnum.OPERATION_SUCCESS; | |||
} | |||
} |