虫情设备图片数据获取修改

This commit is contained in:
mi9688
2024-11-20 17:34:35 +08:00
parent bfafd4bb80
commit 393c942da2
34 changed files with 489 additions and 235 deletions

View File

@ -0,0 +1,105 @@
package com.fastbee.data.controller.aaScreenAgricultural;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.deviceData.api.devlink.service.DevLinkBaseService;
import com.fastbee.deviceInfo.manager.DeviceInformationManager;
import com.fastbee.iot.domain.AlertLog;
import com.fastbee.iot.mapper.AlertLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* 设备告警
*/
@RestController
@RequestMapping("/device/statistics")
public class DeviceAlarmController extends BaseController {
@Autowired
private DevLinkBaseService devLinkBaseService;
@Autowired
private AlertLogMapper alertLogMapper;
@Autowired
private DeviceInformationManager deviceInformationManager;
/**
* 获取设备告警数量
*/
@GetMapping("/alarm/count")
public AjaxResult getDeviceAlarmCount() {
// HashMap<String, Object> body = new HashMap<>();
// body.put("method","get");
// body.put("path","api/v1/product/device/statistics/months");
// JSONObject data = devLinkBaseService.baseRequest(body);
// alertLogMapper
// return AjaxResult.success(data);
Long count = new LambdaQueryChainWrapper<>(alertLogMapper)
.select(AlertLog::getAlertLogId)
.eq(false,AlertLog::getUserId,"")
.count();
Map<String,Object> resp =new HashMap<>();
resp.put("alarmTotal",count);
resp.put("securityLevel",getSecurityLevel(count));
return AjaxResult.success(resp);
}
/**
* 统计不同设备数量
*/
@GetMapping("/countByType")
public AjaxResult getDeviceCountByType() {
return AjaxResult.success(deviceInformationManager.getAllDeviceCount());
}
/**
* 统计设备在线率
*/
@GetMapping("/onlineRate")
public AjaxResult getDeviceOnlineRate() {
HashMap<String, Object> body = new HashMap<>();
body.put("method","get");
body.put("path","api/v1/product/device/list");
JSONObject data = devLinkBaseService.baseRequest(body);
//仁科设备
return AjaxResult.success();
}
/**
* 研判等级评级策略方法
* A级3个以下报警B级3-10个报警C级10个以上报警
*/
private String getSecurityLevel(Long alarmTotal) {
if (alarmTotal <3) {
return "A级";
} else if (alarmTotal <= 10) {
return "B级";
} else {
return "C级";
}
}
}

View File

@ -1,4 +1,4 @@
package com.fastbee.data.controller.deviceData;
package com.fastbee.data.controller.aaScreenAgricultural;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMeteorologyServiceImpl;

View File

@ -1,4 +1,4 @@
package com.fastbee.data.controller.deviceData;
package com.fastbee.data.controller.aaScreenAgricultural;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMoistureServiceImpl;

View File

@ -0,0 +1,61 @@
package com.fastbee.data.controller.aaScreenAgricultural;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.deviceData.api.yingshiyun.service.YingshiyunService;
import com.fastbee.deviceInfo.domain.DeviceInformationMonitor;
import com.fastbee.deviceInfo.mapper.DeviceInformationMonitorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/seedlingGrowth")
public class DeviceRealtimedataSeedlingGrowthController {
@Autowired
private DeviceInformationMonitorMapper monitorMapper ;
@Autowired
private YingshiyunService yingshiyunService;
/**
* 获取苗情监测监控设备列表
*/
@GetMapping("/monitorDeviceList")
public AjaxResult getMonitorDeviceList() {
List<DeviceInformationMonitor> list = new LambdaQueryChainWrapper<>(monitorMapper)
.select(DeviceInformationMonitor::getId,
DeviceInformationMonitor::getName,
DeviceInformationMonitor::getDeviceEncoding,
DeviceInformationMonitor::getLatitude,
DeviceInformationMonitor::getLongitude)
.list();
//获取监控播放地址
list.forEach(this::setPlayUrl);
return AjaxResult.success(list);
}
/**
* 获取监控播放地址
* @param monitor
*/
public void setPlayUrl(DeviceInformationMonitor monitor) {
Map<String, Object> videoPlayMap = yingshiyunService.getVideoPlayUrl(monitor.getDeviceEncoding());
if (videoPlayMap.containsKey("playUrl")) {
Object playUrl = videoPlayMap.get("playUrl");
monitor.setPlayUrl(playUrl.toString());
}
if( videoPlayMap.containsKey("accessToken")){
Object accessToken = videoPlayMap.get("accessToken");
monitor.setAccessToken(accessToken.toString());
}
}
}

