package com.tuoheng.admin.conver; | |||||
import com.tuoheng.admin.entity.domain.WarningRecord; | |||||
import com.tuoheng.admin.entity.vo.warning.WarningRecordVo; | |||||
import org.mapstruct.Mapper; | |||||
import org.mapstruct.factory.Mappers; | |||||
import java.util.List; | |||||
@Mapper | |||||
public interface WarningRecordConverMapper { | |||||
WarningRecordConverMapper INSTANCE = Mappers.getMapper(WarningRecordConverMapper.class); | |||||
List<WarningRecordVo> fromWarningRecordListToWarningRecordListVoList(List<WarningRecord> warningRecordList); | |||||
} |
package com.tuoheng.admin.entity.vo.warning; | |||||
import com.tuoheng.common.common.BaseEntity; | |||||
import lombok.Data; | |||||
import lombok.EqualsAndHashCode; | |||||
import lombok.experimental.Accessors; | |||||
import java.io.Serializable; | |||||
/** | |||||
* 预警记录对象 th_warning_record | |||||
* | |||||
* @author wanjing | |||||
* @team tuoheng | |||||
* @date 2023-02-06 | |||||
*/ | |||||
@Data | |||||
@EqualsAndHashCode(callSuper = true) | |||||
@Accessors(chain = true) | |||||
public class WarningRecordVo extends BaseEntity implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
/** | |||||
* 预警ID | |||||
*/ | |||||
private Integer warningId; | |||||
/** | |||||
* 记录名称 | |||||
*/ | |||||
private String name; | |||||
/** | |||||
* 任务ID | |||||
*/ | |||||
private Integer missionId; | |||||
/** | |||||
* 应急任务ID | |||||
*/ | |||||
private Integer emergencyMissionId; | |||||
/** | |||||
* 任务状态:1任务待飞行 2任务飞行中 3任务执行失败 4任务飞行完成 | |||||
*/ | |||||
private Integer status; | |||||
} |
log.info("修改飞行状态:{}",JSONObject.toJSONString(thMissionUpdate)); | log.info("修改飞行状态:{}",JSONObject.toJSONString(thMissionUpdate)); | ||||
return thMissionMapper.updateById(thMissionUpdate) > 0; | return thMissionMapper.updateById(thMissionUpdate) > 0; | ||||
}else if(AirPortTaskStatusEnum.WAIT.getCode()==missionStatusRequest.getStatus()){ | }else if(AirPortTaskStatusEnum.WAIT.getCode()==missionStatusRequest.getStatus()){ | ||||
// 机场飞行完成,立即修改任务状态为已完成,设置天气 | |||||
ThMission thMission = thMissionMapper.selectOne(new LambdaQueryWrapper<ThMission>() | |||||
.eq(ThMission::getId, missionStatusRequest.getRequestId()) | |||||
.eq(ThMission::getMark, MarkEnum.VALID.getCode())); | |||||
ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode()); | |||||
thMissionUpdate.setId(Integer.parseInt(missionStatusRequest.getRequestId())); | |||||
thMissionUpdate.setStatus(TaskStatusEnum.COMPLETE.getCode()); | |||||
thMissionUpdate.setExecutionEndTime(new Date()); | |||||
try { | |||||
AirWeatherVO weather = inspectionService.getWeather(thMission.getAirportId()); | |||||
String weatherStr = WeatherUtil.getWeather(weather); | |||||
thMissionUpdate.setWeather(weatherStr); | |||||
} catch (Exception e){ | |||||
thMissionUpdate.setWeather(""); | |||||
log.info("获取天气信息失败,请重试"); | |||||
} | |||||
thMissionMapper.updateById(thMissionUpdate); | |||||
//硬件停止后,停止AI分析 | //硬件停止后,停止AI分析 | ||||
return stopAI(missionStatusRequest); | return stopAI(missionStatusRequest); | ||||
}else{ | }else{ | ||||
thMissionUpdate.setId(thMission.getId()); | thMissionUpdate.setId(thMission.getId()); | ||||
thMissionUpdate.setMileage(missionStatusRequest.getMileage()); | thMissionUpdate.setMileage(missionStatusRequest.getMileage()); | ||||
boolean result=false; | boolean result=false; | ||||
try { | |||||
AirWeatherVO weather = inspectionService.getWeather(thMission.getAirportId()); | |||||
String weatherStr = WeatherUtil.getWeather(weather); | |||||
thMissionUpdate.setWeather(weatherStr); | |||||
}catch (Exception e){ | |||||
thMissionUpdate.setWeather(""); | |||||
log.info("获取天气信息失败,请重试"); | |||||
} | |||||
//任务调用完成之后,调用发送通道,请求DSP关闭请求 | //任务调用完成之后,调用发送通道,请求DSP关闭请求 | ||||
//调用DSP接口 | //调用DSP接口 | ||||
JSONObject jsonObject = new JSONObject(); | JSONObject jsonObject = new JSONObject(); |
if (aBoolean) { | if (aBoolean) { | ||||
setComplate(callbackRequest, mission, thMissionUpdate); | setComplate(callbackRequest, mission, thMissionUpdate); | ||||
} else { | } else { | ||||
// setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FAIL, mission); | |||||
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FAIL, mission); | |||||
} | } | ||||
return JsonResult.success(); | return JsonResult.success(); | ||||
} | } | ||||
private void setTaskStatusEnum2(ThMission thMissionUpdate, TaskStatusEnum statusEnum, ThMission mission) { | |||||
private void setTaskStatusEnum(ThMission thMissionUpdate, TaskStatusEnum statusEnum, ThMission mission) { | |||||
thMissionUpdate.setStatus(statusEnum.getCode()); | thMissionUpdate.setStatus(statusEnum.getCode()); | ||||
thMissionUpdate.setId(mission.getId()); | thMissionUpdate.setId(mission.getId()); | ||||
thMissionUpdate.setExecutionEndTime(new Date()); | thMissionUpdate.setExecutionEndTime(new Date()); | ||||
} else { | } else { | ||||
thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.SUCCESS.getCode()); | thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.SUCCESS.getCode()); | ||||
} | } | ||||
// setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.COMPLETE, mission); | |||||
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.COMPLETE, mission); | |||||
} else if (callbackRequest.getAnalyseStatus() == AiAnalyseStatusEnum.FAILED.getCode()) { | } else if (callbackRequest.getAnalyseStatus() == AiAnalyseStatusEnum.FAILED.getCode()) { | ||||
// setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FAIL, mission); | |||||
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FAIL, mission); | |||||
} else { | } else { | ||||
thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.RUNNING.getCode()); | thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.RUNNING.getCode()); | ||||
// setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FLIGHT, mission); | |||||
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FLIGHT, mission); | |||||
} | } | ||||
} | } | ||||
lambdaQueryWrapper | lambdaQueryWrapper | ||||
.eq(ThMission::getMark, MarkTypeEnum.VALID.getCode()) | .eq(ThMission::getMark, MarkTypeEnum.VALID.getCode()) | ||||
.eq(ThMission::getRequestId, requestId) | .eq(ThMission::getRequestId, requestId) | ||||
.eq(ThMission::getStatus, TaskStatusEnum.COMPLETE.getCode()) | |||||
.eq(ThMission::getStatus, TaskStatusEnum.FLIGHT.getCode()) | |||||
.orderByDesc(ThMission::getExecutionStartTime); | .orderByDesc(ThMission::getExecutionStartTime); | ||||
List<ThMission> thMissions = missionMapper.selectList(lambdaQueryWrapper); | List<ThMission> thMissions = missionMapper.selectList(lambdaQueryWrapper); | ||||
if (ObjectUtil.isEmpty(thMissions) || thMissions.size() == 0) { | if (ObjectUtil.isEmpty(thMissions) || thMissions.size() == 0) { |
</resultMap> | </resultMap> | ||||
<sql id="selectWarningRecordVo"> | <sql id="selectWarningRecordVo"> | ||||
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, emergency_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.QueryWarningRecordListByWarningIdRequest" resultMap="WarningRecordResult"> | <select id="getList" parameterType="com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListByWarningIdRequest" resultMap="WarningRecordResult"> |