|
@@ -0,0 +1,500 @@
|
|
|
+package com.jiayue.ipfcst.fileupload.job;
|
|
|
+
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import cn.hutool.poi.excel.ExcelReader;
|
|
|
+import cn.hutool.poi.excel.ExcelUtil;
|
|
|
+import com.jiayue.ipfcst.common.core.util.DateTimeUtil;
|
|
|
+import com.jiayue.ipfcst.common.data.entity.*;
|
|
|
+import com.jiayue.ipfcst.common.data.repository.*;
|
|
|
+import com.jiayue.ipfcst.console.service.NwpService;
|
|
|
+import com.jiayue.ipfcst.fileupload.util.UtilTools;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.velocity.Template;
|
|
|
+import org.apache.velocity.VelocityContext;
|
|
|
+import org.apache.velocity.app.VelocityEngine;
|
|
|
+import org.apache.velocity.runtime.RuntimeConstants;
|
|
|
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.unit.DataUnit;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.function.Predicate;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author shd
|
|
|
+ * @since 2022-06-02
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class UploadFileMatoushanJob {
|
|
|
+ @Autowired
|
|
|
+ NwpRepository nwpRepository;
|
|
|
+ @Autowired
|
|
|
+ FanUnitInfoRepository fanUnitInfoRepository;
|
|
|
+ @Autowired
|
|
|
+ WindTurbinePowerCurveRepository windTurbinePowerCurveRepository;
|
|
|
+ @Autowired
|
|
|
+ CutOutSpeedSpecifyInfoRepository cutOutSpeedSpecifyInfoRepository;
|
|
|
+ @Autowired
|
|
|
+ WindSpeedPointInfoRepository windSpeedPointInfoRepository;
|
|
|
+ @Autowired
|
|
|
+ OverhaulPlanRepository overhaulPlanRepository;
|
|
|
+ //模板风机为key,其它风机id及风速为value
|
|
|
+ public static Map<String, List<String>> moduleFanMaps = new HashMap<>();
|
|
|
+ public static Map<String, FanUnitInfo> fanInfoMap = new HashMap<>();
|
|
|
+ public static List<String> fanIdList = new ArrayList<>();
|
|
|
+ public static List<OverhaulPlan> overhaulInfos = new ArrayList<>();
|
|
|
+ public static Map<String,Map<Float,Float>> windTurbinePowerCurveMaps = new HashMap<>();
|
|
|
+ //模板机ID
|
|
|
+ public static String modleFanId = "";
|
|
|
+
|
|
|
+ public static int dayNum = 16;
|
|
|
+
|
|
|
+ public static String stationCodeStr = "J00307";
|
|
|
+ //模板配置文件路径
|
|
|
+ public static String modleParamFilePath = "/usr/local/singleFan/单风机法模板-all.xlsx";
|
|
|
+
|
|
|
+ public static String overHaulFilePath = "/usr/local/singleFan/风机检修计划.xlsx";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每天凌晨5点30执行 现场每日7点20开始执行文件生成定时任务
|
|
|
+ *
|
|
|
+ * 马头山查询nwp数据生成短期预测文件
|
|
|
+ */
|
|
|
+ //@Scheduled(fixedRate = 1000*60)
|
|
|
+ @Scheduled(cron = "30 30 5 * * ?")
|
|
|
+ public void createDqFile() {
|
|
|
+ log.info("时间 【" + DateTimeUtil.dateToStrLong(new Date()) + "】 马头山短期文件生成开始");
|
|
|
+ //1.读取本地Excel配置
|
|
|
+ readExcelForParams();
|
|
|
+ //2.查询mongodb中的nwp数据
|
|
|
+ List<Nwp> listTemperature = getNwpDatasFromMongodb();
|
|
|
+ //3.计算短期预测
|
|
|
+ List<PowerMeteoforce1> powerMeteoforces = caculateDqs(listTemperature);
|
|
|
+ //4.生成短期文件并上传minio,向v3请求文件记录写入
|
|
|
+ fileCreate(powerMeteoforces,stationCodeStr,"马头山风电场");
|
|
|
+
|
|
|
+ log.info("时间 【" + DateTimeUtil.dateToStrLong(new Date()) + "】 马头山短期文件生成完成");
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 读取excel中配置参数
|
|
|
+ */
|
|
|
+ private void readExcelForParams() {
|
|
|
+ List<FanUnitInfo> fanUnitInfoList = readFanUnitInfo(); //机组信息读取
|
|
|
+ //读取风速点表到缓存map中
|
|
|
+ readWindTurbinePowerCurveMap();
|
|
|
+
|
|
|
+ //整理风机编码及信息
|
|
|
+ for (FanUnitInfo fanUnitInfo:fanUnitInfoList
|
|
|
+ ) {
|
|
|
+ String[] fanarrs = fanUnitInfo.getFanNumArrs().split("\\|");
|
|
|
+ for (String fan: fanarrs) {
|
|
|
+ fanIdList.add(fan);//风机编号list
|
|
|
+ fanInfoMap.put(fan,fanUnitInfo);//风机编号为key的风机信息数据
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //读取以14号风机为基准的风速点表
|
|
|
+ readerSpeedSheet();
|
|
|
+
|
|
|
+ //读取检修计划参数
|
|
|
+ readerOverhual();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询nwp未来15天的数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<Nwp> getNwpDatasFromMongodb() {
|
|
|
+ long startTimes = UtilTools.getMillisecondsSubDay();
|
|
|
+ long endTimes = startTimes + dayNum * 24 * 60 * 60 * 1000 - 15 * 60 * 1000;
|
|
|
+ List<Nwp> listTemperature = nwpRepository.findByFarmIdAndPreTimeBetween(stationCodeStr, startTimes, endTimes);
|
|
|
+ //排序后根据预测时间过滤
|
|
|
+ listTemperature = listTemperature.stream().sorted(Comparator.comparing(Nwp::getPreTime)).filter(distinctByKey(Nwp::getPreTime)).collect(Collectors.toList());
|
|
|
+ return listTemperature;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据nwp的风速计算短期数据
|
|
|
+ * @param listTemperature
|
|
|
+ */
|
|
|
+ private List<PowerMeteoforce1> caculateDqs(List<Nwp> listTemperature) {
|
|
|
+
|
|
|
+ List<PowerMeteoforce1> powerMeteoforces = new ArrayList<>();
|
|
|
+ for (Nwp nwp: listTemperature) {
|
|
|
+
|
|
|
+ Float speed = Convert.toFloat(nwp.getWs30().setScale(1, RoundingMode.HALF_UP));
|
|
|
+
|
|
|
+ //风速小于3米每秒不发电
|
|
|
+ if(speed<3f) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //判断风速象限,不同风向获取不同风速列表
|
|
|
+ String fengxiangId = "1"; //东北风/西北风
|
|
|
+
|
|
|
+ Float wind = Convert.toFloat(nwp.getWd30());
|
|
|
+ if(90<= wind && wind<180){
|
|
|
+ fengxiangId = "2";//东南风
|
|
|
+ }else if(180<= wind && wind<270){
|
|
|
+ fengxiangId = "3";//西南风
|
|
|
+ }
|
|
|
+ //累加对应的所有风机功率值
|
|
|
+ Float totalPower = 0f;
|
|
|
+
|
|
|
+ //剔除检修风机
|
|
|
+ Map<String,List<String>> removeOverhaulFansMaps = removeOverhaulFans(fanIdList,new Date(nwp.getPreTime()));
|
|
|
+ //根据风向+风机模板id配置+风速 获取当前风速对应的其它风机应该有的风速list
|
|
|
+ List<String> fanKeys = removeOverhaulFansMaps.get(fengxiangId + "-" + modleFanId + "-" + speed);
|
|
|
+ for (String fanKey : fanKeys) {
|
|
|
+ //切出风机ID查询风机具体配置信息
|
|
|
+ FanUnitInfo fanInfo = fanInfoMap.get(fanKey.split("-")[0]);
|
|
|
+ //当前风速小于满发,查询点表发电功率
|
|
|
+ if (speed < fanInfo.getFullWindSpeed()) {
|
|
|
+ //根据风机曲线点表获取功率值
|
|
|
+ totalPower += windTurbinePowerCurveMaps.get(fanInfo.getId() + "").get(Convert.toFloat(fanKey.split("-")[1]));
|
|
|
+ } else if (speed > fanInfo.getCutOutSpeed()) {
|
|
|
+ //风速大于切出,发电为0
|
|
|
+ } else {
|
|
|
+ //在满发和切出之间,看具体机组信息和风速
|
|
|
+ for (CutOutSpeedSpecifyInfo cutOutSpeedSpecifyInfo : fanInfo.getCutOutSpeedSpecifyInfos()
|
|
|
+ ) {
|
|
|
+ if (speed >= cutOutSpeedSpecifyInfo.getLowerWindSpeedLimit()
|
|
|
+ && speed < cutOutSpeedSpecifyInfo.getHighWindSpeedLimit()) {
|
|
|
+ //当前风速的发电功率
|
|
|
+ totalPower += cutOutSpeedSpecifyInfo.getPowerGeneration();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PowerMeteoforce1 powerMeteoforce1 = new PowerMeteoforce1();
|
|
|
+ powerMeteoforce1.setCFarmId(stationCodeStr);
|
|
|
+ powerMeteoforce1.setCTime(new Date(nwp.getPreTime()));
|
|
|
+ powerMeteoforce1.setCForecast(Convert.toFloat(NumberUtil.round(totalPower/1000,2)));
|
|
|
+ //powerMeteoforce1.setCForecast(totalPower);
|
|
|
+ powerMeteoforce1.setNwpSpeed(speed);
|
|
|
+ powerMeteoforces.add(powerMeteoforce1);
|
|
|
+ }
|
|
|
+ return powerMeteoforces;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void fileCreate(List<PowerMeteoforce1> powerMeteoforces,String stationCode,String stationName) {
|
|
|
+ VelocityEngine ve = new VelocityEngine();
|
|
|
+ ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
|
|
|
+ ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
|
|
|
+ ve.setProperty("input.encoding", "UTF-8");
|
|
|
+ ve.setProperty("output.encoding", "UTF-8");
|
|
|
+ try {
|
|
|
+ ve.init();
|
|
|
+ Template dq = ve.getTemplate("DQ.vm");
|
|
|
+ String toDay = DateUtil.today();
|
|
|
+ String localPath = UtilTools.judeDirExists(UtilTools.getCreateFilePath() + stationCode+ File.separatorChar);
|
|
|
+ VelocityContext ctx;
|
|
|
+ String fileNameHouZui = UtilTools.getTimeShort() + "0.RB";
|
|
|
+
|
|
|
+ List<ForecastPowerShortTerm> listShort = getFormNwpsData(powerMeteoforces);
|
|
|
+ //排序后根据预测时间过滤
|
|
|
+ listShort = listShort.stream().sorted(Comparator.comparing(ForecastPowerShortTerm::getForecastTime)).filter(distinctByKey(ForecastPowerShortTerm::getForecastTime)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (listShort.size() > 0) {
|
|
|
+ listShort = getDataDQ(listShort, Long.valueOf(dayNum),stationCode);
|
|
|
+ //生成短期文件
|
|
|
+ ctx = new VelocityContext();
|
|
|
+
|
|
|
+ ctx.put("entity", stationName);
|
|
|
+ ctx.put("date", toDay);
|
|
|
+ ctx.put("vList", listShort);
|
|
|
+
|
|
|
+ String fileName = "DQ_" + toDay.replaceAll("-", "") + fileNameHouZui;
|
|
|
+ UtilTools.merge(dq, ctx, localPath + fileName);//本地化模型文件格式DQ_201808080000000.RB
|
|
|
+ log.debug(toDay + "---------文件生成位置:" + localPath + fileName + "---------------");
|
|
|
+ File fileTemp = new File(localPath + fileName);
|
|
|
+ UtilTools.uploadFile(stationCode + "/" + fileName, fileTemp);
|
|
|
+ //请求云预测记录文件生成记录
|
|
|
+ postFileToV3Cloud(stationCodeStr,fileName);
|
|
|
+ } else {
|
|
|
+ log.error("无法生成短期文件,没查到短期数据");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("马头山短期文件生成错误:{}",e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 读取机组信息
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<FanUnitInfo> readFanUnitInfo(){
|
|
|
+
|
|
|
+ List<FanUnitInfo> fanUnitInfoList = fanUnitInfoRepository.findAll();
|
|
|
+
|
|
|
+ List<CutOutSpeedSpecifyInfo> cutOutSpeedSpecifyInfoList = readFanCutOutSpeedInfo(); //机组信息读取
|
|
|
+ modleFanId = fanUnitInfoList.get(0).getBenchmarkFan();
|
|
|
+ for (FanUnitInfo fanUnitInfo:fanUnitInfoList) {
|
|
|
+
|
|
|
+ //把机组切出风速参数填充到机组信息中
|
|
|
+ for (CutOutSpeedSpecifyInfo cutOutSpeedSpecifyInfo:cutOutSpeedSpecifyInfoList) {
|
|
|
+ if(fanUnitInfo.getId() == cutOutSpeedSpecifyInfo.getUnitBelongs()){
|
|
|
+ if(null == fanUnitInfo.getCutOutSpeedSpecifyInfos()){
|
|
|
+ fanUnitInfo.setCutOutSpeedSpecifyInfos(new ArrayList<>());
|
|
|
+ }
|
|
|
+ fanUnitInfo.getCutOutSpeedSpecifyInfos().add(cutOutSpeedSpecifyInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return fanUnitInfoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 读取风速曲线点表
|
|
|
+ */
|
|
|
+ private void readWindTurbinePowerCurveMap() {
|
|
|
+ Map<Float,Float> mapSpeed = new HashMap<>();
|
|
|
+ List<WindTurbinePowerCurve> windTurbinePowerCurves = windTurbinePowerCurveRepository.findAll();
|
|
|
+ for(WindTurbinePowerCurve windTurbinePowerCurve: windTurbinePowerCurves){
|
|
|
+ mapSpeed.put(windTurbinePowerCurve.getSpeed(),windTurbinePowerCurve.getPower());
|
|
|
+ windTurbinePowerCurveMaps.put(String.valueOf(windTurbinePowerCurve.getFanId()),mapSpeed);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 满发风速之后各风速发电曲线
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<CutOutSpeedSpecifyInfo> readFanCutOutSpeedInfo() {
|
|
|
+ return cutOutSpeedSpecifyInfoRepository.findAll();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 读取 东北风向风速 东南风向风速 西南风向风速 西北风向风速 4个sheet表风速点表
|
|
|
+ */
|
|
|
+ private void readerSpeedSheet() {
|
|
|
+
|
|
|
+ List<WindSpeedPointInfo> WindSpeedPointInfos = windSpeedPointInfoRepository.findAll();
|
|
|
+ Map<String,List<String>> moduleFanMaps = new HashMap<>();
|
|
|
+ Map<Integer,List<String>> valMap = new HashMap<>();
|
|
|
+ Map<Integer,String> keyMap = new HashMap<>();
|
|
|
+ List<String> stringList = new ArrayList<>();
|
|
|
+ String modelFanName = null;
|
|
|
+ Integer belong = 1;
|
|
|
+ for (int i = 1; i < WindSpeedPointInfos.size(); i++) {
|
|
|
+ modelFanName = WindSpeedPointInfos.get(0).getFanNumber();
|
|
|
+ belong = WindSpeedPointInfos.get(0).getBelong();
|
|
|
+ if (i == 1 ){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (int i = 0; i < WindSpeedPointInfos.size(); i++) {
|
|
|
+ if (WindSpeedPointInfos.get(i).getBelong() != belong) {
|
|
|
+ valMap.put(belong,stringList);
|
|
|
+ }
|
|
|
+ if (WindSpeedPointInfos.get(i).getFanNumber().equals(modelFanName)) {
|
|
|
+ belong = WindSpeedPointInfos.get(i).getBelong();
|
|
|
+ stringList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ if (!WindSpeedPointInfos.get(i).getFanNumber().equals(modelFanName)) {
|
|
|
+ String str = Convert.toStr(WindSpeedPointInfos.get(i).getFanNumber()) + "-"
|
|
|
+ + Convert.toFloat(new Formatter().format("%.1f", Convert.toDouble(WindSpeedPointInfos.get(i).getSpeed())));
|
|
|
+ stringList.add(str);
|
|
|
+ }
|
|
|
+ if (WindSpeedPointInfos.get(i).getFanNumber().equals(modelFanName)) {
|
|
|
+ String kString = WindSpeedPointInfos.get(i).getWind()+"-"+WindSpeedPointInfos.get(i).getFanNumber()+ "-"+Convert.toFloat(new Formatter().format("%.1f",Convert.toDouble( WindSpeedPointInfos.get(i).getSpeed())));
|
|
|
+ keyMap.put(belong,kString);
|
|
|
+ }
|
|
|
+ keyMap.forEach((k,v) -> {
|
|
|
+ valMap.forEach((k2,v2) -> {
|
|
|
+ if(k2==k){
|
|
|
+ moduleFanMaps.put(v,v2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 读取检修计划数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void readerOverhual() {
|
|
|
+ overhaulInfos = overhaulPlanRepository.findAll();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 过滤重复数据
|
|
|
+ *
|
|
|
+ * @param keyExtractor
|
|
|
+ * @param <T>
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
|
|
|
+ Map<Object, Boolean> seen = new ConcurrentHashMap<>();
|
|
|
+ return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 移除当前时间在检修中的设备id
|
|
|
+ * @param fanIdList
|
|
|
+ * @param c_time
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String,List<String>> removeOverhaulFans(List<String> fanIdList, Date c_time) {
|
|
|
+
|
|
|
+ if(null == overhaulInfos || overhaulInfos.size()==0){
|
|
|
+ return moduleFanMaps;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> runFans = removeFanIdByOverhual(fanIdList, c_time,overhaulInfos);
|
|
|
+
|
|
|
+ Map<String,List<String>> removeOverhaulFansMaps = moduleFanMaps;
|
|
|
+ for (String str:runFans
|
|
|
+ ) {
|
|
|
+ removeOverhaulFansMaps.forEach((key, value) -> {
|
|
|
+ value.removeIf(e -> e.contains(str));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return removeOverhaulFansMaps;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查正常运行的风机,删除检修状态的风机
|
|
|
+ * @param fanIdList
|
|
|
+ * @param c_time
|
|
|
+ * @param overhaulInfos
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<String> removeFanIdByOverhual(List<String> fanIdList, Date c_time, List<OverhaulPlan> overhaulInfos) {
|
|
|
+ List<String> runFanIds= new ArrayList<>();
|
|
|
+ for (String fanId:fanIdList
|
|
|
+ ) {
|
|
|
+ for (OverhaulPlan overhaul: overhaulInfos
|
|
|
+ ) {
|
|
|
+ //风机编号相同且在检修时间
|
|
|
+ if(fanId.equals(overhaul.getName())){
|
|
|
+ if( c_time.after(DateUtil.date(overhaul.getStartTime())) && c_time.before(DateUtil.date(overhaul.getEndTime()))){
|
|
|
+ runFanIds.add(fanId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return runFanIds;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ForecastPowerShortTerm> getDataDQ(List<ForecastPowerShortTerm> shortTermForcastList, Long ycts,String stationCode) {
|
|
|
+
|
|
|
+ List<ForecastPowerShortTerm> dm = new ArrayList<>();
|
|
|
+ dm.addAll(shortTermForcastList);
|
|
|
+ int index = dm.size();
|
|
|
+
|
|
|
+ Long timeD = 15 * 60 * 1000L;
|
|
|
+ Long lt = dm.get(dm.size() - 1).getForecastTime();
|
|
|
+ int i = 1;
|
|
|
+ //第11天数据不够,进行数据补充 ,如果预测值不为0 取预测-预测*1.1之间的随机值
|
|
|
+ while (shortTermForcastList.size() < ycts * 96) {
|
|
|
+ ForecastPowerShortTerm shortTermForcast = new ForecastPowerShortTerm();
|
|
|
+
|
|
|
+ if (dm.get(index - i).getFpValue().doubleValue() > 0) {
|
|
|
+ {
|
|
|
+ double randomDouble = RandomUtil.randomDouble(dm.get(index - i).getFpValue().doubleValue(), dm.get(index - i).getFpValue().doubleValue() * 1.1, 2, RoundingMode.HALF_UP);
|
|
|
+ shortTermForcast.setFpValue(new BigDecimal(randomDouble).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ shortTermForcast.setFpValue(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+ shortTermForcast.setForecastTime(lt + timeD * i);
|
|
|
+ if (dm.get(index - i).getFpValue().doubleValue() > 0) {
|
|
|
+ {
|
|
|
+ double randomDouble = RandomUtil.randomDouble(dm.get(index - i).getFpValue().doubleValue(), dm.get(index - i).getFpValue().doubleValue() * 1.1, 2, RoundingMode.HALF_UP);
|
|
|
+ shortTermForcast.setFpValue(new BigDecimal(randomDouble).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ shortTermForcast.setFpValue(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+// shortTermForcast.setStationCode(stationCode);
|
|
|
+ shortTermForcastList.add(shortTermForcast);
|
|
|
+ if (i == index) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ return shortTermForcastList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 本地短期对象转换为原v3云预测所用对象
|
|
|
+ * @param powerMeteoforces
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<ForecastPowerShortTerm> getFormNwpsData(List<PowerMeteoforce1> powerMeteoforces) {
|
|
|
+ List<ForecastPowerShortTerm> listShort = new ArrayList<>();
|
|
|
+ for (PowerMeteoforce1 power:powerMeteoforces
|
|
|
+ ) {
|
|
|
+ ForecastPowerShortTerm forcastDataDQ = new ForecastPowerShortTerm();
|
|
|
+// forcastDataDQ.setStationCode(power.getCFarmId());
|
|
|
+ forcastDataDQ.setForecastTime(power.getCTime().getTime());
|
|
|
+// forcastDataDQ.setForcastTimeString(DateTimeUtil.dateToStrLong(power.getCTime()));
|
|
|
+ forcastDataDQ.setFpValue(new BigDecimal(power.getCForecast()));
|
|
|
+// forcastDataDQ.setModifyValue(new BigDecimal(power.getCForecast()).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ listShort.add(forcastDataDQ);
|
|
|
+ }
|
|
|
+ return listShort;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void postFileToV3Cloud(String stationCode,String fileName){
|
|
|
+ Map<String, Object> parmer = new HashMap<>();
|
|
|
+ parmer.put("stationCode", stationCode);
|
|
|
+ parmer.put("fileName", fileName);
|
|
|
+ String response = HttpUtil.post("http://117.78.19.70:9009/client/saveFileLogsForAio", parmer);
|
|
|
+ //String response = HttpUtil.post("http://127.0.0.1:9009/client/saveFileLogsForAio", parmer);
|
|
|
+ if (StringUtils.isNotEmpty(response)) {
|
|
|
+ boolean isJson = JSONUtil.isJsonObj(response);
|
|
|
+ if (isJson) {
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(response);
|
|
|
+ String code = jsonObject.getStr("code");
|
|
|
+ if (code.equals("0")) {
|
|
|
+ log.warn("minlo上送日志响应正常");
|
|
|
+ } else {
|
|
|
+ log.warn("minlo上送日志响应不为0");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.warn("minlo上送日志响应格式不对");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|