learshaw 5 ay önce
ebeveyn
işleme
14c63ab405

+ 17 - 1
ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/handle/AcrelElecMonitorHandler.java

@@ -39,7 +39,6 @@ import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -306,6 +305,7 @@ public class AcrelElecMonitorHandler extends BaseMeterDevHandler {
 
             List<MeterKeyValue> meterKeyValueList = template.getMeterParamValueByKey(meterUse.getSubId(),
                 meterUse.getMeterCode());
+            meterKeyValueFormat(meterKeyValueList, "Switch");
 
             for (MeterKeyValue meterKeyValue : meterKeyValueList) {
                 if (attrKeys.contains(meterKeyValue.getParamCode())) {
@@ -361,6 +361,8 @@ public class AcrelElecMonitorHandler extends BaseMeterDevHandler {
 
             Map<String, MeterKeyValue> map = meterKeyValueList.stream()
                 .collect(Collectors.toMap(MeterKeyValue::getParamCode, Function.identity()));
+            // 值格式化
+            meterKeyValueFormat(map, "Switch");
 
             for (EmsObjAttr objAttr : objAttrList) {
                 if (map.containsKey(objAttr.getAttrKey())) {
@@ -374,6 +376,20 @@ public class AcrelElecMonitorHandler extends BaseMeterDevHandler {
         return retList;
     }
 
+    private void meterKeyValueFormat(List<MeterKeyValue> list, String key) {
+        Map<String, MeterKeyValue> map = list.stream()
+            .collect(Collectors.toMap(MeterKeyValue::getParamCode, Function.identity()));
+        meterKeyValueFormat(map, key);
+    }
+
+    private void meterKeyValueFormat(Map<String, MeterKeyValue> map, String key) {
+        MeterKeyValue switchMeterKeyValue = map.get(key);
+
+        if (null != switchMeterKeyValue && null != switchMeterKeyValue.getValue()) {
+            switchMeterKeyValue.setValue(switchMeterKeyValue.getValue().split("\\.")[0]);
+        }
+    }
+
     private EmsDevice convertDevice(MeterUse meterUse) {
         EmsDevice device = new EmsDevice();
         device.setDeviceCode(String.format("W4-E-%s", meterUse.getMeterCode()));

+ 65 - 88
ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/handle/SquareLightCtlHandler.java

@@ -76,7 +76,7 @@ public class SquareLightCtlHandler extends BaseDevHandler {
     private static final String DEV_MODE_CODE = "M_Z010_DEV_SQUARE_LIGHT";
 
     // 集中器设备代码
-    private static final String CONCENTRATOR_MODE_CODE = "M_Z010_DEV_SQUARE_CONCENTRATOR";
+    private static final String CONCENTRATOR = "M_Z010_DEV_SQUARE_CONCENTRATOR";
 
     // 设备子系统代码
     private static final String SUBSYSTEM_CODE = "SYS_ZHZM";
@@ -470,7 +470,7 @@ public class SquareLightCtlHandler extends BaseDevHandler {
     public void syncCentDeviceList(List<SlcDevice> slcDevices) {
         // 查询数据库记录
         QueryDevice param = new QueryDevice();
-        param.setDeviceModel(CONCENTRATOR_MODE_CODE);
+        param.setDeviceModel(CONCENTRATOR);
         param.setSubsystemCode(SUBSYSTEM_CODE);
         List<EmsDevice> dbDevs = deviceService.selectList(param);
         Set<String> dbDevCodeSet = dbDevs.stream().map(EmsDevice::getDeviceCode).collect(Collectors.toSet());
@@ -485,7 +485,7 @@ public class SquareLightCtlHandler extends BaseDevHandler {
 
         if (CollectionUtils.isNotEmpty(delCodes)) {
             for (String code : delCodes) {
-                deviceService.deleteDevice(CONCENTRATOR_MODE_CODE, code);
+                deviceService.deleteDevice(CONCENTRATOR, code);
             }
         }
 
@@ -556,7 +556,7 @@ public class SquareLightCtlHandler extends BaseDevHandler {
         device.setDeviceBrand("佐通");
         device.setDeviceSpec("单灯控制器");
         device.setDeviceStatus(slcDevice.getStatus());
-        device.setDeviceModel(CONCENTRATOR_MODE_CODE);
+        device.setDeviceModel(CONCENTRATOR);
         device.setSubsystemCode(SUBSYSTEM_CODE);
 
         if (StringUtils.startsWith(slcDevice.getDeviceName(), "北区")) {
@@ -593,6 +593,7 @@ public class SquareLightCtlHandler extends BaseDevHandler {
         if (CollectionUtils.isNotEmpty(oaValues)) {
             Map<String, EmsObjAttrValue> vMap = oaValues.stream()
                 .collect(Collectors.toMap(EmsObjAttrValue::getAttrKey, Function.identity()));
+            checkAndUpdate(vMap, deviceId, CONCENTRATOR, "deviceStatus", convertDeviceStatus(slcDevice.getAbnormal()));
 
             if (null != deviceInfo.getBaselineInfo()) {
                 BaselineInfo baselineInfo = deviceInfo.getBaselineInfo();
@@ -627,20 +628,16 @@ public class SquareLightCtlHandler extends BaseDevHandler {
             if (null != slcDevice) {
                 oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "deviceName", slcDevice.getDeviceName()));
                 oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "imageUrl", slcDevice.getImageUrl()));
-                oaValues.add(
-                    new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "deviceStatus", String.valueOf(slcDevice.getAbnormal())));
+                oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "deviceStatus", convertDeviceStatus(slcDevice.getAbnormal())));
                 oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "csq", slcDevice.getCsq()));
-                oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "lampList",
-                    JSON.toJSONString(slcDevice.getLampList())));
+                oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "lampList", JSON.toJSONString(slcDevice.getLampList())));
             }
 
             if (null != deviceInfo.getDeviceInfo()) {
                 DevSub subInfo = deviceInfo.getDeviceInfo();
                 oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "deviceUid", subInfo.getDeviceUid()));
-                oaValues.add(
-                    new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "minCct", String.valueOf(subInfo.getMinCct())));
-                oaValues.add(
-                    new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "maxCct", String.valueOf(subInfo.getMaxCct())));
+                oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "minCct", String.valueOf(subInfo.getMinCct())));
+                oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "maxCct", String.valueOf(subInfo.getMaxCct())));
             }
 
             if (null != deviceInfo.getBaselineInfo()) {
@@ -652,25 +649,20 @@ public class SquareLightCtlHandler extends BaseDevHandler {
 
             if (null != deviceInfo.getStatusInfo()) {
                 StatusInfo sInfo = deviceInfo.getStatusInfo();
-                oaValues.add(
-                    new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "current", String.valueOf(sInfo.getCurrent())));
+                oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "current", String.valueOf(sInfo.getCurrent())));
                 oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "power", String.valueOf(sInfo.getPower())));
                 oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "factor", String.valueOf(sInfo.getFactor())));
