feat: 增加微气象监测数据同步接口
parent
86305a8d5e
commit
82712ffbac
@ -0,0 +1,108 @@
|
|||||||
|
package com.shxy.xymanager_admin.controller;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.shxy.xymanager_common.base.BaseController;
|
||||||
|
import com.shxy.xymanager_common.util.StringUtils;
|
||||||
|
import com.shxy.xymanager_common.zhiping.OutModel;
|
||||||
|
import com.shxy.xymanager_common.zhiping.ZhipingReult;
|
||||||
|
import com.shxy.xymanager_common.entity.LeadPulls;
|
||||||
|
import com.shxy.xymanager_common.entity.Weathers;
|
||||||
|
import com.shxy.xymanager_common.util.DateUtil;
|
||||||
|
import com.shxy.xymanager_service.service.LeadPullsService;
|
||||||
|
import com.shxy.xymanager_service.service.WeatherService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Api(tags = {"微气象监测数据同步接口"})
|
||||||
|
@RequestMapping("zhiping")
|
||||||
|
@Slf4j
|
||||||
|
public class ZhipingController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
LeadPullsService leadPullsService;
|
||||||
|
@Resource
|
||||||
|
WeatherService weatherService;
|
||||||
|
|
||||||
|
@GetMapping("query")
|
||||||
|
@ApiOperation("查询")
|
||||||
|
public ZhipingReult<List<OutModel>> query(String actiontype, String timestamp,
|
||||||
|
String beginTime, String endTime) throws Exception {
|
||||||
|
ZhipingReult result = new ZhipingReult();
|
||||||
|
result.setCode("0");
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(beginTime)) {
|
||||||
|
result.setCode("400");
|
||||||
|
result.setMsg("beginTime不能为空");
|
||||||
|
} else if (StringUtils.isBlank(endTime)) {
|
||||||
|
result.setCode("400");
|
||||||
|
result.setMsg("endTime不能为空");
|
||||||
|
} else if (StringUtils.isBlank(timestamp)) {
|
||||||
|
result.setCode("400");
|
||||||
|
result.setMsg("timestamp不能为空");
|
||||||
|
} else if (!timestamp.contains("9186B579774441C58FB0867FF05C8CE2")) {
|
||||||
|
result.setCode("400");
|
||||||
|
result.setMsg("私钥不正确");
|
||||||
|
} else {
|
||||||
|
Date start = DateUtil.parse(beginTime);
|
||||||
|
Date end = DateUtil.parse(endTime);
|
||||||
|
if ("meteo".equals(actiontype)) {
|
||||||
|
PageInfo<Weathers> page = weatherService.list(null, null, null,
|
||||||
|
start.getTime() / 1000, end.getTime() / 1000, 1, 10000);
|
||||||
|
if (!CollectionUtils.isEmpty(page.getList())) {
|
||||||
|
List<OutModel> list = new ArrayList<>();
|
||||||
|
for (Weathers weather : page.getList()) {
|
||||||
|
OutModel item = new OutModel();
|
||||||
|
item.setCmonitorCode(weather.getCmdid());
|
||||||
|
item.setCupdateTime(DateUtil.format(weather.getUpdateDate()));
|
||||||
|
item.setCtemperature(String.valueOf(weather.getAirTemperature()));
|
||||||
|
item.setChumidity(String.valueOf(weather.getHumidity()));
|
||||||
|
item.setCwindSpeed(String.valueOf(weather.getStandardWindSpeed()));
|
||||||
|
item.setCwindDirection(String.valueOf(weather.getAvgWindDir10min()));
|
||||||
|
item.setCsunshine(String.valueOf(weather.getRadiationIntensity()));
|
||||||
|
item.setCrainAmount(String.valueOf(weather.getPrecipitation()));
|
||||||
|
list.add(item);
|
||||||
|
}
|
||||||
|
result.setDataCount(String.valueOf(list.size()));
|
||||||
|
result.setDataList(list);
|
||||||
|
}
|
||||||
|
} else if ("ice_weight".equals(actiontype)) {
|
||||||
|
PageInfo<LeadPulls> page = leadPullsService.list(null, null, null,
|
||||||
|
start.getTime() / 1000, end.getTime() / 1000, 1, 10000);
|
||||||
|
if (!CollectionUtils.isEmpty(page.getList())) {
|
||||||
|
List<OutModel> list = new ArrayList<>();
|
||||||
|
for (LeadPulls pull : page.getList()) {
|
||||||
|
OutModel item = new OutModel();
|
||||||
|
item.setCmonitorCode(pull.getCmdid());
|
||||||
|
item.setCupdateTime(DateUtil.format(pull.getUpdateDate()));
|
||||||
|
item.setCwindAngle(String.valueOf(pull.getWindSpeed()));
|
||||||
|
item.setCice(String.valueOf(0));
|
||||||
|
Integer x = (pull.getMaxpullPull() + pull.getMinpullPull()) / 2;
|
||||||
|
item.setCpull(String.valueOf(pull.getMaxpullPull()));
|
||||||
|
item.setCpullAngle(String.valueOf(x));
|
||||||
|
list.add(item);
|
||||||
|
}
|
||||||
|
result.setDataCount(String.valueOf(list.size()));
|
||||||
|
result.setDataList(list);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.setCode("400");
|
||||||
|
result.setMsg("actiontype不正确");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.setRTime(DateUtil.format(new Date()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.shxy.xymanager_common.zhiping;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@Data
|
||||||
|
public class OutModel {
|
||||||
|
private String cmonitorCode;
|
||||||
|
private String cupdateTime;
|
||||||
|
private String ctemperature;
|
||||||
|
private String chumidity;
|
||||||
|
private String cwindSpeed;
|
||||||
|
private String cwindDirection;
|
||||||
|
private String csunshine;
|
||||||
|
private String crainAmount;
|
||||||
|
private String cwindAngle;
|
||||||
|
private String cice;
|
||||||
|
private String cpull;
|
||||||
|
private String cpullAngle;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.shxy.xymanager_common.zhiping;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ZhipingReult<T> implements Serializable {
|
||||||
|
|
||||||
|
private T dataList;
|
||||||
|
private String code;
|
||||||
|
private String msg;
|
||||||
|
private String dataCount;
|
||||||
|
private String rTime;
|
||||||
|
}
|
Loading…
Reference in New Issue