统一设备数量计算

This commit is contained in:
zy 2025-12-01 14:40:55 +08:00
parent 2d6dab4a1b
commit b31c07e7df
1 changed files with 24 additions and 1 deletions

View File

@ -261,11 +261,20 @@ public class BigScreenController {
if(stationList!=null&&stationList.size()>0){
Integer count = 0;
for (SurvStationInfo survStationInfo : stationList) {
//设备数量
int counts = survStationInfo.getDeviceList()!=null?survStationInfo.getDeviceList().size():0;
JSONObject jsonObject = new JSONObject();
survStationInfo.setName(count.toString());
List<String> deployList = new ArrayList<>();
survStationInfo.setDeviceCount(survStationInfo.getDeviceList().size());
List<String> orientIds = new ArrayList<>();
Map<String, List<ScEquZhibiao>> zhibiaoMap = new HashMap<>();
if(survStationInfo.getDeviceList()!=null&&survStationInfo.getDeviceList().size()>0){
List<String> listIds = survStationInfo.getDeviceList().stream().map(SurvDeviceDeploy::getId).collect(Collectors.toList());
List<ScEquZhibiao> equList = zhibiaoService.getAllChemical(listIds);
if(!equList.isEmpty()){
zhibiaoMap.putAll(equList.stream().collect(Collectors.groupingBy(ScEquZhibiao::getEquId)));
}
List<SurvDeviceDeploy> remainList = new ArrayList<>();
for (SurvDeviceDeploy survDeviceDeploy : survStationInfo.getDeviceList()) {
deployList.add(survDeviceDeploy.getId());
@ -311,6 +320,7 @@ public class BigScreenController {
//只保留摄像头的数据
remainList.add(survDeviceDeploy);
}else if(PollutionConstants.WATER_ORIENT.equals(survDeviceDeploy.getDeployType())) {//面源
orientIds.add(survDeviceDeploy.getId());
SurvTransdataOrientwaterVo transdataVo= transdataOrientwaterService.getNewestData(survDeviceDeploy.getDeployCode());
if(transdataVo!=null) {
jsonObject.putAll(JSONObject.parseObject(JSON.toJSONString(transdataVo)));
@ -323,6 +333,7 @@ public class BigScreenController {
}
}else if(PollutionConstants.WATER_LIVE.equals(survDeviceDeploy.getDeployType())) {//畜禽
orientIds.add(survDeviceDeploy.getId());
SurvTransdataLivestockwaterVo transdataAir= transdataLivestockwaterService.getNewestData(survDeviceDeploy.getDeployCode());
if(transdataAir!=null) {
jsonObject.putAll(JSONObject.parseObject(JSON.toJSONString(transdataAir)));
@ -358,6 +369,18 @@ public class BigScreenController {
}
survStationInfo.setSurvColorItems(survList);
count++;
//补充设备数量
if(!orientIds.isEmpty()){
//已配置的设备用指标数未配置用1
for (String id : orientIds) {
List<ScEquZhibiao> zhibiaos = zhibiaoMap.get(id);
if(zhibiaos!=null){
counts = counts + zhibiaos.size() -1;
}
}
}
survStationInfo.setDeviceCount(counts);
}
}