Commit 303bd3c5 authored by caotao's avatar caotao

按照区域获取电量指标完成情况接口代码提交、区域实时生产数据消息发送编写

parent 1ad99c46
......@@ -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.service.IMapRegionService;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.RegionNationWideDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
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.service.impl.MonitoringServiceImpl;
......@@ -48,9 +49,9 @@ public class MonitoringMapController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取社会贡献")
@GetMapping("/getTotalSocialContribution")
public void getTotalSocialContribution() {
// return ResponseHelper.buildResponse(monitoringServiceImpl.getTotalSocialContribution());
@ApiOperation(value = "获取区域电量指标完成情况")
@GetMapping("/getCompletionOfPowerIndicatorsByProvinceName")
public ResponseModel<ResultsData> getCompletionOfPowerIndicatorsByProvinceName(@RequestParam(required = true) int current, @RequestParam(required = true) int size, @RequestParam(required = true) String provinceName) {
return ResponseHelper.buildResponse(monitoringServiceImpl.getCompletionOfPowerIndicatorsByProvinceName(current,size,provinceName));
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
@Data
public class CompletionOfPowerIndicatorsDto {
//场站名称
private String stationName;
//装机容量
private String installCapactity;
//风速或者辐照度
private String windSpeedOrIrradiance;
// 有功功率
private String activePower;
//日发电量
private String dailyPower;
//月发电量
private String monthlyPower;
//年发电量
private String annualPower;
}
......@@ -5,28 +5,20 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.StationCoordinate;
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.StationCoordinateMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
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.utils.InfluxDButils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
@Async
@Service
......@@ -42,10 +34,12 @@ public class MonitoringServiceIMQTTmpl {
@Autowired
CommonServiceImpl commonServiceImpl;
@Autowired
RegionMapper regionMapper;
@Autowired
EmqKeeper emqKeeper;
@Scheduled(cron = "*/10 * * * * *")
@Scheduled(cron = "*/50 * * * * *")
public void getTotalSocialContribution() {
Page<SocialContributionDto> socialContributionDtoPage = new Page<SocialContributionDto>();
logger.error("--------------------------社会贡献定时执行----------------------------------------------");
......@@ -57,9 +51,13 @@ public class MonitoringServiceIMQTTmpl {
stationBasicList.forEach(stationBasic -> {
totalSocialContribution.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "年发电量"));
});
//二氧化碳贡献数
SocialContributionDto co2 = new SocialContributionDto();
//标准煤贡献度
SocialContributionDto coal = new SocialContributionDto();
//碳粉尘计算公式
SocialContributionDto toner = new SocialContributionDto();
//二氧化硫贡献度
SocialContributionDto so2 = new SocialContributionDto();
/** 社会贡献原始计算公式,后边的数据已经经过处理
//二氧化碳计算公式 *10000*832/10000/1000/1000
......@@ -90,4 +88,58 @@ public class MonitoringServiceIMQTTmpl {
}
}
@Scheduled(cron = "*/30 * * * * *")
public void getCompletionOfPowerIndicatorsByProvinceName() {
Page<SocialContributionDto> socialContributionDtoPage = new Page<SocialContributionDto>();
logger.error("--------------------------区域实时数据消息开始发送----------------------------------------------");
List<SocialContributionDto> socialContributionDtoList = new ArrayList<>();
Region region = this.regionMapper.selectOne(new QueryWrapper<Region>().eq("level", 1).eq("region_name", "江苏省"));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().like("belong_area", region.getRegionCode()));
//日发电量
AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
//月发电量
AtomicReference<Double> monthlyPower = new AtomicReference<>(0.0);
//年发电量
AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
//年发电量完成比例
Double completionRatio = 23.11;
//年利用小时数
AtomicReference<Double> useHours = new AtomicReference<>(0.01);
stationBasicList.forEach(stationBasic -> {
dailyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日发电量"));
monthlyPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "月发电量"));
annualPower.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "年发电量"));
useHours.updateAndGet(v -> v + commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(), "日工作时间"));
});
SocialContributionDto dailyPowerdto = new SocialContributionDto();
dailyPowerdto.setTitle(dailyPower.get());
dailyPowerdto.setUnit("万kWh");
SocialContributionDto monthlyPowerdto = new SocialContributionDto();
monthlyPowerdto.setTitle(monthlyPower.get());
monthlyPowerdto.setUnit("万kWh");
SocialContributionDto annualPowerdto = new SocialContributionDto();
annualPowerdto.setTitle(annualPower.get());
annualPowerdto.setUnit("万kWh");
SocialContributionDto completionRatioDto = new SocialContributionDto();
completionRatioDto.setTitle(completionRatio);
completionRatioDto.setUnit("%");
SocialContributionDto useHoursDto = new SocialContributionDto();
useHoursDto.setTitle(useHours.get());
useHoursDto.setUnit("h");
socialContributionDtoList.add(dailyPowerdto);
socialContributionDtoList.add(monthlyPowerdto);
socialContributionDtoList.add(annualPowerdto);
socialContributionDtoList.add(completionRatioDto);
socialContributionDtoList.add(useHoursDto);
socialContributionDtoPage.setRecords(socialContributionDtoList);
socialContributionDtoPage.setTotal(100);
socialContributionDtoPage.setCurrent(1);
try {
emqKeeper.getMqttClient().publish("completionofpowerindicator_topic", JSON.toJSON(socialContributionDtoPage).toString().getBytes("UTF-8"), 1, true);
logger.info("-----------------发送区域实时生产数据消息=================== 成功!" + JSON.toJSONString(socialContributionDtoPage));
} catch (Exception exception) {
logger.error("-----------------发送区域实时生产数据消息=================== 失败!");
}
}
}
......@@ -10,9 +10,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.entity.StationCoordinate;
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.StationCoordinateMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IndicatorsDto;
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.dto.*;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.InfluxDButils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -59,7 +57,6 @@ public class MonitoringServiceImpl {
CommonServiceImpl commonServiceImpl;
/**
* 根据场站编号获取该场站的装机容量
*
......@@ -135,4 +132,41 @@ public class MonitoringServiceImpl {
return regionNationWideDtoList;
}
public ResultsData getCompletionOfPowerIndicatorsByProvinceName(int current, int size, String provinceName) {
Region region = this.regionMapper.selectOne(new QueryWrapper<Region>().eq("level", 1).eq("region_name", provinceName));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().like("belong_area", region.getRegionCode()));
List<ColModel> colModels = new ArrayList<>();
List<CompletionOfPowerIndicatorsDto> completionOfPowerIndicatorsDtoList = new ArrayList<>();
ColModel colModelStatitonName = new ColModel("stationName", "stationName", "场站", "场站", "dataGrid", "stationName");
ColModel colModelInstallCapactity = new ColModel("installCapactity", "installCapactity", "装机容量", "装机容量", "dataGrid", "installCapactity");
ColModel colModelWindSpeedOrIrradiance = new ColModel("windSpeedOrIrradiance", "windSpeedOrIrradiance", "风度/辐照度", "风度/辐照度", "dataGrid", "windSpeedOrIrradiance");
ColModel colModelActivePower = new ColModel("activePower", "activePower", "有功", "有功", "dataGrid", "activePower");
ColModel colModelDailyPower = new ColModel("dailyPower", "dailyPower", "日发电量", "日发电量", "dataGrid", "dailyPower");
ColModel colModelMonthlyPower = new ColModel("monthlyPower", "monthlyPower", "月发电量", "月发电量", "dataGrid", "monthlyPower");
ColModel colModelAnnualPower = new ColModel("annualPower", "annualPower", "年发电量", "年发电量", "dataGrid", "annualPower");
colModels.add(colModelStatitonName);
colModels.add(colModelInstallCapactity);
colModels.add(colModelWindSpeedOrIrradiance);
colModels.add(colModelActivePower);
colModels.add(colModelDailyPower);
colModels.add(colModelMonthlyPower);
colModels.add(colModelAnnualPower);
//遍历列表
stationBasicList.forEach(stationBasic -> {
CompletionOfPowerIndicatorsDto completionOfPowerIndicatorsDto = new CompletionOfPowerIndicatorsDto();
completionOfPowerIndicatorsDto.setStationName(stationBasic.getStationName());
completionOfPowerIndicatorsDto.setInstallCapactity(String.valueOf(getStationCaPACITYL(stationBasic.getStationNumber())));
completionOfPowerIndicatorsDto.setWindSpeedOrIrradiance(String.valueOf(commonServiceImpl.getAvgvalueByIndicatior(stationBasic.getFanGatewayId(),"30秒平均风速")));
completionOfPowerIndicatorsDto.setActivePower(String.valueOf(commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(),"有功功率")));
completionOfPowerIndicatorsDto.setDailyPower(String.valueOf(commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(),"日发电量")));
completionOfPowerIndicatorsDto.setMonthlyPower(String.valueOf(commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(),"月发电量")));
completionOfPowerIndicatorsDto.setAnnualPower(String.valueOf(commonServiceImpl.getTotalByIndicatior(stationBasic.getFanGatewayId(),"年发电量")));
completionOfPowerIndicatorsDtoList.add(completionOfPowerIndicatorsDto);
});
Integer allsize = completionOfPowerIndicatorsDtoList.size();
DataGridMock dataGridMock = new DataGridMock(current, allsize, false, allsize/size+1,completionOfPowerIndicatorsDtoList);
ResultsData resultsData = new ResultsData(dataGridMock, colModels);
return resultsData;
}
}
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