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;
import java.util.List;
/**
* 短期间开优化Cloud模块
* 短期间开优化Cloud模块
*
* @author ZWT
* @date 2023/09/18 14:14
......@@ -33,7 +33,7 @@ import java.util.List;
public class SpaceOptimizeMidCloudServiceImpl extends SpaceOptimizeBaseService implements ISpaceOptimizeMidCloudService {
/**
* 短期间开优化Cloud模块--定时任务
* 短期间开优化Cloud模块--定时任务
*
* @param context 上下文
* @return {@link XServiceResult}
......@@ -41,40 +41,35 @@ public class SpaceOptimizeMidCloudServiceImpl extends SpaceOptimizeBaseService i
@Override
public XServiceResult optimizeMidJob(XContext context) {
//取当前时间
DateTime date = DateUtil.date();
DateTime date = DateUtil.beginOfDay(DateTime.now());
String startWeek = date.toString(BusinessConstant.DATE_FORMAT_DAY);
//取生效中的基础间开
List<SpaceInstitutionDetailEnt> detailEntList = super.getEffectiveSpaceInstitution(context, startWeek);
SpaceOptimizeLineRelation relation = super.getOptimizeLineRelation(context, detailEntList);
//月份要加一
int monthNum = date.month() + 1;
DateTime lastWeek = DateUtil.lastWeek();
List<SpaceOptimizePeriodDTO> periodDTOList = new ArrayList<>(32);
List<SpaceOptimizeWellheadDTO> wellheadDTOList = new ArrayList<>(64);
List<SpaceOptimizeDurationDTO> durationDTOList = 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);
//优化
for (SpaceInstitutionDetailEnt detail : detailEntList) {
String detailId = detail.getId();
String lineId = detail.getLineId();
Date institutionEndDate = detail.getInstitutionEndDate();
//优化截止日期
DateTime optimizeDeadline = DateUtil.endOfWeek(date);
DateTime optimizeDeadline = DateUtil.offsetDay(date, 3);
if (optimizeDeadline.compareTo(institutionEndDate) > 0) {
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()) {
//并网型优化
case "1":
super.gridConnectedOptimization(context, wellheadDTOList, durationDTOList, unOptimizeDurationList,
relation.getWellheadsByInstitutionIdIdMap().get(detail.getId()), detail, monthNum, periodId,
DynamicQueryPlantPredictedPowerInput.builder()
.plantIds(relation.getPlantIdsByLineIdMap().get(lineId))
.plantIds(relation.getPlantIdsByLineIdMap().get(detail.getLineId()))
.startTime(startWeek)
.endTime(nextWeek)
.dateType(BusinessConstant.ONE)
......@@ -87,13 +82,13 @@ public class SpaceOptimizeMidCloudServiceImpl extends SpaceOptimizeBaseService i
relation.getWellheadsByInstitutionIdIdMap().get(detail.getId()), relation.getStorageAvgMap(), detail, periodId,
DynamicQueryStoragePredictedPowerInput.builder()
.storageIds(relation.getStorageIdsByLineIdMap().get(detail.getLineId()))
.startTime(DateUtil.beginOfWeek(lastWeek).toString(BusinessConstant.DATE_FORMAT_DAY))
.endTime(DateUtil.endOfWeek(lastWeek).toString(BusinessConstant.DATE_FORMAT_DAY))
.startTime(DateUtil.offsetDay(date, -3).toString(BusinessConstant.DATE_FORMAT_DAY))
.endTime(DateUtil.offsetDay(optimizeDeadline, -3).toString(BusinessConstant.DATE_FORMAT_DAY))
.build(),
DynamicQueryPlantPredictedPowerInput.builder()
.plantIds(relation.getPlantIdsByLineIdMap().get(lineId))
.startTime(startWeek)
.endTime(nextWeek)
.plantIds(relation.getPlantIdsByLineIdMap().get(detail.getLineId()))
.startTime(date.toString(BusinessConstant.DATE_FORMAT_DAY))
.endTime(optimizeDeadline.toString(BusinessConstant.DATE_FORMAT_DAY))
.dateType(BusinessConstant.ONE)
.build());
break;
......
......@@ -21,4 +21,12 @@ public interface PredictedPowerViewMapper {
* @return {@link List}<{@link PredictedPowerView}>
*/
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
Integer dateType = input.getDateType();
List list = null;
if (CollUtil.isNotEmpty(plantIds)) {
PredictedPowerViewMapper mapper = context.getBean(PredictedPowerViewMapper.class);
switch (dateType) {
case 0:
PredictedPowerViewMapper mapper = context.getBean(PredictedPowerViewMapper.class);
list = mapper.selectMidPowerList(PredictedPowerView.builder()
.plantIds(plantIds)
.startTime(startTime)
......@@ -75,23 +75,11 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower
.build());
break;
case 1:
// PlantPredictedPowerDataMapper mapper = context.getBean(PlantPredictedPowerDataMapper.class);
// list = mapper.selectList(
// new QueryWrapper<PlantPredictedPowerDataEnt>()
// .select("hour_time",
// "min_time",
// "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)
// );
list = mapper.selectShortPowerList(PredictedPowerView.builder()
.plantIds(plantIds)
.startTime(startTime)
.endTime(endTime)
.build());
break;
default:
}
......
......@@ -34,4 +34,33 @@
ORDER BY
a.create_time
</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>
\ 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