同步代码
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.common.holder.ProjectHolder;
|
||||||
import com.fastbee.deviceData.api.devlink.service.ZhanLianBaseService;
|
import com.fastbee.deviceData.api.devlink.service.ZhanLianBaseService;
|
||||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||||
|
import com.fastbee.deviceInfo.domain.*;
|
||||||
import com.fastbee.deviceInfo.manager.DeviceInformationManager;
|
import com.fastbee.deviceInfo.manager.DeviceInformationManager;
|
||||||
|
import com.fastbee.deviceInfo.mapper.*;
|
||||||
import com.fastbee.iot.domain.AlertLog;
|
import com.fastbee.iot.domain.AlertLog;
|
||||||
import com.fastbee.iot.domain.Device;
|
import com.fastbee.iot.domain.Device;
|
||||||
import com.fastbee.iot.mapper.AlertLogMapper;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.jws.Oneway;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -44,6 +47,21 @@ public class DeviceAlarmController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DeviceMapper deviceMapper;
|
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();
|
.count();
|
||||||
|
|
||||||
//统计设备离线数量
|
//统计设备离线数量
|
||||||
List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper)
|
// List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper)
|
||||||
.select(Device::getDeviceId,Device::getDeviceName,Device::getProductId,Device::getProductName,Device::getStatus,Device::getTenantId)
|
// .select(Device::getDeviceId,Device::getDeviceName,Device::getProductId,Device::getProductName,Device::getStatus,Device::getTenantId)
|
||||||
.eq(Device::getTenantId, ProjectHolder.getProjectInfo().getProjectAdminId())
|
// .eq(Device::getTenantId, ProjectHolder.getProjectInfo().getProjectAdminId())
|
||||||
.list();
|
// .list();
|
||||||
//循环统计状态值为4离线设备数量
|
// //循环统计状态值为4离线设备数量
|
||||||
int count1 = 0;
|
// int count1 = 0;
|
||||||
for (Device device : deviceList) {
|
// for (Device device : deviceList) {
|
||||||
if(device.getStatus()==4){
|
// if(device.getStatus()==4){
|
||||||
count1++;
|
// 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<>();
|
Map<String,Object> resp =new HashMap<>();
|
||||||
resp.put("alarmTotal",count);//告警总数
|
resp.put("alarmTotal",count);//告警总数
|
||||||
resp.put("securityLevel",getSecurityLevel(count));//安全等级
|
resp.put("securityLevel",getSecurityLevel(count));//安全等级
|
||||||
resp.put("offlineDeviceTotal",count1);//离线设备总数
|
resp.put("offlineDeviceTotal",offlineCount);//离线设备总数
|
||||||
return AjaxResult.success(resp);
|
return AjaxResult.success(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,69 +137,177 @@ public class DeviceAlarmController extends BaseController {
|
|||||||
@GetMapping("/onlineRate")
|
@GetMapping("/onlineRate")
|
||||||
public AjaxResult getDeviceOnlineRate(Device device) {
|
public AjaxResult getDeviceOnlineRate(Device device) {
|
||||||
|
|
||||||
List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper)
|
Map<String, Map<String, Object>> info = getAllTypeDeviceListAndStatusCount();
|
||||||
.select(Device::getDeviceId,Device::getDeviceName,Device::getProductId,Device::getProductName,Device::getStatus,Device::getTenantId)
|
//虫情设备信息
|
||||||
.eq(Device::getTenantId,device.getTenantId())
|
Map<String, Object> worm = info.get("worm");
|
||||||
.list();
|
//气象设备信息
|
||||||
// deviceList.forEach(System.err::println);
|
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 meteorologyDeviceCount = 0;//气象设备总量
|
||||||
int meteorologyDeviceOnLineCount = 0;//气象设备在线量
|
int meteorologyDeviceOnLineCount = 0;//气象设备在线量
|
||||||
|
int meteorologyDeviceOfflineCount=0;//气象设备离线量
|
||||||
double meteorologyDeviceOnlineRate = 0.0; //气象设备在线率
|
double meteorologyDeviceOnlineRate = 0.0; //气象设备在线率
|
||||||
|
|
||||||
int moistureDeviceCount = 0;//墒情设备总量
|
int moistureDeviceCount = 0;//墒情设备总量
|
||||||
int moistureDeviceOnLineCount = 0;//墒情设备在线量
|
int moistureDeviceOnLineCount = 0;//墒情设备在线量
|
||||||
|
int moistureDeviceOfflineCount=0;//墒情设备离线量
|
||||||
double moistureDeviceOnlineRate = 0.0; //墒情设备在线率
|
double moistureDeviceOnlineRate = 0.0; //墒情设备在线率
|
||||||
|
|
||||||
int wormDeviceCount = 0;//虫情设备总量
|
int wormDeviceCount = 0;//虫情设备总量
|
||||||
int wormDeviceOnLineCount = 0;//虫情设备在线量
|
int wormDeviceOnLineCount = 0;//虫情设备在线量
|
||||||
|
int wormDeviceOfflineCount=0;//虫情设备离线量
|
||||||
double wormDeviceOnlineRate = 0.0; //虫情设备在线率
|
double wormDeviceOnlineRate = 0.0; //虫情设备在线率
|
||||||
|
|
||||||
int miaoQingDeviceCount = 0;//苗情设备总量
|
int miaoQingDeviceCount = 0;//苗情设备总量
|
||||||
int miaoQingDeviceOnLineCount = 0;//苗情设备在线量
|
int miaoQingDeviceOnLineCount = 0;//苗情设备在线量
|
||||||
|
int miaoQingDeviceOfflineCount=0;//苗情设备离线量
|
||||||
double miaoQingDeviceOnlineRate = 0.0; //苗情设备在线率
|
double miaoQingDeviceOnlineRate = 0.0; //苗情设备在线率
|
||||||
|
|
||||||
int insecticidalLampDeviceCount = 0;//杀虫灯设备总量
|
int insecticidalLampDeviceCount = 0;//杀虫灯设备总量
|
||||||
int insecticidalLampDeviceOnLineCount = 0;//杀虫灯设备在线量
|
int insecticidalLampDeviceOnLineCount = 0;//杀虫灯设备在线量
|
||||||
|
int insecticidalLampDeviceOfflineCount=0;//杀虫灯设备离线量
|
||||||
double insecticidalLampDeviceOnlineRate = 0.0; //杀虫灯设备在线率
|
double insecticidalLampDeviceOnlineRate = 0.0; //杀虫灯设备在线率
|
||||||
|
|
||||||
int monitorDeviceCount = 0;//监控设备总量
|
int monitorDeviceCount = 0;//监控设备总量
|
||||||
int monitorDeviceOnLineCount = 0;//监控设备在线量
|
int monitorDeviceOnLineCount = 0;//监控设备在线量
|
||||||
|
int monitorDeviceOfflineCount=0;//监控设备离线量
|
||||||
double monitorDeviceOnlineRate = 0.0; //监控设备在线率
|
double monitorDeviceOnlineRate = 0.0; //监控设备在线率
|
||||||
|
|
||||||
for (Device d:deviceList) {
|
// List<Device> deviceList = new LambdaQueryChainWrapper<>(deviceMapper)
|
||||||
if (d.getProductName().equals("气象设备") || d.getProductId() == 144) {
|
// .select(Device::getDeviceId,Device::getDeviceName,Device::getProductId,Device::getProductName,Device::getStatus,Device::getTenantId)
|
||||||
meteorologyDeviceCount++;
|
// .eq(Device::getTenantId,device.getTenantId())
|
||||||
if (d.getStatus() == 3) {
|
// .list();
|
||||||
meteorologyDeviceOnLineCount++;
|
//// deviceList.forEach(System.err::println);
|
||||||
}
|
// for (Device d:deviceList) {
|
||||||
} else if (d.getProductName().equals("墒情设备") || d.getProductId() == 142) {
|
// if (d.getProductName().equals("气象设备") || d.getProductId() == 144) {
|
||||||
moistureDeviceCount++;
|
// meteorologyDeviceCount++;
|
||||||
if (d.getStatus() == 3) {
|
// if (d.getStatus() == 3) {
|
||||||
moistureDeviceOnLineCount++;
|
// meteorologyDeviceOnLineCount++;
|
||||||
}
|
// }
|
||||||
} else if (d.getProductName().equals("太阳能供电设备") || d.getProductId() == 138) {
|
// } else if (d.getProductName().equals("墒情设备") || d.getProductId() == 142) {
|
||||||
miaoQingDeviceCount++;
|
// moistureDeviceCount++;
|
||||||
if (d.getStatus() == 3) {
|
// if (d.getStatus() == 3) {
|
||||||
miaoQingDeviceOnLineCount++;
|
// moistureDeviceOnLineCount++;
|
||||||
}
|
// }
|
||||||
} else if (d.getProductName().equals("杀虫灯设备") || d.getProductId() == 145) {
|
// } else if (d.getProductName().equals("太阳能供电设备") || d.getProductId() == 138) {
|
||||||
insecticidalLampDeviceCount++;
|
// miaoQingDeviceCount++;
|
||||||
if (d.getStatus() == 3) {
|
// if (d.getStatus() == 3) {
|
||||||
insecticidalLampDeviceOnLineCount++;
|
// miaoQingDeviceOnLineCount++;
|
||||||
}
|
// }
|
||||||
} else if (d.getProductName().equals("虫情设备") || d.getProductId() == 143) {
|
// } else if (d.getProductName().equals("杀虫灯设备") || d.getProductId() == 145) {
|
||||||
wormDeviceCount++;
|
// insecticidalLampDeviceCount++;
|
||||||
if (d.getStatus() == 3) {
|
// if (d.getStatus() == 3) {
|
||||||
wormDeviceOnLineCount++;
|
// 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){
|
List<DeviceInformationWorms> wormList = new LambdaQueryChainWrapper<>(wormsMapper)
|
||||||
monitorDeviceOnLineCount++;
|
.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("气象设备总量:"+meteorologyDeviceCount);
|
||||||
System.out.println("气象设备在线量:"+meteorologyDeviceOnLineCount);
|
System.out.println("气象设备在线量:"+meteorologyDeviceOnLineCount);
|
||||||
@ -172,10 +320,10 @@ public class DeviceAlarmController extends BaseController {
|
|||||||
System.out.println("虫情设备总量:"+wormDeviceCount);
|
System.out.println("虫情设备总量:"+wormDeviceCount);
|
||||||
System.out.println("虫情设备在线量:"+wormDeviceOnLineCount);
|
System.out.println("虫情设备在线量:"+wormDeviceOnLineCount);
|
||||||
System.out.println("虫情设备在线率:"+wormDeviceOnlineRate);
|
System.out.println("虫情设备在线率:"+wormDeviceOnlineRate);
|
||||||
System.out.println("-------------------------------------------");
|
// System.out.println("-------------------------------------------");
|
||||||
System.out.println("苗情设备总量:"+miaoQingDeviceCount);
|
// System.out.println("苗情设备总量:"+miaoQingDeviceCount);
|
||||||
System.out.println("苗情设备在线量:"+miaoQingDeviceOnLineCount);
|
// System.out.println("苗情设备在线量:"+miaoQingDeviceOnLineCount);
|
||||||
System.out.println("苗情设备在线率:"+miaoQingDeviceOnlineRate);
|
// System.out.println("苗情设备在线率:"+miaoQingDeviceOnlineRate);
|
||||||
System.out.println("-------------------------------------------");
|
System.out.println("-------------------------------------------");
|
||||||
System.out.println("杀虫灯设备总量:"+insecticidalLampDeviceCount);
|
System.out.println("杀虫灯设备总量:"+insecticidalLampDeviceCount);
|
||||||
System.out.println("杀虫灯设备在线量:"+insecticidalLampDeviceOnLineCount);
|
System.out.println("杀虫灯设备在线量:"+insecticidalLampDeviceOnLineCount);
|
||||||
@ -185,33 +333,51 @@ public class DeviceAlarmController extends BaseController {
|
|||||||
System.out.println("监控设备在线量:"+monitorDeviceOnLineCount);
|
System.out.println("监控设备在线量:"+monitorDeviceOnLineCount);
|
||||||
System.out.println("监控设备在线率:"+monitorDeviceOnlineRate);
|
System.out.println("监控设备在线率:"+monitorDeviceOnlineRate);
|
||||||
System.out.println("-------------------------------------------");
|
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个以上报警
|
* 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 java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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.controller.BaseController;
|
||||||
import com.fastbee.common.core.domain.AjaxResult;
|
import com.fastbee.common.core.domain.AjaxResult;
|
||||||
import com.fastbee.common.enums.BusinessType;
|
|
||||||
import com.fastbee.deviceInfo.domain.DeviceInformationMeteorology;
|
import com.fastbee.deviceInfo.domain.DeviceInformationMeteorology;
|
||||||
import com.fastbee.deviceInfo.service.IDeviceInformationMeteorologyService;
|
import com.fastbee.deviceInfo.service.IDeviceInformationMeteorologyService;
|
||||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
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 java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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 java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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.controller.BaseController;
|
||||||
import com.fastbee.common.core.domain.AjaxResult;
|
import com.fastbee.common.core.domain.AjaxResult;
|
||||||
import com.fastbee.common.enums.BusinessType;
|
|
||||||
import com.fastbee.deviceInfo.domain.DeviceInformationMoisture;
|
import com.fastbee.deviceInfo.domain.DeviceInformationMoisture;
|
||||||
import com.fastbee.deviceInfo.service.IDeviceInformationMoistureService;
|
import com.fastbee.deviceInfo.service.IDeviceInformationMoistureService;
|
||||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
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 java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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.controller.BaseController;
|
||||||
import com.fastbee.common.core.domain.AjaxResult;
|
import com.fastbee.common.core.domain.AjaxResult;
|
||||||
import com.fastbee.common.enums.BusinessType;
|
|
||||||
import com.fastbee.deviceInfo.domain.DeviceInformationMonitor;
|
import com.fastbee.deviceInfo.domain.DeviceInformationMonitor;
|
||||||
import com.fastbee.deviceInfo.service.IDeviceInformationMonitorService;
|
import com.fastbee.deviceInfo.service.IDeviceInformationMonitorService;
|
||||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
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 java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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.controller.BaseController;
|
||||||
import com.fastbee.common.core.domain.AjaxResult;
|
import com.fastbee.common.core.domain.AjaxResult;
|
||||||
import com.fastbee.common.enums.BusinessType;
|
|
||||||
import com.fastbee.deviceInfo.domain.DeviceInformationTargetpests;
|
import com.fastbee.deviceInfo.domain.DeviceInformationTargetpests;
|
||||||
import com.fastbee.deviceInfo.service.IDeviceInformationTargetpestsService;
|
import com.fastbee.deviceInfo.service.IDeviceInformationTargetpestsService;
|
||||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
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 java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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.controller.BaseController;
|
||||||
import com.fastbee.common.core.domain.AjaxResult;
|
import com.fastbee.common.core.domain.AjaxResult;
|
||||||
import com.fastbee.common.enums.BusinessType;
|
|
||||||
import com.fastbee.deviceInfo.domain.DeviceInformationWorms;
|
import com.fastbee.deviceInfo.domain.DeviceInformationWorms;
|
||||||
import com.fastbee.deviceInfo.service.IDeviceInformationWormsService;
|
import com.fastbee.deviceInfo.service.IDeviceInformationWormsService;
|
||||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
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.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
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.page.TableDataInfo;
|
import com.fastbee.common.core.page.TableDataInfo;
|
||||||
import com.fastbee.deviceData.domain.*;
|
import com.fastbee.deviceData.domain.*;
|
||||||
import com.fastbee.deviceData.mapper.*;
|
import com.fastbee.deviceData.mapper.*;
|
||||||
import org.redisson.config.BaseConfig;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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.controller.BaseController;
|
||||||
import com.fastbee.common.core.domain.AjaxResult;
|
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.common.core.domain.AjaxResult;
|
||||||
import com.fastbee.deviceData.service.IDeviceRealtimedataMeteorologyService;
|
import com.fastbee.deviceData.service.IDeviceRealtimedataMeteorologyService;
|
||||||
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMeteorologyServiceImpl;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
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.common.core.domain.AjaxResult;
|
||||||
import com.fastbee.deviceData.domain.DeviceRealtimedataMoisture;
|
|
||||||
import com.fastbee.deviceData.service.IDeviceRealtimedataMoistureService;
|
import com.fastbee.deviceData.service.IDeviceRealtimedataMoistureService;
|
||||||
import com.fastbee.deviceData.service.impl.DeviceRealtimedataMoistureServiceImpl;
|
|
||||||
import com.fastbee.deviceInfo.service.IDeviceInformationMoistureService;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取墒情设备实时数据
|
||||||
|
*/
|
||||||
@RestController()
|
@RestController()
|
||||||
@RequestMapping("/moisture")
|
@RequestMapping("/moisture")
|
||||||
public class DeviceRealtimedataMoistureController {
|
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.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
import com.fastbee.common.core.domain.AjaxResult;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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.controller.BaseController;
|
||||||
import com.fastbee.common.core.domain.AjaxResult;
|
import com.fastbee.common.core.domain.AjaxResult;
|
||||||
import com.fastbee.deviceData.service.IDeviceRealtimedataMoistureService;
|
|
||||||
import com.fastbee.deviceData.service.impl.DeviceRealtimedataWormsServiceImpl;
|
import com.fastbee.deviceData.service.impl.DeviceRealtimedataWormsServiceImpl;
|
||||||
import com.fastbee.deviceInfo.service.IDeviceInformationMoistureService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取虫情设备实时数据
|
||||||
|
*/
|
||||||
@RestController()
|
@RestController()
|
||||||
@RequestMapping("/worms")
|
@RequestMapping("/worms")
|
||||||
public class DeviceRealtimedataWormsController extends BaseController {
|
public class DeviceRealtimedataWormsController extends BaseController {
|
@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 建大仁科气象设备服务
|
* 建大杀虫灯设备
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class RenkeMetDeviceService {
|
public class RenkeMetDeviceService {
|
||||||
@ -22,7 +22,7 @@ public class RenkeMetDeviceService {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取气象设备全部信息
|
* 获取杀虫灯设备全部信息
|
||||||
* @param deviceStr 设备地址,支持多个用英文逗号分隔
|
* @param deviceStr 设备地址,支持多个用英文逗号分隔
|
||||||
* @return JSONObject
|
* @return JSONObject
|
||||||
*/
|
*/
|
||||||
@ -38,7 +38,7 @@ public class RenkeMetDeviceService {
|
|||||||
return JSONUtil.parseObj(respBodyStr);
|
return JSONUtil.parseObj(respBodyStr);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 根据气象设备地址获取节点信息
|
* 根据杀虫灯设备地址获取节点信息
|
||||||
*/
|
*/
|
||||||
public JSONObject getAllInsectEquipmentInformation(String deviceAddr){
|
public JSONObject getAllInsectEquipmentInformation(String deviceAddr){
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public class RenkeMetDeviceService {
|
|||||||
return JSONUtil.parseObj(respBodyStr);
|
return JSONUtil.parseObj(respBodyStr);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 根据气象设备地址获取已启用的节点信息
|
* 根据杀虫灯设备地址获取已启用的节点信息
|
||||||
*/
|
*/
|
||||||
public JSONObject listTargetEnabledNode(String deviceAddr){
|
public JSONObject listTargetEnabledNode(String deviceAddr){
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public class RenkeMetDeviceService {
|
|||||||
return JSONUtil.parseObj(respBodyStr);
|
return JSONUtil.parseObj(respBodyStr);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 根据气象节点编号获取遥调信息
|
* 根据杀虫灯节点编号获取遥调信息
|
||||||
*/
|
*/
|
||||||
public JSONObject listTargetEnabledNode(String deviceAddr,String nodeId){
|
public JSONObject listTargetEnabledNode(String deviceAddr,String nodeId){
|
||||||
// 请求基础URL
|
// 请求基础URL
|
||||||
@ -95,7 +95,7 @@ public class RenkeMetDeviceService {
|
|||||||
return JSONUtil.parseObj(respBodyStr);
|
return JSONUtil.parseObj(respBodyStr);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 修改指定气象设备全部节点的可用状态
|
* 修改指定杀虫灯设备全部节点的可用状态
|
||||||
*/
|
*/
|
||||||
public JSONObject updateAllOfNodesEnable(String deviceAddr,String enable){
|
public JSONObject updateAllOfNodesEnable(String deviceAddr,String enable){
|
||||||
// 请求基础URL
|
// 请求基础URL
|
||||||
@ -121,7 +121,7 @@ public class RenkeMetDeviceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改气象设备信息
|
* 修改杀虫灯设备信息
|
||||||
*/
|
*/
|
||||||
public JSONObject updateDevice(UpdateDevice updateDevice){
|
public JSONObject updateDevice(UpdateDevice updateDevice){
|
||||||
//获取设备实时数据
|
//获取设备实时数据
|
||||||
@ -137,7 +137,7 @@ public class RenkeMetDeviceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新气象节点信息
|
* 更新杀虫灯节点信息
|
||||||
*/
|
*/
|
||||||
public JSONObject updateNodeInfo(UpdateNodeInfo updateNodeInfo){
|
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 cn.hutool.json.JSONUtil;
|
||||||
import com.fastbee.common.exception.ServiceException;
|
import com.fastbee.common.exception.ServiceException;
|
||||||
import com.fastbee.common.utils.DateUtils;
|
import com.fastbee.common.utils.DateUtils;
|
||||||
import com.fastbee.common.utils.date.DateTimeCalculationUtils;
|
|
||||||
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class RenkeDeviceDataService {
|
public class RenkeWormDeviceDataService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RenKeAuthorizationService authenticationService;
|
private RenKeAuthorizationService authenticationService;
|
||||||
@ -29,8 +27,9 @@ public class RenkeDeviceDataService {
|
|||||||
* 获取设备实时数据
|
* 获取设备实时数据
|
||||||
* @param deviceAddrs 设备地址,支持多个用英文逗号分隔
|
* @param deviceAddrs 设备地址,支持多个用英文逗号分隔
|
||||||
*/
|
*/
|
||||||
public DeviceRealtimedataWorms setData(String deviceAddrs) {
|
public List<DeviceRealtimedataWorms> setData(String deviceAddrs) {
|
||||||
DeviceRealtimedataWorms deviceRealtimedataWorms= new DeviceRealtimedataWorms();
|
List<DeviceRealtimedataWorms> dataList =new ArrayList<>();
|
||||||
|
|
||||||
//处理鉴权
|
//处理鉴权
|
||||||
String token = authenticationService.getToken();
|
String token = authenticationService.getToken();
|
||||||
// String token = new RenKeAuthorizationService().getToken();
|
// String token = new RenKeAuthorizationService().getToken();
|
||||||
@ -48,22 +47,24 @@ public class RenkeDeviceDataService {
|
|||||||
throw new ServiceException("获取设备实时数据失败!");
|
throw new ServiceException("获取设备实时数据失败!");
|
||||||
}
|
}
|
||||||
JSONArray realtimeDataList = JSONUtil.parseArray(respBody.get("data"));
|
JSONArray realtimeDataList = JSONUtil.parseArray(respBody.get("data"));
|
||||||
JSONObject jsonObject = JSONUtil.parseObj(realtimeDataList.get(0));
|
realtimeDataList.forEach(o -> {
|
||||||
JSONObject jsonObject1 = JSONUtil.parseObj(jsonObject.get("data"));
|
DeviceRealtimedataWorms deviceRealtimedataWorms= new DeviceRealtimedataWorms();
|
||||||
//获取实时时间
|
JSONObject dataObj = JSONUtil.parseObj(o);
|
||||||
String realTime = jsonObject1.get("DTime").toString();
|
JSONObject jsonObject1 = JSONUtil.parseObj(dataObj .get("data"));
|
||||||
//反序列化封装基础数据
|
//获取实时时间
|
||||||
deviceRealtimedataWorms = JSONUtil.toBean(jsonObject1, DeviceRealtimedataWorms.class);
|
String realTime = jsonObject1.get("DTime").toString();
|
||||||
//获取虫情设备关键数据
|
//反序列化封装基础数据
|
||||||
HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/worm/deviceData/getWormDataAndWormDataAIBy?deviceAddr="+deviceAddrs)
|
deviceRealtimedataWorms = JSONUtil.toBean(jsonObject1, DeviceRealtimedataWorms.class);
|
||||||
.header("token", token)
|
//获取虫情设备关键数据
|
||||||
|
HttpResponse response1 = HttpRequest.get("http://api.farm.0531yun.cn/api/v2.0/worm/deviceData/getWormDataAndWormDataAIBy?deviceAddr="+deviceAddrs)
|
||||||
|
.header("token", token)
|
||||||
// .form( "deviceAddr", 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();
|
||||||
|
|
||||||
// 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/getWormDataList")
|
||||||
// .header("token", token)
|
// .header("token", token)
|
||||||
@ -76,20 +77,20 @@ public class RenkeDeviceDataService {
|
|||||||
// .execute();
|
// .execute();
|
||||||
|
|
||||||
|
|
||||||
String respBodyStr1 = response1.body();
|
String respBodyStr1 = response1.body();
|
||||||
|
|
||||||
JSONObject respBody1 = JSONUtil.parseObj(respBodyStr1);
|
JSONObject respBody1 = JSONUtil.parseObj(respBodyStr1);
|
||||||
// System.err.println(respBodyStr1);
|
// System.err.println(respBodyStr1);
|
||||||
if(!respBody1.get("code") .toString().equals("1000")) {
|
if(!respBody1.get("code") .toString().equals("1000")) {
|
||||||
throw new RuntimeException("获取设备实时数据失败!");
|
throw new RuntimeException("获取设备实时数据失败!");
|
||||||
}
|
}
|
||||||
System.err.println(respBody1);
|
System.err.println(respBody1);
|
||||||
JSONArray jsonArray = JSONUtil.parseArray(respBody1.get("data"));
|
JSONArray jsonArray = JSONUtil.parseArray(respBody1.get("data"));
|
||||||
JSONObject entries = JSONUtil.parseObj(jsonArray.get(0));
|
JSONObject entries = JSONUtil.parseObj(jsonArray.get(0));
|
||||||
|
|
||||||
//获取害虫种类以及数量
|
//获取害虫种类以及数量
|
||||||
JSONArray analyseData = JSONUtil.parseArray(entries.get("analyseData"));
|
JSONArray analyseData = JSONUtil.parseArray(entries.get("analyseData"));
|
||||||
//有害虫时保存
|
//有害虫时保存
|
||||||
// if(!analyseData.isEmpty()){
|
// if(!analyseData.isEmpty()){
|
||||||
//获取拍照图片
|
//获取拍照图片
|
||||||
Object imagesUrl = entries .get("imagesUrl");
|
Object imagesUrl = entries .get("imagesUrl");
|
||||||
@ -100,16 +101,22 @@ public class RenkeDeviceDataService {
|
|||||||
deviceRealtimedataWorms.setCamera(imagesUrl.toString());
|
deviceRealtimedataWorms.setCamera(imagesUrl.toString());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
deviceRealtimedataWorms.setSaveTime(DateUtils.getNowDate());
|
deviceRealtimedataWorms.setSaveTime(DateUtils.getNowDate());
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
try {
|
try {
|
||||||
Date date = sdf.parse(realTime);
|
Date date = sdf.parse(realTime);
|
||||||
deviceRealtimedataWorms.setRealTime(date);
|
deviceRealtimedataWorms.setRealTime(date);
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
throw new ServiceException("时间格式转换失败!");
|
throw new ServiceException("时间格式转换失败!");
|
||||||
}
|
}
|
||||||
System.err.println("虫情设备实时数据:"+deviceRealtimedataWorms);
|
System.err.println("虫情设备实时数据:"+deviceRealtimedataWorms);
|
||||||
return 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.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.fastbee.deviceData.domain.DeviceRealtimedataMeteorology;
|
import com.fastbee.deviceData.domain.DeviceRealtimedataMeteorology;
|
||||||
|
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,7 +14,7 @@ import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
|||||||
* @author kerwincui
|
* @author kerwincui
|
||||||
* @date 2024-11-14
|
* @date 2024-11-14
|
||||||
*/
|
*/
|
||||||
public interface IDeviceRealtimedataMeteorologyService
|
public interface IDeviceRealtimedataMeteorologyService extends IService<DeviceRealtimedataMeteorology>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 查询气象设备实时数据
|
* 查询气象设备实时数据
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.fastbee.deviceData.service;
|
package com.fastbee.deviceData.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.fastbee.deviceData.domain.DeviceRealtimedataMoisture;
|
import com.fastbee.deviceData.domain.DeviceRealtimedataMoisture;
|
||||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||||
|
|
||||||
@ -10,7 +12,7 @@ import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
|||||||
* @author kerwincui
|
* @author kerwincui
|
||||||
* @date 2024-11-14
|
* @date 2024-11-14
|
||||||
*/
|
*/
|
||||||
public interface IDeviceRealtimedataMoistureService
|
public interface IDeviceRealtimedataMoistureService extends IService<DeviceRealtimedataMoisture>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 查询墒情实时数据
|
* 查询墒情实时数据
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.fastbee.deviceData.service;
|
package com.fastbee.deviceData.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
@ -13,7 +15,7 @@ import org.apache.ibatis.annotations.Select;
|
|||||||
* @date 2024-11-14
|
* @date 2024-11-14
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@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.Wrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
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.common.utils.DateUtils;
|
||||||
|
import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
||||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||||
|
import com.fastbee.deviceData.mapper.DeviceRealtimedataWormsMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.fastbee.deviceData.mapper.DeviceRealtimedataMeteorologyMapper;
|
import com.fastbee.deviceData.mapper.DeviceRealtimedataMeteorologyMapper;
|
||||||
@ -19,7 +22,7 @@ import com.fastbee.deviceData.service.IDeviceRealtimedataMeteorologyService;
|
|||||||
* @date 2024-11-14
|
* @date 2024-11-14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DeviceRealtimedataMeteorologyServiceImpl implements IDeviceRealtimedataMeteorologyService
|
public class DeviceRealtimedataMeteorologyServiceImpl extends ServiceImpl<DeviceRealtimedataMeteorologyMapper, DeviceRealtimedataMeteorology> implements IDeviceRealtimedataMeteorologyService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceRealtimedataMeteorologyMapper deviceRealtimedataMeteorologyMapper;
|
private DeviceRealtimedataMeteorologyMapper deviceRealtimedataMeteorologyMapper;
|
||||||
|
@ -3,6 +3,7 @@ package com.fastbee.deviceData.service.impl;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -17,7 +18,7 @@ import com.fastbee.deviceData.service.IDeviceRealtimedataMoistureService;
|
|||||||
* @date 2024-11-14
|
* @date 2024-11-14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DeviceRealtimedataMoistureServiceImpl implements IDeviceRealtimedataMoistureService
|
public class DeviceRealtimedataMoistureServiceImpl extends ServiceImpl<DeviceRealtimedataMoistureMapper,DeviceRealtimedataMoisture> implements IDeviceRealtimedataMoistureService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceRealtimedataMoistureMapper deviceRealtimedataMoistureMapper;
|
private DeviceRealtimedataMoistureMapper deviceRealtimedataMoistureMapper;
|
||||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
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.DeviceRealtimedataMoisture;
|
||||||
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
import com.fastbee.deviceData.domain.dto.DeviceProperties;
|
||||||
import com.fastbee.deviceData.service.IDeviceRealtimedataWormsService;
|
import com.fastbee.deviceData.service.IDeviceRealtimedataWormsService;
|
||||||
@ -22,7 +23,7 @@ import com.fastbee.deviceData.domain.DeviceRealtimedataWorms;
|
|||||||
* @date 2024-11-07
|
* @date 2024-11-07
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DeviceRealtimedataWormsServiceImpl implements IDeviceRealtimedataWormsService
|
public class DeviceRealtimedataWormsServiceImpl extends ServiceImpl<DeviceRealtimedataWormsMapper, DeviceRealtimedataWorms> implements IDeviceRealtimedataWormsService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceRealtimedataWormsMapper deviceRealtimedataWormsMapper;
|
private DeviceRealtimedataWormsMapper deviceRealtimedataWormsMapper;
|
||||||
|
@ -88,5 +88,9 @@ private static final long serialVersionUID = 1L;
|
|||||||
|
|
||||||
/** 删除标志(0代表存在,2代表删除) */
|
/** 删除标志(0代表存在,2代表删除) */
|
||||||
private Integer delFlag;
|
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代表删除) */
|
/** 删除标志(0代表存在,2代表删除) */
|
||||||
private Integer delFlag;
|
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代表删除) */
|
/** 删除标志(0代表存在,2代表删除) */
|
||||||
private Integer delFlag;
|
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("名称")
|
@ApiModelProperty("名称")
|
||||||
private String name;
|
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代表删除) */
|
/** 删除标志(0代表存在,2代表删除) */
|
||||||
private Integer delFlag;
|
private Integer delFlag;
|
||||||
|
/** 状态1在线,0离线 */
|
||||||
|
@Excel(name = "状态1在线,0离线")
|
||||||
|
@ApiModelProperty("状态1在线,0离线")
|
||||||
|
private Long status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,37 @@
|
|||||||
package com.fastbee.iot.timer;
|
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.ZhanLianMetDataService;
|
||||||
import com.fastbee.deviceData.api.devlink.service.ZhanLianMiaoQingDataService;
|
import com.fastbee.deviceData.api.devlink.service.ZhanLianMiaoQingDataService;
|
||||||
import com.fastbee.deviceData.api.devlink.service.ZhanLianMoistureDataService;
|
import com.fastbee.deviceData.api.devlink.service.ZhanLianMoistureDataService;
|
||||||
import com.fastbee.deviceData.api.devlink.service.ZhanLianPhotovoltaicDataService;
|
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.domain.*;
|
||||||
|
|
||||||
import com.fastbee.deviceData.mapper.*;
|
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 com.fastbee.iot.mapper.DeviceMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author mijiupro
|
* @author mijiupro
|
||||||
*/
|
*/
|
||||||
@Component("agricultureDeviceDateTask")
|
@Component("agricultureDeviceDateTask")
|
||||||
|
@Slf4j
|
||||||
public class DeviceDateTask {
|
public class DeviceDateTask {
|
||||||
//
|
//
|
||||||
|
|
||||||
@ -30,10 +45,10 @@ public class DeviceDateTask {
|
|||||||
private DeviceMapper deviceMapper;
|
private DeviceMapper deviceMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceRealtimedataWormsMapper deviceRealtimedataWormsMapper;
|
private DeviceRealtimedataWormsServiceImpl wormsDataService;//虫情
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceRealtimedataMeteorologyMapper deviceRealtimedataMeteorologyMapper;
|
private DeviceRealtimedataMeteorologyServiceImpl meteorologyDataService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceRealtimedataMoistureMapper deviceRealtimedataMoistureMapper;
|
private DeviceRealtimedataMoistureMapper deviceRealtimedataMoistureMapper;
|
||||||
@ -45,7 +60,7 @@ public class DeviceDateTask {
|
|||||||
private DeviceRealtimedataMiaoqingMapper deviceRealtimedataMiaoqingMapper;
|
private DeviceRealtimedataMiaoqingMapper deviceRealtimedataMiaoqingMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RenkeDeviceDataService wormsService; //虫情设备数据获取
|
private RenkeWormDeviceDataService wormsService; //虫情设备数据获取
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ZhanLianMetDataService metDataService; //气象设备数据获取
|
private ZhanLianMetDataService metDataService; //气象设备数据获取
|
||||||
@ -59,6 +74,24 @@ public class DeviceDateTask {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ZhanLianMiaoQingDataService miaoQingDataService; //苗情设备数据获取
|
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{
|
public void getWormsDeviceRealtimeData() {
|
||||||
|
try{
|
||||||
DeviceRealtimedataWorms deviceRealtimedataWorms = wormsService.setData("1017240042");
|
List<DeviceInformationWorms> list = new LambdaQueryChainWrapper<>(wormsMapper).select(DeviceInformationWorms::getDeviceEncoding).list();
|
||||||
int i = deviceRealtimedataWormsMapper.insert(deviceRealtimedataWorms);
|
StringBuilder deviceAddrsStringBuilder= new StringBuilder("");
|
||||||
if (i<1){
|
for (DeviceInformationWorms worms : list) {
|
||||||
System.out.println("插入数据失败!");
|
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{
|
public void getDevLinkMetDeviceRealtimeData(){
|
||||||
DeviceRealtimedataMeteorology deviceRealtimedataMeteorology = metDataService.setData(metDataService.getDeviceRealTimeData("3269"));
|
try{
|
||||||
int i = deviceRealtimedataMeteorologyMapper.insert(deviceRealtimedataMeteorology);
|
List<DeviceInformationMeteorology> list = new LambdaQueryChainWrapper<>(meteorologyMapper).select(DeviceInformationMeteorology::getDeviceEncoding).list();
|
||||||
if (i<1){
|
DeviceRealtimedataMeteorology deviceRealtimedataMeteorology = metDataService.setData(metDataService.getDeviceRealTimeData("3269"));
|
||||||
System.out.println("插入数据失败!");
|
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{
|
public void getDevLinkMoistureDeviceRealtimeData() {
|
||||||
DeviceRealtimedataMoisture deviceRealtimedataMoisture = moistureDataService.setData(moistureDataService.getDeviceRealTimeData("3270"));
|
try{
|
||||||
DeviceRealtimedataMoisture deviceRealtimedataMoisture1 = moistureDataService.setData(moistureDataService.getDeviceRealTimeData("3271"));
|
DeviceRealtimedataMoisture deviceRealtimedataMoisture = moistureDataService.setData(moistureDataService.getDeviceRealTimeData("3270"));
|
||||||
int i = deviceRealtimedataMoistureMapper.insert(deviceRealtimedataMoisture);
|
DeviceRealtimedataMoisture deviceRealtimedataMoisture1 = moistureDataService.setData(moistureDataService.getDeviceRealTimeData("3271"));
|
||||||
int i1 = deviceRealtimedataMoistureMapper.insert(deviceRealtimedataMoisture1);
|
int i = deviceRealtimedataMoistureMapper.insert(deviceRealtimedataMoisture);
|
||||||
if (i<1||i1<1)
|
int i1 = deviceRealtimedataMoistureMapper.insert(deviceRealtimedataMoisture1);
|
||||||
System.out.println("插入数据失败!");
|
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