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 bcc7ea0..fae2028 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 @@ -144,55 +144,78 @@ public class GisDeviceServiceImpl implements IGisDeviceService { .comparing(DeviceLog::getCreateTime, Comparator .nullsFirst(Comparator.naturalOrder())).reversed()).collect(Collectors.groupingBy(t -> t.getIdentity())); for (ThingsModel thingsModel : taiyangnengModels) { - 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) { + if (thingsModel.getModelName().equals("市电状态")) { List deviceLogs1 = taiyangnengCollect.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())) { - hashMap.put("upType", 1); - } else if (Float.parseFloat(deviceLogs1.get(0).getLogValue()) < Float.parseFloat(deviceLogs1.get(1).getLogValue())) { - hashMap.put("upType", -1); + 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) { + 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); + } + } else { + hashMap.put("upType", 0); } + hashMap.put("value", deviceLogs1.get(0).getLogValue()); } else { + hashMap.put("value", "--"); 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()); } - - - } - } 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); } - rMap.put(thingsModel.getIdentifier(), hashMap); + + } } else { for (ThingsModel thingsModel : taiyangnengModels) { @@ -216,12 +239,30 @@ public class GisDeviceServiceImpl implements IGisDeviceService { if (haiWeiPropertyVo.getNameEn().equals("三菱FX2N_1_open")) { HashMap hashMap1 = new HashMap() {{ put("upType", 0); - put("identifier", "xiangmen"); + put("identifier", "xiangmen"); put("unit", ""); put("value", haiWeiPropertyVo.getValue()); put("name", haiWeiPropertyVo.getNameCn()); }}; rMap.put("xiangmen", hashMap1); + } else if (haiWeiPropertyVo.getNameEn().equals("内门上锁")) { + HashMap hashMap1 = new HashMap() {{ + put("upType", 0); + put("identifier", "三菱FX2N_1_lock1Con"); + put("unit", ""); + put("value", Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?"正常":"异常"); + put("name", haiWeiPropertyVo.getNameCn()); + }}; + rMap.put("三菱FX2N_1_lock1Con", hashMap1); + } else if (haiWeiPropertyVo.getNameEn().equals("内门下锁")) { + HashMap hashMap1 = new HashMap() {{ + put("upType", 0); + put("identifier", "三菱FX2N_1_lock2Con"); + put("unit", ""); + put("value", Float.parseFloat(haiWeiPropertyVo.getValue().toString()) == 1f?"正常":"异常"); + put("name", haiWeiPropertyVo.getNameCn()); + }}; + rMap.put("三菱FX2N_1_lock2Con", hashMap1); } } } else { @@ -240,7 +281,7 @@ public class GisDeviceServiceImpl implements IGisDeviceService { ThingsModel thingsModel2 = new ThingsModel(); thingsModel2.setProductId(139L); List liuliangModels = thingsModelService.selectThingsModelList(thingsModel2); - if (StringUtils.isNotEmpty(taiyangnengIds)) { + if (StringUtils.isNotEmpty(liuliangModels)) { Device liuliangDevice = deviceMapper.selectDeviceByDeviceId(Long.parseLong(liuliangIds)); List deviceLogs = logService.selectDeviceLogList(new DeviceLog() {{ setSerialNumber(liuliangDevice.getSerialNumber()); @@ -251,56 +292,109 @@ public class GisDeviceServiceImpl implements IGisDeviceService { .comparing(DeviceLog::getCreateTime, Comparator .nullsFirst(Comparator.naturalOrder())).reversed()).collect(Collectors.groupingBy(t -> t.getIdentity())); for (ThingsModel thingsModel : liuliangModels) { - 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) { + 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 != 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); + if(deviceLogs1.size() > 0){ + 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(Float.parseFloat(deviceLogs1.get(0).getLogValue()) == 1f){ + 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(Float.parseFloat(deviceLogs1.get(0).getLogValue()) == 1f){ + 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); } - 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()); } - - - } - } 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); } - rMap.put(thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow") ? "sumFlow" : thingsModel.getIdentifier(), hashMap1); - } + } } else { for (ThingsModel thingsModel : taiyangnengModels) { HashMap hashMap1 = new HashMap() {{ @@ -313,14 +407,6 @@ public class GisDeviceServiceImpl implements IGisDeviceService { rMap.put(thingsModel.getIdentifier().equals("三菱FX2N_1_sumFlow") ? "sumFlow" : thingsModel.getIdentifier(), hashMap1); } } -// HashMap hashMap1 = new HashMap() {{ -// put("upType", 0); -// put("identifier", "sumFlow"); -// put("unit", "m³"); -// put("value", 0); -// put("name", "累计用水量"); -// }}; -// rMap.put("sumFlow", hashMap1); MaWatereleRecord maWatereleRecord = new MaWatereleRecord(); maWatereleRecord.setDevSn(device.getSerialNumber()); TableDataInfo tableDataInfo = watereleRecordService.selectMaWatereleRecordList(maWatereleRecord);