From 9213e44988f21102690e1da756e4382260c5d1b6 Mon Sep 17 00:00:00 2001 From: wyw <373811525@qq.com> Date: Fri, 13 Sep 2024 19:37:41 +0800 Subject: [PATCH] =?UTF-8?q?1/device/detail/gongdianChart=E3=80=82=E4=BE=9B?= =?UTF-8?q?=E7=94=B5=E5=9B=BE=E8=A1=A8=E6=95=B0=E6=8D=AE=E9=9C=80=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=202/=E5=9C=B0=E5=9B=BE=E5=AE=9E=E6=97=B6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DeviceDetailServiceImpl.java | 3 +- .../gis/impl/GisDeviceServiceImpl.java | 478 ++++++++++-------- .../iot/service/impl/DeviceServiceImpl.java | 3 + .../resources/mapper/iot/DeviceLogMapper.xml | 3 + 4 files changed, 279 insertions(+), 208 deletions(-) diff --git a/fastbee-open-api/src/main/java/com/fastbee/data/service/devicedetail/impl/DeviceDetailServiceImpl.java b/fastbee-open-api/src/main/java/com/fastbee/data/service/devicedetail/impl/DeviceDetailServiceImpl.java index b308000..287b90c 100644 --- a/fastbee-open-api/src/main/java/com/fastbee/data/service/devicedetail/impl/DeviceDetailServiceImpl.java +++ b/fastbee-open-api/src/main/java/com/fastbee/data/service/devicedetail/impl/DeviceDetailServiceImpl.java @@ -113,7 +113,8 @@ public class DeviceDetailServiceImpl implements IDeviceDetailService { if (taiyangnengIds == null) { return new ArrayList<>(); } - ArrayList deviceLogAllCurves = iDeviceService.getDeviceLogAllCurves(Long.parseLong(taiyangnengIds), queryLogVo.getStartTime(), queryLogVo.getEndTime()); + ArrayList deviceLogAllCurves = + iDeviceService.getDeviceLogAllCurves(Long.parseLong(taiyangnengIds), queryLogVo.getStartTime(), queryLogVo.getEndTime()); return deviceLogAllCurves; } diff --git a/fastbee-open-api/src/main/java/com/fastbee/data/service/gis/impl/GisDeviceServiceImpl.java b/fastbee-open-api/src/main/java/com/fastbee/data/service/gis/impl/GisDeviceServiceImpl.java index 5d06d58..5d30f59 100644 --- a/fastbee-open-api/src/main/java/com/fastbee/data/service/gis/impl/GisDeviceServiceImpl.java +++ b/fastbee-open-api/src/main/java/com/fastbee/data/service/gis/impl/GisDeviceServiceImpl.java @@ -131,93 +131,118 @@ public class GisDeviceServiceImpl implements IGisDeviceService { List taiyangnengModels = thingsModelService.selectThingsModelList(thingsModel1); taiyangnengModels.sort(Comparator.comparing(ThingsModel::getModelOrder)); if (StringUtils.isNotEmpty(taiyangnengIds)) { - Device taiyangnengDevice = deviceMapper.selectDeviceByDeviceId(Long.parseLong(taiyangnengIds)); - List deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{ - setSerialNumber(taiyangnengDevice.getSerialNumber()); - setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, -1)).toString()); - setEndTime(DateUtil.endOfDay(dateTime).toString()); - }}); - Map> taiyangnengCollect = deviceLogs.stream().sorted(Comparator - .comparing(DeviceLog::getCreateTime, Comparator - .nullsFirst(Comparator.naturalOrder())).reversed()).collect(Collectors.groupingBy(t -> t.getIdentity())); - for (ThingsModel thingsModel : taiyangnengModels) { - if (thingsModel.getModelName().equals("市电状态")) { - List deviceLogs1 = taiyangnengCollect.get(thingsModel.getIdentifier()); - HashMap hashMap = new HashMap() {{ - put("upType", 0); - put("identifier", thingsModel.getIdentifier()); - put("unit", ""); - put("value", "市电"); - put("name", thingsModel.getModelName()); - }}; - if (deviceLogs1.size() > 0) { - if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) { - if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == 1f) { - hashMap.put("value", "市电"); - } else { - hashMap.put("value", "太阳能"); - } +// Device taiyangnengDevice = deviceMapper.selectDeviceByDeviceId(Long.parseLong(taiyangnengIds)); + CommonResult cache = haiWeiService.getCache(Long.parseLong(taiyangnengIds)); + if(cache != null){ + HaiWeiDeviceInfoVo checkedData = cache.getCheckedData(); + if(checkedData != null){ + List propertyList = checkedData.getPropertyList(); + for (HaiWeiPropertyVo haiWeiPropertyVo : propertyList) { +// if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_kaixian")){ +// continue; +// } + HashMap hashMap = new HashMap() {{ + put("upType", 0); + put("identifier", haiWeiPropertyVo.getNameEn()); + put("unit", haiWeiPropertyVo.getUnit()); + put("value", StringUtils.isEmpty(haiWeiPropertyVo.getValue().toString())? + "--":haiWeiPropertyVo.getValue().toString()); + put("name", haiWeiPropertyVo.getNameCn()); + }}; + if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_MpptDown")){ + hashMap.put("value", NumberUtils.isNumeric(haiWeiPropertyVo.getValue().toString())?( + Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?"正常":"异常"):"正常"); + }else if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_市电状态")){ + hashMap.put("value", NumberUtils.isNumeric(haiWeiPropertyVo.getValue().toString())?( + Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?"市电":"太阳能"):"市电"); } + rMap.put(haiWeiPropertyVo.getNameEn(), hashMap); } - rMap.put(thingsModel.getIdentifier(), hashMap); - } else { - HashMap hashMap = new HashMap() {{ - put("upType", 0); - put("identifier", thingsModel.getIdentifier()); - put("unit", ""); - put("value", 0); - put("name", thingsModel.getModelName()); - }}; - if (StringUtils.isNotEmpty(thingsModel.getSpecs())) { - String specs = thingsModel.getSpecs(); - JSONObject parse = (JSONObject) JSON.parse(specs); - if (parse.containsKey("unit")) { - hashMap.put("unit", parse.get("unit")); - } - } - - if (hashMap.size() > 1) { - List deviceLogs1 = taiyangnengCollect.get(thingsModel.getIdentifier()); - if (deviceLogs1 != null) { - if (deviceLogs1.size() > 0) { - if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) { - if (deviceLogs1.size() > 1) { - try{ - if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == Float.parseFloat(deviceLogs1.get(1).getLogValue())) { - hashMap.put("upType", 1); - } else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) { - hashMap.put("upType", -1); - } - }catch (Exception e){ - hashMap.put("upType", 0); - } - } else { - hashMap.put("upType", 0); - } - hashMap.put("value", deviceLogs1.get(0).getLogValue()); - } else { - hashMap.put("value", "--"); - hashMap.put("upType", 0); - } - - } else { - hashMap.put("value", "--"); - hashMap.put("upType", 0); - } - - - } - } else if (hashMap.size() > 0) { - List deviceLogs2 = taiyangnengCollect.get(thingsModel.getIdentifier()); - if (deviceLogs2 != null) { - hashMap.put("value", deviceLogs2.get(0).getLogValue()); - } - } - rMap.put(thingsModel.getIdentifier(), hashMap); } - - } +// List deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{ +// setSerialNumber(taiyangnengDevice.getSerialNumber()); +// setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, -1)).toString()); +// setEndTime(DateUtil.endOfDay(dateTime).toString()); +// }}); +// Map> taiyangnengCollect = deviceLogs.stream().sorted(Comparator +// .comparing(DeviceLog::getCreateTime, Comparator +// .nullsFirst(Comparator.naturalOrder())).reversed()).collect(Collectors.groupingBy(t -> t.getIdentity())); +// for (ThingsModel thingsModel : taiyangnengModels) { +// if (thingsModel.getModelName().equals("市电状态")) { +// List deviceLogs1 = taiyangnengCollect.get(thingsModel.getIdentifier()); +// HashMap hashMap = new HashMap() {{ +// put("upType", 0); +// put("identifier", thingsModel.getIdentifier()); +// put("unit", ""); +// put("value", "市电"); +// put("name", thingsModel.getModelName()); +// }}; +// if (deviceLogs1.size() > 0) { +// if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) { +// if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == 1f) { +// hashMap.put("value", "市电"); +// } else { +// hashMap.put("value", "太阳能"); +// } +// } +// } +// rMap.put(thingsModel.getIdentifier(), hashMap); +// } else { +// HashMap hashMap = new HashMap() {{ +// put("upType", 0); +// put("identifier", thingsModel.getIdentifier()); +// put("unit", ""); +// put("value", 0); +// put("name", thingsModel.getModelName()); +// }}; +// if (StringUtils.isNotEmpty(thingsModel.getSpecs())) { +// String specs = thingsModel.getSpecs(); +// JSONObject parse = (JSONObject) JSON.parse(specs); +// if (parse.containsKey("unit")) { +// hashMap.put("unit", parse.get("unit")); +// } +// } +// if (hashMap.size() > 1) { +// List deviceLogs1 = taiyangnengCollect.get(thingsModel.getIdentifier()); +// if (deviceLogs1 != null) { +// if (deviceLogs1.size() > 0) { +// if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) { +// if (deviceLogs1.size() > 1) { +// try{ +// if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == Float.parseFloat(deviceLogs1.get(1).getLogValue())) { +// hashMap.put("upType", 1); +// } else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) { +// hashMap.put("upType", -1); +// } +// }catch (Exception e){ +// hashMap.put("upType", 0); +// } +// } else { +// hashMap.put("upType", 0); +// } +// hashMap.put("value", deviceLogs1.get(0).getLogValue()); +// } else { +// hashMap.put("value", "--"); +// hashMap.put("upType", 0); +// } +// +// } else { +// hashMap.put("value", "--"); +// hashMap.put("upType", 0); +// } +// +// +// } +// } else if (hashMap.size() > 0) { +// List deviceLogs2 = taiyangnengCollect.get(thingsModel.getIdentifier()); +// if (deviceLogs2 != null) { +// hashMap.put("value", deviceLogs2.get(0).getLogValue()); +// } +// } +// rMap.put(thingsModel.getIdentifier(), hashMap); +// } +// } } else { for (ThingsModel thingsModel : taiyangnengModels) { HashMap hashMap = new HashMap() {{ @@ -242,7 +267,8 @@ public class GisDeviceServiceImpl implements IGisDeviceService { put("upType", 0); put("identifier", "xiangmen"); put("unit", ""); - put("value", haiWeiPropertyVo.getValue()); + put("value", StringUtils.isEmpty(haiWeiPropertyVo.getValue().toString())? + "--":haiWeiPropertyVo.getValue().toString()); put("name", haiWeiPropertyVo.getNameCn()); }}; rMap.put("xiangmen", hashMap1); @@ -285,131 +311,169 @@ public class GisDeviceServiceImpl implements IGisDeviceService { thingsModel2.setProductId(139L); List liuliangModels = thingsModelService.selectThingsModelList(thingsModel2); if (StringUtils.isNotEmpty(liuliangModels)) { - Device liuliangDevice = deviceMapper.selectDeviceByDeviceId(Long.parseLong(liuliangIds)); - List deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{ - setSerialNumber(liuliangDevice.getSerialNumber()); - setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, -1)).toString()); - setEndTime(DateUtil.endOfDay(dateTime).toString()); - }}); - Map> liuliangCollect = deviceLogs.stream().sorted(Comparator - .comparing(DeviceLog::getCreateTime, Comparator - .nullsFirst(Comparator.naturalOrder())).reversed()).collect(Collectors.groupingBy(t -> t.getIdentity())); - for (ThingsModel thingsModel : liuliangModels) { - if(thingsModel.getIdentifier().equals("三菱FX2N_1_mCon")){ - HashMap hashMap1 = new HashMap() {{ - put("upType", 0); - put("identifier", "三菱FX2N_1_mCon"); - put("unit", ""); - put("value", "停止"); - put("name", thingsModel.getModelName()); - }}; - List deviceLogs1 = liuliangCollect.get(thingsModel.getIdentifier()); - if(deviceLogs1.size() > 0){ - if(NumberUtils.isNumeric(deviceLogs1.get(0).getLogValue())){ - if(Float.parseFloat(deviceLogs1.get(0).getLogValue()) == 1f){ - hashMap1.put("value", "启动"); - }else{ - hashMap1.put("value", "停止"); - } + CommonResult cache = haiWeiService.getCache(Long.parseLong(liuliangIds)); + if(cache != null){ + HaiWeiDeviceInfoVo checkedData = cache.getCheckedData(); + if(checkedData != null){ + List propertyList = checkedData.getPropertyList(); + for (HaiWeiPropertyVo haiWeiPropertyVo : propertyList) { +// if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_kaixian")){ +// continue; +// } + HashMap hashMap = new HashMap() {{ + put("upType", 0); + put("identifier", haiWeiPropertyVo.getNameEn()); + put("unit", haiWeiPropertyVo.getUnit()); + put("value", StringUtils.isEmpty(haiWeiPropertyVo.getValue().toString())? + "--":haiWeiPropertyVo.getValue().toString()); + put("name", haiWeiPropertyVo.getNameCn()); + }}; + if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_guanxian")){ + hashMap.put("value", NumberUtils.isNumeric(haiWeiPropertyVo.getValue().toString())?( + Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?"关闭":"开启"):"关闭"); + rMap.put("阀门状态", hashMap); + }else if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_FlowDown")){ + hashMap.put("value", NumberUtils.isNumeric(haiWeiPropertyVo.getValue().toString())?( + Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?"正常":"异常"):"正常"); + rMap.put("水表状态", hashMap); + }else if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_mCon")){ + hashMap.put("value", NumberUtils.isNumeric(haiWeiPropertyVo.getValue().toString())?( + Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?"正常":"异常"):"正常"); + rMap.put("水泵状态", hashMap); + }else if(haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_sumFlow")){ + hashMap.put("value", haiWeiPropertyVo.getValue().toString()); + rMap.put("sumFlow", hashMap); + }else { + rMap.put(haiWeiPropertyVo.getNameEn(), hashMap); } } - rMap.put("水泵状态", hashMap1); - }else if(thingsModel.getIdentifier().equals("三菱FX2N_1_guanxian")){ - HashMap hashMap1 = new HashMap() {{ - put("upType", 0); - put("identifier", "三菱FX2N_1_guanxian"); - put("unit", ""); - put("value", "关闭"); - put("name", thingsModel.getModelName()); - }}; - List deviceLogs1 = liuliangCollect.get(thingsModel.getIdentifier()); - if(deviceLogs1.size() > 0){ - if(NumberUtils.isNumeric(deviceLogs1.get(0).getLogValue())){ - if(Float.parseFloat(deviceLogs1.get(0).getLogValue()) == 1f){ - hashMap1.put("value", "关闭"); - }else{ - hashMap1.put("value", "开启"); - } - }else{ - hashMap1.put("value", "关闭"); - } - - } - rMap.put("阀门状态", hashMap1); - }else if(thingsModel.getIdentifier().equals("三菱FX2N_1_FlowDown")){ - HashMap hashMap1 = new HashMap() {{ - put("upType", 0); - put("identifier", "三菱FX2N_1_FlowDown"); - put("unit", ""); - put("value", "正常"); - put("name", thingsModel.getModelName()); - }}; - List deviceLogs1 = liuliangCollect.get(thingsModel.getIdentifier()); - if(deviceLogs1.size() > 0){ - if(NumberUtils.isNumeric(deviceLogs1.get(0).getLogValue())){ - if(Float.parseFloat(deviceLogs1.get(0).getLogValue()) == 1f){ - hashMap1.put("value", "断线"); - }else{ - hashMap1.put("value", "正常"); - } - }else{ - hashMap1.put("value", "正常"); - } - - } - rMap.put("水表状态", hashMap1); - }else{ - HashMap hashMap1 = new HashMap() {{ - put("upType", 0); - put("identifier", thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow") ? "sumFlow" : thingsModel.getIdentifier()); - put("unit", ""); - put("value", 0); - put("name", thingsModel.getModelName()); - }}; - if (StringUtils.isNotEmpty(thingsModel.getSpecs())) { - String specs = thingsModel.getSpecs(); - JSONObject parse = (JSONObject) JSON.parse(specs); - if (parse.containsKey("unit")) { - hashMap1.put("unit", parse.get("unit")); - } - } - - if (hashMap1.size() > 1) { - List deviceLogs1 = liuliangCollect.get(thingsModel.getIdentifier()); - if (deviceLogs1 != null) { - if (deviceLogs1.size() > 0) { - if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) { - if (deviceLogs1.size() > 1) { - if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == Float.parseFloat(deviceLogs1.get(1).getLogValue())) { - hashMap1.put("upType", 1); - } else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) { - hashMap1.put("upType", -1); - } - } else { - hashMap1.put("upType", 0); - } - hashMap1.put("value", deviceLogs1.get(0).getLogValue()); - } else { - hashMap1.put("value", "--"); - hashMap1.put("upType", 0); - } - - } else { - hashMap1.put("value", "--"); - hashMap1.put("upType", 0); - } - - - } - } else if (hashMap1.size() > 0) { - List deviceLogs2 = liuliangCollect.get(thingsModel.getIdentifier()); - if (deviceLogs2 != null) { - hashMap1.put("value", deviceLogs2.get(0).getLogValue()); - } - } - rMap.put(thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow") ? "sumFlow" : thingsModel.getIdentifier(), hashMap1); } - } + } +// Device liuliangDevice = deviceMapper.selectDeviceByDeviceId(Long.parseLong(liuliangIds)); +// List deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{ +// setSerialNumber(liuliangDevice.getSerialNumber()); +// setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, -1)).toString()); +// setEndTime(DateUtil.endOfDay(dateTime).toString()); +// }}); +// Map> liuliangCollect = deviceLogs.stream().sorted(Comparator +// .comparing(DeviceLog::getCreateTime, Comparator +// .nullsFirst(Comparator.naturalOrder())).reversed()).collect(Collectors.groupingBy(t -> t.getIdentity())); +// for (ThingsModel thingsModel : liuliangModels) { +// if(thingsModel.getIdentifier().equals("三菱FX2N_1_mCon")){ +// HashMap hashMap1 = new HashMap() {{ +// put("upType", 0); +// put("identifier", "三菱FX2N_1_mCon"); +// put("unit", ""); +// put("value", "停止"); +// put("name", thingsModel.getModelName()); +// }}; +// List deviceLogs1 = liuliangCollect.get(thingsModel.getIdentifier()); +// if(deviceLogs1.size() > 0){ +// if(NumberUtils.isNumeric(deviceLogs1.get(0).getLogValue())){ +// if(Float.parseFloat(deviceLogs1.get(0).getLogValue()) == 1f){ +// hashMap1.put("value", "启动"); +// }else{ +// hashMap1.put("value", "停止"); +// } +// } +// } +// rMap.put("水泵状态", hashMap1); +// }else if(thingsModel.getIdentifier().equals("三菱FX2N_1_guanxian")){ +// HashMap hashMap1 = new HashMap() {{ +// put("upType", 0); +// put("identifier", "三菱FX2N_1_guanxian"); +// put("unit", ""); +// put("value", "关闭"); +// put("name", thingsModel.getModelName()); +// }}; +// List deviceLogs1 = liuliangCollect.get(thingsModel.getIdentifier()); +// if(deviceLogs1.size() > 0){ +// if(NumberUtils.isNumeric(deviceLogs1.get(0).getLogValue())){ +// if(Float.parseFloat(deviceLogs1.get(0).getLogValue()) == 1f){ +// hashMap1.put("value", "关闭"); +// }else{ +// hashMap1.put("value", "开启"); +// } +// }else{ +// hashMap1.put("value", "关闭"); +// } +// +// } +// rMap.put("阀门状态", hashMap1); +// }else if(thingsModel.getIdentifier().equals("三菱FX2N_1_FlowDown")){ +// HashMap hashMap1 = new HashMap() {{ +// put("upType", 0); +// put("identifier", "三菱FX2N_1_FlowDown"); +// put("unit", ""); +// put("value", "正常"); +// put("name", thingsModel.getModelName()); +// }}; +// List deviceLogs1 = liuliangCollect.get(thingsModel.getIdentifier()); +// if(deviceLogs1.size() > 0){ +// if(NumberUtils.isNumeric(deviceLogs1.get(0).getLogValue())){ +// if(Float.parseFloat(deviceLogs1.get(0).getLogValue()) == 1f){ +// hashMap1.put("value", "断线"); +// }else{ +// hashMap1.put("value", "正常"); +// } +// }else{ +// hashMap1.put("value", "正常"); +// } +// +// } +// rMap.put("水表状态", hashMap1); +// }else{ +// HashMap hashMap1 = new HashMap() {{ +// put("upType", 0); +// put("identifier", thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow") ? "sumFlow" : thingsModel.getIdentifier()); +// put("unit", ""); +// put("value", 0); +// put("name", thingsModel.getModelName()); +// }}; +// if (StringUtils.isNotEmpty(thingsModel.getSpecs())) { +// String specs = thingsModel.getSpecs(); +// JSONObject parse = (JSONObject) JSON.parse(specs); +// if (parse.containsKey("unit")) { +// hashMap1.put("unit", parse.get("unit")); +// } +// } +// +// if (hashMap1.size() > 1) { +// List deviceLogs1 = liuliangCollect.get(thingsModel.getIdentifier()); +// if (deviceLogs1 != null) { +// if (deviceLogs1.size() > 0) { +// if (StringUtils.isNotEmpty(deviceLogs1.get(0).getLogValue())) { +// if (deviceLogs1.size() > 1) { +// if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) == Float.parseFloat(deviceLogs1.get(1).getLogValue())) { +// hashMap1.put("upType", 1); +// } else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) { +// hashMap1.put("upType", -1); +// } +// } else { +// hashMap1.put("upType", 0); +// } +// hashMap1.put("value", deviceLogs1.get(0).getLogValue()); +// } else { +// hashMap1.put("value", "--"); +// hashMap1.put("upType", 0); +// } +// +// } else { +// hashMap1.put("value", "--"); +// hashMap1.put("upType", 0); +// } +// +// +// } +// } else if (hashMap1.size() > 0) { +// List deviceLogs2 = liuliangCollect.get(thingsModel.getIdentifier()); +// if (deviceLogs2 != null) { +// hashMap1.put("value", deviceLogs2.get(0).getLogValue()); +// } +// } +// rMap.put(thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow") ? "sumFlow" : thingsModel.getIdentifier(), hashMap1); +// } +// } } else { for (ThingsModel thingsModel : taiyangnengModels) { HashMap hashMap1 = new HashMap() {{ @@ -478,7 +542,7 @@ public class GisDeviceServiceImpl implements IGisDeviceService { if (liuliangDevice != null) { List deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{ setSerialNumber(liuliangDevice.getSerialNumber()); - setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, -1)).toString()); + setBeginTime(DateUtil.beginOfDay(DateUtil.offsetDay(dateTime, 0)).toString()); setEndTime(DateUtil.endOfDay(dateTime).toString()); }}); Map> liuliangCollect = deviceLogs.stream().sorted(Comparator diff --git a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/service/impl/DeviceServiceImpl.java b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/service/impl/DeviceServiceImpl.java index a17fa9b..c683f97 100644 --- a/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/service/impl/DeviceServiceImpl.java +++ b/fastbee-service/fastbee-iot-service/src/main/java/com/fastbee/iot/service/impl/DeviceServiceImpl.java @@ -1664,6 +1664,9 @@ public class DeviceServiceImpl implements IDeviceService { HashMap dataListMap = new HashMap<>(); List deviceLogs1 = collect.get(modelDevice.getIdentifier()); + if(null == deviceLogs1){ + continue; + } deviceLogs1.sort(Comparator.comparing(DeviceLog::getCreateTime)); dataListMap.put("name", modelDevice.getModelName()); if (StringUtils.isNotEmpty(modelDevice.getSpecs())) { diff --git a/fastbee-service/fastbee-iot-service/src/main/resources/mapper/iot/DeviceLogMapper.xml b/fastbee-service/fastbee-iot-service/src/main/resources/mapper/iot/DeviceLogMapper.xml index 8685562..590609f 100644 --- a/fastbee-service/fastbee-iot-service/src/main/resources/mapper/iot/DeviceLogMapper.xml +++ b/fastbee-service/fastbee-iot-service/src/main/resources/mapper/iot/DeviceLogMapper.xml @@ -59,6 +59,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and serial_number = #{serialNumber} and log_type = #{logType} and identity like concat('%', #{identity}, '%') + + and create_time between #{beginTime} and #{endTime} + order by create_time desc