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"; | |||||
} |
package com.tuoheng.admin.controller; | 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.admin.service.warningrecord.IWarningRecordService; | ||||
import com.tuoheng.common.utils.JsonResult; | import com.tuoheng.common.utils.JsonResult; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
/** | /** | ||||
* 查询预警记录列表 | * 查询预警记录列表 | ||||
*/ | */ | ||||
@GetMapping("/list") | |||||
public JsonResult list(QueryWarningRecordListRequest request) { | |||||
return warningRecordService.getList(request); | |||||
@GetMapping("/list/by/warningid") | |||||
public JsonResult getListByWarningId(QueryWarningRecordListByWarningIdRequest request) { | |||||
return warningRecordService.getListByWarningId(request); | |||||
} | } | ||||
} | } |
* @author: qiujinyang | * @author: qiujinyang | ||||
*/ | */ | ||||
@Data | @Data | ||||
public class QueryWarningRecordListRequest implements Serializable { | |||||
public class QueryWarningRecordListByWarningIdRequest implements Serializable { | |||||
private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
@ApiModelProperty(value = "租户Id", hidden = true) | @ApiModelProperty(value = "租户Id", hidden = true) | ||||
private Integer tenantId; | private Integer tenantId; | ||||
@ApiModelProperty(value = "预警Id", hidden = true) | |||||
private Integer warningId; | |||||
} | } |
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
import com.tuoheng.admin.entity.domain.WarningRecord; | 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; | import java.util.List; | ||||
* @param request 预警记录 | * @param request 预警记录 | ||||
* @return 预警记录集合 | * @return 预警记录集合 | ||||
*/ | */ | ||||
List<WarningRecord> getList(QueryWarningRecordListRequest request); | |||||
List<WarningRecord> getList(QueryWarningRecordListByWarningIdRequest request); | |||||
/** | /** | ||||
* 查询预警记录 | * 查询预警记录 |
package com.tuoheng.admin.service.airport; | package com.tuoheng.admin.service.airport; | ||||
import com.tuoheng.admin.entity.request.airport.PointFlightRequest; | import com.tuoheng.admin.entity.request.airport.PointFlightRequest; | ||||
import com.tuoheng.admin.service.third.airport.PointFlightService; | |||||
import com.tuoheng.common.utils.JsonResult; | import com.tuoheng.common.utils.JsonResult; | ||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
@Service | @Service | ||||
public class AirportServiceImpl implements AirportService { | public class AirportServiceImpl implements AirportService { | ||||
@Autowired | |||||
private PointFlightService pointFlightService; | |||||
/** | /** | ||||
* 获取机场列表 | * 获取机场列表 | ||||
* | * | ||||
*/ | */ | ||||
@Override | @Override | ||||
public JsonResult pointFlight(PointFlightRequest request) { | public JsonResult pointFlight(PointFlightRequest request) { | ||||
return JsonResult.success(); | |||||
return pointFlightService.executePointFligh(request); | |||||
} | } | ||||
} | } |
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(); | |||||
} | |||||
} |
if (ObjectUtil.isNull(warning)) { | if (ObjectUtil.isNull(warning)) { | ||||
throw new ServiceException("预警信息不存在"); | throw new ServiceException("预警信息不存在"); | ||||
} | } | ||||
if (!tenantId.equals(warning.getTenantId())) { | |||||
throw new ServiceException("该租户没有查询该预警信息的权限"); | |||||
} | |||||
return JsonResult.success(warning); | return JsonResult.success(warning); | ||||
} | } | ||||
package com.tuoheng.admin.service.warningrecord; | 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; | import com.tuoheng.common.utils.JsonResult; | ||||
/** | /** | ||||
* @param request 预警记录 | * @param request 预警记录 | ||||
* @return 预警记录集合 | * @return 预警记录集合 | ||||
*/ | */ | ||||
JsonResult getList(QueryWarningRecordListRequest request); | |||||
JsonResult getListByWarningId(QueryWarningRecordListByWarningIdRequest request); | |||||
/** | /** | ||||
* 查询预警记录 | * 查询预警记录 |
package com.tuoheng.admin.service.warningrecord; | 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 com.tuoheng.common.utils.JsonResult; | ||||
import org.springframework.beans.factory.annotation.Autowired; | |||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
/** | /** | ||||
@Service | @Service | ||||
public class WarningRecordServiceImpl implements IWarningRecordService { | public class WarningRecordServiceImpl implements IWarningRecordService { | ||||
@Autowired | |||||
private QueryWarningRecordListByWarningIdService queryWarningRecordListByWarningIdService; | |||||
/** | /** | ||||
* 查询预警记录列表 | * 查询预警记录列表 | ||||
* | * | ||||
* @return 预警记录 | * @return 预警记录 | ||||
*/ | */ | ||||
@Override | @Override | ||||
public JsonResult getList(QueryWarningRecordListRequest request) { | |||||
return null; | |||||
public JsonResult getListByWarningId(QueryWarningRecordListByWarningIdRequest request) { | |||||
return queryWarningRecordListByWarningIdService.getListByWarningId(request); | |||||
} | } | ||||
/** | /** |
package com.tuoheng.admin.service.warningrecord.query; | package com.tuoheng.admin.service.warningrecord.query; | ||||
import cn.hutool.core.collection.CollectionUtil; | 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.Warning; | ||||
import com.tuoheng.admin.entity.domain.WarningRecord; | 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.WarningMapper; | ||||
import com.tuoheng.admin.mapper.WarningRecordMapper; | import com.tuoheng.admin.mapper.WarningRecordMapper; | ||||
import com.tuoheng.common.exception.ServiceException; | |||||
import com.tuoheng.common.utils.JsonResult; | import com.tuoheng.common.utils.JsonResult; | ||||
import com.tuoheng.system.entity.User; | import com.tuoheng.system.entity.User; | ||||
import com.tuoheng.system.utils.ShiroUtils; | import com.tuoheng.system.utils.ShiroUtils; | ||||
*/ | */ | ||||
@Slf4j | @Slf4j | ||||
@Service | @Service | ||||
public class QueryWarningRecordListService { | |||||
public class QueryWarningRecordListByWarningIdService { | |||||
@Autowired | |||||
private WarningMapper warningMapper; | |||||
@Autowired | @Autowired | ||||
private WarningRecordMapper warningRecordMapper; | private WarningRecordMapper warningRecordMapper; | ||||
public JsonResult getList(QueryWarningRecordListRequest request) { | |||||
// log.info("进入查询预警记录列表业务"); | |||||
public JsonResult getListByWarningId(QueryWarningRecordListByWarningIdRequest request) { | |||||
// log.info("进入根据预警ID查询预警记录列表业务"); | |||||
User user = ShiroUtils.getUserInfo(); | User user = ShiroUtils.getUserInfo(); | ||||
Integer userId = user.getId(); | |||||
Integer tenantId = user.getTenantId(); | Integer tenantId = user.getTenantId(); | ||||
request.setTenantId(tenantId); | request.setTenantId(tenantId); | ||||
JsonResult result = this.check(tenantId, request); | JsonResult result = this.check(tenantId, request); | ||||
if (0 != result.getCode()) { | if (0 != result.getCode()) { | ||||
log.info("进入查询预警记录列表业务:校验失败:{}", result.getMsg()); | |||||
log.info("进入根据预警ID查询预警记录列表业务:校验失败:{}", result.getMsg()); | |||||
return result; | return result; | ||||
} | } | ||||
List<WarningRecord> warningRecordList = warningRecordMapper.getList(request); | List<WarningRecord> warningRecordList = warningRecordMapper.getList(request); | ||||
* @param request | * @param request | ||||
* @return | * @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(); | return JsonResult.success(); | ||||
} | } | ||||
select id, tenant_id, warning_id, name, mission_id, create_user, create_time, update_user, update_time, mark from th_warning_record | select id, tenant_id, warning_id, name, mission_id, create_user, create_time, update_user, update_time, mark from th_warning_record | ||||
</sql> | </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"/> | <include refid="selectWarningRecordVo"/> | ||||
<where> | <where> | ||||
<if test="1 == 1"> and mark = 1 </if> | <if test="1 == 1"> and mark = 1 </if> | ||||
<if test="tenantId != null "> and tenant_id = #{tenantId}</if> | <if test="tenantId != null "> and tenant_id = #{tenantId}</if> | ||||
<if test="warningId != null "> and warning_id = #{warningId}</if> | |||||
</where> | </where> | ||||
order by create_time desc | order by create_time desc | ||||
</select> | </select> |