|
@@ -3,9 +3,8 @@ package com.jiayue.ipfcst.fileupload.service;
|
|
|
import com.jiayue.ipfcst.common.core.exception.BusinessException;
|
|
|
import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
|
|
|
import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
|
|
|
-import com.jiayue.ipfcst.common.data.entity.ElectricField;
|
|
|
-import com.jiayue.ipfcst.common.data.entity.ForecastPowerShortTermHis;
|
|
|
-import com.jiayue.ipfcst.common.data.entity.ForecastPowerUltraShortTermHis;
|
|
|
+import com.jiayue.ipfcst.common.data.entity.*;
|
|
|
+import com.jiayue.ipfcst.common.data.repository.WeatherStationInfoRepository;
|
|
|
import com.jiayue.ipfcst.common.data.service.uploadfilerule.E63UploadFileRuleService;
|
|
|
import com.jiayue.ipfcst.console.service.ForecastPowerShortTermService;
|
|
|
import com.jiayue.ipfcst.console.service.ForecastPowerUltraShortTermService;
|
|
@@ -17,15 +16,15 @@ import org.apache.velocity.Template;
|
|
|
import org.apache.velocity.VelocityContext;
|
|
|
import org.apache.velocity.app.VelocityEngine;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.ResourceUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
import java.io.StringWriter;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 青海上报文件生成
|
|
@@ -47,17 +46,20 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
|
|
|
private final E63UploadFileRuleService e63UploadFileRuleService;
|
|
|
|
|
|
- public E63UploadFileService(VelocityEngine velocityEngine, ForecastPowerShortTermService forecastPowerShortTermService, ForecastPowerUltraShortTermService forecastPowerUltraShortTermService, E63UploadFileRuleService e63UploadFileRuleService) {
|
|
|
+ private final WeatherStationInfoRepository weatherStationInfoRepository;
|
|
|
+
|
|
|
+ public E63UploadFileService(VelocityEngine velocityEngine, ForecastPowerShortTermService forecastPowerShortTermService, ForecastPowerUltraShortTermService forecastPowerUltraShortTermService, E63UploadFileRuleService e63UploadFileRuleService, WeatherStationInfoRepository weatherStationInfoRepository) {
|
|
|
this.velocityEngine = velocityEngine;
|
|
|
this.forecastPowerShortTermService = forecastPowerShortTermService;
|
|
|
this.forecastPowerUltraShortTermService = forecastPowerUltraShortTermService;
|
|
|
this.e63UploadFileRuleService = e63UploadFileRuleService;
|
|
|
+ this.weatherStationInfoRepository = weatherStationInfoRepository;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成短期预测上报文件。
|
|
|
*/
|
|
|
- public void generateE1File(Date date) {
|
|
|
+ public void generateDqFile(Date date) {
|
|
|
List<ElectricField> electricFieldList = null;
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
@@ -129,7 +131,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
log.error(stationCode + "短期上报模板不存在!");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error(stationCode + "生成短期异常");
|
|
|
+ log.error(stationCode + "生成短期异常", e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -137,7 +139,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
/**
|
|
|
* 生成短期可用预测上报文件。
|
|
|
*/
|
|
|
- public void generateE26File(Date date) {
|
|
|
+ public void generateDqUseFile(Date date) {
|
|
|
List<ElectricField> electricFieldList = null;
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
@@ -168,41 +170,41 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
systemDate = date;
|
|
|
}
|
|
|
// 短期默认天数
|
|
|
- int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3",stationCode);
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E26", startTime);
|
|
|
- if (getFileName(fileName, "E26",stationCode)) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime,stationCode);
|
|
|
- if (forecastPowerShortTermHisList.size() > 0) {
|
|
|
- // 按照预测时间进行升序
|
|
|
- forecastPowerShortTermHisList.sort(Comparator.comparing(ForecastPowerShortTermHis::getForecastTime));
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
- //场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- //系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_" + "00:00:00"));
|
|
|
- //上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd_") + "00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- // 将文件复制到上报路径中
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E26.name(), null, date,stationCode);
|
|
|
+ int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3", stationCode);
|
|
|
+ // 开始时间
|
|
|
+ Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
+ // 结束时间(开始加24小时再减去1秒)
|
|
|
+ Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
+ // 生成上报文件名格式
|
|
|
+ fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E26", startTime);
|
|
|
+ if (getFileName(fileName, "E26", stationCode)) {
|
|
|
+ // 查询短期预测功率
|
|
|
+ List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime, stationCode);
|
|
|
+ if (forecastPowerShortTermHisList.size() > 0) {
|
|
|
+ // 按照预测时间进行升序
|
|
|
+ forecastPowerShortTermHisList.sort(Comparator.comparing(ForecastPowerShortTermHis::getForecastTime));
|
|
|
}
|
|
|
+ // 创建上报文件
|
|
|
+ file = super.createTempFile(fileName);
|
|
|
+ // 根据模板生成文件内容
|
|
|
+ velocityContext = new VelocityContext();
|
|
|
+ velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
+ //场站标识
|
|
|
+ velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
+ //系统当前日期
|
|
|
+ velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_" + "00:00:00"));
|
|
|
+ //上报数据开始日期
|
|
|
+ velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd_") + "00:00");
|
|
|
+ writer = new StringWriter();
|
|
|
+ template.merge(velocityContext, writer);
|
|
|
+ // 将文件复制到上报路径中
|
|
|
+ super.copyUploadFile(writer, file, FileTypeEnum.E26.name(), null, date, stationCode);
|
|
|
+ }
|
|
|
} else {
|
|
|
- log.error(stationCode+"可用短期上报模板不存在!");
|
|
|
+ log.error(stationCode + "可用短期上报模板不存在!");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error(stationCode + "生成可用短期异常");
|
|
|
+ log.error(stationCode + "生成可用短期异常", e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -210,7 +212,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
/**
|
|
|
* 生成超短期预测上报文件。
|
|
|
*/
|
|
|
- public void generateE2File(Date date) {
|
|
|
+ public void generateCdqFile(Date date) {
|
|
|
List<ElectricField> electricFieldList = null;
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
@@ -240,49 +242,49 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
systemDate = date;
|
|
|
}
|
|
|
// 短期默认天数
|
|
|
- int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16",stationCode);
|
|
|
+ int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16", stationCode);
|
|
|
// 获取提前几分钟生成超短期
|
|
|
- int cdqUpMin = super.getTranSysParameter("CDQ_UP_MIN", "0",stationCode);
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getMomentTime(systemDate.getTime() + 15 * 60 * 1000 + cdqUpMin * 1000 * 60, 1, 15 * 60 * 1000L);
|
|
|
- // 结束时间
|
|
|
- Long endTime = startTime + cdqPoint * 15 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E2", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E2",stationCode)) {
|
|
|
- // 查询超短期预测功率
|
|
|
- List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime,stationCode);
|
|
|
- // 按照预测时间进行升序
|
|
|
- forecastPowerUltraShortTermHisList.sort(Comparator.comparing(ForecastPowerUltraShortTermHis::getForecastTime));
|
|
|
+ int cdqUpMin = super.getTranSysParameter("CDQ_UP_MIN", "0", stationCode);
|
|
|
+ // 开始时间
|
|
|
+ Long startTime = DateMomentUtil.getMomentTime(systemDate.getTime() + 15 * 60 * 1000 + cdqUpMin * 1000 * 60, 1, 15 * 60 * 1000L);
|
|
|
+ // 结束时间
|
|
|
+ Long endTime = startTime + cdqPoint * 15 * 60 * 1000 - 1000;
|
|
|
+ // 生成上报文件名格式
|
|
|
+ fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E2", startTime);
|
|
|
+
|
|
|
+ if (getFileName(fileName, "E2", stationCode)) {
|
|
|
+ // 查询超短期预测功率
|
|
|
+ List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime, stationCode);
|
|
|
+ // 按照预测时间进行升序
|
|
|
+ forecastPowerUltraShortTermHisList.sort(Comparator.comparing(ForecastPowerUltraShortTermHis::getForecastTime));
|
|
|
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerUltraShortTermHisList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- if (electricFieldInfo.getElectricFieldTypeEnum().equals("E1")) {
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm" + ":00"));
|
|
|
- } else {
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd HH:mm" + ":00"));
|
|
|
- }
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
-
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E2.name(), null, date,stationCode);
|
|
|
+ // 创建上报文件
|
|
|
+ file = super.createTempFile(fileName);
|
|
|
+ // 根据模板生成文件内容
|
|
|
+ velocityContext = new VelocityContext();
|
|
|
+ velocityContext.put("vList", forecastPowerUltraShortTermHisList);
|
|
|
+ // 场站标识
|
|
|
+ velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
+ // 场站装机容量
|
|
|
+ velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
+ // 系统当前日期
|
|
|
+ if (electricFieldInfo.getElectricFieldTypeEnum().equals("E1")) {
|
|
|
+ velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm" + ":00"));
|
|
|
+ } else {
|
|
|
+ velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd HH:mm" + ":00"));
|
|
|
}
|
|
|
+ // 上报数据开始日期
|
|
|
+ velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd_HH:mm"));
|
|
|
+ writer = new StringWriter();
|
|
|
+ template.merge(velocityContext, writer);
|
|
|
+
|
|
|
+ super.copyUploadFile(writer, file, FileTypeEnum.E2.name(), null, date, stationCode);
|
|
|
+ }
|
|
|
} else {
|
|
|
- log.error(stationCode+"超短期上报模板不存在!");
|
|
|
+ log.error(stationCode + "超短期上报模板不存在!");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error(stationCode + "生成超短期异常");
|
|
|
+ log.error(stationCode + "生成超短期异常", e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -290,7 +292,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
/**
|
|
|
* 生成超短期可用预测上报文件。
|
|
|
*/
|
|
|
- public void generateE27File(Date date) {
|
|
|
+ public void generateCdqUseFile(Date date) {
|
|
|
List<ElectricField> electricFieldList = null;
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
@@ -320,9 +322,9 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
systemDate = date;
|
|
|
}
|
|
|
// 短期默认天数
|
|
|
- int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16",stationCode);
|
|
|
+ int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16", stationCode);
|
|
|
// 获取提前几分钟生成超短期
|
|
|
- int cdqUpMin = super.getTranSysParameter("CDQ_UP_MIN", "0",stationCode);
|
|
|
+ int cdqUpMin = super.getTranSysParameter("CDQ_UP_MIN", "0", stationCode);
|
|
|
|
|
|
// 开始时间
|
|
|
Long startTime = DateMomentUtil.getMomentTime(systemDate.getTime() + 15 * 60 * 1000 + cdqUpMin * 1000 * 60, 1, 15 * 60 * 1000L);
|
|
@@ -332,8 +334,8 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
// 生成上报文件名格式
|
|
|
fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E27", startTime);
|
|
|
|
|
|
- if (getFileName(fileName, "E27",stationCode)) {
|
|
|
- List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime,stationCode);
|
|
|
+ if (getFileName(fileName, "E27", stationCode)) {
|
|
|
+ List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermHisList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime, stationCode);
|
|
|
// 按照预测时间进行升序
|
|
|
if (forecastPowerUltraShortTermHisList.size() > 0) {
|
|
|
forecastPowerUltraShortTermHisList.sort(Comparator.comparing(ForecastPowerUltraShortTermHis::getForecastTime));
|
|
@@ -358,19 +360,283 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
velocityContext.put("uploadTime", DateFormatUtils.format(startTime - 15 * 60 * 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
writer = new StringWriter();
|
|
|
template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E27.name(), null, date,stationCode);
|
|
|
+ super.copyUploadFile(writer, file, FileTypeEnum.E27.name(), null, date, stationCode);
|
|
|
}
|
|
|
} else {
|
|
|
- log.error(stationCode+"可用超短期上报模板不存在!");
|
|
|
+ log.error(stationCode + "可用超短期上报模板不存在!");
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error(stationCode + "生成可用超短期异常");
|
|
|
+ log.error(stationCode + "生成可用超短期异常", e);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成气象站或者测风塔上报文件
|
|
|
+ */
|
|
|
+ public void generateQxzOrCftFile(ElectricField electricFieldInfo,Date date) {
|
|
|
+ String stationCode = electricFieldInfo.getStationCode();
|
|
|
+ try {
|
|
|
+ String fileName;
|
|
|
+ // 获取当前系统时间
|
|
|
+ Date systemDate = new Date();
|
|
|
+ if (date != null) {
|
|
|
+ systemDate = date;
|
|
|
+ }
|
|
|
+ Long startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
+ Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
+ // 生成上报文件名格式
|
|
|
+ Template template = null;
|
|
|
+ VelocityContext velocityContext = new VelocityContext();
|
|
|
+ if (electricFieldInfo.getElectricFieldTypeEnum().toString().equals("E1")) {
|
|
|
+ // 获取气象站模板
|
|
|
+ template = this.velocityEngine.getTemplate(this.vmsPath + "/QXZ.vm");
|
|
|
+ fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E6", endTime + 1000);
|
|
|
+ if (getFileName(fileName, "E6", stationCode)) {
|
|
|
+ generateQxzFile(fileName, velocityContext, template, electricFieldInfo, date, startTime, endTime);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ template = this.velocityEngine.getTemplate(this.vmsPath + "/CFT.vm");
|
|
|
+ fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E7", endTime + 1000);
|
|
|
+ if (getFileName(fileName, "E7", stationCode)) {
|
|
|
+ generateCftFile(fileName, velocityContext, template, electricFieldInfo, date, startTime, endTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(stationCode + "生成文件异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成测风塔上报文件
|
|
|
+ */
|
|
|
+ public void generateQxzFile(String fileName, VelocityContext velocityContext, Template template, ElectricField electricFieldInfo, Date date, Long startTime, Long endTime) throws Exception{
|
|
|
+ ///////////////////此处从缓存取///////////////////////////////////////
|
|
|
+ WeatherStationStatusData weatherStationStatusData = null;
|
|
|
+ // 数据格式化
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
+ BigDecimal globalR = new BigDecimal(0);
|
|
|
+ BigDecimal directR = new BigDecimal(0);
|
|
|
+ BigDecimal diffuseR = new BigDecimal(0);
|
|
|
+ BigDecimal ws = new BigDecimal(0);
|
|
|
+ BigDecimal wd = new BigDecimal(0);
|
|
|
+ BigDecimal airT = new BigDecimal(0);
|
|
|
+ BigDecimal p = new BigDecimal(0);
|
|
|
+ BigDecimal rh = new BigDecimal(0);
|
|
|
+ BigDecimal cellT = new BigDecimal(0);
|
|
|
+
|
|
|
+ if (weatherStationStatusData == null) {
|
|
|
+ // 总辐射产生500-1000随机数
|
|
|
+ globalR = new BigDecimal(df.format(Math.random() * 500 + 500));
|
|
|
+ // 直辐射产生400-500随机数
|
|
|
+ directR = new BigDecimal(df.format(Math.random() * 100 + 400));
|
|
|
+ // 散辐射 = 总 - 直
|
|
|
+ diffuseR = globalR.subtract(directR);
|
|
|
+ airT = new BigDecimal(df.format(Math.random() * 4 + 8));
|
|
|
+ p = new BigDecimal(df.format(Math.random() * 200 + 800));
|
|
|
+ rh = new BigDecimal(df.format(Math.random() * 10 + 30));
|
|
|
+ cellT = new BigDecimal(df.format(Math.random() * 26 + 4));
|
|
|
+ ws = new BigDecimal(df.format(Math.random() * 9 + 1));
|
|
|
+ wd = new BigDecimal(df.format(Math.random() * 100 + 200));
|
|
|
+ } else {
|
|
|
+ globalR = weatherStationStatusData.getGlobalR();
|
|
|
+ directR = weatherStationStatusData.getDirectR();
|
|
|
+ diffuseR = weatherStationStatusData.getDiffuseR();
|
|
|
+ airT = weatherStationStatusData.getAirT();
|
|
|
+ p = weatherStationStatusData.getP();
|
|
|
+ rh = weatherStationStatusData.getRh();
|
|
|
+ cellT = weatherStationStatusData.getCellT();
|
|
|
+ ws = weatherStationStatusData.getWs();
|
|
|
+ wd = weatherStationStatusData.getWd();
|
|
|
+ }
|
|
|
+ // 创建上报文件
|
|
|
+ File file = super.createTempFile(fileName);
|
|
|
+ //青海要求 直=总-散;但是当散辐射大于总辐射时直辐射为负数不符合该规则。所以比较总直散三个值,用最大的当总辐射去减去
|
|
|
+ log.info("qxz 实际值 总GlobalR:" + globalR + " 直DirectR:" + directR + " 散DiffuseR:" + diffuseR);
|
|
|
+ if (globalR.compareTo(diffuseR) == -1) {
|
|
|
+ //当散辐射大于总辐射时,数值互换
|
|
|
+ BigDecimal a = globalR;
|
|
|
+ globalR = diffuseR;
|
|
|
+ diffuseR = a;
|
|
|
+ }
|
|
|
+ directR = globalR.subtract(diffuseR);
|
|
|
+ // 根据模板生成文件内容
|
|
|
+ velocityContext.put("GlobalR", globalR.compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(globalR));
|
|
|
+ velocityContext.put("AirT", airT.compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(airT));
|
|
|
+ velocityContext.put("P", p.compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(p));
|
|
|
+ velocityContext.put("RH", rh.compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(rh));
|
|
|
+ velocityContext.put("CellT", cellT.compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(cellT));
|
|
|
+ velocityContext.put("DirectR", directR.compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(directR));
|
|
|
+ velocityContext.put("DiffuseR", diffuseR.compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(diffuseR));
|
|
|
+ velocityContext.put("WS", ws.compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(ws));
|
|
|
+ velocityContext.put("WD", wd.compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(wd));
|
|
|
+ // 场站标识
|
|
|
+ velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
+ // 场站装机容量
|
|
|
+ velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
+ // 系统当前日期
|
|
|
+ velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm") + ":00");
|
|
|
+ // 上报数据开始日期
|
|
|
+ velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.merge(velocityContext, writer);
|
|
|
+ super.copyUploadFile(writer, file, FileTypeEnum.E6.name(), null, date, electricFieldInfo.getStationCode());
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成测风塔上报文件
|
|
|
+ */
|
|
|
+ public void generateCftFile(String fileName, VelocityContext velocityContext, Template template, ElectricField electricFieldInfo, Date date, Long startTime, Long endTime) throws Exception{
|
|
|
+ WindTowerStatusData windTowerStatusData = null;
|
|
|
+ // 数据格式化
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
+ BigDecimal ws10 = new BigDecimal(0);
|
|
|
+ BigDecimal wd10 = new BigDecimal(0);
|
|
|
+ BigDecimal ws30 = new BigDecimal(0);
|
|
|
+ BigDecimal wd30 = new BigDecimal(0);
|
|
|
+ BigDecimal ws50 = new BigDecimal(0);
|
|
|
+ BigDecimal wd50 = new BigDecimal(0);
|
|
|
+ BigDecimal ws60 = new BigDecimal(0);
|
|
|
+ BigDecimal wd60 = new BigDecimal(0);
|
|
|
+ BigDecimal ws70 = new BigDecimal(0);
|
|
|
+ BigDecimal wd70 = new BigDecimal(0);
|
|
|
+ BigDecimal ws80 = new BigDecimal(0);
|
|
|
+ BigDecimal wd80 = new BigDecimal(0);
|
|
|
+ BigDecimal ws90 = new BigDecimal(0);
|
|
|
+ BigDecimal wd90 = new BigDecimal(0);
|
|
|
+ BigDecimal ws100 = new BigDecimal(0);
|
|
|
+ BigDecimal wd100 = new BigDecimal(0);
|
|
|
+ BigDecimal wsHubHeight = new BigDecimal(0);
|
|
|
+ BigDecimal wdHubHeight = new BigDecimal(0);
|
|
|
+ BigDecimal t8 = new BigDecimal(0);
|
|
|
+ BigDecimal p8 = new BigDecimal(0);
|
|
|
+ BigDecimal rh8 = new BigDecimal(0);
|
|
|
+
|
|
|
+ if (windTowerStatusData == null) {
|
|
|
+ // 10米风速产生1-5随机数
|
|
|
+ BigDecimal ws10RandomValue = new BigDecimal(df.format(Math.random() * 4 + 1));
|
|
|
+ ws10 = ws10.add(ws10RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 10米风向产生40-60随机数
|
|
|
+ BigDecimal wd10RandomValue = new BigDecimal(df.format(Math.random() * 20 + 40));
|
|
|
+ wd10 = wd10.add(wd10RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 30米风速产生6-10随机数
|
|
|
+ BigDecimal ws30RandomValue = new BigDecimal(df.format(Math.random() * 4 + 6));
|
|
|
+ ws30 = ws30.add(ws30RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 30米风向产生70-90随机数
|
|
|
+ BigDecimal wd30RandomValue = new BigDecimal(df.format(Math.random() * 20 + 70));
|
|
|
+ wd30 = wd30.add(wd30RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 50米风速产生16-20随机数
|
|
|
+ BigDecimal ws50RandomValue = new BigDecimal(df.format(Math.random() * 4 + 16));
|
|
|
+ ws50 = ws50.add(ws50RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 50米风向产生130-150随机数
|
|
|
+ BigDecimal wd50RandomValue = new BigDecimal(df.format(Math.random() * 20 + 130));
|
|
|
+ wd50 = wd50.add(wd50RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 70米风速产生31-35随机数
|
|
|
+ BigDecimal ws70RandomValue = new BigDecimal(df.format(Math.random() * 4 + 31));
|
|
|
+ ws70 = ws70.add(ws70RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 70米风向产生220-240随机数
|
|
|
+ BigDecimal wd70RandomValue = new BigDecimal(df.format(Math.random() * 20 + 220));
|
|
|
+ wd70 = wd70.add(wd70RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ // 80米风速产生35-40随机数
|
|
|
+ BigDecimal ws80RandomValue = new BigDecimal(df.format(Math.random() * 5 + 35));
|
|
|
+ ws80 = ws80.add(ws80RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 80米风向产生240-250随机数
|
|
|
+ BigDecimal wd80RandomValue = new BigDecimal(df.format(Math.random() * 10 + 240));
|
|
|
+ wd80 = wd80.add(wd80RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ // 90米风速产生45-50随机数
|
|
|
+ BigDecimal ws90RandomValue = new BigDecimal(df.format(Math.random() * 5 + 45));
|
|
|
+ ws90 = ws90.add(ws90RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 90米风向产生260-270随机数
|
|
|
+ BigDecimal wd90RandomValue = new BigDecimal(df.format(Math.random() * 10 + 260));
|
|
|
+ wd90 = wd90.add(wd90RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ // 100米风速产生60-70随机数
|
|
|
+ BigDecimal ws100RandomValue = new BigDecimal(df.format(Math.random() * 10 + 60));
|
|
|
+ ws100 = ws100.add(ws100RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 100米风向产生280-290随机数
|
|
|
+ BigDecimal wd100RandomValue = new BigDecimal(df.format(Math.random() * 10 + 280));
|
|
|
+ wd100 = wd100.add(wd100RandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ BigDecimal wsRandomValue = new BigDecimal(df.format(Math.random() * 4 + 70));
|
|
|
+ wsHubHeight = wsHubHeight.add(wsRandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal wdRandomValue = new BigDecimal(df.format(Math.random() * 20 + 250));
|
|
|
+ wdHubHeight = wdHubHeight.add(wdRandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 湿度产生50-60随机数
|
|
|
+ BigDecimal rhRandomValue = new BigDecimal(df.format(Math.random() * 10 + 50));
|
|
|
+ rh8 = rh8.add(rhRandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 温度产生20-35随机数
|
|
|
+ BigDecimal tRandomValue = new BigDecimal(df.format(Math.random() * 15 + 20));
|
|
|
+ t8 = t8.add(rhRandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ // 气压产生75-90随机数
|
|
|
+ BigDecimal paRandomValue = new BigDecimal(df.format(Math.random() * 15 + 75));
|
|
|
+ p8 = p8.add(paRandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ ws10 = windTowerStatusData.getWsInst10().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWsInst10();
|
|
|
+ wd10 = windTowerStatusData.getWdInst10().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWdInst10();
|
|
|
+ ws30 = windTowerStatusData.getWsInst30().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWsInst30();
|
|
|
+ wd30 = windTowerStatusData.getWdInst30().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWdInst30();
|
|
|
+ ws50 = windTowerStatusData.getWsInst50().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWsInst50();
|
|
|
+ wd50 = windTowerStatusData.getWdInst50().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWdInst50();
|
|
|
+ ws70 = windTowerStatusData.getWsInst70().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWsInst70();
|
|
|
+ wd70 = windTowerStatusData.getWdInst70().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWdInst70();
|
|
|
+ ws80 = windTowerStatusData.getWsInst80().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWsInst80();
|
|
|
+ wd80 = windTowerStatusData.getWdInst80().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWdInst80();
|
|
|
+ ws90 = windTowerStatusData.getWsInst90().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWsInst90();
|
|
|
+ wd90 = windTowerStatusData.getWdInst90().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWdInst90();
|
|
|
+ ws100 = windTowerStatusData.getWsInst100().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWsInst100();
|
|
|
+ wd100 = windTowerStatusData.getWdInst100().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWdInst100();
|
|
|
+ wsHubHeight = windTowerStatusData.getWsInstHubHeight().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWsInstHubHeight();
|
|
|
+ wdHubHeight = windTowerStatusData.getWdInstHubHeight().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getWdInstHubHeight();
|
|
|
+ p8 = windTowerStatusData.getPaInst().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getPaInst();
|
|
|
+ rh8 = windTowerStatusData.getRhInst().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getRhInst();
|
|
|
+ t8 = windTowerStatusData.getTInst().compareTo(new BigDecimal(-99)) == 0 ? new BigDecimal(0) : windTowerStatusData.getTInst();
|
|
|
+ }
|
|
|
+ // 创建上报文件
|
|
|
+ File file = super.createTempFile(fileName);
|
|
|
+ // 根据模板生成文件内容
|
|
|
+ velocityContext.put("WS_10", df.format(ws10));
|
|
|
+ velocityContext.put("WD_10", df.format(wd10));
|
|
|
+
|
|
|
+ velocityContext.put("WS_30", df.format(ws30));
|
|
|
+ velocityContext.put("WD_30", df.format(wd30));
|
|
|
+
|
|
|
+ velocityContext.put("WS_50", df.format(ws50));
|
|
|
+ velocityContext.put("WD_50", df.format(wd50));
|
|
|
+
|
|
|
+ velocityContext.put("WS_60", df.format(ws60));
|
|
|
+ velocityContext.put("WD_60", df.format(wd60));
|
|
|
+
|
|
|
+ velocityContext.put("WS_70", df.format(ws70));
|
|
|
+ velocityContext.put("WD_70", df.format(wd70));
|
|
|
+
|
|
|
+ velocityContext.put("WS_80", df.format(ws80));
|
|
|
+ velocityContext.put("WD_80", df.format(wd80));
|
|
|
+
|
|
|
+ velocityContext.put("WS_90", df.format(ws90));
|
|
|
+ velocityContext.put("WD_90", df.format(wd90));
|
|
|
+
|
|
|
+ velocityContext.put("WS_100", df.format(ws100));
|
|
|
+ velocityContext.put("WD_100", df.format(wd100));
|
|
|
+
|
|
|
+ velocityContext.put("WS_HubHeight", df.format(wsHubHeight));
|
|
|
+ velocityContext.put("WD_HubHeight", df.format(wdHubHeight));
|
|
|
+
|
|
|
+ velocityContext.put("T_8", df.format(t8));
|
|
|
+ velocityContext.put("P_8", df.format(p8));
|
|
|
+ velocityContext.put("RH_8", df.format(rh8));
|
|
|
+ // 场站标识
|
|
|
+ velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
+ // 系统当前日期
|
|
|
+ velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm") + ":00");
|
|
|
+ // 上报数据开始日期
|
|
|
+ velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
+ StringWriter writer = new StringWriter();
|
|
|
+ template.merge(velocityContext, writer);
|
|
|
+ super.copyUploadFile(writer, file, FileTypeEnum.E7.name(), null, date, electricFieldInfo.getStationCode());
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 除法
|