|
@@ -7,12 +7,13 @@ 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.exception.BusinessException;
|
|
|
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.common.data.service.BaseService;
|
|
|
import com.jiayue.ipfcst.console.service.NwpService;
|
|
|
+import com.jiayue.ipfcst.console.service.SysParameterService;
|
|
|
import com.jiayue.ipfcst.fileupload.util.UtilTools;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -24,13 +25,17 @@ 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.text.DateFormat;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.function.Predicate;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -41,10 +46,12 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
-public class UploadFileMatoushanJob {
|
|
|
+public class UploadFileMatoushanJob extends BaseService {
|
|
|
@Autowired
|
|
|
NwpRepository nwpRepository;
|
|
|
@Autowired
|
|
|
+ NwpService nwpService;
|
|
|
+ @Autowired
|
|
|
FanUnitInfoRepository fanUnitInfoRepository;
|
|
|
@Autowired
|
|
|
WindTurbinePowerCurveRepository windTurbinePowerCurveRepository;
|
|
@@ -54,11 +61,18 @@ public class UploadFileMatoushanJob {
|
|
|
WindSpeedPointInfoRepository windSpeedPointInfoRepository;
|
|
|
@Autowired
|
|
|
OverhaulPlanRepository overhaulPlanRepository;
|
|
|
+ @Autowired
|
|
|
+ SysParameterService sysParameterService;
|
|
|
+ @Autowired
|
|
|
+ ForecastPowerShortTermRepository forecastPowerShortTermRepository;
|
|
|
+ @Autowired
|
|
|
+ ModifyShorterDataRepository modifyShorterDataRepository;
|
|
|
+
|
|
|
//模板风机为key,其它风机id及风速为value
|
|
|
- public static Map<String, List<String>> moduleFanMaps = new HashMap<>();
|
|
|
+ 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 List<OverhaulPlan> overhaulPlans = new ArrayList<>();
|
|
|
public static Map<String,Map<Float,Float>> windTurbinePowerCurveMaps = new HashMap<>();
|
|
|
//模板机ID
|
|
|
public static String modleFanId = "";
|
|
@@ -77,23 +91,22 @@ public class UploadFileMatoushanJob {
|
|
|
* 马头山查询nwp数据生成短期预测文件
|
|
|
*/
|
|
|
//@Scheduled(fixedRate = 1000*60)
|
|
|
- @Scheduled(cron = "30 30 5 * * ?")
|
|
|
+ // 30 30 5 * * ? 0/1 * * * * ?
|
|
|
+ // 30 10,25,30 5,17 * * ?
|
|
|
+ @Scheduled(cron = "30 10,25,30 5,17 * * ?")
|
|
|
public void createDqFile() {
|
|
|
log.info("时间 【" + DateTimeUtil.dateToStrLong(new Date()) + "】 马头山短期文件生成开始");
|
|
|
//1.读取本地Excel配置
|
|
|
readExcelForParams();
|
|
|
//2.查询mongodb中的nwp数据
|
|
|
- List<Nwp> listTemperature = getNwpDatasFromMongodb();
|
|
|
+ List<Nwp> listTemperature = getNwpDatas();
|
|
|
//3.计算短期预测
|
|
|
- List<PowerMeteoforce1> powerMeteoforces = caculateDqs(listTemperature);
|
|
|
+ List<ForecastPowerShortTerm> forecastPowerShortTermList = caculateDqs(listTemperature);
|
|
|
//4.生成短期文件并上传minio,向v3请求文件记录写入
|
|
|
- fileCreate(powerMeteoforces,stationCodeStr,"马头山风电场");
|
|
|
|
|
|
log.info("时间 【" + DateTimeUtil.dateToStrLong(new Date()) + "】 马头山短期文件生成完成");
|
|
|
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 读取excel中配置参数
|
|
|
*/
|
|
@@ -112,13 +125,6 @@ public class UploadFileMatoushanJob {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//读取以14号风机为基准的风速点表
|
|
|
readerSpeedSheet();
|
|
|
|
|
@@ -130,41 +136,58 @@ public class UploadFileMatoushanJob {
|
|
|
* 查询nwp未来15天的数据
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<Nwp> getNwpDatasFromMongodb() {
|
|
|
+ private List<Nwp> getNwpDatas() {
|
|
|
long startTimes = UtilTools.getMillisecondsSubDay();
|
|
|
long endTimes = startTimes + dayNum * 24 * 60 * 60 * 1000 - 15 * 60 * 1000;
|
|
|
- List<Nwp> listTemperature = nwpRepository.findByFarmIdAndPreTimeBetween(stationCodeStr, startTimes, endTimes);
|
|
|
+ List<Nwp> listTemperature = nwpRepository.findByPreTimeBetween(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) {
|
|
|
+ private List<ForecastPowerShortTerm> caculateDqs(List<Nwp> listTemperature) {
|
|
|
+
|
|
|
+ // 是否开启了结冰停机 1开启
|
|
|
+ String yesorno_start_icing_shotdown = super.getSysParameter("YESORNO_START_ICING_SHOTDOWN", "0");
|
|
|
+ // 是否开启了解冻开机 1开启
|
|
|
+ String yesorno_start_thaw_boot = super.getSysParameter("YESORNO_START_THAW_BOOT", "0");
|
|
|
|
|
|
- List<PowerMeteoforce1> powerMeteoforces = new ArrayList<>();
|
|
|
+
|
|
|
+ List<ForecastPowerShortTerm> forecastPowerShortTermList = new ArrayList<>();
|
|
|
for (Nwp nwp: listTemperature) {
|
|
|
|
|
|
- Float speed = Convert.toFloat(nwp.getWs30().setScale(1, RoundingMode.HALF_UP));
|
|
|
+ Float speed = Convert.toFloat(nwp.getWs70().setScale(1, RoundingMode.HALF_UP));
|
|
|
|
|
|
//风速小于3米每秒不发电
|
|
|
if(speed<3f) {
|
|
|
+ ForecastPowerShortTerm forecastPowerShortTerm = new ForecastPowerShortTerm();
|
|
|
+ forecastPowerShortTerm.setForecastTime(nwp.getPreTime());
|
|
|
+ forecastPowerShortTerm.setFpValue(BigDecimal.ZERO);
|
|
|
+ forecastPowerShortTermList.add(forecastPowerShortTerm);
|
|
|
continue;
|
|
|
}
|
|
|
//判断风速象限,不同风向获取不同风速列表
|
|
|
- String fengxiangId = "1"; //东北风/西北风
|
|
|
-
|
|
|
+ String fengxiangId = "1"; // 北风
|
|
|
Float wind = Convert.toFloat(nwp.getWd30());
|
|
|
- if(90<= wind && wind<180){
|
|
|
- fengxiangId = "2";//东南风
|
|
|
- }else if(180<= wind && wind<270){
|
|
|
- fengxiangId = "3";//西南风
|
|
|
+ if(22.5 <= wind && wind < 67.5){
|
|
|
+ fengxiangId = "2"; // 东北风
|
|
|
+ }else if(67.5 <= wind && wind < 112.5){
|
|
|
+ fengxiangId = "3"; // 东风
|
|
|
+ }else if(112.5 <= wind && wind < 157.5){
|
|
|
+ fengxiangId = "4"; // 东南风
|
|
|
+ }else if(157.5 <= wind && wind < 202.5){
|
|
|
+ fengxiangId = "5"; // 南风
|
|
|
+ }else if(202.5 <= wind && wind < 247.5 ){
|
|
|
+ fengxiangId = "6"; // 西南风
|
|
|
+ }else if(247.5 <= wind && wind < 292.5){
|
|
|
+ fengxiangId = "7"; // 西风
|
|
|
+ }else if(292.5 <= wind && wind < 337.5){
|
|
|
+ fengxiangId = "8"; // 西北风
|
|
|
}
|
|
|
//累加对应的所有风机功率值
|
|
|
Float totalPower = 0f;
|
|
@@ -173,79 +196,76 @@ public class UploadFileMatoushanJob {
|
|
|
Map<String,List<String>> removeOverhaulFansMaps = removeOverhaulFans(fanIdList,new Date(nwp.getPreTime()));
|
|
|
//根据风向+风机模板id配置+风速 获取当前风速对应的其它风机应该有的风速list
|
|
|
List<String> fanKeys = removeOverhaulFansMaps.get(fengxiangId + "-" + modleFanId + "-" + speed);
|
|
|
+ if(null == fanKeys){
|
|
|
+ System.out.println(modleFanId);
|
|
|
+ }
|
|
|
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()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (speed >= fanInfo.getCutOutSpeed()) {
|
|
|
//风速大于切出,发电为0
|
|
|
- } else {
|
|
|
+ totalPower += 0;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //大于满发风速
|
|
|
+ if (speed >= fanInfo.getFullWindSpeed()) {
|
|
|
+ //满发和切出之间的功率值
|
|
|
+ Float totalPowerTemp = 0f;
|
|
|
//在满发和切出之间,看具体机组信息和风速
|
|
|
for (CutOutSpeedSpecifyInfo cutOutSpeedSpecifyInfo : fanInfo.getCutOutSpeedSpecifyInfos()
|
|
|
) {
|
|
|
+ //
|
|
|
if (speed >= cutOutSpeedSpecifyInfo.getLowerWindSpeedLimit()
|
|
|
&& speed < cutOutSpeedSpecifyInfo.getHighWindSpeedLimit()) {
|
|
|
//当前风速的发电功率
|
|
|
- totalPower += cutOutSpeedSpecifyInfo.getPowerGeneration();
|
|
|
+ totalPowerTemp += cutOutSpeedSpecifyInfo.getPowerGeneration();
|
|
|
}
|
|
|
}
|
|
|
+ //满发风速和切出 之间无发电则是在满发状态
|
|
|
+ if(totalPowerTemp == 0){
|
|
|
+ totalPower += fanInfo.getFanUnitCapacity();
|
|
|
+ }else{
|
|
|
+ totalPower += totalPowerTemp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ForecastPowerShortTerm forecastPowerShortTerm = new ForecastPowerShortTerm();
|
|
|
+ forecastPowerShortTerm.setForecastTime(nwp.getPreTime());
|
|
|
+ forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000,2));
|
|
|
+
|
|
|
+ // 是否开启了结冰停机
|
|
|
+ if(yesorno_start_icing_shotdown.equals("1")){
|
|
|
+ List<IcingShutdown> icingShutdowns = parkedWindTurbine();
|
|
|
+ for(IcingShutdown icingShutdown:icingShutdowns){
|
|
|
+ if(icingShutdown.getStartTime() < nwp.getPreTime() && nwp.getPreTime() < icingShutdown.getEndTime()){
|
|
|
+ forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000 - 2 * icingShutdown.getShutDownNumber(),2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 是否开启了解冻开机
|
|
|
+ if(yesorno_start_thaw_boot.equals("1")){
|
|
|
+ List<IcingShutdown> icingShutdowns = parkedWindTurbine();
|
|
|
+ for(IcingShutdown icingShutdown:icingShutdowns){
|
|
|
+ if(icingShutdown.getStartTime() < nwp.getPreTime() && nwp.getPreTime() < icingShutdown.getEndTime()){
|
|
|
+ forecastPowerShortTerm.setFpValue(NumberUtil.round(totalPower/1000 + 2 * icingShutdown.getShutDownNumber(),2));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- 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("无法生成短期文件,没查到短期数据");
|
|
|
+ // 计算超装机容量设置为92.7
|
|
|
+ if(forecastPowerShortTerm.getFpValue().compareTo(new BigDecimal(93))> 0 ){
|
|
|
+ forecastPowerShortTerm.setFpValue(BigDecimal.valueOf(random()));
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("马头山短期文件生成错误:{}",e);
|
|
|
+ forecastPowerShortTermList.add(forecastPowerShortTerm);
|
|
|
}
|
|
|
+ List<ForecastPowerShortTerm> forecastPowerShortTerms = modifyShorterData(forecastPowerShortTermList);
|
|
|
+ return forecastPowerShortTerms;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -253,8 +273,7 @@ public class UploadFileMatoushanJob {
|
|
|
* 读取机组信息
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<FanUnitInfo> readFanUnitInfo(){
|
|
|
-
|
|
|
+ private List<FanUnitInfo> readFanUnitInfo(){
|
|
|
List<FanUnitInfo> fanUnitInfoList = fanUnitInfoRepository.findAll();
|
|
|
|
|
|
List<CutOutSpeedSpecifyInfo> cutOutSpeedSpecifyInfoList = readFanCutOutSpeedInfo(); //机组信息读取
|
|
@@ -263,7 +282,7 @@ public class UploadFileMatoushanJob {
|
|
|
|
|
|
//把机组切出风速参数填充到机组信息中
|
|
|
for (CutOutSpeedSpecifyInfo cutOutSpeedSpecifyInfo:cutOutSpeedSpecifyInfoList) {
|
|
|
- if(fanUnitInfo.getId() == cutOutSpeedSpecifyInfo.getUnitBelongs()){
|
|
|
+ if(fanUnitInfo.getFanId() == cutOutSpeedSpecifyInfo.getFanId()){
|
|
|
if(null == fanUnitInfo.getCutOutSpeedSpecifyInfos()){
|
|
|
fanUnitInfo.setCutOutSpeedSpecifyInfos(new ArrayList<>());
|
|
|
}
|
|
@@ -279,12 +298,21 @@ public class UploadFileMatoushanJob {
|
|
|
* 读取风速曲线点表
|
|
|
*/
|
|
|
private void readWindTurbinePowerCurveMap() {
|
|
|
+
|
|
|
+ //查询风功率曲线
|
|
|
+ List<WindTurbinePowerCurve> windTurbinePowerCurves = windTurbinePowerCurveRepository.findAll();
|
|
|
+ //并按照机组id区分不同map
|
|
|
+ Map<Integer, List<WindTurbinePowerCurve>> windTurbineMap = windTurbinePowerCurves.stream().collect(Collectors.groupingBy(WindTurbinePowerCurve::getFanId));
|
|
|
+ windTurbineMap.forEach((fanId, v) -> {
|
|
|
+ //遍历不同机组的风速发电曲线,已风速为key,功率为value构造map
|
|
|
Map<Float,Float> mapSpeed = new HashMap<>();
|
|
|
- List<WindTurbinePowerCurve> windTurbinePowerCurves = windTurbinePowerCurveRepository.findAll();
|
|
|
- for(WindTurbinePowerCurve windTurbinePowerCurve: windTurbinePowerCurves){
|
|
|
+ v.forEach(windTurbinePowerCurve -> {
|
|
|
mapSpeed.put(windTurbinePowerCurve.getSpeed(),windTurbinePowerCurve.getPower());
|
|
|
- windTurbinePowerCurveMaps.put(String.valueOf(windTurbinePowerCurve.getFanId()),mapSpeed);
|
|
|
- }
|
|
|
+ });
|
|
|
+ //缓存风功率数据
|
|
|
+ windTurbinePowerCurveMaps.put(String.valueOf(fanId),mapSpeed);
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -292,53 +320,52 @@ public class UploadFileMatoushanJob {
|
|
|
* @return
|
|
|
*/
|
|
|
private List<CutOutSpeedSpecifyInfo> readFanCutOutSpeedInfo() {
|
|
|
- return cutOutSpeedSpecifyInfoRepository.findAll();
|
|
|
+ return cutOutSpeedSpecifyInfoRepository.findAll();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 读取 东北风向风速 东南风向风速 西南风向风速 西北风向风速 4个sheet表风速点表
|
|
|
+ *
|
|
|
+ * 构造map
|
|
|
+ * key:风向+基准风机编号+基准风机对应的风速
|
|
|
+ * value:所有 风机的 :风机编号+其风速
|
|
|
+ *
|
|
|
+ *
|
|
|
+ *
|
|
|
*/
|
|
|
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);
|
|
|
+ //基准风机的风机编号
|
|
|
+ String modleFanId = fanUnitInfoRepository.findAll().get(0).getBenchmarkFan();
|
|
|
+ AtomicReference<Float> modleFanSpeed = new AtomicReference<>(0f);
|
|
|
+
|
|
|
+ //按照4个风向分组,以风向为key,每个风向的数据为value list
|
|
|
+ Map<Integer, List<WindSpeedPointInfo>> map = WindSpeedPointInfos.stream().collect(Collectors.groupingBy(WindSpeedPointInfo::getWind));
|
|
|
+
|
|
|
+ map.forEach((wind, v) -> {
|
|
|
+ //遍历每个风向下的点值,按照所属序号进行分组合并
|
|
|
+ Map<Integer, List<WindSpeedPointInfo>> belongList = v.stream().collect(Collectors.groupingBy(WindSpeedPointInfo::getBelong));
|
|
|
+ //遍历每个风向下每个组风速数据,构造map点表数据
|
|
|
+ belongList.forEach((belongKey, windSpeedPointInfoList) -> {
|
|
|
+ //遍历每组风速
|
|
|
+ List<String> valueList = new ArrayList<>();
|
|
|
+ windSpeedPointInfoList.forEach(windSpeedPointInfo -> {
|
|
|
+ //当前数据是基准风机的,取基准风机的风速用做key值
|
|
|
+ if(modleFanId.equals(windSpeedPointInfo.getFanNumber())){
|
|
|
+ modleFanSpeed.set(windSpeedPointInfo.getSpeed());
|
|
|
}
|
|
|
+ //每行统计以基准风机为节点的风速数据的集合 风机编号+风速
|
|
|
+ String str = Convert.toStr(windSpeedPointInfo.getFanNumber()) + "-"
|
|
|
+ + Convert.toFloat(new Formatter().format("%.1f", Convert.toDouble(windSpeedPointInfo.getSpeed())));
|
|
|
+ valueList.add(str);
|
|
|
});
|
|
|
+ //以风向+基准风机编号+风速 为key
|
|
|
+ String keyString = wind+"-"+modleFanId+ "-"+Convert.toFloat(new Formatter().format("%.1f",Convert.toDouble(modleFanSpeed.get())));
|
|
|
+ //缓存点表数据
|
|
|
+ moduleFanMaps.put(keyString,valueList);
|
|
|
});
|
|
|
- }
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|
|
@@ -347,7 +374,7 @@ public class UploadFileMatoushanJob {
|
|
|
* @return
|
|
|
*/
|
|
|
private void readerOverhual() {
|
|
|
- overhaulInfos = overhaulPlanRepository.findAll();
|
|
|
+ overhaulPlans = overhaulPlanRepository.findAll();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -367,16 +394,15 @@ public class UploadFileMatoushanJob {
|
|
|
* 移除当前时间在检修中的设备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){
|
|
|
+ if(null == overhaulPlans || overhaulPlans.size()==0){
|
|
|
return moduleFanMaps;
|
|
|
}
|
|
|
|
|
|
- List<String> runFans = removeFanIdByOverhual(fanIdList, c_time,overhaulInfos);
|
|
|
+ List<String> runFans = removeFanIdByOverhual(fanIdList, c_time,overhaulPlans);
|
|
|
|
|
|
Map<String,List<String>> removeOverhaulFansMaps = moduleFanMaps;
|
|
|
for (String str:runFans
|
|
@@ -393,18 +419,18 @@ public class UploadFileMatoushanJob {
|
|
|
* 检查正常运行的风机,删除检修状态的风机
|
|
|
* @param fanIdList
|
|
|
* @param c_time
|
|
|
- * @param overhaulInfos
|
|
|
+ * @param
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<String> removeFanIdByOverhual(List<String> fanIdList, Date c_time, List<OverhaulPlan> overhaulInfos) {
|
|
|
+ private List<String> removeFanIdByOverhual(List<String> fanIdList, Date c_time, List<OverhaulPlan> overhaulPlans) {
|
|
|
List<String> runFanIds= new ArrayList<>();
|
|
|
for (String fanId:fanIdList
|
|
|
) {
|
|
|
- for (OverhaulPlan overhaul: overhaulInfos
|
|
|
+ for (OverhaulPlan overhaul: overhaulPlans
|
|
|
) {
|
|
|
//风机编号相同且在检修时间
|
|
|
if(fanId.equals(overhaul.getName())){
|
|
|
- if( c_time.after(DateUtil.date(overhaul.getStartTime())) && c_time.before(DateUtil.date(overhaul.getEndTime()))){
|
|
|
+ if( c_time.after(new Date(overhaul.getStartTime())) && c_time.before(new Date(overhaul.getEndTime()))){
|
|
|
runFanIds.add(fanId);
|
|
|
}
|
|
|
}
|
|
@@ -414,87 +440,335 @@ public class UploadFileMatoushanJob {
|
|
|
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();
|
|
|
+ /**
|
|
|
+ * 修改短期系数
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ForecastPowerShortTerm> modifyShorterData(List<ForecastPowerShortTerm> forecastPowerShortTermList){
|
|
|
+ List<ModifyShorterData> modifyShorterDataList = modifyShorterDataRepository.findByStartTimeAfter(new Date());
|
|
|
+ DecimalFormat decimalFormat=new DecimalFormat(".00");
|
|
|
+ for(ModifyShorterData m: modifyShorterDataList){
|
|
|
+ Date startTime = m.getStartTime();
|
|
|
+ Date endTime = m.getEndTime();
|
|
|
+ for(ForecastPowerShortTerm f: forecastPowerShortTermList){
|
|
|
+ // 修改短期数据
|
|
|
+ if(new Date(f.getForecastTime()).after(startTime) && new Date(f.getForecastTime()).before(endTime)){
|
|
|
+ f.setFpValue(f.getFpValue().multiply(new BigDecimal(m.getModulus())));
|
|
|
+ }
|
|
|
+ // 计算超装机容量设置为92.7
|
|
|
+ if(f.getFpValue().compareTo(new BigDecimal(93)) > 0){
|
|
|
+ f.setFpValue(new BigDecimal(random()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return modifyMinPower(forecastPowerShortTermList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据时间段修改最小值
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<ForecastPowerShortTerm> modifyMinPower(List<ForecastPowerShortTerm> forecastPowerShortTermList) {
|
|
|
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ for (ForecastPowerShortTerm f : forecastPowerShortTermList) {
|
|
|
+ // 获取当前预测时间
|
|
|
+ String pDate = dateFormat.format(f.getForecastTime());
|
|
|
+ String[] pDateArr = pDate.split(" ");
|
|
|
+ String nineDate = pDateArr[0] +" "+ "00:00:00";
|
|
|
+ String ntDate = pDateArr[0] +" "+ "00:30:00";
|
|
|
+ String tenDate = pDateArr[0] +" "+ "22:00:00";
|
|
|
+ String fiveDate = pDateArr[0] +" "+ "05:00:00";
|
|
|
+ String sixDate = pDateArr[0] +" "+ "06:00:00";
|
|
|
+ Date nDate = null;
|
|
|
+ Date nHDate = null;
|
|
|
+ Date tDate = null;
|
|
|
+ Date fDate = null;
|
|
|
+ Date nextFDate = null;
|
|
|
+ Date sDate = null;
|
|
|
+ try {
|
|
|
+ nDate = dateFormat.parse(nineDate);
|
|
|
+ nHDate = dateFormat.parse(ntDate);
|
|
|
+ tDate = dateFormat.parse(tenDate);
|
|
|
+ fDate = dateFormat.parse(fiveDate);
|
|
|
+ nextFDate = new Date(fDate.getTime()+1000 * 60 * 60 * 24*1);
|
|
|
+ sDate = dateFormat.parse(sixDate);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ // 九点的时候 小于2 设置为2
|
|
|
+ if (f.getForecastTime() > nDate.getTime() && f.getForecastTime() < nHDate.getTime() && f.getFpValue().compareTo(new BigDecimal(2)) > 0) {
|
|
|
+ f.setFpValue(new BigDecimal(2));
|
|
|
+ }
|
|
|
+ if(dateFormat.format(f.getForecastTime()).equals(ntDate) && f.getFpValue().compareTo(new BigDecimal(3)) < 0) {
|
|
|
+ f.setFpValue(new BigDecimal(3));
|
|
|
+ }
|
|
|
+ if(new Date(f.getForecastTime()).after(tDate) && new Date(f.getForecastTime()).before(nextFDate) && f.getFpValue().compareTo(new BigDecimal(3.8)) < 0) {
|
|
|
+ f.setFpValue(new BigDecimal(3.8));
|
|
|
+ }
|
|
|
+ if(new Date(f.getForecastTime()).after(fDate) && new Date(f.getForecastTime()).before(sDate) && f.getFpValue().compareTo(new BigDecimal(2)) < 0) {
|
|
|
+ f.setFpValue(new BigDecimal(2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return forecastPowerShortTermList;
|
|
|
+ }
|
|
|
|
|
|
- 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();
|
|
|
+ // 随机数80-90
|
|
|
+ public Float random(){
|
|
|
+ Random r = new Random();
|
|
|
+ DecimalFormat df= new DecimalFormat( "0.00");
|
|
|
+ float randomFloat = r.nextFloat() * (90 - 80) + 80;
|
|
|
+ String format = df.format(randomFloat);
|
|
|
+ return Float.parseFloat(format);
|
|
|
+ }
|
|
|
|
|
|
- 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));
|
|
|
+ /**
|
|
|
+ * 结冰停机
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<IcingShutdown> parkedWindTurbine(){
|
|
|
+ // 停机温度
|
|
|
+ BigDecimal down_the_temperature = new BigDecimal(super.getSysParameter("DOWN_THE_TEMPERATURE", "-4"));
|
|
|
+ // 结冰降水量阈值
|
|
|
+ BigDecimal tpr_threshold = new BigDecimal(super.getSysParameter("TPR_THRESHOLD", "1.0000"));
|
|
|
+ // 持续降雪多长时间开始结冰 马头山
|
|
|
+ String duration_of_snow_m = super.getSysParameter("DURATION_OF_SNOW_M", "30");
|
|
|
+ // 持续降雪多长时间开始结冰 将军山
|
|
|
+ String duration_of_snow_j = super.getSysParameter("DURATION_OF_SNOW_J", "18");
|
|
|
+ // 停机间隔时间 马头山
|
|
|
+ String shut_down_number_time_interval_m = super.getSysParameter("SHUT_DOWN_NUMBER_TIME_INTERVAL_M", "18");
|
|
|
+ // 停机间隔时间 将军山
|
|
|
+ String shut_down_number_time_interval_j = super.getSysParameter("SHUT_DOWN_NUMBER_TIME_INTERVAL_J", "18");
|
|
|
+ // 强北风出现次数
|
|
|
+ Integer snowHowLong = 0;
|
|
|
+ // 强北风中断次数
|
|
|
+ Integer snowHowLongCut = 0;
|
|
|
+ // 返回集合
|
|
|
+ List<IcingShutdown> icingShutdowns = new ArrayList<>();
|
|
|
+ // 系统时间
|
|
|
+ Date systemDate = new Date();
|
|
|
+ // 明晚
|
|
|
+ long tomrrow = DateUtil.endOfDay(DateUtil.offsetDay(systemDate,1)).getTime() + 1;
|
|
|
+ // 获取两天nwp数据
|
|
|
+ List<Nwp> nwpData = nwpService.getNwpData(DateUtil.beginOfDay(systemDate).getTime(), tomrrow);
|
|
|
+ // 临时对象
|
|
|
+ IcingShutdown icingShutdown = new IcingShutdown();
|
|
|
+ IcingShutdown icingShutdownM = new IcingShutdown();
|
|
|
+
|
|
|
+ for(Nwp nwp: nwpData){
|
|
|
+ // 判断是否结冰
|
|
|
+ if(nwp.getT().compareTo(down_the_temperature) < 1 && nwp.getTpr().compareTo(tpr_threshold) > 0){
|
|
|
+ snowHowLong += 1;
|
|
|
+ }else{
|
|
|
+ snowHowLongCut += 1;
|
|
|
+ if(snowHowLongCut > 4){
|
|
|
+ snowHowLong = 0;
|
|
|
}
|
|
|
- } 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);
|
|
|
+ // 到达将军山停机时间
|
|
|
+ if(snowHowLong == Integer.parseInt(duration_of_snow_j) * 4){
|
|
|
+ icingShutdown.setStartTime(nwp.getPreTime());
|
|
|
+ icingShutdown.setEndTime(DateUtil.offsetHour(new Date(nwp.getPreTime()), Integer.parseInt(shut_down_number_time_interval_j)).getTime());
|
|
|
+ icingShutdown.setShutDownNumber(1);
|
|
|
+ icingShutdowns.add(icingShutdown);
|
|
|
}
|
|
|
-// shortTermForcast.setStationCode(stationCode);
|
|
|
- shortTermForcastList.add(shortTermForcast);
|
|
|
- if (i == index) {
|
|
|
- break;
|
|
|
+
|
|
|
+ if(snowHowLong > Integer.parseInt(duration_of_snow_j) * 4){
|
|
|
+ icingShutdown.setStartTime(icingShutdown.getEndTime());
|
|
|
+ icingShutdown.setEndTime(DateUtil.offsetHour(new Date(icingShutdown.getEndTime()), Integer.parseInt(shut_down_number_time_interval_j)).getTime());
|
|
|
+ icingShutdown.setShutDownNumber(icingShutdown.getShutDownNumber() + 1);
|
|
|
+ icingShutdowns.add(icingShutdown);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 到达马头山停机时间
|
|
|
+ if(snowHowLong == Integer.parseInt(duration_of_snow_m) * 4){
|
|
|
+ icingShutdownM.setStartTime(nwp.getPreTime());
|
|
|
+ icingShutdownM.setEndTime(DateUtil.offsetHour(new Date(nwp.getPreTime()), Integer.parseInt(shut_down_number_time_interval_m)).getTime());
|
|
|
+ icingShutdownM.setShutDownNumber(icingShutdown.getShutDownNumber() + 1);
|
|
|
+ icingShutdowns.add(icingShutdownM);
|
|
|
+ }
|
|
|
+ if(snowHowLong > Integer.parseInt(duration_of_snow_m) * 4){
|
|
|
+ icingShutdownM.setStartTime(nwp.getPreTime());
|
|
|
+ icingShutdownM.setEndTime(DateUtil.offsetHour(new Date(nwp.getPreTime()), Integer.parseInt(shut_down_number_time_interval_m)).getTime());
|
|
|
+ icingShutdownM.setShutDownNumber(icingShutdown.getShutDownNumber() + 1);
|
|
|
+ icingShutdowns.add(icingShutdownM);
|
|
|
}
|
|
|
- i++;
|
|
|
}
|
|
|
- return shortTermForcastList;
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ SysParameter shut_down_number = sysParameterService.getParameterBySysKey("SHUT_DOWN_NUMBER");
|
|
|
+ shut_down_number.setSysValue(String.valueOf(icingShutdowns.size()));
|
|
|
+ sysParameterService.update(shut_down_number);
|
|
|
+ } catch (BusinessException e) {
|
|
|
+ log.info("获取参数错误:" + e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return icingShutdowns;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * 本地短期对象转换为原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);
|
|
|
+ public List<IcingShutdown> thawBoot(){
|
|
|
+ // 解冻间隔时间 马头山
|
|
|
+ String thawing_interval_m = super.getSysParameter("THAWING_INTERVAL_M", "1");
|
|
|
+ // 解冻间隔时间 将军山
|
|
|
+ String thawing_interval_j = super.getSysParameter("THAWING_INTERVAL_J", "1");
|
|
|
+ // 开机温度
|
|
|
+ String thawing_interval_temperature = super.getSysParameter("THAWING_INTERVAL_TEMPERATURE", "1");
|
|
|
+ // 系统时间
|
|
|
+ Date systemDate = new Date();
|
|
|
+ long tomrrow = DateUtil.endOfDay(DateUtil.offsetDay(systemDate,1)).getTime() + 1;
|
|
|
+ // 获取两天nwp数据
|
|
|
+ List<Nwp> nwpData = nwpService.getNwpData(DateUtil.beginOfDay(systemDate).getTime(), tomrrow);
|
|
|
+ // 临时对象
|
|
|
+ IcingShutdown icingShutdown = new IcingShutdown();
|
|
|
+ IcingShutdown icingShutdownM = new IcingShutdown();
|
|
|
+ // 停机数量
|
|
|
+ String shut_down_number = super.getSysParameter("SHUT_DOWN_NUMBER", "0");
|
|
|
+ // 返回集合
|
|
|
+ List<IcingShutdown> icingShutdowns = new ArrayList<>();
|
|
|
+
|
|
|
+ Integer ifOfCount = 0;
|
|
|
+ Integer ifOfCountM = 0;
|
|
|
+//
|
|
|
+// if(Integer.parseInt(shut_down_number) > 0){
|
|
|
+// for(Nwp nwp:nwpData){
|
|
|
+// if(Integer.parseInt(shut_down_number) > 0){
|
|
|
+// if(nwp.getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0){
|
|
|
+// ifOfCount = ifOfCount + 1;
|
|
|
+// icingShutdown.setStartTime(nwp.getPreTime());
|
|
|
+// icingShutdown.setEndTime(DateUtil.offsetHour(new Date(nwp.getPreTime()),Integer.parseInt(thawing_interval_j)).getTime());
|
|
|
+// icingShutdown.setShutDownNumber(ifOfCount);
|
|
|
+// icingShutdowns.add(icingShutdown);
|
|
|
+// ifOfCountM = ifOfCountM + 1;
|
|
|
+// icingShutdownM.setStartTime(nwp.getPreTime());
|
|
|
+// icingShutdownM.setEndTime(DateUtil.offsetHour(new Date(nwp.getPreTime()),Integer.parseInt(thawing_interval_m)).getTime());
|
|
|
+// icingShutdown.setShutDownNumber(ifOfCountM);
|
|
|
+// icingShutdowns.add(icingShutdownM);
|
|
|
+//
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// for (long i = nwpData.get(0).getPreTime(); i <= nwpData.get(nwpData.size() - 1).getPreTime(); i+=1000 * 60 * 15) {
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+ if(Integer.parseInt(shut_down_number) > 0) {
|
|
|
+ for (int i = 0; i < nwpData.size(); i++) {
|
|
|
+ if (Integer.parseInt(shut_down_number) > 0) {
|
|
|
+ if(nwpData.get(i).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0){
|
|
|
+ if(nwpData.get(i+1).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0){
|
|
|
+ if(nwpData.get(i+2).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0){
|
|
|
+ if(nwpData.get(i+3).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0){
|
|
|
+ if(nwpData.get(i+4).getT().compareTo(new BigDecimal(thawing_interval_temperature)) > 0){
|
|
|
+ ifOfCount = ifOfCount + 1;
|
|
|
+ Long preTime = nwpData.get(i).getPreTime();
|
|
|
+ Long preTimeJ = DateUtil.offsetHour(new Date(preTime),Integer.parseInt(thawing_interval_j)).getTime();
|
|
|
+ Long preTimeM = DateUtil.offsetHour(new Date(preTime),Integer.parseInt(thawing_interval_m)).getTime();
|
|
|
+ icingShutdown.setStartTime(preTime);
|
|
|
+ icingShutdown.setEndTime(preTimeJ);
|
|
|
+ icingShutdown.setShutDownNumber(ifOfCount);
|
|
|
+ ifOfCountM = ifOfCountM + 1;
|
|
|
+ icingShutdowns.add(icingShutdown);
|
|
|
+ icingShutdownM.setStartTime(preTime);
|
|
|
+ icingShutdownM.setEndTime(preTimeM);
|
|
|
+ icingShutdownM.setShutDownNumber(ifOfCountM);
|
|
|
+ i += 4;
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- return listShort;
|
|
|
+ return icingShutdowns;
|
|
|
}
|
|
|
|
|
|
|
|
|
- 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上送日志响应格式不对");
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断风速是上升风还是下降风
|
|
|
+ *
|
|
|
+ * @return 返回 1 则视为上升风 返回 0 则视为下降风 返回 -1 则不满足计算条件
|
|
|
+ */
|
|
|
+ public Integer upOrDownWind(){
|
|
|
+ // 返回值
|
|
|
+ Integer returnValue = -1;
|
|
|
+ // 系统时间
|
|
|
+ Date sysDate = new Date();
|
|
|
+ // 半小时
|
|
|
+ long halfHour = 1000 * 60 * 30;
|
|
|
+ // 当前系统时间戳
|
|
|
+ long sysMillis = sysDate.getTime();
|
|
|
+ // 前半小时
|
|
|
+ long beforeHalfHour = sysMillis - halfHour;
|
|
|
+ // 后半小时
|
|
|
+ long afterHalfHour = sysMillis + halfHour;
|
|
|
+ // 前一个半小时
|
|
|
+ long anHourAndAHalf = 1000 * 60 * 90;
|
|
|
+ // 一小时数据
|
|
|
+ List<Nwp> nwpData = nwpService.getNwpData(beforeHalfHour, afterHalfHour);
|
|
|
+ // 当前时间段平均风速
|
|
|
+ BigDecimal avgSpeed = BigDecimal.ZERO;
|
|
|
+ // 前一小时平均风速
|
|
|
+ BigDecimal beforeAvgSpeed = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ // 风速小于10米再计算
|
|
|
+ for(Nwp nwp:nwpData){
|
|
|
+ if(nwp.getWs80().compareTo(new BigDecimal(10)) < 0){
|
|
|
+ avgSpeed.add(nwp.getWs80());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ avgSpeed = avgSpeed.divide(new BigDecimal(4));
|
|
|
+
|
|
|
+ // 前一个半小时的数据
|
|
|
+ List<Nwp> beforeNwpData = nwpService.getNwpData(anHourAndAHalf,beforeHalfHour);
|
|
|
+
|
|
|
+ // 风速小于10米再计算
|
|
|
+ beforeAvgSpeed = beforeNwpData.stream().map(Nwp::getWs80).reduce((s, m) -> s.add(m)).get().divide(new BigDecimal(4));
|
|
|
+
|
|
|
+ // 如果当前时间段平均风速大于0 则表示满足风速小于10米的条件
|
|
|
+ if (avgSpeed.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if(avgSpeed.subtract(beforeAvgSpeed).compareTo(new BigDecimal(1.5)) >0 ){
|
|
|
+ returnValue = 1;
|
|
|
+ }else {
|
|
|
+ returnValue = 0;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ return returnValue;
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|