Browse Source

接口字段修正

learshaw 4 months ago
parent
commit
49cc450a26
21 changed files with 252 additions and 177 deletions
  1. 2 1
      ems/ems-application/ems-admin/src/main/java/com/ruoyi/web/controller/ems/EmsObjAttrController.java
  2. 41 1
      ems/ems-application/ems-admin/src/main/java/com/ruoyi/web/controller/ems/EmsObjAttrValueController.java
  3. 2 2
      ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/handle/GeekOpenCbHandler.java
  4. 41 22
      ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/handle/MqttBaseHandler.java
  5. 2 2
      ems/ems-cloud/ems-server/src/main/java/com/ruoyi/ems/controller/EmsObjAbilityController.java
  6. 40 1
      ems/ems-cloud/ems-server/src/main/java/com/ruoyi/ems/controller/EmsObjAttrValueController.java
  7. 0 12
      ems/ems-core/src/main/java/com/ruoyi/ems/domain/EmsObjAbilityCallLog.java
  8. 5 17
      ems/ems-core/src/main/java/com/ruoyi/ems/domain/EmsObjAttrValue.java
  9. 6 6
      ems/ems-core/src/main/java/com/ruoyi/ems/domain/EmsObjReportLog.java
  10. 4 4
      ems/ems-core/src/main/java/com/ruoyi/ems/mapper/EmsObjAttrValueMapper.java
  11. 0 13
      ems/ems-core/src/main/java/com/ruoyi/ems/model/AbilityPayload.java
  12. 17 1
      ems/ems-core/src/main/java/com/ruoyi/ems/service/IAbilityCallService.java
  13. 4 4
      ems/ems-core/src/main/java/com/ruoyi/ems/service/IEmsObjAttrValueService.java
  14. 15 16
      ems/ems-core/src/main/java/com/ruoyi/ems/service/impl/AbilityCallServiceImpl.java
  15. 5 5
      ems/ems-core/src/main/java/com/ruoyi/ems/service/impl/EmsObjAttrValueServiceImpl.java
  16. 13 18
      ems/ems-core/src/main/resources/mapper/ems/EmsObjAbilityCallLogMapper.xml
  17. 3 4
      ems/ems-core/src/main/resources/mapper/ems/EmsObjAttrMapper.xml
  18. 6 10
      ems/ems-core/src/main/resources/mapper/ems/EmsObjAttrValueMapper.xml
  19. 29 19
      ems/ems-core/src/main/resources/mapper/ems/EmsObjReportLogMapper.xml
  20. 12 12
      ems/sql/ems_init_data.sql
  21. 5 7
      ems/sql/ems_server.sql

+ 2 - 1
ems/ems-application/ems-admin/src/main/java/com/ruoyi/web/controller/ems/EmsObjAttrController.java

