Commit 0bf0f627 authored by ZWT's avatar ZWT

Merge remote-tracking branch 'origin/master'

parents d15e6f0c 39a04f4a
......@@ -10,6 +10,9 @@ import xstartup.data.XListResult;
@XService
public interface BasePhotovoltaicPlantCloudService {
@XText("获取电站")
XListResult<GetBasePhotovoltaicPlantCloudOutput> getBasePhotovoltaicPlantViewList(XContext context, GetBasePhotovoltaicPlantCloudInput input);
@XText("获取电站")
XListResult<GetBasePhotovoltaicPlantCloudOutput> getBasePhotovoltaicPlantList(XContext context, GetBasePhotovoltaicPlantCloudInput input);
}
package pps.core.base.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.cloud.base.service.BasePhotovoltaicPlantCloudService;
import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPlantCloudInput;
import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPlantCloudOutput;
import pps.core.base.constant.ScadaConstant;
import pps.core.base.entity.BasePhotovoltaicPlantEnt;
import pps.core.base.entity.BasePhotovoltaicPlantView;
import pps.core.base.mapper.BasePhotovoltaicPlantMapper;
import pps.core.base.mapper.BasePhotovoltaicPlantViewMapper;
import pps.core.common.constant.BusinessConstant;
import xstartup.annotation.XService;
import xstartup.base.XContext;
import xstartup.base.util.XCopyUtils;
import xstartup.data.XListResult;
import java.util.List;
......@@ -15,11 +20,21 @@ import java.util.List;
@XService
public class BasePhotovoltaicPlantCloudServiceImpl implements BasePhotovoltaicPlantCloudService {
@Override
public XListResult<GetBasePhotovoltaicPlantCloudOutput> getBasePhotovoltaicPlantList(XContext context, GetBasePhotovoltaicPlantCloudInput input) {
public XListResult<GetBasePhotovoltaicPlantCloudOutput> getBasePhotovoltaicPlantViewList(XContext context, GetBasePhotovoltaicPlantCloudInput input) {
BasePhotovoltaicPlantViewMapper mapper = context.getBean(BasePhotovoltaicPlantViewMapper.class);
BasePhotovoltaicPlantView view = new BasePhotovoltaicPlantView();
view.setIsDeleted(ScadaConstant.IS_DELETE_FLASE);
List<BasePhotovoltaicPlantView> plantList = mapper.selectPlantDetailList(view);
return null;
}
@Override
public XListResult<GetBasePhotovoltaicPlantCloudOutput> getBasePhotovoltaicPlantList(XContext context, GetBasePhotovoltaicPlantCloudInput input) {
BasePhotovoltaicPlantMapper mapper = context.getBean(BasePhotovoltaicPlantMapper.class);
QueryWrapper<BasePhotovoltaicPlantEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BasePhotovoltaicPlantEnt::getIsDeleted , BusinessConstant.ONE);
List<BasePhotovoltaicPlantEnt> list = mapper.selectList(queryWrapper);
List<GetBasePhotovoltaicPlantCloudOutput> outPuts = XCopyUtils.copyNewList(list , GetBasePhotovoltaicPlantCloudOutput.class);
return XListResult.success(outPuts);
}
}
......@@ -51,6 +51,18 @@
<version>1.0.0-pps</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>gf</groupId>
<artifactId>pps-cloud-prediction</artifactId>
<version>1.0.0-pps</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>gf</groupId>
<artifactId>pps-cloud-prediction</artifactId>
<version>1.0.0-pps</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
......
package pps.core.task.job;
import pps.cloud.base.service.BaseWatherCloudService;
import pps.cloud.prediction.service.PlantPredictedPowerLongTermDataCloudService;
import xstartup.annotation.XService;
import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.data.XServiceResult;
import xstartup.error.XError;
import xstartup.service.job.XJob;
import xstartup.service.job.annotation.XCronTrigger;
@XText("长期预测数据,每天更新一次")
@XService
public class PlantPredictedPowerLongTermDataJob implements XJob {
@XCronTrigger(value = "0 45 1 * * ?")
@Override
public XServiceResult execute(XContext context) {
PlantPredictedPowerLongTermDataCloudService cloudService = context.getBean(PlantPredictedPowerLongTermDataCloudService.class);
cloudService.runPlantPredictedPowerLongTermData(context);
return XServiceResult.error(context, XError.NotFound);
}
}
package pps.cloud.prediction.service;
import xstartup.annotation.XService;
import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.data.XServiceResult;
@XService
@XText("光伏预测长期")
public interface PlantPredictedPowerLongTermDataCloudService {
@XText("定时运行预测长期数据")
XServiceResult runPlantPredictedPowerLongTermData(XContext context);
}
\ No newline at end of file
package pps.core.prediction.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import xstartup.annotation.XText;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
@TableName("plant_power_data")
public class PlantPowerDataEnt implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
@XText("线路id")
@TableField
private String plantId;
@XText("日期")
@TableField
private String dataDate;
@XText("温度")
@TableField
private BigDecimal temperature;
@XText("湿度")
@TableField
private BigDecimal humidity;
@XText("风速")
@TableField
private BigDecimal windSpeed;
@XText("风向")
@TableField
private BigDecimal windDirection;
@XText("压强")
@TableField
private BigDecimal pressure;
@XText("组件平面辐照度")
@TableField
private BigDecimal planeIrradiance;
@XText("全水平辐照度")
@TableField
private BigDecimal horizontalIrradiance;
@XText("实际功率")
@TableField
private BigDecimal power;
}
package pps.core.prediction.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import xstartup.annotation.XText;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
@TableName("plant_predicted_power_long_term_data")
public class PlantPredictedPowerLongTermDataEnt implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
@XText("线路id")
@TableField
private String plantId;
@XText("日期")
@TableField
private String dataDate;
@XText("温度")
@TableField
private BigDecimal temperature;
@XText("湿度")
@TableField
private BigDecimal humidity;
@XText("风速")
@TableField
private BigDecimal windSpeed;
@XText("风向")
@TableField
private BigDecimal windDirection;
@XText("压强")
@TableField
private BigDecimal pressure;
@XText("组件平面辐照度")
@TableField
private BigDecimal planeIrradiance;
@XText("全水平辐照度")
@TableField
private BigDecimal horizontalIrradiance;
@XText("预测功率")
@TableField
private BigDecimal power;
@XText("预测功率")
@TableField(exist = false)
private BigDecimal predictedPower;
@XText("创建时间")
@TableField
private Date createTime;
}
package pps.core.prediction.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import pps.core.prediction.entity.PlantPowerDataEnt;
@Repository(value="pps.core.prediction.mapper.PlantPowerDataMapper")
public interface PlantPowerDataMapper extends BaseMapper<PlantPowerDataEnt> {
}
package pps.core.prediction.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import pps.core.prediction.entity.PlantPredictedPowerLongTermDataEnt;
@Repository(value="pps.core.prediction.mapper.PlantPredictedPowerLongTermDataMapper")
public interface PlantPredictedPowerLongTermDataMapper extends BaseMapper<PlantPredictedPowerLongTermDataEnt> {
}
......@@ -2,7 +2,9 @@ package pps.core.prediction.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import pps.core.prediction.entity.PlantPredictedPowerDataEnt;
import pps.core.prediction.entity.PlantPredictedPowerLongTermDataEnt;
import pps.core.prediction.mapper.PlantPredictedPowerDataMapper;
import pps.core.prediction.mapper.PlantPredictedPowerLongTermDataMapper;
import pps.core.prediction.service.data.plant_predicted_power_data.GetPlantPredictedPowerDataInput;
import pps.core.prediction.service.data.plant_predicted_power_data.GetPlantPredictedPowerDataOutput;
import xstartup.annotation.XService;
......@@ -72,7 +74,7 @@ public class PlantPredictedPowerDataService {
@XApiGet
@XText("根据电站预测30天的预测数据")
public XListResult<GetPlantPredictedPowerDataOutput> getThirtyPlantPredictedPowerData(XContext context, GetPlantPredictedPowerDataInput input){
public XListResult<GetPlantPredictedPowerDataOutput> getThirtyPlantPredictedPowerData_delete(XContext context, GetPlantPredictedPowerDataInput input){
//今年(7天总值)/去年(7天的总值) 同比值
PlantPredictedPowerDataMapper mapper = context.getBean(PlantPredictedPowerDataMapper.class);
Date date = new Date();
......@@ -106,4 +108,19 @@ public class PlantPredictedPowerDataService {
return XListResult.success(outputs);
}
@XApiGet
@XText("根据电站预测30天的预测数据")
public XListResult<GetPlantPredictedPowerDataOutput> getThirtyPlantPredictedPowerData(XContext context, GetPlantPredictedPowerDataInput input){
PlantPredictedPowerLongTermDataMapper mapper = context.getBean(PlantPredictedPowerLongTermDataMapper.class);
Date date = new Date();
QueryWrapper<PlantPredictedPowerLongTermDataEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.select("id, plant_id, data_date, temperature, humidity, wind_speed, wind_direction, pressure, plane_irradiance, horizontal_irradiance, power as predicted_power, create_time");
queryWrapper.lambda().eq(PlantPredictedPowerLongTermDataEnt::getPlantId ,input.getPlantId());
queryWrapper.lambda().ge(PlantPredictedPowerLongTermDataEnt::getDataDate , date);
queryWrapper.lambda().le(PlantPredictedPowerLongTermDataEnt::getDataDate , XDateUtils.addMonth(date , 1));
List<PlantPredictedPowerLongTermDataEnt> list = mapper.selectList(queryWrapper);
List<GetPlantPredictedPowerDataOutput> outputs = XCopyUtils.copyNewList(list , GetPlantPredictedPowerDataOutput.class);
return XListResult.success(outputs);
}
}
package pps.core.prediction.service;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils;
import pps.cloud.base.service.BasePhotovoltaicPlantCloudService;
import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPlantCloudInput;
import pps.cloud.base.service.data.base_photovoltaic_plant.GetBasePhotovoltaicPlantCloudOutput;
import pps.cloud.prediction.service.IPlantPredictedPowerCloudService;
import pps.cloud.prediction.service.PlantPredictedPowerLongTermDataCloudService;
import pps.cloud.prediction.service.data.plant_predicted_power_data.DynamicQueryPlantPredictedPowerInput;
import pps.cloud.prediction.service.data.plant_predicted_power_data.DynamicQueryPlantPredictedPowerOutput;
import pps.core.prediction.entity.PlantPowerDataEnt;
import pps.core.prediction.entity.PlantPredictedPowerDataEnt;
import pps.core.prediction.entity.PlantPredictedPowerLongTermDataEnt;
import pps.core.prediction.mapper.PlantPowerDataMapper;
import pps.core.prediction.mapper.PlantPredictedPowerDataMapper;
import pps.core.prediction.mapper.PlantPredictedPowerLongTermDataMapper;
import pps.core.prediction.service.data.plant_predicted_power_data.GetPlantPredictedPowerDataOutput;
import xstartup.annotation.XService;
import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XDateUtils;
import xstartup.data.XListResult;
import xstartup.data.XServiceResult;
import xstartup.feature.api.annotation.XApiAnonymous;
import xstartup.feature.api.annotation.XApiGet;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 光伏预测Cloud模块
*
* @author ZWT
* @date 2023/09/13 19:05
*/
@XService
public class PlantPredictedPowerLongTermDataCloudServiceImpl implements PlantPredictedPowerLongTermDataCloudService {
@XText("定时运行预测长期数据")
@Override
@XApiGet
@XApiAnonymous
public XServiceResult runPlantPredictedPowerLongTermData(XContext context) {
//获取所有的电站
BasePhotovoltaicPlantCloudService cloudService = context.getBean(BasePhotovoltaicPlantCloudService.class);
XListResult<GetBasePhotovoltaicPlantCloudOutput> result = cloudService.getBasePhotovoltaicPlantList(context , new GetBasePhotovoltaicPlantCloudInput());
if(!result.isSuccess())
return XServiceResult.error(500 , "未查询到电站数据");
List<GetBasePhotovoltaicPlantCloudOutput> list = result.getResult();
PlantPowerDataMapper powerDataMapper = context.getBean(PlantPowerDataMapper.class);
Date currentDate = new Date();
for(GetBasePhotovoltaicPlantCloudOutput output : list ){
//获取最近七天的实际数据
QueryWrapper<PlantPowerDataEnt> queryWrapper = new QueryWrapper<>();
queryWrapper.select(" IFNULL(avg(power ) , 0 ) power ");
queryWrapper.lambda().eq(PlantPowerDataEnt::getPlantId , output.getId());
queryWrapper.lambda().ge(PlantPowerDataEnt::getDataDate , XDateUtils.addDays(currentDate , -7));
PlantPowerDataEnt currentEnt = powerDataMapper.selectOne(queryWrapper);
//获取同期七天的实际数据
queryWrapper.clear();
queryWrapper.select(" IFNULL(avg(power ) , 0 ) power ");
queryWrapper.lambda().eq(PlantPowerDataEnt::getPlantId , output.getId());
queryWrapper.lambda().ge(PlantPowerDataEnt::getDataDate , XDateUtils.addYear(currentDate , -1));
PlantPowerDataEnt lastEnt = powerDataMapper.selectOne(queryWrapper);
//获取同比 = 当前/同期
BigDecimal compare = new BigDecimal(1);
if(lastEnt.getPower().compareTo(BigDecimal.ZERO) > 0)
compare = currentEnt.getPower().divide(lastEnt.getPower() , 6 , BigDecimal.ROUND_HALF_UP );
//获取同期30天数据
queryWrapper.clear();
queryWrapper.select(" plant_id, data_date, temperature, humidity, wind_speed, wind_direction, pressure, plane_irradiance, horizontal_irradiance, power ");
queryWrapper.lambda().eq(PlantPowerDataEnt::getPlantId ,output.getId());
queryWrapper.lambda().ge(PlantPowerDataEnt::getDataDate , XDateUtils.addYear(currentDate , -1));
queryWrapper.lambda().le(PlantPowerDataEnt::getDataDate , XDateUtils.addMonth(currentDate , -11));
List<PlantPowerDataEnt> lastList = powerDataMapper.selectList(queryWrapper);
//未来30天=同期30*同比
List<PlantPredictedPowerLongTermDataEnt> insertList = new ArrayList<>();
for(PlantPowerDataEnt item : lastList){
item.setPower(item.getPower().multiply(compare));
item.setDataDate(XDateUtils.getString(XDateUtils.addYear(XDateUtils.parse(item.getDataDate()) , 1)));
PlantPredictedPowerLongTermDataEnt insertData = XCopyUtils.copyNewObject(item , PlantPredictedPowerLongTermDataEnt.class);
insertData.setCreateTime(currentDate);
insertList.add(insertData);
}
//插入数据前,先删除数据
PlantPredictedPowerLongTermDataMapper longTermDataMapper = context.getBean(PlantPredictedPowerLongTermDataMapper.class);
QueryWrapper<PlantPredictedPowerLongTermDataEnt> longTermDataWrapper = new QueryWrapper<>();
longTermDataWrapper.lambda().eq(PlantPredictedPowerLongTermDataEnt::getPlantId , output.getId());
longTermDataWrapper.lambda().ge(PlantPredictedPowerLongTermDataEnt::getDataDate , currentDate);
longTermDataWrapper.lambda().le(PlantPredictedPowerLongTermDataEnt::getDataDate , XDateUtils.addMonth(currentDate , 1));
longTermDataMapper.delete(longTermDataWrapper);
insertList.forEach(item->{
longTermDataMapper.insert(item);
});
}
return XServiceResult.OK;
}
}
......@@ -35,6 +35,8 @@ public class DeployPpsAllApplication {
startup.enable(XJobFeature.class).config(new XJobServiceConf(SpaceOptimizeMidJob.class));
startup.enable(XJobFeature.class).config(new XJobServiceConf(SpaceCalibrationJob.class));
startup.enable(XJobFeature.class).config(new XJobServiceConf(SpaceOptimizeShortJob.class));
startup.enable(XJobFeature.class).config(new XJobServiceConf(PlantPredictedPowerLongTermDataJob.class));
//startup.enable(XCloudHuaweiCseFeature.class);
startup.run(args);
}
......
......@@ -58,6 +58,7 @@ x.job.service=pps.core.task.job.TestJob,\
pps.core.task.job.SpaceOptimizeMidJob,\
pps.core.task.job.SpaceCalibrationJob,\
pps.core.task.job.SpaceOptimizeShortJob,\
pps.core.task.job.PlantPredictedPowerLongTermDataJob,\
pps.core.task.job.WeatherJob
# redis
......
......@@ -36,12 +36,14 @@ public class DeployPpsTaskApplication {
startup.enable(XJobFeature.class).config(new XJobServiceConf(SpaceOptimizeMidJob.class));
startup.enable(XJobFeature.class).config(new XJobServiceConf(SpaceCalibrationJob.class));
startup.enable(XJobFeature.class).config(new XJobServiceConf(SpaceOptimizeShortJob.class));
startup.enable(XJobFeature.class).config(new XJobServiceConf(PlantPredictedPowerLongTermDataJob.class));
startup.enable(XRpcFeature.class);
startup.enable(XCloudHuaweiCseFeature.class)
.config(XCloudBundlesConf.with(
// XCloudBundle.naming("pps-workflow").addModule("pps", "cloud", "task"),
XCloudBundle.naming("pps-base-info").addModule("pps", "cloud", "system"),
XCloudBundle.naming("pps-base-prediction").addModule("pps", "cloud", "prediction"),
XCloudBundle.naming("pps-base-info").addModule("pps", "cloud", "base")));
startup.run(args);
......
......@@ -12,6 +12,7 @@ x.job.service=pps.core.task.job.TestJob,\
pps.core.task.job.SpaceOptimizeMidJob,\
pps.core.task.job.SpaceCalibrationJob,\
pps.core.task.job.SpaceOptimizeShortJob,\
pps.core.task.job.PlantPredictedPowerLongTermDataJob,\
pps.core.task.job.WeatherJob
#\uFFFD\uFFFD\u05BE\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
......
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