|
@@ -2,7 +2,6 @@ package com.jiayue.ipfcst.fileupload.service.E42;
|
|
|
|
|
|
import com.jiayue.ipfcst.common.core.exception.BusinessException;
|
|
|
import com.jiayue.ipfcst.common.core.util.DateMomentUtil;
|
|
|
-import com.jiayue.ipfcst.common.core.util.NumberUtils;
|
|
|
import com.jiayue.ipfcst.common.data.constant.enums.ElectricFieldTypeEnum;
|
|
|
import com.jiayue.ipfcst.common.data.constant.enums.FileTypeEnum;
|
|
|
import com.jiayue.ipfcst.common.data.entity.*;
|
|
@@ -58,26 +57,16 @@ public class E42UploadFileService extends BaseUploadFileService implements IUplo
|
|
|
|
|
|
private final WindTowerInfoRepository windTowerInfoRepository;
|
|
|
|
|
|
- private final WindTowerStatusDataRepository windTowerStatusDataRepository;
|
|
|
-
|
|
|
private final NwpRepository nwpRepository;
|
|
|
|
|
|
private final E42UploadFileRuleService e42UploadFileRuleService;
|
|
|
|
|
|
private final WeatherStationInfoRepository weatherStationInfoRepository;
|
|
|
|
|
|
- private final WeatherStationStatusDataRepository weatherStationStatusDataRepository;
|
|
|
-
|
|
|
private final WindTurbineInfoRepository windTurbineInfoRepository;
|
|
|
|
|
|
- private final WindTurbineStatusDataRepository windTurbineStatusDataRepository;
|
|
|
-
|
|
|
private final InverterInfoService inverterInfoService;
|
|
|
|
|
|
- private final InverterStatusDataRepository inverterStatusDataRepository;
|
|
|
-
|
|
|
- private final EnvironmentDataAnyTimeGenerator environmentDataAnyTimeGenerator;
|
|
|
-
|
|
|
|
|
|
@Override
|
|
|
public Map<String, String> getUploadFileType() {
|
|
@@ -88,78 +77,7 @@ public class E42UploadFileService extends BaseUploadFileService implements IUplo
|
|
|
uploadFileTypeMap.put(FileTypeEnum.E6.toString(), FileTypeEnum.E6.getMessage());
|
|
|
uploadFileTypeMap.put(FileTypeEnum.E7.toString(), FileTypeEnum.E7.getMessage());
|
|
|
uploadFileTypeMap.put(FileTypeEnum.E8.toString(), FileTypeEnum.E8.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E84.toString(), FileTypeEnum.E84.getMessage());
|
|
|
uploadFileTypeMap.put(FileTypeEnum.E9.toString(), FileTypeEnum.E9.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E48.toString(), FileTypeEnum.E48.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E62.toString(), FileTypeEnum.E62.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E63.toString(), FileTypeEnum.E63.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E64.toString(), FileTypeEnum.E64.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E65.toString(), FileTypeEnum.E65.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E66.toString(), FileTypeEnum.E66.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E67.toString(), FileTypeEnum.E67.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E68.toString(), FileTypeEnum.E68.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E69.toString(), FileTypeEnum.E69.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E70.toString(), FileTypeEnum.E70.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E71.toString(), FileTypeEnum.E71.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E72.toString(), FileTypeEnum.E72.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E73.toString(), FileTypeEnum.E73.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E74.toString(), FileTypeEnum.E74.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E75.toString(), FileTypeEnum.E75.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E92.toString(), FileTypeEnum.E92.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E93.toString(), FileTypeEnum.E93.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E94.toString(), FileTypeEnum.E94.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E95.toString(), FileTypeEnum.E95.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E96.toString(), FileTypeEnum.E96.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E97.toString(), FileTypeEnum.E97.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E98.toString(), FileTypeEnum.E98.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E99.toString(), FileTypeEnum.E99.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E100.toString(), FileTypeEnum.E100.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E101.toString(), FileTypeEnum.E101.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E102.toString(), FileTypeEnum.E102.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E103.toString(), FileTypeEnum.E103.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E104.toString(), FileTypeEnum.E104.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E120.toString(), FileTypeEnum.E120.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E121.toString(), FileTypeEnum.E121.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E141.toString(), FileTypeEnum.E141.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E142.toString(), FileTypeEnum.E142.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E143.toString(), FileTypeEnum.E143.getMessage());
|
|
|
-
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E174.toString(), FileTypeEnum.E174.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E175.toString(), FileTypeEnum.E175.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E176.toString(), FileTypeEnum.E176.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E177.toString(), FileTypeEnum.E177.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E178.toString(), FileTypeEnum.E178.getMessage());
|
|
|
-
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E179.toString(), FileTypeEnum.E179.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E180.toString(), FileTypeEnum.E180.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E181.toString(), FileTypeEnum.E181.getMessage());
|
|
|
-
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E182.toString(), FileTypeEnum.E182.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E183.toString(), FileTypeEnum.E183.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E184.toString(), FileTypeEnum.E184.getMessage());
|
|
|
-
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E185.toString(), FileTypeEnum.E185.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E186.toString(), FileTypeEnum.E186.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E187.toString(), FileTypeEnum.E187.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E188.toString(), FileTypeEnum.E188.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E189.toString(), FileTypeEnum.E189.getMessage());
|
|
|
-
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E225.toString(), FileTypeEnum.E225.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E226.toString(), FileTypeEnum.E226.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E227.toString(), FileTypeEnum.E227.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E228.toString(), FileTypeEnum.E228.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E229.toString(), FileTypeEnum.E229.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E230.toString(), FileTypeEnum.E230.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E231.toString(), FileTypeEnum.E231.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E232.toString(), FileTypeEnum.E232.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E233.toString(), FileTypeEnum.E233.getMessage());
|
|
|
-
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E234.toString(), FileTypeEnum.E234.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E235.toString(), FileTypeEnum.E235.getMessage());
|
|
|
-
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E237.toString(), FileTypeEnum.E237.getMessage());
|
|
|
- uploadFileTypeMap.put(FileTypeEnum.E238.toString(), FileTypeEnum.E238.getMessage());
|
|
|
-
|
|
|
return uploadFileTypeMap;
|
|
|
}
|
|
|
|
|
@@ -194,260 +112,6 @@ public class E42UploadFileService extends BaseUploadFileService implements IUplo
|
|
|
// 风机
|
|
|
this.generateE9File(date);
|
|
|
break;
|
|
|
- case "E48":
|
|
|
- // 单机
|
|
|
- this.generateE48File(date);
|
|
|
- break;
|
|
|
- case "E62":
|
|
|
- // 旧可用短期
|
|
|
- this.generateE62File(date);
|
|
|
- break;
|
|
|
- case "E63":
|
|
|
- // 旧可用超短期
|
|
|
- this.generateE63File(date);
|
|
|
- break;
|
|
|
- case "E64":
|
|
|
- // 旧72NWP
|
|
|
- this.generateE64File(date);
|
|
|
- break;
|
|
|
- case "E65":
|
|
|
- // 旧气象站
|
|
|
- this.generateE65File(date);
|
|
|
- break;
|
|
|
- case "E66":
|
|
|
- // 旧测风塔
|
|
|
- this.generateE66File(date);
|
|
|
- break;
|
|
|
- case "E84":
|
|
|
- // 旧逆变器
|
|
|
- this.generateE84File(date);
|
|
|
- break;
|
|
|
- case "E67":
|
|
|
- // 旧风场单机
|
|
|
- this.generateE67File(date);
|
|
|
- break;
|
|
|
- case "E68":
|
|
|
- // 地调短期
|
|
|
- this.generateE68File(date);
|
|
|
- break;
|
|
|
- case "E69":
|
|
|
- // 地调超短期
|
|
|
- this.generateE69File(date);
|
|
|
- break;
|
|
|
- case "E70":
|
|
|
- // 地调72nwp
|
|
|
- this.generateE70File(date);
|
|
|
- break;
|
|
|
- case "E71":
|
|
|
- // 地调气象站
|
|
|
- this.generateE71File(date);
|
|
|
- break;
|
|
|
- case "E72":
|
|
|
- // 地调测风塔
|
|
|
- this.generateE72File(date);
|
|
|
- break;
|
|
|
- case "E73":
|
|
|
- // 地调单机
|
|
|
- this.generateE73File(date);
|
|
|
- break;
|
|
|
- case "E74":
|
|
|
- // 地调风机基础信息
|
|
|
- this.generateE74File(date);
|
|
|
- break;
|
|
|
- case "E75":
|
|
|
- // 地调逆变器基础信息
|
|
|
- this.generateE75File(date);
|
|
|
- break;
|
|
|
- case "E92":
|
|
|
- // 省调逆变器基础信息
|
|
|
- this.generateE92File(date);
|
|
|
- break;
|
|
|
-
|
|
|
- case "E93":
|
|
|
- // 黄冈地调短期
|
|
|
- this.generateE93File(date);
|
|
|
- break;
|
|
|
- case "E94":
|
|
|
- // 黄冈地调超短期
|
|
|
- this.generateE94File(date);
|
|
|
- break;
|
|
|
- case "E95":
|
|
|
- // 黄冈地调72nwp
|
|
|
- this.generateE95File(date);
|
|
|
- break;
|
|
|
- case "E96":
|
|
|
- // 黄冈地调气象站
|
|
|
- this.generateE96File(date);
|
|
|
- break;
|
|
|
- case "E97":
|
|
|
- // 黄冈地调测风塔
|
|
|
- this.generateE97File(date);
|
|
|
- break;
|
|
|
- case "E98":
|
|
|
- // 黄冈地调风机
|
|
|
- this.generateE98File(date);
|
|
|
- break;
|
|
|
- case "E99":
|
|
|
- // 黄冈地调逆变器
|
|
|
- this.generateE99File(date);
|
|
|
- break;
|
|
|
- case "E100":
|
|
|
- // 随州地调短期
|
|
|
- this.generateE100File(date);
|
|
|
- break;
|
|
|
- case "E101":
|
|
|
- // 随州地调超短期
|
|
|
- this.generateE101File(date);
|
|
|
- break;
|
|
|
- case "E102":
|
|
|
- // 随州地调72nwp
|
|
|
- this.generateE102File(date);
|
|
|
- break;
|
|
|
- case "E103":
|
|
|
- // 随州地调气象站
|
|
|
- this.generateE103File(date);
|
|
|
- break;
|
|
|
- case "E104":
|
|
|
- // 随州地调逆变器
|
|
|
- this.generateE104File(date);
|
|
|
- break;
|
|
|
- case "E120":
|
|
|
- // 孝感地调测风塔
|
|
|
- this.generateE120File(date);
|
|
|
- break;
|
|
|
- case "E121":
|
|
|
- // 孝感地调风机
|
|
|
- this.generateE121File(date);
|
|
|
- break;
|
|
|
- case "E141":
|
|
|
- // 孝感地调短期
|
|
|
- this.generateE141File(date);
|
|
|
- break;
|
|
|
- case "E142":
|
|
|
- // 孝感地调超短期
|
|
|
- this.generateE142File(date);
|
|
|
- break;
|
|
|
- case "E143":
|
|
|
- // 孝感地调nwp
|
|
|
- this.generateE143File(date);
|
|
|
- break;
|
|
|
-
|
|
|
- case "E174":
|
|
|
- // 咸宁地调短期
|
|
|
- this.generateE174File(date);
|
|
|
- break;
|
|
|
- case "E175":
|
|
|
- // 咸宁地调超短期
|
|
|
- this.generateE175File(date);
|
|
|
- break;
|
|
|
- case "E176":
|
|
|
- // 咸宁地调超短期
|
|
|
- this.generateE176File(date);
|
|
|
- break;
|
|
|
- case "E177":
|
|
|
- this.generateE177File(date);
|
|
|
- break;
|
|
|
- case "E178":
|
|
|
- // 咸宁地调nwp
|
|
|
- this.generateE178File(date);
|
|
|
- break;
|
|
|
- case "E179":
|
|
|
- // 上午短期
|
|
|
- this.generateE179File(date);
|
|
|
- break;
|
|
|
- case "E180":
|
|
|
- // 下午短期
|
|
|
- this.generateE180File(date);
|
|
|
- break;
|
|
|
- case "E181":
|
|
|
- // 原短期下午
|
|
|
- this.generateE181File(date);
|
|
|
- break;
|
|
|
- case "E182":
|
|
|
- // 上午短期(老系统)
|
|
|
- this.generateE182File(date);
|
|
|
- break;
|
|
|
- case "E183":
|
|
|
- // 下午短期(老系统)
|
|
|
- this.generateE183File(date);
|
|
|
- break;
|
|
|
- case "E184":
|
|
|
- // 原短期下午(老系统)
|
|
|
- this.generateE184File(date);
|
|
|
- break;
|
|
|
- case "E185":
|
|
|
- // 湖北荆州地调短期
|
|
|
- this.generateE185File(date);
|
|
|
- break;
|
|
|
- case "E186":
|
|
|
- // 湖北荆州地调超短期
|
|
|
- this.generateE186File(date);
|
|
|
- break;
|
|
|
- case "E187":
|
|
|
- // 湖北荆州地调nwp
|
|
|
- this.generateE187File(date);
|
|
|
- break;
|
|
|
- case "E188":
|
|
|
- // 湖北荆州地调测风塔
|
|
|
- this.generateE188File(date);
|
|
|
- break;
|
|
|
- case "E189":
|
|
|
- // 湖北荆州地调风机
|
|
|
- this.generateE189File(date);
|
|
|
- break;
|
|
|
-
|
|
|
- case "E225":
|
|
|
- // 宜昌地调短期
|
|
|
- this.generateE225File(date);
|
|
|
- break;
|
|
|
- case "E226":
|
|
|
- // 宜昌地调超短期
|
|
|
- this.generateE226File(date);
|
|
|
- break;
|
|
|
- case "E227":
|
|
|
- // 宜昌地调NWP
|
|
|
- this.generateE227File(date);
|
|
|
- break;
|
|
|
- case "E228":
|
|
|
- // 宜昌地调测风塔
|
|
|
- this.generateE228File(date);
|
|
|
- break;
|
|
|
- case "E229":
|
|
|
- // 宜昌地调单机
|
|
|
- this.generateE229File(date);
|
|
|
- break;
|
|
|
- case "E230":
|
|
|
- // 宜昌地调气象站
|
|
|
- this.generateE230File(date);
|
|
|
- break;
|
|
|
- case "E231":
|
|
|
- // 宜昌地调逆变器
|
|
|
- this.generateE231File(date);
|
|
|
- break;
|
|
|
- case "E232":
|
|
|
- // 宜昌地调风机信息
|
|
|
- this.generateE232File(date);
|
|
|
- break;
|
|
|
- case "E233":
|
|
|
- // 宜昌地调逆变器信息
|
|
|
- this.generateE233File(date);
|
|
|
- break;
|
|
|
- case "E234":
|
|
|
- // 孝感地调气象站
|
|
|
- this.generateE234File(date);
|
|
|
- break;
|
|
|
- case "E235":
|
|
|
- // 孝感地调逆变器
|
|
|
- this.generateE235File(date);
|
|
|
- break;
|
|
|
- case "E237":
|
|
|
- // 荆门地调72nwp(下午)
|
|
|
- this.generateE237File(date);
|
|
|
- break;
|
|
|
- case "E238":
|
|
|
- // 地调短期
|
|
|
- this.generateE238File(date);
|
|
|
- break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -1032,128 +696,6 @@ public class E42UploadFileService extends BaseUploadFileService implements IUplo
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 生成宜昌逆变器地调上报文件。
|
|
|
- * 文件名格式(ZJNCMS_20181204_1050_NBQ.PVD)
|
|
|
- */
|
|
|
- private void generateE84File(Date date) {
|
|
|
- // 获取基本信息模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DDNBQ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("逆变器文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E84", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E84")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取逆变器
|
|
|
- List<InverterInfo> inverterInfos = inverterInfoService.getAll();
|
|
|
- // 获取逆变器遥测数据
|
|
|
- // List<InverterStatusData> inverterStatusDataList = inverterStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的逆变器
|
|
|
- List<InverterInfo> filterInverterInfoList = inverterInfos.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- //因为现场未接入数据 默认状态为3 数据为0
|
|
|
- if (filterInverterInfoList.size() > 0) {
|
|
|
- List<Map<String, String>> dtaInverterList = new ArrayList<>();
|
|
|
- for (InverterInfo inverterInfo : filterInverterInfoList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", inverterInfo.getName());
|
|
|
- // 过滤出逆变器对应的数据
|
|
|
- // List<InverterStatusData> filterInverterStatusData = inverterStatusDataList.stream().filter(w -> w.getEquipmentNo() == inverterInfo.getId()).collect(Collectors.toList());
|
|
|
- InverterStatusData inverterStatusData = super.getInverterStatusData(inverterInfo.getId());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- if (inverterStatusData != null) {
|
|
|
- //map.put("status", inverterStatusData.getStatus().toString());
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(inverterStatusData.getActivePower().compareTo(new BigDecimal(-99)) == 0 ? 0 : inverterStatusData.getActivePower().divide(new BigDecimal(1000))));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(inverterStatusData.getReactivePower().compareTo(new BigDecimal(-99)) == 0 ? 0 : inverterStatusData.getReactivePower().divide(new BigDecimal(1000))));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(inverterStatusData.getVoltage().compareTo(new BigDecimal(-99)) == 0 ? 0 : inverterStatusData.getVoltage()));
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(inverterStatusData.getElectricalCurrent().compareTo(new BigDecimal(-99)) == 0 ? 0 : inverterStatusData.getElectricalCurrent()));
|
|
|
- /*韩雪融
|
|
|
- 单机信息:
|
|
|
- WPD文件:省调老系统-地调
|
|
|
- 0是运行,1是故障,2是待机,3是检修
|
|
|
- PVD文件:
|
|
|
- 1是运行,0是故障,2是待机,3是检修
|
|
|
-
|
|
|
- 老系统WPD:
|
|
|
- 有功>0 状态为运行:0
|
|
|
- 有功<=0 状态为非运行:2
|
|
|
- 新系统PVD:
|
|
|
- 有功>0 状态为运行:1
|
|
|
- 有功<=0 状态为非运行:2*/
|
|
|
- BigDecimal bd = new BigDecimal(map.get("NbqActivePower"));
|
|
|
- if (bd.compareTo(new BigDecimal(0)) == 1) {
|
|
|
- //有功大于0 则运行状态为0
|
|
|
- map.put("status", "0");
|
|
|
- } else {
|
|
|
- //不大于0则为小于等于0 则运行状态为2
|
|
|
- map.put("status", "2");
|
|
|
- }
|
|
|
- } else {
|
|
|
- map.put("status", "2");
|
|
|
- map.put("NbqActivePower", "0");
|
|
|
- map.put("NbqReActivePower", "0");
|
|
|
- map.put("Voltage", "0");
|
|
|
- map.put("GalvanicCurrent", "0");
|
|
|
- }
|
|
|
- dtaInverterList.add(map);
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", dtaInverterList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("netSubstationName", 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"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E84.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的逆变器,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("逆变器文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("逆变器上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
* 生成逆变器省调上报文件。
|
|
|
* 文件名格式(ZJNCMS_20181204_1050_NBQ.PVD)
|
|
|
*/
|
|
@@ -1375,6599 +917,6 @@ public class E42UploadFileService extends BaseUploadFileService implements IUplo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 生成省调D5000风场单机上报文件。
|
|
|
- */
|
|
|
- private void generateE48File(Date date) {
|
|
|
- // 获取单机模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DJ_SD.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("单机文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E48", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E48")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取风机
|
|
|
- List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoRepository.findAllByOrderByIdAsc();
|
|
|
- // 获取风机数据
|
|
|
- // List<WindTurbineStatusData> fjStatusDataList = windTurbineStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的风机
|
|
|
- List<WindTurbineInfo> filterWindInfoList = windTurbineInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- filterWindInfoList.sort(Comparator.comparing(WindTurbineInfo::getId));
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- int index = 0;
|
|
|
- String name = "";
|
|
|
- String flag = "0.00";
|
|
|
- for (WindTurbineInfo windTurbineInfo : filterWindInfoList) {
|
|
|
- // 根据风机找到对应的风机数据
|
|
|
- // List<WindTurbineStatusData> filterWindTurbineStatusDataList = fjStatusDataList.stream().filter(w -> w.getEquipmentNo() == windTurbineInfo.getId()).collect(Collectors.toList());
|
|
|
- WindTurbineStatusData windTurbineStatusData = super.getWindTurbineStatusData(windTurbineInfo.getId());
|
|
|
- if (windTurbineStatusData != null) {
|
|
|
- index = index + 1;
|
|
|
- if (index < 10) {
|
|
|
- name = "0" + String.valueOf(index);
|
|
|
- } else {
|
|
|
- name = String.valueOf(index);
|
|
|
- }
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- //接到风机运行状态的数据,不做处理,有功无功电压电流风速风向等真实接入 0:运行
|
|
|
- if (windTurbineStatusData.getStatus() == 0) {
|
|
|
- // 名称
|
|
|
- map.put("name", name);
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(windTurbineStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- //湖北康桥该类型上报文件中 1代表运行 0代表故障 ,但是接进来的数据是 0代表运行 1代表故障,所以在生成的上报文件中对调下
|
|
|
-
|
|
|
- map.put("status", "1" + "");
|
|
|
-
|
|
|
- vList.add(map);
|
|
|
- //接到风机待机状态的数据,将有功置0,无功电压电流风速风向等真实接入 2:待机
|
|
|
- } else if (windTurbineStatusData.getStatus() == 2) {
|
|
|
- // 名称
|
|
|
- map.put("name", name);
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- //接到风机故障状态的数据,将有功、无功置0,其他数据真实接入 1:故障
|
|
|
- } else if (windTurbineStatusData.getStatus() == 1) {
|
|
|
- // 名称
|
|
|
- map.put("name", name);
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", flag);
|
|
|
- // 状态
|
|
|
- map.put("status", "0" + "");
|
|
|
-
|
|
|
- vList.add(map);
|
|
|
- } else {
|
|
|
- // 名称
|
|
|
- map.put("name", name);
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", flag);
|
|
|
- // 电压
|
|
|
- map.put("Voltage", flag);
|
|
|
- // 风速
|
|
|
- map.put("ws", flag);
|
|
|
- // 风向
|
|
|
- map.put("wd", flag);
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", flag);
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().toString());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E48.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("省调D5000单机文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("省调D5000单机上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成短期预测上报文件。
|
|
|
- */
|
|
|
- private void generateE62File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3");
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E62", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E62")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
-
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E62.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成超短期预测上报文件。
|
|
|
- */
|
|
|
- private void generateE63File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- File file1 = null;
|
|
|
- try {
|
|
|
- file1 = ResourceUtils.getFile(this.vmsPath + "/CDQ.vm");
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- Template template = this.velocityEngine.getTemplate(file1.getPath());
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16");
|
|
|
- // 获取提前几分钟生成超短期
|
|
|
- int cdqUpMin = super.getTranSysParameter("CDQ_UP_MIN", "0");
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = new Date(date.getTime() - cdqUpMin * 1000 * 60);
|
|
|
- }
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- 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 = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E63", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E63")) {
|
|
|
- // 查询超短期预测功率
|
|
|
- List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerUltraShortTermList);
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(startTime, "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.E63.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("超短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("超短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成72NWP预测上报文件。
|
|
|
- */
|
|
|
- private void generateE64File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NWP72.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int fileNwpDays = super.getTranSysParameter("FILE_NWP_DAYS", "3");
|
|
|
- //获取nwp72轮毂高度
|
|
|
- int turbinH = super.getTranSysParameter("HB_NWP72_TURBINH", "80");
|
|
|
- try {
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, fileNwpDays).getTime()) - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E64", startTime);
|
|
|
- if (getFileName(fileName, "E64")) {
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- String efiLabel = "";
|
|
|
- // 查询NWP数据(风电第一个点从00:15开始)
|
|
|
- List<Nwp> nwpDataList = this.nwpService.getNwpData(startTime + 1000 * 60 * 15, endTime + 1000 * 60 * 15);
|
|
|
- // 按照预测时间进行升序
|
|
|
- nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- // 光伏
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("time", DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm"));
|
|
|
- map.put("swr", df.format(nwpDataList.get(i).getSwr()));
|
|
|
- map.put("directRadiation", df.format(NumberUtils.multiply(nwpDataList.get(i).getSwr(), new BigDecimal(0.7))));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
-
|
|
|
- String tempTime = "";
|
|
|
- if ("00:00".equals(DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "HH:mm"))) {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime() - 1000 * 60 * 60 * 24, "yyyy-MM-dd") + " 24:00";
|
|
|
- } else {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm");
|
|
|
- }
|
|
|
-
|
|
|
- map.put("time", tempTime);
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- map.put("ws30", df.format(nwpDataList.get(i).getWs30()));
|
|
|
- map.put("wd30", df.format(nwpDataList.get(i).getWd30()));
|
|
|
- map.put("ws100", df.format(nwpDataList.get(i).getWs100()));
|
|
|
- map.put("wd100", df.format(nwpDataList.get(i).getWd100()));
|
|
|
- map.put("ws170", df.format(nwpDataList.get(i).getWs170()));
|
|
|
- map.put("wd170", df.format(nwpDataList.get(i).getWd170()));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- // 场站经纬度
|
|
|
- velocityContext.put("longitude", electricFieldInfo.getLongitude());
|
|
|
- velocityContext.put("latitude", electricFieldInfo.getLatitude());
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- velocityContext.put("vList", list);
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().name());
|
|
|
- velocityContext.put("turbinH", turbinH);
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E64.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("72NWP文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("72NWP上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成气象站上报文件
|
|
|
- */
|
|
|
- private void generateE65File(Date date) {
|
|
|
- // 获取气象站模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/QXZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("气象站文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E65", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E65")) {
|
|
|
- // 获取气象站信息
|
|
|
- List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WeatherStationInfo> weatherStationInfos = weatherStationInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!weatherStationInfos.isEmpty()) {
|
|
|
- Integer uploadWeatherStationId = weatherStationInfos.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WeatherStationStatusData> weatherStationStatusDataList = weatherStationStatusDataRepository.findByTimeBetweenAndEquipmentNo(new Date(startTime), new Date(endTime), uploadWeatherStationId);
|
|
|
- // 数据格式化
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- BigDecimal globalR = new BigDecimal(0);
|
|
|
- BigDecimal directR = new BigDecimal(0);
|
|
|
- BigDecimal diffuseR = new BigDecimal(0);
|
|
|
- BigDecimal airT = new BigDecimal(0);
|
|
|
- BigDecimal p = new BigDecimal(0);
|
|
|
- BigDecimal rh = new BigDecimal(0);
|
|
|
- BigDecimal cellT = new BigDecimal(0);
|
|
|
- BigDecimal ws = new BigDecimal(0);
|
|
|
- BigDecimal wd = new BigDecimal(0);
|
|
|
-
|
|
|
- WeatherStationStatusData weatherStationStatusData = super.getWeatherStationStatusData(uploadWeatherStationId);
|
|
|
- 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 = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("GlobalR", globalR);
|
|
|
- velocityContext.put("DirectR", directR);
|
|
|
- velocityContext.put("DiffuseR", diffuseR);
|
|
|
- velocityContext.put("AirT", airT);
|
|
|
- velocityContext.put("P", p);
|
|
|
- velocityContext.put("RH", rh);
|
|
|
- velocityContext.put("CellT", cellT);
|
|
|
- velocityContext.put("WS", ws);
|
|
|
- velocityContext.put("WD", wd);
|
|
|
- velocityContext.put("time", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd"));
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- velocityContext.put("efiLabel", "hubei." + electricFieldInfo.getSign() + ".guangfuP");
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 系统当前日期
|
|
|
- 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"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E65.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的气象站,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("气象站上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成测风塔上报文件
|
|
|
- */
|
|
|
- private void generateE66File(Date date) {
|
|
|
- // 获取气象站模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/CFT.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("测风塔文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E66", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E66")) {
|
|
|
- // 获取测风塔信息
|
|
|
- List<WindTowerInfo> windTowerInfoList = windTowerInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WindTowerInfo> filterWindTowerInfoList = windTowerInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!filterWindTowerInfoList.isEmpty()) {
|
|
|
- Integer uploadWindTowerId = filterWindTowerInfoList.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WindTowerStatusData> windTowerStatusDataList = windTowerStatusDataRepository.findByEquipmentNoAndTimeBetween(uploadWindTowerId, new Date(startTime), new Date(endTime));
|
|
|
- // 数据格式化
|
|
|
- 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 ws70 = new BigDecimal(0);
|
|
|
- BigDecimal wd70 = 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);
|
|
|
-
|
|
|
- WindTowerStatusData windTowerStatusData = super.getWindTowerStatusData(uploadWindTowerId);
|
|
|
- if (windTowerStatusData == null) {
|
|
|
- // 没有测风塔数据用nwp数据补
|
|
|
- Long nwpTime;
|
|
|
- try {
|
|
|
- nwpTime = DateMomentUtil.getMomentTime(systemDate.getTime(), 1, 15 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("获取nwp时刻步长错误", e);
|
|
|
- nwpTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- List<Nwp> nwpList = nwpRepository.findByPreTimeBetween(nwpTime, nwpTime);
|
|
|
-
|
|
|
- if (nwpList.size() > 0) {
|
|
|
- Nwp nwpData = nwpList.get(0);
|
|
|
- ws10 = nwpData.getWs10();
|
|
|
- wd10 = nwpData.getWd10();
|
|
|
- ws30 = nwpData.getWs30();
|
|
|
- wd30 = nwpData.getWd30();
|
|
|
- ws50 = nwpData.getWs50();
|
|
|
- wd50 = nwpData.getWd50();
|
|
|
- ws70 = nwpData.getWs70();
|
|
|
- wd70 = nwpData.getWd70();
|
|
|
- wsHubHeight = nwpData.getWs70();
|
|
|
- wdHubHeight = nwpData.getWd70();
|
|
|
- rh8 = nwpData.getRh();
|
|
|
- t8 = nwpData.getT();
|
|
|
- p8 = nwpData.getPressure();
|
|
|
- }
|
|
|
- // 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);
|
|
|
- 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();
|
|
|
- wd10 = windTowerStatusData.getWdInst10();
|
|
|
- ws30 = windTowerStatusData.getWsInst30();
|
|
|
- wd30 = windTowerStatusData.getWdInst30();
|
|
|
- ws50 = windTowerStatusData.getWsInst50();
|
|
|
- wd50 = windTowerStatusData.getWdInst50();
|
|
|
- ws70 = windTowerStatusData.getWsInst70();
|
|
|
- wd70 = windTowerStatusData.getWdInst70();
|
|
|
- wsHubHeight = windTowerStatusData.getWsInstHubHeight();
|
|
|
- wdHubHeight = windTowerStatusData.getWdInstHubHeight();
|
|
|
- t8 = windTowerStatusData.getTInst();
|
|
|
- p8 = windTowerStatusData.getPaInst();
|
|
|
- rh8 = windTowerStatusData.getRhInst();
|
|
|
-
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("efiLabel", "hubei." + electricFieldInfo.getSign() + ".fengdianP");
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- velocityContext.put("WS_10", ws10);
|
|
|
- velocityContext.put("WD_10", wd10);
|
|
|
- velocityContext.put("WS_30", ws30);
|
|
|
- velocityContext.put("WD_30", wd30);
|
|
|
- velocityContext.put("WS_50", ws50);
|
|
|
- velocityContext.put("WD_50", wd50);
|
|
|
- velocityContext.put("WS_70", ws70);
|
|
|
- velocityContext.put("WD_70", wd70);
|
|
|
- velocityContext.put("WS_HubHeight", wsHubHeight);
|
|
|
- velocityContext.put("WD_HubHeight", wdHubHeight);
|
|
|
- velocityContext.put("T_8", t8);
|
|
|
- velocityContext.put("P_8", p8);
|
|
|
- velocityContext.put("RH_8", rh8);
|
|
|
-
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E66.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的测风塔,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("测风塔上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成风场单机上报文件。
|
|
|
- */
|
|
|
- private void generateE67File(Date date) {
|
|
|
- // 获取单机模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DJ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("单机文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E67", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E67")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取风机
|
|
|
- List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoRepository.findAllByOrderByIdAsc();
|
|
|
- // 获取风机数据
|
|
|
- // List<WindTurbineStatusData> fjStatusDataList = windTurbineStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的风机
|
|
|
- List<WindTurbineInfo> filterWindInfoList = windTurbineInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- String flag = "0.00";
|
|
|
- for (WindTurbineInfo windTurbineInfo : filterWindInfoList) {
|
|
|
- // 根据风机找到对应的风机数据
|
|
|
- // List<WindTurbineStatusData> filterWindTurbineStatusDataList = fjStatusDataList.stream().filter(w -> w.getEquipmentNo() == windTurbineInfo.getId()).collect(Collectors.toList());
|
|
|
- WindTurbineStatusData windTurbineStatusData = super.getWindTurbineStatusData(windTurbineInfo.getId());
|
|
|
- if (windTurbineStatusData != null) {
|
|
|
- // filterWindTurbineStatusDataList.sort(Comparator.comparing(WindTurbineStatusData::getTime).reversed());
|
|
|
- // WindTurbineStatusData windTurbineStatusData = filterWindTurbineStatusDataList.get(0);
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- //接到风机运行状态的数据,不做处理,有功无功电压电流风速风向等真实接入
|
|
|
- if (windTurbineStatusData.getStatus() == 0) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(windTurbineStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- //接到风机待机状态的数据,将有功置0,无功电压电流风速风向等真实接入
|
|
|
- } else if (windTurbineStatusData.getStatus() == 2) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- //接到风机故障状态的数据,将有功、无功置0,其他数据真实接入
|
|
|
- } else if (windTurbineStatusData.getStatus() == 1) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", flag);
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- } else {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", flag);
|
|
|
- // 电压
|
|
|
- map.put("Voltage", flag);
|
|
|
- // 风速
|
|
|
- map.put("ws", flag);
|
|
|
- // 风向d
|
|
|
- map.put("wd", flag);
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", flag);
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getSign());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E67.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("单机文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("单机上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成地调短期预测上报文件。
|
|
|
- */
|
|
|
- private void generateE68File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_DD.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3");
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E68", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E68")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E68.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("地调短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("地调短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成地调超短期预测上报文件。
|
|
|
- */
|
|
|
- private void generateE69File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- File file1 = null;
|
|
|
- try {
|
|
|
- file1 = ResourceUtils.getFile(this.vmsPath + "/CDQ_DD.vm");
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- Template template = this.velocityEngine.getTemplate(file1.getPath());
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16");
|
|
|
- // 获取提前几分钟生成超短期
|
|
|
- int cdqUpMin = super.getTranSysParameter("CDQ_UP_MIN", "0");
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = new Date(date.getTime() - cdqUpMin * 1000 * 60);
|
|
|
- }
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- 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 = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E69", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E69")) {
|
|
|
- // 查询超短期预测功率
|
|
|
- List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime);
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerUltraShortTermList);
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
-
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E69.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("地调超短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("地调超短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void generateE70File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NWP72_DD_JM.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int fileNwpDays = super.getTranSysParameter("HUBEI_DD_NWP", "3");
|
|
|
- //获取nwp72轮毂高度
|
|
|
- int turbinH = super.getTranSysParameter("HB_NWP72_TURBINH", "80");
|
|
|
- try {
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, fileNwpDays).getTime()) - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E70", startTime);
|
|
|
- if (getFileName(fileName, "E70")) {
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- String efiLabel = "";
|
|
|
- // 查询NWP数据(风电第一个点从00:15开始)
|
|
|
- List<Nwp> nwpDataList = this.nwpService.getNwpData(startTime + 1000 * 60 * 15, endTime + 1000 * 60 * 15);
|
|
|
- // 按照预测时间进行升序
|
|
|
- nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- // 光伏
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("time", DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm"));
|
|
|
- map.put("swr", df.format(nwpDataList.get(i).getSwr()));
|
|
|
- map.put("directRadiation", df.format(NumberUtils.multiply(nwpDataList.get(i).getSwr(), new BigDecimal(0.7))));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
-
|
|
|
- String tempTime = "";
|
|
|
- if ("00:00".equals(DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "HH:mm"))) {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime() - 1000 * 60 * 60 * 24, "yyyy-MM-dd") + " 24:00";
|
|
|
- } else {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm");
|
|
|
- }
|
|
|
-
|
|
|
- map.put("time", tempTime);
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- map.put("ws30", df.format(nwpDataList.get(i).getWs30()));
|
|
|
- map.put("wd30", df.format(nwpDataList.get(i).getWd30()));
|
|
|
- map.put("ws50", df.format(nwpDataList.get(i).getWs50()));
|
|
|
- map.put("wd50", df.format(nwpDataList.get(i).getWd50()));
|
|
|
- map.put("ws70", df.format(nwpDataList.get(i).getWs70()));
|
|
|
- map.put("wd70", df.format(nwpDataList.get(i).getWd70()));
|
|
|
- map.put("ws170", df.format(nwpDataList.get(i).getWs170()));
|
|
|
- map.put("wd170", df.format(nwpDataList.get(i).getWd170()));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- // 场站经纬度
|
|
|
- velocityContext.put("longitude", electricFieldInfo.getLongitude());
|
|
|
- velocityContext.put("latitude", electricFieldInfo.getLatitude());
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- velocityContext.put("vList", list);
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().name());
|
|
|
- velocityContext.put("turbinH", turbinH);
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E70.name(), null, date);
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("地调72NWP文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("地调72NWP上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成地调气象站上报文件
|
|
|
- */
|
|
|
- private void generateE71File(Date date) {
|
|
|
- // 获取气象站模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/QXZ_DD.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("气象站文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E71", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E71")) {
|
|
|
- // 获取气象站信息
|
|
|
- List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WeatherStationInfo> weatherStationInfos = weatherStationInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!weatherStationInfos.isEmpty()) {
|
|
|
- Integer uploadWeatherStationId = weatherStationInfos.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WeatherStationStatusData> weatherStationStatusDataList = weatherStationStatusDataRepository.findByTimeBetweenAndEquipmentNo(new Date(startTime), new Date(endTime), uploadWeatherStationId);
|
|
|
- WeatherStationStatusData weatherStationStatusData = super.getWeatherStationStatusData(uploadWeatherStationId);
|
|
|
- // 数据格式化
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- BigDecimal globalR = new BigDecimal(0);
|
|
|
- BigDecimal directR = new BigDecimal(0);
|
|
|
- BigDecimal diffuseR = new BigDecimal(0);
|
|
|
- BigDecimal airT = new BigDecimal(0);
|
|
|
- BigDecimal p = new BigDecimal(0);
|
|
|
- BigDecimal rh = new BigDecimal(0);
|
|
|
- BigDecimal cellT = new BigDecimal(0);
|
|
|
- BigDecimal ws = new BigDecimal(0);
|
|
|
- BigDecimal wd = 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 = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("globalR", globalR);
|
|
|
- velocityContext.put("directR", directR);
|
|
|
- velocityContext.put("diffuseR", diffuseR);
|
|
|
- velocityContext.put("airT", airT);
|
|
|
- velocityContext.put("p", p);
|
|
|
- velocityContext.put("rh", rh);
|
|
|
- velocityContext.put("cellT", cellT);
|
|
|
- velocityContext.put("ws", ws);
|
|
|
- velocityContext.put("wd", wd);
|
|
|
- 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"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E71.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的气象站,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("地调气象站文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("地调气象站上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成地调测风塔上报文件
|
|
|
- */
|
|
|
- private void generateE72File(Date date) {
|
|
|
- // 获取测风塔模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/CFT_DD.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("测风塔文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E72", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E72")) {
|
|
|
- // 获取测风塔信息
|
|
|
- List<WindTowerInfo> windTowerInfoList = windTowerInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WindTowerInfo> filterWindTowerInfoList = windTowerInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!filterWindTowerInfoList.isEmpty()) {
|
|
|
- Integer uploadWindTowerId = filterWindTowerInfoList.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WindTowerStatusData> windTowerStatusDataList = windTowerStatusDataRepository.findByEquipmentNoAndTimeBetween(uploadWindTowerId, new Date(startTime), new Date(endTime));
|
|
|
- // 数据格式化
|
|
|
- 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 ws70 = new BigDecimal(0);
|
|
|
- BigDecimal wd70 = 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);
|
|
|
-
|
|
|
- WindTowerStatusData windTowerStatusData = super.getWindTowerStatusData(uploadWindTowerId);
|
|
|
-
|
|
|
- if (windTowerStatusData == null) {
|
|
|
- // 没有测风塔数据用nwp数据补
|
|
|
- Long nwpTime;
|
|
|
- try {
|
|
|
- nwpTime = DateMomentUtil.getMomentTime(systemDate.getTime(), 1, 15 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("获取nwp时刻步长错误", e);
|
|
|
- nwpTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- List<Nwp> nwpList = nwpRepository.findByPreTimeBetween(nwpTime, nwpTime);
|
|
|
-
|
|
|
- if (nwpList.size() > 0) {
|
|
|
- Nwp nwpData = nwpList.get(0);
|
|
|
- ws10 = nwpData.getWs10();
|
|
|
- wd10 = nwpData.getWd10();
|
|
|
- ws30 = nwpData.getWs30();
|
|
|
- wd30 = nwpData.getWd30();
|
|
|
- ws50 = nwpData.getWs50();
|
|
|
- wd50 = nwpData.getWd50();
|
|
|
- ws70 = nwpData.getWs70();
|
|
|
- wd70 = nwpData.getWd70();
|
|
|
- wsHubHeight = nwpData.getWs70();
|
|
|
- wdHubHeight = nwpData.getWd70();
|
|
|
- rh8 = nwpData.getRh();
|
|
|
- t8 = nwpData.getT();
|
|
|
- p8 = nwpData.getPressure();
|
|
|
- }
|
|
|
- // 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);
|
|
|
- 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();
|
|
|
- wd10 = windTowerStatusData.getWdInst10();
|
|
|
- ws30 = windTowerStatusData.getWsInst30();
|
|
|
- wd30 = windTowerStatusData.getWdInst30();
|
|
|
- ws50 = windTowerStatusData.getWsInst50();
|
|
|
- wd50 = windTowerStatusData.getWdInst50();
|
|
|
- ws70 = windTowerStatusData.getWsInst70();
|
|
|
- wd70 = windTowerStatusData.getWdInst70();
|
|
|
- wsHubHeight = windTowerStatusData.getWsInstHubHeight();
|
|
|
- wdHubHeight = windTowerStatusData.getWdInstHubHeight();
|
|
|
- t8 = windTowerStatusData.getTInst();
|
|
|
- p8 = windTowerStatusData.getPaInst();
|
|
|
- rh8 = windTowerStatusData.getRhInst();
|
|
|
-
|
|
|
- }
|
|
|
- String sign = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- sign = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- sign = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("sign", sign);
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("WS_10", ws10);
|
|
|
- velocityContext.put("WD_10", wd10);
|
|
|
- velocityContext.put("WS_30", ws30);
|
|
|
- velocityContext.put("WD_30", wd30);
|
|
|
- velocityContext.put("WS_50", ws50);
|
|
|
- velocityContext.put("WD_50", wd50);
|
|
|
- velocityContext.put("WS_70", ws70);
|
|
|
- velocityContext.put("WD_70", wd70);
|
|
|
- velocityContext.put("WS_HubHeight", wsHubHeight);
|
|
|
- velocityContext.put("WD_HubHeight", wdHubHeight);
|
|
|
- velocityContext.put("T_8", t8);
|
|
|
- velocityContext.put("P_8", p8);
|
|
|
- velocityContext.put("RH_8", rh8);
|
|
|
-
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E72.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的测风塔,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("地调测风塔文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("地调测风塔上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成地调风场单机上报文件。
|
|
|
- */
|
|
|
- private void generateE73File(Date date) {
|
|
|
- // 获取单机模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DJ_DD.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("单机文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E73", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E73")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- if (electricFieldInfo.getElectricFieldTypeEnum().toString().equals("E1")) {
|
|
|
- List<InverterInfo> inverterInfoList = inverterInfoService.getAll();
|
|
|
- // List<InverterStatusData> inverterStatusDataList = inverterStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- List<InverterInfo> filterInverterInfoList = inverterInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- for (InverterInfo inverterInfo : filterInverterInfoList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", inverterInfo.getName());
|
|
|
- BigDecimal galvanicCurrent = new BigDecimal("0");
|
|
|
- map.put("GalvanicCurrent", df.format(galvanicCurrent));
|
|
|
- BigDecimal voltage = new BigDecimal("0");
|
|
|
- map.put("Voltage", df.format(voltage));
|
|
|
- BigDecimal nbqActivePower = new BigDecimal("0");
|
|
|
- map.put("NbqActivePower", df.format(nbqActivePower));
|
|
|
- BigDecimal nbqReActivePower = new BigDecimal("0");
|
|
|
- map.put("NbqReActivePower", df.format(nbqReActivePower));
|
|
|
- map.put("status", "0");
|
|
|
- // List<InverterStatusData> filterInverterStatusDataList = inverterStatusDataList.stream().filter(w -> w.getEquipmentNo() == inverterInfo.getId()).collect(Collectors.toList());
|
|
|
- InverterStatusData inverterStatusData = super.getInverterStatusData(inverterInfo.getId());
|
|
|
- if (inverterStatusData != null) {
|
|
|
- // filterInverterStatusDataList.sort(Comparator.comparing(InverterStatusData::getTime).reversed());
|
|
|
- // InverterStatusData inverterStatusData = filterInverterStatusDataList.get(0);
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(inverterStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(inverterStatusData.getVoltage()));
|
|
|
- // 是否组串式逆变器
|
|
|
- map.put("groupSeries", inverterInfo.getGroupSeries() ? "1" : "0");
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(inverterStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(inverterStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", inverterStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 获取风机
|
|
|
- List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoRepository.findAllByOrderByIdAsc();
|
|
|
- // 获取风机数据
|
|
|
- // List<WindTurbineStatusData> fjStatusDataList = windTurbineStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的风机
|
|
|
- List<WindTurbineInfo> filterWindInfoList = windTurbineInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- String flag = "0.00";
|
|
|
- for (WindTurbineInfo windTurbineInfo : filterWindInfoList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- BigDecimal galvanicCurrent = new BigDecimal("0");
|
|
|
- map.put("GalvanicCurrent", df.format(galvanicCurrent));
|
|
|
- BigDecimal voltage = new BigDecimal("0");
|
|
|
- map.put("Voltage", df.format(voltage));
|
|
|
- BigDecimal ws = new BigDecimal("0");
|
|
|
- map.put("ws", df.format(ws));
|
|
|
- BigDecimal wd = new BigDecimal("0");
|
|
|
- map.put("wd", df.format(wd));
|
|
|
- BigDecimal nbqActivePower = new BigDecimal("0");
|
|
|
- map.put("NbqActivePower", df.format(nbqActivePower));
|
|
|
- BigDecimal nbqReActivePower = new BigDecimal("0");
|
|
|
- map.put("NbqReActivePower", df.format(nbqReActivePower));
|
|
|
- map.put("status", "0");
|
|
|
- // 根据风机找到对应的风机数据
|
|
|
- WindTurbineStatusData windTurbineStatusData = super.getWindTurbineStatusData(windTurbineInfo.getId());
|
|
|
- if (windTurbineStatusData != null) {
|
|
|
- // filterWindTurbineStatusDataList.sort(Comparator.comparing(WindTurbineStatusData::getTime).reversed());
|
|
|
- // WindTurbineStatusData windTurbineStatusData = filterWindTurbineStatusDataList.get(0);
|
|
|
- //接到风机运行状态的数据,不做处理,有功无功电压电流风速风向等真实接入 0:运行
|
|
|
- if (windTurbineStatusData.getStatus() == 0) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(windTurbineStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- //接到风机待机状态的数据,将有功置0,无功电压电流风速风向等真实接入 2:待机
|
|
|
- } else if (windTurbineStatusData.getStatus() == 2) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- //接到风机故障状态的数据,将有功、无功置0,其他数据真实接入 1:故障
|
|
|
- } else if (windTurbineStatusData.getStatus() == 1) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", flag);
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- } else {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", flag);
|
|
|
- // 电压
|
|
|
- map.put("Voltage", flag);
|
|
|
- // 风速
|
|
|
- map.put("ws", flag);
|
|
|
- // 风向d
|
|
|
- map.put("wd", flag);
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", flag);
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().toString());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E73.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("地调单机文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("地调单机上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成地调风场基础信息上报文件。
|
|
|
- */
|
|
|
- private void generateE74File(Date date) {
|
|
|
- // 获取风机基础信息模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/FJ_BASE.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("单机文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E74", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E74")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取风机
|
|
|
- List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoRepository.findAllByOrderByIdAsc();
|
|
|
- // 过滤上报的风机
|
|
|
- List<WindTurbineInfo> filterWindInfoList = windTurbineInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- Double cap = 0.00;
|
|
|
- for (WindTurbineInfo windTurbineInfo : filterWindInfoList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 额定功率
|
|
|
- map.put("maxPower", df.format(windTurbineInfo.getMaxPower() / 1000));
|
|
|
- // 型号
|
|
|
- map.put("modelNumber", windTurbineInfo.getModelNumber());
|
|
|
- // 经度
|
|
|
- map.put("longitude", windTurbineInfo.getLongitude() == null ? "无" : DDtoDMS(windTurbineInfo.getLongitude()));
|
|
|
- // 纬度
|
|
|
- map.put("latitude", windTurbineInfo.getLatitude() == null ? "无" : DDtoDMS(windTurbineInfo.getLatitude()));
|
|
|
- // 是否样板机
|
|
|
- map.put("sample", windTurbineInfo.getSample() ? "1" : "0");
|
|
|
- vList.add(map);
|
|
|
- cap = cap + windTurbineInfo.getMaxPower() / 1000;
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- velocityContext.put("capacity", df.format(cap));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E74.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("地调风机基础信息文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("地调风机基础信息上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成地调逆变器单机上报文件。
|
|
|
- */
|
|
|
- private void generateE75File(Date date) {
|
|
|
- // 获取逆变器单机模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NBQ_BASE.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("基础文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E75", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E75")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取风机
|
|
|
- List<InverterInfo> inverterInfoList = inverterInfoService.getAll();
|
|
|
- // 过滤上报的风机
|
|
|
- List<InverterInfo> filterInverterInfoList = inverterInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- Double cap = 0.00;
|
|
|
- for (InverterInfo inverterInfo : filterInverterInfoList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", inverterInfo.getName());
|
|
|
- // 额定功率
|
|
|
- map.put("capacity", df.format(inverterInfo.getCapacity()));
|
|
|
- // 型号
|
|
|
- map.put("modelNumber", inverterInfo.getModelNumber());
|
|
|
- // 经度
|
|
|
- map.put("longitude", electricFieldInfo.getLongitude() == null ? "无" : DDtoDMS(electricFieldInfo.getLongitude().doubleValue()));
|
|
|
- // 纬度
|
|
|
- map.put("latitude", electricFieldInfo.getLatitude() == null ? "无" : DDtoDMS(electricFieldInfo.getLatitude().doubleValue()));
|
|
|
- // 是否样板机
|
|
|
- map.put("sample", inverterInfo.getSample() ? "1" : "0");
|
|
|
- // 是否组串式
|
|
|
- map.put("groupSeries", inverterInfo.getGroupSeries() ? "1" : "0");
|
|
|
- vList.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E75.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("地调逆变器基础信息文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("地调逆变器基础信息上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成地调逆变器单机上报文件。
|
|
|
- */
|
|
|
- private void generateE92File(Date date) {
|
|
|
- // 获取逆变器单机模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NBQ_BASE_SD.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("基础文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E92", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E92")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取风机
|
|
|
- List<InverterInfo> inverterInfoList = inverterInfoService.getAll();
|
|
|
- // 过滤上报的风机
|
|
|
- List<InverterInfo> filterInverterInfoList = inverterInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- Double cap = 0.00;
|
|
|
- for (InverterInfo inverterInfo : filterInverterInfoList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", inverterInfo.getName());
|
|
|
- // 额定功率
|
|
|
- map.put("capacity", df.format(inverterInfo.getCapacity()));
|
|
|
- // 型号
|
|
|
- map.put("modelNumber", inverterInfo.getModelNumber());
|
|
|
- // 经度
|
|
|
- map.put("longitude", inverterInfo.getBackupB() == null ? "无" : DDtoDMS(Double.parseDouble(inverterInfo.getBackupB())));
|
|
|
- // 纬度
|
|
|
- map.put("latitude", inverterInfo.getBackupC() == null ? "无" : DDtoDMS(Double.parseDouble(inverterInfo.getBackupC())));
|
|
|
- // 是否样板机
|
|
|
- map.put("sample", inverterInfo.getSample() ? "1" : "0");
|
|
|
- // 是否组串式
|
|
|
- map.put("groupSeries", inverterInfo.getGroupSeries() ? "1" : "0");
|
|
|
- vList.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E92.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("省调逆变器基础信息文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("省调逆变器基础信息上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 黄冈地调短期
|
|
|
- */
|
|
|
- private void generateE93File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_DD_HG.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3");
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E93", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E93")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
-
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E93.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("黄冈地调短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("黄冈地调短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //黄冈地调超短期
|
|
|
- private void generateE94File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- File file1 = null;
|
|
|
- try {
|
|
|
- file1 = ResourceUtils.getFile(this.vmsPath + "/CDQ_DD_HG.vm");
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- Template template = this.velocityEngine.getTemplate(file1.getPath());
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16");
|
|
|
- // 获取提前几分钟生成超短期
|
|
|
- int cdqUpMin = super.getTranSysParameter("CDQ_UP_MIN", "0");
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = new Date(date.getTime() - cdqUpMin * 1000 * 60);
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- 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 = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E94", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E94")) {
|
|
|
- // 查询超短期预测功率
|
|
|
- List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerUltraShortTermList);
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(startTime, "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.E94.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("黄冈地调超短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("黄冈地调超短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成黄冈地调72NWP预测上报文件。
|
|
|
- */
|
|
|
- private void generateE95File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NWP72_DD_HG.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int fileNwpDays = super.getTranSysParameter("HUBEI_DD_NWP", "3");
|
|
|
- //获取nwp72轮毂高度
|
|
|
- int turbinH = super.getTranSysParameter("HB_NWP72_TURBINH", "80");
|
|
|
- try {
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, fileNwpDays).getTime()) - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E95", startTime);
|
|
|
- if (getFileName(fileName, "E95")) {
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- String efiLabel = "";
|
|
|
- // 查询NWP数据(风电第一个点从00:15开始)
|
|
|
- List<Nwp> nwpDataList = this.nwpService.getNwpData(startTime + 1000 * 60 * 15, endTime + 1000 * 60 * 15);
|
|
|
- // 按照预测时间进行升序
|
|
|
- nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- // 光伏
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("time", DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm"));
|
|
|
- map.put("swr", df.format(nwpDataList.get(i).getSwr()));
|
|
|
- map.put("directRadiation", df.format(NumberUtils.multiply(nwpDataList.get(i).getSwr(), new BigDecimal(0.7))));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
-
|
|
|
- String tempTime = "";
|
|
|
- if ("00:00".equals(DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "HH:mm"))) {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime() - 1000 * 60 * 60 * 24, "yyyy-MM-dd") + " 24:00";
|
|
|
- } else {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm");
|
|
|
- }
|
|
|
-
|
|
|
- map.put("time", tempTime);
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- map.put("ws30", df.format(nwpDataList.get(i).getWs30()));
|
|
|
- map.put("wd30", df.format(nwpDataList.get(i).getWd30()));
|
|
|
- map.put("ws100", df.format(nwpDataList.get(i).getWs100()));
|
|
|
- map.put("wd100", df.format(nwpDataList.get(i).getWd100()));
|
|
|
- map.put("ws170", df.format(nwpDataList.get(i).getWs170()));
|
|
|
- map.put("wd170", df.format(nwpDataList.get(i).getWd170()));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- // 场站经纬度
|
|
|
- velocityContext.put("longitude", electricFieldInfo.getLongitude());
|
|
|
- velocityContext.put("latitude", electricFieldInfo.getLatitude());
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- velocityContext.put("vList", list);
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().name());
|
|
|
- velocityContext.put("turbinH", turbinH);
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E95.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("黄冈地调72nwp文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("黄冈地调72nwp上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成气象站上报文件
|
|
|
- */
|
|
|
- private void generateE96File(Date date) {
|
|
|
- // 获取气象站模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/QXZ_DD_HG.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("气象站文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E96", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E96")) {
|
|
|
- // 获取气象站信息
|
|
|
- List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WeatherStationInfo> weatherStationInfos = weatherStationInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!weatherStationInfos.isEmpty()) {
|
|
|
- Integer uploadWeatherStationId = weatherStationInfos.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WeatherStationStatusData> weatherStationStatusDataList = weatherStationStatusDataRepository.findByTimeBetweenAndEquipmentNo(new Date(startTime), new Date(endTime), uploadWeatherStationId);
|
|
|
- // 数据格式化
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- BigDecimal globalR = new BigDecimal(0);
|
|
|
- BigDecimal directR = new BigDecimal(0);
|
|
|
- BigDecimal diffuseR = new BigDecimal(0);
|
|
|
- BigDecimal airT = new BigDecimal(0);
|
|
|
- BigDecimal p = new BigDecimal(0);
|
|
|
- BigDecimal rh = new BigDecimal(0);
|
|
|
- BigDecimal cellT = new BigDecimal(0);
|
|
|
- BigDecimal ws = new BigDecimal(0);
|
|
|
- BigDecimal wd = new BigDecimal(0);
|
|
|
-
|
|
|
- WeatherStationStatusData weatherStationStatusData = super.getWeatherStationStatusData(uploadWeatherStationId);
|
|
|
- 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 = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("GlobalR", globalR);
|
|
|
- velocityContext.put("DirectR", directR);
|
|
|
- velocityContext.put("DiffuseR", diffuseR);
|
|
|
- velocityContext.put("AirT", airT);
|
|
|
- velocityContext.put("P", p);
|
|
|
- velocityContext.put("RH", rh);
|
|
|
- velocityContext.put("CellT", cellT);
|
|
|
- velocityContext.put("WS", ws);
|
|
|
- velocityContext.put("WD", wd);
|
|
|
- velocityContext.put("time", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd"));
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- velocityContext.put("efiLabel", "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP");
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 系统当前日期
|
|
|
- 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"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E96.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的气象站,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("黄冈地调气象站文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("黄冈地调气象站上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成测风塔上报文件
|
|
|
- */
|
|
|
- private void generateE97File(Date date) {
|
|
|
- // 获取气象站模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/CFT_DD_HG.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("测风塔文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E97", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E97")) {
|
|
|
- // 获取测风塔信息
|
|
|
- List<WindTowerInfo> windTowerInfoList = windTowerInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WindTowerInfo> filterWindTowerInfoList = windTowerInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!filterWindTowerInfoList.isEmpty()) {
|
|
|
- Integer uploadWindTowerId = filterWindTowerInfoList.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WindTowerStatusData> windTowerStatusDataList = windTowerStatusDataRepository.findByEquipmentNoAndTimeBetween(uploadWindTowerId, new Date(startTime), new Date(endTime));
|
|
|
- // 数据格式化
|
|
|
- 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 ws70 = new BigDecimal(0);
|
|
|
- BigDecimal wd70 = 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);
|
|
|
-
|
|
|
- WindTowerStatusData windTowerStatusData = super.getWindTowerStatusData(uploadWindTowerId);
|
|
|
- if (windTowerStatusData == null) {
|
|
|
- // 没有测风塔数据用nwp数据补
|
|
|
- Long nwpTime;
|
|
|
- try {
|
|
|
- nwpTime = DateMomentUtil.getMomentTime(systemDate.getTime(), 1, 15 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("获取nwp时刻步长错误", e);
|
|
|
- nwpTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- List<Nwp> nwpList = nwpRepository.findByPreTimeBetween(nwpTime, nwpTime);
|
|
|
-
|
|
|
- if (nwpList.size() > 0) {
|
|
|
- Nwp nwpData = nwpList.get(0);
|
|
|
- ws10 = nwpData.getWs10();
|
|
|
- wd10 = nwpData.getWd10();
|
|
|
- ws30 = nwpData.getWs30();
|
|
|
- wd30 = nwpData.getWd30();
|
|
|
- ws50 = nwpData.getWs50();
|
|
|
- wd50 = nwpData.getWd50();
|
|
|
- ws70 = nwpData.getWs70();
|
|
|
- wd70 = nwpData.getWd70();
|
|
|
- wsHubHeight = nwpData.getWs70();
|
|
|
- wdHubHeight = nwpData.getWd70();
|
|
|
- rh8 = nwpData.getRh();
|
|
|
- t8 = nwpData.getT();
|
|
|
- p8 = nwpData.getPressure();
|
|
|
- }
|
|
|
- // 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);
|
|
|
- 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();
|
|
|
- wd10 = windTowerStatusData.getWdInst10();
|
|
|
- ws30 = windTowerStatusData.getWsInst30();
|
|
|
- wd30 = windTowerStatusData.getWdInst30();
|
|
|
- ws50 = windTowerStatusData.getWsInst50();
|
|
|
- wd50 = windTowerStatusData.getWdInst50();
|
|
|
- ws70 = windTowerStatusData.getWsInst70();
|
|
|
- wd70 = windTowerStatusData.getWdInst70();
|
|
|
- wsHubHeight = windTowerStatusData.getWsInstHubHeight();
|
|
|
- wdHubHeight = windTowerStatusData.getWdInstHubHeight();
|
|
|
- t8 = windTowerStatusData.getTInst();
|
|
|
- p8 = windTowerStatusData.getPaInst();
|
|
|
- rh8 = windTowerStatusData.getRhInst();
|
|
|
-
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("efiLabel", "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP");
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- velocityContext.put("WS_10", ws10);
|
|
|
- velocityContext.put("WD_10", wd10);
|
|
|
- velocityContext.put("WS_30", ws30);
|
|
|
- velocityContext.put("WD_30", wd30);
|
|
|
- velocityContext.put("WS_50", ws50);
|
|
|
- velocityContext.put("WD_50", wd50);
|
|
|
- velocityContext.put("WS_70", ws70);
|
|
|
- velocityContext.put("WD_70", wd70);
|
|
|
- velocityContext.put("WS_HubHeight", wsHubHeight);
|
|
|
- velocityContext.put("WD_HubHeight", wdHubHeight);
|
|
|
- velocityContext.put("T_8", t8);
|
|
|
- velocityContext.put("P_8", p8);
|
|
|
- velocityContext.put("RH_8", rh8);
|
|
|
-
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E97.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的测风塔,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("黄冈地调测风塔文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("黄冈地调测风塔上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成风场单机上报文件。
|
|
|
- */
|
|
|
- private void generateE98File(Date date) {
|
|
|
- // 获取单机模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/FJ_DD_HG.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("单机文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E98", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E98")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取风机
|
|
|
- List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoRepository.findAllByOrderByIdAsc();
|
|
|
- // 获取风机数据
|
|
|
- // List<WindTurbineStatusData> fjStatusDataList = windTurbineStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的风机
|
|
|
- List<WindTurbineInfo> filterWindInfoList = windTurbineInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- String flag = "0.00";
|
|
|
- for (WindTurbineInfo windTurbineInfo : filterWindInfoList) {
|
|
|
- // 根据风机找到对应的风机数据
|
|
|
- // List<WindTurbineStatusData> filterWindTurbineStatusDataList = fjStatusDataList.stream().filter(w -> w.getEquipmentNo() == windTurbineInfo.getId()).collect(Collectors.toList());
|
|
|
- WindTurbineStatusData windTurbineStatusData = super.getWindTurbineStatusData(windTurbineInfo.getId());
|
|
|
- if (windTurbineStatusData != null) {
|
|
|
- // filterWindTurbineStatusDataList.sort(Comparator.comparing(WindTurbineStatusData::getTime).reversed());
|
|
|
- // WindTurbineStatusData windTurbineStatusData = filterWindTurbineStatusDataList.get(0);
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- //接到风机运行状态的数据,不做处理,有功无功电压电流风速风向等真实接入
|
|
|
- if (windTurbineStatusData.getStatus() == 0) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(windTurbineStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- //接到风机待机状态的数据,将有功置0,无功电压电流风速风向等真实接入
|
|
|
- } else if (windTurbineStatusData.getStatus() == 2) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- //接到风机故障状态的数据,将有功、无功置0,其他数据真实接入
|
|
|
- } else if (windTurbineStatusData.getStatus() == 1) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", flag);
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- } else {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", flag);
|
|
|
- // 电压
|
|
|
- map.put("Voltage", flag);
|
|
|
- // 风速
|
|
|
- map.put("ws", flag);
|
|
|
- // 风向d
|
|
|
- map.put("wd", flag);
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", flag);
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E98.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("黄冈地调风机文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("黄冈地调风机上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成逆变器省调上报文件。
|
|
|
- * 文件名格式(ZJNCMS_20181204_1050_NBQ.PVD)
|
|
|
- */
|
|
|
- private void generateE99File(Date date) {
|
|
|
- // 获取基本信息模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NBQ_DD_HG.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("逆变器文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E99", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E99")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取逆变器
|
|
|
- List<InverterInfo> inverterInfos = inverterInfoService.getAll();
|
|
|
- // 获取逆变器遥测数据
|
|
|
- // List<InverterStatusData> inverterStatusDataList = inverterStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的逆变器
|
|
|
- List<InverterInfo> filterInverterInfoList = inverterInfos.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (filterInverterInfoList.size() > 0) {
|
|
|
- List<Map<String, String>> dtaInverterList = new ArrayList<>();
|
|
|
- for (InverterInfo inverterInfo : filterInverterInfoList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", inverterInfo.getName());
|
|
|
- map.put("groupSeries", inverterInfo.getGroupSeries() ? "1" : "0");
|
|
|
- // 过滤出逆变器对应的数据
|
|
|
- // List<InverterStatusData> filterInverterStatusData = inverterStatusDataList.stream().filter(w -> w.getEquipmentNo() == inverterInfo.getId()).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- InverterStatusData inverterStatusData = super.getInverterStatusData(inverterInfo.getId());
|
|
|
- if (inverterStatusData != null) {
|
|
|
- // InverterStatusData inverterStatusData = filterInverterStatusData.get(0);
|
|
|
- map.put("status", inverterStatusData.getStatus().toString());
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(inverterStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(inverterStatusData.getReactivePower()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(inverterStatusData.getVoltage()));
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(inverterStatusData.getElectricalCurrent()));
|
|
|
- } else {
|
|
|
- map.put("status", "3");
|
|
|
- map.put("NbqActivePower", "0");
|
|
|
- map.put("NbqReActivePower", "0");
|
|
|
- map.put("Voltage", "0");
|
|
|
- map.put("GalvanicCurrent", "0");
|
|
|
- }
|
|
|
- dtaInverterList.add(map);
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", dtaInverterList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- // 系统当前日期
|
|
|
- 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"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E99.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的逆变器,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("黄冈地调逆变器文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("黄冈地调逆变器上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 随州地调短期
|
|
|
- */
|
|
|
- private void generateE100File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_DD_SZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3");
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E100", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E100")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
-
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E100.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("随州地调短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("随州地调短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //随州地调超短期
|
|
|
- private void generateE101File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- File file1 = null;
|
|
|
- try {
|
|
|
- file1 = ResourceUtils.getFile(this.vmsPath + "/CDQ_DD_SZ.vm");
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- Template template = this.velocityEngine.getTemplate(file1.getPath());
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16");
|
|
|
- // 获取提前几分钟生成超短期
|
|
|
- int cdqUpMin = super.getTranSysParameter("CDQ_UP_MIN", "0");
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = new Date(date.getTime() - cdqUpMin * 1000 * 60);
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- 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 = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E101", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E101")) {
|
|
|
- // 查询超短期预测功率
|
|
|
- List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerUltraShortTermList);
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(startTime, "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.E101.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("随州地调超短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("随州地调超短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成随州地调72NWP预测上报文件。
|
|
|
- */
|
|
|
- private void generateE102File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NWP72_DD_SZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int fileNwpDays = super.getTranSysParameter("HUBEI_DD_NWP", "3");
|
|
|
- //获取nwp72轮毂高度
|
|
|
- int turbinH = super.getTranSysParameter("HB_NWP72_TURBINH", "80");
|
|
|
- try {
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, fileNwpDays).getTime()) - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E102", startTime);
|
|
|
- if (getFileName(fileName, "E102")) {
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- String efiLabel = "";
|
|
|
- // 查询NWP数据(风电第一个点从00:15开始)
|
|
|
- List<Nwp> nwpDataList = this.nwpService.getNwpData(startTime + 1000 * 60 * 15, endTime + 1000 * 60 * 15);
|
|
|
- // 按照预测时间进行升序
|
|
|
- nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- // 光伏
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("time", DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm"));
|
|
|
- map.put("swr", df.format(nwpDataList.get(i).getSwr()));
|
|
|
- map.put("directRadiation", df.format(NumberUtils.multiply(nwpDataList.get(i).getSwr(), new BigDecimal(0.7))));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
-
|
|
|
- String tempTime = "";
|
|
|
- if ("00:00".equals(DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "HH:mm"))) {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime() - 1000 * 60 * 60 * 24, "yyyy-MM-dd") + " 24:00";
|
|
|
- } else {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm");
|
|
|
- }
|
|
|
-
|
|
|
- map.put("time", tempTime);
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- map.put("ws30", df.format(nwpDataList.get(i).getWs30()));
|
|
|
- map.put("wd30", df.format(nwpDataList.get(i).getWd30()));
|
|
|
- map.put("ws100", df.format(nwpDataList.get(i).getWs100()));
|
|
|
- map.put("wd100", df.format(nwpDataList.get(i).getWd100()));
|
|
|
- map.put("ws170", df.format(nwpDataList.get(i).getWs170()));
|
|
|
- map.put("wd170", df.format(nwpDataList.get(i).getWd170()));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- // 场站经纬度
|
|
|
- velocityContext.put("longitude", electricFieldInfo.getLongitude());
|
|
|
- velocityContext.put("latitude", electricFieldInfo.getLatitude());
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- velocityContext.put("vList", list);
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().name());
|
|
|
- velocityContext.put("turbinH", turbinH);
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E102.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("随州地调72nwp文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("随州地调72nwp上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成随州地调气象站上报文件
|
|
|
- */
|
|
|
- private void generateE103File(Date date) {
|
|
|
- // 获取气象站模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/QXZ_DD_SZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("随州气象站文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E103", endTime + 1000 + 5 * 60 * 1000);
|
|
|
- if (getFileName(fileName, "E103")) {
|
|
|
- // 获取气象站信息
|
|
|
- List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WeatherStationInfo> weatherStationInfos = weatherStationInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!weatherStationInfos.isEmpty()) {
|
|
|
- Integer uploadWeatherStationId = weatherStationInfos.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WeatherStationStatusData> weatherStationStatusDataList = weatherStationStatusDataRepository.findByTimeBetweenAndEquipmentNo(new Date(startTime), new Date(endTime), uploadWeatherStationId);
|
|
|
- // 数据格式化
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- BigDecimal globalR = new BigDecimal(0);
|
|
|
- BigDecimal directR = new BigDecimal(0);
|
|
|
- BigDecimal diffuseR = new BigDecimal(0);
|
|
|
- BigDecimal airT = new BigDecimal(0);
|
|
|
- BigDecimal p = new BigDecimal(0);
|
|
|
- BigDecimal rh = new BigDecimal(0);
|
|
|
- BigDecimal cellT = new BigDecimal(0);
|
|
|
- BigDecimal ws = new BigDecimal(0);
|
|
|
- BigDecimal wd = new BigDecimal(0);
|
|
|
-
|
|
|
- WeatherStationStatusData weatherStationStatusData = super.getWeatherStationStatusData(uploadWeatherStationId);
|
|
|
- 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 = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("GlobalR", globalR);
|
|
|
- velocityContext.put("DirectR", directR);
|
|
|
- velocityContext.put("DiffuseR", diffuseR);
|
|
|
- velocityContext.put("AirT", airT);
|
|
|
- velocityContext.put("P", p);
|
|
|
- velocityContext.put("RH", rh);
|
|
|
- velocityContext.put("CellT", cellT);
|
|
|
- velocityContext.put("WS", ws);
|
|
|
- velocityContext.put("WD", wd);
|
|
|
- velocityContext.put("time", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd"));
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- velocityContext.put("efiLabel", "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP");
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000 + 5 * 60 * 1000, "yyyy-MM-dd_HH:mm") + ":00");
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000 + 5 * 60 * 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E103.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的气象站,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("随州地调气象站文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("随州地调气象站上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成随州逆变器省调上报文件。
|
|
|
- * 文件名格式(ZJNCMS_20181204_1050_NBQ.PVD)
|
|
|
- */
|
|
|
- private void generateE104File(Date date) {
|
|
|
- // 获取基本信息模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NBQ_DD_SZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("随州逆变器文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E104", endTime + 1000 + 5 * 60 * 1000);
|
|
|
- if (getFileName(fileName, "E104")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取逆变器
|
|
|
- List<InverterInfo> inverterInfos = inverterInfoService.getAll();
|
|
|
- // 获取逆变器遥测数据
|
|
|
- // List<InverterStatusData> inverterStatusDataList = inverterStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的逆变器
|
|
|
- List<InverterInfo> filterInverterInfoList = inverterInfos.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (filterInverterInfoList.size() > 0) {
|
|
|
- List<Map<String, String>> dtaInverterList = new ArrayList<>();
|
|
|
- for (InverterInfo inverterInfo : filterInverterInfoList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", inverterInfo.getName());
|
|
|
- map.put("groupSeries", inverterInfo.getGroupSeries() ? "1" : "0");
|
|
|
- // 过滤出逆变器对应的数据
|
|
|
- // List<InverterStatusData> filterInverterStatusData = inverterStatusDataList.stream().filter(w -> w.getEquipmentNo() == inverterInfo.getId()).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- InverterStatusData inverterStatusData = super.getInverterStatusData(inverterInfo.getId());
|
|
|
- if (inverterStatusData != null) {
|
|
|
-
|
|
|
- map.put("status", inverterStatusData.getStatus().toString());
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(inverterStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(inverterStatusData.getReactivePower()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(inverterStatusData.getVoltage()));
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(inverterStatusData.getElectricalCurrent()));
|
|
|
- } else {
|
|
|
- map.put("status", "3");
|
|
|
- map.put("NbqActivePower", "0");
|
|
|
- map.put("NbqReActivePower", "0");
|
|
|
- map.put("Voltage", "0");
|
|
|
- map.put("GalvanicCurrent", "0");
|
|
|
- }
|
|
|
- dtaInverterList.add(map);
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", dtaInverterList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000 + 5 * 60 * 1000, "yyyy-MM-dd_HH:mm") + ":00");
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000 + 5 * 60 * 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E104.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的逆变器,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("随州逆变器文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("随州逆变器上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成随州地调测风塔上报文件
|
|
|
- */
|
|
|
- private void generateE120File(Date date) {
|
|
|
- // 获取气象站模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/CFT_DD_SZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("孝感测风塔文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E120", endTime + 1000 + 5 * 60 * 1000);
|
|
|
- if (getFileName(fileName, "E120")) {
|
|
|
- // 获取气象站信息
|
|
|
- List<WindTowerInfo> windTowerInfoList = windTowerInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WindTowerInfo> windTowerInfos = windTowerInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!windTowerInfos.isEmpty()) {
|
|
|
- Integer uploadWindTowerId = windTowerInfos.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WeatherStationStatusData> weatherStationStatusDataList = weatherStationStatusDataRepository.findByTimeBetweenAndEquipmentNo(new Date(startTime), new Date(endTime), uploadWeatherStationId);
|
|
|
- // 数据格式化
|
|
|
- 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 ws70 = new BigDecimal(0);
|
|
|
- BigDecimal wd70 = new BigDecimal(0);
|
|
|
- BigDecimal wsHubHeight = new BigDecimal(0);
|
|
|
- BigDecimal wdHubHeight = new BigDecimal(0);
|
|
|
- BigDecimal t = new BigDecimal(0);
|
|
|
- BigDecimal p = new BigDecimal(0);
|
|
|
- BigDecimal h = new BigDecimal(0);
|
|
|
-
|
|
|
- WindTowerStatusData windTowerStatusData = super.getWindTowerStatusData(uploadWindTowerId);
|
|
|
- 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);
|
|
|
- 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));
|
|
|
- h = h.add(rhRandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- // 温度产生20-35随机数
|
|
|
- BigDecimal tRandomValue = new BigDecimal(df.format(Math.random() * 15 + 20));
|
|
|
- t = t.add(rhRandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- // 气压产生75-90随机数
|
|
|
- BigDecimal paRandomValue = new BigDecimal(df.format(Math.random() * 15 + 75));
|
|
|
- p = p.add(paRandomValue).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- } else {
|
|
|
-
|
|
|
- ws10 = windTowerStatusData.getWsAve10();
|
|
|
- wd10 = windTowerStatusData.getWdAve10();
|
|
|
- ws30 = windTowerStatusData.getWsAve30();
|
|
|
- wd30 = windTowerStatusData.getWdAve30();
|
|
|
- ws50 = windTowerStatusData.getWsAve50();
|
|
|
- wd50 = windTowerStatusData.getWdAve50();
|
|
|
- ws70 = windTowerStatusData.getWsAve70();
|
|
|
- wd70 = windTowerStatusData.getWdAve70();
|
|
|
- wsHubHeight = windTowerStatusData.getWsAveHubHeight();
|
|
|
- wdHubHeight = windTowerStatusData.getWdAveHubHeight();
|
|
|
- t = windTowerStatusData.getTAve();
|
|
|
- p = windTowerStatusData.getPaAve();
|
|
|
- h = windTowerStatusData.getRhAve();
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("ws10", ws10);
|
|
|
- velocityContext.put("wd10", wd10);
|
|
|
- velocityContext.put("ws30", ws30);
|
|
|
- velocityContext.put("wd30", wd30);
|
|
|
- velocityContext.put("ws50", ws50);
|
|
|
- velocityContext.put("wd50", wd50);
|
|
|
- velocityContext.put("ws70", ws70);
|
|
|
- velocityContext.put("wd70", wd70);
|
|
|
- velocityContext.put("wsHubHeight", wsHubHeight);
|
|
|
- velocityContext.put("wdHubHeight", wdHubHeight);
|
|
|
- velocityContext.put("t", t);
|
|
|
- velocityContext.put("p", p);
|
|
|
- velocityContext.put("h", h);
|
|
|
- velocityContext.put("time", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd"));
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- velocityContext.put("efiLabel", "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP");
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000 + 10 * 60 * 1000, "yyyy-MM-dd_HH:mm") + ":00");
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000 + 10 * 60 * 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E120.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的测风塔,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("孝感地调测风塔文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("孝感地调测风塔上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成孝感风机省调上报文件。
|
|
|
- * 文件名格式(ZJNCMS_20181204_1050_NBQ.PVD)
|
|
|
- */
|
|
|
- private void generateE121File(Date date) {
|
|
|
- // 获取单机模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/FJ_DD_HG.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("单机文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E121", endTime + 1000 + 5 * 60 * 1000L);
|
|
|
- if (getFileName(fileName, "E121")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取风机
|
|
|
- List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoRepository.findAllByOrderByIdAsc();
|
|
|
- // 获取风机数据
|
|
|
- // List<WindTurbineStatusData> fjStatusDataList = windTurbineStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的风机
|
|
|
- List<WindTurbineInfo> filterWindInfoList = windTurbineInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- for (WindTurbineInfo windTurbineInfo : filterWindInfoList) {
|
|
|
- // 根据风机找到对应的风机数据
|
|
|
- // List<WindTurbineStatusData> filterWindTurbineStatusDataList = fjStatusDataList.stream().filter(w -> w.getEquipmentNo() == windTurbineInfo.getId()).collect(Collectors.toList());
|
|
|
- WindTurbineStatusData windTurbineStatusData = super.getWindTurbineStatusData(windTurbineInfo.getId());
|
|
|
- if (windTurbineStatusData != null) {
|
|
|
- // filterWindTurbineStatusDataList.sort(Comparator.comparing(WindTurbineStatusData::getTime).reversed());
|
|
|
- // WindTurbineStatusData windTurbineStatusData = filterWindTurbineStatusDataList.get(0);
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- //接到风机运行状态的数据,不做处理,有功无功电压电流风速风向等真实接入
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", windTurbineStatusData.getElectricalCurrent().compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", windTurbineStatusData.getVoltage().compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", windTurbineStatusData.getWs().compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", windTurbineStatusData.getWd().compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", windTurbineStatusData.getActivePower().compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(windTurbineStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", windTurbineStatusData.getReactivePower().compareTo(new BigDecimal(-99)) == 0 ? "0.00" : df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E121.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("孝感风机文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("孝感风机上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 孝感地调短期
|
|
|
- */
|
|
|
- private void generateE141File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_DD_SZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3");
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E141", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E141")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
-
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E141.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("孝感地调短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("孝感地调短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //孝感地调超短期
|
|
|
- private void generateE142File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- File file1 = null;
|
|
|
- try {
|
|
|
- file1 = ResourceUtils.getFile(this.vmsPath + "/CDQ_DD_SZ.vm");
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- Template template = this.velocityEngine.getTemplate(file1.getPath());
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16");
|
|
|
- // 获取提前几分钟生成超短期
|
|
|
- int cdqUpMin = 30;
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- 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 = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E142", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E142")) {
|
|
|
- // 查询超短期预测功率
|
|
|
- List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerUltraShortTermList);
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(startTime, "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.E142.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("孝感地调超短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("孝感地调超短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成孝感地调72NWP预测上报文件。
|
|
|
- */
|
|
|
- private void generateE143File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NWP72_DD_SZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int fileNwpDays = super.getTranSysParameter("HUBEI_DD_NWP", "3");
|
|
|
- //获取nwp72轮毂高度
|
|
|
- int turbinH = super.getTranSysParameter("HB_NWP72_TURBINH", "80");
|
|
|
- try {
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, fileNwpDays).getTime()) - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E143", startTime);
|
|
|
- if (getFileName(fileName, "E143")) {
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- String efiLabel = "";
|
|
|
- // 查询NWP数据(风电第一个点从00:15开始)
|
|
|
- List<Nwp> nwpDataList = this.nwpService.getNwpData(startTime + 1000 * 60 * 15, endTime + 1000 * 60 * 15);
|
|
|
- // 按照预测时间进行升序
|
|
|
- nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- // 光伏
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("time", DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm"));
|
|
|
- map.put("swr", df.format(nwpDataList.get(i).getSwr()));
|
|
|
- map.put("directRadiation", df.format(NumberUtils.multiply(nwpDataList.get(i).getSwr(), new BigDecimal(0.7))));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
-
|
|
|
- String tempTime = "";
|
|
|
- if ("00:00".equals(DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "HH:mm"))) {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime() - 1000 * 60 * 60 * 24, "yyyy-MM-dd") + " 24:00";
|
|
|
- } else {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm");
|
|
|
- }
|
|
|
-
|
|
|
- map.put("time", tempTime);
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- map.put("ws30", df.format(nwpDataList.get(i).getWs30()));
|
|
|
- map.put("wd30", df.format(nwpDataList.get(i).getWd30()));
|
|
|
- map.put("ws100", df.format(nwpDataList.get(i).getWs100()));
|
|
|
- map.put("wd100", df.format(nwpDataList.get(i).getWd100()));
|
|
|
- map.put("ws170", df.format(nwpDataList.get(i).getWs170()));
|
|
|
- map.put("wd170", df.format(nwpDataList.get(i).getWd170()));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- // 场站经纬度
|
|
|
- velocityContext.put("longitude", electricFieldInfo.getLongitude());
|
|
|
- velocityContext.put("latitude", electricFieldInfo.getLatitude());
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- velocityContext.put("vList", list);
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().name());
|
|
|
- velocityContext.put("turbinH", turbinH);
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E143.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("孝感地调72nwp文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("孝感地调72nwp上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成孝感地调气象站上报文件
|
|
|
- */
|
|
|
- private void generateE234File(Date date) {
|
|
|
- // 获取气象站模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/QXZ_DD_SZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("随州气象站文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E234", endTime + 1000 + 5 * 60 * 1000);
|
|
|
- if (getFileName(fileName, "E234")) {
|
|
|
- // 获取气象站信息
|
|
|
- List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WeatherStationInfo> weatherStationInfos = weatherStationInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!weatherStationInfos.isEmpty()) {
|
|
|
- Integer uploadWeatherStationId = weatherStationInfos.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WeatherStationStatusData> weatherStationStatusDataList = weatherStationStatusDataRepository.findByTimeBetweenAndEquipmentNo(new Date(startTime), new Date(endTime), uploadWeatherStationId);
|
|
|
- // 数据格式化
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- BigDecimal globalR = new BigDecimal(0);
|
|
|
- BigDecimal directR = new BigDecimal(0);
|
|
|
- BigDecimal diffuseR = new BigDecimal(0);
|
|
|
- BigDecimal airT = new BigDecimal(0);
|
|
|
- BigDecimal p = new BigDecimal(0);
|
|
|
- BigDecimal rh = new BigDecimal(0);
|
|
|
- BigDecimal cellT = new BigDecimal(0);
|
|
|
- BigDecimal ws = new BigDecimal(0);
|
|
|
- BigDecimal wd = new BigDecimal(0);
|
|
|
-
|
|
|
- WeatherStationStatusData weatherStationStatusData = super.getWeatherStationStatusData(uploadWeatherStationId);
|
|
|
- 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 = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("GlobalR", globalR);
|
|
|
- velocityContext.put("DirectR", directR);
|
|
|
- velocityContext.put("DiffuseR", diffuseR);
|
|
|
- velocityContext.put("AirT", airT);
|
|
|
- velocityContext.put("P", p);
|
|
|
- velocityContext.put("RH", rh);
|
|
|
- velocityContext.put("CellT", cellT);
|
|
|
- velocityContext.put("WS", ws);
|
|
|
- velocityContext.put("WD", wd);
|
|
|
- velocityContext.put("time", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd"));
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- velocityContext.put("efiLabel", "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP");
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000 + 5 * 60 * 1000, "yyyy-MM-dd_HH:mm") + ":00");
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000 + 5 * 60 * 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E234.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的气象站,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("孝感地调气象站文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("孝感地调气象站上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成孝感逆变器省调上报文件。
|
|
|
- * 文件名格式(ZJNCMS_20181204_1050_NBQ.PVD)
|
|
|
- */
|
|
|
- private void generateE235File(Date date) {
|
|
|
- // 获取基本信息模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NBQ_DD_SZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("随州逆变器文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E235", endTime + 1000 + 5 * 60 * 1000);
|
|
|
- if (getFileName(fileName, "E235")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取逆变器
|
|
|
- List<InverterInfo> inverterInfos = inverterInfoService.getAll();
|
|
|
- // 获取逆变器遥测数据
|
|
|
- // List<InverterStatusData> inverterStatusDataList = inverterStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的逆变器
|
|
|
- List<InverterInfo> filterInverterInfoList = inverterInfos.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (filterInverterInfoList.size() > 0) {
|
|
|
- List<Map<String, String>> dtaInverterList = new ArrayList<>();
|
|
|
- for (InverterInfo inverterInfo : filterInverterInfoList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", inverterInfo.getName());
|
|
|
- map.put("groupSeries", inverterInfo.getGroupSeries() ? "1" : "0");
|
|
|
- // 过滤出逆变器对应的数据
|
|
|
- // List<InverterStatusData> filterInverterStatusData = inverterStatusDataList.stream().filter(w -> w.getEquipmentNo() == inverterInfo.getId()).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- InverterStatusData inverterStatusData = super.getInverterStatusData(inverterInfo.getId());
|
|
|
- if (inverterStatusData != null) {
|
|
|
-
|
|
|
- map.put("status", inverterStatusData.getStatus().toString());
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(inverterStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(inverterStatusData.getReactivePower()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(inverterStatusData.getVoltage()));
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(inverterStatusData.getElectricalCurrent()));
|
|
|
- } else {
|
|
|
- map.put("status", "3");
|
|
|
- map.put("NbqActivePower", "0");
|
|
|
- map.put("NbqReActivePower", "0");
|
|
|
- map.put("Voltage", "0");
|
|
|
- map.put("GalvanicCurrent", "0");
|
|
|
- }
|
|
|
- dtaInverterList.add(map);
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", dtaInverterList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000 + 5 * 60 * 1000, "yyyy-MM-dd_HH:mm") + ":00");
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000 + 5 * 60 * 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E235.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的逆变器,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("孝感逆变器文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("孝感逆变器上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 咸宁地调短期
|
|
|
- */
|
|
|
- private void generateE174File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_DD_XN.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3");
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E174", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E174")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
-
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E174.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("咸宁地调短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("咸宁地调短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //咸宁地调超短期
|
|
|
- private void generateE175File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- File file1 = null;
|
|
|
- try {
|
|
|
- file1 = ResourceUtils.getFile(this.vmsPath + "/CDQ_DD_XN.vm");
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- Template template = this.velocityEngine.getTemplate(file1.getPath());
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16");
|
|
|
- // 获取提前几分钟生成超短期
|
|
|
- int cdqUpMin = super.getTranSysParameter("CDQ_UP_MIN", "0");
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = new Date(date.getTime() - cdqUpMin * 1000 * 60);
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- 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 = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E175", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E175")) {
|
|
|
- // 查询超短期预测功率
|
|
|
- List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerUltraShortTermList);
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(startTime, "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.E175.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("咸宁地调超短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("咸宁地调超短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成孝感地调72NWP预测上报文件。
|
|
|
- */
|
|
|
- private void generateE178File(Date date) {
|
|
|
- // 获取nwp模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NWP72_DD_XN.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int fileNwpDays = super.getTranSysParameter("HUBEI_DD_NWP", "3");
|
|
|
- //获取nwp72轮毂高度
|
|
|
- int turbinH = super.getTranSysParameter("HB_NWP72_TURBINH", "80");
|
|
|
- try {
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, fileNwpDays).getTime()) - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E178", startTime);
|
|
|
- if (getFileName(fileName, "E178")) {
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- String efiLabel = "";
|
|
|
- // 查询NWP数据(风电第一个点从00:15开始)
|
|
|
- List<Nwp> nwpDataList = this.nwpService.getNwpData(startTime + 1000 * 60 * 15, endTime + 1000 * 60 * 15);
|
|
|
- // 按照预测时间进行升序
|
|
|
- nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- // 光伏
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("time", DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm"));
|
|
|
- map.put("swr", df.format(nwpDataList.get(i).getSwr()));
|
|
|
- map.put("directRadiation", df.format(NumberUtils.multiply(nwpDataList.get(i).getSwr(), new BigDecimal(0.7))));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".guangfuP";
|
|
|
- } else {
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
-
|
|
|
- String tempTime = "";
|
|
|
- if ("00:00".equals(DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "HH:mm"))) {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime() - 1000 * 60 * 60 * 24, "yyyy-MM-dd") + " 24:00";
|
|
|
- } else {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm");
|
|
|
- }
|
|
|
-
|
|
|
- map.put("time", tempTime);
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- map.put("ws30", df.format(nwpDataList.get(i).getWs30()));
|
|
|
- map.put("wd30", df.format(nwpDataList.get(i).getWd30()));
|
|
|
- map.put("ws100", df.format(nwpDataList.get(i).getWs100()));
|
|
|
- map.put("wd100", df.format(nwpDataList.get(i).getWd100()));
|
|
|
- map.put("ws170", df.format(nwpDataList.get(i).getWs170()));
|
|
|
- map.put("wd170", df.format(nwpDataList.get(i).getWd170()));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getNetSubstationName() + ".fengdianP";
|
|
|
- // 场站经纬度
|
|
|
- velocityContext.put("longitude", electricFieldInfo.getLongitude());
|
|
|
- velocityContext.put("latitude", electricFieldInfo.getLatitude());
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- velocityContext.put("vList", list);
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().name());
|
|
|
- velocityContext.put("turbinH", turbinH);
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E178.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("咸宁地调72nwp文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("咸宁地调72nwp上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成咸宁地调气象站上报文件
|
|
|
- */
|
|
|
- private void generateE176File(Date date) {
|
|
|
- // 获取气象站模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/QXZ_DD_XN.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("咸宁气象站文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E176", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E176")) {
|
|
|
- // 获取气象站信息
|
|
|
- List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WeatherStationInfo> weatherStationInfos = weatherStationInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!weatherStationInfos.isEmpty()) {
|
|
|
- Integer uploadWeatherStationId = weatherStationInfos.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WeatherStationStatusData> weatherStationStatusDataList = weatherStationStatusDataRepository.findByTimeBetweenAndEquipmentNo(new Date(startTime), new Date(endTime), uploadWeatherStationId);
|
|
|
- // 数据格式化
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- BigDecimal globalR = new BigDecimal(0);
|
|
|
- BigDecimal directR = new BigDecimal(0);
|
|
|
- BigDecimal diffuseR = new BigDecimal(0);
|
|
|
- BigDecimal airT = new BigDecimal(0);
|
|
|
- BigDecimal p = new BigDecimal(0);
|
|
|
- BigDecimal rh = new BigDecimal(0);
|
|
|
- BigDecimal cellT = new BigDecimal(0);
|
|
|
- BigDecimal ws = new BigDecimal(0);
|
|
|
- BigDecimal wd = new BigDecimal(0);
|
|
|
-
|
|
|
- WeatherStationStatusData weatherStationStatusData = super.getWeatherStationStatusData(uploadWeatherStationId);
|
|
|
- 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 = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("GlobalR", globalR);
|
|
|
- velocityContext.put("DirectR", directR);
|
|
|
- velocityContext.put("DiffuseR", diffuseR);
|
|
|
- velocityContext.put("AirT", airT);
|
|
|
- velocityContext.put("P", p);
|
|
|
- velocityContext.put("RH", rh);
|
|
|
- velocityContext.put("CellT", cellT);
|
|
|
- velocityContext.put("WS", ws);
|
|
|
- velocityContext.put("WD", wd);
|
|
|
- velocityContext.put("time", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd"));
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- velocityContext.put("efiLabel", "hubei." + weatherStationInfos.get(0).getName() + ".guangfuP");
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000 + 10 * 60 * 1000, "yyyy-MM-dd_HH:mm") + ":00");
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000 + 10 * 60 * 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E176.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的气象站,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("咸宁地调气象站文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("咸宁地调气象站上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成湖北咸宁地调逆变器上报文件
|
|
|
- * 文件名格式(XNLFGF_NBQ_20211229_1635.WPD)
|
|
|
- */
|
|
|
- public void generateE177File(Date date) {
|
|
|
- // 获取基本信息模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NBQ_DD_XN.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("逆变器文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E177", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E177")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取逆变器
|
|
|
- List<InverterInfo> inverterInfos = inverterInfoService.getAll();
|
|
|
- // 获取逆变器遥测数据
|
|
|
- // List<InverterStatusData> inverterStatusDataList = inverterStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的逆变器
|
|
|
- List<InverterInfo> filterInverterInfoList = inverterInfos.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (filterInverterInfoList.size() > 0) {
|
|
|
- List<Map<String, String>> dtaInverterList = new ArrayList<>();
|
|
|
- for (InverterInfo inverterInfo : filterInverterInfoList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", inverterInfo.getName());
|
|
|
- map.put("groupSeries", inverterInfo.getGroupSeries() ? "1" : "0");
|
|
|
- // 过滤出逆变器对应的数据
|
|
|
- // List<InverterStatusData> filterInverterStatusData = inverterStatusDataList.stream().filter(w -> w.getEquipmentNo() == inverterInfo.getId()).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- InverterStatusData inverterStatusData = super.getInverterStatusData(inverterInfo.getId());
|
|
|
- if (inverterStatusData != null) {
|
|
|
- // InverterStatusData inverterStatusData = filterInverterStatusData.get(0);
|
|
|
- map.put("status", inverterStatusData.getStatus().toString());
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(inverterStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(inverterStatusData.getReactivePower()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(inverterStatusData.getVoltage()));
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(inverterStatusData.getElectricalCurrent()));
|
|
|
- } else {
|
|
|
- map.put("status", "3");
|
|
|
- map.put("NbqActivePower", "0");
|
|
|
- map.put("NbqReActivePower", "0");
|
|
|
- map.put("Voltage", "0");
|
|
|
- map.put("GalvanicCurrent", "0");
|
|
|
- }
|
|
|
- dtaInverterList.add(map);
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", dtaInverterList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- // 系统当前日期
|
|
|
- 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"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E177.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的逆变器,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("湖北咸宁地调逆变器文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("湖北咸宁地调逆变器上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成短期上午预测上报文件。
|
|
|
- */
|
|
|
- private void generateE179File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_SD.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- if (electricFieldInfo.getElectricFieldTypeEnum().getCode().toString().equals("1")) {
|
|
|
- template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_SD_G.vm");
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = 10;
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E179", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E179")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
- velocityContext.put("efiLabel", electricFieldInfo.getSign());
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E179.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("短期上午文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("短期上午上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成短期下午预测上报文件。
|
|
|
- */
|
|
|
- private void generateE180File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_SD.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- if (electricFieldInfo.getElectricFieldTypeEnum().getCode().toString().equals("1")) {
|
|
|
- template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_SD_G.vm");
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = 10;
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E180", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E180")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
- velocityContext.put("efiLabel", electricFieldInfo.getSign());
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E180.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("短期下午文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("短期下午上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成短期下午预测上报文件。
|
|
|
- */
|
|
|
- private void generateE181File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_SD.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- if (electricFieldInfo.getElectricFieldTypeEnum().getCode().toString().equals("1")) {
|
|
|
- template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_SD_G.vm");
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = 10;
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E181", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E181")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
- velocityContext.put("efiLabel", electricFieldInfo.getSign());
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E181.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("短期下午文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("短期下午上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成短期预测上报文件。
|
|
|
- */
|
|
|
- private void generateE182File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = 10;
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E182", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E182")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
-
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E182.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("湖北上午短期(老系统)文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("湖北上午短期(老系统)上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成短期预测上报文件。
|
|
|
- */
|
|
|
- private void generateE183File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = 10;
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E183", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E183")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
-
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E183.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("湖北下午短期(老系统)文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("湖北下午短期(老系统)上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成短期预测上报文件。
|
|
|
- */
|
|
|
- private void generateE184File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3");
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E184", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E184")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
-
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- }
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E184.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("湖北原短期下午(老系统)文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("湖北原短期下午(老系统)上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 湖北荆州地调短期
|
|
|
- */
|
|
|
- private void generateE185File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- //1月22日,桑国建提供风模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_DD_JZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- if (electricFieldInfo.getElectricFieldTypeEnum().getCode().toString().equals("1")) {
|
|
|
- template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_SD_G.vm");
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3");
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E185", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E185")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
- velocityContext.put("efiLabel", electricFieldInfo.getSign());
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E185.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("湖北荆州地调短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("湖北荆州地调短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 湖北荆州地调风机
|
|
|
- */
|
|
|
- private void generateE189File(Date date) {
|
|
|
- // 获取单机模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DJ_DD_JZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("湖北荆州地调风机文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E189", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E189")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取风机
|
|
|
- List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoRepository.findAllByOrderByIdAsc();
|
|
|
- // 获取风机数据
|
|
|
- // List<WindTurbineStatusData> fjStatusDataList = windTurbineStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的风机
|
|
|
- List<WindTurbineInfo> filterWindInfoList = windTurbineInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- filterWindInfoList.sort(Comparator.comparing(WindTurbineInfo::getId));
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- String name = "";
|
|
|
- String flag = "0.00";
|
|
|
- for (WindTurbineInfo windTurbineInfo : filterWindInfoList) {
|
|
|
- // 根据风机找到对应的风机数据
|
|
|
- // List<WindTurbineStatusData> filterWindTurbineStatusDataList = fjStatusDataList.stream().filter(w -> w.getEquipmentNo() == windTurbineInfo.getId()).collect(Collectors.toList());
|
|
|
- WindTurbineStatusData windTurbineStatusData = super.getWindTurbineStatusData(windTurbineInfo.getId());
|
|
|
- if (windTurbineStatusData != null) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- //接到风机运行状态的数据,不做处理,有功无功电压电流风速风向等真实接入
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(windTurbineStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
-
|
|
|
- vList.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().toString());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd") + "_00:00:00");
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E189.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("湖北荆州地调风机文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("湖北荆州地调风机上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 湖北荆州地调nwp
|
|
|
- */
|
|
|
- private void generateE187File(Date date) {
|
|
|
- // 获取72nwp模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NWP72_DD_JZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int fileNwpDays = super.getTranSysParameter("FILE_NWP_DAYS", "3");
|
|
|
-
|
|
|
- //获取nwp72轮毂高度
|
|
|
- int turbinH = super.getTranSysParameter("HB_NWP72_TURBINH", "80");
|
|
|
-
|
|
|
- try {
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, fileNwpDays).getTime()) - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E187", startTime);
|
|
|
- if (getFileName(fileName, "E187")) {
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- DecimalFormat dfs = new DecimalFormat("0.0000");
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- // 查询NWP数据
|
|
|
- List<Nwp> nwpDataList = this.nwpService.getNwpData(startTime, endTime);
|
|
|
- // 按照预测时间进行升序
|
|
|
- nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- // 光伏
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("time", DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy/MM/dd_HH:mm"));
|
|
|
- map.put("GlobalR", df.format(nwpDataList.get(i).getDirectRadiation().floatValue() + nwpDataList.get(i).getDiffuseRadiation().floatValue()));
|
|
|
- map.put("DirectR", df.format(nwpDataList.get(i).getDirectRadiation()));
|
|
|
- map.put("DiffuseR", df.format(nwpDataList.get(i).getDiffuseRadiation()));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("p", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- map.put("ws", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("time", DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd\tHH:mm"));
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- map.put("ws30", df.format(nwpDataList.get(i).getWs30()));
|
|
|
- map.put("wd30", df.format(nwpDataList.get(i).getWd30()));
|
|
|
- map.put("ws100", df.format(nwpDataList.get(i).getWs100()));
|
|
|
- map.put("wd100", df.format(nwpDataList.get(i).getWd100()));
|
|
|
- map.put("ws170", df.format(nwpDataList.get(i).getWs170()));
|
|
|
- map.put("wd170", df.format(nwpDataList.get(i).getWd170()));
|
|
|
- map.put("ws80", df.format(nwpDataList.get(i).getWs80()));
|
|
|
- map.put("wd80", df.format(nwpDataList.get(i).getWd80()));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- velocityContext.put("vList", list);
|
|
|
- velocityContext.put("sign", electricFieldInfo.getSign());
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().toString());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("E", dfs.format(electricFieldInfo.getLongitude()));
|
|
|
- velocityContext.put("N", dfs.format(electricFieldInfo.getLatitude()));
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("date", DateFormatUtils.format(systemDate, "yyyy-MM-dd"));
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E187.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("湖北荆州地调nwp文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("湖北荆州地调nwp上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 湖北荆州地调测风塔
|
|
|
- */
|
|
|
- private void generateE188File(Date date) {
|
|
|
- // 获取测风塔模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/CFT_DD_JZ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("湖北荆州地调测风塔文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E188", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E188")) {
|
|
|
- // 获取测风塔信息
|
|
|
- List<WindTowerInfo> windTowerInfoList = windTowerInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WindTowerInfo> filterWindTowerInfoList = windTowerInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!filterWindTowerInfoList.isEmpty()) {
|
|
|
- Integer uploadWindTowerId = filterWindTowerInfoList.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WindTowerStatusData> windTowerStatusDataList = windTowerStatusDataRepository.findByEquipmentNoAndTimeBetween(uploadWindTowerId, new Date(startTime), new Date(endTime));
|
|
|
- WindTowerStatusData windTowerStatusData = super.getWindTowerStatusData(uploadWindTowerId);
|
|
|
- // 数据格式化
|
|
|
- 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 ws70 = new BigDecimal(0);
|
|
|
- BigDecimal wd70 = 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) {
|
|
|
- // 没有测风塔数据用nwp数据补
|
|
|
- Long nwpTime;
|
|
|
- try {
|
|
|
- nwpTime = DateMomentUtil.getMomentTime(systemDate.getTime(), 1, 15 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("获取nwp时刻步长错误", e);
|
|
|
- nwpTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- List<Nwp> nwpList = nwpRepository.findByPreTimeBetween(nwpTime, nwpTime);
|
|
|
-
|
|
|
- if (nwpList.size() > 0) {
|
|
|
- Nwp nwpData = nwpList.get(0);
|
|
|
- ws10 = nwpData.getWs10();
|
|
|
- wd10 = nwpData.getWd10();
|
|
|
- ws30 = nwpData.getWs30();
|
|
|
- wd30 = nwpData.getWd30();
|
|
|
- ws50 = nwpData.getWs50();
|
|
|
- wd50 = nwpData.getWd50();
|
|
|
- ws70 = nwpData.getWs70();
|
|
|
- wd70 = nwpData.getWd70();
|
|
|
- wsHubHeight = nwpData.getWs70();
|
|
|
- wdHubHeight = nwpData.getWd70();
|
|
|
- rh8 = nwpData.getRh();
|
|
|
- t8 = nwpData.getT();
|
|
|
- p8 = nwpData.getPressure();
|
|
|
- }
|
|
|
- // 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);
|
|
|
- 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();
|
|
|
- wd10 = windTowerStatusData.getWdInst10();
|
|
|
- ws30 = windTowerStatusData.getWsInst30();
|
|
|
- wd30 = windTowerStatusData.getWdInst30();
|
|
|
- ws50 = windTowerStatusData.getWsInst50();
|
|
|
- wd50 = windTowerStatusData.getWdInst50();
|
|
|
- ws70 = windTowerStatusData.getWsInst70();
|
|
|
- wd70 = windTowerStatusData.getWdInst70();
|
|
|
- wsHubHeight = windTowerStatusData.getWsInstHubHeight();
|
|
|
- wdHubHeight = windTowerStatusData.getWdInstHubHeight();
|
|
|
- t8 = windTowerStatusData.getTInst();
|
|
|
- p8 = windTowerStatusData.getPaInst();
|
|
|
- rh8 = windTowerStatusData.getRhInst();
|
|
|
-
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("efiLabel", electricFieldInfo.getSign());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- velocityContext.put("WS_10", ws10);
|
|
|
- velocityContext.put("WD_10", wd10.divideAndRemainder(new BigDecimal(360))[1]);
|
|
|
- velocityContext.put("WS_30", ws30);
|
|
|
- velocityContext.put("WD_30", wd30.divideAndRemainder(new BigDecimal(360))[1]);
|
|
|
- velocityContext.put("WS_50", ws50);
|
|
|
- velocityContext.put("WD_50", wd50.divideAndRemainder(new BigDecimal(360))[1]);
|
|
|
- velocityContext.put("WS_70", ws70);
|
|
|
- velocityContext.put("WD_70", wd70.divideAndRemainder(new BigDecimal(360))[1]);
|
|
|
- velocityContext.put("WS_HubHeight", wsHubHeight);
|
|
|
- velocityContext.put("WD_HubHeight", wdHubHeight.divideAndRemainder(new BigDecimal(360))[1]);
|
|
|
- velocityContext.put("T_8", t8);
|
|
|
- velocityContext.put("P_8", p8);
|
|
|
- velocityContext.put("RH_8", rh8);
|
|
|
-
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E188.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的测风塔,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("湖北荆州地调测风塔文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("湖北荆州地调测风塔上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 湖北荆州地调超短期
|
|
|
- */
|
|
|
- private void generateE186File(Date date) {
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取超短期模板
|
|
|
- File file1 = null;
|
|
|
- try {
|
|
|
- file1 = ResourceUtils.getFile(this.vmsPath + "/CDQ_DD_JZ.vm");
|
|
|
- if (electricFieldInfo.getElectricFieldTypeEnum().getCode().toString().equals("1")) {
|
|
|
- file1 = ResourceUtils.getFile(this.vmsPath + "/CDQ_SD_G.vm");
|
|
|
- }
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- Template template = this.velocityEngine.getTemplate(file1.getPath());
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- // 短期默认天数
|
|
|
- int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16");
|
|
|
- // 获取提前几分钟生成超短期
|
|
|
- int cdqUpMin = super.getTranSysParameter("CDQ_UP_MIN", "0");
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = new Date(date.getTime() - cdqUpMin * 1000 * 60);
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- 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 = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E186", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E186")) {
|
|
|
- // 查询超短期预测功率
|
|
|
- List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerUltraShortTermList);
|
|
|
- velocityContext.put("efiLabel", electricFieldInfo.getSign());
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(startTime, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
-
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E186.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("湖北荆州地调超短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("湖北荆州地调超短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 宜昌地调超短期。
|
|
|
- */
|
|
|
- private void generateE226File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- File file1 = null;
|
|
|
- try {
|
|
|
- file1 = ResourceUtils.getFile(this.vmsPath + "/CDQ.vm");
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- Template template = this.velocityEngine.getTemplate(file1.getPath());
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int cdqPoint = super.getTranSysParameter("FILE_CDQ_POINT", "16");
|
|
|
- // 获取提前几分钟生成超短期
|
|
|
- int cdqUpMin = super.getTranSysParameter("CDQ_UP_MIN", "0");
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = new Date(date.getTime() - cdqUpMin * 1000 * 60);
|
|
|
- }
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- 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 = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E226", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E226")) {
|
|
|
- // 查询超短期预测功率
|
|
|
- List<ForecastPowerUltraShortTermHis> forecastPowerUltraShortTermList = this.forecastPowerUltraShortTermService.getForecastPowerUltraShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerUltraShortTermList);
|
|
|
-
|
|
|
- velocityContext.put("efiLabel", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(startTime, "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.E226.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("超短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("超短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 宜昌地调短期。
|
|
|
- */
|
|
|
- private void generateE225File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3");
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E225", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E225")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
-
|
|
|
-
|
|
|
- velocityContext.put("efiLabel", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E225.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("短期文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("短期上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 宜昌地调测风塔
|
|
|
- */
|
|
|
- private void generateE228File(Date date) {
|
|
|
- // 获取气象站模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/CFT.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("测风塔文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E228", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E228")) {
|
|
|
- // 获取测风塔信息
|
|
|
- List<WindTowerInfo> windTowerInfoList = windTowerInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WindTowerInfo> filterWindTowerInfoList = windTowerInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!filterWindTowerInfoList.isEmpty()) {
|
|
|
- Integer uploadWindTowerId = filterWindTowerInfoList.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WindTowerStatusData> windTowerStatusDataList = windTowerStatusDataRepository.findByEquipmentNoAndTimeBetween(uploadWindTowerId, new Date(startTime), new Date(endTime));
|
|
|
- // 数据格式化
|
|
|
- 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 ws70 = new BigDecimal(0);
|
|
|
- BigDecimal wd70 = 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);
|
|
|
-
|
|
|
- WindTowerStatusData windTowerStatusData = super.getWindTowerStatusData(uploadWindTowerId);
|
|
|
- if (windTowerStatusData == null) {
|
|
|
- // 没有测风塔数据用nwp数据补
|
|
|
- Long nwpTime;
|
|
|
- try {
|
|
|
- nwpTime = DateMomentUtil.getMomentTime(systemDate.getTime(), 1, 15 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("获取nwp时刻步长错误", e);
|
|
|
- nwpTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- List<Nwp> nwpList = nwpRepository.findByPreTimeBetween(nwpTime, nwpTime);
|
|
|
-
|
|
|
- if (nwpList.size() > 0) {
|
|
|
- Nwp nwpData = nwpList.get(0);
|
|
|
- ws10 = nwpData.getWs10();
|
|
|
- wd10 = nwpData.getWd10();
|
|
|
- ws30 = nwpData.getWs30();
|
|
|
- wd30 = nwpData.getWd30();
|
|
|
- ws50 = nwpData.getWs50();
|
|
|
- wd50 = nwpData.getWd50();
|
|
|
- ws70 = nwpData.getWs70();
|
|
|
- wd70 = nwpData.getWd70();
|
|
|
- wsHubHeight = nwpData.getWs70();
|
|
|
- wdHubHeight = nwpData.getWd70();
|
|
|
- rh8 = nwpData.getRh();
|
|
|
- t8 = nwpData.getT();
|
|
|
- p8 = nwpData.getPressure();
|
|
|
- }
|
|
|
- // 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);
|
|
|
- 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();
|
|
|
- wd10 = windTowerStatusData.getWdInst10();
|
|
|
- ws30 = windTowerStatusData.getWsInst30();
|
|
|
- wd30 = windTowerStatusData.getWdInst30();
|
|
|
- ws50 = windTowerStatusData.getWsInst50();
|
|
|
- wd50 = windTowerStatusData.getWdInst50();
|
|
|
- ws70 = windTowerStatusData.getWsInst70();
|
|
|
- wd70 = windTowerStatusData.getWdInst70();
|
|
|
- wsHubHeight = windTowerStatusData.getWsInstHubHeight();
|
|
|
- wdHubHeight = windTowerStatusData.getWdInstHubHeight();
|
|
|
- t8 = windTowerStatusData.getTInst();
|
|
|
- p8 = windTowerStatusData.getPaInst();
|
|
|
- rh8 = windTowerStatusData.getRhInst();
|
|
|
-
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("efiLabel",electricFieldInfo.getNetSubstationName());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- velocityContext.put("WS_10", ws10);
|
|
|
- velocityContext.put("WD_10", wd10);
|
|
|
- velocityContext.put("WS_30", ws30);
|
|
|
- velocityContext.put("WD_30", wd30);
|
|
|
- velocityContext.put("WS_50", ws50);
|
|
|
- velocityContext.put("WD_50", wd50);
|
|
|
- velocityContext.put("WS_70", ws70);
|
|
|
- velocityContext.put("WD_70", wd70);
|
|
|
- velocityContext.put("WS_HubHeight", wsHubHeight);
|
|
|
- velocityContext.put("WD_HubHeight", wdHubHeight);
|
|
|
- velocityContext.put("T_8", t8);
|
|
|
- velocityContext.put("P_8", p8);
|
|
|
- velocityContext.put("RH_8", rh8);
|
|
|
-
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E228.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的测风塔,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("测风塔上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 宜昌地调单机。
|
|
|
- */
|
|
|
- private void generateE229File(Date date) {
|
|
|
- // 获取单机模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DJ.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("单机文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E229", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E229")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取风机
|
|
|
- List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoRepository.findAllByOrderByIdAsc();
|
|
|
- // 获取风机数据
|
|
|
- // List<WindTurbineStatusData> fjStatusDataList = windTurbineStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的风机
|
|
|
- List<WindTurbineInfo> filterWindInfoList = windTurbineInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- String flag = "0.00";
|
|
|
- for (WindTurbineInfo windTurbineInfo : filterWindInfoList) {
|
|
|
- // 根据风机找到对应的风机数据
|
|
|
- // List<WindTurbineStatusData> filterWindTurbineStatusDataList = fjStatusDataList.stream().filter(w -> w.getEquipmentNo() == windTurbineInfo.getId()).collect(Collectors.toList());
|
|
|
- WindTurbineStatusData windTurbineStatusData = super.getWindTurbineStatusData(windTurbineInfo.getId());
|
|
|
- if (windTurbineStatusData != null) {
|
|
|
- // filterWindTurbineStatusDataList.sort(Comparator.comparing(WindTurbineStatusData::getTime).reversed());
|
|
|
- // WindTurbineStatusData windTurbineStatusData = filterWindTurbineStatusDataList.get(0);
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- //接到风机运行状态的数据,不做处理,有功无功电压电流风速风向等真实接入
|
|
|
- if (windTurbineStatusData.getStatus() == 0) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(windTurbineStatusData.getActivePower()));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- //接到风机待机状态的数据,将有功置0,无功电压电流风速风向等真实接入
|
|
|
- } else if (windTurbineStatusData.getStatus() == 2) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(windTurbineStatusData.getReactivePower()));
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- //接到风机故障状态的数据,将有功、无功置0,其他数据真实接入
|
|
|
- } else if (windTurbineStatusData.getStatus() == 1) {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(windTurbineStatusData.getElectricalCurrent()));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(windTurbineStatusData.getVoltage()));
|
|
|
- // 风速
|
|
|
- map.put("ws", df.format(windTurbineStatusData.getWs()));
|
|
|
- // 风向
|
|
|
- map.put("wd", df.format(windTurbineStatusData.getWd()));
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", flag);
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- } else {
|
|
|
- // 名称
|
|
|
- map.put("name", windTurbineInfo.getName());
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", flag);
|
|
|
- // 电压
|
|
|
- map.put("Voltage", flag);
|
|
|
- // 风速
|
|
|
- map.put("ws", flag);
|
|
|
- // 风向d
|
|
|
- map.put("wd", flag);
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", flag);
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", flag);
|
|
|
- // 状态
|
|
|
- map.put("status", windTurbineStatusData.getStatus() + "");
|
|
|
- vList.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E229.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("单机文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("单机上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成宜昌地调NWP预测上报文件。
|
|
|
- */
|
|
|
- private void generateE227File(Date date) {
|
|
|
- // 获取72nwp模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NWP72_YC.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int fileNwpDays = super.getTranSysParameter("FILE_NWP_DAYS", "3");
|
|
|
-
|
|
|
- //获取nwp72轮毂高度
|
|
|
- int turbinH = super.getTranSysParameter("HB_NWP72_TURBINH", "80");
|
|
|
-
|
|
|
- try {
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, fileNwpDays).getTime()) - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E227", startTime);
|
|
|
- if (getFileName(fileName, "E227")) {
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- // 查询NWP数据
|
|
|
- List<Nwp> nwpDataList = this.nwpService.getNwpData(startTime, endTime);
|
|
|
- // 按照预测时间进行升序
|
|
|
- nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- // 光伏
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("time", DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy/MM/dd_HH:mm"));
|
|
|
- map.put("GlobalR", df.format(nwpDataList.get(i).getDirectRadiation().floatValue() + nwpDataList.get(i).getDiffuseRadiation().floatValue()));
|
|
|
- map.put("DirectR", df.format(nwpDataList.get(i).getDirectRadiation()));
|
|
|
- map.put("DiffuseR", df.format(nwpDataList.get(i).getDiffuseRadiation()));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("p", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- map.put("ws", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("time", DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy/MM/dd_HH:mm"));
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- map.put("ws30", df.format(nwpDataList.get(i).getWs30()));
|
|
|
- map.put("wd30", df.format(nwpDataList.get(i).getWd30()));
|
|
|
- map.put("ws100", df.format(nwpDataList.get(i).getWs100()));
|
|
|
- map.put("wd100", df.format(nwpDataList.get(i).getWd100()));
|
|
|
- map.put("ws170", df.format(nwpDataList.get(i).getWs170()));
|
|
|
- map.put("wd170", df.format(nwpDataList.get(i).getWd170()));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- BigDecimal turbinWS = new BigDecimal(-99);
|
|
|
- BigDecimal turbinWD = new BigDecimal(-99);
|
|
|
-
|
|
|
- switch (turbinH) {
|
|
|
- case 10:
|
|
|
- turbinWS = nwpDataList.get(i).getWs10();
|
|
|
- turbinWD = nwpDataList.get(i).getWd10();
|
|
|
- break;
|
|
|
- case 30:
|
|
|
- turbinWS = nwpDataList.get(i).getWs30();
|
|
|
- turbinWD = nwpDataList.get(i).getWd30();
|
|
|
- break;
|
|
|
- case 50:
|
|
|
- turbinWS = nwpDataList.get(i).getWs50();
|
|
|
- turbinWD = nwpDataList.get(i).getWd50();
|
|
|
- break;
|
|
|
- case 70:
|
|
|
- turbinWS = nwpDataList.get(i).getWs70();
|
|
|
- turbinWD = nwpDataList.get(i).getWd70();
|
|
|
- break;
|
|
|
- case 80:
|
|
|
- turbinWS = nwpDataList.get(i).getWs80();
|
|
|
- turbinWD = nwpDataList.get(i).getWd80();
|
|
|
- break;
|
|
|
- case 90:
|
|
|
- turbinWS = nwpDataList.get(i).getWs90();
|
|
|
- turbinWD = nwpDataList.get(i).getWd90();
|
|
|
- break;
|
|
|
- case 100:
|
|
|
- turbinWS = nwpDataList.get(i).getWs100();
|
|
|
- turbinWD = nwpDataList.get(i).getWd100();
|
|
|
- break;
|
|
|
- case 170:
|
|
|
- turbinWS = nwpDataList.get(i).getWs170();
|
|
|
- turbinWD = nwpDataList.get(i).getWd170();
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- map.put("turbinWS", df.format(turbinWS));
|
|
|
- map.put("turbinWD", df.format(turbinWD));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- velocityContext.put("vList", list);
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().toString());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E227.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("宜昌地调NWP文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("宜昌地调NWP上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成地调气象站上报文件
|
|
|
- */
|
|
|
- private void generateE230File(Date date) {
|
|
|
- // 获取气象站模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/QXZ_DD_YC.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("气象站文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E230", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E230")) {
|
|
|
- // 获取气象站信息
|
|
|
- List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoRepository.findAll();
|
|
|
- // 将测风塔信息过滤出上报的塔
|
|
|
- List<WeatherStationInfo> weatherStationInfos = weatherStationInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- if (!weatherStationInfos.isEmpty()) {
|
|
|
- Integer uploadWeatherStationId = weatherStationInfos.get(0).getId();
|
|
|
- // 获取测风塔遥测数据
|
|
|
- // List<WeatherStationStatusData> weatherStationStatusDataList = weatherStationStatusDataRepository.findByTimeBetweenAndEquipmentNo(new Date(startTime), new Date(endTime), uploadWeatherStationId);
|
|
|
- WeatherStationStatusData weatherStationStatusData = super.getWeatherStationStatusData(uploadWeatherStationId);
|
|
|
- // 数据格式化
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- BigDecimal globalR;
|
|
|
- BigDecimal directR;
|
|
|
- BigDecimal diffuseR;
|
|
|
- BigDecimal airT;
|
|
|
- BigDecimal p;
|
|
|
- BigDecimal rh;
|
|
|
- BigDecimal cellT;
|
|
|
- BigDecimal ws;
|
|
|
- BigDecimal wd;
|
|
|
-
|
|
|
-
|
|
|
- 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 = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("globalR", globalR);
|
|
|
- velocityContext.put("directR", directR);
|
|
|
- velocityContext.put("diffuseR", diffuseR);
|
|
|
- velocityContext.put("airT", airT);
|
|
|
- velocityContext.put("p", p);
|
|
|
- velocityContext.put("rh", rh);
|
|
|
- velocityContext.put("cellT", cellT);
|
|
|
- velocityContext.put("ws", ws);
|
|
|
- velocityContext.put("wd", wd);
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- // 系统当前日期
|
|
|
- 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"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E230.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的气象站,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("气象站文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("气象站上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成宜昌逆变器地调上报文件。
|
|
|
- * 文件名格式(ZJNCMS_20181204_1050_NBQ.PVD)
|
|
|
- */
|
|
|
- private void generateE231File(Date date) {
|
|
|
- // 获取基本信息模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NBQ_DD_YC.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("逆变器文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E231", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E231")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取逆变器
|
|
|
- List<InverterInfo> inverterInfos = inverterInfoService.getAll();
|
|
|
- // 获取逆变器遥测数据
|
|
|
- // List<InverterStatusData> inverterStatusDataList = inverterStatusDataRepository.findByTimeBetween(new Date(startTime), new Date(endTime));
|
|
|
- // 过滤上报的逆变器
|
|
|
- List<InverterInfo> filterInverterInfoList = inverterInfos.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
-
|
|
|
- BigDecimal cap = new BigDecimal(0);
|
|
|
-
|
|
|
- //因为现场未接入数据 默认状态为3 数据为0
|
|
|
- if (filterInverterInfoList.size() > 0) {
|
|
|
- List<Map<String, String>> dtaInverterList = new ArrayList<>();
|
|
|
- for (InverterInfo inverterInfo : filterInverterInfoList) {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", inverterInfo.getName());
|
|
|
-
|
|
|
- map.put("groupSeries", inverterInfo.getGroupSeries()?"1":"0");
|
|
|
-
|
|
|
- cap = cap.add(inverterInfo.getCapacity());
|
|
|
- // 过滤出逆变器对应的数据
|
|
|
- // List<InverterStatusData> filterInverterStatusData = inverterStatusDataList.stream().filter(w -> w.getEquipmentNo() == inverterInfo.getId()).collect(Collectors.toList());
|
|
|
- InverterStatusData inverterStatusData = super.getInverterStatusData(inverterInfo.getId());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- if (inverterStatusData != null) {
|
|
|
- //map.put("status", inverterStatusData.getStatus().toString());
|
|
|
- // 有功
|
|
|
- map.put("NbqActivePower", df.format(inverterStatusData.getActivePower().compareTo(new BigDecimal(-99)) == 0 ? 0 : inverterStatusData.getActivePower().divide(new BigDecimal(1000))));
|
|
|
- // 无功
|
|
|
- map.put("NbqReActivePower", df.format(inverterStatusData.getReactivePower().compareTo(new BigDecimal(-99)) == 0 ? 0 : inverterStatusData.getReactivePower().divide(new BigDecimal(1000))));
|
|
|
- // 电压
|
|
|
- map.put("Voltage", df.format(inverterStatusData.getVoltage().compareTo(new BigDecimal(-99)) == 0 ? 0 : inverterStatusData.getVoltage()));
|
|
|
- // 电流
|
|
|
- map.put("GalvanicCurrent", df.format(inverterStatusData.getElectricalCurrent().compareTo(new BigDecimal(-99)) == 0 ? 0 : inverterStatusData.getElectricalCurrent()));
|
|
|
- /*韩雪融
|
|
|
- 单机信息:
|
|
|
- WPD文件:省调老系统-地调
|
|
|
- 0是运行,1是故障,2是待机,3是检修
|
|
|
- PVD文件:
|
|
|
- 1是运行,0是故障,2是待机,3是检修
|
|
|
-
|
|
|
- 老系统WPD:
|
|
|
- 有功>0 状态为运行:0
|
|
|
- 有功<=0 状态为非运行:2
|
|
|
- 新系统PVD:
|
|
|
- 有功>0 状态为运行:1
|
|
|
- 有功<=0 状态为非运行:2*/
|
|
|
- BigDecimal bd = new BigDecimal(map.get("NbqActivePower"));
|
|
|
- if (bd.compareTo(new BigDecimal(0)) == 1) {
|
|
|
- //有功大于0 则运行状态为0
|
|
|
- map.put("status", "0");
|
|
|
- } else {
|
|
|
- //不大于0则为小于等于0 则运行状态为2
|
|
|
- map.put("status", "2");
|
|
|
- }
|
|
|
- } else {
|
|
|
- map.put("status", "2");
|
|
|
- map.put("NbqActivePower", "0");
|
|
|
- map.put("NbqReActivePower", "0");
|
|
|
- map.put("Voltage", "0");
|
|
|
- map.put("GalvanicCurrent", "0");
|
|
|
- }
|
|
|
- dtaInverterList.add(map);
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", dtaInverterList);
|
|
|
- DecimalFormat df1 = new DecimalFormat("0.0");
|
|
|
- cap = cap.divide(new BigDecimal(1000));
|
|
|
- velocityContext.put("cap", df1.format(cap));
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("netSubstationName", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- 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"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E231.name(), null, date);
|
|
|
- } else {
|
|
|
- log.info("没有上报的逆变器,不能生成文件!");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("逆变器文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("逆变器上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成风机基本信息上报文件。
|
|
|
- */
|
|
|
- private void generateE232File(Date date) {
|
|
|
- // 获取基本信息模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/FJ_BASE_YC.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("风机基础信息文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E232", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E232")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取风机
|
|
|
- List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoRepository.findAllByOrderByIdAsc();
|
|
|
- // 过滤上报的风机
|
|
|
- List<WindTurbineInfo> filterWindInfoList = windTurbineInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- filterWindInfoList.sort(Comparator.comparing(WindTurbineInfo::getId));
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- Double cap = 0.00;
|
|
|
- int index = 0;
|
|
|
- String name = "";
|
|
|
- for (WindTurbineInfo windTurbineInfo : filterWindInfoList) {
|
|
|
- index = index + 1;
|
|
|
- if (index < 10) {
|
|
|
- name = "0" + String.valueOf(index);
|
|
|
- } else {
|
|
|
- name = String.valueOf(index);
|
|
|
- }
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", name);
|
|
|
- // 额定功率
|
|
|
- map.put("maxPower", df.format(windTurbineInfo.getMaxPower() / 1000));
|
|
|
- // 型号
|
|
|
- map.put("modelNumber", windTurbineInfo.getModelNumber());
|
|
|
- // 经度
|
|
|
- map.put("longitude", windTurbineInfo.getLongitude() == null ? "无" : DDtoDMS(windTurbineInfo.getLongitude()));
|
|
|
- // 纬度
|
|
|
- map.put("latitude", windTurbineInfo.getLatitude() == null ? "无" : DDtoDMS(windTurbineInfo.getLatitude()));
|
|
|
- // 是否样板机
|
|
|
- map.put("sample", windTurbineInfo.getSample() ? "1" : "0");
|
|
|
- vList.add(map);
|
|
|
- cap = cap + windTurbineInfo.getMaxPower() / 1000;
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- velocityContext.put("capacity", df.format(cap));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E232.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("宜昌地调风机基础信息文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("宜昌地调风机基础信息上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成地调逆变器单机上报文件。
|
|
|
- */
|
|
|
- private void generateE233File(Date date) {
|
|
|
- // 获取逆变器单机模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NBQ_BASE_DD_YC.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- try {
|
|
|
- Long startTime;
|
|
|
- try {
|
|
|
- startTime = DateMomentUtil.getMomentTime(systemDate.getTime() - 5 * 60 * 1000, 1, 5 * 60 * 1000L);
|
|
|
- } catch (ServiceException e) {
|
|
|
- log.error("基础文件生成时刻步长错误", e);
|
|
|
- startTime = DateMomentUtil.getDayStartTime(systemDate.getTime());
|
|
|
- }
|
|
|
- Long endTime = startTime + 5 * 60 * 1000 - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E233", endTime + 1000);
|
|
|
- if (getFileName(fileName, "E233")) {
|
|
|
- List<Map<String, String>> vList = new ArrayList<>();
|
|
|
- // 获取风机
|
|
|
- List<InverterInfo> inverterInfoList = inverterInfoService.getAll();
|
|
|
- // 过滤上报的风机
|
|
|
- List<InverterInfo> filterInverterInfoList = inverterInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- BigDecimal cap = new BigDecimal(0);
|
|
|
- for (InverterInfo inverterInfo : filterInverterInfoList) {
|
|
|
- cap = cap.add(inverterInfo.getCapacity());
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- // 名称
|
|
|
- map.put("name", inverterInfo.getName());
|
|
|
- // 额定功率
|
|
|
- map.put("capacity", df.format(inverterInfo.getCapacity()));
|
|
|
- // 型号
|
|
|
- map.put("modelNumber", inverterInfo.getModelNumber());
|
|
|
- // 经度
|
|
|
- map.put("longitude", inverterInfo.getBackupB() == null ? "无" : DDtoDMS(Double.parseDouble(inverterInfo.getBackupB())));
|
|
|
- // 纬度
|
|
|
- map.put("latitude", inverterInfo.getBackupC() == null ? "无" : DDtoDMS(Double.parseDouble(inverterInfo.getBackupC())));
|
|
|
- // 是否样板机
|
|
|
- map.put("sample", inverterInfo.getSample() ? "1" : "0");
|
|
|
- // 是否组串式
|
|
|
- map.put("groupSeries", inverterInfo.getGroupSeries() ? "1" : "0");
|
|
|
- vList.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", vList);
|
|
|
- velocityContext.put("cap", cap);
|
|
|
- // 场站标识
|
|
|
- velocityContext.put("sign", electricFieldInfo.getNetSubstationName());
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E233.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("省调逆变器基础信息文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("省调逆变器基础信息上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成荆门地调72nwp(下午)上报文件。
|
|
|
- */
|
|
|
- private void generateE237File(Date date) {
|
|
|
- // 获取超短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/NWP72.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
- // 短期默认天数
|
|
|
- int fileNwpDays = super.getTranSysParameter("HUBEI_DD_NWP", "3");
|
|
|
- //获取nwp72轮毂高度
|
|
|
- int turbinH = super.getTranSysParameter("HB_NWP72_TURBINH", "80");
|
|
|
- try {
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, fileNwpDays).getTime()) - 1000;
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E237", startTime);
|
|
|
- if (getFileName(fileName, "E237")) {
|
|
|
- List<Map<String, Object>> list = new ArrayList<>();
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- String efiLabel = "";
|
|
|
- // 查询NWP数据(风电第一个点从00:15开始)
|
|
|
- List<Nwp> nwpDataList = this.nwpService.getNwpData(startTime + 1000 * 60 * 15, endTime + 1000 * 60 * 15);
|
|
|
- // 按照预测时间进行升序
|
|
|
- nwpDataList.sort(Comparator.comparing(Nwp::getPreTime));
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- // 光伏
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("time", DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm"));
|
|
|
- map.put("swr", df.format(nwpDataList.get(i).getSwr()));
|
|
|
- map.put("directRadiation", df.format(NumberUtils.multiply(nwpDataList.get(i).getSwr(), new BigDecimal(0.7))));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- for (int i = 0; i < nwpDataList.size(); i++) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
-
|
|
|
- String tempTime = "";
|
|
|
- if ("00:00".equals(DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "HH:mm"))) {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime() - 1000 * 60 * 60 * 24, "yyyy-MM-dd") + " 24:00";
|
|
|
- } else {
|
|
|
- tempTime = DateFormatUtils.format(nwpDataList.get(i).getPreTime(), "yyyy-MM-dd HH:mm");
|
|
|
- }
|
|
|
-
|
|
|
- map.put("time", tempTime);
|
|
|
- map.put("ws10", df.format(nwpDataList.get(i).getWs10()));
|
|
|
- map.put("wd10", df.format(nwpDataList.get(i).getWd10()));
|
|
|
- map.put("ws30", df.format(nwpDataList.get(i).getWs30()));
|
|
|
- map.put("wd30", df.format(nwpDataList.get(i).getWd30()));
|
|
|
- map.put("ws100", df.format(nwpDataList.get(i).getWs100()));
|
|
|
- map.put("wd100", df.format(nwpDataList.get(i).getWd100()));
|
|
|
- map.put("ws170", df.format(nwpDataList.get(i).getWs170()));
|
|
|
- map.put("wd170", df.format(nwpDataList.get(i).getWd170()));
|
|
|
- map.put("t", df.format(nwpDataList.get(i).getT()));
|
|
|
- map.put("rh", df.format(nwpDataList.get(i).getRh()));
|
|
|
- map.put("ps", df.format(nwpDataList.get(i).getPressure()));
|
|
|
- list.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- // 场站经纬度
|
|
|
- velocityContext.put("longitude", electricFieldInfo.getLongitude());
|
|
|
- velocityContext.put("latitude", electricFieldInfo.getLatitude());
|
|
|
- }
|
|
|
-
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- velocityContext.put("vList", list);
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- velocityContext.put("electricFieldType", electricFieldInfo.getElectricFieldTypeEnum().name());
|
|
|
- velocityContext.put("turbinH", turbinH);
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd"));
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E237.name(), null, date);
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("地调72NWP(下午)文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("地调72NWP(下午)上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成地调短期(下午)预测上报文件。
|
|
|
- */
|
|
|
- private void generateE238File(Date date) {
|
|
|
- // 获取短期模板
|
|
|
- Template template = this.velocityEngine.getTemplate(this.vmsPath + "/DQ_DD.vm");
|
|
|
- if (template != null) {
|
|
|
- VelocityContext velocityContext;
|
|
|
- StringWriter writer;
|
|
|
- String fileName;
|
|
|
- File file;
|
|
|
- ElectricField electricFieldInfo = null;
|
|
|
- try {
|
|
|
- electricFieldInfo = super.getElectricField();
|
|
|
- } catch (BusinessException e) {
|
|
|
- log.error("场站获取失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取当前系统时间
|
|
|
- Date systemDate = new Date();
|
|
|
- if (date != null) {
|
|
|
- systemDate = date;
|
|
|
- }
|
|
|
-
|
|
|
- // 短期默认天数
|
|
|
- int dqDays = super.getTranSysParameter("FILE_FORECAST_DAYS", "3");
|
|
|
-
|
|
|
- try {
|
|
|
- // 开始时间
|
|
|
- Long startTime = DateMomentUtil.getDayStartTime(DateUtils.addDays(systemDate, 1).getTime());
|
|
|
- // 结束时间(开始加24小时再减去1秒)
|
|
|
- Long endTime = DateMomentUtil.getDayLastTime(DateUtils.addDays(systemDate, dqDays).getTime());
|
|
|
- // 生成上报文件名格式
|
|
|
- fileName = e42UploadFileRuleService.getFileNameRule(electricFieldInfo, "E238", startTime);
|
|
|
-
|
|
|
- if (getFileName(fileName, "E238")) {
|
|
|
- // 查询短期预测功率
|
|
|
- List<ForecastPowerShortTermHis> forecastPowerShortTermHisList = this.forecastPowerShortTermService.getForecastPowerShortTerm(startTime, endTime);
|
|
|
- String efiLabel = "";
|
|
|
- if (ElectricFieldTypeEnum.E1.equals(electricFieldInfo.getElectricFieldTypeEnum())) {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".guangfuP";
|
|
|
- } else {
|
|
|
- efiLabel = "hubei." + electricFieldInfo.getSign() + ".fengdianP";
|
|
|
- }
|
|
|
- // 创建上报文件
|
|
|
- file = super.createTempFile(fileName);
|
|
|
- // 根据模板生成文件内容
|
|
|
- velocityContext = new VelocityContext();
|
|
|
- velocityContext.put("vList", forecastPowerShortTermHisList);
|
|
|
- velocityContext.put("efiLabel", efiLabel);
|
|
|
- // 场站标识别名
|
|
|
- velocityContext.put("backupA", electricFieldInfo.getNetSubstationName());
|
|
|
- // 场站装机容量
|
|
|
- velocityContext.put("capacity", electricFieldInfo.getCapacity());
|
|
|
- // 系统当前日期
|
|
|
- velocityContext.put("currentTime", DateFormatUtils.format(systemDate, "yyyy-MM-dd_HH:mm:ss"));
|
|
|
- // 上报数据开始日期
|
|
|
- velocityContext.put("uploadTime", DateFormatUtils.format(startTime, "yyyy-MM-dd") + "_00:00");
|
|
|
- writer = new StringWriter();
|
|
|
- template.merge(velocityContext, writer);
|
|
|
- super.copyUploadFile(writer, file, FileTypeEnum.E238.name(), null, date);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("地调短期(下午)文件生成失败", e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log.error("地调短期(下午)上报模板不存在!");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 经纬度转换
|