Browse Source

bug修复

learshaw 4 months ago
parent
commit
27ecc83624

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

@@ -100,10 +100,11 @@ public class GeekOpenCbHandler extends MqttBaseHandler {
         String topic = TOPIC_PREFIX + deviceCode;
         sendMqttMsg(topic, msgBody, 2, false);
 
-        // 写入日志
-        EmsObjAbilityCallLog logItem = saveCallLog(abilityParam, sendTime, 1);
-
+        // 需要监测回包的流程
         if (StringUtils.equals(type, "event") || (StringUtils.equals(type, "setting") && StringUtils.isEmpty(system))) {
+            // 写入日志
+            EmsObjAbilityCallLog logItem = saveCallLog(abilityParam, sendTime, 1);
+
             while (true) {
                 MqttCacheMsg cacheMsg = messageCache.getAndRemoveMqttMessage(messageId);
 
@@ -111,13 +112,7 @@ public class GeekOpenCbHandler extends MqttBaseHandler {
                     String receiveParam = cacheMsg.getPayload();
                     JSONObject receiveObject = JSONObject.parseObject(receiveParam);
                     callResponse = checkResult(sendObject, receiveObject);
-
-                    if (callResponse.getCode() == 0) {
-                        updateCallLog(logItem, cacheMsg, 1);
-                    }
-                    else {
-                        updateCallLog(logItem, cacheMsg, 2);
-                    }
+                    updateCallLog(logItem, cacheMsg, callResponse.getCode() == 0 ? 0:2);
 
                     break;
                 }
@@ -133,6 +128,7 @@ public class GeekOpenCbHandler extends MqttBaseHandler {
             }
         }
         else {
+            saveCallLog(abilityParam, sendTime, 0);
             callResponse = new CallResponse<>(0, "执行成功!");
         }
 

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

@@ -26,6 +26,8 @@ public class EmsObjReportLog extends BaseEntity {
      */
     private String objCode;
 
+    private String objName;
+
     /**
      * 对象类型
      */
@@ -63,6 +65,14 @@ public class EmsObjReportLog extends BaseEntity {
         this.objCode = objCode;
     }
 
+    public String getObjName() {
+        return objName;
+    }
+
+    public void setObjName(String objName) {
+        this.objName = objName;
+    }
+
     public Integer getObjType() {
         return objType;
     }

+ 10 - 1
ems/ems-core/src/main/resources/mapper/ems/EmsObjReportLogMapper.xml

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <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"    />
@@ -14,7 +15,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectList">
-        select id, obj_code, obj_type, msg_desc, report_time from adm_ems_obj_report_log
+        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.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
     </sql>
 
     <sql id="selectDetail">

+ 7 - 7
ems/sql/ems_init_data.sql

@@ -320,12 +320,12 @@ INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`,
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'keyLock-0', '按键锁定-关闭', '设置按键控制锁-关闭', '{\"type\":\"setting\",\"keyLock\":0}', 1);
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'keyLock-1', '按键锁定-开启', '设置按键控制锁-开启', '{\"type\":\"setting\",\"keyLock\":1}', 1);
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'restart', '软重启', '设备软重启', '{\"type\":\"setting\",\"system\":\"restart\"}', 0);
-INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'settAutoReport', '设置电量信息定时上报', '开关(timerEnable:0:关闭上报 1:开启上报) 时间间隔(timerInterval: 上报时间间隔 单位秒', '{\"type\":\"setting\",\"timerEnable\":1,\"timerInterval\":10}', 0);
+INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'settAutoReport', '设置电量信息定时上报', '设置电量信息定时上报(timerEnable:0:关闭上报 1:开启上报) timerInterval: 上报时间间隔单位秒', '{\"type\":\"setting\",\"timerEnable\":1,\"timerInterval\":3600}', 0);
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'setReset', '重置/恢复出厂', '设备恢复出厂设置固定传\"reset\"', '{\"type\":\"setting\",\"system\":\"reset\"}', 0);
-INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'setOnState', '设置设备上电默认状态', '0:记忆;1:关闭,即断开;2:开启,即通电,默认=1', '{\"type\":\"setting\",\"onState\":1}', 0);
-INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'syncInfo', '同步基础信息', '获取设备状态信息', '{\"type\":\"info\"}', 0);
+INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'setOnState', '设置默认上电状态', '0:记忆;1:关闭,即断开;2:开启,即通电,默认=1', '{\"type\":\"setting\",\"onState\":1}', 0);
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'syncProtocol', '同步设备通讯信息', '获取设备通讯信息', '{\"type\":\"protocol\"}', 0);
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'syncStatistic', '同步设备电量信息', '获取设备电量信息', '{\"type\":\"statistic\"}', 1);
+INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`, `hidden_flag`) VALUES ('M_W2_QF_GEEKOPEN', 'syncInfo', '同步基础信息', '获取设备状态信息', '{\"type\":\"info\"}', 0);
 
 -- 对象事件DEMO数据
 INSERT INTO `adm_ems_obj_event` (`model_code`, `event_type`, `event_key`, `event_name`, `event_desc`, `event_code`, `ext_event_code`) VALUES ('M_W2', 2, 'overload', '过载', '功率过载', 'e-gy-0001', '0x0001');
@@ -591,12 +591,12 @@ INSERT INTO `adm_meter_device` (`area_code`, `device_code`, `device_name`, `loca
 INSERT INTO `adm_meter_device` (`area_code`, `device_code`, `device_name`, `location_ref`, `location`, `meter_cls`, `obj_tag`, `col_cycle`, `col_mode`, `magnification`, `spec_desc`) VALUES ('321283124S3002', 'J-D-N-G001', '南区/广场照明', '321283124S300201', '南区广场1#配电柜', 45, 0, 4, 0, 1, '智能表');
 
 -- 智能断路器
-INSERT INTO `adm_meter_device` (`area_code`, `device_code`, `device_name`, `device_location`, `meter_cls`, `obj_tag`, `col_cycle`, `col_mode`, `magnification`, `spec_desc`) VALUES ('321283124S3001', 'J-D-B-864142073640059', '智能断路器', '华设C3-开水间', 45, 0, 4, 0, 1, '智能断路器');
+INSERT INTO `adm_meter_device` (`area_code`, `device_code`, `device_name`, `location_ref`, `location`, `meter_cls`, `obj_tag`, `col_cycle`, `col_mode`, `magnification`, `spec_desc`) VALUES ('321283124S3001', 'J-D-B-864142073640059', '智能断路器', '321283124S3001','华设C3-开水间', 45, 0, 4, 0, 1, '智能断路器');
 
 -- 水表
-INSERT INTO `adm_meter_device` (`area_code`, `device_code`, `device_name`, `device_location`, `meter_cls`, `obj_tag`, `col_cycle`, `col_mode`, `magnification`, `spec_desc`) VALUES ('321283124S3001', 'J-S-B-02', '北区/综合楼B-102', '北区综合楼后院1号井', 70, 0, 4, 1, 1, '直采表');
-INSERT INTO `adm_meter_device` (`area_code`, `device_code`, `device_name`, `device_location`, `meter_cls`, `obj_tag`, `col_cycle`, `col_mode`, `magnification`, `spec_desc`) VALUES ('321283124S3001', 'J-S-B-01', '北区/综合楼盥洗室', '北区综合楼后院1号井', 70, 0, 4, 0, 1, '直采表');
-INSERT INTO `adm_meter_device` (`area_code`, `device_code`, `device_name`, `device_location`, `meter_cls`, `obj_tag`, `col_cycle`, `col_mode`, `magnification`, `spec_desc`) VALUES ('321283124S3002', 'J-S-N-01', '南区/综合楼盥洗室', '南区综合楼后院1号井', 70, 0, 4, 0, 1, '直采表');
+INSERT INTO `adm_meter_device` (`area_code`, `device_code`, `device_name`, `location_ref`, `location`, `meter_cls`, `obj_tag`, `col_cycle`, `col_mode`, `magnification`, `spec_desc`) VALUES ('321283124S3001', 'J-S-B-02', '北区/综合楼B-102', '321283124S3001', '北区综合楼后院1号井', 70, 0, 4, 1, 1, '直采表');
+INSERT INTO `adm_meter_device` (`area_code`, `device_code`, `device_name`, `location_ref`, `location`, `meter_cls`, `obj_tag`, `col_cycle`, `col_mode`, `magnification`, `spec_desc`) VALUES ('321283124S3001', 'J-S-B-01', '北区/综合楼盥洗室', '321283124S3001', '北区综合楼后院1号井', 70, 0, 4, 0, 1, '直采表');
+INSERT INTO `adm_meter_device` (`area_code`, `device_code`, `device_name`, `location_ref`, `location`, `meter_cls`, `obj_tag`, `col_cycle`, `col_mode`, `magnification`, `spec_desc`) VALUES ('321283124S3002', 'J-S-N-01', '南区/综合楼盥洗室', '321283124S3001', '南区综合楼后院1号井', 70, 0, 4, 0, 1, '直采表');
 
 -- 表计绑定关系
 INSERT INTO `adm_meter_boundary_rel` (`obj_type`, `boundary_obj`, `meter_cls`, `meter_device`) VALUES (1, 'B-101', 45, 'J-D-B-101');