-                oaValues.add(
-                    new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "voltage", String.valueOf(sInfo.getVoltage())));
+                oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "voltage", String.valueOf(sInfo.getVoltage())));
                 oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "energy", String.valueOf(sInfo.getEnergy())));
-                oaValues.add(
-                    new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "frequency", String.valueOf(sInfo.getFrequency())));
-                oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "temperature",
-                    String.valueOf(sInfo.getTemperature())));
+                oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "frequency", String.valueOf(sInfo.getFrequency())));
+                oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "temperature", String.valueOf(sInfo.getTemperature())));
             }
 
             if (CollectionUtils.isNotEmpty(deviceInfo.getLampList())) {
                 List<SlcDeviceLamp> lampList = deviceInfo.getLampList();
                 SlcDeviceLamp lamp = lampList.get(0);
                 oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "cct", String.valueOf(lamp.getCct())));
-                oaValues.add(
-                    new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "Switch", String.valueOf(lamp.getLampOnOff())));
+                oaValues.add(new EmsObjAttrValue(deviceId, DEV_MODE_CODE, "Switch", String.valueOf(lamp.getLampOnOff())));
             }
 
             objAttrValueService.insertBatch(oaValues);
@@ -678,80 +670,65 @@ public class SquareLightCtlHandler extends BaseDevHandler {
     }
 
     private void mergeCentDevAttrValue(String projectId, List<SlcDevice> slcDevices) {
-        for (SlcDevice slcDevice : slcDevices) {
-            List<EmsObjAttrValue> objAttrValues = objAttrValueService.selectByObjCode(CONCENTRATOR_MODE_CODE,
-                slcDevice.getDeviceCode());
-            CcElecInfo info = slcDevice.getCcElecInfo();
+        for (SlcDevice slc : slcDevices) {
+            List<EmsObjAttrValue> objAttrValues = objAttrValueService.selectByObjCode(CONCENTRATOR,
+                slc.getDeviceCode());
+            CcElecInfo info = slc.getCcElecInfo();
 
             if (CollectionUtils.isNotEmpty(objAttrValues)) {
-                Map<String, EmsObjAttrValue> objAttrValueMap = objAttrValues.stream()
-                    .collect(Collectors.toMap(EmsObjAttrValue::getAttrKey, Function.identity()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "deviceStatus",
-                    String.valueOf(slcDevice.getAbnormal()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "csq", String.valueOf(slcDevice.getCsq()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "kwh", String.valueOf(info.getKwh()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "kvarh", String.valueOf(info.getKvarh()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "ua", String.valueOf(info.getUa()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "ub", String.valueOf(info.getUb()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "uc", String.valueOf(info.getUc()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "ia", String.valueOf(info.getIa()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "ib", String.valueOf(info.getIb()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "ic", String.valueOf(info.getIc()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "pfa", String.valueOf(info.getPfa()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "pfb", String.valueOf(info.getPfb()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "pfc", String.valueOf(info.getPfc()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "hza", String.valueOf(info.getHza()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "hzb", String.valueOf(info.getHzb()));
-                checkAndUpdate(objAttrValueMap, slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "hzc", String.valueOf(info.getHzc()));
+                Map<String, EmsObjAttrValue> vMap = objAttrValues.stream().collect(Collectors.toMap(EmsObjAttrValue::getAttrKey, Function.identity()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "deviceStatus", convertDeviceStatus(slc.getAbnormal()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "csq", String.valueOf(slc.getCsq()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "kwh", String.valueOf(info.getKwh()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "kvarh", String.valueOf(info.getKvarh()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "ua", String.valueOf(info.getUa()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "ub", String.valueOf(info.getUb()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "uc", String.valueOf(info.getUc()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "ia", String.valueOf(info.getIa()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "ib", String.valueOf(info.getIb()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "ic", String.valueOf(info.getIc()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "pfa", String.valueOf(info.getPfa()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "pfb", String.valueOf(info.getPfb()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "pfc", String.valueOf(info.getPfc()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "hza", String.valueOf(info.getHza()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "hzb", String.valueOf(info.getHzb()));
+                checkAndUpdate(vMap, slc.getDeviceCode(), CONCENTRATOR, "hzc", String.valueOf(info.getHzc()));
             }
             else {
                 objAttrValues = new ArrayList<>();
-                objAttrValues.add(
-                    new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "projectId", projectId));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "deviceId",
-                    slcDevice.getDeviceId()));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "deviceUid",
-                    slcDevice.getDeviceUid()));
-                objAttrValues.add(
-                    new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "deviceModelId",
-                        slcDevice.getDeviceModelId()));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "imageUrl",
-                    slcDevice.getImageUrl()));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "deviceStatus",
-                    String.valueOf(slcDevice.getAbnormal())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "csq",
-                    String.valueOf(slcDevice.getCsq())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "kwh",
-                    String.valueOf(info.getKwh())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "kvarh",
-                    String.valueOf(info.getKvarh())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "ua",
-                    String.valueOf(info.getUa())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "ub",
-                    String.valueOf(info.getUb())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "uc",
-                    String.valueOf(info.getUc())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "ia",
-                    String.valueOf(info.getIa())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "ib",
-                    String.valueOf(info.getIb())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "ic",
-                    String.valueOf(info.getIc())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "pfa",
-                    String.valueOf(info.getPfa())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "pfb",
-                    String.valueOf(info.getPfb())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "pfc",
-                    String.valueOf(info.getPfc())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "hza",
-                    String.valueOf(info.getHza())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "hzb",
-                    String.valueOf(info.getHzb())));
-                objAttrValues.add(new EmsObjAttrValue(slcDevice.getDeviceCode(), CONCENTRATOR_MODE_CODE, "hzc",
-                    String.valueOf(info.getHzc())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "projectId", projectId));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "deviceId", slc.getDeviceId()));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "deviceUid", slc.getDeviceUid()));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "deviceModelId", slc.getDeviceModelId()));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "imageUrl", slc.getImageUrl()));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "deviceStatus", convertDeviceStatus(slc.getAbnormal())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "csq", String.valueOf(slc.getCsq())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "kwh", String.valueOf(info.getKwh())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "kvarh", String.valueOf(info.getKvarh())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "ua", String.valueOf(info.getUa())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "ub", String.valueOf(info.getUb())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "uc", String.valueOf(info.getUc())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "ia", String.valueOf(info.getIa())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "ib", String.valueOf(info.getIb())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "ic", String.valueOf(info.getIc())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "pfa", String.valueOf(info.getPfa())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "pfb", String.valueOf(info.getPfb())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "pfc", String.valueOf(info.getPfc())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "hza", String.valueOf(info.getHza())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "hzb", String.valueOf(info.getHzb())));
+                objAttrValues.add(new EmsObjAttrValue(slc.getDeviceCode(), CONCENTRATOR, "hzc", String.valueOf(info.getHzc())));
 
                 objAttrValueService.insertBatch(objAttrValues);
             }
         }
     }
+
+    private String convertDeviceStatus(Integer abnormal) {
+        if (null == abnormal) {
+            return "0";
+        }
+        else {
+            return abnormal == 0 ? "1" : "0";
+        }
+    }
 }

+ 1 - 1
ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/retrofit/Acrel3000Api.java

@@ -85,7 +85,7 @@ public interface Acrel3000Api {
     Call<String> getCircuitInfoTree(@Header("Authorization") String authorization, @Query("fSubId") String subId);
 
     /**
-     * 获取回路
+     * 获取实时数据
      *
      * @param authorization 用户名
      * @param subId         站点ID

+ 7 - 0
ems/ems-core/src/main/java/com/ruoyi/ems/mapper/ElecPvSupplyHMapper.java

@@ -17,6 +17,13 @@ import java.util.Map;
  */
 public interface ElecPvSupplyHMapper {
     /**
+     * 查询光伏产能按小时统计列表
+     * @param queryMeter 查询参数
+     * @return 结果
+     */
+    List<PvSupplyVO> selectPvSupplyHourlyList(QueryMeter queryMeter);
+
+    /**
      * 查询光伏产能按日统计列表
      */
     List<PvSupplyVO> selectPvSupplyDailyList(@Param("queryMeter") QueryMeter queryMeter);

+ 7 - 106
ems/ems-core/src/main/java/com/ruoyi/ems/model/PvSupplyVO.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.huashe.common.annotation.Excel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -11,6 +12,7 @@ import java.util.Date;
 /**
  * 光伏产能统计视图对象
  */
+@Data
 @ApiModel("光伏产能统计响应模型")
 public class PvSupplyVO {
 
@@ -64,119 +66,18 @@ public class PvSupplyVO {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 
-    // 构造方法
-    public PvSupplyVO() {}
+    @ApiModelProperty("时间序列(1-24)")
+    private Integer timeIndex;
 
-    // Getters and Setters
-    public String getAreaCode() {
-        return areaCode;
-    }
-
-    public void setAreaCode(String areaCode) {
-        this.areaCode = areaCode;
-    }
-
-    public String getAreaName() {
-        return areaName;
-    }
-
-    public void setAreaName(String areaName) {
-        this.areaName = areaName;
-    }
-
-    public String getFacsCode() {
-        return facsCode;
-    }
-
-    public void setFacsCode(String facsCode) {
-        this.facsCode = facsCode;
-    }
-
-    public String getFacsName() {
-        return facsName;
-    }
-
-    public void setFacsName(String facsName) {
-        this.facsName = facsName;
-    }
-
-    public Date getStatisticDate() {
-        return statisticDate;
-    }
-
-    public void setStatisticDate(Date statisticDate) {
-        this.statisticDate = statisticDate;
-    }
-
-    public String getStatisticYear() {
-        return statisticYear;
-    }
-
-    public void setStatisticYear(String statisticYear) {
-        this.statisticYear = statisticYear;
-    }
-
-    public String getStatisticMonth() {
-        return statisticMonth;
-    }
-
-    public void setStatisticMonth(String statisticMonth) {
-        this.statisticMonth = statisticMonth;
-    }
-
-    public String getTimeDimension() {
-        return timeDimension;
-    }
-
-    public void setTimeDimension(String timeDimension) {
-        this.timeDimension = timeDimension;
-    }
-
-    public BigDecimal getGenElecQuantity() {
-        return genElecQuantity;
-    }
+    @ApiModelProperty("统计小时")
+    @Excel(name = "统计小时")
+    private String statisticHour;
 
     public Double getGenElecQuantityValue() {
         return genElecQuantity != null ? genElecQuantity.doubleValue() : 0;
     }
 
-    public void setGenElecQuantity(BigDecimal genElecQuantity) {
-        this.genElecQuantity = genElecQuantity;
-    }
-
-    public BigDecimal getUseElecQuantity() {
-        return useElecQuantity;
-    }
-
-    public void setUseElecQuantity(BigDecimal useElecQuantity) {
-        this.useElecQuantity = useElecQuantity;
-    }
-
-    public BigDecimal getUpElecQuantity() {
-        return upElecQuantity;
-    }
-
     public Double getUpElecQuantityValue() {
         return upElecQuantity != null ? upElecQuantity.doubleValue() : 0;
     }
-
-    public void setUpElecQuantity(BigDecimal upElecQuantity) {
-        this.upElecQuantity = upElecQuantity;
-    }
-
-    public BigDecimal getUpElecEarn() {
-        return upElecEarn;
-    }
-
-    public void setUpElecEarn(BigDecimal upElecEarn) {
-        this.upElecEarn = upElecEarn;
-    }
-
-    public Date getCreateTime() {
-        return createTime;
-    }
-
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
-    }
 }

+ 2 - 0
ems/ems-core/src/main/java/com/ruoyi/ems/service/impl/ElecPvSupplyHServiceImpl.java

@@ -38,6 +38,8 @@ public class ElecPvSupplyHServiceImpl implements IElecPvSupplyHService {
 
             // 根据时间维度调用相应的查询方法
             switch (queryMeter.getTimeDimension().toLowerCase()) {
+                case "hour":
+                    return pvSupplyHMapper.selectPvSupplyHourlyList(queryMeter);
                 case "day":
                     return pvSupplyHMapper.selectPvSupplyDailyList(queryMeter);
                 case "month":

+ 34 - 0
ems/ems-core/src/main/resources/mapper/ems/ElecPvSupplyHMapper.xml

@@ -39,6 +39,40 @@
         <result property="upElecEarn" column="up_elec_earn"/>
     </resultMap>
 
+    <select id="selectPvSupplyHourlyList" parameterType="com.ruoyi.ems.model.QueryMeter" resultMap="PvSupplyVOResult">
+        SELECT
+        pv.area_code,
+        a.area_name,
+        pv.date as statistic_date,
+        pv.time_index,
+        CONCAT(LPAD(pv.time_index - 1, 2, '0'), ':00') as statistic_hour,
+        'HOUR' as time_dimension,
+        ROUND(SUM(COALESCE(pv.gen_elec_quantity, 0)), 2) as gen_elec_quantity,
+        ROUND(SUM(COALESCE(pv.use_elec_quantity, 0)), 2) as use_elec_quantity,
+        ROUND(SUM(COALESCE(pv.up_elec_quantity, 0)), 2) as up_elec_quantity,
+        ROUND(SUM(COALESCE(pv.up_elec_earn, 0)), 2) as up_elec_earn,
+        NOW() as create_time
+        FROM adm_ems_pv_supply_h pv
+        LEFT JOIN adm_area a ON pv.area_code = a.area_code
+        <where>
+            <if test="queryMeter.areaCode != null and queryMeter.areaCode != '' and queryMeter.areaCode != '-1'">
+                AND pv.area_code = #{queryMeter.areaCode}
+            </if>
+            <if test="queryMeter.date != null and queryMeter.date != ''">
+                AND pv.date = DATE(#{queryMeter.date})
+            </if>
+            <if test="queryMeter.startRecTime != null and queryMeter.startRecTime != ''">
+                AND pv.date &gt;= DATE(#{queryMeter.startRecTime})
+            </if>
+            <if test="queryMeter.endRecTime != null and queryMeter.endRecTime != ''">
+                AND pv.date &lt;= DATE(#{queryMeter.endRecTime})
+            </if>
+            AND pv.date IS NOT NULL
+        </where>
+        GROUP BY pv.area_code, a.area_name, pv.date, pv.time_index
+        ORDER BY pv.time_index ${queryMeter.orderFlag}
+    </select>
+
     <!-- ==================== 光伏产能按日汇总统计 ==================== -->
     <select id="selectPvSupplyDailyList" parameterType="com.ruoyi.ems.model.QueryMeter" resultMap="PvSupplyVOResult">
         SELECT

+ 4 - 4
ems/sql/ems_init_data.sql

@@ -394,12 +394,12 @@ INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `at
 INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_Z010_SYS_SQUARE_LIGHT', 'interfaceStatus', '0', '断开');
 INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_W4_SYS_ELEC_MONITOR', 'interfaceStatus', '1', '正常');
 INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_W4_SYS_ELEC_MONITOR', 'interfaceStatus', '0', '断开');
-INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_Z010_DEV_SQUARE_LIGHT', 'deviceStatus', '0', '正常');
-INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_Z010_DEV_SQUARE_LIGHT', 'deviceStatus', '1', '异常');
+INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_Z010_DEV_SQUARE_LIGHT', 'deviceStatus', '1', '正常');
+INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_Z010_DEV_SQUARE_LIGHT', 'deviceStatus', '0', '异常');
 INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_Z010_DEV_SQUARE_LIGHT', 'Switch', '0', '关闭');
 INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_Z010_DEV_SQUARE_LIGHT', 'Switch', '1', '开启');
-INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_Z010_DEV_SQUARE_CONCENTRATOR', 'deviceStatus', '0', '正常');
-INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_Z010_DEV_SQUARE_CONCENTRATOR', 'deviceStatus', '1', '异常');
+INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_Z010_DEV_SQUARE_CONCENTRATOR', 'deviceStatus', '1', '正常');
+INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_Z010_DEV_SQUARE_CONCENTRATOR', 'deviceStatus', '0', '异常');
 INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_W4_DEV_ELEC_MONITOR_BHZZ', 'Switch', '0', '关闭');
 INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_W4_DEV_ELEC_MONITOR_BHZZ', 'Switch', '1', '开启');
 INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_W4_DEV_ELEC_MONITOR_DB', 'Switch', '0', '关闭');