Commit f85472a5 authored by ZWT's avatar ZWT

feat(零碳): 长庆演示系统新增功能

1.修改第三方日累计数据推送表表结构,增加日累计储能放电量字段,同时修改代码对应实体及mapper文件,修改相关接口增加储能日累计放电量接收逻辑;
2.修改首页井场收益分析模块接口,修改获取储能累计放电量逻辑;
3.设计并创建井口日用电趋势表,生成对应实体类及mapper文件;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 9663a531
...@@ -107,10 +107,15 @@ public class BusinessConstant { ...@@ -107,10 +107,15 @@ public class BusinessConstant {
/** /**
* 025 * 0.25
*/ */
public static final BigDecimal BIG_DECIMAL_025 = BigDecimal.valueOf(0.25); public static final BigDecimal BIG_DECIMAL_025 = BigDecimal.valueOf(0.25);
/**
* 6.67
*/
public static final BigDecimal BIG_DECIMAL_667 = BigDecimal.valueOf(6.67);
/** /**
* 60 * 60
*/ */
......
...@@ -93,4 +93,8 @@ public class SpaceOptimizeShortDurationView extends BaseModel implements Seriali ...@@ -93,4 +93,8 @@ public class SpaceOptimizeShortDurationView extends BaseModel implements Seriali
@XText("启动顺序") @XText("启动顺序")
@TableField(exist = false) @TableField(exist = false)
private Integer startSeq; private Integer startSeq;
@XText("开井时长(h)")
@TableField(exist = false)
private BigDecimal runDuration;
} }
...@@ -28,6 +28,10 @@ public class WellDailyElectricityTrendEnt implements Serializable { ...@@ -28,6 +28,10 @@ public class WellDailyElectricityTrendEnt implements Serializable {
@TableField @TableField
private String wellNumber; private String wellNumber;
@XText("间开每日运行时长(h)")
@TableField
private BigDecimal spaceRunDuration;
@XText("每日开井时间(h)") @XText("每日开井时间(h)")
@TableField @TableField
private BigDecimal dailyOpenHour; private BigDecimal dailyOpenHour;
...@@ -36,6 +40,10 @@ public class WellDailyElectricityTrendEnt implements Serializable { ...@@ -36,6 +40,10 @@ public class WellDailyElectricityTrendEnt implements Serializable {
@TableField @TableField
private BigDecimal dailyGreenOpenHour; private BigDecimal dailyGreenOpenHour;
@XText("日绿电用电量(kW-h)")
@TableField
private BigDecimal dailyGreenConsumption;
@XText("日耗电量(kW-h)") @XText("日耗电量(kW-h)")
@TableField @TableField
private BigDecimal dailyElectricityConsumption; private BigDecimal dailyElectricityConsumption;
......
package pps.core.space.entity; package pps.core.space.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import xstartup.annotation.XText; import xstartup.annotation.XText;
import java.io.Serializable; import java.io.Serializable;
...@@ -15,6 +18,9 @@ import java.util.Date; ...@@ -15,6 +18,9 @@ import java.util.Date;
* @date 2024/05/24 * @date 2024/05/24
*/ */
@Data @Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class WellDailyElectricityTrendView implements Serializable { public class WellDailyElectricityTrendView implements Serializable {
@XText("ID") @XText("ID")
@TableField @TableField
...@@ -24,6 +30,10 @@ public class WellDailyElectricityTrendView implements Serializable { ...@@ -24,6 +30,10 @@ public class WellDailyElectricityTrendView implements Serializable {
@TableField @TableField
private String wellNumber; private String wellNumber;
@XText("间开每日运行时长(h)")
@TableField
private BigDecimal spaceRunDuration;
@XText("每日开井时间(h)") @XText("每日开井时间(h)")
@TableField @TableField
private BigDecimal dailyOpenHour; private BigDecimal dailyOpenHour;
...@@ -32,6 +42,10 @@ public class WellDailyElectricityTrendView implements Serializable { ...@@ -32,6 +42,10 @@ public class WellDailyElectricityTrendView implements Serializable {
@TableField @TableField
private BigDecimal dailyGreenOpenHour; private BigDecimal dailyGreenOpenHour;
@XText("日绿电用电量(kW-h)")
@TableField
private BigDecimal dailyGreenConsumption;
@XText("日耗电量(kW-h)") @XText("日耗电量(kW-h)")
@TableField @TableField
private BigDecimal dailyElectricityConsumption; private BigDecimal dailyElectricityConsumption;
......
...@@ -31,7 +31,9 @@ import xstartup.data.XServiceResult; ...@@ -31,7 +31,9 @@ import xstartup.data.XServiceResult;
import xstartup.helper.XTransactionHelper; import xstartup.helper.XTransactionHelper;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -62,8 +64,8 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -62,8 +64,8 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
//查昨日间开优化结果 //查昨日间开优化结果
Map<String, List<SpaceOptimizeShortDurationView>> lineMap = this.getOptimizationResult(context, yesterday); Map<String, List<SpaceOptimizeShortDurationView>> lineMap = this.getOptimizationResult(context, yesterday);
//查昨日井口生产情况 //查昨日井口生产情况
Map<String, List<GetWellheadDailyProductionSituationOutput>> wellProductionMap = this.getWellProductionList(context, yesterday); Map<String, GetWellheadDailyProductionSituationOutput> wellProductionMap = this.getWellProductionList(context, yesterday);
//查昨日日累计 //查昨日日累计
Map<String, BigDecimal> dailyUpdatePowerMap = this.getDailyUpdatePowerMap(context, yesterday); Map<String, BigDecimal> dailyUpdatePowerMap = this.getDailyUpdatePowerMap(context, yesterday);
//查去年同期用电趋势 //查去年同期用电趋势
Map<String, List<LineDailyElectricityTrendEnt>> lastElectricityTrendMap = this.getLastElectricityTrendMap(context, yesterday); Map<String, List<LineDailyElectricityTrendEnt>> lastElectricityTrendMap = this.getLastElectricityTrendMap(context, yesterday);
...@@ -71,11 +73,14 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -71,11 +73,14 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
List<LineDailyElectricityTrendView> saveList = new ArrayList<>(powerMap.size()); List<LineDailyElectricityTrendView> saveList = new ArrayList<>(powerMap.size());
//井口用电趋势计算结果 //井口用电趋势计算结果
List<WellDailyElectricityTrendView> wellSaveList = new ArrayList<>(wellProductionMap.size()); List<WellDailyElectricityTrendView> wellSaveList = new ArrayList<>(wellProductionMap.size());
SpaceOptimizeShortDurationView wellInfo;
BigDecimal currentServiceRating; BigDecimal currentServiceRating;
String wellNumber;
List<GetThirdActivePowerOutput> thirdActivePowerList; List<GetThirdActivePowerOutput> thirdActivePowerList;
Map<Integer, List<SpaceOptimizeShortDurationView>> startSeqMap; Map<Integer, List<SpaceOptimizeShortDurationView>> startSeqMap;
List<SpaceOptimizeShortDurationView> durationList; List<SpaceOptimizeShortDurationView> durationList;
GetThirdActivePowerOutput thirdActivePower; GetThirdActivePowerOutput thirdActivePower;
GetWellheadDailyProductionSituationOutput productionSituationOutput;
//遍历全量电站 //遍历全量电站
for (String stationName : powerMap.keySet()) { for (String stationName : powerMap.keySet()) {
//取存在的间开 //取存在的间开
...@@ -91,10 +96,16 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -91,10 +96,16 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
BigDecimal serviceRating = BigDecimal.ZERO; BigDecimal serviceRating = BigDecimal.ZERO;
for (int i = 1; i <= startSeqMap.size(); i++) { for (int i = 1; i <= startSeqMap.size(); i++) {
durationList = startSeqMap.get(i); durationList = startSeqMap.get(i);
//当前井口
wellInfo = durationList.get(0);
//当前井运行功率 //当前井运行功率
currentServiceRating = durationList.get(0).getServiceRating(); currentServiceRating = wellInfo.getServiceRating();
//井号
wellNumber = wellInfo.getWellNumber();
//累加运行功率 //累加运行功率
serviceRating.add(currentServiceRating); serviceRating.add(currentServiceRating);
//绿电开井时间(h)
BigDecimal dailyGreenOpenHour = BigDecimal.ZERO;
//记录每一次计算结束位置 //记录每一次计算结束位置
int index = 0; int index = 0;
for (SpaceOptimizeShortDurationView duration : durationList) { for (SpaceOptimizeShortDurationView duration : durationList) {
...@@ -113,9 +124,47 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -113,9 +124,47 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
if (DateUtil.isIn(thirdActivePower.getCreateDate(), openWellTime, closeWellTime) && thirdActivePower.getPhotovoltaicPower().compareTo(serviceRating) >= 0) { if (DateUtil.isIn(thirdActivePower.getCreateDate(), openWellTime, closeWellTime) && thirdActivePower.getPhotovoltaicPower().compareTo(serviceRating) >= 0) {
//单井绿电用电:运行功率*绿电阶段开井时间(0.25h) //单井绿电用电:运行功率*绿电阶段开井时间(0.25h)
photovoltaicPower = photovoltaicPower.add(currentServiceRating.multiply(BusinessConstant.BIG_DECIMAL_025)); photovoltaicPower = photovoltaicPower.add(currentServiceRating.multiply(BusinessConstant.BIG_DECIMAL_025));
//当前井口绿电运行时长
dailyGreenOpenHour = dailyGreenOpenHour.add(BusinessConstant.BIG_DECIMAL_025);
} }
} }
} }
//用电趋势结果计算
BigDecimal runDuration = wellInfo.getRunDuration();
WellDailyElectricityTrendView view;
if (wellProductionMap.containsKey(wellNumber)) {
productionSituationOutput = wellProductionMap.get(wellNumber);
view = WellDailyElectricityTrendView.builder()
.wellNumber(wellNumber)
.spaceRunDuration(runDuration)
.dailyOpenHour(productionSituationOutput.getProductionTime())
.dailyGreenOpenHour(dailyGreenOpenHour)
.dailyGreenConsumption(photovoltaicPower)
.dailyElectricityConsumption(productionSituationOutput.getDailyElectricityConsumption())
.dailyLiquidProduction(productionSituationOutput.getDailyLiquidProduction())
//日减碳量:日绿电用电量*6.67
.dailyCarbonReduction(photovoltaicPower.multiply(BusinessConstant.BIG_DECIMAL_667))
//绿电占比:绿电开井时长/开井时长*100%
.greenElectricityRate(this.getRate(dailyGreenOpenHour, runDuration))
.createDate(yesterday)
.systemSource("长庆")
.build();
} else {
view = WellDailyElectricityTrendView.builder()
.wellNumber(wellNumber)
.spaceRunDuration(runDuration)
.dailyOpenHour(BigDecimal.ZERO)
.dailyGreenOpenHour(dailyGreenOpenHour)
.dailyGreenConsumption(photovoltaicPower)
.dailyElectricityConsumption(BigDecimal.ZERO)
.dailyLiquidProduction(BigDecimal.ZERO)
.dailyCarbonReduction(BigDecimal.ZERO)
.greenElectricityRate(BigDecimal.ZERO)
.createDate(yesterday)
.systemSource("长庆")
.build();
}
wellSaveList.add(view);
} }
//计算封装数据 //计算封装数据
...@@ -191,7 +240,7 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -191,7 +240,7 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
powerMap = Collections.emptyMap(); powerMap = Collections.emptyMap();
} else { } else {
powerMap = powerList.stream() powerMap = powerList.stream()
.collect(Collectors.toMap(GetThirdDailyAccumulationUpdateOutput::getStationName, GetThirdDailyAccumulationUpdateOutput::getPhotovoltaicPower)); .collect(Collectors.toMap(GetThirdDailyAccumulationUpdateOutput::getStationName, GetThirdDailyAccumulationUpdateOutput::getDailyElectricityConsumption));
} }
return powerMap; return powerMap;
} }
...@@ -225,21 +274,21 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -225,21 +274,21 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
* *
* @param context 上下文 * @param context 上下文
* @param createDate 创建日期 * @param createDate 创建日期
* @return {@link Map }<{@link String }, {@link List }<{@link GetWellheadDailyProductionSituationOutput }>> * @return {@link Map }<{@link String }, {@link GetWellheadDailyProductionSituationOutput }>
*/ */
private Map<String, List<GetWellheadDailyProductionSituationOutput>> getWellProductionList(XContext context, Date createDate) { private Map<String, GetWellheadDailyProductionSituationOutput> getWellProductionList(XContext context, Date createDate) {
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)
.build()); .build());
result.throwIfFail(); result.throwIfFail();
Map<String, List<GetWellheadDailyProductionSituationOutput>> collect; Map<String, GetWellheadDailyProductionSituationOutput> collect;
List<GetWellheadDailyProductionSituationOutput> list = result.getResult(); List<GetWellheadDailyProductionSituationOutput> list = result.getResult();
if (CollUtil.isEmpty(list)) { if (CollUtil.isEmpty(list)) {
collect = Collections.emptyMap(); collect = Collections.emptyMap();
} else { } else {
collect = list.stream() collect = list.stream()
.collect(Collectors.groupingBy(GetWellheadDailyProductionSituationOutput::getWellNumber)); .collect(Collectors.toMap(GetWellheadDailyProductionSituationOutput::getWellNumber, Function.identity()));
} }
return collect; return collect;
} }
...@@ -265,4 +314,22 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT ...@@ -265,4 +314,22 @@ public class DailyElectricityTrendCloudServiceImpl implements IDailyElectricityT
} }
return lineMap; return lineMap;
} }
/**
* 计算率
*
* @param one 一
* @param two 二
* @return {@link BigDecimal }
*/
private BigDecimal getRate(BigDecimal one, BigDecimal two) {
BigDecimal rate;
if (two.compareTo(BigDecimal.ZERO) > 0) {
rate = one.divide(two, 4, RoundingMode.HALF_UP)
.multiply(BusinessConstant.BIG_DECIMAL_100);
} else {
rate = BigDecimal.ZERO;
}
return rate;
}
} }
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
<result column="line_name" property="lineName" jdbcType="VARCHAR"/> <result column="line_name" property="lineName" jdbcType="VARCHAR"/>
<result column="service_rating" property="serviceRating" jdbcType="DECIMAL"/> <result column="service_rating" property="serviceRating" jdbcType="DECIMAL"/>
<result column="start_seq" property="startSeq" jdbcType="INTEGER"/> <result column="start_seq" property="startSeq" jdbcType="INTEGER"/>
<result column="run_duration" property="runDuration" jdbcType="DECIMAL"/>
</resultMap> </resultMap>
<select id="selectDailySystemDisplay" resultMap="ExtendsResultMap" <select id="selectDailySystemDisplay" resultMap="ExtendsResultMap"
...@@ -126,15 +127,23 @@ ...@@ -126,15 +127,23 @@
w.service_rating, w.service_rating,
s.start_seq, s.start_seq,
d.open_well_time, d.open_well_time,
d.close_well_time d.close_well_time,
IFNULL(CASE i.run_type_key WHEN 'CONTINUOUS' THEN 24 ELSE i.run_duration END, 0) AS run_duration
FROM space_optimize_short_period p FROM space_optimize_short_period p
JOIN space_optimize_short_wellhead s ON p.id = s.short_period_id JOIN space_optimize_short_wellhead s ON p.id = s.short_period_id
JOIN space_optimize_short_duration d ON s.wellhead_id = d.wellhead_id JOIN space_optimize_short_duration d ON s.wellhead_id = d.wellhead_id
AND s.optimize_date = d.optimize_date AND s.optimize_date = d.optimize_date
LEFT JOIN base_wellhead w ON s.wellhead_id = w.id LEFT JOIN base_wellhead w ON s.wellhead_id = w.id
LEFT JOIN base_power_line l ON p.line_id = l.id LEFT JOIN base_power_line l ON p.line_id = l.id
LEFT JOIN space_institution_wellhead i ON s.wellhead_id = i.wellhead_id
WHERE p.optimize_date = #{optimizeDate} WHERE p.optimize_date = #{optimizeDate}
AND d.is_optimize = 0 AND d.is_optimize = 0
AND p.is_deleted = 1
AND s.is_deleted = 1
AND d.is_deleted = 1
AND w.is_deleted = 1
AND l.is_deleted = 1
AND i.is_deleted = 1
ORDER BY p.line_id, ORDER BY p.line_id,
s.start_seq, s.start_seq,
d.open_well_time d.open_well_time
......
...@@ -4,8 +4,10 @@ ...@@ -4,8 +4,10 @@
<resultMap id="BaseResultMap" type="pps.core.space.entity.WellDailyElectricityTrendView"> <resultMap id="BaseResultMap" type="pps.core.space.entity.WellDailyElectricityTrendView">
<id column="id" property="id" jdbcType="BIGINT"/> <id column="id" property="id" jdbcType="BIGINT"/>
<result column="well_number" property="wellNumber" jdbcType="VARCHAR"/> <result column="well_number" property="wellNumber" jdbcType="VARCHAR"/>
<result column="space_run_duration" property="spaceRunDuration" jdbcType="DECIMAL"/>
<result column="daily_open_hour" property="dailyOpenHour" jdbcType="DECIMAL"/> <result column="daily_open_hour" property="dailyOpenHour" jdbcType="DECIMAL"/>
<result column="daily_green_open_hour" property="dailyGreenOpenHour" jdbcType="DECIMAL"/> <result column="daily_green_open_hour" property="dailyGreenOpenHour" jdbcType="DECIMAL"/>
<result column="daily_green_consumption" property="dailyGreenConsumption" jdbcType="DECIMAL"/>
<result column="daily_electricity_consumption" property="dailyElectricityConsumption" jdbcType="DECIMAL"/> <result column="daily_electricity_consumption" property="dailyElectricityConsumption" jdbcType="DECIMAL"/>
<result column="daily_liquid_production" property="dailyLiquidProduction" jdbcType="DECIMAL"/> <result column="daily_liquid_production" property="dailyLiquidProduction" jdbcType="DECIMAL"/>
<result column="daily_carbon_reduction" property="dailyCarbonReduction" jdbcType="DECIMAL"/> <result column="daily_carbon_reduction" property="dailyCarbonReduction" jdbcType="DECIMAL"/>
...@@ -17,8 +19,10 @@ ...@@ -17,8 +19,10 @@
id id
, ,
well_number, well_number,
space_run_duration,
daily_open_hour, daily_open_hour,
daily_green_open_hour, daily_green_open_hour,
daily_green_consumption,
daily_electricity_consumption, daily_electricity_consumption,
daily_liquid_production, daily_liquid_production,
daily_carbon_reduction, daily_carbon_reduction,
...@@ -44,14 +48,16 @@ ...@@ -44,14 +48,16 @@
</select> </select>
<insert id="batchInsert" parameterType="list"> <insert id="batchInsert" parameterType="list">
INSERT INTO well_daily_electricity_trend (well_number, daily_open_hour, daily_green_open_hour, INSERT INTO well_daily_electricity_trend (well_number, space_run_duration, daily_open_hour,
daily_electricity_consumption, daily_liquid_production, daily_carbon_reduction, green_electricity_rate, daily_green_open_hour, daily_green_consumption, daily_electricity_consumption, daily_liquid_production,
create_date, system_source) VALUES daily_carbon_reduction, green_electricity_rate, create_date, system_source) VALUES
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
( (
#{item.wellNumber}, #{item.wellNumber},
#{item.spaceRunDuration},
#{item.dailyOpenHour}, #{item.dailyOpenHour},
#{item.dailyGreenOpenHour}, #{item.dailyGreenOpenHour},
#{item.dailyGreenConsumption},
#{item.dailyElectricityConsumption}, #{item.dailyElectricityConsumption},
#{item.dailyLiquidProduction}, #{item.dailyLiquidProduction},
#{item.dailyCarbonReduction}, #{item.dailyCarbonReduction},
......
...@@ -19,4 +19,7 @@ public class GetThirdDailyAccumulationUpdateOutput { ...@@ -19,4 +19,7 @@ public class GetThirdDailyAccumulationUpdateOutput {
@XText("光伏日累计发电(KWh)") @XText("光伏日累计发电(KWh)")
private BigDecimal photovoltaicPower; private BigDecimal photovoltaicPower;
@XText("日累计用电量(KW·h)")
private BigDecimal dailyElectricityConsumption;
} }
...@@ -59,7 +59,9 @@ public class ThirdPowerCloudServiceImpl implements IThirdPowerCloudService { ...@@ -59,7 +59,9 @@ public class ThirdPowerCloudServiceImpl implements IThirdPowerCloudService {
public XListResult<GetThirdDailyAccumulationUpdateOutput> queryDailyUpdatePower(XContext context, GetThirdDailyAccumulationUpdateInput input) { public XListResult<GetThirdDailyAccumulationUpdateOutput> queryDailyUpdatePower(XContext context, GetThirdDailyAccumulationUpdateInput input) {
ThirdDailyAccumulationUpdateMapper mapper = context.getBean(ThirdDailyAccumulationUpdateMapper.class); ThirdDailyAccumulationUpdateMapper mapper = context.getBean(ThirdDailyAccumulationUpdateMapper.class);
List<ThirdDailyAccumulationUpdateEnt> list = mapper.selectList(new QueryWrapper<ThirdDailyAccumulationUpdateEnt>() List<ThirdDailyAccumulationUpdateEnt> list = mapper.selectList(new QueryWrapper<ThirdDailyAccumulationUpdateEnt>()
.select("station_name", "IFNULL( AVG( photovoltaic_power ), 0 ) AS photovoltaic_power") .select("station_name",
"IFNULL( AVG( photovoltaic_power ), 0 ) AS photovoltaic_power",
"IFNULL( AVG( daily_electricity_consumption ), 0 ) AS daily_electricity_consumption")
.lambda() .lambda()
.gt(ThirdDailyAccumulationUpdateEnt::getPhotovoltaicPower, 0) .gt(ThirdDailyAccumulationUpdateEnt::getPhotovoltaicPower, 0)
.apply("DATE( create_date ) = {0}", input.getCreateDate()) .apply("DATE( create_date ) = {0}", input.getCreateDate())
......
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