@@ -6,10 +6,8 @@ import com.tuoheng.admin.service.airData.IAirDataService; | |||
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.GetMapping; | |||
import org.springframework.web.bind.annotation.PathVariable; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import org.springframework.web.bind.annotation.*; | |||
import java.util.List; | |||
/** | |||
@@ -54,10 +52,10 @@ public class AirDataController { | |||
/** | |||
* 导出报告 | |||
*/ | |||
@GetMapping("/export") | |||
public void exportReport(ExportReportRequest request) { | |||
@PostMapping("/export") | |||
public JsonResult exportReport(@RequestBody ExportReportRequest request) { | |||
// log.info("进入导出报告接口"); | |||
airDataService.exportReport(request); | |||
return airDataService.exportReport(request); | |||
} | |||
} |
@@ -1,6 +1,7 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.entity.dto.ReversalFlightDto; | |||
import com.tuoheng.admin.entity.request.airport.DroneHoverRequest; | |||
import com.tuoheng.admin.entity.request.airport.ReversalFlightRequest; | |||
import com.tuoheng.admin.service.third.airport.AirportService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
@@ -61,15 +62,25 @@ public class AirPortController { | |||
return airportService.getAirportVideo(droneId); | |||
} | |||
/** | |||
* 无人机悬停 | |||
* @param request | |||
* @return | |||
*/ | |||
@PostMapping("/hover") | |||
public JsonResult hover(@RequestBody DroneHoverRequest request){ | |||
log.info("进入无人机悬停接口,request={}",request); | |||
return airportService.hover(request); | |||
} | |||
/** | |||
* 无人机返仓 | |||
* @param dto | |||
* @param request | |||
* @return | |||
*/ | |||
@PostMapping("/reversalFlight") | |||
public JsonResult reversalFlight(@RequestBody ReversalFlightDto dto){ | |||
log.info("进入无人机返航接口:dto={}",dto); | |||
public JsonResult reversalFlight(@RequestBody ReversalFlightRequest request){ | |||
log.info("进入无人机返航接口: request={}", request); | |||
return JsonResult.success(); | |||
} | |||
@@ -28,12 +28,14 @@ public class AirDataType extends BaseEntity { | |||
*/ | |||
private String name; | |||
/** | |||
* 参照指标图片地址 | |||
*/ | |||
private String referenceIndicatorImage; | |||
/** | |||
* 排序 | |||
*/ | |||
private String sort; | |||
} |
@@ -0,0 +1,26 @@ | |||
package com.tuoheng.admin.entity.request.airport; | |||
import lombok.Data; | |||
/** | |||
* 无人机悬停请求参数 | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2023-05-25 | |||
*/ | |||
@Data | |||
public class DroneHoverRequest { | |||
/** | |||
* 任务id | |||
*/ | |||
private String inspectiontId; | |||
/** | |||
* 校验数字符 | |||
*/ | |||
private String zhilin; | |||
} |
@@ -1,4 +1,4 @@ | |||
package com.tuoheng.admin.entity.dto; | |||
package com.tuoheng.admin.entity.request.airport; | |||
import lombok.Data; | |||
@@ -8,18 +8,16 @@ import lombok.Data; | |||
* @Date 2023/3/14 | |||
*/ | |||
@Data | |||
public class ReversalFlightDto { | |||
public class ReversalFlightRequest { | |||
/** | |||
* 应急事故id | |||
*/ | |||
private String accidentId; | |||
/** | |||
* 校验数字符 | |||
*/ | |||
private String zhilin; | |||
} |
@@ -11,7 +11,7 @@ import lombok.Data; | |||
* @date 2022-12-05 | |||
*/ | |||
@Data | |||
public class ExportReportRequest extends BaseQuery { | |||
public class ExportReportRequest { | |||
/** | |||
* 任务ID | |||
@@ -78,8 +78,4 @@ public class ExportReportRequest extends BaseQuery { | |||
*/ | |||
private String ossUrl; | |||
/** | |||
* 标准图片oss地址 | |||
*/ | |||
private String standardOssUrl; | |||
} |
@@ -13,8 +13,10 @@ import com.tuoheng.admin.mapper.AirDataMapper; | |||
import com.tuoheng.admin.mapper.AirDataTypeMapper; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.admin.utils.AliyunOSSUtil; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.common.core.config.UploadFileConfig; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.FileUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
@@ -58,7 +60,7 @@ public class ExportReportService { | |||
AirDataExport airDataExport = this.checkAirDataExport(request); | |||
if (ObjectUtil.isNotEmpty(airDataExport)) { | |||
return JsonResult.success(airDataExport); | |||
return JsonResult.success( airDataExport.getOssUrl(), "导出成功"); | |||
} | |||
Inspection inspection = (Inspection) result.getData(); | |||
@@ -113,7 +115,7 @@ public class ExportReportService { | |||
// 删除原文件 | |||
FileUtils.deleteFile(filePath); | |||
return JsonResult.success(); | |||
return JsonResult.success(ossUrl, "导出成功"); | |||
} | |||
/** | |||
@@ -182,7 +184,8 @@ public class ExportReportService { | |||
airDataExport.setAirDataTypeId(airDataType.getId()); | |||
airDataExport.setGridSize(request.getGridSize()); | |||
airDataExport.setOssUrl(ossUrl); | |||
airDataExport.setCreateUser(CurrentUserUtil.getUserId()); | |||
airDataExport.setCreateTime(DateUtils.now()); | |||
Integer count = airDataExportMapper.insert(airDataExport); | |||
if (count <= 0) { | |||
log.info("添加大气数据报告导出记录失败"); |
@@ -54,7 +54,7 @@ public class GenerateReportWordService { | |||
wordUtils.insertContext(airDataType.getDataType() + "单点浓度最高值:" + request.getSinglePointConcentrationMax(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0); | |||
wordUtils.insertContext(airDataType.getDataType() + "单点浓度最低值:" + request.getSinglePointConcentrationMix(), 10, Font.NORMAL, Element.ALIGN_LEFT, 20, 0, 0); | |||
wordUtils.insertImg(request.getOssUrl(), Image.ALIGN_CENTER, 400, 500, 100, 100, 100, 0); | |||
wordUtils.insertImg(request.getStandardOssUrl(), Image.ALIGN_CENTER, 100, 500, 100, 100, 100, 0); | |||
wordUtils.insertImg(airDataType.getReferenceIndicatorImage(), Image.ALIGN_CENTER, 100, 500, 100, 100, 100, 0); | |||
} catch (DocumentException e) { | |||
log.info("生成报告word异常"); | |||
throw new RuntimeException(e); |
@@ -1,6 +1,7 @@ | |||
package com.tuoheng.admin.service.third.airport; | |||
import com.tuoheng.admin.entity.domain.Inspection; | |||
import com.tuoheng.admin.entity.request.airport.DroneHoverRequest; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
public interface AirportService { | |||
@@ -15,4 +16,13 @@ public interface AirportService { | |||
JsonResult getAirportVideo(Integer droneId); | |||
/** | |||
* | |||
* 无人机悬停 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
JsonResult hover(DroneHoverRequest request); | |||
} |
@@ -1,6 +1,8 @@ | |||
package com.tuoheng.admin.service.third.airport; | |||
import com.tuoheng.admin.entity.domain.Inspection; | |||
import com.tuoheng.admin.entity.request.airport.DroneHoverRequest; | |||
import com.tuoheng.admin.service.third.airport.drone.DroneService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -23,6 +25,9 @@ public class AirportServiceImpl implements AirportService { | |||
@Autowired | |||
private GetAirportVideoService getAirportVideoService; | |||
@Autowired | |||
private DroneService droneService; | |||
@Override | |||
public JsonResult getAirportList() { | |||
return getAirportListService.getAirportList(); | |||
@@ -47,4 +52,10 @@ public class AirportServiceImpl implements AirportService { | |||
public JsonResult getAirportVideo(Integer droneId) { | |||
return getAirportVideoService.getAirportVideo(droneId); | |||
} | |||
@Override | |||
public JsonResult hover(DroneHoverRequest request) { | |||
return droneService.hover(request.getInspectiontId()); | |||
} | |||
} |
@@ -9,5 +9,9 @@ public interface DroneService { | |||
*/ | |||
JsonResult continuee(Integer airportId, String inspectionId); | |||
/** | |||
* 无人机悬停 | |||
*/ | |||
JsonResult hover(String inspectionId); | |||
} |
@@ -1,5 +1,7 @@ | |||
package com.tuoheng.admin.service.third.airport.drone; | |||
import com.tuoheng.admin.service.third.airport.drone.continuee.DroneContinueService; | |||
import com.tuoheng.admin.service.third.airport.drone.hover.DroneHoverService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -12,8 +14,16 @@ public class DroneServiceImpl implements DroneService { | |||
@Autowired | |||
private DroneContinueService droneContinueService; | |||
@Autowired | |||
private DroneHoverService droneHoverService; | |||
@Override | |||
public JsonResult continuee(Integer airportId, String inspectionId) { | |||
return droneContinueService.continuee(airportId, inspectionId); | |||
} | |||
@Override | |||
public JsonResult hover(String inspectionId) { | |||
return droneHoverService.hover(inspectionId); | |||
} | |||
} |
@@ -1,4 +1,4 @@ | |||
package com.tuoheng.admin.service.third.airport.drone; | |||
package com.tuoheng.admin.service.third.airport.drone.continuee; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.admin.constant.SystemConstant; |
@@ -0,0 +1,88 @@ | |||
package com.tuoheng.admin.service.third.airport.drone.hover; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.admin.constant.SystemConstant; | |||
import com.tuoheng.admin.entity.domain.Inspection; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.enums.code.inspection.QueryInspectionDetailsByIdCodeEnum; | |||
import com.tuoheng.admin.mapper.InspectionMapper; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.HttpUtils; | |||
import com.tuoheng.common.core.utils.JacksonUtil; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@Slf4j | |||
@Service | |||
public class DroneHoverService { | |||
@Autowired | |||
private InspectionMapper inspectionMapper; | |||
/** | |||
* 调用机场平台,原无人机悬停 | |||
* | |||
* @param inspectionId 任务Id | |||
*/ | |||
public JsonResult hover(String inspectionId) { | |||
//校验 | |||
JsonResult jsonResult = this.check(inspectionId); | |||
if(0 != jsonResult.getCode()){ | |||
log.info("无人机悬停, 参数检验失败"); | |||
return JsonResult.error(jsonResult.getCode(),jsonResult.getMsg()); | |||
} | |||
Inspection inspection = (Inspection) jsonResult.getData(); | |||
Integer airportId = inspection.getAirportId(); | |||
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_DRONE_CONTROL; | |||
JSONObject jsonObject = new JSONObject(); | |||
jsonObject.put("zhilin", "01"); | |||
jsonObject.put("airportId", airportId); | |||
jsonObject.put("taskId", inspectionId); | |||
jsonObject.put("msg", "悬停"); | |||
log.info("调用机场,无人机悬停:url:{}", url); | |||
log.info("调用机场,无人机悬停:jsonObject:{}", jsonObject); | |||
String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST"); | |||
if (StringUtils.isEmpty(airPortStr)) { | |||
log.info("调用机场,无人机悬停:机场接口返回数据为空,悬停失败,jsonObject:{}", jsonObject); | |||
throw new com.aliyun.oss.ServiceException("机场接口返回数据为空,悬停失败"); | |||
} | |||
jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | |||
if (0 != jsonResult.getCode()) { | |||
log.info("调用机场,无人机悬停:悬停失败,jsonResult:{}", jsonResult.getMsg()); | |||
throw new ServiceException("机场平台返回,悬停失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 检查参数 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
private JsonResult check(String id) { | |||
// 判断任务id是否为空 | |||
if (StringUtils.isEmpty(id)) { | |||
log.info("无人机悬停,任务ID为空"); | |||
throw new ServiceException("任务ID为空"); | |||
} | |||
// 判断任务是否存在 | |||
Inspection inspection = inspectionMapper.selectOne(new LambdaQueryWrapper<Inspection>() | |||
.eq(Inspection::getId, id) | |||
.eq(Inspection::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isEmpty(inspection)) { | |||
log.info("无人机悬停,任务不存在"); | |||
throw new ServiceException("任务不存在"); | |||
} | |||
return JsonResult.success(inspection); | |||
} | |||
} |
@@ -1,9 +1,11 @@ | |||
package com.tuoheng.admin.service; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.admin.entity.request.report.ExportReportRequest; | |||
import com.tuoheng.admin.entity.request.third.DspCallbackRequest; | |||
import com.tuoheng.admin.service.airData.report.ExportReportService; | |||
import com.tuoheng.admin.service.third.dsp.IDspCallbackService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.junit.Test; | |||
import org.junit.runner.RunWith; | |||
@@ -25,7 +27,6 @@ public class ExportReportServiceTest { | |||
request.setInspectionId("e53dc6189ec300fe063c30f5972a5fe1"); | |||
request.setAirDataTypeId("1"); | |||
request.setOssUrl("https://img2.woyaogexing.com/2023/05/23/1ec4a4a1560ca19c8c1775251dabb620.png"); | |||
request.setStandardOssUrl("https://img2.woyaogexing.com/2023/05/23/1ec4a4a1560ca19c8c1775251dabb620.png"); | |||
request.setSamplingPointsNum("510"); // 采样点数量 | |||
request.setAverageGridSize("84.9635米X849635米(7218803平方米)"); // 检测区域网格平均尺寸 | |||
request.setGridArea("346502.563(平方米)"); // 总检测区域网格面积 | |||
@@ -36,6 +37,10 @@ public class ExportReportServiceTest { | |||
request.setSinglePointConcentrationMax("25000ug/m3(1187718318252N)2022/04/29 14:06:40"); // 单点浓度最高值 | |||
request.setSinglePointConcentrationMix("16000ug/m3(1187753318286 N)2022/04/2914:02:21"); // 单点浓度最低值 | |||
request.setGridSize(1); | |||
JSONObject json = (JSONObject) JSONObject.toJSON(request); | |||
log.info("-----> json={}", json); | |||
// exportReportService.exportReport(request); | |||
} | |||