View File

@ -1,115 +0,0 @@
package com.fastbee.data.controller.deviceData;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.dtflys.forest.annotation.Get;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.deviceData.api.devlink.service.DevLinkAuthorizationService;
import com.fastbee.deviceData.api.devlink.service.DevLinkBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* 设备告警
*/
@RestController
@RequestMapping("/device/statistics")
public class DeviceAlarmController extends BaseController {
@Autowired
private DevLinkBaseService devLinkBaseService;
/**
* 获取设备告警数量
*/
@GetMapping("/alarm/count")
public AjaxResult getDeviceAlarmCount() {
HashMap<String, Object> body = new HashMap<>();
body.put("method","get");
body.put("path","api/v1/product/device/statistics/months");
JSONObject data = devLinkBaseService.baseRequest(body);
return AjaxResult.success(data);
}
/**
* 获取设备相关统计
*/
@GetMapping("/count")
public AjaxResult getDeviceStatusCount() {
HashMap<String, Object> body = new HashMap<>();
body.put("method","get");
body.put("path","api/v1/product/device/statistics");
JSONObject data = devLinkBaseService.baseRequest(body);
//计算安全状态等级
String securityLevel="?";
JSONObject total = JSONUtil.parseObj(data.get("deviceTotal"));
int alarmTotal = Integer.parseInt(total.get("alarmTotal").toString());
if(alarmTotal < 2){
securityLevel= "A";
}
else if(alarmTotal<4){
securityLevel = "B";
}else if(alarmTotal<6){
securityLevel = "C";
}else if(alarmTotal<8){
securityLevel = "D";
}
total.put("securityLevel",securityLevel);
return AjaxResult.success(total);
}
/**
* 统计不同设备数量
*/
@GetMapping("/countByType")
public AjaxResult getDeviceCountByType() {
HashMap<String, Object> body = new HashMap<>();
body.put("method","get");
body.put("path","api/v1/product/device/list");
JSONObject data = devLinkBaseService.baseRequest(body);
//设备列表
JSONArray devArray = JSONUtil.parseArray(data);
//分组统计
Map<String, Integer> map = new HashMap<>();
for (int i = 0; i < devArray.size(); i++) {
JSONObject dev = devArray.getJSONObject(i);
String type = dev.get("type").toString();
if(map.containsKey(type)){
map.put(type,map.get(type)+1);
}else
map.put(type,1);
}
return AjaxResult.success();
}
/**
* 统计设备在线率
*/
@GetMapping("/onlineRate")
public AjaxResult getDeviceOnlineRate() {
HashMap<String, Object> body = new HashMap<>();
body.put("method","get");
body.put("path","api/v1/product/device/list");
JSONObject data = devLinkBaseService.baseRequest(body);
//设备列表
JSONArray devArray = JSONUtil.parseArray(data);
//分组统计
return AjaxResult.success();
}
}

View File

@ -1,4 +1,4 @@
package com.fastbee.data.controller.gis;
package com.fastbee.data.controller.gis.water;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;

View File

@ -1,4 +1,4 @@
package com.fastbee.data.controller.gis;
package com.fastbee.data.controller.gis.water;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -1,4 +1,4 @@
package com.fastbee.data.controller.gis;
package com.fastbee.data.controller.gis.water;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

View File

@ -1,4 +1,4 @@
package com.fastbee.data.controller.gis;
package com.fastbee.data.controller.gis.water;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

View File

@ -1,4 +1,4 @@
package com.fastbee.data.controller.gis;
package com.fastbee.data.controller.gis.water;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

View File

@ -1,4 +1,4 @@
package com.fastbee.data.controller.gis;
package com.fastbee.data.controller.gis.water;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

View File

@ -1,4 +1,4 @@
package com.fastbee.data.controller.gis;
package com.fastbee.data.controller.gis.water;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

View File

@ -1,4 +1,4 @@
package com.fastbee.data.controller.gis;
package com.fastbee.data.controller.gis.water;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

View File

@ -1,4 +1,4 @@
package com.fastbee.data.controller.gis;
package com.fastbee.data.controller.gis.water;
import java.util.List;

View File

@ -22,6 +22,12 @@ public class WeatherController {
return AjaxResult.success(TianqiApi.QitianApi());
}
/**
* 获取实时天气
*/
@GetMapping("/shishi")
public AjaxResult getWeatherShiShi() {
return AjaxResult.success(TianqiApi.weatherNow());
}
}