Przeglądaj źródła

修改获取添加接口参数

tags/v1.2.0^2
wanjing 1 rok temu
rodzic
commit
7c1373e55d
3 zmienionych plików z 26 dodań i 4 usunięć
  1. +16
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/AirWeatherVO.java
  2. +6
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java
  3. +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 Wyświetl plik

@@ -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

+ 6
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/ThInspectionServiceImpl.java Wyświetl plik

@@ -231,13 +231,19 @@ public class ThInspectionServiceImpl extends BaseServiceImpl<ThInspectionMapper,
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 Wyświetl plik

@@ -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();
}
}

Ładowanie…
Anuluj
Zapisz