From 7ee2b1bba8982bd875454aa6bfdc0e7c63c4cd19 Mon Sep 17 00:00:00 2001 From: zhumeixiao <3313492479@qq.com> Date: Tue, 19 Nov 2024 13:12:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E8=99=AB=E7=81=AF=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/RenKeDeviceTypeConstant.java | 8 +--- .../service/RenKeUserDeviceOverview.java | 38 +++---------------- 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/fastbee-service/fastbee-device-service/src/main/java/com/fastbee/deviceData/api/renke/constant/RenKeDeviceTypeConstant.java b/fastbee-service/fastbee-device-service/src/main/java/com/fastbee/deviceData/api/renke/constant/RenKeDeviceTypeConstant.java index e06a366..423b833 100644 --- a/fastbee-service/fastbee-device-service/src/main/java/com/fastbee/deviceData/api/renke/constant/RenKeDeviceTypeConstant.java +++ b/fastbee-service/fastbee-device-service/src/main/java/com/fastbee/deviceData/api/renke/constant/RenKeDeviceTypeConstant.java @@ -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";//照相机 + } diff --git a/fastbee-service/fastbee-device-service/src/main/java/com/fastbee/deviceData/api/renke/service/RenKeUserDeviceOverview.java b/fastbee-service/fastbee-device-service/src/main/java/com/fastbee/deviceData/api/renke/service/RenKeUserDeviceOverview.java index 8ccbb12..ec1cbfe 100644 --- a/fastbee-service/fastbee-device-service/src/main/java/com/fastbee/deviceData/api/renke/service/RenKeUserDeviceOverview.java +++ b/fastbee-service/fastbee-device-service/src/main/java/com/fastbee/deviceData/api/renke/service/RenKeUserDeviceOverview.java @@ -29,49 +29,21 @@ public class RenKeUserDeviceOverview { JSONObject respBody = JSONUtil.parseObj(resultObjectStr); JSONArray realtimeDataList = JSONUtil.parseArray(respBody.get("data")); Map map = new HashMap<>(); - -/* Map 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; } + }