diff --git a/zh-module-applet/zh-applet-admin/src/main/java/org/jeecg/modules/appmana/controller/BigScreenController.java b/zh-module-applet/zh-applet-admin/src/main/java/org/jeecg/modules/appmana/controller/BigScreenController.java index 790040a..a2a9ce0 100644 --- a/zh-module-applet/zh-applet-admin/src/main/java/org/jeecg/modules/appmana/controller/BigScreenController.java +++ b/zh-module-applet/zh-applet-admin/src/main/java/org/jeecg/modules/appmana/controller/BigScreenController.java @@ -22,6 +22,7 @@ import org.jeecg.common.iot.common.VOWaterSurvIntegrateParam; import org.jeecg.common.util.R; import org.jeecg.common.util.oConvertUtils; import org.jeecg.common.vo.*; +import org.jeecg.common.vo.inner.TransZhiBiaoVo; import org.jeecg.common.vo.statistic.ScreenIndexSummaryDetailVo; import org.jeecg.common.vo.statistic.ScreenSummaryVo; import org.jeecg.modules.appmana.service.*; @@ -816,7 +817,9 @@ public class BigScreenController { SurvStationInfo survStationInfo = stationList.get(0); List deviceList = new ArrayList<>(); List deployList = new ArrayList<>(); - survStationInfo.setDeviceCount(survStationInfo.getDeviceList().size()); + Map> zhibiaoMap = new HashMap<>(); + List orientIds = new ArrayList<>(); + if(survStationInfo.getDeviceList()!=null&&survStationInfo.getDeviceList().size()>0){ //补充设备数量 survStationInfo.setDeviceCount(survStationInfo.getDeviceList().size()); @@ -849,12 +852,14 @@ public class BigScreenController { } else if(PollutionConstants.WATER_ORIENT.equals(survDeviceDeploy.getDeployType())) {//面源 SurvTransdataOrientwaterVo transdataOrientwaterVo=transdataOrientwaterService.getNewestData(survDeviceDeploy.getDeployCode()); + orientIds.add(survDeviceDeploy.getId()); if(transdataOrientwaterVo!=null) { List orientData = commonP3Service.constructOrient(transdataOrientwaterVo,survStationInfo,survDeviceDeploy); returnArrs = JSONArray.parseArray(JSONObject.toJSONString(orientData)); } }else if(PollutionConstants.WATER_LIVE.equals(survDeviceDeploy.getDeployType())) {//畜禽 SurvTransdataLivestockwaterVo transdataLivestockwaterVo=transdataLivestockwaterService.getNewestData(survDeviceDeploy.getDeployCode()); + orientIds.add(survDeviceDeploy.getId()); if(transdataLivestockwaterVo!=null) { List liveData = commonP3Service.constructLive(transdataLivestockwaterVo,survStationInfo,survDeviceDeploy); returnArrs = JSONArray.parseArray(JSONObject.toJSONString(liveData)); @@ -868,7 +873,25 @@ public class BigScreenController { survStationInfo.getDeviceList().retainAll(remainList); //补充在线状态 survStationInfo.setDeviceList(iotutils.addOnlineStatus(survStationInfo.getDeviceList())); + List equList = zhibiaoService.getAllChemical(deployList); + if(equList.size()>0){ + zhibiaoMap = equList.stream().collect(Collectors.groupingBy(ScEquZhibiao::getEquId)); + } + } + + //重新计算设备数 + int counts = survStationInfo.getDeviceList().size(); + if(!orientIds.isEmpty()){ + //已配置的设备用指标数,未配置用1; + for (String id : orientIds) { + List zhibiaos = zhibiaoMap.get(id); + if(zhibiaos!=null){ + counts = counts + zhibiaos.size() -1; + } + } + } + survStationInfo.setDeviceCount(survStationInfo.getDeviceList().size()); survStationInfo.setLatestData(returnArrs); survStationInfo.setLatestSoilData(returnSoilArrs); survStationInfo.setLatestAirData(returnAirArrs); diff --git a/zh-module-applet/zh-applet-admin/src/main/java/org/jeecg/modules/appmana/service/impl/IotCommonP3ServiceImpl.java b/zh-module-applet/zh-applet-admin/src/main/java/org/jeecg/modules/appmana/service/impl/IotCommonP3ServiceImpl.java index 9b4e530..94d1356 100644 --- a/zh-module-applet/zh-applet-admin/src/main/java/org/jeecg/modules/appmana/service/impl/IotCommonP3ServiceImpl.java +++ b/zh-module-applet/zh-applet-admin/src/main/java/org/jeecg/modules/appmana/service/impl/IotCommonP3ServiceImpl.java @@ -301,8 +301,7 @@ public class IotCommonP3ServiceImpl { } tempEnt.setSurvItem(pollutionEnum.getCode()); String vals = EntityFieldUtil.getFieldValue(transdataOrientwaterVo,zhibiao.getEntityField(),String.class); - log.warn(zhibiao.getEntityField()+"=============wtch==============="+vals); - EntityFieldUtil.setFieldValue(tempEnt,zhibiao.getEntityField(),vals); + tempEnt.setValue(vals); tempEnt.setDeployId(deploy.getId()); listFinal.add(tempEnt); } @@ -426,7 +425,7 @@ public class IotCommonP3ServiceImpl { tempEnt.setDataDateTime(transdataLivestockwaterVo.getDataDateTime()); tempEnt.setSurvItem(pollutionEnum.getCode()); String vals = EntityFieldUtil.getFieldValue(transdataLivestockwaterVo,zhibiao.getEntityField(),String.class); - EntityFieldUtil.setFieldValue(tempEnt,zhibiao.getEntityField(),vals); + tempEnt.setValue(vals); tempEnt.setDeployId(deploy.getId()); listFinal.add(tempEnt); } diff --git a/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/controller/SurvStationInfoController.java b/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/controller/SurvStationInfoController.java index 453b4a6..4cf3609 100644 --- a/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/controller/SurvStationInfoController.java +++ b/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/controller/SurvStationInfoController.java @@ -211,6 +211,8 @@ public class SurvStationInfoController { List liveList = new ArrayList<>(); List stinkList = new ArrayList<>(); List waterList = new ArrayList<>(); + List orientIds = new ArrayList<>(); + Map> zhibiaoMap = new HashMap<>(); if(curStation.getDeviceList()!=null&&curStation.getDeviceList().size()>0){ for (SurvDeviceDeploy survDeviceDeploy : curStation.getDeviceList()) { deployList.add(survDeviceDeploy.getId()); @@ -222,8 +224,10 @@ public class SurvStationInfoController { waterList.add(survDeviceDeploy.getDeployCode()); }else if(PollutionConstants.WATER_ORIENT.equals(survDeviceDeploy.getDeployType())) {//面源 orientList.add(survDeviceDeploy.getDeployCode()); + orientIds.add(survDeviceDeploy.getId()); }else if(PollutionConstants.WATER_LIVE.equals(survDeviceDeploy.getDeployType())) {//畜禽 liveList.add(survDeviceDeploy.getDeployCode()); + orientIds.add(survDeviceDeploy.getId()); }else if(PollutionConstants.STINK.equals(survDeviceDeploy.getDeployType())) {//恶臭 stinkList.add(survDeviceDeploy.getDeployCode()); }else if(PollutionConstants.CAMERA.equals(survDeviceDeploy.getDeployType())) {//摄像头 @@ -231,6 +235,7 @@ public class SurvStationInfoController { } List equList = zhibiaoService.getShowedChemical(deployList); if(equList.size()>0){ + zhibiaoMap = equList.stream().collect(Collectors.groupingBy(ScEquZhibiao::getEquId)); TransZhiBiaoVo transZhiBiaoVo = new TransZhiBiaoVo(); transZhiBiaoVo.setZhibiaos(equList); allSurv = zhAdminFeignClient.translatePollution(transZhiBiaoVo); @@ -295,7 +300,18 @@ public class SurvStationInfoController { } //获取数据量 curStation.setSurvDataCount(finalDataCounts); - curStation.setDeviceCount(curStation.getDeviceList().size()); + //重新计算设备数 + int counts = curStation.getDeviceList().size(); + if(!orientIds.isEmpty()){ + //已配置的设备用指标数,未配置用1; + for (String id : orientIds) { + List zhibiaos = zhibiaoMap.get(id); + if(zhibiaos!=null){ + counts = counts + zhibiaos.size() -1; + } + } + } + curStation.setDeviceCount(counts); // curStation.setSurvItemCount(allSurv.size()); curStation.setSurvItemCount(curStation.getSurvObj().length); List survList = new ArrayList<>(); @@ -305,6 +321,7 @@ public class SurvStationInfoController { survList = zhAdminFeignClient.translateArrPollution(transSurvObjVo); } curStation.setSurvColorItems(survList); + jsonObject.put("stationInfo",curStation); //TODO 实时监测数据 jsonObject.put("liveSurvData",jsonArray);