引虫灯信息接口

This commit is contained in:
zhumeixiao 2024-11-19 13:12:06 +08:00
parent 921982ba70
commit 7ee2b1bba8
2 changed files with 7 additions and 39 deletions

View File

@ -4,12 +4,8 @@ package com.fastbee.deviceData.api.renke.constant;
* 建大仁科设备类型常量
*/
public class RenKeDeviceTypeConstant {
public static final String MET = "met";//气象设备
public static final String InsectsLights = "met";//引虫灯设备
public static final String WORM = "wormFlagship";//虫情设备
public static final String Irrigation = "irrigation";//灌溉
public static final String Worm = "worm";//蠕虫
public static final String Soil = "soil";//
public static final String Spore = "spore";//孢子
public static final String Camera = "camera";//照相机
}

View File

@ -29,49 +29,21 @@ public class RenKeUserDeviceOverview {
JSONObject respBody = JSONUtil.parseObj(resultObjectStr);
JSONArray realtimeDataList = JSONUtil.parseArray(respBody.get("data"));
Map<String,Integer> map = new HashMap<>();
/* Map<String, Integer> deviceTypeCountMap = realtimeDataList.stream()
.map(jsonObject -> (JSONObject) jsonObject)
.collect(Collectors.groupingBy(
e -> (String) e.get("deviceType"),
Collectors.summingInt(e -> 1)
));
Integer WORM = deviceTypeCountMap.getOrDefault(RenKeDeviceTypeConstant.WORM, 0);*/
//map = realtimeDataList.stream().collect(Collectors.groupingBy(obj -> ((JSONObject) obj).getStr("deviceType")));
Integer MET = 0;
Integer InsectsLights = 0;
Integer WORM = 0;
Integer Irrigation = 0;
Integer Worm = 0;
Integer Soil =0;
Integer Spore = 0;
Integer Camera = 0;
for (Object jsonObject : realtimeDataList) {
JSONObject josnConversion = (JSONObject) jsonObject;
if (RenKeDeviceTypeConstant.WORM.equals(josnConversion.get("deviceType"))) {
WORM=WORM+1;
} else if (RenKeDeviceTypeConstant.MET.equals(josnConversion.get("deviceType"))) {
MET=MET+1;
}else if (RenKeDeviceTypeConstant.Irrigation.equals(josnConversion.get("deviceType"))) {
Irrigation=Irrigation+1;
} else if (RenKeDeviceTypeConstant.Camera.equals(josnConversion.get("deviceType"))) {
Camera=Camera+1;
} else if (RenKeDeviceTypeConstant.Worm.equals(josnConversion.get("deviceType"))) {
Worm=Worm+1;
} else if (RenKeDeviceTypeConstant.Soil.equals(josnConversion.get("deviceType"))) {
Soil=Soil+1;
} else if (RenKeDeviceTypeConstant.Spore.equals(josnConversion.get("deviceType"))) {
Spore=Spore+1;
} else if (RenKeDeviceTypeConstant.InsectsLights.equals(josnConversion.get("deviceType"))) {
InsectsLights=InsectsLights+1;
}
}
// map.put("MET",MET);
// map.put("Worm",Worm);
// map.put("Irrigation",Irrigation);
// map.put("Camera",Camera);
map.put("InsectsLights",InsectsLights);
map.put("wormFlagship",WORM);
// map.put("Soil",Soil);
// map.put("Spore",Spore);
return map;
}
}