Browse Source

增加风机文件生成

xusl 3 years ago
parent
commit
05eceee295

+ 117 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/entity/WindTurbineStatusData.java

@@ -0,0 +1,117 @@
+package com.jiayue.ipfcst.common.data.entity;
+
+
+import com.jiayue.ipfcst.common.data.abst.equipmentstatus.AbstractEquipmentStatusData;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.validation.constraints.Digits;
+import java.math.BigDecimal;
+
+/**
+ * 风机数据实体
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/8/2 10:22
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Entity
+public class WindTurbineStatusData extends AbstractEquipmentStatusData {
+	/**
+	 * 有功(KW)
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal activePower = new BigDecimal(-99);
+
+	/**
+	 * 无功(KVar)
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal reactivePower = new BigDecimal(-99);
+
+	/**
+	 * 功率因数
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal powerFactor = new BigDecimal(-99);
+
+	/**
+	 * 电压(V)
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal voltage = new BigDecimal(-99);
+
+	/**
+	 * 电流(A)
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal electricalCurrent = new BigDecimal(-99);
+
+	/**
+	 * 当日发电量(kW·h)
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal dayElectricQuantity = new BigDecimal(-99);
+
+	/**
+	 * 当日并网小时
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal dayGridConnectedHours = new BigDecimal(-99);
+
+
+	/**
+	 * 转速(rpm)
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal windWheelRatedSpeed = new BigDecimal(-99);
+
+	/**
+	 * 风速(m/s)
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal ws = new BigDecimal(-99);
+
+	/**
+	 * 风向(°)
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal wd = new BigDecimal(-99);
+
+	/**
+	 * 温度(℃)
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal t = new BigDecimal(-99);
+
+	/**
+	 * 桨距角(°)
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal pitchAngle = new BigDecimal(-99);
+
+
+	/**
+	 * 累积发电量(MW·h)
+	 */
+	@Digits(integer = 10, fraction = 2)
+	@Column
+	private BigDecimal cumulativeGeneratedEnergy  = new BigDecimal(-99);
+
+}

+ 20 - 0
ipfcst-common/ipfcst-common-data/src/main/java/com/jiayue/ipfcst/common/data/repository/WindTurbineStatusDataRepository.java

@@ -0,0 +1,20 @@
+package com.jiayue.ipfcst.common.data.repository;
+
+import com.jiayue.ipfcst.common.data.entity.WindTurbineStatusData;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 风机数据实体仓储
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2019/8/6 13:02
+ */
+public interface WindTurbineStatusDataRepository extends BaseRepository<WindTurbineStatusData, Integer> {
+    List<WindTurbineStatusData> findByTimeBetween(Date startTime, Date endTime);
+    List<WindTurbineStatusData> findByTimeBetweenAndEquipmentNo(Date startTime, Date endTime, Integer no);
+
+    List<WindTurbineStatusData> findByTimeBetweenAndEquipmentNoIn(Date startTime, Date endTime, Integer[] no);
+}

+ 125 - 17
ipfcst-console/src/main/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileService.java

