同步代码
This commit is contained in:
parent
9327c600f7
commit
172bd4f89d
@ -8,7 +8,9 @@ import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.holder.ProjectHolder;
|
||||
import com.fastbee.deviceData.api.devlink.service.ZhanLianBaseService;
|
||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||
import com.fastbee.deviceInfo.domain.*;
|
||||
import com.fastbee.deviceInfo.manager.DeviceInformationManager;
|
||||
import com.fastbee.deviceInfo.mapper.*;
|
||||
import com.fastbee.iot.domain.AlertLog;
|
||||
import com.fastbee.iot.domain.Device;
|
||||
import com.fastbee.iot.mapper.AlertLogMapper;
|
||||
@ -20,6 +22,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.jws.Oneway;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -44,6 +47,21 @@ public class DeviceAlarmController extends BaseController {
|
||||
@Autowired
|
||||
private DeviceMapper deviceMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceInformationWormsMapper wormsMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceInformationMeteorologyMapper meteorologyMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceInformationMoistureMapper moistureMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceInformationMonitorMapper monitorMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceInformationTargetpestsMapper targetpestsMapper;
|
||||
|
||||
/**
|
||||
* 获取设备告警数量
|
||||
*/
|
||||
@ -62,22 +80,44 @@ public class DeviceAlarmController extends BaseController {
|
||||
.count();
|
||||
|
||||
//统计设备离线数量
|
||||
List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper)
|
||||
.select(Device::getDeviceId,Device::getDeviceName,Device::getProductId,Device::getProductName,Device::getStatus,Device::getTenantId)
|
||||
.eq(Device::getTenantId, ProjectHolder.getProjectInfo().getProjectAdminId())
|
||||
.list();
|
||||
//循环统计状态值为4离线设备数量
|
||||
int count1 = 0;
|
||||
for (Device device : deviceList) {
|
||||
if(device.getStatus()==4){
|
||||
count1++;
|
||||
}
|
||||
}
|
||||
// List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper)
|
||||
// .select(Device::getDeviceId,Device::getDeviceName,Device::getProductId,Device::getProductName,Device::getStatus,Device::getTenantId)
|
||||
// .eq(Device::getTenantId, ProjectHolder.getProjectInfo().getProjectAdminId())
|
||||
// .list();
|
||||
// //循环统计状态值为4离线设备数量
|
||||
// int count1 = 0;
|
||||
// for (Device device : deviceList) {
|
||||
// if(device.getStatus()==4){
|
||||
// count1++;
|
||||
// }
|
||||
// }
|
||||
//统计设备总离线量
|
||||
Map<String, Map<String, Object>> info = getAllTypeDeviceListAndStatusCount();
|
||||
//虫情设备信息
|
||||
Map<String, Object> worm = info.get("worm");
|
||||
//气象设备信息
|
||||
Map<String, Object> meteorology = info.get("meteorology");
|
||||
//墒情设备信息
|
||||
Map<String, Object> moisture = info.get("moisture");
|
||||
//监控设备信息
|
||||
Map<String, Object> monitor = info.get("monitor");
|
||||
//杀虫灯设备信息
|
||||
Map<String, Object> targetpest = info.get("targetpest");
|
||||
|
||||
int offlineCount=0;
|
||||
//计算离线设备总数
|
||||
offlineCount+=Integer.parseInt(String.valueOf(worm.get("deviceOfflineCount")));
|
||||
offlineCount+=Integer.parseInt(String.valueOf(meteorology.get("deviceOfflineCount")));
|
||||
offlineCount+=Integer.parseInt(String.valueOf(moisture.get("deviceOfflineCount")));
|
||||
offlineCount+=Integer.parseInt(String.valueOf(monitor.get("deviceOfflineCount")));
|
||||
offlineCount+=Integer.parseInt(String.valueOf(targetpest.get("deviceOfflineCount")));
|
||||
|
||||
|
||||
|
||||
Map<String,Object> resp =new HashMap<>();
|
||||
resp.put("alarmTotal",count);//告警总数
|
||||
resp.put("securityLevel",getSecurityLevel(count));//安全等级
|
||||
resp.put("offlineDeviceTotal",count1);//离线设备总数
|
||||
resp.put("offlineDeviceTotal",offlineCount);//离线设备总数
|
||||
return AjaxResult.success(resp);
|
||||
}
|
||||
|
||||
@ -97,69 +137,177 @@ public class DeviceAlarmController extends BaseController {
|
||||
@GetMapping("/onlineRate")
|
||||
public AjaxResult getDeviceOnlineRate(Device device) {
|
||||
|
||||
List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper)
|
||||
.select(Device::getDeviceId,Device::getDeviceName,Device::getProductId,Device::getProductName,Device::getStatus,Device::getTenantId)
|
||||
.eq(Device::getTenantId,device.getTenantId())
|
||||
.list();
|
||||
// deviceList.forEach(System.err::println);
|
||||
Map<String, Map<String, Object>> info = getAllTypeDeviceListAndStatusCount();
|
||||
//虫情设备信息
|
||||
Map<String, Object> worm = info.get("worm");
|
||||
//气象设备信息
|
||||
Map<String, Object> meteorology = info.get("meteorology");
|
||||
//墒情设备信息
|
||||
Map<String, Object> moisture = info.get("moisture");
|
||||
//监控设备信息
|
||||
Map<String, Object> monitor = info.get("monitor");
|
||||
//杀虫灯设备信息
|
||||
Map<String, Object> targetpest = info.get("targetpest");
|
||||
|
||||
System.out.println("-------------------------------------------");
|
||||
//封装结果
|
||||
List<DeviceProperties> restList=new ArrayList<>();
|
||||
restList.add(DeviceProperties.builder().name("气象监测").value(String.valueOf(meteorology.get("deviceOnlineRate"))).unit("%").build());
|
||||
restList.add(DeviceProperties.builder().name("墒情监测").value(String.valueOf(moisture.get("deviceOnlineRate"))).unit("%").build());
|
||||
restList.add(DeviceProperties.builder().name("虫情监测").value(String.valueOf(worm.get("deviceOnlineRate"))).unit("%").build());
|
||||
// restList.add(DeviceProperties.builder().name("苗情监测").value(String.valueOf(miaoQingDeviceOnlineRate)).unit("%").build());
|
||||
restList.add(DeviceProperties.builder().name("杀虫灯").value(String.valueOf(targetpest.get("deviceOnlineRate"))).unit("%").build());
|
||||
restList.add(DeviceProperties.builder().name("监控").value(String.valueOf(monitor.get("deviceOnlineRate"))).unit("%").build());
|
||||
|
||||
return AjaxResult.success(restList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有类型设备列表返回每种设备列表Map
|
||||
*/
|
||||
private Map<String,Map<String,Object>> getAllTypeDeviceListAndStatusCount(){
|
||||
Map<String,Map<String,Object>> resultMap=new HashMap<>();
|
||||
int meteorologyDeviceCount = 0;//气象设备总量
|
||||
int meteorologyDeviceOnLineCount = 0;//气象设备在线量
|
||||
int meteorologyDeviceOfflineCount=0;//气象设备离线量
|
||||
double meteorologyDeviceOnlineRate = 0.0; //气象设备在线率
|
||||
|
||||
int moistureDeviceCount = 0;//墒情设备总量
|
||||
int moistureDeviceOnLineCount = 0;//墒情设备在线量
|
||||
int moistureDeviceOfflineCount=0;//墒情设备离线量
|
||||
double moistureDeviceOnlineRate = 0.0; //墒情设备在线率
|
||||
|
||||
int wormDeviceCount = 0;//虫情设备总量
|
||||
int wormDeviceOnLineCount = 0;//虫情设备在线量
|
||||
int wormDeviceOfflineCount=0;//虫情设备离线量
|
||||
double wormDeviceOnlineRate = 0.0; //虫情设备在线率
|
||||
|
||||
int miaoQingDeviceCount = 0;//苗情设备总量
|
||||
int miaoQingDeviceOnLineCount = 0;//苗情设备在线量
|
||||
int miaoQingDeviceOfflineCount=0;//苗情设备离线量
|
||||
double miaoQingDeviceOnlineRate = 0.0; //苗情设备在线率
|
||||
|
||||
int insecticidalLampDeviceCount = 0;//杀虫灯设备总量
|
||||
int insecticidalLampDeviceOnLineCount = 0;//杀虫灯设备在线量
|
||||
int insecticidalLampDeviceOfflineCount=0;//杀虫灯设备离线量
|
||||
double insecticidalLampDeviceOnlineRate = 0.0; //杀虫灯设备在线率
|
||||
|
||||
int monitorDeviceCount = 0;//监控设备总量
|
||||
int monitorDeviceOnLineCount = 0;//监控设备在线量
|
||||
int monitorDeviceOfflineCount=0;//监控设备离线量
|
||||
double monitorDeviceOnlineRate = 0.0; //监控设备在线率
|
||||
|
||||
for (Device d:deviceList) {
|
||||
if (d.getProductName().equals("气象设备") || d.getProductId() == 144) {
|
||||
meteorologyDeviceCount++;
|
||||
if (d.getStatus() == 3) {
|
||||
meteorologyDeviceOnLineCount++;
|
||||
}
|
||||
} else if (d.getProductName().equals("墒情设备") || d.getProductId() == 142) {
|
||||
moistureDeviceCount++;
|
||||
if (d.getStatus() == 3) {
|
||||
moistureDeviceOnLineCount++;
|
||||
}
|
||||
} else if (d.getProductName().equals("太阳能供电设备") || d.getProductId() == 138) {
|
||||
miaoQingDeviceCount++;
|
||||
if (d.getStatus() == 3) {
|
||||
miaoQingDeviceOnLineCount++;
|
||||
}
|
||||
} else if (d.getProductName().equals("杀虫灯设备") || d.getProductId() == 145) {
|
||||
insecticidalLampDeviceCount++;
|
||||
if (d.getStatus() == 3) {
|
||||
insecticidalLampDeviceOnLineCount++;
|
||||
}
|
||||
} else if (d.getProductName().equals("虫情设备") || d.getProductId() == 143) {
|
||||
wormDeviceCount++;
|
||||
if (d.getStatus() == 3) {
|
||||
wormDeviceOnLineCount++;
|
||||
}
|
||||
// List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper)
|
||||
// .select(Device::getDeviceId,Device::getDeviceName,Device::getProductId,Device::getProductName,Device::getStatus,Device::getTenantId)
|
||||
// .eq(Device::getTenantId,device.getTenantId())
|
||||
// .list();
|
||||
//// deviceList.forEach(System.err::println);
|
||||
// for (Device d:deviceList) {
|
||||
// if (d.getProductName().equals("气象设备") || d.getProductId() == 144) {
|
||||
// meteorologyDeviceCount++;
|
||||
// if (d.getStatus() == 3) {
|
||||
// meteorologyDeviceOnLineCount++;
|
||||
// }
|
||||
// } else if (d.getProductName().equals("墒情设备") || d.getProductId() == 142) {
|
||||
// moistureDeviceCount++;
|
||||
// if (d.getStatus() == 3) {
|
||||
// moistureDeviceOnLineCount++;
|
||||
// }
|
||||
// } else if (d.getProductName().equals("太阳能供电设备") || d.getProductId() == 138) {
|
||||
// miaoQingDeviceCount++;
|
||||
// if (d.getStatus() == 3) {
|
||||
// miaoQingDeviceOnLineCount++;
|
||||
// }
|
||||
// } else if (d.getProductName().equals("杀虫灯设备") || d.getProductId() == 145) {
|
||||
// insecticidalLampDeviceCount++;
|
||||
// if (d.getStatus() == 3) {
|
||||
// insecticidalLampDeviceOnLineCount++;
|
||||
// }
|
||||
// } else if (d.getProductName().equals("虫情设备") || d.getProductId() == 143) {
|
||||
// wormDeviceCount++;
|
||||
// if (d.getStatus() == 3) {
|
||||
// wormDeviceOnLineCount++;
|
||||
// }
|
||||
//
|
||||
// } else if ( d.getProductName().equals("萤石云视频")||d.getProductId()==141) {
|
||||
// monitorDeviceCount++;
|
||||
// if(d.getStatus()==3){
|
||||
// monitorDeviceOnLineCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
} else if ( d.getProductName().equals("萤石云视频")||d.getProductId()==141) {
|
||||
monitorDeviceCount++;
|
||||
if(d.getStatus()==3){
|
||||
monitorDeviceOnLineCount++;
|
||||
}
|
||||
//查询虫情设备列表
|
||||
|
||||
List<DeviceInformationWorms> wormList = new LambdaQueryChainWrapper<>(wormsMapper)
|
||||
.select(DeviceInformationWorms::getStatus)
|
||||
.list();
|
||||
wormDeviceCount=wormList.size();
|
||||
for(DeviceInformationWorms d:wormList){
|
||||
if(d.getStatus()==1){
|
||||
wormDeviceOnLineCount++;
|
||||
} else if (d.getStatus()==0) {
|
||||
wormDeviceOfflineCount++;
|
||||
}
|
||||
}
|
||||
//查询墒情设备列表
|
||||
List<DeviceInformationMoisture> moistureList = new LambdaQueryChainWrapper<>(moistureMapper).select(DeviceInformationMoisture::getStatus).list();
|
||||
moistureDeviceCount=moistureList.size();
|
||||
for(DeviceInformationMoisture d:moistureList){
|
||||
if(d.getStatus()==1){
|
||||
moistureDeviceOnLineCount++;
|
||||
} else if (d.getStatus()==0) {
|
||||
meteorologyDeviceOfflineCount++;
|
||||
}
|
||||
}
|
||||
//查询气象设备列表
|
||||
List<DeviceInformationMeteorology> meteorologyList = new LambdaQueryChainWrapper<>(meteorologyMapper).select(DeviceInformationMeteorology::getStatus).list();
|
||||
meteorologyDeviceCount=meteorologyList.size();
|
||||
for(DeviceInformationMeteorology d:meteorologyList){
|
||||
if(d.getStatus()==1){
|
||||
meteorologyDeviceOnLineCount++;
|
||||
} else if (d.getStatus()==0) {
|
||||
meteorologyDeviceOfflineCount++;
|
||||
}
|
||||
}
|
||||
|
||||
//查询监控设备列表
|
||||
List<DeviceInformationMonitor> monitorList = new LambdaQueryChainWrapper<>(monitorMapper).select(DeviceInformationMonitor::getStatus).list();
|
||||
monitorDeviceCount=monitorList.size();
|
||||
for(DeviceInformationMonitor d:monitorList){
|
||||
if(d.getStatus()==1){
|
||||
monitorDeviceOnLineCount++;
|
||||
} else if (d.getStatus()==0) {
|
||||
monitorDeviceOfflineCount++;
|
||||
}
|
||||
}
|
||||
|
||||
//查询杀虫灯设备列表
|
||||
List<DeviceInformationTargetpests> targetpestList = new LambdaQueryChainWrapper<>(targetpestsMapper).select(DeviceInformationTargetpests::getStatus).list();
|
||||
insecticidalLampDeviceCount=targetpestList.size();
|
||||
for(DeviceInformationTargetpests d:targetpestList){
|
||||
if(d.getStatus()==1){
|
||||
insecticidalLampDeviceOnLineCount++;
|
||||
} else if (d.getStatus()==0) {
|
||||
insecticidalLampDeviceOfflineCount++;
|
||||
}
|
||||
}
|
||||
|
||||
//计算在线率
|
||||
//气象设备在线率
|
||||
meteorologyDeviceOnlineRate = meteorologyDeviceCount==0?0.0:((double) meteorologyDeviceOnLineCount / meteorologyDeviceCount)*100;
|
||||
//墒情设备在线率
|
||||
moistureDeviceOnlineRate = moistureDeviceCount==0?0.0:((double) moistureDeviceOnLineCount / moistureDeviceCount)*100;
|
||||
//虫情设备在线率
|
||||
wormDeviceOnlineRate = wormDeviceCount==0?0.0:((double) wormDeviceOnLineCount / wormDeviceCount)*100;
|
||||
//苗情设备在线率
|
||||
// miaoQingDeviceOnlineRate = miaoQingDeviceCount==0?0.0:((double) miaoQingDeviceOnLineCount / miaoQingDeviceCount)*100;
|
||||
//杀虫灯设备在线率
|
||||
insecticidalLampDeviceOnlineRate = insecticidalLampDeviceCount==0?0.0:((double) insecticidalLampDeviceOnLineCount / insecticidalLampDeviceCount)*100;
|
||||
//监控设备在线率
|
||||
monitorDeviceOnlineRate = monitorDeviceCount==0?0.0:((double) monitorDeviceOnLineCount / monitorDeviceCount)*100;
|
||||
|
||||
//打印累加后结果
|
||||
System.out.println("气象设备总量:"+meteorologyDeviceCount);
|
||||
System.out.println("气象设备在线量:"+meteorologyDeviceOnLineCount);
|
||||
@ -172,10 +320,10 @@ public class DeviceAlarmController extends BaseController {
|
||||
System.out.println("虫情设备总量:"+wormDeviceCount);
|
||||
System.out.println("虫情设备在线量:"+wormDeviceOnLineCount);
|
||||
System.out.println("虫情设备在线率:"+wormDeviceOnlineRate);
|
||||
System.out.println("-------------------------------------------");
|
||||
System.out.println("苗情设备总量:"+miaoQingDeviceCount);
|
||||
System.out.println("苗情设备在线量:"+miaoQingDeviceOnLineCount);
|
||||
System.out.println("苗情设备在线率:"+miaoQingDeviceOnlineRate);
|
||||
// System.out.println("-------------------------------------------");
|
||||
// System.out.println("苗情设备总量:"+miaoQingDeviceCount);
|
||||
// System.out.println("苗情设备在线量:"+miaoQingDeviceOnLineCount);
|
||||
// System.out.println("苗情设备在线率:"+miaoQingDeviceOnlineRate);
|
||||
System.out.println("-------------------------------------------");
|
||||
System.out.println("杀虫灯设备总量:"+insecticidalLampDeviceCount);
|
||||
System.out.println("杀虫灯设备在线量:"+insecticidalLampDeviceOnLineCount);
|
||||
@ -185,33 +333,51 @@ public class DeviceAlarmController extends BaseController {
|
||||
System.out.println("监控设备在线量:"+monitorDeviceOnLineCount);
|
||||
System.out.println("监控设备在线率:"+monitorDeviceOnlineRate);
|
||||
System.out.println("-------------------------------------------");
|
||||
//计算在线率
|
||||
//气象设备在线率
|
||||
meteorologyDeviceOnlineRate = meteorologyDeviceCount==0?0.0:((double) meteorologyDeviceOnLineCount / meteorologyDeviceCount)*100;
|
||||
//墒情设备在线率
|
||||
moistureDeviceOnlineRate = moistureDeviceCount==0?0.0:((double) moistureDeviceOnLineCount / moistureDeviceCount)*100;
|
||||
//虫情设备在线率
|
||||
wormDeviceOnlineRate = wormDeviceCount==0?0.0:((double) wormDeviceOnLineCount / wormDeviceCount)*100;
|
||||
//苗情设备在线率
|
||||
miaoQingDeviceOnlineRate = miaoQingDeviceCount==0?0.0:((double) miaoQingDeviceOnLineCount / miaoQingDeviceCount)*100;
|
||||
//杀虫灯设备在线率
|
||||
insecticidalLampDeviceOnlineRate = insecticidalLampDeviceCount==0?0.0:((double) insecticidalLampDeviceOnLineCount / insecticidalLampDeviceCount)*100;
|
||||
//监控设备在线率
|
||||
monitorDeviceOnlineRate = monitorDeviceCount==0?0.0:((double) monitorDeviceOnLineCount / monitorDeviceCount)*100;
|
||||
|
||||
//封装结果
|
||||
List<DeviceProperties> restList=new ArrayList<>();
|
||||
restList.add(DeviceProperties.builder().name("气象监测").value(String.valueOf(meteorologyDeviceOnlineRate)).unit("%").build());
|
||||
restList.add(DeviceProperties.builder().name("墒情监测").value(String.valueOf(moistureDeviceOnlineRate)).unit("%").build());
|
||||
restList.add(DeviceProperties.builder().name("虫情监测").value(String.valueOf(wormDeviceOnlineRate)).unit("%").build());
|
||||
restList.add(DeviceProperties.builder().name("苗情监测").value(String.valueOf(miaoQingDeviceOnlineRate)).unit("%").build());
|
||||
restList.add(DeviceProperties.builder().name("杀虫灯").value(String.valueOf(insecticidalLampDeviceOnlineRate)).unit("%").build());
|
||||
restList.add(DeviceProperties.builder().name("监控").value(String.valueOf(monitorDeviceOnlineRate)).unit("%").build());
|
||||
|
||||
return AjaxResult.success(restList);
|
||||
Map<String,Object> worm=new HashMap<>();
|
||||
worm.put("deviceCount",wormDeviceCount);
|
||||
worm.put("deviceOnlineCount",wormDeviceOnLineCount);
|
||||
worm.put("deviceOfflineCount",wormDeviceOfflineCount);
|
||||
worm.put("deviceOnlineRate",wormDeviceOnlineRate);
|
||||
resultMap.put("worm",worm);
|
||||
|
||||
|
||||
Map<String,Object> moisture=new HashMap<>();
|
||||
moisture.put("deviceCount",moistureDeviceCount);
|
||||
moisture.put("deviceOnlineCount",moistureDeviceOnLineCount);
|
||||
moisture.put("deviceOfflineCount",moistureDeviceOfflineCount);
|
||||
moisture.put("deviceOnlineRate",moistureDeviceOnlineRate);
|
||||
resultMap.put("moisture",moisture);
|
||||
|
||||
|
||||
Map<String,Object> meteorology=new HashMap<>();
|
||||
meteorology.put("deviceCount",meteorologyDeviceCount);
|
||||
meteorology.put("deviceOnlineCount",meteorologyDeviceOnLineCount);
|
||||
meteorology.put("deviceOfflineCount",meteorologyDeviceOfflineCount);
|
||||
meteorology.put("deviceOnlineRate",meteorologyDeviceOnlineRate);
|
||||
resultMap.put("meteorology",meteorology);
|
||||
|
||||
|
||||
Map<String,Object> targetpest=new HashMap<>();
|
||||
targetpest.put("deviceCount",insecticidalLampDeviceCount );
|
||||
targetpest.put("deviceOnlineCount",insecticidalLampDeviceOnLineCount);
|
||||
targetpest.put("deviceOfflineCount",insecticidalLampDeviceOfflineCount);
|
||||
targetpest.put("deviceOnlineRate",insecticidalLampDeviceOnlineRate);
|
||||
resultMap.put("targetpest",targetpest);
|
||||
|
||||
|
||||
|
||||
Map<String,Object> monitor=new HashMap<>();
|
||||
monitor.put("deviceCount",monitorDeviceCount);
|
||||
monitor.put("deviceOnlineCount",monitorDeviceOnLineCount);
|
||||
monitor.put("deviceOfflineCount",monitorDeviceOfflineCount);
|
||||
monitor.put("deviceOnlineRate",monitorDeviceOnlineRate);
|
||||
resultMap.put("monitor",monitor);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 研判等级评级策略方法
|
||||
* A级,3个以下报警;B级,3-10个报警;C级;10个以上报警
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceBaseInfo;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -15,10 +15,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationMeteorology;
|
||||
import com.fastbee.deviceInfo.service.IDeviceInformationMeteorologyService;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
@ -1,4 +1,4 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceBaseInfo;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
@ -1,4 +1,4 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceBaseInfo;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -15,10 +15,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationMoisture;
|
||||
import com.fastbee.deviceInfo.service.IDeviceInformationMoistureService;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
@ -1,4 +1,4 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceBaseInfo;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -15,10 +15,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationMonitor;
|
||||
import com.fastbee.deviceInfo.service.IDeviceInformationMonitorService;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
@ -1,4 +1,4 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceBaseInfo;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -15,10 +15,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationTargetpests;
|
||||
import com.fastbee.deviceInfo.service.IDeviceInformationTargetpestsService;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
@ -1,4 +1,4 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceBaseInfo;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -15,10 +15,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.fastbee.common.annotation.Log;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.common.enums.BusinessType;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationWorms;
|
||||
import com.fastbee.deviceInfo.service.IDeviceInformationWormsService;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
@ -1,12 +1,10 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.historyData;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceHistoryData;
|
||||
|
||||
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.common.core.page.TableDataInfo;
|
||||
import com.fastbee.deviceData.domain.*;
|
||||
import com.fastbee.deviceData.mapper.*;
|
||||
import org.redisson.config.BaseConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
@ -1,4 +1,4 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.realTimeData;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceRealTimeData;
|
||||
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
@ -1,8 +1,7 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceRealTimeData;
|
||||
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.deviceData.service.IDeviceRealtimedataMeteorologyService;
|
||||
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMeteorologyServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
@ -1,18 +1,16 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceRealTimeData;
|
||||
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataMoisture;
|
||||
import com.fastbee.deviceData.service.IDeviceRealtimedataMoistureService;
|
||||
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMoistureServiceImpl;
|
||||
import com.fastbee.deviceInfo.service.IDeviceInformationMoistureService;
|
||||
import com.fastbee.deviceInfo.service.impl.DeviceInformationMoistureServiceImpl;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 获取墒情设备实时数据
|
||||
*/
|
||||
@RestController()
|
||||
@RequestMapping("/moisture")
|
||||
public class DeviceRealtimedataMoistureController {
|
@ -1,4 +1,4 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceRealTimeData;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
@ -10,7 +10,6 @@ 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;
|
||||
|
@ -1,15 +1,16 @@
|
||||
package com.fastbee.data.controller.aaScreenAgricultural;
|
||||
package com.fastbee.data.controller.aaScreenAgricultural.deviceRealTimeData;
|
||||
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.deviceData.service.IDeviceRealtimedataMoistureService;
|
||||
import com.fastbee.deviceData.service.impl.DeviceRealtimedataWormsServiceImpl;
|
||||
import com.fastbee.deviceInfo.service.IDeviceInformationMoistureService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 获取虫情设备实时数据
|
||||
*/
|
||||
@RestController()
|
||||
@RequestMapping("/worms")
|
||||
public class DeviceRealtimedataWormsController extends BaseController {
|
@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
* 建大仁科气象设备服务
|
||||
* 建大杀虫灯设备
|
||||
*/
|
||||
@Service
|
||||
public class RenkeMetDeviceService {
|
||||
@ -22,7 +22,7 @@ public class RenkeMetDeviceService {
|
||||
|
||||
|
||||
/**
|
||||
* 获取气象设备全部信息
|
||||
* 获取杀虫灯设备全部信息
|
||||
* @param deviceStr 设备地址,支持多个用英文逗号分隔
|
||||
* @return JSONObject
|
||||
*/
|
||||
@ -38,7 +38,7 @@ public class RenkeMetDeviceService {
|
||||
return JSONUtil.parseObj(respBodyStr);
|
||||
}
|
||||
/**
|
||||
* 根据气象设备地址获取节点信息
|
||||
* 根据杀虫灯设备地址获取节点信息
|
||||
*/
|
||||
public JSONObject getAllInsectEquipmentInformation(String deviceAddr){
|
||||
|
||||
@ -54,7 +54,7 @@ public class RenkeMetDeviceService {
|
||||
return JSONUtil.parseObj(respBodyStr);
|
||||
}
|
||||
/**
|
||||
* 根据气象设备地址获取已启用的节点信息
|
||||
* 根据杀虫灯设备地址获取已启用的节点信息
|
||||
*/
|
||||
public JSONObject listTargetEnabledNode(String deviceAddr){
|
||||
|
||||
@ -70,7 +70,7 @@ public class RenkeMetDeviceService {
|
||||
return JSONUtil.parseObj(respBodyStr);
|
||||
}
|
||||
/**
|
||||
* 根据气象节点编号获取遥调信息
|
||||
* 根据杀虫灯节点编号获取遥调信息
|
||||
*/
|
||||
public JSONObject listTargetEnabledNode(String deviceAddr,String nodeId){
|
||||
// 请求基础URL
|
||||
@ -95,7 +95,7 @@ public class RenkeMetDeviceService {
|
||||
return JSONUtil.parseObj(respBodyStr);
|
||||
}
|
||||
/**
|
||||
* 修改指定气象设备全部节点的可用状态
|
||||
* 修改指定杀虫灯设备全部节点的可用状态
|
||||
*/
|
||||
public JSONObject updateAllOfNodesEnable(String deviceAddr,String enable){
|
||||
// 请求基础URL
|
||||
@ -121,7 +121,7 @@ public class RenkeMetDeviceService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改气象设备信息
|
||||
* 修改杀虫灯设备信息
|
||||
*/
|
||||
public JSONObject updateDevice(UpdateDevice updateDevice){
|
||||
//获取设备实时数据
|
||||
@ -137,7 +137,7 @@ public class RenkeMetDeviceService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新气象节点信息
|
||||
* 更新杀虫灯节点信息
|
||||
*/
|
||||
public JSONObject updateNodeInfo(UpdateNodeInfo updateNodeInfo){
|
||||
//获取设备实时数据
|
||||
|
@ -0,0 +1,92 @@
|
||||
package com.fastbee.deviceData.api.renke.service;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationTargetpests;
|
||||
import com.fastbee.deviceInfo.mapper.DeviceInformationTargetpestsMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class RenkeTargetpestsDeviceDataService {
|
||||
|
||||
@Autowired
|
||||
private RenKeAuthorizationService authenticationService;
|
||||
|
||||
@Autowired
|
||||
private DeviceInformationTargetpestsMapper targetpestsMapper;
|
||||
|
||||
/**
|
||||
* 获取设备实时数据
|
||||
* @param deviceAddrs 设备地址,支持多个用英文逗号分隔
|
||||
*/
|
||||
public void setData(String deviceAddrs) {
|
||||
DeviceRealtimedataWorms deviceRealtimedataWorms = new DeviceRealtimedataWorms();
|
||||
//处理鉴权
|
||||
String token = authenticationService.getToken();
|
||||
// String token = "34491732858666778";
|
||||
|
||||
//获取设备基础实时数据
|
||||
HttpResponse response = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/entrance/device/getRealTimeData")
|
||||
.header("token", token)
|
||||
.form("deviceAddrs", deviceAddrs)
|
||||
.execute();
|
||||
String respBodyStr = response.body();
|
||||
|
||||
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"));
|
||||
realtimeDataList.forEach(json -> {
|
||||
//设备编码
|
||||
JSONObject jsonObject = JSONUtil.parseObj(json);
|
||||
String deviceAddr = jsonObject.getStr("deviceAddr");
|
||||
String data = jsonObject.getStr("data");
|
||||
JSONArray jsonArray = JSONUtil.parseArray(data);
|
||||
jsonArray.forEach(json1 -> {
|
||||
JSONObject obj = JSONUtil.parseObj(json1);
|
||||
String nodeName = obj.getStr("nodeName");
|
||||
if(nodeName.equals("引虫灯状态")){
|
||||
//引虫灯状态
|
||||
String temValueStr = obj.getStr("temValueStr");
|
||||
// System.err.println(deviceAddr+"引虫灯状态:"+temValueStr);
|
||||
//如果引虫灯设备关闭判定为离线
|
||||
if(temValueStr.equals("关闭")){
|
||||
//更新设备状态为离线
|
||||
new LambdaUpdateChainWrapper<>(targetpestsMapper).eq(DeviceInformationTargetpests::getDeviceEncoding,deviceAddr).set(DeviceInformationTargetpests::getStatus, 0).update();
|
||||
} else {
|
||||
new LambdaUpdateChainWrapper<>(targetpestsMapper).eq(DeviceInformationTargetpests::getDeviceEncoding,deviceAddr).set(DeviceInformationTargetpests::getStatus, 1).update();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
RenkeTargetpestsDeviceDataService renkeDeviceDataService = new RenkeTargetpestsDeviceDataService();
|
||||
renkeDeviceDataService.setData("21094868");
|
||||
// HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/entrance/device/getRealTimeData?deviceAddrs="+"21094868")
|
||||
// .header("token", "34491732858666778")
|
||||
// .execute();
|
||||
// String respBodyStr1 = response1.body();
|
||||
//
|
||||
// JSONObject respBody1 = JSONUtil.parseObj(respBodyStr1);
|
||||
// System.err.println(respBodyStr1);
|
||||
}
|
||||
|
||||
}
|
@ -7,20 +7,18 @@ import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fastbee.common.exception.ServiceException;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.common.utils.date.DateTimeCalculationUtils;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RenkeDeviceDataService {
|
||||
public class RenkeWormDeviceDataService {
|
||||
|
||||
@Autowired
|
||||
private RenKeAuthorizationService authenticationService;
|
||||
@ -29,8 +27,9 @@ public class RenkeDeviceDataService {
|
||||
* 获取设备实时数据
|
||||
* @param deviceAddrs 设备地址,支持多个用英文逗号分隔
|
||||
*/
|
||||
public DeviceRealtimedataWorms setData(String deviceAddrs) {
|
||||
DeviceRealtimedataWorms deviceRealtimedataWorms= new DeviceRealtimedataWorms();
|
||||
public List<DeviceRealtimedataWorms> setData(String deviceAddrs) {
|
||||
List<DeviceRealtimedataWorms> dataList =new ArrayList<>();
|
||||
|
||||
//处理鉴权
|
||||
String token = authenticationService.getToken();
|
||||
// String token = new RenKeAuthorizationService().getToken();
|
||||
@ -48,22 +47,24 @@ public class RenkeDeviceDataService {
|
||||
throw new ServiceException("获取设备实时数据失败!");
|
||||
}
|
||||
JSONArray realtimeDataList = JSONUtil.parseArray(respBody.get("data"));
|
||||
JSONObject jsonObject = JSONUtil.parseObj(realtimeDataList.get(0));
|
||||
JSONObject jsonObject1 = JSONUtil.parseObj(jsonObject.get("data"));
|
||||
//获取实时时间
|
||||
String realTime = jsonObject1.get("DTime").toString();
|
||||
//反序列化封装基础数据
|
||||
deviceRealtimedataWorms = JSONUtil.toBean(jsonObject1, DeviceRealtimedataWorms.class);
|
||||
//获取虫情设备关键数据
|
||||
HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/worm/deviceData/getWormDataAndWormDataAIBy?deviceAddr="+deviceAddrs)
|
||||
.header("token", token)
|
||||
realtimeDataList.forEach(o -> {
|
||||
DeviceRealtimedataWorms deviceRealtimedataWorms= new DeviceRealtimedataWorms();
|
||||
JSONObject dataObj = JSONUtil.parseObj(o);
|
||||
JSONObject jsonObject1 = JSONUtil.parseObj(dataObj .get("data"));
|
||||
//获取实时时间
|
||||
String realTime = jsonObject1.get("DTime").toString();
|
||||
//反序列化封装基础数据
|
||||
deviceRealtimedataWorms = JSONUtil.toBean(jsonObject1, DeviceRealtimedataWorms.class);
|
||||
//获取虫情设备关键数据
|
||||
HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/worm/deviceData/getWormDataAndWormDataAIBy?deviceAddr="+deviceAddrs)
|
||||
.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();
|
||||
.execute();
|
||||
|
||||
// HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/worm/deviceData/getWormDataList")
|
||||
// .header("token", token)
|
||||
@ -76,20 +77,20 @@ public class RenkeDeviceDataService {
|
||||
// .execute();
|
||||
|
||||
|
||||
String respBodyStr1 = response1.body();
|
||||
String respBodyStr1 = response1.body();
|
||||
|
||||
JSONObject respBody1 = JSONUtil.parseObj(respBodyStr1);
|
||||
JSONObject respBody1 = JSONUtil.parseObj(respBodyStr1);
|
||||
// System.err.println(respBodyStr1);
|
||||
if(!respBody1.get("code") .toString().equals("1000")) {
|
||||
throw new RuntimeException("获取设备实时数据失败!");
|
||||
}
|
||||
System.err.println(respBody1);
|
||||
JSONArray jsonArray = JSONUtil.parseArray(respBody1.get("data"));
|
||||
JSONObject entries = JSONUtil.parseObj(jsonArray.get(0));
|
||||
if(!respBody1.get("code") .toString().equals("1000")) {
|
||||
throw new RuntimeException("获取设备实时数据失败!");
|
||||
}
|
||||
System.err.println(respBody1);
|
||||
JSONArray jsonArray = JSONUtil.parseArray(respBody1.get("data"));
|
||||
JSONObject entries = JSONUtil.parseObj(jsonArray.get(0));
|
||||
|
||||
//获取害虫种类以及数量
|
||||
JSONArray analyseData = JSONUtil.parseArray(entries.get("analyseData"));
|
||||
//有害虫时保存
|
||||
//获取害虫种类以及数量
|
||||
JSONArray analyseData = JSONUtil.parseArray(entries.get("analyseData"));
|
||||
//有害虫时保存
|
||||
// if(!analyseData.isEmpty()){
|
||||
//获取拍照图片
|
||||
Object imagesUrl = entries .get("imagesUrl");
|
||||
@ -100,16 +101,22 @@ public class RenkeDeviceDataService {
|
||||
deviceRealtimedataWorms.setCamera(imagesUrl.toString());
|
||||
// }
|
||||
|
||||
deviceRealtimedataWorms.setSaveTime(DateUtils.getNowDate());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
try {
|
||||
Date date = sdf.parse(realTime);
|
||||
deviceRealtimedataWorms.setRealTime(date);
|
||||
} catch (ParseException e) {
|
||||
throw new ServiceException("时间格式转换失败!");
|
||||
}
|
||||
System.err.println("虫情设备实时数据:"+deviceRealtimedataWorms);
|
||||
return deviceRealtimedataWorms;
|
||||
deviceRealtimedataWorms.setSaveTime(DateUtils.getNowDate());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
try {
|
||||
Date date = sdf.parse(realTime);
|
||||
deviceRealtimedataWorms.setRealTime(date);
|
||||
} catch (ParseException e) {
|
||||
throw new ServiceException("时间格式转换失败!");
|
||||
}
|
||||
System.err.println("虫情设备实时数据:"+deviceRealtimedataWorms);
|
||||
dataList.add(deviceRealtimedataWorms);
|
||||
});
|
||||
|
||||
// JSONObject jsonObject = JSONUtil.parseObj(realtimeDataList.get(0));
|
||||
// JSONObject jsonObject1 = JSONUtil.parseObj(jsonObject.get("data"));
|
||||
|
||||
return dataList;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,9 @@ package com.fastbee.deviceData.service;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataMeteorology;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||
|
||||
/**
|
||||
@ -12,7 +14,7 @@ import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||
* @author kerwincui
|
||||
* @date 2024-11-14
|
||||
*/
|
||||
public interface IDeviceRealtimedataMeteorologyService
|
||||
public interface IDeviceRealtimedataMeteorologyService extends IService<DeviceRealtimedataMeteorology>
|
||||
{
|
||||
/**
|
||||
* 查询气象设备实时数据
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceData.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataMoisture;
|
||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||
|
||||
@ -10,7 +12,7 @@ import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||
* @author kerwincui
|
||||
* @date 2024-11-14
|
||||
*/
|
||||
public interface IDeviceRealtimedataMoistureService
|
||||
public interface IDeviceRealtimedataMoistureService extends IService<DeviceRealtimedataMoisture>
|
||||
{
|
||||
/**
|
||||
* 查询墒情实时数据
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastbee.deviceData.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -13,7 +15,7 @@ import org.apache.ibatis.annotations.Select;
|
||||
* @date 2024-11-14
|
||||
*/
|
||||
@Mapper
|
||||
public interface IDeviceRealtimedataWormsService
|
||||
public interface IDeviceRealtimedataWormsService extends IService<DeviceRealtimedataWorms>
|
||||
{
|
||||
/**
|
||||
* 查询虫情设备实时数据
|
||||
|
@ -4,8 +4,11 @@ import java.util.*;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||
import com.fastbee.deviceData.mapper.DeviceRealtimedataWormsMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fastbee.deviceData.mapper.DeviceRealtimedataMeteorologyMapper;
|
||||
@ -19,7 +22,7 @@ import com.fastbee.deviceData.service.IDeviceRealtimedataMeteorologyService;
|
||||
* @date 2024-11-14
|
||||
*/
|
||||
@Service
|
||||
public class DeviceRealtimedataMeteorologyServiceImpl implements IDeviceRealtimedataMeteorologyService
|
||||
public class DeviceRealtimedataMeteorologyServiceImpl extends ServiceImpl<DeviceRealtimedataMeteorologyMapper, DeviceRealtimedataMeteorology> implements IDeviceRealtimedataMeteorologyService
|
||||
{
|
||||
@Autowired
|
||||
private DeviceRealtimedataMeteorologyMapper deviceRealtimedataMeteorologyMapper;
|
||||
|
@ -3,6 +3,7 @@ package com.fastbee.deviceData.service.impl;
|
||||
import java.util.*;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -17,7 +18,7 @@ import com.fastbee.deviceData.service.IDeviceRealtimedataMoistureService;
|
||||
* @date 2024-11-14
|
||||
*/
|
||||
@Service
|
||||
public class DeviceRealtimedataMoistureServiceImpl implements IDeviceRealtimedataMoistureService
|
||||
public class DeviceRealtimedataMoistureServiceImpl extends ServiceImpl<DeviceRealtimedataMoistureMapper,DeviceRealtimedataMoisture> implements IDeviceRealtimedataMoistureService
|
||||
{
|
||||
@Autowired
|
||||
private DeviceRealtimedataMoistureMapper deviceRealtimedataMoistureMapper;
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fastbee.deviceData.domain.DeviceRealtimedataMoisture;
|
||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||
import com.fastbee.deviceData.service.IDeviceRealtimedataWormsService;
|
||||
@ -22,7 +23,7 @@ import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||
* @date 2024-11-07
|
||||
*/
|
||||
@Service
|
||||
public class DeviceRealtimedataWormsServiceImpl implements IDeviceRealtimedataWormsService
|
||||
public class DeviceRealtimedataWormsServiceImpl extends ServiceImpl<DeviceRealtimedataWormsMapper, DeviceRealtimedataWorms> implements IDeviceRealtimedataWormsService
|
||||
{
|
||||
@Autowired
|
||||
private DeviceRealtimedataWormsMapper deviceRealtimedataWormsMapper;
|
||||
|
@ -88,5 +88,9 @@ private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 删除标志(0代表存在,2代表删除) */
|
||||
private Integer delFlag;
|
||||
/** 状态1在线,0离线 */
|
||||
@Excel(name = "状态1在线,0离线")
|
||||
@ApiModelProperty("状态1在线,0离线")
|
||||
private Long status;
|
||||
|
||||
}
|
||||
|
@ -94,4 +94,9 @@ private static final long serialVersionUID = 1L;
|
||||
/** 删除标志(0代表存在,2代表删除) */
|
||||
private Integer delFlag;
|
||||
|
||||
/** 状态1在线,0离线 */
|
||||
@Excel(name = "状态1在线,0离线")
|
||||
@ApiModelProperty("状态1在线,0离线")
|
||||
private Long status;
|
||||
|
||||
}
|
||||
|
@ -108,6 +108,10 @@ public class DeviceInformationMonitor extends BaseEntity
|
||||
|
||||
/** 删除标志(0代表存在,2代表删除) */
|
||||
private Integer delFlag;
|
||||
/** 状态1在线,0离线 */
|
||||
@Excel(name = "状态1在线,0离线")
|
||||
@ApiModelProperty("状态1在线,0离线")
|
||||
private Long status;
|
||||
|
||||
//------------------------------------------------------------------------------------业务字段---------------
|
||||
|
||||
|
@ -85,4 +85,9 @@ private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
/** 状态1在线,0离线 */
|
||||
@Excel(name = "状态1在线,0离线")
|
||||
@ApiModelProperty("状态1在线,0离线")
|
||||
private Long status;
|
||||
|
||||
}
|
||||
|
@ -83,5 +83,9 @@ private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 删除标志(0代表存在,2代表删除) */
|
||||
private Integer delFlag;
|
||||
/** 状态1在线,0离线 */
|
||||
@Excel(name = "状态1在线,0离线")
|
||||
@ApiModelProperty("状态1在线,0离线")
|
||||
private Long status;
|
||||
|
||||
}
|
||||
|
@ -1,22 +1,37 @@
|
||||
package com.fastbee.iot.timer;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||
import com.fastbee.deviceData.api.devlink.service.ZhanLianMetDataService;
|
||||
import com.fastbee.deviceData.api.devlink.service.ZhanLianMiaoQingDataService;
|
||||
import com.fastbee.deviceData.api.devlink.service.ZhanLianMoistureDataService;
|
||||
import com.fastbee.deviceData.api.devlink.service.ZhanLianPhotovoltaicDataService;
|
||||
import com.fastbee.deviceData.api.renke.service.RenkeDeviceDataService;
|
||||
import com.fastbee.deviceData.api.renke.service.RenkeTargetpestsDeviceDataService;
|
||||
import com.fastbee.deviceData.api.renke.service.RenkeWormDeviceDataService;
|
||||
import com.fastbee.deviceData.domain.*;
|
||||
|
||||
import com.fastbee.deviceData.mapper.*;
|
||||
import com.fastbee.deviceData.service.IDeviceRealtimedataWormsService;
|
||||
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMeteorologyServiceImpl;
|
||||
import com.fastbee.deviceData.service.impl.DeviceRealtimedataWormsServiceImpl;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationMeteorology;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationMoisture;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationTargetpests;
|
||||
import com.fastbee.deviceInfo.domain.DeviceInformationWorms;
|
||||
import com.fastbee.deviceInfo.mapper.*;
|
||||
import com.fastbee.iot.mapper.DeviceMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author mijiupro
|
||||
*/
|
||||
@Component("agricultureDeviceDateTask")
|
||||
@Slf4j
|
||||
public class DeviceDateTask {
|
||||
//
|
||||
|
||||
@ -30,10 +45,10 @@ public class DeviceDateTask {
|
||||
private DeviceMapper deviceMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceRealtimedataWormsMapper deviceRealtimedataWormsMapper;
|
||||
private DeviceRealtimedataWormsServiceImpl wormsDataService;//虫情
|
||||
|
||||
@Autowired
|
||||
private DeviceRealtimedataMeteorologyMapper deviceRealtimedataMeteorologyMapper;
|
||||
private DeviceRealtimedataMeteorologyServiceImpl meteorologyDataService;
|
||||
|
||||
@Autowired
|
||||
private DeviceRealtimedataMoistureMapper deviceRealtimedataMoistureMapper;
|
||||
@ -45,7 +60,7 @@ public class DeviceDateTask {
|
||||
private DeviceRealtimedataMiaoqingMapper deviceRealtimedataMiaoqingMapper;
|
||||
|
||||
@Autowired
|
||||
private RenkeDeviceDataService wormsService; //虫情设备数据获取
|
||||
private RenkeWormDeviceDataService wormsService; //虫情设备数据获取
|
||||
|
||||
@Autowired
|
||||
private ZhanLianMetDataService metDataService; //气象设备数据获取
|
||||
@ -59,6 +74,24 @@ public class DeviceDateTask {
|
||||
@Autowired
|
||||
private ZhanLianMiaoQingDataService miaoQingDataService; //苗情设备数据获取
|
||||
|
||||
@Autowired
|
||||
private RenkeTargetpestsDeviceDataService targetpestsDeviceDataService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private DeviceInformationWormsMapper wormsMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceInformationMeteorologyMapper meteorologyMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceInformationMoistureMapper moistureMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceInformationMonitorMapper monitorMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceInformationTargetpestsMapper targetpestsMapper;
|
||||
|
||||
|
||||
|
||||
@ -66,36 +99,90 @@ public class DeviceDateTask {
|
||||
/**
|
||||
* 获取虫情设备实时数据并保存
|
||||
*/
|
||||
public void getWormsDeviceRealtimeData() throws Exception{
|
||||
|
||||
DeviceRealtimedataWorms deviceRealtimedataWorms = wormsService.setData("1017240042");
|
||||
int i = deviceRealtimedataWormsMapper.insert(deviceRealtimedataWorms);
|
||||
if (i<1){
|
||||
System.out.println("插入数据失败!");
|
||||
public void getWormsDeviceRealtimeData() {
|
||||
try{
|
||||
List<DeviceInformationWorms> list = new LambdaQueryChainWrapper<>(wormsMapper).select(DeviceInformationWorms::getDeviceEncoding).list();
|
||||
StringBuilder deviceAddrsStringBuilder= new StringBuilder("");
|
||||
for (DeviceInformationWorms worms : list) {
|
||||
deviceAddrsStringBuilder.append(worms.getDeviceEncoding());
|
||||
deviceAddrsStringBuilder.append(",");
|
||||
}
|
||||
//去除最后,
|
||||
StringBuilder stringBuilder = deviceAddrsStringBuilder.deleteCharAt(deviceAddrsStringBuilder.length() - 1);
|
||||
String deviceAddrs = stringBuilder.toString();
|
||||
List<DeviceRealtimedataWorms> deviceRealtimedataWorms = wormsService.setData(deviceAddrs);
|
||||
// int i = deviceRealtimedataWormsMapper.in(deviceRealtimedataWorms);
|
||||
boolean saved = wormsDataService.saveBatch(deviceRealtimedataWorms);
|
||||
if (!saved){
|
||||
System.out.println("插入数据失败!");
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
log.error("获取虫情设备实时数据失败",e);
|
||||
new LambdaUpdateChainWrapper<>(wormsMapper).eq(DeviceInformationWorms::getDeviceEncoding,"1017240042").set(DeviceInformationWorms::getStatus, 0).update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取气象设备实时数据并保存
|
||||
*/
|
||||
public void getDevLinkMetDeviceRealtimeData() throws Exception{
|
||||
DeviceRealtimedataMeteorology deviceRealtimedataMeteorology = metDataService.setData(metDataService.getDeviceRealTimeData("3269"));
|
||||
int i = deviceRealtimedataMeteorologyMapper.insert(deviceRealtimedataMeteorology);
|
||||
if (i<1){
|
||||
System.out.println("插入数据失败!");
|
||||
public void getDevLinkMetDeviceRealtimeData(){
|
||||
try{
|
||||
List<DeviceInformationMeteorology> list = new LambdaQueryChainWrapper<>(meteorologyMapper).select(DeviceInformationMeteorology::getDeviceEncoding).list();
|
||||
DeviceRealtimedataMeteorology deviceRealtimedataMeteorology = metDataService.setData(metDataService.getDeviceRealTimeData("3269"));
|
||||
boolean save = meteorologyDataService.save(deviceRealtimedataMeteorology);
|
||||
if (!save){
|
||||
System.out.println("插入数据失败!");
|
||||
}
|
||||
}
|
||||
catch (Exception e){
|
||||
log.error("获取气象设备实时数据失败",e);
|
||||
new LambdaUpdateChainWrapper<>(meteorologyMapper).eq(DeviceInformationMeteorology::getDeviceEncoding,"3269").set(DeviceInformationMeteorology::getStatus, 0).update();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* 获取墒情设备实时数据并保存
|
||||
*/
|
||||
public void getDevLinkMoistureDeviceRealtimeData() throws Exception{
|
||||
DeviceRealtimedataMoisture deviceRealtimedataMoisture = moistureDataService.setData(moistureDataService.getDeviceRealTimeData("3270"));
|
||||
DeviceRealtimedataMoisture deviceRealtimedataMoisture1 = moistureDataService.setData(moistureDataService.getDeviceRealTimeData("3271"));
|
||||
int i = deviceRealtimedataMoistureMapper.insert(deviceRealtimedataMoisture);
|
||||
int i1 = deviceRealtimedataMoistureMapper.insert(deviceRealtimedataMoisture1);
|
||||
if (i<1||i1<1)
|
||||
System.out.println("插入数据失败!");
|
||||
public void getDevLinkMoistureDeviceRealtimeData() {
|
||||
try{
|
||||
DeviceRealtimedataMoisture deviceRealtimedataMoisture = moistureDataService.setData(moistureDataService.getDeviceRealTimeData("3270"));
|
||||
DeviceRealtimedataMoisture deviceRealtimedataMoisture1 = moistureDataService.setData(moistureDataService.getDeviceRealTimeData("3271"));
|
||||
int i = deviceRealtimedataMoistureMapper.insert(deviceRealtimedataMoisture);
|
||||
int i1 = deviceRealtimedataMoistureMapper.insert(deviceRealtimedataMoisture1);
|
||||
if (i<1||i1<1)
|
||||
System.out.println("插入数据失败!");
|
||||
}
|
||||
catch (Exception e){
|
||||
log.error("获取墒情设备实时数据失败",e);
|
||||
new LambdaUpdateChainWrapper<>(moistureMapper).in(DeviceInformationMoisture::getDeviceEncoding,"3270","3271").set(DeviceInformationMoisture::getStatus, 0).update();
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取杀虫灯设备实时数据并保存
|
||||
*/
|
||||
public void getDevLinkTargetpestsDeviceRealtimeData() {
|
||||
try{
|
||||
//查询杀虫灯设备列表
|
||||
StringBuilder deviceAddrsStringBuilder= new StringBuilder("");
|
||||
List<DeviceInformationTargetpests> list = new LambdaQueryChainWrapper<>(targetpestsMapper).select(DeviceInformationTargetpests::getDeviceEncoding).list();
|
||||
for(DeviceInformationTargetpests targetpests:list){
|
||||
deviceAddrsStringBuilder.append(targetpests.getDeviceEncoding());
|
||||
deviceAddrsStringBuilder.append(",");
|
||||
}
|
||||
//去除最后,
|
||||
StringBuilder stringBuilder = deviceAddrsStringBuilder.deleteCharAt(deviceAddrsStringBuilder.length() - 1);
|
||||
String deviceAddrs = stringBuilder.toString();
|
||||
//拼接设备编码
|
||||
System.err.println("拼接后设备地址参数编码:"+deviceAddrs);
|
||||
targetpestsDeviceDataService.setData(deviceAddrs);
|
||||
}
|
||||
catch (Exception e){
|
||||
log.error("获取杀虫灯设备实时数据失败",e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user