Browse Source

Merge branch 'develop' of http://192.168.11.14:51037/gitadmin/tuoheng_lc into feature_v1.0

tags/v1.2.0^2
chengwang 1 year ago
parent
commit
fc75293d90
5 changed files with 54 additions and 22 deletions
  1. +16
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/AirWeatherVO.java
  2. +18
    -12
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/MissionServiceImpl.java
  3. +5
    -6
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java
  4. +11
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java
  5. +4
    -4
      tuoheng-admin/src/main/java/com/tuoheng/admin/utils/WeatherUtil.java

+ 16
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/AirWeatherVO.java View File

@@ -51,6 +51,7 @@ public class AirWeatherVO implements Serializable {
public static class WTHDTO {
@ApiModelProperty(value = "parm")
private ParmDTO parm;
private ParmNewDTO parmNew;
@ApiModelProperty(value = "mid")
private Integer mid;
@ApiModelProperty(value = "deviceid")
@@ -88,6 +89,21 @@ public class AirWeatherVO implements Serializable {
@ApiModelProperty(value = "WDIR")
private Integer wdir;
}

@NoArgsConstructor
@Data
public static class ParmNewDTO {
private Double hum;
private Double noise;
private Double rainfull;
private Double tmp;
private String wdirname;
private Double dew;
private Double wspd;
private Double hpa;
private Double wdir;
private Double lux;
}
}

@NoArgsConstructor

+ 18
- 12
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/MissionServiceImpl.java View File

@@ -179,10 +179,8 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
thMissionMapper.updateById(mission);
}


@Override
public boolean updateStatus(MissionStatusRequest missionStatusRequest) throws ServiceException {

//如果发送过来的状态是执行中,那么就说明之前是待执行,查询等待执行的数据,开始飞行
if(AirPortTaskStatusEnum.FLIGHT.getCode()==missionStatusRequest.getStatus()){
ThMission thMission = getRecentlyRecord(missionStatusRequest,TaskStatusEnum.WAIT.getCode());
@@ -207,6 +205,24 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
log.info("修改飞行状态:{}",JSONObject.toJSONString(thMissionUpdate));
return thMissionMapper.updateById(thMissionUpdate) > 0;
}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分析
return stopAI(missionStatusRequest);
}else{
@@ -258,19 +274,9 @@ public class MissionServiceImpl extends BaseServiceImpl<ThMissionMapper, ThMissi
ThMission thMission = getRecentlyRecord(missionStatusRequest,TaskStatusEnum.FLIGHT.getCode());
Assert.notNull(thMission, "飞行任务不能为空!");
ThMission thMissionUpdate = new ThMission(UpdateOrCreateEnum.UPDATE.getCode());

thMissionUpdate.setId(thMission.getId());
thMissionUpdate.setMileage(missionStatusRequest.getMileage());
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接口
JSONObject jsonObject = new JSONObject();

+ 5
- 6
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/QuestionServiceImpl.java View File

@@ -303,12 +303,12 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
if (aBoolean) {
setComplate(callbackRequest, mission, thMissionUpdate);
} else {
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FAIL, mission);
// setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FAIL, mission);
}
return JsonResult.success();
}

private void setTaskStatusEnum(ThMission thMissionUpdate, TaskStatusEnum statusEnum, ThMission mission) {
private void setTaskStatusEnum2(ThMission thMissionUpdate, TaskStatusEnum statusEnum, ThMission mission) {
thMissionUpdate.setStatus(statusEnum.getCode());
thMissionUpdate.setId(mission.getId());
thMissionUpdate.setExecutionEndTime(new Date());
@@ -326,13 +326,12 @@ public class QuestionServiceImpl extends BaseServiceImpl<QuestionMapper, Questio
} else {
thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.SUCCESS.getCode());
}

setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.COMPLETE, mission);
// setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.COMPLETE, mission);
} else if (callbackRequest.getAnalyseStatus() == AiAnalyseStatusEnum.FAILED.getCode()) {
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FAIL, mission);
// setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FAIL, mission);
} else {
thMissionUpdate.setAnalyseStatus(AiAnalyseStatusEnum.RUNNING.getCode());
setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FLIGHT, mission);
// setTaskStatusEnum(thMissionUpdate, TaskStatusEnum.FLIGHT, mission);
}

}

+ 11
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java View File

@@ -222,22 +222,33 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper,

@Override
public AirWeatherVO getWeather(Integer airportId) throws ServiceException {
log.info("获取天气信息信息");
Tenant tenant = tenantMapper.selectById(ShiroUtils.getTenantId());
//这边需要配置到yml文件里面
String url = tenant.getAirportUrl() + "/api/airportInterface/getWeather";
String param = "airportId=" + airportId;
log.info("获取天气信息信息,调用机场接口");
log.info("获取天气信息信息,url={}", url);
log.info("获取天气信息信息,param={}", param);
String weatherStr = HttpUtils.sendGet(url, param);
log.info("获取天气信息信息,调用机场接口结束,weatherStr={}", weatherStr);
JsonResult jsonResult;
try {
jsonResult = JacksonUtil.json2pojo(weatherStr, JsonResult.class);
if (ObjectUtil.isEmpty(jsonResult) || Objects.requireNonNull(jsonResult).getCode() != 0) {
log.info("获取天气信息失败,返回为空或code不为0");
log.info("获取天气信息失败,url={}", url);
log.info("获取天气信息失败,param={}", param);
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取天气信息失败,请重试");
}
if (ObjectUtil.isEmpty(jsonResult.getData())) {
log.info("获取天气信息,返回数据为空");
return new AirWeatherVO();
}
return JSONObject.parseObject(JSONObject.toJSONString(jsonResult.getData()), AirWeatherVO.class);
} catch (Exception e) {
log.info("获取天气信息异常,url={}", url);
log.info("获取天气信息异常,param={}", param);
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "获取天气信息失败,请重试");
}
}

+ 4
- 4
tuoheng-admin/src/main/java/com/tuoheng/admin/utils/WeatherUtil.java View File

@@ -11,9 +11,9 @@ public class WeatherUtil {
if(ObjectUtil.isEmpty(airWeather) ||ObjectUtil.isEmpty(airWeather.getWth())){
return "";
}
return "气温:" + new BigDecimal(airWeather.getWth().getParm().getTmp()).divide(new BigDecimal(10))+"℃"
+ ";湿度:" + new BigDecimal(airWeather.getWth().getParm().getHum()).divide(new BigDecimal(10))+"RH"
+ ";风速:" + new BigDecimal(airWeather.getWth().getParm().getWspd()).divide(new BigDecimal(10))+"M/S"
+ ";风向:" + airWeather.getWth().getParm().getWdir() + "°";
return "气温:" + airWeather.getWth().getParmNew().getTmp() + "℃"
+ ";湿度:" + airWeather.getWth().getParmNew().getHum() + "RH"
+ ";风速:" + airWeather.getWth().getParmNew().getWspd() + "M/S"
+ ";风向:" + airWeather.getWth().getParmNew().getWdirname();
}
}

Loading…
Cancel
Save