同步代码

This commit is contained in:
mi9688 2024-11-28 18:12:00 +08:00
parent 01fd0b4ca5
commit 9327c600f7
4 changed files with 12 additions and 4 deletions

View File

@ -8,6 +8,9 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 气象设备实时数据
*/
@RestController()
@RequestMapping("/meteorology")
public class DeviceRealtimedataMeteorologyController {
@ -23,4 +26,5 @@ public class DeviceRealtimedataMeteorologyController {
public AjaxResult getLatestWeatherRealtimedata() {
return AjaxResult.success(deviceRealtimedataMeteorologyService.getLatestWeatherRealtimedata());
}
}

View File

@ -32,6 +32,9 @@ public class DeviceRealtimedataMoistureController {
return AjaxResult.success(deviceRealtimedataMoistureService.getLatestWeatherRealtimedata(deviceId));
}
/**
* 获取墒情设备列表
*/
@GetMapping("/weather/pullDown")
public AjaxResult getLatestWeatherPullDown() {
return AjaxResult.success(deviceInformationMoistureService.selectDeviceInformationMoistureList(null));

View File

@ -17,7 +17,7 @@ public class DeviceRealtimedataWormsController extends BaseController {
* 虫情实时数据
*/
@Autowired
private DeviceRealtimedataWormsServiceImpl deviceRealtimedataWormsServiceImpl;
private DeviceRealtimedataWormsServiceImpl deviceRealtimedataWormsServiceImpl;

View File

@ -44,6 +44,7 @@ public class RenkeDeviceDataService {
JSONObject respBody = JSONUtil.parseObj(respBodyStr);
// System.err.println(respBodyStr);
if(!respBody.get("code") .toString().equals("1000")){
System.err.println(respBodyStr);
throw new ServiceException("获取设备实时数据失败!");
}
JSONArray realtimeDataList = JSONUtil.parseArray(respBody.get("data"));
@ -89,7 +90,7 @@ public class RenkeDeviceDataService {
//获取害虫种类以及数量
JSONArray analyseData = JSONUtil.parseArray(entries.get("analyseData"));
//有害虫时保存
if(!analyseData.isEmpty()){
// if(!analyseData.isEmpty()){
//获取拍照图片
Object imagesUrl = entries .get("imagesUrl");
//获取虫情分析后的图片地址
@ -97,7 +98,7 @@ public class RenkeDeviceDataService {
deviceRealtimedataWorms.setPestPhotos(analyseCoordUrl.toString());
deviceRealtimedataWorms.setCamera(imagesUrl.toString());
}
// }
deviceRealtimedataWorms.setSaveTime(DateUtils.getNowDate());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -116,7 +117,7 @@ public class RenkeDeviceDataService {
// RenkeDeviceDataService renkeDeviceDataService = new RenkeDeviceDataService();
// renkeDeviceDataService.setData("1017240042");
HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/worm/deviceData/getWormDataAndWormDataAIBy?deviceAddr="+"1017240042")
.header("token", "834991732092248683")
.header("token", "300591732787388355")
.execute();
String respBodyStr1 = response1.body();