站点数据总量统计调整

This commit is contained in:
zhangyue 2026-08-21 16:44:35 +08:00
parent d18226e13d
commit 36d3ccce3a
5 changed files with 69 additions and 43 deletions

View File

@ -49,8 +49,6 @@ public class SurvStationInfoController {
@Autowired
private ISurvStationInfoService survStationInfoService;
@Autowired
private ISurvDeviceInfoService survDeviceInfoService;
@Autowired
private ISurvDeviceDeployService survDeviceDeployService;
@Autowired
private IScEquZhibiaoService zhibiaoService;
@ -156,36 +154,39 @@ public class SurvStationInfoController {
Integer finalDataCounts = 0;
//水实时
if(!orientList.isEmpty()) {
//计算历史数据量
Integer dataCounts = hisdataOrientwaterService.getHisDataCount(orientList);
finalDataCounts=finalDataCounts+dataCounts;
}
// //畜禽
if(!liveList.isEmpty()) {
//计算历史数据量
Integer dataCounts = hisdataLivestockwaterService.getHisDataCount(liveList);
finalDataCounts=finalDataCounts+dataCounts;
}
//气实时
if(!airList.isEmpty()) {
// if(!orientList.isEmpty()) {
// //计算历史数据量
// Integer dataCounts = hisdataOrientwaterService.getHisDataCount(orientList);
// finalDataCounts=finalDataCounts+dataCounts;
// }
//// //畜禽
// if(!liveList.isEmpty()) {
// //计算历史数据量
// Integer dataCounts = hisdataLivestockwaterService.getHisDataCount(liveList);
// finalDataCounts=finalDataCounts+dataCounts;
// }
// //气实时
// if(!airList.isEmpty()) {
//
// //计算历史数据量
// Integer dataCounts = hisdataAirService.getHisDataCount(airList);
// finalDataCounts=finalDataCounts+dataCounts;
// }
// //土壤实时
// if(!soilList.isEmpty()){
// //计算历史数据量
// Integer dataCounts = hisdataSoilService.getHisDataCount(soilList);
// finalDataCounts=finalDataCounts+dataCounts;
// }
// //水质实时
// if(!waterList.isEmpty()){
// //计算历史数据量
// Integer dataCounts = hisdataSoilService.getHisDataCount(waterList);
// finalDataCounts=finalDataCounts+dataCounts;
// }
finalDataCounts = survStationInfoService.countStationData(record.getStationCode());
//计算历史数据量
Integer dataCounts = hisdataAirService.getHisDataCount(airList);
finalDataCounts=finalDataCounts+dataCounts;
}
//土壤实时
if(!soilList.isEmpty()){
//计算历史数据量
Integer dataCounts = hisdataSoilService.getHisDataCount(soilList);
finalDataCounts=finalDataCounts+dataCounts;
}
//水质实时
if(!waterList.isEmpty()){
//计算历史数据量
Integer dataCounts = hisdataSoilService.getHisDataCount(waterList);
finalDataCounts=finalDataCounts+dataCounts;
}
//获取数据量
record.setSurvDataCount(finalDataCounts);
//补充设备在线状态
@ -313,8 +314,8 @@ public class SurvStationInfoController {
constructOrient.setTransdataOrientwaterVo(survTransdataOrientwaterVo);
orientData.addAll(zhAdminFeignClient.constructOrient(constructOrient));
//计算历史数据量
Integer dataCounts = hisdataOrientwaterService.getHisDataCount(orientList);
finalDataCounts=finalDataCounts+dataCounts;
// Integer dataCounts = hisdataOrientwaterService.getHisDataCount(orientList);
// finalDataCounts=finalDataCounts+dataCounts;
}
// //畜禽
if(!liveList.isEmpty()) {
@ -324,8 +325,8 @@ public class SurvStationInfoController {
constructLive.setTransdataLivestockwaterVo(survTransdataLivestockwaterVo);
LiveData.addAll(zhAdminFeignClient.constructLive(constructLive));
//计算历史数据量
Integer dataCounts = hisdataLivestockwaterService.getHisDataCount(liveList);
finalDataCounts=finalDataCounts+dataCounts;
// Integer dataCounts = hisdataLivestockwaterService.getHisDataCount(liveList);
// finalDataCounts=finalDataCounts+dataCounts;
}
// //气实时
if(!airList.isEmpty()) {
@ -337,8 +338,8 @@ public class SurvStationInfoController {
constructAir.setDeploy(deployMap.get(survTransdataAirVo.getDeployCode()));
airData.addAll(zhAdminFeignClient.constructAir(constructAir));
//计算历史数据量
Integer dataCounts = hisdataAirService.getHisDataCount(airList);
finalDataCounts=finalDataCounts+dataCounts;
// Integer dataCounts = hisdataAirService.getHisDataCount(airList);
// finalDataCounts=finalDataCounts+dataCounts;
}
//土壤实时
if(!soilList.isEmpty()){
@ -350,8 +351,8 @@ public class SurvStationInfoController {
constructSoil.setDeploy(deployMap.get(survTransdataSoilVo.getDeployCode()));
soilData.addAll(zhAdminFeignClient.constructSoil(constructSoil));
//计算历史数据量
Integer dataCounts = hisdataSoilService.getHisDataCount(soilList);
finalDataCounts=finalDataCounts+dataCounts;
// Integer dataCounts = hisdataSoilService.getHisDataCount(soilList);
// finalDataCounts=finalDataCounts+dataCounts;
}
//水质实时
if(!waterList.isEmpty()){
@ -363,8 +364,8 @@ public class SurvStationInfoController {
constructSoil.setDeploy(deployMap.get(survTransdataSoilVo.getDeployCode()));
waterData.addAll(zhAdminFeignClient.constructSoil(constructSoil));
//计算历史数据量
Integer dataCounts = hisdataSoilService.getHisDataCount(waterList);
finalDataCounts=finalDataCounts+dataCounts;
// Integer dataCounts = hisdataSoilService.getHisDataCount(waterList);
// finalDataCounts=finalDataCounts+dataCounts;
}
// //恶臭实时
if(!stinkList.isEmpty()){
@ -373,10 +374,11 @@ public class SurvStationInfoController {
constructStink.setTransdataStinkVo(survTransdataStinkVo);
stinkData.addAll(zhAdminFeignClient.constructStink(constructStink));
//计算历史数据量
Integer dataCounts = survHisdataVocsService.getHisDataCount(stinkList);
finalDataCounts=finalDataCounts+dataCounts;
// Integer dataCounts = survHisdataVocsService.getHisDataCount(stinkList);
// finalDataCounts=finalDataCounts+dataCounts;
}
//获取数据量
finalDataCounts = survStationInfoService.countStationData(curStation.getStationCode());
curStation.setSurvDataCount(finalDataCounts);
//重新计算设备数
// int counts = curStation.getDeviceList().size();

View File

@ -25,4 +25,6 @@ public interface SurvStationInfoMapper extends BaseMapper<SurvStationInfo> {
List<SurvStationInfo> getAllStationAndDevice(@Param("stationCode") String stationCode,@Param("camera") String camera, @Param("token")String token,@Param("tenantId")String tenantId);
Integer getCountOfAllData();
Integer countStationData(String stationCode);
}

View File

@ -118,4 +118,19 @@
<select id="getCountOfAllData" resultType="java.lang.Integer">
SELECT SUM(table_rows) FROM information_schema.tables where TABLE_NAME in ('surv_hisdata_air','surv_hisdata_soil','surv_hisdata_dad','surv_hisdata_flowmeter','surv_hisdata_livestockwater','surv_hisdata_orientwater')
</select>
<select id="countStationData" resultType="java.lang.Integer">
SELECT SUM(row_count) AS total_count
FROM (
SELECT COUNT(*) AS row_count FROM surv_hisdata_soil WHERE STATION_CODE = #{stationCode}
UNION ALL
SELECT COUNT(*) AS row_count FROM surv_hisdata_air WHERE STATION_CODE = #{stationCode}
UNION ALL
SELECT COUNT(*) AS row_count FROM surv_hisdata_livestockwater WHERE STATION_CODE = #{stationCode}
UNION ALL
SELECT COUNT(*) AS row_count FROM surv_hisdata_orientwater WHERE STATION_CODE = #{stationCode}
UNION ALL
SELECT COUNT(*) AS row_count FROM surv_hisdata_vocs WHERE STATION_CODE = #{stationCode}
) AS stats
</select>
</mapper>

View File

@ -25,4 +25,6 @@ public interface ISurvStationInfoService extends IService<SurvStationInfo> {
Integer getCountOfAllData();
Integer getStationDataCounts(SurvStationInfo survStationInfo,String tenantId);
Integer countStationData(String stationCode);
}

View File

@ -108,5 +108,10 @@ public class SurvStationInfoServiceImpl extends ServiceImpl<SurvStationInfoMappe
return dataCounts;
}
@Override
public Integer countStationData(String stationCode) {
return baseMapper.countStationData(stationCode);
}
}