瀏覽代碼

Merge branch 'develop' of gitadmin/tuoheng_lc into release

tags/v1.2.0^2
wanjing 1 年之前
父節點
當前提交
befacf130b
共有 8 個檔案被更改,包括 261 行新增12 行删除
  1. +38
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/config/CORSConfig.java
  2. +5
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/config/SystemConstant.java
  3. +18
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/conver/MissionConverMapper.java
  4. +5
    -3
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/InspectionRequest.java
  5. +32
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/AirPortStatusVO.java
  6. +105
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/EmergencyMissionVO.java
  7. +2
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java
  8. +56
    -9
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/mission/query/QueryEmergencyListService.java

+ 38
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/config/CORSConfig.java 查看文件

@@ -0,0 +1,38 @@
package com.tuoheng.admin.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.Collections;

/**
* 解决跨域问题
*
* @author wanjing
* @team tuoheng
* @date 2022-11-28
*/
@Configuration
public class CORSConfig implements WebMvcConfigurer {

@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("*")
.allowedOrigins("*");

}
};
}

}

+ 5
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/config/SystemConstant.java 查看文件

@@ -44,4 +44,9 @@ public interface SystemConstant {
*/
String API_AIRPORT_DRONE_CONTROL = "/api/airportInterface/droneCommand";

/**
* 机场平台:获取机场状态
*/
String API_AIRPORT_STATUS_BY_AIRPORT_ID = "/api/airportInterface/getAirportStatusByAirportId";

}

+ 18
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/conver/MissionConverMapper.java 查看文件

@@ -0,0 +1,18 @@
package com.tuoheng.admin.conver;

import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.vo.EmergencyMissionVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface MissionConverMapper {

MissionConverMapper INSTANCE = Mappers.getMapper(MissionConverMapper.class);

List<EmergencyMissionVO> fromMissionListToEmergencyMissionVOList(List<ThMission> missionList);


}

+ 5
- 3
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/request/InspectionRequest.java 查看文件

@@ -41,13 +41,15 @@ public class InspectionRequest implements Serializable {
@NotNull(message = "地面基站不能为空!")
private String hostIp;


@ApiModelProperty(value = "飞行时间")
@NotNull(message = "飞行时间不能为空!")
private Long flyTime;

@ApiModelProperty(value = "飞行速度")
private String speed;
@ApiModelProperty(value = "水平速度")
private String hspeed;

@ApiModelProperty(value = "垂直速度")
private String vspeed;

@ApiModelProperty(value = "遥测信号")
private String ysingal;

+ 32
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/AirPortStatusVO.java 查看文件

@@ -0,0 +1,32 @@
package com.tuoheng.admin.entity.vo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* 机场状态视图Vo
*
* @author wanjing
* @team tuoheng
* @date 2023-02-07
*/
@NoArgsConstructor
@Data
public class AirPortStatusVO implements Serializable {

private static final long serialVersionUID = 1L;

@ApiModelProperty(value = "机场id")
private Integer airportId;

@ApiModelProperty(value = "机场名称")
private String airportName;

@ApiModelProperty(value = "状态")
private String msg;


}

+ 105
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/EmergencyMissionVO.java 查看文件

@@ -0,0 +1,105 @@
package com.tuoheng.admin.entity.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
* 巡检任务 新增或修改请求参数 2022/7/27
* @author : qiujinyang
*/
@Data
public class EmergencyMissionVO implements Serializable {
private static final long serialVersionUID = 1L;

@ApiModelProperty(value = "任务id")
private Integer id;

@ApiModelProperty(value = "巡检任务编号")
private String code;

@ApiModelProperty(value = "任务名称")
private String name;

@ApiModelProperty(value = "巡检方式 1 机场服务,2 人工巡检")
private Integer inspectionType;

@ApiModelProperty(value = "巡检机场")
private Integer airportId;

@ApiModelProperty(value = "巡检机场名称")
private String airportName;

@ApiModelProperty(value = "巡检机场状态")
private String airportStatus;

@ApiModelProperty(value = "巡检线路")
private Integer inspectionLine;

@ApiModelProperty(value = "巡检线路名称")
private String inspectionLineName;

@ApiModelProperty(value = "飞机Id")
private Integer droneId;

@ApiModelProperty(value = "飞机名称")
private String droneName;

@ApiModelProperty(value = "巡检里程")
private String mileage;

@ApiModelProperty(value = "任务类型 1 日常,2 应急巡检")
private Integer type;

@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "巡检时间")
private Date executionStartTime;

@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "巡检结束时间")
private Date executionEndTime;

//直播的两个通道
@ApiModelProperty(value = "视频拉流地址")
private String pullUrl;
@ApiModelProperty(value = "AI拉流地址")
private String aipullUrl;


//直播的视频地址
@ApiModelProperty(value = "视频地址")
private String playUrl;
@ApiModelProperty(value = "AI识别后视频地址")
private String aiplayUrl;

//回放视频的两个地址
@ApiModelProperty(value = "原视频地址")
private String videoUrl;
@ApiModelProperty(value = "AI识别后视频地址")
private String aiVideoUrl;

@ApiModelProperty(value = "任务飞行状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成")
private Integer status;

@ApiModelProperty(value = "巡检报告是否生成 是否生成 0 未生成 1 需修改 2 已生成")
private Integer reportStatus;

@ApiModelProperty(value = "备注")
private String note;

