虫情设备图片数据获取修改
This commit is contained in:
@ -57,6 +57,7 @@ spring:
|
|||||||
multi-statement-allow: true
|
multi-statement-allow: true
|
||||||
# redis 配置
|
# redis 配置
|
||||||
redis:
|
redis:
|
||||||
|
|
||||||
host: localhost # 地址
|
host: localhost # 地址
|
||||||
port: 6379 # 端口,默认为6379
|
port: 6379 # 端口,默认为6379
|
||||||
database: 1 # 数据库索引
|
database: 1 # 数据库索引
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.fastbee.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目类型常量
|
||||||
|
*/
|
||||||
|
public class ProjectTypeConstant {
|
||||||
|
|
||||||
|
public static final Long WATER = 1L;//水利
|
||||||
|
public static final Long AGRICULTURE = 2L;//农业
|
||||||
|
|
||||||
|
public static boolean isValidProjectType(Long projectType) {
|
||||||
|
return projectType.equals(WATER) || projectType.equals(AGRICULTURE);
|
||||||
|
}
|
||||||
|
}
|
@ -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级";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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.common.core.domain.AjaxResult;
|
||||||
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMeteorologyServiceImpl;
|
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMeteorologyServiceImpl;
|
@ -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.common.core.domain.AjaxResult;
|
||||||
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMoistureServiceImpl;
|
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMoistureServiceImpl;
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -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.controller.BaseController;
|
||||||
import com.fastbee.common.core.domain.AjaxResult;
|
import com.fastbee.common.core.domain.AjaxResult;
|
@ -1,4 +1,4 @@
|
|||||||
package com.fastbee.data.controller.gis;
|
package com.fastbee.data.controller.gis.water;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
@ -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.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
@ -1,4 +1,4 @@
|
|||||||
package com.fastbee.data.controller.gis;
|
package com.fastbee.data.controller.gis.water;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
@ -1,4 +1,4 @@
|
|||||||
package com.fastbee.data.controller.gis;
|
package com.fastbee.data.controller.gis.water;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
@ -1,4 +1,4 @@
|
|||||||
package com.fastbee.data.controller.gis;
|
package com.fastbee.data.controller.gis.water;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
@ -1,4 +1,4 @@
|
|||||||
package com.fastbee.data.controller.gis;
|
package com.fastbee.data.controller.gis.water;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
@ -1,4 +1,4 @@
|
|||||||
package com.fastbee.data.controller.gis;
|
package com.fastbee.data.controller.gis.water;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
@ -1,4 +1,4 @@
|
|||||||
package com.fastbee.data.controller.gis;
|
package com.fastbee.data.controller.gis.water;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -22,6 +22,12 @@ public class WeatherController {
|
|||||||
return AjaxResult.success(TianqiApi.QitianApi());
|
return AjaxResult.success(TianqiApi.QitianApi());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取实时天气
|
||||||
|
*/
|
||||||
|
@GetMapping("/shishi")
|
||||||
|
public AjaxResult getWeatherShiShi() {
|
||||||
|
return AjaxResult.success(TianqiApi.weatherNow());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ public class DevLinkBaseService {
|
|||||||
//TODO 属性值历史数据,是否需要
|
//TODO 属性值历史数据,是否需要
|
||||||
Object list = JSONUtil.parseObj(p).get("list");
|
Object list = JSONUtil.parseObj(p).get("list");
|
||||||
// System.err.print("name:"+name);
|
// System.err.print("name:"+name);
|
||||||
System.err.print("key:"+key);
|
// System.err.print("key:"+key);
|
||||||
System.err.println("------------value:"+value);
|
// System.err.println("------------value:"+value);
|
||||||
//建立属性-值映射关系
|
//建立属性-值映射关系
|
||||||
propertiesMap.put(key,value);
|
propertiesMap.put(key,value);
|
||||||
// saveRealData(key,value,realData);
|
// saveRealData(key,value,realData);
|
||||||
|
@ -54,7 +54,7 @@ public class DevLinkMetDataService extends DevLinkBaseService {
|
|||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new ServiceException("时间格式转换失败!");
|
throw new ServiceException("时间格式转换失败!");
|
||||||
}
|
}
|
||||||
System.err.println(build);
|
System.err.println("气象设备实时数据:"+build);
|
||||||
return build;
|
return build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class DevLinkMiaoQingDataService extends DevLinkBaseService {
|
|||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new ServiceException("时间格式转换失败!");
|
throw new ServiceException("时间格式转换失败!");
|
||||||
}
|
}
|
||||||
System.err.println(miaoqing);
|
System.err.println("苗情设备光伏板实时数据:"+miaoqing);
|
||||||
return miaoqing;
|
return miaoqing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class DevLinkMoistureDataService extends DevLinkBaseService {
|
|||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new ServiceException("时间格式转换失败!");
|
throw new ServiceException("时间格式转换失败!");
|
||||||
}
|
}
|
||||||
System.err.println(build);
|
System.err.println("墒情设备实时数据:"+build);
|
||||||
return build;
|
return build;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class DevLinkPhotovoltaicDataService extends DevLinkBaseService {
|
|||||||
throw new ServiceException("时间格式转换失败!");
|
throw new ServiceException("时间格式转换失败!");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.err.println(photovoltaic);
|
System.err.println("光伏设备实时数据:"+photovoltaic);
|
||||||
return photovoltaic;
|
return photovoltaic;
|
||||||
}
|
}
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -29,7 +29,7 @@ public class RenKeAuthorizationService {
|
|||||||
//判断token是否过期
|
//判断token是否过期
|
||||||
String cacheToken = stringRedisTemplate.opsForValue().get("renke:user:token");
|
String cacheToken = stringRedisTemplate.opsForValue().get("renke:user:token");
|
||||||
if (!Objects.isNull(cacheToken)){
|
if (!Objects.isNull(cacheToken)){
|
||||||
System.err.println("缓存中获取token:"+cacheToken);
|
// System.err.println("缓存中获取token:"+cacheToken);
|
||||||
return cacheToken;
|
return cacheToken;
|
||||||
}
|
}
|
||||||
//获取token
|
//获取token
|
||||||
|
@ -40,10 +40,12 @@ public class RenkeDeviceDataService {
|
|||||||
.form("deviceAddrs", deviceAddrs)
|
.form("deviceAddrs", deviceAddrs)
|
||||||
.execute();
|
.execute();
|
||||||
String respBodyStr = response.body();
|
String respBodyStr = response.body();
|
||||||
if(StringUtils.isBlank(respBodyStr)) {
|
|
||||||
throw new RuntimeException("获取设备实时数据失败!");
|
|
||||||
}
|
|
||||||
JSONObject respBody = JSONUtil.parseObj(respBodyStr);
|
JSONObject respBody = JSONUtil.parseObj(respBodyStr);
|
||||||
|
// System.err.println(respBodyStr);
|
||||||
|
if(!respBody.get("code") .toString().equals("1000")){
|
||||||
|
throw new ServiceException("获取设备实时数据失败!");
|
||||||
|
}
|
||||||
JSONArray realtimeDataList = JSONUtil.parseArray(respBody.get("data"));
|
JSONArray realtimeDataList = JSONUtil.parseArray(respBody.get("data"));
|
||||||
JSONObject jsonObject = JSONUtil.parseObj(realtimeDataList.get(0));
|
JSONObject jsonObject = JSONUtil.parseObj(realtimeDataList.get(0));
|
||||||
JSONObject jsonObject1 = JSONUtil.parseObj(jsonObject.get("data"));
|
JSONObject jsonObject1 = JSONUtil.parseObj(jsonObject.get("data"));
|
||||||
@ -52,27 +54,42 @@ public class RenkeDeviceDataService {
|
|||||||
//反序列化封装基础数据
|
//反序列化封装基础数据
|
||||||
deviceRealtimedataWorms = JSONUtil.toBean(jsonObject1, DeviceRealtimedataWorms.class);
|
deviceRealtimedataWorms = JSONUtil.toBean(jsonObject1, DeviceRealtimedataWorms.class);
|
||||||
//获取虫情设备关键数据
|
//获取虫情设备关键数据
|
||||||
HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/worm/deviceData/getWormDataList")
|
HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/worm/deviceData/getWormDataAndWormDataAIBy?deviceAddr="+deviceAddrs)
|
||||||
.header("token", token)
|
.header("token", token)
|
||||||
.form("deviceAddrs", deviceAddrs)
|
// .form( "deviceAddr", deviceAddrs)
|
||||||
//开始时间是5分钟前
|
// //开始时间是5分钟前
|
||||||
.form("beginTime", DateTimeCalculationUtils.format(DateTimeCalculationUtils.minus(5, ChronoUnit.MINUTES)))
|
// .form("beginTime", DateTimeCalculationUtils.format(DateTimeCalculationUtils.minus(5, ChronoUnit.MINUTES)))
|
||||||
.form("endTime", DateUtils.getNowDate())
|
// .form("endTime", DateUtils.getNowDate())
|
||||||
.form("pages", 1)
|
// .form("pages", 1)
|
||||||
.form("limit", 10)
|
// .form("limit", 10)
|
||||||
.execute();
|
.execute();
|
||||||
String respBodyStr1 = response.body();
|
|
||||||
if(StringUtils.isBlank(respBodyStr1)) {
|
// HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/worm/deviceData/getWormDataList")
|
||||||
|
// .header("token", token)
|
||||||
|
// .form( "deviceAddr", deviceAddrs)
|
||||||
|
// //开始时间是5分钟前
|
||||||
|
// .form("beginTime", DateTimeCalculationUtils.format(DateTimeCalculationUtils.minus(5, ChronoUnit.MINUTES)))
|
||||||
|
// .form("endTime", DateUtils.getNowDate())
|
||||||
|
// .form("pages", 1)
|
||||||
|
// .form("limit", 10)
|
||||||
|
// .execute();
|
||||||
|
|
||||||
|
|
||||||
|
String respBodyStr1 = response1.body();
|
||||||
|
|
||||||
|
JSONObject respBody1 = JSONUtil.parseObj(respBodyStr1);
|
||||||
|
// System.err.println(respBodyStr1);
|
||||||
|
if(!respBody1.get("code") .toString().equals("1000")) {
|
||||||
throw new RuntimeException("获取设备实时数据失败!");
|
throw new RuntimeException("获取设备实时数据失败!");
|
||||||
}
|
}
|
||||||
JSONObject jsonObject2 = JSONUtil.parseObj(respBodyStr1);
|
System.err.println(respBody1);
|
||||||
JSONObject jsonObject3 = JSONUtil.parseObj(jsonObject2.get("data"));
|
JSONArray jsonArray = JSONUtil.parseArray(respBody1.get("data"));
|
||||||
JSONArray jsonArray = JSONUtil.parseArray(jsonObject3.get("rows"));
|
JSONObject entries = JSONUtil.parseObj(jsonArray.get(0));
|
||||||
JSONObject jsonObject4 = JSONUtil.parseObj(jsonArray.get(0));
|
|
||||||
//获取拍照图片
|
//获取拍照图片
|
||||||
Object imagesUrl = jsonObject4.get("imagesUrl");
|
Object imagesUrl = entries .get("imagesUrl");
|
||||||
//获取虫情分析后的图片地址
|
//获取虫情分析后的图片地址
|
||||||
Object analyseCoordUrl = jsonObject4.get("analyseCoordUrl");
|
Object analyseCoordUrl = entries .get("analyseCoordUrl");
|
||||||
|
|
||||||
deviceRealtimedataWorms.setPestPhotos(analyseCoordUrl.toString());
|
deviceRealtimedataWorms.setPestPhotos(analyseCoordUrl.toString());
|
||||||
deviceRealtimedataWorms.setCamera(imagesUrl.toString());
|
deviceRealtimedataWorms.setCamera(imagesUrl.toString());
|
||||||
@ -86,14 +103,21 @@ public class RenkeDeviceDataService {
|
|||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new ServiceException("时间格式转换失败!");
|
throw new ServiceException("时间格式转换失败!");
|
||||||
}
|
}
|
||||||
System.err.println("设备实时数据:"+deviceRealtimedataWorms);
|
System.err.println("虫情设备实时数据:"+deviceRealtimedataWorms);
|
||||||
return deviceRealtimedataWorms;
|
return deviceRealtimedataWorms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
RenkeDeviceDataService renkeDeviceDataService = new RenkeDeviceDataService();
|
// RenkeDeviceDataService renkeDeviceDataService = new RenkeDeviceDataService();
|
||||||
renkeDeviceDataService.setData("1017240042");
|
// renkeDeviceDataService.setData("1017240042");
|
||||||
|
HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/worm/deviceData/getWormDataAndWormDataAIBy?deviceAddr="+"1017240042")
|
||||||
|
.header("token", "834991732092248683")
|
||||||
|
.execute();
|
||||||
|
String respBodyStr1 = response1.body();
|
||||||
|
|
||||||
|
JSONObject respBody1 = JSONUtil.parseObj(respBodyStr1);
|
||||||
|
System.err.println(respBodyStr1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import cn.hutool.json.JSONObject;
|
|||||||
public class TianqiApi {
|
public class TianqiApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户所有设备信息
|
* 获取未来天气预测
|
||||||
*/
|
*/
|
||||||
public static JSONObject QitianApi() {
|
public static JSONObject QitianApi() {
|
||||||
|
|
||||||
@ -28,6 +28,22 @@ public class TianqiApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取天气实况
|
||||||
|
*/
|
||||||
|
public static JSONObject weatherNow() {
|
||||||
|
String url = UrlConstant.ShishiApi + "?key=" +
|
||||||
|
UrlConstant.PrivateKey +
|
||||||
|
"&location=YBMUBR41ZWVC&language=zh-Hans&unit=c";//指定URL
|
||||||
|
HttpResponse execute = HttpUtil.createGet(url).execute();
|
||||||
|
if (execute.getStatus() == HttpStatus.HTTP_OK) {
|
||||||
|
JSONObject jsonObject = new JSONObject(execute.body());
|
||||||
|
// System.out.println("jsonObject = " + jsonObject);
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,20 +72,6 @@ public class TianqiApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// String url="https://api.seniverse.com/v3/location/search.json?key="+UrlConstant.PrivateKey+"&q=绥滨";
|
TianqiApi.weatherNow();
|
||||||
// HttpResponse execute = HttpUtil.createGet(url).execute();
|
|
||||||
// if (execute.getStatus() == HttpStatus.HTTP_OK) {
|
|
||||||
// JSONObject jsonObject = new JSONObject(execute.body());
|
|
||||||
// System.out.println("jsonObject = " + jsonObject);
|
|
||||||
// }
|
|
||||||
String url = UrlConstant.QitianApi + "?key=" +
|
|
||||||
UrlConstant.PrivateKey +
|
|
||||||
"&location=YBMUBR41ZWVC&language=zh-Hans&unit=c";//指定URL
|
|
||||||
HttpResponse execute = HttpUtil.createGet(url).execute();
|
|
||||||
if (execute.getStatus() == HttpStatus.HTTP_OK) {
|
|
||||||
JSONObject jsonObject = new JSONObject(execute.body());
|
|
||||||
System.out.println("jsonObject = " + jsonObject);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -35,45 +36,65 @@ public class YingshiyunService {
|
|||||||
String body = StrUtil.format("appKey={}&appSecret={}", appKey, appSecret);
|
String body = StrUtil.format("appKey={}&appSecret={}", appKey, appSecret);
|
||||||
HttpResponse response = HttpRequest.post(AUTH_URL)
|
HttpResponse response = HttpRequest.post(AUTH_URL)
|
||||||
.body(body).execute();
|
.body(body).execute();
|
||||||
|
|
||||||
JSONObject jsonObject = JSONUtil.parseObj(response.body());
|
JSONObject jsonObject = JSONUtil.parseObj(response.body());
|
||||||
String accessToken = JSONUtil.parseObj(jsonObject.get("data")).get("accessToken").toString();
|
// System.err.println(jsonObject);
|
||||||
stringRedisTemplate.opsForValue().set("yingshiyun:user:accessToken",accessToken, 60*60*24*6);
|
if( !jsonObject.get("code").toString().equals("200")){
|
||||||
|
throw new RuntimeException("获取萤石云token失败!");
|
||||||
|
}
|
||||||
|
JSONObject data = JSONUtil.parseObj(jsonObject.get("data"));
|
||||||
|
String accessToken = data.get("accessToken").toString();
|
||||||
|
|
||||||
|
stringRedisTemplate.opsForValue().set("yingshiyun:user:accessToken",accessToken, 60*60*24*6, TimeUnit.MILLISECONDS);
|
||||||
return accessToken;
|
return accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取视频播放地址
|
//获取视频播放地址
|
||||||
public String getVideoPlayUrl(String deviceSerial){
|
public Map<String,Object> getVideoPlayUrl(String deviceSerial){
|
||||||
String accessToken = getAuth();
|
String accessToken = getAuth();
|
||||||
|
// System.err.println(accessToken);
|
||||||
String VIDEO_PLAY_URL = "https://open.ys7.com/api/lapp/v2/live/address/get";
|
String VIDEO_PLAY_URL = "https://open.ys7.com/api/lapp/v2/live/address/get";
|
||||||
String body = StrUtil.format("accessToken={}&deviceSerial={}",accessToken ,deviceSerial );
|
String body = StrUtil.format("accessToken={}&deviceSerial={}&protocol={}",accessToken ,deviceSerial,"2");
|
||||||
|
|
||||||
HttpResponse response = HttpRequest.post(VIDEO_PLAY_URL)
|
HttpResponse response = HttpRequest.post(VIDEO_PLAY_URL)
|
||||||
.form(body).execute();
|
.body(body).execute();
|
||||||
JSONObject jsonObject = JSONUtil.parseObj(response.body());
|
JSONObject jsonObject = JSONUtil.parseObj(response.body());
|
||||||
String videoPlayUrl = JSONUtil.parseObj(jsonObject.get("data")).get("url").toString();
|
Map<String,Object> map = new HashMap<>();
|
||||||
String expireTime = JSONUtil.parseObj(jsonObject.get("data")).get("expireTime").toString();
|
if(!jsonObject.get("code").toString().equals("200")){
|
||||||
Map<String, Object> resp= new HashMap<>();
|
return map;
|
||||||
resp.put("videoPlayUrl",videoPlayUrl);
|
}
|
||||||
resp.put("expireTime",expireTime);
|
// System.err.println(jsonObject);
|
||||||
resp.put("deviceSerial",deviceSerial);
|
JSONObject data = JSONUtil.parseObj(jsonObject.get("data"));
|
||||||
return videoPlayUrl;
|
// System.err.println(data);
|
||||||
|
String playUrl = data.get("url").toString();
|
||||||
|
|
||||||
|
|
||||||
|
map.put("playUrl",playUrl);
|
||||||
|
map.put("accessToken",accessToken);
|
||||||
|
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
YingshiyunService yingshiyunService = new YingshiyunService();
|
// 鉴权请求
|
||||||
yingshiyunService.getAuth();
|
String AUTH_URL = "https://open.ys7.com/api/lapp/token/get";
|
||||||
long timeStamp = 1731571309231L;
|
String appKey = "b21f910dc7044d668e7625a3c0392e62";
|
||||||
Date date = new Date(timeStamp);
|
String appSecret = "b4beff5f8f6694dd6993c8c5b618417b";
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
// 构建请求体参数
|
||||||
sdf.setTimeZone(java.util.TimeZone.getTimeZone("Asia/Shanghai"));
|
String body = StrUtil.format("appKey={}&appSecret={}", appKey, appSecret);
|
||||||
String formattedDate = sdf.format(date);
|
HttpResponse response = HttpRequest.post(AUTH_URL)
|
||||||
System.out.println(formattedDate);
|
.body(body).execute();
|
||||||
|
JSONObject jsonObject = JSONUtil.parseObj(response.body());
|
||||||
|
System.err.println(jsonObject);
|
||||||
|
if( !jsonObject.get("code").toString().equals("200")){
|
||||||
|
throw new RuntimeException("获取萤石云token失败!");
|
||||||
|
}
|
||||||
|
JSONObject data = JSONUtil.parseObj(jsonObject.get("data"));
|
||||||
|
String accessToken = data.get("accessToken").toString();
|
||||||
|
System.err.println(accessToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,96 +17,109 @@ import com.fastbee.common.core.domain.BaseEntity;
|
|||||||
* 监控站设备基础信息对象 iot_device_information_monitor
|
* 监控站设备基础信息对象 iot_device_information_monitor
|
||||||
*
|
*
|
||||||
* @author kerwincui
|
* @author kerwincui
|
||||||
* @date 2024-11-18
|
* @date 2024-11-20
|
||||||
*/
|
*/
|
||||||
@ApiModel(value = "DeviceInformationMonitor",description = "监控站设备基础信息 iot_device_information_monitor")
|
@ApiModel(value = "DeviceInformationMonitor",description = "监控站设备基础信息 iot_device_information_monitor")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("iot_device_information_monitor")
|
@TableName ("iot_device_information_monitor")
|
||||||
public class DeviceInformationMonitor extends BaseEntity
|
public class DeviceInformationMonitor extends BaseEntity
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 主键 */
|
/** 主键 */
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/** 名称 */
|
/** 名称 */
|
||||||
@Excel(name = "名称")
|
@Excel(name = "名称")
|
||||||
@ApiModelProperty("名称")
|
@ApiModelProperty("名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/** 设备编码 */
|
/** 设备编码 */
|
||||||
@Excel(name = "设备编码")
|
@Excel(name = "设备编码")
|
||||||
@ApiModelProperty("设备编码")
|
@ApiModelProperty("设备编码")
|
||||||
private String deviceEncoding;
|
private String deviceEncoding;
|
||||||
|
|
||||||
/** 类型 */
|
/** 类型 */
|
||||||
@Excel(name = "类型")
|
@Excel(name = "类型")
|
||||||
@ApiModelProperty("类型")
|
@ApiModelProperty("类型")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
/** 经度 */
|
/** 经度 */
|
||||||
@Excel(name = "经度")
|
@Excel(name = "经度")
|
||||||
@ApiModelProperty("经度")
|
@ApiModelProperty("经度")
|
||||||
private String longitude;
|
private String longitude;
|
||||||
|
|
||||||
/** 纬度 */
|
/** 纬度 */
|
||||||
@Excel(name = "纬度")
|
@Excel(name = "纬度")
|
||||||
@ApiModelProperty("纬度")
|
@ApiModelProperty("纬度")
|
||||||
private String latitude;
|
private String latitude;
|
||||||
|
|
||||||
/** 安装位置 */
|
/** 安装位置 */
|
||||||
@Excel(name = "安装位置")
|
@Excel(name = "安装位置")
|
||||||
@ApiModelProperty("安装位置")
|
@ApiModelProperty("安装位置")
|
||||||
private String installationLocation;
|
private String installationLocation;
|
||||||
|
|
||||||
/** 设备品牌 */
|
/** 设备品牌 */
|
||||||
@Excel(name = "设备品牌")
|
@Excel(name = "设备品牌")
|
||||||
@ApiModelProperty("设备品牌")
|
@ApiModelProperty("设备品牌")
|
||||||
private String deviceBrand;
|
private String deviceBrand;
|
||||||
|
|
||||||
/** 设备型号 */
|
/** 设备型号 */
|
||||||
@Excel(name = "设备型号")
|
@Excel(name = "设备型号")
|
||||||
@ApiModelProperty("设备型号")
|
@ApiModelProperty("设备型号")
|
||||||
private String deviceType;
|
private String deviceType;
|
||||||
|
|
||||||
/** 项目的名称 */
|
/** 项目的名称 */
|
||||||
@Excel(name = "项目的名称")
|
@Excel(name = "项目的名称")
|
||||||
@ApiModelProperty("项目的名称")
|
@ApiModelProperty("项目的名称")
|
||||||
private String nameProject;
|
private String nameProject;
|
||||||
|
|
||||||
/** 建设年度 */
|
/** 建设年度 */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@Excel(name = "建设年度", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "建设年度", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
@ApiModelProperty("建设年度")
|
@ApiModelProperty("建设年度")
|
||||||
private Date constructionYear;
|
private Date constructionYear;
|
||||||
|
|
||||||
/** 所属乡镇 */
|
/** 所属乡镇 */
|
||||||
@Excel(name = "所属乡镇")
|
@Excel(name = "所属乡镇")
|
||||||
@ApiModelProperty("所属乡镇")
|
@ApiModelProperty("所属乡镇")
|
||||||
private String affiliationTownship;
|
private String affiliationTownship;
|
||||||
|
|
||||||
/** 管理负责人 */
|
/** 管理负责人 */
|
||||||
@Excel(name = "管理负责人")
|
@Excel(name = "管理负责人")
|
||||||
@ApiModelProperty("管理负责人")
|
@ApiModelProperty("管理负责人")
|
||||||
private String managementLeader;
|
private String managementLeader;
|
||||||
|
|
||||||
/** 管理负责人电话 */
|
/** 管理负责人电话 */
|
||||||
@Excel(name = "管理负责人电话")
|
@Excel(name = "管理负责人电话")
|
||||||
@ApiModelProperty("管理负责人电话")
|
@ApiModelProperty("管理负责人电话")
|
||||||
private String managementLeaderTelephone;
|
private String managementLeaderTelephone;
|
||||||
|
|
||||||
/** 管理单位 */
|
/** 管理单位 */
|
||||||
@Excel(name = "管理单位")
|
@Excel(name = "管理单位")
|
||||||
@ApiModelProperty("管理单位")
|
@ApiModelProperty("管理单位")
|
||||||
private String managementUnit;
|
private String managementUnit;
|
||||||
|
|
||||||
/** 备注信息 */
|
/** 备注信息 */
|
||||||
@Excel(name = "备注信息")
|
@Excel(name = "备注信息")
|
||||||
@ApiModelProperty("备注信息")
|
@ApiModelProperty("备注信息")
|
||||||
private String remarksInformation;
|
private String remarksInformation;
|
||||||
|
|
||||||
/** 删除标志(0代表存在,2代表删除) */
|
/** 删除标志(0代表存在,2代表删除) */
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------业务字段---------------
|
||||||
|
|
||||||
|
|
||||||
|
/** 监控播放地址 */
|
||||||
|
@Excel(name = "监控播放地址")
|
||||||
|
@ApiModelProperty("监控播放地址")
|
||||||
|
private String playUrl;
|
||||||
|
|
||||||
|
/** accessToken */
|
||||||
|
@Excel(name = "accessToken")
|
||||||
|
@ApiModelProperty("accessToken")
|
||||||
|
private String accessToken;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
package com.fastbee.deviceInfo.manager;
|
||||||
|
|
||||||
|
import com.fastbee.deviceInfo.domain.*;
|
||||||
|
import com.fastbee.deviceInfo.mapper.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class DeviceInformationManager {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceInformationMeteorologyMapper meteorologyMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceInformationMiaoqingMapper miaoqingMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceInformationMoistureMapper moistureMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceInformationMonitorMapper monitorMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceInformationTargetpestsMapper targetpestsMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DeviceInformationWormsMapper wormsMapper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有设备
|
||||||
|
*/
|
||||||
|
public Map<String,Object> getAllDeviceCount() {
|
||||||
|
List<DeviceInformationMeteorology> meteorologieList = meteorologyMapper.selectDeviceInformationMeteorologyList(null);
|
||||||
|
List<DeviceInformationMiaoqing> miaoqingList = miaoqingMapper.selectDeviceInformationMiaoqingList(null);
|
||||||
|
List<DeviceInformationMoisture> moistureList= moistureMapper.selectDeviceInformationMoistureList(null);
|
||||||
|
List<DeviceInformationMonitor> monitorList = monitorMapper.selectDeviceInformationMonitorList(null);
|
||||||
|
List<DeviceInformationTargetpests> targetpestList= targetpestsMapper.selectDeviceInformationTargetpestsList(null);
|
||||||
|
List<DeviceInformationWorms> wormList = wormsMapper.selectDeviceInformationWormsList(null);
|
||||||
|
|
||||||
|
Map<String,Object> resp =new HashMap<>();
|
||||||
|
resp.put("meteorologieTotal",meteorologieList.size());
|
||||||
|
resp.put("miaoqingTotal",miaoqingList.size());
|
||||||
|
resp.put("moistureTotal",moistureList.size());
|
||||||
|
resp.put("monitorTotal",monitorList.size());
|
||||||
|
resp.put("targetpestTotal",targetpestList.size());
|
||||||
|
resp.put("wormTotal",wormList.size());
|
||||||
|
resp.put("photovoltaicTotal",miaoqingList.size());
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -26,10 +26,11 @@
|
|||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="playUrl" column="play_url" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectDeviceInformationMonitorVo">
|
<sql id="selectDeviceInformationMonitorVo">
|
||||||
select id, name, device_encoding, type, longitude, latitude, installation_location, device_brand, device_type, name_project, construction_year, affiliation_township, management_leader, management_leader_telephone, management_unit, remarks_information, del_flag, create_time, create_by, update_time, update_by from iot_device_information_monitor
|
select id, name, device_encoding, type, longitude, latitude, installation_location, device_brand, device_type, name_project, construction_year, affiliation_township, management_leader, management_leader_telephone, management_unit, remarks_information, del_flag, create_time, create_by, update_time, update_by, play_url from iot_device_information_monitor
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectDeviceInformationMonitorList" parameterType="DeviceInformationMonitor" resultMap="DeviceInformationMonitorResult">
|
<select id="selectDeviceInformationMonitorList" parameterType="DeviceInformationMonitor" resultMap="DeviceInformationMonitorResult">
|
||||||
@ -50,6 +51,7 @@
|
|||||||
<if test="managementLeaderTelephone != null and managementLeaderTelephone != ''"> and management_leader_telephone = #{managementLeaderTelephone}</if>
|
<if test="managementLeaderTelephone != null and managementLeaderTelephone != ''"> and management_leader_telephone = #{managementLeaderTelephone}</if>
|
||||||
<if test="managementUnit != null and managementUnit != ''"> and management_unit = #{managementUnit}</if>
|
<if test="managementUnit != null and managementUnit != ''"> and management_unit = #{managementUnit}</if>
|
||||||
<if test="remarksInformation != null and remarksInformation != ''"> and remarks_information = #{remarksInformation}</if>
|
<if test="remarksInformation != null and remarksInformation != ''"> and remarks_information = #{remarksInformation}</if>
|
||||||
|
<if test="playUrl != null and playUrl != ''"> and play_url = #{playUrl}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -81,6 +83,7 @@
|
|||||||
<if test="createBy != null">create_by,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
<if test="updateTime != null">update_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
||||||
<if test="updateBy != null">update_by,</if>
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="playUrl != null">play_url,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="name != null">#{name},</if>
|
<if test="name != null">#{name},</if>
|
||||||
@ -103,6 +106,7 @@
|
|||||||
<if test="createBy != null">#{createBy},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
<if test="updateBy != null">#{updateBy},</if>
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="playUrl != null">#{playUrl},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@ -129,6 +133,7 @@
|
|||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="playUrl != null">play_url = #{playUrl},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.fastbee.iot.domain;
|
package com.fastbee.iot.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -19,6 +20,7 @@ import java.util.Date;
|
|||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ApiModel(value = "AlertLog", description = "设备告警日志实体 iot_alert_log")
|
@ApiModel(value = "AlertLog", description = "设备告警日志实体 iot_alert_log")
|
||||||
|
@TableName("iot_alert_log")
|
||||||
public class AlertLog extends BaseEntity
|
public class AlertLog extends BaseEntity
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.fastbee.iot.mapper;
|
package com.fastbee.iot.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.fastbee.iot.domain.AlertLog;
|
import com.fastbee.iot.domain.AlertLog;
|
||||||
import com.fastbee.iot.model.DeviceAlertCount;
|
import com.fastbee.iot.model.DeviceAlertCount;
|
||||||
import com.fastbee.iot.model.AlertCountVO;
|
import com.fastbee.iot.model.AlertCountVO;
|
||||||
@ -16,7 +17,7 @@ import java.util.List;
|
|||||||
* @date 2022-01-13
|
* @date 2022-01-13
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface AlertLogMapper
|
public interface AlertLogMapper extends BaseMapper<AlertLog>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 查询设备告警
|
* 查询设备告警
|
||||||
|
@ -153,6 +153,11 @@ public class Project extends BaseEntity
|
|||||||
@ApiModelProperty("行政区域村代码")
|
@ApiModelProperty("行政区域村代码")
|
||||||
private String villageCode;
|
private String villageCode;
|
||||||
|
|
||||||
|
/** 项目lei */
|
||||||
|
@Excel(name = "项目lei")
|
||||||
|
@ApiModelProperty("项目lei")
|
||||||
|
private Long type;
|
||||||
|
|
||||||
//业务字段---------------------------------------------------------------------------
|
//业务字段---------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* 系统账号名称
|
* 系统账号名称
|
||||||
|
@ -17,6 +17,7 @@ import com.fastbee.common.utils.json.JsonStrUtil;
|
|||||||
import com.fastbee.iot.model.RegisterUserInput;
|
import com.fastbee.iot.model.RegisterUserInput;
|
||||||
import com.fastbee.iot.model.RegisterUserOutput;
|
import com.fastbee.iot.model.RegisterUserOutput;
|
||||||
import com.fastbee.iot.service.IToolService;
|
import com.fastbee.iot.service.IToolService;
|
||||||
|
import com.fastbee.common.constant.ProjectTypeConstant;
|
||||||
import com.fastbee.project.domain.Project;
|
import com.fastbee.project.domain.Project;
|
||||||
import com.fastbee.project.domain.vo.ProjectLoginBaseInfo;
|
import com.fastbee.project.domain.vo.ProjectLoginBaseInfo;
|
||||||
import com.fastbee.project.mapper.ProjectMapper;
|
import com.fastbee.project.mapper.ProjectMapper;
|
||||||
@ -168,9 +169,26 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
// 添加管理员角色,给基本权限
|
// 添加管理员角色,给基本权限
|
||||||
SysDept sysDept = deptService.selectDeptById(100L);
|
SysDept sysDept = deptService.selectDeptById(100L);
|
||||||
List<SysMenu> sysMenuList = sysMenuService.selectMenuList(new SysMenu(), sysDept.getDeptUserId());
|
List<SysMenu> sysMenuList = sysMenuService.selectMenuList(new SysMenu(), sysDept.getDeptUserId());
|
||||||
Long[] menuIdList = sysMenuList.stream().map(SysMenu::getMenuId)
|
Long[] menuIdList = sysMenuList.stream()
|
||||||
.filter(menuId-> menuId!=3469L&&menuId!=3L&&menuId!=2L &&menuId!=3468L&&menuId!=102L)
|
//过滤掉不该有的菜单
|
||||||
|
.filter(this::baseMenuFilter)
|
||||||
|
.map(SysMenu::getMenuId)
|
||||||
.toArray(Long[]::new);
|
.toArray(Long[]::new);
|
||||||
|
//根据项目类型过滤菜单
|
||||||
|
if (!Objects.nonNull(project.getType())||ProjectTypeConstant.isValidProjectType(project.getType())) {
|
||||||
|
throw new ServiceException("项目类型不能为空或者非法!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Objects.equals(project.getType(),ProjectTypeConstant.WATER)) {
|
||||||
|
List<Long> menuList=Arrays.asList(menuIdList);
|
||||||
|
menuIdList = menuList.stream().filter(this::waterMenuFilter).toArray(Long[]::new);
|
||||||
|
}
|
||||||
|
if (Objects.equals(project.getType(),ProjectTypeConstant.AGRICULTURE)) {
|
||||||
|
List<Long> menuList=Arrays.asList(menuIdList);
|
||||||
|
menuIdList = menuList.stream().filter(this::agriculturalMenuFilter).toArray(Long[]::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SysRole sysRole = new SysRole();
|
SysRole sysRole = new SysRole();
|
||||||
sysRole.setRoleName("管理员");
|
sysRole.setRoleName("管理员");
|
||||||
sysRole.setRoleKey("manager");
|
sysRole.setRoleKey("manager");
|
||||||
@ -209,8 +227,37 @@ public class ProjectServiceImpl implements IProjectService
|
|||||||
if(!updatedSysDept){
|
if(!updatedSysDept){
|
||||||
throw new ServiceException("机构与项目关联失败!");
|
throw new ServiceException("机构与项目关联失败!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 判断菜单是否为非法持有菜单
|
||||||
|
* @param sysMenu 菜单
|
||||||
|
* @return 是否为非法菜单
|
||||||
|
*/
|
||||||
|
private boolean baseMenuFilter(SysMenu sysMenu) {
|
||||||
|
Long menuId = sysMenu.getMenuId();
|
||||||
|
boolean base = menuId != 3469L//项目管理
|
||||||
|
&& menuId != 3L//系统工具
|
||||||
|
&& menuId!= 2L//系统监控
|
||||||
|
&& menuId != 3468L//图例管理
|
||||||
|
&& menuId != 102L;//菜单管理
|
||||||
|
return base;
|
||||||
|
|
||||||
|
}
|
||||||
|
//农业项目过滤菜单
|
||||||
|
private boolean agriculturalMenuFilter(Long menuId){
|
||||||
|
return menuId != 3353L;//项目管理
|
||||||
|
|
||||||
|
}
|
||||||
|
//水利项目过滤菜单
|
||||||
|
private boolean waterMenuFilter(Long menuId){
|
||||||
|
return menuId != 3474L;//项目管理
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析项目行政区划信息
|
* 解析项目行政区划信息
|
||||||
|
@ -36,10 +36,11 @@
|
|||||||
<result property="countyCode" column="county_code" />
|
<result property="countyCode" column="county_code" />
|
||||||
<result property="townCode" column="town_code" />
|
<result property="townCode" column="town_code" />
|
||||||
<result property="villageCode" column="village_code" />
|
<result property="villageCode" column="village_code" />
|
||||||
|
<result property="type" column="type" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectProjectVo">
|
<sql id="selectProjectVo">
|
||||||
select id, project_name, sys_show_name, central_coordinates, scope, administrative_area, owner, logo, image, video_introduction, remark, p_params, introduce, del_flag, create_time, create_by, update_time, remarks, tenant_id, tenant_name, owner_id, parent_id, dept_id, administrative_area_code, dept_name, level, province_code, city_code, county_code, town_code, village_code from project
|
select id, project_name, sys_show_name, central_coordinates, scope, administrative_area, owner, logo, image, video_introduction, remark, p_params, introduce, del_flag, create_time, create_by, update_time, remarks, tenant_id, tenant_name, owner_id, parent_id, dept_id, administrative_area_code, dept_name, level, province_code, city_code, county_code, town_code, village_code, type from project
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectProjectList" parameterType="Project" resultMap="ProjectResult">
|
<select id="selectProjectList" parameterType="Project" resultMap="ProjectResult">
|
||||||
@ -70,6 +71,7 @@
|
|||||||
<if test="countyCode != null and countyCode != ''"> and county_code = #{countyCode}</if>
|
<if test="countyCode != null and countyCode != ''"> and county_code = #{countyCode}</if>
|
||||||
<if test="townCode != null and townCode != ''"> and town_code = #{townCode}</if>
|
<if test="townCode != null and townCode != ''"> and town_code = #{townCode}</if>
|
||||||
<if test="villageCode != null and villageCode != ''"> and village_code = #{villageCode}</if>
|
<if test="villageCode != null and villageCode != ''"> and village_code = #{villageCode}</if>
|
||||||
|
<if test="type != null "> and type = #{type}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@ -111,6 +113,7 @@
|
|||||||
<if test="countyCode != null">county_code,</if>
|
<if test="countyCode != null">county_code,</if>
|
||||||
<if test="townCode != null">town_code,</if>
|
<if test="townCode != null">town_code,</if>
|
||||||
<if test="villageCode != null">village_code,</if>
|
<if test="villageCode != null">village_code,</if>
|
||||||
|
<if test="type != null">type,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="projectName != null and projectName != ''">#{projectName},</if>
|
<if test="projectName != null and projectName != ''">#{projectName},</if>
|
||||||
@ -143,6 +146,7 @@
|
|||||||
<if test="countyCode != null">#{countyCode},</if>
|
<if test="countyCode != null">#{countyCode},</if>
|
||||||
<if test="townCode != null">#{townCode},</if>
|
<if test="townCode != null">#{townCode},</if>
|
||||||
<if test="villageCode != null">#{villageCode},</if>
|
<if test="villageCode != null">#{villageCode},</if>
|
||||||
|
<if test="type != null">#{type},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@ -179,6 +183,7 @@
|
|||||||
<if test="countyCode != null">county_code = #{countyCode},</if>
|
<if test="countyCode != null">county_code = #{countyCode},</if>
|
||||||
<if test="townCode != null">town_code = #{townCode},</if>
|
<if test="townCode != null">town_code = #{townCode},</if>
|
||||||
<if test="villageCode != null">village_code = #{villageCode},</if>
|
<if test="villageCode != null">village_code = #{villageCode},</if>
|
||||||
|
<if test="type != null">type = #{type},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
Reference in New Issue
Block a user