From 1cea027067820edd2326ca9e29c18490b65ab7f5 Mon Sep 17 00:00:00 2001 From: zy <82248909@qq.com> Date: Wed, 14 Jan 2026 11:24:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=BB=9F=E8=AE=A1=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../applet/controller/WxAppletController.java | 7 +- .../service/ISurvStationInfoService.java | 2 + .../impl/SurvStationInfoServiceImpl.java | 67 ++++++++++++++++++- 3 files changed, 73 insertions(+), 3 deletions(-) diff --git a/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/controller/WxAppletController.java b/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/controller/WxAppletController.java index f714ff9..20b38af 100644 --- a/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/controller/WxAppletController.java +++ b/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/controller/WxAppletController.java @@ -143,11 +143,12 @@ public class WxAppletController { @ApiOperation("获取首页最新数据") public R getNewestData(@RequestParam(required = false) String dataMode){ List stationList = stationInfoService.getAllStationAndDevice("","","token"); - Integer dataCounts = stationInfoService.getCountOfAllData(); + Integer dataCounts = 0; //补充最新数据进入 List listFinal = new ArrayList<>(); if(stationList!=null&&stationList.size()>0){ for (SurvStationInfo survStationInfo : stationList) { + dataCounts = dataCounts + stationInfoService.getStationDataCounts(survStationInfo); if(survStationInfo.getDeviceList()!=null&&survStationInfo.getDeviceList().size()>0){ List remainList = new ArrayList<>(); List airList = new ArrayList<>(); @@ -230,7 +231,9 @@ public class WxAppletController { } } if(!listFinal.isEmpty()){ - listFinal.forEach(item->item.setDataCounts(dataCounts)); + for (CommonDataTrans commonDataTrans : listFinal) { + commonDataTrans.setDataCounts(dataCounts); + } } return R.ok(listFinal); } diff --git a/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/service/ISurvStationInfoService.java b/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/service/ISurvStationInfoService.java index 7193c57..e9cbcf0 100644 --- a/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/service/ISurvStationInfoService.java +++ b/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/service/ISurvStationInfoService.java @@ -23,4 +23,6 @@ public interface ISurvStationInfoService extends IService { List getAllStationAndDevice(String stationCode,String deployType, String token); Integer getCountOfAllData(); + + Integer getStationDataCounts(SurvStationInfo survStationInfo); } diff --git a/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/service/impl/SurvStationInfoServiceImpl.java b/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/service/impl/SurvStationInfoServiceImpl.java index 169fae1..cdda2ef 100644 --- a/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/service/impl/SurvStationInfoServiceImpl.java +++ b/zh-module-applet/zh-applet-api/src/main/java/org/jeecg/system/applet/service/impl/SurvStationInfoServiceImpl.java @@ -2,11 +2,17 @@ package org.jeecg.system.applet.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.common.constant.PollutionConstants; +import org.jeecg.common.entity.SurvDeviceDeploy; import org.jeecg.common.entity.SurvStationInfo; import org.jeecg.system.applet.mapper.SurvStationInfoMapper; -import org.jeecg.system.applet.service.ISurvStationInfoService; +import org.jeecg.system.applet.service.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -18,6 +24,28 @@ import java.util.List; @Service public class SurvStationInfoServiceImpl extends ServiceImpl implements ISurvStationInfoService { + @Lazy + @Autowired + private ISurvDeviceDeployService deviceDeployService; + + @Lazy + @Autowired + private ISurvHisdataAirService airService; + + @Lazy + @Autowired + private ISurvHisdataSoilService soilService; + + @Lazy + @Autowired + private ISurvHisdataOrientwaterService orientwaterService; + + @Lazy + @Autowired + private ISurvHisdataLivestockwaterService livestockwaterService; + + + @Override public IPage pages(IPage page, SurvStationInfo survStationInfo) { return baseMapper.pages(page,survStationInfo); @@ -43,5 +71,42 @@ public class SurvStationInfoServiceImpl extends ServiceImpl deploys = new ArrayList<>(); + if(survStationInfo.getDeviceList() !=null && !survStationInfo.getDeviceList().isEmpty()){ //没有设备传入去重新查询 + deploys = survStationInfo.getDeviceList(); + }else{ + deploys = deviceDeployService.getDeviceByStation(survStationInfo.getStationCode(),null); + } + + if(!deploys.isEmpty()){ + for (SurvDeviceDeploy deploy : deploys) { + switch (deploy.getDeployType()){ + case PollutionConstants.AIR_SURV: + dataCounts = dataCounts + airService.getHisDataCount(new ArrayList<>(Arrays.asList(deploy.getDeployCode()))); + break; + case PollutionConstants.SOIL_SURV: + dataCounts = dataCounts + soilService.getHisDataCount(new ArrayList<>(Arrays.asList(deploy.getDeployCode()))); + break; + case PollutionConstants.WATER_ORIENT: + dataCounts = dataCounts + orientwaterService.getHisDataCount(new ArrayList<>(Arrays.asList(deploy.getDeployCode()))); + break; + case PollutionConstants.WATER_LIVE: + dataCounts = dataCounts + livestockwaterService.getHisDataCount(new ArrayList<>(Arrays.asList(deploy.getDeployCode()))); + break; + case PollutionConstants.WATER_QULITY: + dataCounts = dataCounts + soilService.getHisDataCount(new ArrayList<>(Arrays.asList(deploy.getDeployCode()))); + break; + } + } + } + + } + return dataCounts; + } + }