Commit 97ea402d authored by ZWT's avatar ZWT

feat[零碳项目]: 松原演示

[
1.修改日耗电日产液信息定时任务及井口生产情况表表结构,增加来源系统字段,同时修改代码批量插入逻辑;
2.修改日用电趋势计算定时任务,修改代码逻辑,增加区分来源系统逻辑;
]
parent bb0e8d03
...@@ -16,7 +16,6 @@ import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPl ...@@ -16,7 +16,6 @@ import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPl
import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPlantCloudOutput; import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPlantCloudOutput;
import pps.cloud.base.service.data.base_price_strategy_detail.GetBasePriceStrategyDetailInput; import pps.cloud.base.service.data.base_price_strategy_detail.GetBasePriceStrategyDetailInput;
import pps.cloud.base.service.data.base_price_strategy_detail.GetBasePriceStrategyDetailOutput; import pps.cloud.base.service.data.base_price_strategy_detail.GetBasePriceStrategyDetailOutput;
import pps.cloud.base.service.data.config_oil_field.GetConfigOilFieldOutput;
import pps.cloud.prediction.service.IThirdPowerCloudService; import pps.cloud.prediction.service.IThirdPowerCloudService;
import pps.cloud.prediction.service.data.third_active_power.GetThirdActivePowerInput; import pps.cloud.prediction.service.data.third_active_power.GetThirdActivePowerInput;
import pps.cloud.prediction.service.data.third_active_power.GetThirdActivePowerOutput; import pps.cloud.prediction.service.data.third_active_power.GetThirdActivePowerOutput;
...@@ -74,16 +73,17 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -74,16 +73,17 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
@Override @Override
public XServiceResult dailyElectricityTrendJob(XContext context) { public XServiceResult dailyElectricityTrendJob(XContext context) {
DateTime yesterday = DateUtil.beginOfDay(DateUtil.yesterday()); DateTime yesterday = DateUtil.beginOfDay(DateUtil.yesterday());
String oilFieldCode = ServiceUtil.getOilFieldCode(context);
//查每15分钟的有功功率 //查每15分钟的有功功率
Map<String, List<GetThirdActivePowerOutput>> powerMap = this.getAvgPhotovoltaicPower(context, yesterday); Map<String, List<GetThirdActivePowerOutput>> powerMap = this.getAvgPhotovoltaicPower(context, yesterday, oilFieldCode);
//查昨日间开优化结果 //查昨日间开优化结果
Map<String, List<SpaceOptimizeShortDurationView>> lineMap = this.getOptimizationResult(context, yesterday); Map<String, List<SpaceOptimizeShortDurationView>> lineMap = this.getOptimizationResult(context, yesterday);
//查昨日井口生产情况 //查昨日井口生产情况
Map<String, GetWellheadDailyProductionSituationOutput> wellProductionMap = this.getWellProductionList(context, yesterday); Map<String, GetWellheadDailyProductionSituationOutput> wellProductionMap = this.getWellProductionList(context, yesterday, oilFieldCode);
//查昨日日累计用电 //查昨日日累计用电
Map<String, BigDecimal> dailyUpdatePowerMap = this.getDailyUpdatePowerMap(context, yesterday); Map<String, BigDecimal> dailyUpdatePowerMap = this.getDailyUpdatePowerMap(context, yesterday, oilFieldCode);
//查去年同期用电趋势 //查去年同期用电趋势
Map<String, LineDailyElectricityTrendEnt> lastElectricityTrendMap = this.getLastElectricityTrendMap(context, yesterday); Map<String, LineDailyElectricityTrendEnt> lastElectricityTrendMap = this.getLastElectricityTrendMap(context, yesterday, oilFieldCode);
//用电趋势计算结果 //用电趋势计算结果
List<LineDailyElectricityTrendView> stationSaveList = new ArrayList<>(powerMap.size()); List<LineDailyElectricityTrendView> stationSaveList = new ArrayList<>(powerMap.size());
//井口用电趋势计算结果 //井口用电趋势计算结果
...@@ -101,8 +101,6 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -101,8 +101,6 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
Map<String, String> plantStrategyMap = placeListResult.getResult().stream() Map<String, String> plantStrategyMap = placeListResult.getResult().stream()
.collect(Collectors.toMap(GetBasePhotovoltaicPlantCloudOutput::getStationName, GetBasePhotovoltaicPlantCloudOutput::getStrategyId)); .collect(Collectors.toMap(GetBasePhotovoltaicPlantCloudOutput::getStationName, GetBasePhotovoltaicPlantCloudOutput::getStrategyId));
//获取当前配置 //获取当前配置
GetConfigOilFieldOutput currentConfig = ServiceUtil.getCurrentConfig(context);
String oilFieldCode = ObjectUtil.defaultIfNull(currentConfig.getOilFieldCode(), BusinessConstant.DEFAULT_VALUE);
SpaceOptimizeShortDurationView wellInfo; SpaceOptimizeShortDurationView wellInfo;
BigDecimal currentServiceRating; BigDecimal currentServiceRating;
String wellNumber; String wellNumber;
...@@ -146,7 +144,7 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -146,7 +144,7 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
//井号 //井号
wellNumber = wellInfo.getWellNumber(); wellNumber = wellInfo.getWellNumber();
//累加运行功率 //累加运行功率
serviceRating.add(currentServiceRating); serviceRating = serviceRating.add(currentServiceRating);
//绿电开井时间(h) //绿电开井时间(h)
dailyGreenOpenHour = BigDecimal.ZERO; dailyGreenOpenHour = BigDecimal.ZERO;
//谷电开井时长(h) //谷电开井时长(h)
...@@ -382,11 +380,13 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -382,11 +380,13 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
* *
* @param context 上下文 * @param context 上下文
* @param createDate 创建日期 * @param createDate 创建日期
* @param oilFieldCode 来源系统
* @return {@link Map }<{@link String }, {@link LineDailyElectricityTrendEnt }> * @return {@link Map }<{@link String }, {@link LineDailyElectricityTrendEnt }>
*/ */
private Map<String, LineDailyElectricityTrendEnt> getLastElectricityTrendMap(XContext context, Date createDate) { private Map<String, LineDailyElectricityTrendEnt> getLastElectricityTrendMap(XContext context, Date createDate, String oilFieldCode) {
LineDailyElectricityTrendMapper mapper = context.getBean(LineDailyElectricityTrendMapper.class); LineDailyElectricityTrendMapper mapper = context.getBean(LineDailyElectricityTrendMapper.class);
List<LineDailyElectricityTrendEnt> list = mapper.selectList(new LambdaQueryWrapper<LineDailyElectricityTrendEnt>() List<LineDailyElectricityTrendEnt> list = mapper.selectList(new LambdaQueryWrapper<LineDailyElectricityTrendEnt>()
.eq(CharSequenceUtil.isNotBlank(oilFieldCode), LineDailyElectricityTrendEnt::getSystemSource, oilFieldCode)
.apply("DATE( create_date ) = {0}", DateUtil.offset(createDate, DateField.YEAR, -1)) .apply("DATE( create_date ) = {0}", DateUtil.offset(createDate, DateField.YEAR, -1))
); );
Map<String, LineDailyElectricityTrendEnt> collect; Map<String, LineDailyElectricityTrendEnt> collect;
...@@ -404,12 +404,14 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -404,12 +404,14 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
* *
* @param context 上下文 * @param context 上下文
* @param createDate 创建日期 * @param createDate 创建日期
* @param oilFieldCode 来源系统
* @return {@link Map }<{@link String }, {@link BigDecimal }> * @return {@link Map }<{@link String }, {@link BigDecimal }>
*/ */
private Map<String, BigDecimal> getDailyUpdatePowerMap(XContext context, Date createDate) { private Map<String, BigDecimal> getDailyUpdatePowerMap(XContext context, Date createDate, String oilFieldCode) {
IThirdPowerCloudService service = context.getBean(IThirdPowerCloudService.class); IThirdPowerCloudService service = context.getBean(IThirdPowerCloudService.class);
XListResult<GetThirdDailyAccumulationUpdateOutput> result = service.queryDailyUpdatePower(context, GetThirdDailyAccumulationUpdateInput.builder() XListResult<GetThirdDailyAccumulationUpdateOutput> result = service.queryDailyUpdatePower(context, GetThirdDailyAccumulationUpdateInput.builder()
.createDate(createDate) .createDate(createDate)
.systemSource(oilFieldCode)
.build()); .build());
result.throwIfFail(); result.throwIfFail();
Map<String, BigDecimal> powerMap; Map<String, BigDecimal> powerMap;
...@@ -428,12 +430,14 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -428,12 +430,14 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
* *
* @param context 上下文 * @param context 上下文
* @param createDate 创建日期 * @param createDate 创建日期
* @param oilFieldCode 来源系统
* @return {@link Map }<{@link String }, {@link List }<{@link GetThirdActivePowerOutput }>> * @return {@link Map }<{@link String }, {@link List }<{@link GetThirdActivePowerOutput }>>
*/ */
private Map<String, List<GetThirdActivePowerOutput>> getAvgPhotovoltaicPower(XContext context, Date createDate) { private Map<String, List<GetThirdActivePowerOutput>> getAvgPhotovoltaicPower(XContext context, Date createDate, String oilFieldCode) {
IThirdPowerCloudService service = context.getBean(IThirdPowerCloudService.class); IThirdPowerCloudService service = context.getBean(IThirdPowerCloudService.class);
XListResult<GetThirdActivePowerOutput> result = service.queryAvgPhotovoltaicPower(context, GetThirdActivePowerInput.builder() XListResult<GetThirdActivePowerOutput> result = service.queryAvgPhotovoltaicPower(context, GetThirdActivePowerInput.builder()
.createDate(createDate) .createDate(createDate)
.systemSource(oilFieldCode)
.build()); .build());
result.throwIfFail(); result.throwIfFail();
Map<String, List<GetThirdActivePowerOutput>> powerMap; Map<String, List<GetThirdActivePowerOutput>> powerMap;
...@@ -452,12 +456,14 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -452,12 +456,14 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
* *
* @param context 上下文 * @param context 上下文
* @param createDate 创建日期 * @param createDate 创建日期
* @param oilFieldCode 来源系统
* @return {@link Map }<{@link String }, {@link GetWellheadDailyProductionSituationOutput }> * @return {@link Map }<{@link String }, {@link GetWellheadDailyProductionSituationOutput }>
*/ */
private Map<String, GetWellheadDailyProductionSituationOutput> getWellProductionList(XContext context, Date createDate) { private Map<String, GetWellheadDailyProductionSituationOutput> getWellProductionList(XContext context, Date createDate, String oilFieldCode) {
IThirdPowerCloudService service = context.getBean(IThirdPowerCloudService.class); IThirdPowerCloudService service = context.getBean(IThirdPowerCloudService.class);
XListResult<GetWellheadDailyProductionSituationOutput> result = service.queryWellProductionList(context, GetWellheadDailyProductionSituationInput.builder() XListResult<GetWellheadDailyProductionSituationOutput> result = service.queryWellProductionList(context, GetWellheadDailyProductionSituationInput.builder()
.createDate(createDate) .createDate(createDate)
.systemSource(oilFieldCode)
.build()); .build());
result.throwIfFail(); result.throwIfFail();
Map<String, GetWellheadDailyProductionSituationOutput> collect; Map<String, GetWellheadDailyProductionSituationOutput> collect;
......
...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateField; ...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import pps.cloud.base.service.IBasePowerLineCloudService; import pps.cloud.base.service.IBasePowerLineCloudService;
import pps.cloud.base.service.IBasePriceStrategyCloudService; import pps.cloud.base.service.IBasePriceStrategyCloudService;
import pps.cloud.base.service.IBaseWellheadCloudService; import pps.cloud.base.service.IBaseWellheadCloudService;
...@@ -343,4 +344,16 @@ public class ServiceUtil { ...@@ -343,4 +344,16 @@ public class ServiceUtil {
currentConfig.throwIfFail(); currentConfig.throwIfFail();
return currentConfig.getResult(); return currentConfig.getResult();
} }
/**
* 获取油田代码
*
* @param context 上下文
* @return {@link String }
*/
public static String getOilFieldCode(XContext context) {
//判断部署环境
GetConfigOilFieldOutput currentConfig = getCurrentConfig(context);
return ObjectUtil.defaultIfNull(currentConfig.getOilFieldCode(), BusinessConstant.DEFAULT_VALUE);
}
} }
\ No newline at end of file
...@@ -22,4 +22,7 @@ public class GetThirdActivePowerInput { ...@@ -22,4 +22,7 @@ public class GetThirdActivePowerInput {
@XText("创建时间") @XText("创建时间")
private Date createDate; private Date createDate;
@XText("来源系统")
private String systemSource;
} }
...@@ -22,4 +22,7 @@ public class GetThirdDailyAccumulationUpdateInput { ...@@ -22,4 +22,7 @@ public class GetThirdDailyAccumulationUpdateInput {
@XText("创建时间") @XText("创建时间")
private Date createDate; private Date createDate;
@XText("来源系统")
private String systemSource;
} }
...@@ -22,4 +22,7 @@ public class GetWellheadDailyProductionSituationInput { ...@@ -22,4 +22,7 @@ public class GetWellheadDailyProductionSituationInput {
@XText("创建时间") @XText("创建时间")
private Date createDate; private Date createDate;
@XText("来源系统")
private String systemSource;
} }
\ No newline at end of file
package pps.core.prediction.service; package pps.core.prediction.service;
import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.cloud.prediction.service.IThirdPowerCloudService; import pps.cloud.prediction.service.IThirdPowerCloudService;
import pps.cloud.prediction.service.data.third_active_power.GetThirdActivePowerInput; import pps.cloud.prediction.service.data.third_active_power.GetThirdActivePowerInput;
...@@ -43,6 +44,7 @@ public class ThirdPowerCloudServiceImpl implements IThirdPowerCloudService { ...@@ -43,6 +44,7 @@ public class ThirdPowerCloudServiceImpl implements IThirdPowerCloudService {
public XListResult<GetThirdActivePowerOutput> queryAvgPhotovoltaicPower(XContext context, GetThirdActivePowerInput input) { public XListResult<GetThirdActivePowerOutput> queryAvgPhotovoltaicPower(XContext context, GetThirdActivePowerInput input) {
ThirdActivePowerViewMapper mapper = context.getBean(ThirdActivePowerViewMapper.class); ThirdActivePowerViewMapper mapper = context.getBean(ThirdActivePowerViewMapper.class);
List<ThirdActivePowerView> list = mapper.selectAvgPhotovoltaicPower(ThirdActivePowerView.builder() List<ThirdActivePowerView> list = mapper.selectAvgPhotovoltaicPower(ThirdActivePowerView.builder()
.systemSource(input.getSystemSource())
.createDate(input.getCreateDate()) .createDate(input.getCreateDate())
.build()); .build());
return XListResult.success(XCopyUtils.copyNewList(list, GetThirdActivePowerOutput.class)); return XListResult.success(XCopyUtils.copyNewList(list, GetThirdActivePowerOutput.class));
...@@ -64,6 +66,7 @@ public class ThirdPowerCloudServiceImpl implements IThirdPowerCloudService { ...@@ -64,6 +66,7 @@ public class ThirdPowerCloudServiceImpl implements IThirdPowerCloudService {
"IFNULL( AVG( daily_electricity_consumption ), 0 ) AS daily_electricity_consumption") "IFNULL( AVG( daily_electricity_consumption ), 0 ) AS daily_electricity_consumption")
.lambda() .lambda()
.gt(ThirdDailyAccumulationUpdateEnt::getPhotovoltaicPower, 0) .gt(ThirdDailyAccumulationUpdateEnt::getPhotovoltaicPower, 0)
.eq(CharSequenceUtil.isNotBlank(input.getSystemSource()), ThirdDailyAccumulationUpdateEnt::getSystemSource, input.getSystemSource())
.apply("DATE( create_date ) = {0}", input.getCreateDate()) .apply("DATE( create_date ) = {0}", input.getCreateDate())
.groupBy(ThirdDailyAccumulationUpdateEnt::getStationName) .groupBy(ThirdDailyAccumulationUpdateEnt::getStationName)
); );
...@@ -87,6 +90,7 @@ public class ThirdPowerCloudServiceImpl implements IThirdPowerCloudService { ...@@ -87,6 +90,7 @@ public class ThirdPowerCloudServiceImpl implements IThirdPowerCloudService {
"IFNULL( daily_liquid_production, 0 ) AS daily_liquid_production") "IFNULL( daily_liquid_production, 0 ) AS daily_liquid_production")
.lambda() .lambda()
.eq(WellheadDailyProductionSituationEnt::getDataDate, input.getCreateDate()) .eq(WellheadDailyProductionSituationEnt::getDataDate, input.getCreateDate())
.eq(CharSequenceUtil.isNotBlank(input.getSystemSource()), WellheadDailyProductionSituationEnt::getSystemSource, input.getSystemSource())
); );
return XListResult.success(XCopyUtils.copyNewList(list, GetWellheadDailyProductionSituationOutput.class)); return XListResult.success(XCopyUtils.copyNewList(list, GetWellheadDailyProductionSituationOutput.class));
} }
......
...@@ -130,6 +130,9 @@ ...@@ -130,6 +130,9 @@
third_active_power third_active_power
WHERE WHERE
DATE ( create_date ) = #{createDate} DATE ( create_date ) = #{createDate}
<if test="systemSource != null">
AND system_source = #{systemSource}
</if>
AND photovoltaic_power AND photovoltaic_power
&gt; 0) z) a) g &gt; 0) z) a) g
GROUP BY g.station_name, GROUP BY g.station_name,
......
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