Răsfoiți Sursa

BA楼控能力调用集成

learshaw 4 luni în urmă
părinte
comite
789f278ffe

+ 0 - 1
ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/TaskExecutor.java

@@ -76,7 +76,6 @@ public class TaskExecutor {
     public void refresh5min() {
         CompletableFuture.runAsync(() -> squareLightCtlHandler.execSyncDevAttrAll());
         CompletableFuture.runAsync(() -> acrelElecMonitorHandler.execSyncDevAttrAll());
-        baCtlHandler.refreshOnline();
         squareLightCtlHandler.refreshOnline();
     }
 

+ 52 - 7
ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/core/BaCtlEnergyTemplate.java

@@ -12,11 +12,14 @@ package com.ruoyi.ems.core;
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.support.retrofit.Retrofit2ConverterFactory;
+import com.alibaba.fastjson2.JSON;
 import com.huashe.common.exception.Assert;
 import com.ruoyi.common.core.utils.SpringUtils;
 import com.ruoyi.common.redis.service.RedisService;
 import com.ruoyi.ems.config.BaCtlConfig;
+import com.ruoyi.ems.model.CallData;
 import com.ruoyi.ems.model.idenergy.CodesValReq;
+import com.ruoyi.ems.model.idenergy.CodesValSetReq;
 import com.ruoyi.ems.model.idenergy.Token;
 import com.ruoyi.ems.retrofit.BaCtlEnergyApi;
 import lombok.extern.slf4j.Slf4j;
@@ -168,18 +171,19 @@ public class BaCtlEnergyTemplate extends BaseApiTemplate {
     }
 
     /**
-     * 获取能耗数据
+     * 获取实时数据
      *
      * @param req 请求
-     * @return 能耗数据列表
+     * @return 实时数据列表
      */
-    public String getCodesVal(CodesValReq req) {
-        String ret = null;
+    public CallData<String> getCodesVal(CodesValReq req) {
+        CallData.Builder<String> builder = CallData.builder();
 
         try {
             String token = getToken();
             BaCtlConfig config = SpringUtils.getBean(BaCtlConfig.class);
             // 执行调用
+            builder.addCallParam("appId", config.getAppId()).addCallParam("token", token).addCallParam("req", JSONObject.toJSONString(req));
             Call<String> call = api.getCodesVal(config.getAppId(), token, req);
             Response<String> response = call.execute();
             log.debug("getCodesVal response:{}", response);
@@ -187,7 +191,7 @@ public class BaCtlEnergyTemplate extends BaseApiTemplate {
             JSONObject resJson = JSONObject.parseObject(response.body());
 
             if (resJson.getInteger("code") == 200) {
-                ret = response.body();
+                builder.setCallStatus(0).setResPayload(response.body());
             }
             else if (resJson.getInteger("code") == 302) {
                 token = getNewToken();
@@ -195,13 +199,54 @@ public class BaCtlEnergyTemplate extends BaseApiTemplate {
                 call = api.getCodesVal(config.getAppId(), token, req);
                 response = call.execute();
                 log.debug("getCodesVal response:{}", response);
-                ret = response.body();
+                builder.setCallStatus(0).setResPayload(response.body());
             }
         }
         catch (Exception e) {
+            builder.setCallStatus(1);
             log.error("getCodesVal fail!", e);
         }
 
-        return ret;
+        return builder.build();
+    }
+
+    /**
+     * 设置下发
+     *
+     * @param req 请求
+     * @return 能耗数据列表
+     */
+    public CallData<String> setCodesVal(CodesValSetReq req) {
+        CallData.Builder<String> builder = CallData.builder();
+
+        try {
+            String token = getToken();
+            BaCtlConfig config = SpringUtils.getBean(BaCtlConfig.class);
+            // 执行调用
+            builder.addCallParam("appId", config.getAppId()).addCallParam("token", token).addCallParam("req", JSON.toJSONString(req));
+            Call<String> call = api.setCodesVal(config.getAppId(), token, req);
+            Response<String> response = call.execute();
+            log.debug("setCodesVal response:{}", response);
+
+            JSONObject resJson = JSONObject.parseObject(response.body());
+
+            if (resJson.getInteger("code") == 200) {
+                builder.setCallStatus(0).setResPayload(response.body());
+            }
+            else if (resJson.getInteger("code") == 302) {
+                token = getNewToken();
+                // 执行调用
+                call = api.setCodesVal(config.getAppId(), token, req);
+                response = call.execute();
+                log.debug("setCodesVal response:{}", response);
+                builder.setCallStatus(0).setResPayload(response.body());
+            }
+        }
+        catch (Exception e) {
+            builder.setCallStatus(1);
+            log.error("setCodesVal fail!", e);
+        }
+
+        return builder.build();
     }
 }

+ 68 - 55
ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/handle/BaCtlHandler.java

@@ -19,11 +19,13 @@ import com.ruoyi.ems.domain.WaterMeterH;
 import com.ruoyi.ems.enums.DevObjType;
 import com.ruoyi.ems.model.AbilityPayload;
 import com.ruoyi.ems.model.BoundaryObj;
+import com.ruoyi.ems.model.CallData;
 import com.ruoyi.ems.model.CallResponse;
 import com.ruoyi.ems.model.Price;
 import com.ruoyi.ems.model.QueryDevice;
 import com.ruoyi.ems.model.idenergy.CodesVal;
 import com.ruoyi.ems.model.idenergy.CodesValReq;
+import com.ruoyi.ems.model.idenergy.CodesValSetReq;
 import com.ruoyi.ems.service.IEmsObjAttrValueService;
 import com.ruoyi.ems.util.PingUtils;
 import org.apache.commons.collections4.CollectionUtils;
@@ -152,13 +154,46 @@ public class BaCtlHandler extends BaseMeterDevHandler {
                         meterReadingGw(device.getDeviceModel(), "MeterReadingGw", device.getDeviceCode());
                     }
                 }
+                else if (StringUtils.equals("SyncXfDevAttr", param.getAbilityKey())) {
+                    xfCollect();
+                }
+                else if (StringUtils.equals("SyncAuhDevAttr", param.getAbilityKey())) {
+                    ahuCollect();
+                }
+                else if (StringUtils.equals("SyncWtDevAttr", param.getAbilityKey())) {
+                    wtCollect();
+                }
+                else if (StringUtils.equals("SyncWpDevAttr", param.getAbilityKey())) {
+                    wpCollect();
+                }
+                else if (StringUtils.equals("SyncLightDevAttr", param.getAbilityKey())) {
+                    lightCollect();
+                }
 
                 callResponse = new CallResponse<>(0, "成功");
             }
             else if (DevObjType.DEVC.getCode() == param.getObjType()) {
-                if (StringUtils.equals("MeterReadingGw", param.getAbilityKey())) {
+                if (StringUtils.equals("MeterReadingGw", param.getAbilityKey()) && StringUtils.equals(param.getModelCode(), GATEWAY_MODEL)) {
                     meterReadingGw(param.getModelCode(), param.getAbilityKey(), param.getObjCode());
                 }
+                else if (StringUtils.equals("StartStopCtl", param.getAbilityKey()) && StringUtils.equals(param.getModelCode(), METER_MODEL_XF)) {
+                    Map<String, String> xfMapper = config.getXfMapper();
+                    String pointId = xfMapper.get(String.format("%s.%s", param.getObjCode(), "setCtl-StartStop"));
+                    Assert.notEmpty(pointId, -1, "该设备未配置控制测点pointId.");
+                    devAbilityCall(METER_MODEL_XF, param.getObjCode(), pointId, param.getAbilityKey(), param.getAbilityParam());
+                }
+                else if (StringUtils.equals("StartStopCtl", param.getAbilityKey()) && StringUtils.equals(param.getModelCode(), METER_MODEL_AHU)) {
+                    Map<String, String> ahuMapper = config.getAhuMapper();
+                    String pointId = ahuMapper.get(String.format("%s.%s", param.getObjCode(), "setCtl-StartStop"));
+                    Assert.notEmpty(pointId, -1, "该设备未配置控制测点pointId.");
+                    devAbilityCall(METER_MODEL_AHU, param.getObjCode(), pointId, param.getAbilityKey(), param.getAbilityParam());
+                }
+                else if (StringUtils.equals("OnOffCtl", param.getAbilityKey()) && StringUtils.equals(param.getModelCode(), METER_MODEL_AHU)) {
+                    Map<String, String> lightMapper = config.getLightMapper();
+                    String pointId = lightMapper.get(String.format("%s.%s", param.getObjCode(), "setCtl-OnOff"));
+                    Assert.notEmpty(pointId, -1, "该设备未配置控制测点pointId.");
+                    devAbilityCall(METER_MODEL_LIGHT, param.getObjCode(), pointId, param.getAbilityKey(), param.getAbilityParam());
+                }
 
                 callResponse = new CallResponse<>(0, "成功");
             }
@@ -175,50 +210,18 @@ public class BaCtlHandler extends BaseMeterDevHandler {
 
     @Override
     public void refreshOnline() {
-        try {
-            // 1. 从URL中提取IP地址
-            String url = config.getUrl();
-            if (StringUtils.isBlank(url)) {
-                log.warn("能耗监测系统URL配置为空,跳过心跳检测");
-                return;
-            }
-
-            String ipAddress = PingUtils.extractIpFromUrl(url);
-            if (StringUtils.isBlank(ipAddress)) {
-                log.warn("无法从URL中提取IP地址: {}", url);
-                return;
-            }
-
-            // 2. 执行ping检测
-            boolean isOnline = PingUtils.pingHost(ipAddress, 3000); // 3秒超时
-
-            // 3. 获取当前系统状态
-            String statusKey = "interfaceStatus";
-
-            // 查询当前状态
-            EmsObjAttrValue currentStatus = objAttrValueService.selectObjAttrValue(SYS_MODE_CODE, SUBSYSTEM_CODE,
-                statusKey);
-
-            String newStatus = isOnline ? "1" : "0";
-            String oldStatus = currentStatus != null ? currentStatus.getAttrValue() : null;
+    }
 
-            // 4. 状态发生变化时更新并记录
-            if (!StringUtils.equals(oldStatus, newStatus)) {
-                log.info("能耗监测系统连接状态变化: {} -> {}, IP: {}", oldStatus, newStatus, ipAddress);
+    public void devAbilityCall(String modelCode, String deviceId, String pointId, String abilityKey, String paramValue) {
+        CodesVal codesVal = new CodesVal();
+        codesVal.setPointId(pointId);
+        codesVal.setValue(paramValue);
 
-                // 更新系统属性状态
-                objAttrValueService.updateObjAttrValue(SYS_MODE_CODE, SUBSYSTEM_CODE, statusKey, newStatus);
+        BaCtlEnergyTemplate template = new BaCtlEnergyTemplate(config.getUrl());
+        CallData<String> callData = template.setCodesVal(new CodesValSetReq(codesVal));
 
-                String key = isOnline ? "connect" : "disconnect";
-                triggerEvent(SYS_MODE_CODE, SUBSYSTEM_CODE, key, null, new Date());
-            }
-
-            // 5. 记录心跳日志(可选,用于调试)
-            log.debug("能耗监测系统心跳检测完成 - IP: {}, 状态: {}", ipAddress, isOnline ? "在线" : "离线");
-        }
-        catch (Exception e) {
-            log.error("能耗监测系统心跳检测异常", e);
-        }
+        saveCallLog(deviceId, modelCode, abilityKey, callData.getCallStatus(),
+            callData.getCallPayload(), callData.getResPayload());
     }
 
     private void meterReadingGw(String modeCode, String abilityKey, String objCode) {
@@ -233,7 +236,8 @@ public class BaCtlHandler extends BaseMeterDevHandler {
             CodesValReq req = new CodesValReq(pointIdSet);
 
             // 调用能耗数据接口获取实时数据
-            String callRes = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            CallData<String> callData = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            String callRes = callData.getResPayload();
             JSONObject resJson = JSONObject.parseObject(callRes);
 
             if (resJson.getInteger("code") == 200) {
@@ -367,7 +371,8 @@ public class BaCtlHandler extends BaseMeterDevHandler {
                 CodesValReq req = new CodesValReq(pointIdSet);
 
                 // 调用能耗数据接口获取实时数据
-                String callRes = template.getCodesVal(req);
+                CallData<String> callData = template.getCodesVal(req);
+                String callRes = callData.getResPayload();
                 JSONObject resJson = JSONObject.parseObject(callRes);
                 Assert.isTrue(StringUtils.equals(resJson.getString("code"), "200"), resJson.getInteger("code"),
                     resJson.getString("error"));
@@ -393,16 +398,18 @@ public class BaCtlHandler extends BaseMeterDevHandler {
         String deviceCode = device.getDeviceCode();
         Map<String, String> paramKeys = config.getXfMapper();
 
-        Set<String> pointIds = paramKeys.entrySet().stream()
-            .filter(entry -> StringUtils.startsWith(entry.getKey(), deviceCode))
-            .flatMap(entry -> Arrays.stream(StringUtils.split(entry.getValue(), ","))).map(String::trim)
-            .collect(Collectors.toSet());
+        Set<String> pointIds = paramKeys.entrySet().stream().filter(
+                entry -> StringUtils.startsWith(entry.getKey(), deviceCode)
+                    && !StringUtils.startsWith(entry.getKey(), deviceCode + ".setCtl-"))
+            .flatMap(entry -> Arrays.stream(StringUtils.split(entry.getValue(), ",")))
+            .map(String::trim).collect(Collectors.toSet());
 
         if (CollectionUtils.isNotEmpty(pointIds)) {
             CodesValReq req = new CodesValReq(pointIds);
 
             // 调用能耗数据接口获取实时数据
-            String callRes = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            CallData<String> callData = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            String callRes = callData.getResPayload();
             JSONObject resJson = JSONObject.parseObject(callRes);
             Assert.isTrue(StringUtils.equals(resJson.getString("code"), "200"), resJson.getInteger("code"),
                 resJson.getString("error"));
@@ -445,7 +452,8 @@ public class BaCtlHandler extends BaseMeterDevHandler {
         Map<String, String> paramKeys = config.getAhuMapper();
 
         Set<String> pointIds = paramKeys.entrySet().stream()
-            .filter(entry -> StringUtils.startsWith(entry.getKey(), deviceCode))
+            .filter(entry -> StringUtils.startsWith(entry.getKey(), deviceCode)
+                && !StringUtils.startsWith(entry.getKey(), deviceCode + ".setCtl-"))
             .flatMap(entry -> Arrays.stream(StringUtils.split(entry.getValue(), ","))).map(String::trim)
             .collect(Collectors.toSet());
 
@@ -453,7 +461,8 @@ public class BaCtlHandler extends BaseMeterDevHandler {
             CodesValReq req = new CodesValReq(pointIds);
 
             // 调用能耗数据接口获取实时数据
-            String callRes = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            CallData<String> callData = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            String callRes = callData.getResPayload();
             JSONObject resJson = JSONObject.parseObject(callRes);
             Assert.isTrue(StringUtils.equals(resJson.getString("code"), "200"), resJson.getInteger("code"),
                 resJson.getString("error"));
@@ -498,7 +507,8 @@ public class BaCtlHandler extends BaseMeterDevHandler {
             CodesValReq req = new CodesValReq(pointIds);
 
             // 调用能耗数据接口获取实时数据
-            String callRes = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            CallData<String> callData = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            String callRes = callData.getResPayload();
             JSONObject resJson = JSONObject.parseObject(callRes);
             Assert.isTrue(StringUtils.equals(resJson.getString("code"), "200"), resJson.getInteger("code"),
                 resJson.getString("error"));
@@ -530,7 +540,8 @@ public class BaCtlHandler extends BaseMeterDevHandler {
             CodesValReq req = new CodesValReq(pointIds);
 
             // 调用能耗数据接口获取实时数据
-            String callRes = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            CallData<String> callData = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            String callRes = callData.getResPayload();
             JSONObject resJson = JSONObject.parseObject(callRes);
             Assert.isTrue(StringUtils.equals(resJson.getString("code"), "200"), resJson.getInteger("code"),
                 resJson.getString("error"));
@@ -554,7 +565,8 @@ public class BaCtlHandler extends BaseMeterDevHandler {
         Map<String, String> paramKeys = config.getLightMapper();
 
         Set<String> pointIds = paramKeys.entrySet().stream()
-            .filter(entry -> StringUtils.startsWith(entry.getKey(), deviceCode))
+            .filter(entry -> StringUtils.startsWith(entry.getKey(), deviceCode)
+                && !StringUtils.startsWith(entry.getKey(), deviceCode + ".setCtl-"))
             .flatMap(entry -> Arrays.stream(StringUtils.split(entry.getValue(), ","))).map(String::trim)
             .collect(Collectors.toSet());
 
@@ -562,7 +574,8 @@ public class BaCtlHandler extends BaseMeterDevHandler {
             CodesValReq req = new CodesValReq(pointIds);
 
             // 调用能耗数据接口获取实时数据
-            String callRes = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            CallData<String> callData = new BaCtlEnergyTemplate(config.getUrl()).getCodesVal(req);
+            String callRes = callData.getResPayload();
             JSONObject resJson = JSONObject.parseObject(callRes);
             Assert.isTrue(StringUtils.equals(resJson.getString("code"), "200"), resJson.getInteger("code"),
                 resJson.getString("error"));

+ 44 - 0
ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/model/idenergy/CodesValSetReq.java

@@ -0,0 +1,44 @@
+/*
+ * 文 件 名:  CodesValSetReq
+ * 版    权:  华设设计集团股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2025/11/22
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.ruoyi.ems.model.idenergy;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * 设置下发
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2025/11/22]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@Data
+public class CodesValSetReq {
+    private List<CodesVal> aryPoints;
+
+    public CodesValSetReq() {
+    }
+
+    public CodesValSetReq(List<CodesVal> aryPoints) {
+        this.aryPoints = aryPoints;
+    }
+
+    public CodesValSetReq(CodesVal... codesVal) {
+        this.aryPoints = new ArrayList<>(Arrays.asList(codesVal));
+    }
+}

+ 12 - 0
ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/retrofit/BaCtlEnergyApi.java

@@ -11,6 +11,7 @@
 package com.ruoyi.ems.retrofit;
 
 import com.ruoyi.ems.model.idenergy.CodesValReq;
+import com.ruoyi.ems.model.idenergy.CodesValSetReq;
 import retrofit2.Call;
 import retrofit2.http.Body;
 import retrofit2.http.GET;
@@ -61,4 +62,15 @@ public interface BaCtlEnergyApi {
     @Headers({ "Content-Type: application/json" })
     @POST("/_webtalk/_cur/api/getCodesVal")
     Call<String> getCodesVal(@Header("appId") String appId, @Header("Token") String token, @Body CodesValReq req);
+
+    /**
+     * 下发设置
+     *
+     * @param appId 应用ID
+     * @param token 认证令牌
+     * @return 实时数据
+     */
+    @Headers({ "Content-Type: application/json" })
+    @POST("/_webtalk/_cur/api/setCodesVal")
+    Call<String> setCodesVal(@Header("appId") String appId, @Header("Token") String token, @Body CodesValSetReq req);
 }

+ 50 - 21
ems/ems-cloud/ems-dev-adapter/src/main/resources/application-local.yml

@@ -45,7 +45,7 @@ spring:
 
 mqtt:
   server:
-    host: tcp://broker.emqx.io:1883
+    host: tcp://xt.wenhq.top:8581
     client_id: ems-dev-adapter1
   executor:
     msgHandle:
@@ -155,6 +155,7 @@ adapter:
         timeSetTag: 'C_2012_BV_0010'
         manualTag: 'C_2012_BV_0011'
       'Z020-N-XF-1F-5':
+        setCtl-StartStop: 'C_1201_DO_0004'
         xfTemp: 'C_1009_AI_0000'
         sfTemp: 'C_1009_AI_0001'
         hfTemp: 'C_1009_AI_0002'
@@ -175,6 +176,7 @@ adapter:
         timeSetTag: 'C_1009_BV_0010'
         manualTag: 'C_1009_BV_0011'
       'Z020-N-XF-1F-4':
+        setCtl-StartStop: 'C_1201_DO_0003'
         xfTemp: 'C_1010_AI_0000'
         sfTemp: 'C_1010_AI_0001'
         hfTemp: 'C_1010_AI_0002'
@@ -195,6 +197,7 @@ adapter:
         timeSetTag: 'C_1010_BV_0010'
         manualTag: 'C_1010_BV_0011'
       'Z020-N-XF-1F-3':
+        setCtl-StartStop: 'C_1201_DO_0002'
         xfTemp: 'C_1011_AI_0000'
         sfTemp: 'C_1011_AI_0001'
         hfTemp: 'C_1011_AI_0002'
@@ -215,6 +218,7 @@ adapter:
         timeSetTag: 'C_1011_BV_0010'
         manualTag: 'C_1011_BV_0011'
       'Z020-N-XF-2F-1':
+        setCtl-StartStop: 'C_1012_BO_0017'
         xfTemp: 'C_1012_AI_0000'
         sfTemp: 'C_1012_AI_0001'
         hfTemp: 'C_1012_AI_0002'
@@ -351,45 +355,70 @@ adapter:
         faultState: '1008-BI7'
     lightMapper:
       'Z020-B-LIGHT-01':
-        Switch: C_8001_BO_0000
+        setCtl-OnOff: 'C_8001_BV_0000'
+        Switch: 'C_8001_BO_0000'
       'Z020-B-LIGHT-02':
-        Switch: C_8002_BO_0001
+        setCtl-OnOff: 'C_8001_BV_0002'
+        Switch: 'C_8002_BO_0001'
       'Z020-B-LIGHT-03':
-        Switch: C_8001_BO_0001
+        setCtl-OnOff: 'C_8001_BV_0008'
+        Switch: 'C_8001_BO_0001'
       'Z020-B-LIGHT-04':
-        Switch: C_8001_BO_0004
+        setCtl-OnOff: 'C_8001_BV_0002'
+        Switch: 'C_8001_BO_0004'
       'Z020-B-LIGHT-05':
-        Switch: C_8001_BO_0001
+        setCtl-OnOff: 'C_8001_BV_0000'
+        Switch: 'C_8001_BO_0001'
       'Z020-B-LIGHT-06':
-        Switch: C_8001_BO_0005
+        setCtl-OnOff: 'C_8001_BV_0018'
+        Switch: 'C_8001_BO_0005'
       'Z020-B-LIGHT-07':
-        Switch: C_8001_BO_0006
+        setCtl-OnOff: 'C_8001_BV_0020'
+        Switch: 'C_8001_BO_0006'
       'Z020-B-LIGHT-08':
-        Switch: C_8001_BO_0007
+        Switch: 'C_8001_BO_0007'
       'Z020-B-LIGHT-09':
-        Switch: C_8002_BO_0000
+        setCtl-OnOff: 'C_8001_BV_0022'
+        Switch: 'C_8002_BO_0000'
       'Z020-B-LIGHT-10':
-        Switch: C_8002_BO_0002
+        setCtl-OnOff: 'C_8001_BV_0024'
+        Switch: 'C_8002_BO_0002'
+      'Z020-B-LIGHT-11':
+        setCtl-OnOff: 'C_8001_BV_0028'
+        Switch: 'C_8001_BO_0003'
       'Z020-N-LIGHT-01':
-        Switch: C_7001_BO_0000
+        setCtl-OnOff: 'C_7001_BV_0000'
+        Switch: 'C_7001_BO_0000'
       'Z020-N-LIGHT-02':
-        Switch: C_7001_BO_0001
+        setCtl-OnOff: 'C_7001_BV_0002'
+        Switch: 'C_7001_BO_0001'
       'Z020-N-LIGHT-03':
-        Switch: C_7001_BO_0002
+        setCtl-OnOff: 'C_7001_BV_0004'
+        Switch: 'C_7001_BO_0002'
       'Z020-N-LIGHT-04':
-        Switch: C_7001_BO_0004
+        setCtl-OnOff: 'C_7001_BV_0012'
+        Switch: 'C_7001_BO_0004'
       'Z020-N-LIGHT-05':
-        Switch: C_7001_BO_0003
+        setCtl-OnOff: 'C_7001_BV_0010'
+        Switch: 'C_7001_BO_0003'
       'Z020-N-LIGHT-06':
-        Switch: C_7001_BO_0006
+        setCtl-OnOff: 'C_7001_BV_0018'
+        Switch: 'C_7001_BO_0006'
       'Z020-N-LIGHT-07':
-        Switch: C_7001_BO_0007
+        setCtl-OnOff: 'C_7001_BV_0020'
+        Switch: 'C_7001_BO_0007'
       'Z020-N-LIGHT-08':
-        Switch: C_7002_BO_0000
+        setCtl-OnOff: 'C_7001_BV_0022'
+        Switch: 'C_7002_BO_0000'
       'Z020-N-LIGHT-09':
-        Switch: C_7002_BO_0001
+        setCtl-OnOff: 'C_7001_BV_0022'
+        Switch: 'C_7002_BO_0001'
       'Z020-N-LIGHT-10':
-        Switch: C_7002_BO_0004
+        setCtl-OnOff: 'C_7001_BV_0024'
+        Switch: 'C_7002_BO_0004'
+      'Z020-N-LIGHT-11':
+        setCtl-OnOff: 'C_7001_BV_0028'
+        Switch: 'C_7001_BO_0005'
 # mybatis配置
 mybatis:
   # 搜索指定包别名

+ 52 - 23
ems/ems-cloud/ems-dev-adapter/src/main/resources/application-prod-ct.yml

@@ -155,6 +155,7 @@ adapter:
         timeSetTag: 'C_2012_BV_0010'
         manualTag: 'C_2012_BV_0011'
       'Z020-N-XF-1F-5':
+        setCtl-StartStop: 'C_1201_DO_0004'
         xfTemp: 'C_1009_AI_0000'
         sfTemp: 'C_1009_AI_0001'
         hfTemp: 'C_1009_AI_0002'
@@ -175,6 +176,7 @@ adapter:
         timeSetTag: 'C_1009_BV_0010'
         manualTag: 'C_1009_BV_0011'
       'Z020-N-XF-1F-4':
+        setCtl-StartStop: 'C_1201_DO_0003'
         xfTemp: 'C_1010_AI_0000'
         sfTemp: 'C_1010_AI_0001'
         hfTemp: 'C_1010_AI_0002'
@@ -195,6 +197,7 @@ adapter:
         timeSetTag: 'C_1010_BV_0010'
         manualTag: 'C_1010_BV_0011'
       'Z020-N-XF-1F-3':
+        setCtl-StartStop: 'C_1201_DO_0002'
         xfTemp: 'C_1011_AI_0000'
         sfTemp: 'C_1011_AI_0001'
         hfTemp: 'C_1011_AI_0002'
@@ -215,6 +218,7 @@ adapter:
         timeSetTag: 'C_1011_BV_0010'
         manualTag: 'C_1011_BV_0011'
       'Z020-N-XF-2F-1':
+        setCtl-StartStop: 'C_1012_BO_0017'
         xfTemp: 'C_1012_AI_0000'
         sfTemp: 'C_1012_AI_0001'
         hfTemp: 'C_1012_AI_0002'
@@ -309,9 +313,9 @@ adapter:
     wtMapper:
       # 北区水箱
       'Z020-B-WT-1':
-        tankLevel: 'C_2011_AI_0016'
-        highLevelAlarm: 'C_2011_AI_0017'
-        lowLevelAlarm: 'C_2011_AI_0018'
+        tankLevel: 'C_2008_AI_0000'
+        highLevelAlarm: 'C_2008_BI_0001'
+        lowLevelAlarm: 'C_2008_BI_0002'
       # 南区水箱
       'Z020-N-WT-1':
         highLevelAlarm: '1008-BI0'
@@ -351,45 +355,70 @@ adapter:
         faultState: '1008-BI7'
     lightMapper:
       'Z020-B-LIGHT-01':
-        Switch: C_8001_BO_0000
+        setCtl-OnOff: 'C_8001_BV_0000'
+        Switch: 'C_8001_BO_0000'
       'Z020-B-LIGHT-02':
-        Switch: C_8002_BO_0001
+        setCtl-OnOff: 'C_8001_BV_0002'
+        Switch: 'C_8002_BO_0001'
       'Z020-B-LIGHT-03':
-        Switch: C_8001_BO_0001
+        setCtl-OnOff: 'C_8001_BV_0008'
+        Switch: 'C_8001_BO_0001'
       'Z020-B-LIGHT-04':
-        Switch: C_8001_BO_0004
+        setCtl-OnOff: 'C_8001_BV_0002'
+        Switch: 'C_8001_BO_0004'
       'Z020-B-LIGHT-05':
-        Switch: C_8001_BO_0001
+        setCtl-OnOff: 'C_8001_BV_0000'
+        Switch: 'C_8001_BO_0001'
       'Z020-B-LIGHT-06':
-        Switch: C_8001_BO_0005
+        setCtl-OnOff: 'C_8001_BV_0018'
+        Switch: 'C_8001_BO_0005'
       'Z020-B-LIGHT-07':
-        Switch: C_8001_BO_0006
+        setCtl-OnOff: 'C_8001_BV_0020'
+        Switch: 'C_8001_BO_0006'
       'Z020-B-LIGHT-08':
-        Switch: C_8001_BO_0007
+        Switch: 'C_8001_BO_0007'
       'Z020-B-LIGHT-09':
-        Switch: C_8002_BO_0000
+        setCtl-OnOff: 'C_8001_BV_0022'
+        Switch: 'C_8002_BO_0000'
       'Z020-B-LIGHT-10':
-        Switch: C_8002_BO_0002
+        setCtl-OnOff: 'C_8001_BV_0024'
+        Switch: 'C_8002_BO_0002'
+      'Z020-B-LIGHT-11':
+        setCtl-OnOff: 'C_8001_BV_0028'
+        Switch: 'C_8001_BO_0003'
       'Z020-N-LIGHT-01':
-        Switch: C_7001_BO_0000
+        setCtl-OnOff: 'C_7001_BV_0000'
+        Switch: 'C_7001_BO_0000'
       'Z020-N-LIGHT-02':
-        Switch: C_7001_BO_0001
+        setCtl-OnOff: 'C_7001_BV_0002'
+        Switch: 'C_7001_BO_0001'
       'Z020-N-LIGHT-03':
-        Switch: C_7001_BO_0002
+        setCtl-OnOff: 'C_7001_BV_0004'
+        Switch: 'C_7001_BO_0002'
       'Z020-N-LIGHT-04':
-        Switch: C_7001_BO_0004
+        setCtl-OnOff: 'C_7001_BV_0012'
+        Switch: 'C_7001_BO_0004'
       'Z020-N-LIGHT-05':
-        Switch: C_7001_BO_0003
+        setCtl-OnOff: 'C_7001_BV_0010'
+        Switch: 'C_7001_BO_0003'
       'Z020-N-LIGHT-06':
-        Switch: C_7001_BO_0006
+        setCtl-OnOff: 'C_7001_BV_0018'
+        Switch: 'C_7001_BO_0006'
       'Z020-N-LIGHT-07':
-        Switch: C_7001_BO_0007
+        setCtl-OnOff: 'C_7001_BV_0020'
+        Switch: 'C_7001_BO_0007'
       'Z020-N-LIGHT-08':
-        Switch: C_7002_BO_0000
+        setCtl-OnOff: 'C_7001_BV_0022'
+        Switch: 'C_7002_BO_0000'
       'Z020-N-LIGHT-09':
-        Switch: C_7002_BO_0001
+        setCtl-OnOff: 'C_7001_BV_0022'
+        Switch: 'C_7002_BO_0001'
       'Z020-N-LIGHT-10':
-        Switch: C_7002_BO_0004
+        setCtl-OnOff: 'C_7001_BV_0024'
+        Switch: 'C_7002_BO_0004'
+      'Z020-N-LIGHT-11':
+        setCtl-OnOff: 'C_7001_BV_0028'
+        Switch: 'C_7001_BO_0005'
 # mybatis配置
 mybatis:
   # 搜索指定包别名

+ 19 - 3
ems/ems-cloud/ems-dev-adapter/src/test/java/com/huashe/test/BaCtlTest.java

@@ -13,7 +13,10 @@ package com.huashe.test;
 import com.ruoyi.ems.EmsDevAdpApplication;
 import com.ruoyi.ems.config.BaCtlConfig;
 import com.ruoyi.ems.core.BaCtlEnergyTemplate;
+import com.ruoyi.ems.model.CallData;
+import com.ruoyi.ems.model.idenergy.CodesVal;
 import com.ruoyi.ems.model.idenergy.CodesValReq;
+import com.ruoyi.ems.model.idenergy.CodesValSetReq;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Assert;
 import org.junit.Test;
@@ -61,9 +64,22 @@ public class BaCtlTest {
     @Test
     public void testGetCodesVal() {
         BaCtlEnergyTemplate template = new BaCtlEnergyTemplate(config.getUrl());
-        String ret = template.getCodesVal(new CodesValReq("C_7001_BO_0000","C_7001_BO_0001","C_7002_BO_0002","C_7001_BO_0002","C_7001_BO_0003","C_7001_BO_0004","C_7002_BO_0003","C_7001_BO_0006","C_7001_BO_0007","C_7002_BO_0000","C_7002_BO_0001","C_7002_BO_0004","C_7001_BO_0005","C_7002_BO_0005","C_7003_BO_0001","C_7003_BO_0002"));
-        log.info("ret:{}", ret);
+        CallData<String> ret = template.getCodesVal(new CodesValReq("C_1009_BO_0000"));
+        log.info("ret:{}", ret.getResPayload());
+        Assert.assertNotNull(ret.getResPayload());
+    }
+
+    @Test
+    public void testSetCodesVal() {
+        CodesVal codesVal = new CodesVal();
+        codesVal.setPointId("C_999_DO_999");
+        codesVal.setValue("1");
+        CodesValSetReq req = new CodesValSetReq(codesVal);
+
+        BaCtlEnergyTemplate template = new BaCtlEnergyTemplate(config.getUrl());
+        CallData<String> ret = template.setCodesVal(req);
+        log.info("ret:{}", ret.getResPayload());
 
-        Assert.assertNotNull(ret);
+        Assert.assertNotNull(ret.getResPayload());
     }
 }

+ 0 - 1
ems/ems-core/src/main/java/com/ruoyi/ems/service/impl/MeterDeviceServiceImpl.java

@@ -12,7 +12,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;

+ 8 - 0
ems/sql/ems_init_data.sql

@@ -1192,7 +1192,15 @@ INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `att
 
 -- 对象能力数据
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_W4_SYS_BA', 'MeterReadingTotal', '全量抄报-网关', '网关-测点批量抄报', null, 1);
+INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_W4_SYS_BA', 'SyncXfDevAttr', '采集同步-新风设备', '新风-采集同步', null, 1);
+INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_W4_SYS_BA', 'SyncAuhDevAttr', '采集同步-空调设备', '空调-采集同步', null, 1);
+INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_W4_SYS_BA', 'SyncWtDevAttr', '采集同步-水箱监测', '水箱-采集同步', null, 1);
+INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_W4_SYS_BA', 'SyncWpDevAttr', '采集同步-水泵监测', '水泵-采集同步', null, 1);
+INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_W4_SYS_BA', 'SyncLightDevAttr', '采集同步-照明监测', '照明-采集同步', null, 1);
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_W4_DEV_BA_GA', 'MeterReadingGw', '实时抄报-网关', '网关-测点批量抄报', null, 1);
+INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_Z020_DEV_BA_XF', 'StartStopCtl', '启停控制', '启动/停止', '{"type":"Options", "list":[{"key":"启动", "value":"1"},{"key":"停止", "value":"0"}]}', 1);
+INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_Z020_DEV_BA_AHU', 'StartStopCtl', '启停控制', '启动/停止', '{"type":"Options", "list":[{"key":"启动", "value":"1"},{"key":"停止", "value":"0"}]}', 1);
+INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_Z020_DEV_BA_LIGHT', 'OnOffCtl', '开关控制', '开启/关闭', '{"type":"Options", "list":[{"key":"开灯", "value":"1"},{"key":"关灯", "value":"0"}]}', 1);
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_Z010_SYS_SQUARE_LIGHT', 'GetProjectList', '同步项目列表', '同步项目列表', null, 1);
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_Z010_SYS_SQUARE_LIGHT', 'GetProjectSubsetList', '同步项目分组列表', '同步项目分组列表', null, 1);
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_Z010_SYS_SQUARE_LIGHT', 'GetDeviceList', '同步设备列表', '同步设备列表', null, 1);