@@ -787,24 +787,132 @@ public class E63UploadFileService extends BaseUploadFileService {
    * 生成风机上报文件
    */
   private void generateFjFile(String fileName, Template template, ElectricField electricFieldInfo, Date date, Long startTime, Long endTime) {
-    Map<String, Object> map = new HashMap<>();
-    // 创建上报文件
-    File file = super.createTempFile(fileName);
-    VelocityContext velocityContext = new VelocityContext();
-    // 根据模板生成文件内容
-    velocityContext.put("vList", null);
-    // 场站标识
-    velocityContext.put("sign", electricFieldInfo.getSign());
-    // 场站装机容量
-    velocityContext.put("capacity", electricFieldInfo.getCapacity());
-    // 系统当前日期
-    velocityContext.put("currentTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm") + ":00");
-    // 上报数据开始日期
-    velocityContext.put("uploadTime", DateFormatUtils.format(endTime + 1000, "yyyy-MM-dd_HH:mm"));
+    // 获取风机信息
+    List<WindTurbineInfo> windTurbineInfoList = windTurbineInfoRepository.findAll();
+    // 将测风塔信息过滤出上报的塔
+    List<WindTurbineInfo> filterWindTurbineInfoList = windTurbineInfoList.stream().filter(w -> w.getReport() == true).collect(Collectors.toList());
+    if (filterWindTurbineInfoList.size() > 0) {
+      List<Map<String, Object>> fanList = new ArrayList<>();
+      for (WindTurbineInfo windTurbineInfo : filterWindTurbineInfoList) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("name", windTurbineInfo.getName());
+        map.put("dtaStatus", windTurbineInfo);
+        map.put("sample", windTurbineInfo.getSample() ? "1" : "0");
+        map.put("modelNumber", windTurbineInfo.getModelNumber());
+        map.put("RatedCapacity", div(new BigDecimal(windTurbineInfo.getMaxPower()),new BigDecimal("1000"),2));
+        map.put("elName",electricFieldInfo.getName());
+        map.put("collectorCircuit",windTurbineInfo.getCollectorCircuit());
 
-    StringWriter writer = new StringWriter();
-    template.merge(velocityContext, writer);
-    super.copyUploadFile(writer, file, FileTypeEnum.E9.name(), null, date, electricFieldInfo.getStationCode());
+        String windTurbineEquipmentNo = windTurbineInfo.getEquipmentNo();
+        Map<String, String> fjMap = redisUtils.hgetall("fj-" + electricFieldInfo.getStationCode() + "-" + windTurbineEquipmentNo);
+        DecimalFormat df = new DecimalFormat("0.00");
+
+        // 状态
+        String status = "1";
+        // 有功
+        BigDecimal activePower = new BigDecimal("0");
+        // 无功
+        BigDecimal reactivePower = new BigDecimal("0");
+        // 功率因数
+        BigDecimal powerFactor = new BigDecimal("0");
+        // 电压
+        BigDecimal voltage = new BigDecimal("0");
+        // 电流
+        BigDecimal electricalCurrent = new BigDecimal("0");
+        // 当日发电量
+        BigDecimal dayElectricQuantity = new BigDecimal("0");
+        // 转速
+        BigDecimal windWheelRatedSpeed = new BigDecimal("0");
+        // 风速
+        BigDecimal ws = new BigDecimal("0");
+        // 风向
+        BigDecimal wd = new BigDecimal("0");
+        // 温度
+        BigDecimal t = new BigDecimal("0");
+        // 桨距角
+        BigDecimal pitchAngle = new BigDecimal("0");
+        // 累积发电量
+        BigDecimal cumulativeGeneratedEnergy = new BigDecimal("0");
+
+        if (!fjMap.isEmpty()) {
+          String time = fjMap.get("time");
+          if (StrUtil.isNotBlank(time)) {
+            if (Long.parseLong(time) >= startTime && Long.parseLong(time) <= endTime) {
+              if (fjMap.get("status") != null) {
+                status = fjMap.get("status");
+              }
+              if (fjMap.get("activePower") != null) {
+                activePower = new BigDecimal(fjMap.get("activePower"));
+              }
+              if (fjMap.get("reactivePower") != null) {
+                reactivePower = new BigDecimal(fjMap.get("reactivePower"));
+              }
+              if (fjMap.get("powerFactor") != null) {
+                powerFactor = new BigDecimal(fjMap.get("powerFactor"));
+              }
+              if (fjMap.get("voltage") != null) {
+                voltage = new BigDecimal(fjMap.get("voltage"));
+              }
+              if (fjMap.get("electricalCurrent") != null) {
+                electricalCurrent = new BigDecimal(fjMap.get("electricalCurrent"));
+              }
+              if (fjMap.get("dayElectricQuantity") != null) {
+                dayElectricQuantity = new BigDecimal(fjMap.get("dayElectricQuantity"));
+              }
+              if (fjMap.get("cumulativeGeneratedEnergy") != null) {
+                cumulativeGeneratedEnergy = new BigDecimal(fjMap.get("cumulativeGeneratedEnergy"));
+              }
+              if (fjMap.get("windWheelRatedSpeed") != null) {
+                windWheelRatedSpeed = new BigDecimal(fjMap.get("windWheelRatedSpeed"));
+              }
+              if (fjMap.get("ws") != null) {
+                ws = new BigDecimal(fjMap.get("ws"));
+              }
+              if (fjMap.get("wd") != null) {
+                wd = new BigDecimal(fjMap.get("wd"));
+              }
+              if (fjMap.get("t") != null) {
+                t = new BigDecimal(fjMap.get("t"));
+              }
+              if (fjMap.get("pitchAngle") != null) {
+                pitchAngle = new BigDecimal(fjMap.get("pitchAngle"));
+              }
+            }
+          }
+        }
+        map.put("ActivePower", div(activePower, new BigDecimal("1000"), 2).toString());
+        map.put("ReActivePower", div(reactivePower, new BigDecimal("1000"), 2).toString());
+        map.put("RotationlSpeed", df.format(windWheelRatedSpeed));
+        map.put("WS", df.format(ws));
+        map.put("WD", df.format(wd));
+        map.put("T", df.format(t));
+        map.put("Voltage", df.format(voltage));
+        map.put("GalvanicCurrent", df.format(electricalCurrent));
+        map.put("PowerFactor", df.format(powerFactor));
+        map.put("GeneratingCap", df.format(cumulativeGeneratedEnergy));
+        map.put("dtaStatus", status);
+        map.put("DayElectricQuantity", df.format(dayElectricQuantity));
+        map.put("PropellerPitchAngle", df.format(pitchAngle));
+        fanList.add(map);
+      }
+      // 创建上报文件
+      File file = super.createTempFile(fileName);
+      VelocityContext velocityContext = new VelocityContext();
+      // 根据模板生成文件内容
+      velocityContext.put("vList", fanList);
+      // 场站标识
+      velocityContext.put("sign", electricFieldInfo.getSign());
+      // 场站装机容量
+      velocityContext.put("capacity", electricFieldInfo.getCapacity());
+      // 系统当前日期
+      velocityContext.put("currentTime", DateFormatUtils.format(endTime, "yyyy-MM-dd_HH:mm") + ":00");
+      // 上报数据开始日期
+      velocityContext.put("uploadTime", DateFormatUtils.format(endTime, "yyyy-MM-dd_HH:mm"));
+
+      StringWriter writer = new StringWriter();
+      template.merge(velocityContext, writer);
+      super.copyUploadFile(writer, file, FileTypeEnum.E9.name(), null, date, electricFieldInfo.getStationCode());
+    }
   }
 
   /**

+ 1 - 1
ipfcst-console/src/test/java/com/jiayue/ipfcst/fileupload/service/E63UploadFileServiceTest.java

@@ -34,7 +34,7 @@ public class E63UploadFileServiceTest extends BaseTest {
 
   @Test
   public void testCreateFile() throws Exception{
-      e63UploadFileService.generateQxzOrCftFile(new Date());
+      e63UploadFileService.generateNbqOrFjFile(new Date());
   }
 
   @Test