Commit 8a786831 authored by ZWT's avatar ZWT

Merge remote-tracking branch 'origin/master'

parents d5187f9b 37c26ed5
package pps.core.base.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import pps.core.base.entity.PlantPredictedPowerDataEnt;
import java.util.List;
@Repository(value="pps.core.base.mapper.PlantPredictedPowerDataViewMapper")
public interface PlantPredictedPowerDataViewMapper{
int insertBatch(List<PlantPredictedPowerDataEnt> list);
}
......@@ -16,6 +16,7 @@ import pps.core.base.entity.PlantPredictedPowerDataEnt;
import pps.core.base.enums.WindDirection;
import pps.core.base.mapper.BasePhotovoltaicPlantViewMapper;
import pps.core.base.mapper.PlantPredictedPowerDataMapper;
import pps.core.base.mapper.PlantPredictedPowerDataViewMapper;
import pps.core.base.mapper.WeatherDataMapper;
import pps.core.base.utils.HttpUtils;
import pps.core.common.constant.BusinessConstant;
......@@ -233,7 +234,8 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
dao.setMinTime(time);
dao.setDataDate(dao.getYearTime() + "-" + dao.getMonthTime() + "-" + dao.getDayTime() +" " + dao.getHourTime() + ":" + dao.getMinTime() );
PlantPredictedPowerDataEnt insertDao = XCopyUtils.copyNewObject(dao , PlantPredictedPowerDataEnt.class);
mapper.insert(insertDao);
// mapper.insert(insertDao);
allList.add(insertDao);
}
PlantPredictedPowerDataEnt isExit = objList.stream().filter(item->item.getYearTime().equals(dao.getYearTime())&&
item.getMonthTime().equals(dao.getMonthTime())&&
......@@ -305,8 +307,15 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
}
}
}
List<PlantPredictedPowerDataEnt> batchList = new ArrayList<>();
PlantPredictedPowerDataViewMapper dataViewMapper = context.getBean(PlantPredictedPowerDataViewMapper.class);
for (PlantPredictedPowerDataEnt item :allList ){
mapper.insert(item);
batchList.add(item);
if(batchList.size() > 0){
dataViewMapper.insertBatch(batchList);
batchList = new ArrayList<>();
}
}
//训练接口http://127.0.0.1:10098/aiprediction/xgbtrain?plantId=018a64635ac47cf58895147b0e1bf7e3
//自动调用预测接口
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pps.core.base.mapper.PlantPredictedPowerDataViewMapper">
<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO plant_predicted_power_data
(plant_id,
data_date,
year_time,
month_time,
day_time,
hour_time,
min_time,
temperature,
humidity,
wind_speed,
wind_direction,
pressure,
plane_irradiance,
horizontal_irradiance,
power,
create_time) VALUES
<foreach collection="list" separator="," item="item">
(#{item.plantId},
#{item.dataDate},
#{item.yearTime},
#{item.monthTime},
#{item.dayTime},
#{item.hourTime},
#{item.minTime},
#{item.temperature},
#{item.humidity},
#{item.windSpeed},
#{item.windDirection},
#{item.pressure},
#{item.planeIrradiance},
#{item.horizontalIrradiance},
#{item.power},
#{item.createTime})
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -25,6 +25,26 @@ public class PlantPredictedPowerLongTermDataEnt implements Serializable {
@TableField
private String dataDate;
@XText("年")
@TableField
private String yearTime;
@XText("月")
@TableField
private String monthTime;
@XText("日")
@TableField
private String dayTime;
@XText("时")
@TableField
private String hourTime;
@XText("分")
@TableField
private String minTime;
@XText("温度")
@TableField
private BigDecimal temperature;
......
package pps.core.prediction.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
import pps.core.prediction.entity.PlantPredictedPowerLongTermDataEnt;
import java.util.List;
@Repository(value="pps.core.prediction.mapper.PlantPredictedPowerLongTermDataViewMapper")
public interface PlantPredictedPowerLongTermDataViewMapper{
int insertBatch(List<PlantPredictedPowerLongTermDataEnt> list);
}
......@@ -16,6 +16,7 @@ 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.mapper.PlantPredictedPowerLongTermDataViewMapper;
import pps.core.prediction.service.data.plant_predicted_power_data.GetPlantPredictedPowerDataOutput;
import xstartup.annotation.XService;
import xstartup.annotation.XText;
......@@ -93,9 +94,22 @@ public class PlantPredictedPowerLongTermDataCloudServiceImpl implements PlantPre
longTermDataWrapper.lambda().ge(PlantPredictedPowerLongTermDataEnt::getDataDate , currentDate);
longTermDataWrapper.lambda().le(PlantPredictedPowerLongTermDataEnt::getDataDate , XDateUtils.addMonth(currentDate , 1));
longTermDataMapper.delete(longTermDataWrapper);
insertList.forEach(item->{
longTermDataMapper.insert(item);
});
PlantPredictedPowerLongTermDataViewMapper longTermDataViewMapper = context.getBean(PlantPredictedPowerLongTermDataViewMapper.class);
List<PlantPredictedPowerLongTermDataEnt> batchList = new ArrayList<>();
for(PlantPredictedPowerLongTermDataEnt item : insertList){
Date date = XDateUtils.parse(item.getDataDate());
item.setYearTime(XDateUtils.getYear(date)+"");
item.setMonthTime(String.format("%02d", XDateUtils.getMonth(date)));
item.setDayTime(String.format("%02d", XDateUtils.getDay(date)));
item.setHourTime(String.format("%02d", XDateUtils.getHour24(date)));
item.setMinTime(String.format("%02d", XDateUtils.getMinute(date)) + ":00");
//longTermDataMapper.insert(item);
batchList.add(item);
if(batchList.size() > 500){
longTermDataViewMapper.insertBatch(batchList);
batchList = new ArrayList<>();
}
}
}
return XServiceResult.OK;
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pps.core.prediction.mapper.PlantPredictedPowerLongTermDataViewMapper">
<insert id="insertBatch" parameterType="java.util.List">
INSERT INTO plant_predicted_power_long_term_data
(plant_id,
data_date,
year_time,
month_time,
day_time,
hour_time,
min_time,
temperature,
humidity,
wind_speed,
wind_direction,
pressure,
plane_irradiance,
horizontal_irradiance,
power,
create_time) VALUES
<foreach collection="list" separator="," item="item">
(#{item.plantId},
#{item.dataDate},
#{item.yearTime},
#{item.monthTime},
#{item.dayTime},
#{item.hourTime},
#{item.minTime},
#{item.temperature},
#{item.humidity},
#{item.windSpeed},
#{item.windDirection},
#{item.pressure},
#{item.planeIrradiance},
#{item.horizontalIrradiance},
#{item.power},
#{item.createTime})
</foreach>
</insert>
</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