Commit b243d108 authored by ZWT's avatar ZWT

feat(零碳): 长庆

1.邮件发送服务代码修改,修改配置文件及发送逻辑,解决邮件名称唯一性;
2.邮件接收功能修改,解决邮件接收协议修改后导致的一系列问题;
3.长期间开优化功能修改,修改定时任务处理逻辑及执行周期;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 0f78916a
...@@ -24,7 +24,7 @@ import java.util.Date; ...@@ -24,7 +24,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* 短期间开优化Cloud模块 * 短期间开优化Cloud模块
* *
* @author ZWT * @author ZWT
* @date 2023/09/18 14:14 * @date 2023/09/18 14:14
...@@ -33,7 +33,7 @@ import java.util.List; ...@@ -33,7 +33,7 @@ import java.util.List;
public class SpaceOptimizeMidCloudServiceImpl extends SpaceOptimizeBaseService implements ISpaceOptimizeMidCloudService { public class SpaceOptimizeMidCloudServiceImpl extends SpaceOptimizeBaseService implements ISpaceOptimizeMidCloudService {
/** /**
* 短期间开优化Cloud模块--定时任务 * 短期间开优化Cloud模块--定时任务
* *
* @param context 上下文 * @param context 上下文
* @return {@link XServiceResult} * @return {@link XServiceResult}
...@@ -41,40 +41,35 @@ public class SpaceOptimizeMidCloudServiceImpl extends SpaceOptimizeBaseService i ...@@ -41,40 +41,35 @@ public class SpaceOptimizeMidCloudServiceImpl extends SpaceOptimizeBaseService i
@Override @Override
public XServiceResult optimizeMidJob(XContext context) { public XServiceResult optimizeMidJob(XContext context) {
//取当前时间 //取当前时间
DateTime date = DateUtil.date(); DateTime date = DateUtil.beginOfDay(DateTime.now());
String startWeek = date.toString(BusinessConstant.DATE_FORMAT_DAY); String startWeek = date.toString(BusinessConstant.DATE_FORMAT_DAY);
//取生效中的基础间开 //取生效中的基础间开
List<SpaceInstitutionDetailEnt> detailEntList = super.getEffectiveSpaceInstitution(context, startWeek); List<SpaceInstitutionDetailEnt> detailEntList = super.getEffectiveSpaceInstitution(context, startWeek);
SpaceOptimizeLineRelation relation = super.getOptimizeLineRelation(context, detailEntList); SpaceOptimizeLineRelation relation = super.getOptimizeLineRelation(context, detailEntList);
//月份要加一 //月份要加一
int monthNum = date.month() + 1; int monthNum = date.month() + 1;
DateTime lastWeek = DateUtil.lastWeek();
List<SpaceOptimizePeriodDTO> periodDTOList = new ArrayList<>(32); List<SpaceOptimizePeriodDTO> periodDTOList = new ArrayList<>(32);
List<SpaceOptimizeWellheadDTO> wellheadDTOList = new ArrayList<>(64); List<SpaceOptimizeWellheadDTO> wellheadDTOList = new ArrayList<>(64);
List<SpaceOptimizeDurationDTO> durationDTOList = new ArrayList<>(128); List<SpaceOptimizeDurationDTO> durationDTOList = new ArrayList<>(128);
List<SpaceOptimizeDurationDTO> unOptimizeDurationList = new ArrayList<>(128); List<SpaceOptimizeDurationDTO> unOptimizeDurationList = new ArrayList<>(128);
String executionCycleForWeek = BaseUtils.getExecutionCycleForWeek(date);
//日期查询范围结束条件,下周一 //日期查询范围结束条件,下周一
String nextWeek = DateUtil.beginOfWeek(DateUtil.nextWeek()).toString(BusinessConstant.DATE_FORMAT_DAY); String nextWeek = DateUtil.beginOfWeek(DateUtil.nextWeek()).toString(BusinessConstant.DATE_FORMAT_DAY);
//优化 //优化
for (SpaceInstitutionDetailEnt detail : detailEntList) { for (SpaceInstitutionDetailEnt detail : detailEntList) {
String detailId = detail.getId();
String lineId = detail.getLineId();
Date institutionEndDate = detail.getInstitutionEndDate(); Date institutionEndDate = detail.getInstitutionEndDate();
//优化截止日期 DateTime optimizeDeadline = DateUtil.offsetDay(date, 3);
DateTime optimizeDeadline = DateUtil.endOfWeek(date);
if (optimizeDeadline.compareTo(institutionEndDate) > 0) { if (optimizeDeadline.compareTo(institutionEndDate) > 0) {
optimizeDeadline = DateUtil.endOfDay(institutionEndDate); optimizeDeadline = DateUtil.endOfDay(institutionEndDate);
} }
//创建记录 //创建记录
String periodId = super.createOptimizePeriod(periodDTOList, detailId, lineId, executionCycleForWeek, optimizeDeadline); String periodId = super.createOptimizePeriod(periodDTOList, detail.getId(), detail.getLineId(), BaseUtils.getExecutionCycleForCalibration(date, optimizeDeadline), optimizeDeadline);
switch (detail.getGridTypeKey()) { switch (detail.getGridTypeKey()) {
//并网型优化 //并网型优化
case "1": case "1":
super.gridConnectedOptimization(context, wellheadDTOList, durationDTOList, unOptimizeDurationList, super.gridConnectedOptimization(context, wellheadDTOList, durationDTOList, unOptimizeDurationList,
relation.getWellheadsByInstitutionIdIdMap().get(detail.getId()), detail, monthNum, periodId, relation.getWellheadsByInstitutionIdIdMap().get(detail.getId()), detail, monthNum, periodId,
DynamicQueryPlantPredictedPowerInput.builder() DynamicQueryPlantPredictedPowerInput.builder()
.plantIds(relation.getPlantIdsByLineIdMap().get(lineId)) .plantIds(relation.getPlantIdsByLineIdMap().get(detail.getLineId()))
.startTime(startWeek) .startTime(startWeek)
.endTime(nextWeek) .endTime(nextWeek)
.dateType(BusinessConstant.ONE) .dateType(BusinessConstant.ONE)
...@@ -87,13 +82,13 @@ public class SpaceOptimizeMidCloudServiceImpl extends SpaceOptimizeBaseService i ...@@ -87,13 +82,13 @@ public class SpaceOptimizeMidCloudServiceImpl extends SpaceOptimizeBaseService i
relation.getWellheadsByInstitutionIdIdMap().get(detail.getId()), relation.getStorageAvgMap(), detail, periodId, relation.getWellheadsByInstitutionIdIdMap().get(detail.getId()), relation.getStorageAvgMap(), detail, periodId,
DynamicQueryStoragePredictedPowerInput.builder() DynamicQueryStoragePredictedPowerInput.builder()
.storageIds(relation.getStorageIdsByLineIdMap().get(detail.getLineId())) .storageIds(relation.getStorageIdsByLineIdMap().get(detail.getLineId()))
.startTime(DateUtil.beginOfWeek(lastWeek).toString(BusinessConstant.DATE_FORMAT_DAY)) .startTime(DateUtil.offsetDay(date, -3).toString(BusinessConstant.DATE_FORMAT_DAY))
.endTime(DateUtil.endOfWeek(lastWeek).toString(BusinessConstant.DATE_FORMAT_DAY)) .endTime(DateUtil.offsetDay(optimizeDeadline, -3).toString(BusinessConstant.DATE_FORMAT_DAY))
.build(), .build(),
DynamicQueryPlantPredictedPowerInput.builder() DynamicQueryPlantPredictedPowerInput.builder()
.plantIds(relation.getPlantIdsByLineIdMap().get(lineId)) .plantIds(relation.getPlantIdsByLineIdMap().get(detail.getLineId()))
.startTime(startWeek) .startTime(date.toString(BusinessConstant.DATE_FORMAT_DAY))
.endTime(nextWeek) .endTime(optimizeDeadline.toString(BusinessConstant.DATE_FORMAT_DAY))
.dateType(BusinessConstant.ONE) .dateType(BusinessConstant.ONE)
.build()); .build());
break; break;
......
...@@ -21,4 +21,12 @@ public interface PredictedPowerViewMapper { ...@@ -21,4 +21,12 @@ public interface PredictedPowerViewMapper {
* @return {@link List}<{@link PredictedPowerView}> * @return {@link List}<{@link PredictedPowerView}>
*/ */
List<PredictedPowerView> selectMidPowerList(PredictedPowerView view); List<PredictedPowerView> selectMidPowerList(PredictedPowerView view);
/**
* 获取短期预测数据
*
* @param view 看法
* @return {@link List}<{@link PredictedPowerView}>
*/
List<PredictedPowerView> selectShortPowerList(PredictedPowerView view);
} }
...@@ -65,9 +65,9 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower ...@@ -65,9 +65,9 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower
Integer dateType = input.getDateType(); Integer dateType = input.getDateType();
List list = null; List list = null;
if (CollUtil.isNotEmpty(plantIds)) { if (CollUtil.isNotEmpty(plantIds)) {
PredictedPowerViewMapper mapper = context.getBean(PredictedPowerViewMapper.class);
switch (dateType) { switch (dateType) {
case 0: case 0:
PredictedPowerViewMapper mapper = context.getBean(PredictedPowerViewMapper.class);
list = mapper.selectMidPowerList(PredictedPowerView.builder() list = mapper.selectMidPowerList(PredictedPowerView.builder()
.plantIds(plantIds) .plantIds(plantIds)
.startTime(startTime) .startTime(startTime)
...@@ -75,23 +75,11 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower ...@@ -75,23 +75,11 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower
.build()); .build());
break; break;
case 1: case 1:
// PlantPredictedPowerDataMapper mapper = context.getBean(PlantPredictedPowerDataMapper.class); list = mapper.selectShortPowerList(PredictedPowerView.builder()
// list = mapper.selectList( .plantIds(plantIds)
// new QueryWrapper<PlantPredictedPowerDataEnt>() .startTime(startTime)
// .select("hour_time", .endTime(endTime)
// "min_time", .build());
// "IFNULL( AVG( power ), 0 ) AS power",
// "data_date AS create_time")
// .lambda()
// .eq(StringUtils.isNotBlank(plantId), PlantPredictedPowerDataEnt::getPlantId, plantId)
// .in(PlantPredictedPowerDataEnt::getPlantId, plantIds)
// .eq(StringUtils.isNotBlank(yearTime), PlantPredictedPowerDataEnt::getYearTime, yearTime)
// .eq(StringUtils.isNotBlank(monthTime), PlantPredictedPowerDataEnt::getMonthTime, monthTime)
// .between(!StringUtils.isAnyBlank(startTime, endTime), PlantPredictedPowerDataEnt::getDataDate, startTime, endTime)
// .groupBy(PlantPredictedPowerDataEnt::getHourTime,
// PlantPredictedPowerDataEnt::getMinTime)
// .orderByAsc(PlantPredictedPowerDataEnt::getHourTime, PlantPredictedPowerDataEnt::getMinTime)
// );
break; break;
default: default:
} }
......
...@@ -34,4 +34,33 @@ ...@@ -34,4 +34,33 @@
ORDER BY ORDER BY
a.create_time a.create_time
</select> </select>
<select id="selectShortPowerList" resultMap="BaseResultMap">
SELECT
IFNULL( AVG( a.predict_power ), 0 ) AS power,
a.create_time
FROM
(
SELECT
predict_power,
TIME( data_date ) AS create_time
FROM
plant_predicted_power_short_term
WHERE
plant_id IN
<foreach collection="plantIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<if test="startTime != null and endTime != null">
AND
data_date BETWEEN
#{startTime} AND
#{endTime}
</if>
) a
GROUP BY
a.create_time
ORDER BY
a.create_time
</select>
</mapper> </mapper>
\ No newline at end of file
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