@@ -0,0 +1,36 @@ | |||
package com.tuoheng.admin.config; | |||
public interface SystemConstant { | |||
/** | |||
* 机场平台:获取机场列表接口 | |||
*/ | |||
String API_AIRPORT_LIST = "/api/airportInterface/airportList"; | |||
/** | |||
* 机场平台:获取机场路线列表接口 | |||
*/ | |||
String API_AIRPORT_LINE_LIST = "/api/airportInterface/taskByDroneId"; | |||
/** | |||
* 机场平台:执行接口 | |||
*/ | |||
String API_AIRPORT_EXECUTE_TASK = "/api/airportInterface/executeTaskAnsy"; | |||
/** | |||
* 机场平台:获取天气 | |||
*/ | |||
String API_AIRPORT_GET_WEATHER = "/api/airportInterface/getWeather"; | |||
// 飞手平台不同接口url | |||
/** | |||
* 新增任务接口 | |||
*/ | |||
String ADD_PILOTTASK = "apiTask/add"; | |||
/** | |||
* 机场平台:定点飞行 | |||
*/ | |||
String API_AIRPORT_POINT_FLIGH = "/api/airportInterface/createPointLine"; | |||
} |
@@ -1,6 +1,6 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListRequest; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListByWarningIdRequest; | |||
import com.tuoheng.admin.service.warningrecord.IWarningRecordService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -24,9 +24,9 @@ public class WarningRecordController { | |||
/** | |||
* 查询预警记录列表 | |||
*/ | |||
@GetMapping("/list") | |||
public JsonResult list(QueryWarningRecordListRequest request) { | |||
return warningRecordService.getList(request); | |||
@GetMapping("/list/by/warningid") | |||
public JsonResult getListByWarningId(QueryWarningRecordListByWarningIdRequest request) { | |||
return warningRecordService.getListByWarningId(request); | |||
} | |||
} |
@@ -11,11 +11,14 @@ import java.io.Serializable; | |||
* @author: qiujinyang | |||
*/ | |||
@Data | |||
public class QueryWarningRecordListRequest implements Serializable { | |||
public class QueryWarningRecordListByWarningIdRequest implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
@ApiModelProperty(value = "租户Id", hidden = true) | |||
private Integer tenantId; | |||
@ApiModelProperty(value = "预警Id", hidden = true) | |||
private Integer warningId; | |||
} |
@@ -2,7 +2,7 @@ package com.tuoheng.admin.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.admin.entity.domain.WarningRecord; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListRequest; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListByWarningIdRequest; | |||
import java.util.List; | |||
@@ -21,7 +21,7 @@ public interface WarningRecordMapper extends BaseMapper<WarningRecord> { | |||
* @param request 预警记录 | |||
* @return 预警记录集合 | |||
*/ | |||
List<WarningRecord> getList(QueryWarningRecordListRequest request); | |||
List<WarningRecord> getList(QueryWarningRecordListByWarningIdRequest request); | |||
/** | |||
* 查询预警记录 |
@@ -1,12 +1,17 @@ | |||
package com.tuoheng.admin.service.airport; | |||
import com.tuoheng.admin.entity.request.airport.PointFlightRequest; | |||
import com.tuoheng.admin.service.third.airport.PointFlightService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@Service | |||
public class AirportServiceImpl implements AirportService { | |||
@Autowired | |||
private PointFlightService pointFlightService; | |||
/** | |||
* 获取机场列表 | |||
* | |||
@@ -24,6 +29,6 @@ public class AirportServiceImpl implements AirportService { | |||
*/ | |||
@Override | |||
public JsonResult pointFlight(PointFlightRequest request) { | |||
return JsonResult.success(); | |||
return pointFlightService.executePointFligh(request); | |||
} | |||
} |
@@ -0,0 +1,66 @@ | |||
package com.tuoheng.admin.service.third.airport; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.admin.config.SystemConstant; | |||
import com.tuoheng.admin.entity.domain.Tenant; | |||
import com.tuoheng.admin.entity.request.airport.PointFlightRequest; | |||
import com.tuoheng.admin.mapper.TenantMapper; | |||
import com.tuoheng.common.exception.ServiceException; | |||
import com.tuoheng.common.utils.HttpUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
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; | |||
@Slf4j | |||
@Service | |||
public class PointFlightService { | |||
@Autowired | |||
private TenantMapper tenantMapper; | |||
public JsonResult executePointFligh(PointFlightRequest request) { | |||
log.info("进入调用机场平台,执行定点飞行"); | |||
// 读取不同租户的机场平台url | |||
User user = ShiroUtils.getUserInfo(); | |||
Integer tenantId = user.getTenantId(); | |||
Tenant tenant = tenantMapper.selectById(tenantId); | |||
if (ObjectUtil.isEmpty(tenant)) { | |||
log.info("调用机场平台,执行定点飞行: 租户不存在"); | |||
throw new ServiceException("租户不存在"); | |||
} | |||
if (StringUtils.isEmpty(tenant.getAirportUrl())) { | |||
log.info("调用机场平台,执行定点飞行: 机场平台URL为空"); | |||
throw new ServiceException("机场平台URL为空"); | |||
} | |||
String url = tenant.getAirportUrl() + SystemConstant.API_AIRPORT_POINT_FLIGH; | |||
JSONObject jsonObject = new JSONObject(); | |||
jsonObject.put("airportId", request.getAirportId()); | |||
jsonObject.put("requestId", request.getRequestId()); | |||
jsonObject.put("code", "gs"); // 与机场平台约定好的 | |||
jsonObject.put("tenantCode", tenant.getCode()); | |||
jsonObject.put("alt", request.getAlt()); | |||
jsonObject.put("lon", request.getLon()); | |||
jsonObject.put("lat", request.getLat()); | |||
log.info("调用机场平台,执行定点飞行: url:{}", url); | |||
log.info("调用机场平台,执行定点飞行: jsonObject:{}", jsonObject); | |||
String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST"); | |||
if (StringUtils.isEmpty(airPortStr)) { | |||
log.info("执行定点飞行:机场接口返回数据为空,飞行失败,jsonObject:{}", jsonObject); | |||
return JsonResult.error(-1, "机场接口返回数据为空"); | |||
} | |||
log.info("调用机场平台方法: 执行定点飞行结束"); | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -63,9 +63,6 @@ public class QueryWarningByIdService { | |||
if (ObjectUtil.isNull(warning)) { | |||
throw new ServiceException("预警信息不存在"); | |||
} | |||
if (!tenantId.equals(warning.getTenantId())) { | |||
throw new ServiceException("该租户没有查询该预警信息的权限"); | |||
} | |||
return JsonResult.success(warning); | |||
} | |||
@@ -1,6 +1,6 @@ | |||
package com.tuoheng.admin.service.warningrecord; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListRequest; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListByWarningIdRequest; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
@@ -18,7 +18,7 @@ public interface IWarningRecordService { | |||
* @param request 预警记录 | |||
* @return 预警记录集合 | |||
*/ | |||
JsonResult getList(QueryWarningRecordListRequest request); | |||
JsonResult getListByWarningId(QueryWarningRecordListByWarningIdRequest request); | |||
/** | |||
* 查询预警记录 |
@@ -1,7 +1,9 @@ | |||
package com.tuoheng.admin.service.warningrecord; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListRequest; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListByWarningIdRequest; | |||
import com.tuoheng.admin.service.warningrecord.query.QueryWarningRecordListByWarningIdService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
@@ -14,6 +16,9 @@ import org.springframework.stereotype.Service; | |||
@Service | |||
public class WarningRecordServiceImpl implements IWarningRecordService { | |||
@Autowired | |||
private QueryWarningRecordListByWarningIdService queryWarningRecordListByWarningIdService; | |||
/** | |||
* 查询预警记录列表 | |||
* | |||
@@ -21,8 +26,8 @@ public class WarningRecordServiceImpl implements IWarningRecordService { | |||
* @return 预警记录 | |||
*/ | |||
@Override | |||
public JsonResult getList(QueryWarningRecordListRequest request) { | |||
return null; | |||
public JsonResult getListByWarningId(QueryWarningRecordListByWarningIdRequest request) { | |||
return queryWarningRecordListByWarningIdService.getListByWarningId(request); | |||
} | |||
/** |
@@ -1,12 +1,15 @@ | |||
package com.tuoheng.admin.service.warningrecord.query; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.tuoheng.admin.entity.domain.Warning; | |||
import com.tuoheng.admin.entity.domain.WarningRecord; | |||
import com.tuoheng.admin.entity.request.warning.QueryWarningListRequest; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListRequest; | |||
import com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListByWarningIdRequest; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.mapper.WarningMapper; | |||
import com.tuoheng.admin.mapper.WarningRecordMapper; | |||
import com.tuoheng.common.exception.ServiceException; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.system.entity.User; | |||
import com.tuoheng.system.utils.ShiroUtils; | |||
@@ -25,22 +28,24 @@ import java.util.List; | |||
*/ | |||
@Slf4j | |||
@Service | |||
public class QueryWarningRecordListService { | |||
public class QueryWarningRecordListByWarningIdService { | |||
@Autowired | |||
private WarningMapper warningMapper; | |||
@Autowired | |||
private WarningRecordMapper warningRecordMapper; | |||
public JsonResult getList(QueryWarningRecordListRequest request) { | |||
// log.info("进入查询预警记录列表业务"); | |||
public JsonResult getListByWarningId(QueryWarningRecordListByWarningIdRequest request) { | |||
// log.info("进入根据预警ID查询预警记录列表业务"); | |||
User user = ShiroUtils.getUserInfo(); | |||
Integer userId = user.getId(); | |||
Integer tenantId = user.getTenantId(); | |||
request.setTenantId(tenantId); | |||
JsonResult result = this.check(tenantId, request); | |||
if (0 != result.getCode()) { | |||
log.info("进入查询预警记录列表业务:校验失败:{}", result.getMsg()); | |||
log.info("进入根据预警ID查询预警记录列表业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
List<WarningRecord> warningRecordList = warningRecordMapper.getList(request); | |||
@@ -57,8 +62,18 @@ public class QueryWarningRecordListService { | |||
* @param request | |||
* @return | |||
*/ | |||
private JsonResult check(Integer tenantId, QueryWarningRecordListRequest request) { | |||
private JsonResult check(Integer tenantId, QueryWarningRecordListByWarningIdRequest request) { | |||
// 判断预警id是否为空 | |||
if (ObjectUtil.isNotNull(request.getWarningId())) { | |||
throw new ServiceException("预警ID为空"); | |||
} | |||
Warning warning = warningMapper.selectOne(new LambdaQueryWrapper<Warning>() | |||
.eq(Warning::getId, request.getWarningId()) | |||
.eq(Warning::getTenantId, tenantId) | |||
.eq(Warning::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isNull(warning)) { | |||
throw new ServiceException("预警信息不存在"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
@@ -21,11 +21,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
select id, tenant_id, warning_id, name, mission_id, create_user, create_time, update_user, update_time, mark from th_warning_record | |||
</sql> | |||
<select id="getList" parameterType="com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListRequest" resultMap="WarningRecordResult"> | |||
<select id="getList" parameterType="com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListByWarningIdRequest" resultMap="WarningRecordResult"> | |||
<include refid="selectWarningRecordVo"/> | |||
<where> | |||
<if test="1 == 1"> and mark = 1 </if> | |||
<if test="tenantId != null "> and tenant_id = #{tenantId}</if> | |||
<if test="warningId != null "> and warning_id = #{warningId}</if> | |||
</where> | |||
order by create_time desc | |||
</select> |