@@ -107,11 +107,12 @@ public class EmsObjAttrController extends BaseController {
             JSONObject json = new JSONObject();
             json.put("objType", objType);
             json.put("objCode", objCode);
+            json.put("modeCode", modeCode);
 
             List<EmsObjAttr> modelAttrs = attrService.selectByModelCode(modeCode);
             json.put("attrs", CollectionUtils.isNotEmpty(modelAttrs) ? modelAttrs : new ArrayList<>());
 
-            List<EmsObjAttrValue> attrValues = objAttrValueService.selectByObjCode(objType, objCode);
+            List<EmsObjAttrValue> attrValues = objAttrValueService.selectByObjCode(modeCode, objCode);
             json.put("attrValues", attrValues);
 
             result = success(json);

+ 41 - 1
ems/ems-application/ems-admin/src/main/java/com/ruoyi/web/controller/ems/EmsObjAttrValueController.java

@@ -4,7 +4,15 @@ import com.huashe.common.domain.AjaxResult;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.exception.Assert;
+import com.ruoyi.ems.domain.EmsDevice;
+import com.ruoyi.ems.domain.EmsDeviceComponent;
+import com.ruoyi.ems.domain.EmsFacs;
 import com.ruoyi.ems.domain.EmsObjAttrValue;
+import com.ruoyi.ems.enums.DevObjType;
+import com.ruoyi.ems.service.IEmsDeviceComponentService;
+import com.ruoyi.ems.service.IEmsDeviceService;
+import com.ruoyi.ems.service.IEmsFacsService;
 import com.ruoyi.ems.service.IEmsObjAttrValueService;
 import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,6 +41,15 @@ public class EmsObjAttrValueController extends BaseController {
     @Autowired
     private IEmsObjAttrValueService objAttrValueService;
 
+    @Autowired
+    private IEmsDeviceService deviceService;
+
+    @Autowired
+    private IEmsFacsService facsService;
+
+    @Autowired
+    private IEmsDeviceComponentService componentService;
+
     /**
      * 查询能源对象属性值列表
      */
@@ -84,6 +101,29 @@ public class EmsObjAttrValueController extends BaseController {
     @DeleteMapping("/deleteByObj")
     public AjaxResult removeByObj(@RequestParam(name = "objType") Integer objType,
         @RequestParam(name = "objCode") String objCode) {
-        return toAjax(objAttrValueService.deleteByObjCode(objType, objCode));
+
+        String modeCode = null;
+        int cnt = 0;
+
+        if (objType == DevObjType.FACS.getCode()) {
+            EmsFacs facs = facsService.selectEmsFacsByCode(objCode);
+            Assert.notNull(facs, -1, "能源设施不存在");
+            modeCode = facs.getFacsModel();
+            cnt = objAttrValueService.deleteByObjCode(modeCode, objCode);
+        }
+        else if (objType == DevObjType.DEVC.getCode()) {
+            EmsDevice device = deviceService.selectByCode(objCode);
+            Assert.notNull(device, -1, "能源设备不存在");
+            modeCode = device.getDeviceModel();
+            cnt = objAttrValueService.deleteByObjCode(modeCode, objCode);
+        }
+        else if (objType == DevObjType.COMPONENT.getCode()) {
+            EmsDeviceComponent devCompo = componentService.selectByCode(objCode);
+            Assert.notNull(devCompo, -1, "设备部件不存在");
+            modeCode = devCompo.getCompoModel();
+            cnt = objAttrValueService.deleteByObjCode(modeCode, objCode);
+        }
+
+        return toAjax(cnt);
     }
 }

+ 2 - 2
ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/handle/GeekOpenCbHandler.java

@@ -148,7 +148,7 @@ public class GeekOpenCbHandler extends MqttBaseHandler {
                 // 自动上报数据: 1.更新属性值,2.更新电量计量数据
                 if (StringUtils.equals("auto", messageId)) {
                     updateAutoAttr(device, msgBody);
-                    saveReportLog(deviceCode, DevObjType.DEVC.getCode(), "电量上报", payload);
+                    saveReportLog(deviceCode, device.getDeviceModel(), "电量上报", payload);
                 }
                 // 前序调用的响应消息:1.写入消息队列,2.更新属性值
                 else if (StringUtils.isNotEmpty(messageId) && StringUtils.startsWith(messageId, "CALL-")) {
@@ -159,7 +159,7 @@ public class GeekOpenCbHandler extends MqttBaseHandler {
                 // 设备同步数据(INFO类,协议类):更新基础属性值
                 else {
                     updateBaseAttr(device, msgBody);
-                    saveReportLog(deviceCode, DevObjType.DEVC.getCode(), "信息上报", payload);
+                    saveReportLog(deviceCode, device.getDeviceModel(), "信息上报", payload);
                 }
 
                 // 设备消息抵达,将数据库离线状态改为在线

+ 41 - 22
ems/ems-cloud/ems-dev-adapter/src/main/java/com/ruoyi/ems/handle/MqttBaseHandler.java

@@ -105,11 +105,13 @@ public abstract class MqttBaseHandler {
      */
     public abstract int getObjType();
 
+
+
     /**
      * 添加消息ID到消息中
      *
-     * @param msg
-     * @return
+     * @param msg 消息
+     * @return msgBody
      */
     public String addMsgId(String msg, String msgIdKey, String msgIdValue) {
         JSONObject json = JSONObject.parseObject(msg);
@@ -117,12 +119,38 @@ public abstract class MqttBaseHandler {
         return json.toString();
     }
 
+    /**
+     * 发送MQTT消息
+     * @param topic 主题
+     * @param payload 负载数据
+     * @param qos 质量服务等级
+     * @param retained 是否保留消息
+     */
     public void sendMqttMsg(String topic, String payload, int qos, boolean retained) {
         log.info("[Send] Topic:{}, message:{}, qos:{}, retained:{}", topic, payload, qos, retained);
         mqttTemplate.send(topic, payload, 2, false);
     }
 
     /**
+     * 更新最后消息时
+     * @param device 设备
+     * @param timeValue 时间值
+     */
+    public void updateMsgTime(EmsDevice device, Date timeValue) {
+        try {
+            String dateTime = DateUtils.dateToString(timeValue, DateUtils.YYYY_MM_DD_HH_MM_SS);
+
+            attrCache.computeIfAbsent(device.getDeviceCode(), k -> new ConcurrentHashMap<>());
+
+            // 更新缓存
+            updateCacheAfterSuccess(device, MQTT_LAST_TIME, dateTime);
+        }
+        catch (Exception e) {
+            log.error("刷新缓存消息时间失败!", e);
+        }
+    }
+
+    /**
      * 校验是否需要更新属性值
      *
      * @param jsonBody jsonBody 消息体
@@ -143,7 +171,7 @@ public abstract class MqttBaseHandler {
 
             // 获取缓存
             Map<String, String> attrMap = attrCache.computeIfAbsent(device.getDeviceCode(), k -> {
-                List<EmsObjAttrValue> attrList = objAttrValueService.selectByObjCode(getObjType(), k);
+                List<EmsObjAttrValue> attrList = objAttrValueService.selectByObjCode(device.getDeviceModel(), k);
 
                 if (CollectionUtils.isNotEmpty(attrList)) {
                     return attrList.stream().collect(
@@ -160,8 +188,8 @@ public abstract class MqttBaseHandler {
 
             // 比较属性值是否发生变化
             if (!StringUtils.equals(currentValue, cacheValue)) {
-                EmsObjAttrValue attrValue = new EmsObjAttrValue(device.getDeviceCode(), getObjType(),
-                    device.getDeviceModel(), attrKey, currentValue);
+                EmsObjAttrValue attrValue = new EmsObjAttrValue(device.getDeviceCode(), device.getDeviceModel(),
+                    attrKey, currentValue);
                 // 更新数据库
                 objAttrValueService.mergeObjAttrValue(attrValue);
                 // 更新缓存
@@ -177,20 +205,12 @@ public abstract class MqttBaseHandler {
         return flag;
     }
 
-    public void updateMsgTime(EmsDevice device, Date timeValue) {
-        try {
-            String dateTime = DateUtils.dateToString(timeValue, DateUtils.YYYY_MM_DD_HH_MM_SS);
-
-            attrCache.computeIfAbsent(device.getDeviceCode(), k -> new ConcurrentHashMap<>());
-
-            // 更新缓存
-            updateCacheAfterSuccess(device, MQTT_LAST_TIME, dateTime);
-        }
-        catch (Exception e) {
-            log.error("刷新缓存消息时间失败!", e);
-        }
-    }
-
+    /**
+     * 更新缓存值
+     * @param device 设备信息
+     * @param attrKey 属性值
+     * @param newValue
+     */
     public void updateCacheAfterSuccess(EmsDevice device, String attrKey, String newValue) {
         attrCache.computeIfPresent(device.getDeviceCode(), (k, attrMap) -> {
             attrMap.put(attrKey, newValue);
@@ -221,7 +241,6 @@ public abstract class MqttBaseHandler {
     protected EmsObjAbilityCallLog saveCallLog(AbilityPayload abilityParam, long sendTime, int callStatus) {
         EmsObjAbilityCallLog objAbilityCallLog = new EmsObjAbilityCallLog();
         objAbilityCallLog.setObjCode(abilityParam.getObjCode());
-        objAbilityCallLog.setObjType(abilityParam.getObjType());
         objAbilityCallLog.setModelCode(abilityParam.getModeCode());
         objAbilityCallLog.setAbilityKey(abilityParam.getAbilityKey());
         objAbilityCallLog.setCallTime(new Date(sendTime));
@@ -238,10 +257,10 @@ public abstract class MqttBaseHandler {
         objAbilityCallLogService.updateLog(objAbilityCallLog);
     }
 
-    protected void saveReportLog(String objCode, int objType, String msgDesc, String payload) {
+    protected void saveReportLog(String objCode, String modelCode, String msgDesc, String payload) {
         EmsObjReportLog objReportLog = new EmsObjReportLog();
         objReportLog.setObjCode(objCode);
-        objReportLog.setObjType(objType);
+        objReportLog.setModelCode(modelCode);
         objReportLog.setMsgDesc(msgDesc);
         objReportLog.setReportPayload(payload);
         objReportLog.setReportTime(new Date());

+ 2 - 2
ems/ems-cloud/ems-server/src/main/java/com/ruoyi/ems/controller/EmsObjAbilityController.java

@@ -49,8 +49,8 @@ public class EmsObjAbilityController extends BaseController {
         AjaxResult ajaxResult = null;
 
         try {
-            String ret = abilityCallService.abilityCall(abilityPayload.getObjCode(), abilityPayload.getObjType(),
-                abilityPayload.getAbilityKey(), abilityPayload.getAbilityParam());
+            String ret = abilityCallService.devAbilityCall(abilityPayload.getObjCode(), abilityPayload.getAbilityKey(),
+                abilityPayload.getAbilityParam());
             ajaxResult = success(ret);
         }
         catch (BusinessException e) {

+ 40 - 1
ems/ems-cloud/ems-server/src/main/java/com/ruoyi/ems/controller/EmsObjAttrValueController.java

@@ -1,10 +1,18 @@
 package com.ruoyi.ems.controller;
 
 import com.huashe.common.domain.AjaxResult;
+import com.huashe.common.exception.Assert;
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.log.annotation.Log;
 import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.ems.domain.EmsDevice;
+import com.ruoyi.ems.domain.EmsDeviceComponent;
+import com.ruoyi.ems.domain.EmsFacs;
 import com.ruoyi.ems.domain.EmsObjAttrValue;
+import com.ruoyi.ems.enums.DevObjType;
+import com.ruoyi.ems.service.IEmsDeviceComponentService;
+import com.ruoyi.ems.service.IEmsDeviceService;
+import com.ruoyi.ems.service.IEmsFacsService;
 import com.ruoyi.ems.service.IEmsObjAttrValueService;
 import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,6 +41,15 @@ public class EmsObjAttrValueController extends BaseController {
     @Autowired
     private IEmsObjAttrValueService objAttrValueService;
 
+    @Autowired
+    private IEmsDeviceService deviceService;
+
+    @Autowired
+    private IEmsFacsService facsService;
+
+    @Autowired
+    private IEmsDeviceComponentService componentService;
+
     /**
      * 查询能源对象属性值列表
      */
@@ -84,6 +101,28 @@ public class EmsObjAttrValueController extends BaseController {
     @DeleteMapping("/deleteByObj")
     public AjaxResult removeByObj(@RequestParam(name = "objType") Integer objType,
         @RequestParam(name = "objCode") String objCode) {
-        return toAjax(objAttrValueService.deleteByObjCode(objType, objCode));
+        String modeCode = null;
+        int cnt = 0;
+
+        if (objType == DevObjType.FACS.getCode()) {
+            EmsFacs facs = facsService.selectEmsFacsByCode(objCode);
+            Assert.notNull(facs, -1, "能源设施不存在");
+            modeCode = facs.getFacsModel();
+            cnt = objAttrValueService.deleteByObjCode(modeCode, objCode);
+        }
+        else if (objType == DevObjType.DEVC.getCode()) {
+            EmsDevice device = deviceService.selectByCode(objCode);
+            Assert.notNull(device, -1, "能源设备不存在");
+            modeCode = device.getDeviceModel();
+            cnt = objAttrValueService.deleteByObjCode(modeCode, objCode);
+        }
+        else if (objType == DevObjType.COMPONENT.getCode()) {
+            EmsDeviceComponent devCompo = componentService.selectByCode(objCode);
+            Assert.notNull(devCompo, -1, "设备部件不存在");
+            modeCode = devCompo.getCompoModel();
+            cnt = objAttrValueService.deleteByObjCode(modeCode, objCode);
+        }
+
+        return toAjax(cnt);
     }
 }

+ 0 - 12
ems/ems-core/src/main/java/com/ruoyi/ems/domain/EmsObjAbilityCallLog.java

@@ -23,9 +23,6 @@ public class EmsObjAbilityCallLog extends BaseEntity
     /** 对象代码 */
     private String objCode;
 
-    /** 对象类型 */
-    private Integer objType;
-
     private String objName;
 
     private String modelCode;
@@ -70,14 +67,6 @@ public class EmsObjAbilityCallLog extends BaseEntity
         this.objCode = objCode;
     }
 
-    public Integer getObjType() {
-        return objType;
-    }
-
-    public void setObjType(Integer objType) {
-        this.objType = objType;
-    }
-
     public String getObjName() {
         return objName;
     }
@@ -163,7 +152,6 @@ public class EmsObjAbilityCallLog extends BaseEntity
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
             .append("id", getId())
             .append("objCode", getObjCode())
-            .append("objType", getObjType())
             .append("modelCode", getModelCode())
             .append("abilityKey", getAbilityKey())
             .append("callTime", getCallTime())

+ 5 - 17
ems/ems-core/src/main/java/com/ruoyi/ems/domain/EmsObjAttrValue.java

@@ -23,11 +23,6 @@ public class EmsObjAttrValue {
     private String objCode;
 
     /**
-     * 对象类型
-     */
-    private Integer objType;
-
-    /**
      * 属性标识
      */
     private String attrKey;
@@ -50,9 +45,8 @@ public class EmsObjAttrValue {
     public EmsObjAttrValue() {
     }
 
-    public EmsObjAttrValue(String objCode, Integer objType, String modelCode, String attrKey, String attrValue) {
+    public EmsObjAttrValue(String objCode, String modelCode, String attrKey, String attrValue) {
         this.objCode = objCode;
-        this.objType = objType;
         this.modelCode = modelCode;
         this.attrKey = attrKey;
         this.attrValue = attrValue;
@@ -74,14 +68,6 @@ public class EmsObjAttrValue {
         return objCode;
     }
 
-    public void setObjType(Integer objType) {
-        this.objType = objType;
-    }
-
-    public Integer getObjType() {
-        return objType;
-    }
-
     public void setAttrKey(String attrKey) {
         this.attrKey = attrKey;
     }
@@ -117,8 +103,10 @@ public class EmsObjAttrValue {
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId())
-            .append("objCode", getObjCode()).append("objType", getObjType()).append("attrKey", getAttrKey())
-            .append("attrValue", getAttrValue()).append("modelCode", getModelCode())
+            .append("objCode", getObjCode())
+            .append("attrKey", getAttrKey())
+            .append("attrValue", getAttrValue())
+            .append("modelCode", getModelCode())
             .append("updateTime", getUpdateTime()).toString();
     }
 }

+ 6 - 6
ems/ems-core/src/main/java/com/ruoyi/ems/domain/EmsObjReportLog.java

@@ -31,7 +31,7 @@ public class EmsObjReportLog extends BaseEntity {
     /**
      * 对象类型
      */
-    private Integer objType;
+    private String modelCode;
 
     /**
      * 消息描述
@@ -73,12 +73,12 @@ public class EmsObjReportLog extends BaseEntity {
         this.objName = objName;
     }
 
-    public Integer getObjType() {
-        return objType;
+    public String getModelCode() {
+        return modelCode;
     }
 
-    public void setObjType(Integer objType) {
-        this.objType = objType;
+    public void setModelCode(String modelCode) {
+        this.modelCode = modelCode;
     }
 
     public String getMsgDesc() {
@@ -110,7 +110,7 @@ public class EmsObjReportLog extends BaseEntity {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
             .append("id", getId())
             .append("objCode", getObjCode())
-            .append("objType", getObjType())
+            .append("modelCode", getModelCode())
             .append("msgDesc", getMsgDesc())
             .append("reportTime", getReportTime())
             .append("reportPayload", getReportPayload()).toString();

+ 4 - 4
ems/ems-core/src/main/java/com/ruoyi/ems/mapper/EmsObjAttrValueMapper.java

@@ -31,11 +31,11 @@ public interface EmsObjAttrValueMapper {
     /**
      * 查询能源对象属性值列表
      *
-     * @param objType 对象类型
+     * @param modelCode 对象类型
      * @param objCode 对象代码
      * @return 能源对象属性值集合
      */
-    List<EmsObjAttrValue> selectByObjCode(@Param("objType") Integer objType, @Param("objCode") String objCode);
+    List<EmsObjAttrValue> selectByObjCode(@Param("modelCode") String modelCode, @Param("objCode") String objCode);
 
     /**
      * 新增能源对象属性值
@@ -56,11 +56,11 @@ public interface EmsObjAttrValueMapper {
     /**
      * 删除能源对象属性值
      *
-     * @param objType 对象类
+     * @param modelCode 对象模
      * @param objCode 对象代码
      * @return 结果
      */
-    int deleteByObjCode(@Param("objType") Integer objType, @Param("objCode") String objCode);
+    int deleteByObjCode(@Param("modelCode") String modelCode, @Param("objCode") String objCode);
 
     /**
      * 删除能源对象属性值

+ 0 - 13
ems/ems-core/src/main/java/com/ruoyi/ems/model/AbilityPayload.java

@@ -26,11 +26,6 @@ public class AbilityPayload {
     private String objCode;
 
     /**
-     * 对象类型
-     */
-    private Integer objType;
-
-    /**
      * 模型代码
      */
     private String modeCode;
@@ -53,14 +48,6 @@ public class AbilityPayload {
         this.objCode = objCode;
     }
 
-    public Integer getObjType() {
-        return objType;
-    }
-
-    public void setObjType(Integer objType) {
-        this.objType = objType;
-    }
-
     public String getModeCode() {
         return modeCode;
     }

+ 17 - 1
ems/ems-core/src/main/java/com/ruoyi/ems/service/IAbilityCallService.java

@@ -20,5 +20,21 @@ package com.ruoyi.ems.service;
  * @since [产品/模块版本]
  */
 public interface IAbilityCallService {
-    String abilityCall(String objCode, int objType, String abilityKey, String param);
+    /**
+     * 设备能力调用
+     * @param objCode 设备编码
+     * @param abilityKey 能力键
+     * @param param 参数
+     * @return 返回结果
+     */
+    String devAbilityCall(String objCode, String abilityKey, String param);
+
+    /**
+     * 设施能力调用
+     * @param objCode 设备编码
+     * @param abilityKey 能力键
+     * @param param 参数
+     * @return 返回结果
+     */
+    String facsAbilityCall(String objCode, String abilityKey, String param);
 }

+ 4 - 4
ems/ems-core/src/main/java/com/ruoyi/ems/service/IEmsObjAttrValueService.java

@@ -30,11 +30,11 @@ public interface IEmsObjAttrValueService {
     /**
      * 查询能源对象属性值列表
      *
-     * @param objType 对象类型
+     * @param modelCode 对象类型
      * @param objCode 对象代码
      * @return 能源对象属性值集合
      */
-    List<EmsObjAttrValue> selectByObjCode(Integer objType, String objCode);
+    List<EmsObjAttrValue> selectByObjCode(String modelCode, String objCode);
 
     /**
      * 新增能源对象属性值
@@ -71,9 +71,9 @@ public interface IEmsObjAttrValueService {
     /**
      * 删除能源对象属性值
      *
-     * @param objType 对象类
+     * @param modelCode 对象模
      * @param objCode 对象代码
      * @return 结果
      */
-    int deleteByObjCode(Integer objType, String objCode);
+    int deleteByObjCode(String modelCode, String objCode);
 }

+ 15 - 16
ems/ems-core/src/main/java/com/ruoyi/ems/service/impl/AbilityCallServiceImpl.java

@@ -57,14 +57,14 @@ public class AbilityCallServiceImpl implements IAbilityCallService {
     private IEmsObjModelService objModelService;
 
     @Override
-    public String abilityCall(String objCode, int objType, String abilityKey, String param) {
+    public String devAbilityCall(String objCode, String abilityKey, String param) {
         String ret = null;
 
         try {
             Assert.notNull(objCode, -1, "对象代码code不能为空");
             Assert.notNull(abilityKey, -1, "设备模型能力key不能为空");
 
-            String modeCode = getModeCode(objCode, objType);
+            String modeCode = getDevModeCode(objCode);
 
             EmsObjModel objModel = objModelService.selectByModelCode(modeCode);
             Assert.notNull(objModel, -1, "设备模型(" + modeCode + ")不存在");
@@ -77,7 +77,6 @@ public class AbilityCallServiceImpl implements IAbilityCallService {
             AbilityPayload payload = new AbilityPayload();
             payload.setObjCode(objCode);
             payload.setModeCode(modeCode);
-            payload.setObjType(objType);
             payload.setAbilityKey(abilityKey);
             payload.setAbilityParam(param);
             String jsonBody = JSON.toJSONString(payload);
@@ -99,22 +98,22 @@ public class AbilityCallServiceImpl implements IAbilityCallService {
         return ret;
     }
 
-    private String getModeCode(String objCode, int objType) {
-        String modeCode = null;
-
-        if (objType == 2) {
-            // 设备验证
-            EmsDevice device = deviceService.selectByCode(objCode);
-            Assert.notNull(device, -1, "设备不存在");
-            Assert.isTrue(null != device.getDeviceStatus() && device.getDeviceStatus() == 1, -1, "设备不在线");
+    @Override
+    public String facsAbilityCall(String objCode, String abilityKey, String param) {
+        // TODO: 暂不支持
+        throw new UnsupportedOperationException("暂不支持");
+    }
 
-            // 设备模型匹配
-            Assert.notNull(device.getDeviceModel(), -1, "设备未关联模型能力");
+    private String getDevModeCode(String objCode) {
+        // 设备验证
+        EmsDevice device = deviceService.selectByCode(objCode);
+        Assert.notNull(device, -1, "设备不存在");
+        Assert.isTrue(null != device.getDeviceStatus() && device.getDeviceStatus() == 1, -1, "设备不在线");
 
-            modeCode = device.getDeviceModel();
-        }
+        // 设备模型匹配
+        Assert.notNull(device.getDeviceModel(), -1, "设备未关联模型能力");
 
-        return modeCode;
+        return device.getDeviceModel();
     }
 
     private String execPost(String url, String jsonBody) {

+ 5 - 5
ems/ems-core/src/main/java/com/ruoyi/ems/service/impl/EmsObjAttrValueServiceImpl.java

@@ -42,8 +42,8 @@ public class EmsObjAttrValueServiceImpl implements IEmsObjAttrValueService {
     }
 
     @Override
-    public List<EmsObjAttrValue> selectByObjCode(Integer objType, String objCode) {
-        return objAttrValueMapper.selectByObjCode(objType, objCode);
+    public List<EmsObjAttrValue> selectByObjCode(String modelCode, String objCode) {
+        return objAttrValueMapper.selectByObjCode(modelCode, objCode);
     }
 
     /**
@@ -60,7 +60,7 @@ public class EmsObjAttrValueServiceImpl implements IEmsObjAttrValueService {
     @Override
     public int insertBatch(List<EmsObjAttrValue> list) {
         EmsObjAttrValue objAttrValue = list.get(0);
-        objAttrValueMapper.deleteByObjCode(objAttrValue.getObjType(), objAttrValue.getObjCode());
+        objAttrValueMapper.deleteByObjCode(objAttrValue.getModelCode(), objAttrValue.getObjCode());
         return objAttrValueMapper.insertBatch(list);
     }
 
@@ -87,7 +87,7 @@ public class EmsObjAttrValueServiceImpl implements IEmsObjAttrValueService {
     }
 
     @Override
-    public int deleteByObjCode(Integer objType, String objCode) {
-        return objAttrValueMapper.deleteByObjCode(objType, objCode);
+    public int deleteByObjCode(String modelCode, String objCode) {
+        return objAttrValueMapper.deleteByObjCode(modelCode, objCode);
     }
 }

+ 13 - 18
ems/ems-core/src/main/resources/mapper/ems/EmsObjAbilityCallLogMapper.xml

@@ -7,7 +7,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="com.ruoyi.ems.domain.EmsObjAbilityCallLog" id="objAbilityCallLogResult">
         <result property="id"    column="id"    />
         <result property="objCode"    column="obj_code"    />
-        <result property="objType"    column="obj_type"    />
         <result property="objName"    column="obj_name"    />
         <result property="modelCode"    column="model_code"    />
         <result property="modelName"    column="model_name"    />
@@ -23,26 +22,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <sql id="selectList">
         select l.id, l.obj_code,
                CASE
-                   WHEN l.obj_type = 1 THEN f.facs_name
-                   WHEN l.obj_type = 2 THEN d.device_name
+                   WHEN m.obj_type = 1 THEN f.facs_name
+                   WHEN m.obj_type = 2 THEN d.device_name
                    END as obj_name,
-               l.obj_type, l.model_code, m.model_name, l.ability_key, a.ability_name, l.call_time, l.call_status from adm_ems_obj_ability_call_log l
-        left join adm_ems_facs f on l.obj_code = f.facs_code and l.obj_type = 1
-        left join adm_ems_device d on l.obj_code = d.device_code and l.obj_type = 2
-        left join adm_ems_obj_model m on l.model_code = m.model_code and l.obj_type = m.obj_type
+               l.model_code, m.model_name, l.ability_key, a.ability_name, l.call_time, l.call_status from adm_ems_obj_ability_call_log l
+        left join adm_ems_obj_model m on l.model_code = m.model_code
+        left join adm_ems_facs f on l.obj_code = f.facs_code and m.obj_type = 1
+        left join adm_ems_device d on l.obj_code = d.device_code and m.obj_type = 2
         left join adm_ems_obj_ability a on l.ability_key = a.ability_key
     </sql>
 
     <sql id="selectDetail">
         select l.id, l.obj_code,
                case
-                   when l.obj_type = 1 then f.facs_name
-                   when l.obj_type = 2 then d.device_name
-                   end as obj_name,
-               l.obj_type, l.model_code, m.model_name, l.ability_key, a.ability_name, l.call_time, l.call_status, l.call_payload, l.res_time, l.res_payload from adm_ems_obj_ability_call_log l
-        left join adm_ems_facs f on l.obj_code = f.facs_code and l.obj_type = 1
-        left join adm_ems_device d on l.obj_code = d.device_code and l.obj_type = 2
-        left join adm_ems_obj_model m on l.model_code = m.model_code and l.obj_type = m.obj_type
+                   WHEN m.obj_type = 1 THEN f.facs_name
+                   WHEN m.obj_type = 2 THEN d.device_name
+                   END as obj_name,
+               l.model_code, m.model_name, l.ability_key, a.ability_name, l.call_time, l.call_status, l.call_payload, l.res_time, l.res_payload from adm_ems_obj_ability_call_log l
+        left join adm_ems_obj_model m on l.model_code = m.model_code
+        left join adm_ems_facs f on l.obj_code = f.facs_code and m.obj_type = 1
+        left join adm_ems_device d on l.obj_code = d.device_code and m.obj_type = 2
         left join adm_ems_obj_ability a on l.ability_key = a.ability_key
     </sql>
 
@@ -55,7 +54,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectList"/>
         <where>  
             <if test="objCode != null  and objCode != ''"> and l.obj_code = #{objCode}</if>
-            <if test="objType != null "> and l.obj_type = #{objType}</if>
             <if test="modelCode != null  and modelCode != ''"> and l.model_code = #{modelCode}</if>
             <if test="abilityKey != null  and abilityKey != ''"> and l.ability_key = #{abilityKey}</if>
             <if test="callStatus != null "> and l.call_status = #{callStatus}</if>
@@ -69,7 +67,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         insert into adm_ems_obj_ability_call_log
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="objCode != null and objCode != ''">obj_code,</if>
-            <if test="objType != null">obj_type,</if>
             <if test="modelCode != null and modelCode != ''">model_code,</if>
             <if test="abilityKey != null and abilityKey != ''">ability_key,</if>
             <if test="callTime != null">call_time,</if>
@@ -80,7 +77,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="objCode != null and objCode != ''">#{objCode},</if>
-            <if test="objType != null">#{objType},</if>
             <if test="modelCode != null and modelCode != ''">#{modelCode},</if>
             <if test="abilityKey != null and abilityKey != ''">#{abilityKey},</if>
             <if test="callTime != null">#{callTime},</if>
@@ -95,7 +91,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         update adm_ems_obj_ability_call_log
         <trim prefix="SET" suffixOverrides=",">
             <if test="objCode != null and objCode != ''">obj_code = #{objCode},</if>
-            <if test="objType != null">obj_type = #{objType},</if>
             <if test="modelCode != null and modelCode != ''">model_code = #{modelCode},</if>
             <if test="abilityKey != null and abilityKey != ''">ability_key = #{abilityKey},</if>
             <if test="callTime != null">call_time = #{callTime},</if>

+ 3 - 4
ems/ems-core/src/main/resources/mapper/ems/EmsObjAttrMapper.xml

@@ -52,11 +52,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                select
                   attr_key, attr_value, update_time
                from adm_ems_obj_attr_value
-               where model_code = #{modelCode} and obj_type = #{objType} and obj_code = #{objCode}
+               where model_code = #{modelCode} and obj_code = #{objCode}
             ) v on a.attr_key = v.attr_key
-        left join
-            adm_ems_obj_attr_enum e
-           on a.model_code = e.model_code and a.attr_key = e.attr_key and v.attr_value = e.attr_value
+        join adm_ems_obj_model m on a.model_code = m.model_code and m.obj_type = #{objType}
+        left join adm_ems_obj_attr_enum e on a.model_code = e.model_code and a.attr_key = e.attr_key and v.attr_value = e.attr_value
         WHERE a.model_code = #{modelCode}
         order by attr_group, attr_name
     </select>

+ 6 - 10
ems/ems-core/src/main/resources/mapper/ems/EmsObjAttrValueMapper.xml

@@ -6,23 +6,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     
     <resultMap type="com.ruoyi.ems.domain.EmsObjAttrValue" id="objAttrValueResult">
         <result property="id"    column="id"    />
+        <result property="modelCode"    column="model_code"    />
         <result property="objCode"    column="obj_code"    />
-        <result property="objType"    column="obj_type"    />
         <result property="attrKey"    column="attr_key"    />
         <result property="attrValue"    column="attr_value"    />
-        <result property="modelCode"    column="model_code"    />
         <result property="updateTime"    column="update_time"    />
     </resultMap>
 
     <sql id="selectObjAttrValueVo">
-        select id, obj_code, obj_type, attr_key, attr_value, model_code, update_time from adm_ems_obj_attr_value
+        select id, model_code, obj_code, attr_key, attr_value, update_time from adm_ems_obj_attr_value
     </sql>
 
     <select id="selectObjAttrValueList" parameterType="com.ruoyi.ems.domain.EmsObjAttrValue" resultMap="objAttrValueResult">
         <include refid="selectObjAttrValueVo"/>
         <where>  
             <if test="objCode != null  and objCode != ''"> and obj_code = #{objCode}</if>
-            <if test="objType != null "> and obj_type = #{objType}</if>
             <if test="attrKey != null  and attrKey != ''"> and attr_key = #{attrKey}</if>
             <if test="modelCode != null  and modelCode != ''"> and model_code = #{modelCode}</if>
         </where>
@@ -30,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectByObjCode" resultMap="objAttrValueResult">
         <include refid="selectObjAttrValueVo"/>
-        where obj_type = #{objType} and obj_code = #{objCode}
+        where model_code = #{modelCode} and obj_code = #{objCode}
     </select>
 
     <select id="selectObjAttrValueById" parameterType="Long" resultMap="objAttrValueResult">
@@ -42,14 +40,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         replace into adm_ems_obj_attr_value
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="objCode != null and objCode != ''">obj_code,</if>
-            <if test="objType != null">obj_type,</if>
             <if test="modelCode != null">model_code,</if>
             <if test="attrKey != null and attrKey != ''">attr_key,</if>
             <if test="attrValue != null">attr_value,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="objCode != null and objCode != ''">#{objCode},</if>
-            <if test="objType != null">#{objType},</if>
             <if test="modelCode != null">#{modelCode},</if>
             <if test="attrKey != null and attrKey != ''">#{attrKey},</if>
             <if test="attrValue != null">#{attrValue},</if>
@@ -57,10 +53,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <insert id="insertBatch" parameterType="java.util.List" >
-        insert into adm_ems_obj_attr_value (obj_code, obj_type, model_code, attr_key, attr_value)
+        insert into adm_ems_obj_attr_value (obj_code, model_code, attr_key, attr_value)
         values
         <foreach collection="list" item="item" index="index" separator=",">
-            (#{item.objCode}, #{item.objType},  #{item.modelCode}, #{item.attrKey}, #{item.attrValue})
+            (#{item.objCode}, #{item.modelCode}, #{item.attrKey}, #{item.attrValue})
         </foreach>
     </insert>
 
@@ -69,7 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteByObjCode" >
-        delete from adm_ems_obj_attr_value where obj_type = #{objType} and obj_code = #{objCode}
+        delete from adm_ems_obj_attr_value where model_code = #{modelCode} and obj_code = #{objCode}
     </delete>
 
     <delete id="deleteObjAttrValueByIds" parameterType="String">

+ 29 - 19
ems/ems-core/src/main/resources/mapper/ems/EmsObjReportLogMapper.xml

@@ -5,43 +5,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.ruoyi.ems.mapper.EmsObjReportLogMapper">
     
     <resultMap type="com.ruoyi.ems.domain.EmsObjReportLog" id="objLogResult">
-        <result property="id"    column="id"    />
-        <result property="objCode"    column="obj_code"    />
-        <result property="objName"    column="obj_name"    />
-        <result property="objType"    column="obj_type"    />
-        <result property="msgDesc"    column="msg_desc"    />
-        <result property="reportPayload"    column="report_payload"    />
-        <result property="reportTime"    column="report_time"    />
+        <result property="id"             column="id"    />
+        <result property="objCode"        column="obj_code"    />
+        <result property="objName"        column="obj_name"    />
+        <result property="modelCode"      column="model_code"    />
+        <result property="msgDesc"        column="msg_desc"    />
+        <result property="reportPayload"  column="report_payload"    />
+        <result property="reportTime"     column="report_time"    />
     </resultMap>
 
     <sql id="selectList">
         select l.id, l.obj_code,
                CASE
-                   WHEN l.obj_type = 1 THEN f.facs_name
-                   WHEN l.obj_type = 2 THEN d.device_name
+                   WHEN m.obj_type = 1 THEN f.facs_name
+                   WHEN m.obj_type = 2 THEN d.device_name
                    END as obj_name,
-               l.obj_type, l.msg_desc, l.report_time
+               l.model_code, l.msg_desc, l.report_time
         from adm_ems_obj_report_log l
-          left join adm_ems_facs f on l.obj_code = f.facs_code and l.obj_type = 1
-          left join adm_ems_device d on l.obj_code = d.device_code and l.obj_type = 2
+                 left join adm_ems_obj_model m on l.model_code = m.model_code
+                 left join adm_ems_facs f on l.obj_code = f.facs_code and m.obj_type = 1
+                 left join adm_ems_device d on l.obj_code = d.device_code and m.obj_type = 2
     </sql>
 
     <sql id="selectDetail">
-        select id, obj_code, obj_type, msg_desc, report_time, report_payload from adm_ems_obj_report_log
+        select l.id, l.obj_code,
+               CASE
+                   WHEN m.obj_type = 1 THEN f.facs_name
+                   WHEN m.obj_type = 2 THEN d.device_name
+                   END as obj_name,
+               l.model_code, l.msg_desc, l.report_time, l.report_payload
+        from adm_ems_obj_report_log l
+                 left join adm_ems_obj_model m on l.model_code = m.model_code
+                 left join adm_ems_facs f on l.obj_code = f.facs_code and m.obj_type = 1
+                 left join adm_ems_device d on l.obj_code = d.device_code and m.obj_type = 2
     </sql>
 
     <select id="selectLogById" parameterType="java.lang.Long" resultMap="objLogResult">
         <include refid="selectDetail"/>
-        where id = #{id}
+        where l.id = #{id}
     </select>
 
     <select id="selectLog" parameterType="com.ruoyi.ems.domain.EmsObjReportLog" resultMap="objLogResult">
         <include refid="selectList"/>
         <where>  
-            <if test="objCode != null  and objCode != ''"> and obj_code = #{objCode}</if>
-            <if test="objType != null "> and obj_type = #{objType}</if>
+            <if test="objCode != null  and objCode != ''"> and l.obj_code = #{objCode}</if>
+            <if test="modelCode != null and modelCode != ''"> and l.model_code = #{modelCode}</if>
             <if test="startRecTime != null  and startRecTime != '' and endRecTime != null and endRecTime !=''">
-                and report_time between #{startRecTime} and #{endRecTime}
+                and l.report_time between #{startRecTime} and #{endRecTime}
             </if>
         </where>
     </select>
@@ -50,14 +60,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         insert into adm_ems_obj_report_log
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="objCode != null and objCode != ''">obj_code,</if>
-            <if test="objType != null">obj_type,</if>
+            <if test="modelCode != null and modelCode != ''">model_code,</if>
             <if test="msgDesc != null and msgDesc != ''">msg_desc,</if>
             <if test="reportTime != null">report_time,</if>
             <if test="reportPayload != null">report_payload,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="objCode != null and objCode != ''">#{objCode},</if>
-            <if test="objType != null">#{objType},</if>
+            <if test="modelCode != null and modelCode != ''">#{modelCode},</if>
             <if test="msgDesc != null and msgDesc != ''">#{msgDesc},</if>
             <if test="reportTime != null">#{reportTime},</if>
             <if test="reportPayload != null">#{reportPayload},</if>

+ 12 - 12
ems/sql/ems_init_data.sql

@@ -288,18 +288,18 @@ INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_group`, `attr_key`, `attr_na
 
 
 -- 对象属性DEMO数据
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'current', '0.050', '2025-03-05 16:07:36');
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'energy', '421.787', '2025-03-05 16:02:36');
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'iccid', '898604E6192390306801', '2025-03-05 15:51:00');
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'key', '1', '2025-03-05 15:57:59');
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'keyLock', '0', '2025-03-05 15:51:00');
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'onState', '2', '2025-03-05 15:51:00');
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'power', '5.108', '2025-03-05 16:07:36');
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'resetLock', '0', '2025-03-05 15:51:00');
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'signal', '31', '2025-03-05 15:51:00');
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'timerEnable', '1', '2025-03-05 15:51:00');
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'timerInterval', '300', '2025-03-05 15:51:00');
-INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 2, 'M_W2_QF_GEEKOPEN', 'version', '1.0.1', '2025-03-05 15:51:00');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'current', '0.050', '2025-03-05 16:07:36');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'energy', '421.787', '2025-03-05 16:02:36');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'iccid', '898604E6192390306801', '2025-03-05 15:51:00');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'key', '1', '2025-03-05 15:57:59');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'keyLock', '0', '2025-03-05 15:51:00');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'onState', '2', '2025-03-05 15:51:00');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'power', '5.108', '2025-03-05 16:07:36');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'resetLock', '0', '2025-03-05 15:51:00');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'signal', '31', '2025-03-05 15:51:00');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'timerEnable', '1', '2025-03-05 15:51:00');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'timerInterval', '300', '2025-03-05 15:51:00');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `model_code`, `attr_key`, `attr_value`, `update_time`) VALUES ('864142073640059', 'M_W2_QF_GEEKOPEN', 'version', '1.0.1', '2025-03-05 15:51:00');
 
 -- 对象属性值枚举
 INSERT INTO `adm_ems_obj_attr_enum` (`model_code`, `attr_key`, `attr_value`, `attr_value_name`) VALUES ('M_W2_QF_GEEKOPEN', 'onState', '1', '断开');

+ 5 - 7
ems/sql/ems_server.sql

@@ -625,13 +625,12 @@ drop table if exists adm_ems_obj_attr_value;
 create table adm_ems_obj_attr_value  (
   `id`              bigint(20)      not null auto_increment      comment '序号',
   `obj_code`        varchar(64)     not null                     comment '对象代码',
-  `obj_type`        int             not null                     comment '对象类型',
   `model_code`      varchar(64)     not null                     comment '模型code',
   `attr_key`        varchar(128)    not null                     comment '属性标识',
   `attr_value`      varchar(32)     default null                 comment '属性值',
   `update_time`     datetime        default CURRENT_TIMESTAMP    ON UPDATE CURRENT_TIMESTAMP comment '更新时间',
   primary key (`id`),
-  unique key ux_ems_obj_attr_value(`obj_code`, `obj_type`, `model_code`, `attr_key`)
+  unique key ux_ems_obj_attr_value(`obj_code`, `model_code`, `attr_key`)
 ) engine=innodb auto_increment=1 comment = '能源对象属性值表';
 
 
@@ -659,16 +658,15 @@ drop table if exists adm_ems_obj_ability_call_log;
 create table adm_ems_obj_ability_call_log  (
   `id`              bigint(20)      not null auto_increment      comment '序号',
   `obj_code`        varchar(64)     not null                     comment '对象代码',
-  `obj_type`        int             not null                     comment '对象类型',
   `model_code`      varchar(64)     not null                     comment '模型code',
   `ability_key`     varchar(128)    not null                     comment '能力键',
   `call_time`       datetime        not null                     comment '调用时间',
-  `call_payload`      text            default null                 comment '调用参数',
+  `call_payload`    text            default null                 comment '调用参数',
   `call_status`     int             not null                     comment '调用状态',
   `res_time`        datetime        default null                 comment '响应时间',
   `res_payload`       text            default null                 comment '响应内容',
   primary key (`id`),
-  key i_ability_call_log(`obj_code`, `obj_type`, `ability_key`, `call_time`)
+  key i_ability_call_log(`obj_code`, `model_code`, `ability_key`, `call_time`)
 ) engine=innodb auto_increment=1 comment = '能源对象能力调用日志表';
 
 
@@ -679,12 +677,12 @@ drop table if exists adm_ems_obj_report_log;
 create table adm_ems_obj_report_log  (
   `id`              bigint(20)      not null auto_increment      comment '序号',
   `obj_code`        varchar(64)     not null                     comment '对象代码',
-  `obj_type`        int             not null                     comment '对象类型',
+  `model_code`      varchar(64)     not null                     comment '模型code',
   `msg_desc`        varchar(128)    default null                 comment '消息描述',
   `report_time`     datetime        not null                     comment '上报时间',
   `report_payload`  text            default null                 comment '上报参数',
   primary key (`id`),
-  key i_obj_report_log(`obj_code`, `obj_type`, `report_time`)
+  key i_obj_report_log(`obj_code`, `model_code`, `report_time`)
 ) engine=innodb auto_increment=1 comment = '能源对象上报日志表';