|
@@ -3,6 +3,7 @@ package com.jiayue.ipfcst.fileupload.service;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.jiayue.ipfcst.common.core.exception.BusinessException;
|
|
|
import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
|
|
|
+import com.jiayue.ipfcst.common.data.abst.equipmentinfo.AbstractEquipmentInfo;
|
|
|
import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
|
|
|
import com.jiayue.ipfcst.common.data.entity.*;
|
|
|
import com.jiayue.ipfcst.common.data.repository.*;
|
|
@@ -23,6 +24,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.io.File;
|
|
|
import java.io.StringWriter;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -37,7 +39,7 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
public class E63UploadFileService extends BaseUploadFileService {
|
|
|
|
|
|
- private String vmsPath = FileUtil.getResourceBasePath() + "/vms/E63";
|
|
|
+ private final String vmsPath = FileUtil.getResourceBasePath() + "/vms/E63";
|
|
|
|
|
|
private final VelocityEngine velocityEngine;
|
|
|
|
|
@@ -91,7 +93,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
* 生成短期预测上报文件。
|
|
|
*/
|
|
|
public void generateDqFile(Date date) {
|
|
|
- List<ElectricField> electricFieldList = null;
|
|
|
+ List<ElectricField> electricFieldList = new ArrayList<>();
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
|
} catch (BusinessException e) {
|
|
@@ -102,7 +104,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
for (ElectricField electricFieldInfo : electricFieldList) {
|
|
|
String stationCode = electricFieldInfo.getStationCode();
|
|
|
try {
|
|
|
- Template template = null;
|
|
|
+ Template template;
|
|
|
// 获取短期模板
|
|
|
if (electricFieldInfo.getElectricFieldTypeEnum().equals("E1")) {
|
|
|
template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ.vm");
|
|
@@ -111,10 +113,10 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
}
|
|
|
|
|
|
if (template != null) {
|
|
|
- VelocityContext velocityContext = null;
|
|
|
- StringWriter writer = null;
|
|
|
- String fileName = null;
|
|
|
- File file = null;
|
|
|
+ VelocityContext velocityContext;
|
|
|
+ StringWriter writer;
|
|
|
+ String fileName;
|
|
|
+ File file;
|
|
|
|
|
|
// 获取当前系统时间
|
|
|
Date systemDate = new Date();
|
|
@@ -171,7 +173,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
* 生成短期可用预测上报文件。
|
|
|
*/
|
|
|
public void generateDqUseFile(Date date) {
|
|
|
- List<ElectricField> electricFieldList = null;
|
|
|
+ List<ElectricField> electricFieldList = new ArrayList<>();
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
|
} catch (BusinessException e) {
|
|
@@ -182,7 +184,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
for (ElectricField electricFieldInfo : electricFieldList) {
|
|
|
String stationCode = electricFieldInfo.getStationCode();
|
|
|
try {
|
|
|
- Template template = null;
|
|
|
+ Template template;
|
|
|
// 获取短期模板
|
|
|
if (electricFieldInfo.getElectricFieldTypeEnum().equals("E1")) {
|
|
|
template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_USE.vm");
|
|
@@ -244,7 +246,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
* 生成超短期预测上报文件。
|
|
|
*/
|
|
|
public void generateCdqFile(Date date) {
|
|
|
- List<ElectricField> electricFieldList = null;
|
|
|
+ List<ElectricField> electricFieldList = new ArrayList<>();
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
|
} catch (BusinessException e) {
|
|
@@ -255,7 +257,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
for (ElectricField electricFieldInfo : electricFieldList) {
|
|
|
String stationCode = electricFieldInfo.getStationCode();
|
|
|
try {
|
|
|
- Template template = null;
|
|
|
+ Template template;
|
|
|
// 获取短期模板
|
|
|
if (electricFieldInfo.getElectricFieldTypeEnum().equals("E1")) {
|
|
|
template = this.velocityEngine.getTemplate(this.vmsPath + "/CDQ.vm");
|
|
@@ -277,9 +279,9 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
// 获取提前几分钟生成超短期
|
|
|
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 startTime = DateMomentUtil.getMomentTime(systemDate.getTime() + 15 * 60 * 1000 + (long) cdqUpMin * 1000 * 60, 1, 15 * 60 * 1000L);
|
|
|
// 结束时间
|
|
|
- Long endTime = startTime + cdqPoint * 15 * 60 * 1000 - 1000;
|
|
|
+ long endTime = startTime + (long) cdqPoint * 15 * 60 * 1000 - 1000;
|
|
|
// 生成上报文件名格式
|
|
|
fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E2", startTime);
|
|
|
|
|
@@ -324,7 +326,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
* 生成超短期可用预测上报文件。
|
|
|
*/
|
|
|
public void generateCdqUseFile(Date date) {
|
|
|
- List<ElectricField> electricFieldList = null;
|
|
|
+ List<ElectricField> electricFieldList = new ArrayList<>();
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
|
} catch (BusinessException e) {
|
|
@@ -335,7 +337,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
for (ElectricField electricFieldInfo : electricFieldList) {
|
|
|
String stationCode = electricFieldInfo.getStationCode();
|
|
|
try {
|
|
|
- Template template = null;
|
|
|
+ Template template;
|
|
|
// 获取短期模板
|
|
|
if (electricFieldInfo.getElectricFieldTypeEnum().equals("E1")) {
|
|
|
template = this.velocityEngine.getTemplate(this.vmsPath + "/CDQ_USE.vm");
|
|
@@ -358,9 +360,9 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
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 startTime = DateMomentUtil.getMomentTime(systemDate.getTime() + 15 * 60 * 1000 + (long) cdqUpMin * 1000 * 60, 1, 15 * 60 * 1000L);
|
|
|
// 结束时间
|
|
|
- Long endTime = startTime + cdqPoint * 15 * 60 * 1000 - 1000;
|
|
|
+ long endTime = startTime + (long) cdqPoint * 15 * 60 * 1000 - 1000;
|
|
|
|
|
|
// 生成上报文件名格式
|
|
|
fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E27", startTime);
|
|
@@ -406,7 +408,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
* 生成气象站或者测风塔上报文件
|
|
|
*/
|
|
|
public void generateQxzOrCftFile(Date date) {
|
|
|
- List<ElectricField> electricFieldList = null;
|
|
|
+ List<ElectricField> electricFieldList = new ArrayList<>();
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
|
} catch (BusinessException e) {
|
|
@@ -426,8 +428,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
Long endTime = DateMomentUtil.getMomentTime(systemDate.getTime(), 1, 5 * 60 * 1000L);
|
|
|
Long startTime = endTime - 4 * 60 * 1000;
|
|
|
// 生成上报文件名格式
|
|
|
- Template template = null;
|
|
|
- VelocityContext velocityContext = new VelocityContext();
|
|
|
+ Template template;
|
|
|
if (electricFieldInfo.getElectricFieldTypeEnum().toString().equals("E1")) {
|
|
|
// 获取气象站模板
|
|
|
template = this.velocityEngine.getTemplate(this.vmsPath + "/QXZ.vm");
|
|
@@ -451,11 +452,11 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
/**
|
|
|
* 生成气象站上报文件
|
|
|
*/
|
|
|
- private void generateQxzFile(String fileName, Template template, ElectricField electricFieldInfo, Date date, Long startTime, Long endTime) throws Exception {
|
|
|
+ private void generateQxzFile(String fileName, Template template, ElectricField electricFieldInfo, Date date, Long startTime, Long endTime) {
|
|
|
// 获取气象站信息
|
|
|
List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoRepository.findAll();
|
|
|
// 将气象站信息过滤出上报
|
|
|
- List<WeatherStationInfo> weatherStationInfos = weatherStationInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
+ List<WeatherStationInfo> weatherStationInfos = weatherStationInfoList.stream().filter(AbstractEquipmentInfo::getReport).collect(Collectors.toList());
|
|
|
if (!weatherStationInfos.isEmpty()) {
|
|
|
String qxzId = String.valueOf(weatherStationInfos.get(0).getId());
|
|
|
Map<String, String> qxzMap = redisUtils.hgetall("qxz-" + electricFieldInfo.getStationCode() + "-" + qxzId);
|
|
@@ -487,14 +488,14 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
ws = qxzMap.get("ws") == null ? qxzRandomCreate("ws") : new BigDecimal(qxzMap.get("ws"));
|
|
|
wd = qxzMap.get("wd") == null ? qxzRandomCreate("wd") : new BigDecimal(qxzMap.get("wd"));
|
|
|
isUseRedis = true;
|
|
|
- log.info(electricFieldInfo.getStationCode() + "生成气象站数据从redis获取:" + qxzMap.toString());
|
|
|
+ log.info(electricFieldInfo.getStationCode() + "生成气象站数据从redis获取:" + qxzMap);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!isUseRedis) {
|
|
|
- List<WeatherStationStatusData> weatherStationStatusDataList = weatherStationStatusDataRepository.findByStationCodeAndTimeBetweenAndEquipmentId(electricFieldInfo.getStationCode(),new Date(startTime), new Date(endTime), qxzId);
|
|
|
- if (weatherStationStatusDataList.isEmpty()){
|
|
|
+ List<WeatherStationStatusData> weatherStationStatusDataList = weatherStationStatusDataRepository.findByStationCodeAndTimeBetweenAndEquipmentId(electricFieldInfo.getStationCode(), new Date(startTime), new Date(endTime), qxzId);
|
|
|
+ if (weatherStationStatusDataList.isEmpty()) {
|
|
|
// 总辐射产生500-1000随机数
|
|
|
globalR = qxzRandomCreate("globalR");
|
|
|
// 直辐射产生400-500随机数
|
|
@@ -508,8 +509,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
ws = qxzRandomCreate("ws");
|
|
|
wd = qxzRandomCreate("wd");
|
|
|
log.info(electricFieldInfo.getStationCode() + "生成气象站数据用随机数");
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
weatherStationStatusDataList.stream().sorted(Comparator.comparing(WeatherStationStatusData::getTime).reversed()).collect(Collectors.toList());
|
|
|
WeatherStationStatusData weatherStationStatusData = weatherStationStatusDataList.get(0);
|
|
|
globalR = weatherStationStatusData.getGlobalR();
|
|
@@ -563,11 +563,11 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
/**
|
|
|
* 生成测风塔上报文件
|
|
|
*/
|
|
|
- private void generateCftFile(String fileName, Template template, ElectricField electricFieldInfo, Date date, Long startTime, Long endTime) throws Exception {
|
|
|
+ private void generateCftFile(String fileName, Template template, ElectricField electricFieldInfo, Date date, Long startTime, Long endTime) {
|
|
|
// 获取测风塔信息
|
|
|
List<WindTowerInfo> windTowerInfoList = windTowerInfoRepository.findAll();
|
|
|
// 将测风塔信息过滤出上报的塔
|
|
|
- List<WindTowerInfo> filterWindTowerInfoList = windTowerInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
+ List<WindTowerInfo> filterWindTowerInfoList = windTowerInfoList.stream().filter(AbstractEquipmentInfo::getReport).collect(Collectors.toList());
|
|
|
if (!filterWindTowerInfoList.isEmpty()) {
|
|
|
String cftId = String.valueOf(filterWindTowerInfoList.get(0).getId());
|
|
|
Map<String, String> cftMap = redisUtils.hgetall("cft-" + electricFieldInfo.getStationCode() + "-" + cftId);
|
|
@@ -623,15 +623,15 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
p8 = cftMap.get("paInst") == null ? cftRandomCreate("paInst") : new BigDecimal(cftMap.get("paInst"));
|
|
|
rh8 = cftMap.get("rhInst") == null ? cftRandomCreate("rhInst") : new BigDecimal(cftMap.get("rhInst"));
|
|
|
isUseRedis = true;
|
|
|
- log.info(electricFieldInfo.getStationCode() + "生成测风塔数据从redis获取:" + cftMap.toString());
|
|
|
+ log.info(electricFieldInfo.getStationCode() + "生成测风塔数据从redis获取:" + cftMap);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (!isUseRedis) {
|
|
|
- List<WindTowerStatusData> windTowerStatusDataList = windTowerStatusDataRepository.findByStationCodeAndEquipmentIdAndTimeBetween(electricFieldInfo.getStationCode(),cftId, new Date(startTime), new Date(endTime));
|
|
|
- if (windTowerStatusDataList.isEmpty()){
|
|
|
+ List<WindTowerStatusData> windTowerStatusDataList = windTowerStatusDataRepository.findByStationCodeAndEquipmentIdAndTimeBetween(electricFieldInfo.getStationCode(), cftId, new Date(startTime), new Date(endTime));
|
|
|
+ if (windTowerStatusDataList.isEmpty()) {
|
|
|
// 没有测风塔数据用nwp数据补
|
|
|
- Long nwpTime;
|
|
|
+ long nwpTime;
|
|
|
try {
|
|
|
nwpTime = DateMomentUtil.getMomentTime(endTime, 1, 15 * 60 * 1000L);
|
|
|
} catch (Exception e) {
|
|
@@ -643,45 +643,45 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
if (nwpList.size() > 0) {
|
|
|
Nwp nwpData = nwpList.get(0);
|
|
|
ws10 = nwpData.getWs10();
|
|
|
- ws10 = ws10.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ ws10 = ws10.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
wd10 = nwpData.getWd10();
|
|
|
- wd10 = wd10.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wd10 = wd10.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
ws30 = nwpData.getWs30();
|
|
|
- ws30 = ws30.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ ws30 = ws30.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
wd30 = nwpData.getWd30();
|
|
|
- wd30 = wd30.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wd30 = wd30.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
ws50 = nwpData.getWs50();
|
|
|
- ws50 = ws50.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ ws50 = ws50.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
wd50 = nwpData.getWd50();
|
|
|
- wd50 = wd50.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- ws60 = ws50.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- wd60 = wd50.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wd50 = wd50.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ ws60 = ws50.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ wd60 = wd50.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
ws70 = nwpData.getWs70();
|
|
|
- ws70 = ws70.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ ws70 = ws70.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
wd70 = nwpData.getWd70();
|
|
|
- wd70 = wd70.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wd70 = wd70.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
ws80 = nwpData.getWs80();
|
|
|
- ws80 = ws80.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ ws80 = ws80.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
wd80 = nwpData.getWd80();
|
|
|
- wd80 = wd80.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wd80 = wd80.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
ws90 = nwpData.getWs90();
|
|
|
- ws90 = ws90.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ ws90 = ws90.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
wd90 = nwpData.getWd90();
|
|
|
- wd90 = wd90.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wd90 = wd90.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
ws100 = nwpData.getWs100();
|
|
|
- ws100 = ws100.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ ws100 = ws100.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
wd100 = nwpData.getWd100();
|
|
|
- wd100 = wd100.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wd100 = wd100.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
wsHubHeight = nwpData.getWs170();
|
|
|
- wsHubHeight = wsHubHeight.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wsHubHeight = wsHubHeight.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
wdHubHeight = nwpData.getWd170();
|
|
|
- wdHubHeight = wdHubHeight.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ wdHubHeight = wdHubHeight.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
rh8 = nwpData.getRh();
|
|
|
- rh8 = rh8.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ rh8 = rh8.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
t8 = nwpData.getT();
|
|
|
- t8 = t8.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ t8 = t8.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
p8 = nwpData.getPressure();
|
|
|
- p8 = p8.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ p8 = p8.add(new BigDecimal(df.format(Math.random() * 1 + 0.01))).setScale(2, RoundingMode.HALF_UP);
|
|
|
log.info(electricFieldInfo.getStationCode() + "生成测风塔数据用nwp+随机数");
|
|
|
} else {
|
|
|
// 10米风速产生1-5随机数
|
|
@@ -726,70 +726,69 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
p8 = cftRandomCreate("paInst");
|
|
|
log.info(electricFieldInfo.getStationCode() + "生成测风塔数据用随机数");
|
|
|
}
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
windTowerStatusDataList.stream().sorted(Comparator.comparing(WindTowerStatusData::getTime).reversed()).collect(Collectors.toList());
|
|
|
WindTowerStatusData windTowerStatusData = windTowerStatusDataList.get(0);
|
|
|
// 10米风速
|
|
|
- if (windTowerStatusData.getWsInst10()!=null)
|
|
|
+ if (windTowerStatusData.getWsInst10() != null)
|
|
|
ws10 = windTowerStatusData.getWsInst10();
|
|
|
// 10米风向
|
|
|
- if (windTowerStatusData.getWdInst10()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst10() != null)
|
|
|
wd10 = windTowerStatusData.getWdInst10();
|
|
|
// 30米风速
|
|
|
- if (windTowerStatusData.getWdInst30()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst30() != null)
|
|
|
ws30 = windTowerStatusData.getWsInst30();
|
|
|
// 30米风向
|
|
|
- if (windTowerStatusData.getWdInst30()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst30() != null)
|
|
|
wd30 = windTowerStatusData.getWdInst30();
|
|
|
// 50米风速
|
|
|
- if (windTowerStatusData.getWdInst50()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst50() != null)
|
|
|
ws50 = windTowerStatusData.getWsInst50();
|
|
|
// 50米风向
|
|
|
- if (windTowerStatusData.getWdInst50()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst50() != null)
|
|
|
wd50 = windTowerStatusData.getWdInst50();
|
|
|
// 60米风速
|
|
|
- if (windTowerStatusData.getWdInst60()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst60() != null)
|
|
|
ws60 = windTowerStatusData.getWsInst60();
|
|
|
// 60米风向
|
|
|
- if (windTowerStatusData.getWdInst60()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst60() != null)
|
|
|
wd60 = windTowerStatusData.getWdInst60();
|
|
|
// 70米风速
|
|
|
- if (windTowerStatusData.getWdInst70()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst70() != null)
|
|
|
ws70 = windTowerStatusData.getWsInst70();
|
|
|
// 70米风向
|
|
|
- if (windTowerStatusData.getWdInst70()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst70() != null)
|
|
|
wd70 = windTowerStatusData.getWdInst70();
|
|
|
// 80米风速
|
|
|
- if (windTowerStatusData.getWdInst80()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst80() != null)
|
|
|
ws80 = windTowerStatusData.getWsInst80();
|
|
|
// 80米风向
|
|
|
- if (windTowerStatusData.getWdInst80()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst80() != null)
|
|
|
wd80 = windTowerStatusData.getWdInst80();
|
|
|
// 90米风速
|
|
|
- if (windTowerStatusData.getWdInst90()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst90() != null)
|
|
|
ws90 = windTowerStatusData.getWsInst90();
|
|
|
// 90米风向
|
|
|
- if (windTowerStatusData.getWdInst90()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst90() != null)
|
|
|
wd90 = windTowerStatusData.getWdInst90();
|
|
|
// 100米风速
|
|
|
- if (windTowerStatusData.getWdInst100()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst100() != null)
|
|
|
ws100 = windTowerStatusData.getWsInst100();
|
|
|
// 100米风向
|
|
|
- if (windTowerStatusData.getWdInst100()!=null)
|
|
|
+ if (windTowerStatusData.getWdInst100() != null)
|
|
|
wd100 = windTowerStatusData.getWdInst100();
|
|
|
- if (windTowerStatusData.getWsInstHubHeight()!=null)
|
|
|
+ if (windTowerStatusData.getWsInstHubHeight() != null)
|
|
|
wsHubHeight = windTowerStatusData.getWsInstHubHeight();
|
|
|
- if (windTowerStatusData.getWdInstHubHeight()!=null)
|
|
|
+ if (windTowerStatusData.getWdInstHubHeight() != null)
|
|
|
wdHubHeight = windTowerStatusData.getWdInstHubHeight();
|
|
|
// 湿度产生
|
|
|
- if (windTowerStatusData.getRhInst()!=null)
|
|
|
+ if (windTowerStatusData.getRhInst() != null)
|
|
|
rh8 = windTowerStatusData.getRhInst();
|
|
|
// 温度产生
|
|
|
- if (windTowerStatusData.getTInst()!=null)
|
|
|
+ if (windTowerStatusData.getTInst() != null)
|
|
|
t8 = windTowerStatusData.getTInst();
|
|
|
// 气压产生
|
|
|
- if (windTowerStatusData.getPaInst()!=null)
|
|
|
+ if (windTowerStatusData.getPaInst() != null)
|
|
|
p8 = windTowerStatusData.getPaInst();
|
|
|
log.info(electricFieldInfo.getStationCode() + "生成测风塔数据用数据表");
|
|
|
}
|
|
@@ -835,7 +834,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
* 生成逆变器上报文件。
|
|
|
*/
|
|
|
public void generateNbqOrFjFile(Date date) {
|
|
|
- List<ElectricField> electricFieldList = null;
|
|
|
+ List<ElectricField> electricFieldList = new ArrayList<>();
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
|
} catch (BusinessException e) {
|
|
@@ -854,7 +853,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
Long endTime = DateMomentUtil.getMomentTime(systemDate.getTime(), 1, 5 * 60 * 1000L);
|
|
|
Long startTime = endTime - 4 * 60 * 1000;
|
|
|
// 生成上报文件名格式
|
|
|
- Template template = null;
|
|
|
+ Template template;
|
|
|
|
|
|
if (electricFieldInfo.getElectricFieldTypeEnum().toString().equals("E1")) {
|
|
|
// 获取逆变器模板
|
|
@@ -883,7 +882,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
// 获取风机信息
|
|
|
List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoRepository.findAll();
|
|
|
// 将测风塔信息过滤出上报的塔
|
|
|
- List<WindTurbineInfo> filterWindTurbineInfoList = windTurbineInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
+ List<WindTurbineInfo> filterWindTurbineInfoList = windTurbineInfoList.stream().filter(AbstractEquipmentInfo::getReport).collect(Collectors.toList());
|
|
|
if (filterWindTurbineInfoList.size() > 0) {
|
|
|
List<Map<String, Object>> fanList = new ArrayList<>();
|
|
|
for (WindTurbineInfo windTurbineInfo : filterWindTurbineInfoList) {
|
|
@@ -892,9 +891,9 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
map.put("dtaStatus", windTurbineInfo);
|
|
|
map.put("sample", windTurbineInfo.getSample() ? "1" : "0");
|
|
|
map.put("modelNumber", windTurbineInfo.getModelNumber());
|
|
|
- map.put("RatedCapacity", div(new BigDecimal(windTurbineInfo.getMaxPower()),new BigDecimal("1000"),2));
|
|
|
- map.put("elName",electricFieldInfo.getName());
|
|
|
- map.put("collectorCircuit",windTurbineInfo.getCollectorCircuit());
|
|
|
+ map.put("RatedCapacity", div(BigDecimal.valueOf(windTurbineInfo.getMaxPower()), new BigDecimal("1000"), 2));
|
|
|
+ map.put("elName", electricFieldInfo.getName());
|
|
|
+ map.put("collectorCircuit", windTurbineInfo.getCollectorCircuit());
|
|
|
|
|
|
String fjId = String.valueOf(windTurbineInfo.getId());
|
|
|
Map<String, String> fjMap = redisUtils.hgetall("fj-" + electricFieldInfo.getStationCode() + "-" + fjId);
|
|
@@ -975,9 +974,9 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (!isUseRedis){
|
|
|
- List<WindTurbineStatusData> windTurbineStatusDataList = windTurbineStatusDataRepository.findByTimeBetweenAndEquipmentId(new Date(startTime), new Date(endTime),fjId);
|
|
|
- if (!windTurbineStatusDataList.isEmpty()){
|
|
|
+ if (!isUseRedis) {
|
|
|
+ List<WindTurbineStatusData> windTurbineStatusDataList = windTurbineStatusDataRepository.findByTimeBetweenAndEquipmentId(new Date(startTime), new Date(endTime), fjId);
|
|
|
+ if (!windTurbineStatusDataList.isEmpty()) {
|
|
|
windTurbineStatusDataList.stream().sorted(Comparator.comparing(WindTurbineStatusData::getTime).reversed()).collect(Collectors.toList());
|
|
|
WindTurbineStatusData windTurbineStatusData = windTurbineStatusDataList.get(0);
|
|
|
if (windTurbineStatusData.getStatus() != null) {
|
|
@@ -1020,8 +1019,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
pitchAngle = windTurbineStatusData.getPitchAngle();
|
|
|
}
|
|
|
log.info(electricFieldInfo.getStationCode() + "生成风机数据用数据表");
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
log.info(electricFieldInfo.getStationCode() + "生成风机数据缓存和数据表都没有值,使用默认0");
|
|
|
}
|
|
|
}
|
|
@@ -1068,7 +1066,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
// 获取逆变器
|
|
|
List<InverterInfo> inverterInfoList = inverterInfoRepository.findAll();
|
|
|
// 过滤上报的逆变器
|
|
|
- List<InverterInfo> filterInverterInfoList = inverterInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
+ List<InverterInfo> filterInverterInfoList = inverterInfoList.stream().filter(AbstractEquipmentInfo::getReport).collect(Collectors.toList());
|
|
|
if (filterInverterInfoList.size() > 0) {
|
|
|
List<Map<String, String>> dtaInverterList = new ArrayList<>();
|
|
|
for (InverterInfo inverterInfo : filterInverterInfoList) {
|
|
@@ -1143,9 +1141,9 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!isUseRedis){
|
|
|
- List<InverterStatusData> inverterStatusDataList = inverterStatusDataRepository.findByTimeBetweenAndEquipmentId(new Date(startTime), new Date(endTime),nbqId);
|
|
|
- if (!inverterStatusDataList.isEmpty()){
|
|
|
+ if (!isUseRedis) {
|
|
|
+ List<InverterStatusData> inverterStatusDataList = inverterStatusDataRepository.findByTimeBetweenAndEquipmentId(new Date(startTime), new Date(endTime), nbqId);
|
|
|
+ if (!inverterStatusDataList.isEmpty()) {
|
|
|
inverterStatusDataList.stream().sorted(Comparator.comparing(InverterStatusData::getTime).reversed()).collect(Collectors.toList());
|
|
|
InverterStatusData inverterStatusData = inverterStatusDataList.get(0);
|
|
|
if (inverterStatusData.getStatus() != null) {
|
|
@@ -1180,8 +1178,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
cumulativeGeneratedEnergy = inverterStatusData.getCumulativeGeneratedEnergy();
|
|
|
}
|
|
|
log.info(electricFieldInfo.getStationCode() + "生成逆变器数据用数据表");
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
log.info(electricFieldInfo.getStationCode() + "生成逆变器数据缓存和数据表都没有值,使用默认0");
|
|
|
}
|
|
|
}
|
|
@@ -1225,7 +1222,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
* 生成理论功率上报文件
|
|
|
*/
|
|
|
public void generateTheroyFile(Date date) {
|
|
|
- List<ElectricField> electricFieldList = null;
|
|
|
+ List<ElectricField> electricFieldList = new ArrayList<>();
|
|
|
try {
|
|
|
electricFieldList = super.getMultipleStation();
|
|
|
} catch (BusinessException e) {
|
|
@@ -1245,7 +1242,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
Long endTime = DateMomentUtil.getMomentTime(systemDate.getTime(), 1, 5 * 60 * 1000L);
|
|
|
Long startTime = endTime - 4 * 60 * 1000;
|
|
|
// 生成上报文件名格式
|
|
|
- Template template = null;
|
|
|
+ Template template;
|
|
|
if (electricFieldInfo.getElectricFieldTypeEnum().toString().equals("E1")) {
|
|
|
fileName = e63UploadFileRuleService.getFileNameRule(electricFieldInfo, "E3", endTime);
|
|
|
if (getFileName(fileName, "E3", stationCode)) {
|
|
@@ -1281,7 +1278,6 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
if (StrUtil.isNotBlank(time)) {
|
|
|
if (Long.parseLong(time) >= startTime && Long.parseLong(time) <= endTime) {
|
|
|
// 对预测值保留2位小数显示输出
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
if (powerMap.get("ableValue") != null) {
|
|
|
ableValueAfter = Float.parseFloat(powerMap.get("ableValue"));
|
|
|
}
|
|
@@ -1294,15 +1290,15 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!isUseRedis){
|
|
|
+ if (!isUseRedis) {
|
|
|
// 从数据表获取
|
|
|
- List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataRepository.findByTimeBetweenAndStationCode(new Date(startTime), new Date(endTime),electricFieldInfo.getStationCode());
|
|
|
+ List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataRepository.findByTimeBetweenAndStationCode(new Date(startTime), new Date(endTime), electricFieldInfo.getStationCode());
|
|
|
if (!powerStationStatusDataList.isEmpty()) {
|
|
|
powerStationStatusDataList.stream().sorted(Comparator.comparing(PowerStationStatusData::getTime).reversed()).collect(Collectors.toList());
|
|
|
PowerStationStatusData powerStationStatusData = powerStationStatusDataList.get(0);
|
|
|
- if (powerStationStatusData.getAbleValue()!=null)
|
|
|
+ if (powerStationStatusData.getAbleValue() != null)
|
|
|
ableValueAfter = powerStationStatusData.getAbleValue().floatValue();
|
|
|
- if (powerStationStatusData.getTheoryValue()!=null)
|
|
|
+ if (powerStationStatusData.getTheoryValue() != null)
|
|
|
theoryValueAfter = powerStationStatusData.getTheoryValue().floatValue();
|
|
|
log.info(electricFieldInfo.getStationCode() + "生成理论功率使用数据表");
|
|
|
}
|
|
@@ -1364,19 +1360,19 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!isUseRedis){
|
|
|
+ if (!isUseRedis) {
|
|
|
// 从数据表获取
|
|
|
- List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataRepository.findByTimeBetweenAndStationCode(new Date(startTime), new Date(endTime),electricFieldInfo.getStationCode());
|
|
|
+ List<PowerStationStatusData> powerStationStatusDataList = powerStationStatusDataRepository.findByTimeBetweenAndStationCode(new Date(startTime), new Date(endTime), electricFieldInfo.getStationCode());
|
|
|
if (!powerStationStatusDataList.isEmpty()) {
|
|
|
powerStationStatusDataList.stream().sorted(Comparator.comparing(PowerStationStatusData::getTime).reversed()).collect(Collectors.toList());
|
|
|
PowerStationStatusData powerStationStatusData = powerStationStatusDataList.get(0);
|
|
|
- if (powerStationStatusData.getAbleValue()!=null)
|
|
|
+ if (powerStationStatusData.getAbleValue() != null)
|
|
|
ableValueAfter = powerStationStatusData.getAbleValue().floatValue();
|
|
|
- if (powerStationStatusData.getTheoryValue()!=null)
|
|
|
+ if (powerStationStatusData.getTheoryValue() != null)
|
|
|
theoryValueAfter = powerStationStatusData.getTheoryValue().floatValue();
|
|
|
- if (powerStationStatusData.getReferencePowerBySample()!=null)
|
|
|
+ if (powerStationStatusData.getReferencePowerBySample() != null)
|
|
|
referencePowerBySampleAfter = powerStationStatusData.getReferencePowerBySample().floatValue();
|
|
|
- if (powerStationStatusData.getReferencePowerByMeasuring()!=null)
|
|
|
+ if (powerStationStatusData.getReferencePowerByMeasuring() != null)
|
|
|
referencePowerByMeasuringAfter = powerStationStatusData.getReferencePowerByMeasuring().floatValue();
|
|
|
log.info(electricFieldInfo.getStationCode() + "生成理论功率使用数据表");
|
|
|
}
|
|
@@ -1417,7 +1413,7 @@ public class E63UploadFileService extends BaseUploadFileService {
|
|
|
if (scale < 0) {
|
|
|
throw new IllegalArgumentException("The scale must be a positive integer or zero");
|
|
|
}
|
|
|
- return v1.divide(v2, scale, BigDecimal.ROUND_HALF_UP);
|
|
|
+ return v1.divide(v2, scale, RoundingMode.HALF_UP);
|
|
|
}
|
|
|
|
|
|
private BigDecimal qxzRandomCreate(String type) {
|