@ApiModelProperty(value = "创建人")
private String createUser;

@ApiModelProperty(value = "飞行时间")
private String flyTime;

@ApiModelProperty(value = "租户id",hidden = true)
private Integer tenantId;

}

+ 2
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java 查看文件

@@ -113,6 +113,8 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper,
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "没有该任务!");
}
ThMission mission = thMissions.get(0);
inspection.setSpeed(inspectionRequest.getHspeed());
inspection.setYsingal(inspectionRequest.getYsingal());
inspection.setMissionId(mission.getId());
inspection.setTenantId(mission.getTenantId());
inspectionMapper.insert(inspection);

+ 56
- 9
tuoheng-admin/src/main/java/com/tuoheng/admin/service/mission/query/QueryEmergencyListService.java 查看文件

@@ -2,26 +2,33 @@ package com.tuoheng.admin.service.mission.query;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.domain.Camera;
import com.tuoheng.admin.config.SystemConstant;
import com.tuoheng.admin.conver.MissionConverMapper;
import com.tuoheng.admin.entity.domain.ThMission;
import com.tuoheng.admin.entity.request.camera.QueryCameraListRequest;
import com.tuoheng.admin.entity.request.emergency.QueryEmergencyListRequest;
import com.tuoheng.admin.enums.AccidentTaskEnum;
import com.tuoheng.admin.entity.vo.AirPortStatusVO;
import com.tuoheng.admin.entity.vo.EmergencyMissionVO;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.MissionEnum;
import com.tuoheng.admin.enums.TaskStatusEnum;
import com.tuoheng.admin.mapper.CameraMapper;
import com.tuoheng.admin.mapper.ThMissionMapper;
import com.tuoheng.common.config.CommonConfig;
import com.tuoheng.common.exception.ServiceException;
import com.tuoheng.common.utils.HttpUtils;
import com.tuoheng.common.utils.JacksonUtil;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.common.utils.StringUtils;
import com.tuoheng.system.entity.City;
import com.tuoheng.system.entity.User;
import com.tuoheng.system.utils.ShiroUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* 查询应急任务列表业务层处理
@@ -47,15 +54,23 @@ public class QueryEmergencyListService {
log.info("进入查询应急任务列表业务:校验失败:{}", result.getMsg());
return result;
}

List<ThMission> missionList = thMissionMapper.selectList(new LambdaQueryWrapper<ThMission>()
.eq(ThMission::getMark, MarkEnum.VALID.getCode())
.eq(ThMission::getTenantId, tenantId)
.eq(ThMission::getType, 2)
.in(CollectionUtil.isNotEmpty(request.getStatusList()), ThMission::getStatus, request.getStatusList()));

if (CollectionUtil.isEmpty(missionList)) {
log.info("应急任务列表数据为空");
return JsonResult.success("应急任务列表数据为空");
}
List<EmergencyMissionVO> emergencyMissionVOList = MissionConverMapper.INSTANCE.fromMissionListToEmergencyMissionVOList(missionList);
Map<Integer, AirPortStatusVO> airPortStatusVOMap = getAirPortStatusVOMap(missionList);
AirPortStatusVO airPortStatusVO;
for (EmergencyMissionVO emergencyMissionVO : emergencyMissionVOList) {
airPortStatusVO = airPortStatusVOMap.get(emergencyMissionVO.getAirportId());
if (ObjectUtil.isNotNull(airPortStatusVO)) {
emergencyMissionVO.setAirportStatus(airPortStatusVO.getMsg());
}
}
return JsonResult.success(missionList);
}
@@ -71,4 +86,36 @@ public class QueryEmergencyListService {
return JsonResult.success();
}

private Map<Integer, AirPortStatusVO> getAirPortStatusVOMap(List<ThMission> missionList) {
String airportIds = "";
for (ThMission mission : missionList) {
airportIds += mission.getAirportId() + ",";
}
airportIds.substring(0, airportIds.length() - 1);

String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_STATUS_BY_AIRPORT_ID;
JSONObject jsonObject = new JSONObject();
jsonObject.put("airportIds", airportIds);

log.info("调用机场平台,查询飞行状态: url:{}", url);
log.info("调用机场平台,查询飞行状态: jsonObject:{}", jsonObject);

String airPortStatusStr = HttpUtils.doSend(url, jsonObject, null, "POST");
if (StringUtils.isEmpty(airPortStatusStr)) {
log.info("调用机场平台,查询飞行状态:机场接口返回数据为空,查询飞行状态失败");
throw new ServiceException("机场接口返回数据为空,查询飞行状态失败");
}
log.info("调用机场平台,查询飞行状态:机场接口返回数据为空,查询飞行状态失败,airPortStatusStr:{}", airPortStatusStr);

JsonResult jsonResult = JacksonUtil.json2pojo(airPortStatusStr, JsonResult.class);

List<AirPortStatusVO> airPortStatusVOList = JSONObject.parseArray(JSONObject.toJSONString(jsonResult.getData()), AirPortStatusVO.class);
Map<Integer, AirPortStatusVO> map = new HashMap<>();
for (AirPortStatusVO airPortStatusVO : airPortStatusVOList) {
log.info("调用机场平台,查询飞行状态, airPortStatusVO={}", airPortStatusVO);
map.put(airPortStatusVO.getAirportId(), airPortStatusVO);
}
return map;
}

}

Loading…
取消
儲存