Commit ddb59419 authored by caotao's avatar caotao

获取社会贡献值

parent 2643f2be
...@@ -72,7 +72,12 @@ ...@@ -72,7 +72,12 @@
WHERE gateway=#{gateway} and WHERE gateway=#{gateway} and
indicator like concat('%',#{indicator},'%') indicator like concat('%',#{indicator},'%')
</select> </select>
<select id="getIndicatoralueTotal" resultType="Object">
SELECT SUM(indicator_value) wind_speed
FROM monitor_fan_indicator
WHERE gateway=#{gateway} and
indicator like concat('%',#{indicator},'%')
</select>
<select id="queryRunRecord" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.RunRecord"> <select id="queryRunRecord" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.RunRecord">
SELECT SELECT
t.equipment_number AS FanName, t.equipment_number AS FanName,
......
...@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; ...@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.service.IMapRegionService; import com.yeejoin.amos.boot.module.jxiop.api.service.IMapRegionService;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test; import com.yeejoin.amos.boot.module.jxiop.biz.entity.Test;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitoringServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitoringServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.RegionServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.RegionServiceImpl;
...@@ -46,9 +47,10 @@ public class MonitoringMapController extends BaseController { ...@@ -46,9 +47,10 @@ public class MonitoringMapController extends BaseController {
return ResponseHelper.buildResponse(monitoringServiceImpl.getNationWideInfo(provinceName)); return ResponseHelper.buildResponse(monitoringServiceImpl.getNationWideInfo(provinceName));
} }
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取社会贡献")
@GetMapping("/getTotalSocialContribution")
public ResponseModel<List<SocialContributionDto>> getTotalSocialContribution() {
return ResponseHelper.buildResponse(monitoringServiceImpl.getTotalSocialContribution());
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
@Data
public class SocialContributionDto {
/**
* 社会贡献值
*/
private Double title;
/**
* 贡献单位
*/
private String unit;
}
...@@ -125,7 +125,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -125,7 +125,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
/** /**
* 根据网关与指标获取指标的平均 * 根据网关与指标获取指标的
* @param gateway * @param gateway
* @param indicator * @param indicator
* @return * @return
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.injector.methods.SelectOne;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region; import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationCoordinate; import com.yeejoin.amos.boot.module.jxiop.api.entity.StationCoordinate;
...@@ -8,6 +9,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper; ...@@ -8,6 +9,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationCoordinateMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationCoordinateMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.SocialContributionDto;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -140,18 +142,36 @@ public class MonitoringServiceImpl { ...@@ -140,18 +142,36 @@ public class MonitoringServiceImpl {
return this.monitorFanIndicatorImpl.getIndicatoralueTotal(gateway,indicatorcName); return this.monitorFanIndicatorImpl.getIndicatoralueTotal(gateway,indicatorcName);
} }
public void getTotalSocialContribution(){ public List<SocialContributionDto> getTotalSocialContribution(){
HashMap<String,Double> hashMap = new HashMap<>(); List<SocialContributionDto> socialContributionDtoList =new ArrayList<>();
AtomicReference<Double> totalSocialContribution = new AtomicReference<>(0.0); AtomicReference<Double> totalSocialContribution = new AtomicReference<>(0.0);
//获取所有网关id不为空的数据 //获取所有网关id不为空的数据
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("gateway_id")); List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("gateway_id"));
stationBasicList.forEach(stationBasic -> { stationBasicList.forEach(stationBasic -> {
totalSocialContribution.updateAndGet(v -> v + (Double) monitorFanIndicatorImpl.getIndicatoralueTotal(stationBasic.getStationNumber(), "年发电量")); totalSocialContribution.updateAndGet(v -> v + (Double) monitorFanIndicatorImpl.getIndicatoralueTotal(stationBasic.getGatewayId(), "年发电量"));
}); });
// SocialContributionDto co2 = new SocialContributionDto();
// hashMap.put("CO2",(totalSocialContribution * 0.3049)/1000000); SocialContributionDto coal = new SocialContributionDto();
// hashMap.put("Coal",totalSocialContribution*); SocialContributionDto toner = new SocialContributionDto();
// hashMap.put("Toner",totalSocialContribution*); SocialContributionDto so2 = new SocialContributionDto();
// hashMap.put("S02",totalSocialContribution*); /** 社会贡献原始计算公式,后边的数据已经经过处理
//二氧化碳计算公式 *10000*832/10000/1000/1000
//标准煤计算公式 *10000*304.9/10000/1000/1000
//碳粉尘计算公式 *10000*0.032/1000/1000
//二氧化硫计算公式 =A2*10000*0.16/1000/1000
*/
co2.setUnit("二氧化碳减排量(万t)");
co2.setTitle(totalSocialContribution.get() * 0.000832);
socialContributionDtoList.add(co2);
coal.setUnit("节约标准煤(万t)");
coal.setTitle(totalSocialContribution.get() * 0.0003049);
socialContributionDtoList.add(coal);
toner.setUnit("碳粉尘减排量(万t)");
toner.setTitle(totalSocialContribution.get() * 0.00032);
socialContributionDtoList.add(toner);
so2.setUnit("二氧化硫减排量(万t)");
so2.setTitle(totalSocialContribution.get() * 0.0016);
socialContributionDtoList.add(so2);
return socialContributionDtoList;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment