From 5f9bf98779e2c3e69324d75849efdda00868da4f Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期五, 29 五月 2026 15:45:47 +0800
Subject: [PATCH] 新增智能电表、空调管理

---
 admin/src/views/business/ywconditionermeter.vue                                                                |   26 ++++++--
 server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwConditionerMeter.java              |    6 ++
 server/visits/admin_timer/src/main/resources/bootstrap.yml                                                     |    2 
 server/visits/dmvisit_admin/src/main/resources/bootstrap.yml                                                   |    2 
 server/db/yw_conditioner_module.sql                                                                            |    3 +
 server/visits/dmvisit_service/src/main/java/com/doumee/core/conditoner/model/response/MeterDbInfoResponse.java |    3 +
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ConditionerBizServiceImpl.java    |   69 +++++++++++++++++-----
 server/visits/admin_timer/src/main/java/com/doumee/api/InterfaceLogTimerController.java                        |    1 
 server/system_timer/src/main/resources/bootstrap.yml                                                           |    2 
 server/db/business.yw_conditioner_meter.dlj_mac.sql                                                            |   32 ++++++++++
 10 files changed, 117 insertions(+), 29 deletions(-)

diff --git a/admin/src/views/business/ywconditionermeter.vue b/admin/src/views/business/ywconditionermeter.vue
index 392aa24..0e7ceb5 100644
--- a/admin/src/views/business/ywconditionermeter.vue
+++ b/admin/src/views/business/ywconditionermeter.vue
@@ -27,14 +27,20 @@
         <el-table-column prop="dbName" label="鐢佃〃鍚嶇О" min-width="130" align="center" show-overflow-tooltip />
         <el-table-column prop="dbAdr" label="琛ㄥ湴鍧�" min-width="120" align="center" show-overflow-tooltip />
         <el-table-column prop="wgMac" label="缃戝叧MAC" min-width="140" align="center" show-overflow-tooltip />
+        <el-table-column label="澶氳仈鏈篗AC" min-width="180" align="center" show-overflow-tooltip>
+          <template slot-scope="{ row }">{{ formatNum(row.dljMac) }}</template>
+        </el-table-column>
+        <el-table-column label="娉㈢壒鐜�" min-width="80" align="center">
+          <template slot-scope="{ row }">{{ formatNum(row.btl) }}</template>
+        </el-table-column>
+        <el-table-column label="鏄惁鏍¢獙" min-width="100" align="center">
+          <template slot-scope="{ row }">{{ formatJy(row.jy) }}</template>
+        </el-table-column>
         <el-table-column prop="dbBb" label="鍙樻瘮" min-width="80" align="center" />
         <el-table-column prop="xyName" label="鍗忚" min-width="100" align="center" show-overflow-tooltip />
         <el-table-column prop="standbyShare" label="寰呮満鍒嗘憡" min-width="100" align="center" show-overflow-tooltip />
         <el-table-column prop="outdoorLoop" label="澶栨満鍥炶矾" min-width="90" align="center" />
-        <el-table-column label="鍔熺巼(kW)" min-width="100" align="center">
-          <template slot-scope="{ row }">{{ formatNum(row.powerKw) }}</template>
-        </el-table-column>
-        <el-table-column label="绱鐢甸噺" min-width="110" align="center">
+        <el-table-column label="绱鐢佃兘" min-width="110" align="center">
           <template slot-scope="{ row }">{{ formatNum(row.totalDl) }}</template>
         </el-table-column>
         <el-table-column label="鎿嶄綔" min-width="160" align="center" fixed="right">
@@ -122,6 +128,10 @@
       if (val === null || val === undefined || val === '') return '-'
       return val
     },
+    formatJy (val) {
+      if (val === null || val === undefined || val === '') return '-'
+      return Number(val) === 1 ? '1-鏍¢獙' : '0-鏃犳牎楠�'
+    },
     handleSync () {
       this.$dialog.actionConfirm('纭浠庢櫤绮剧伒骞冲彴鍚屾鍏ㄩ儴鐢佃〃鍚楋紵', '鍚屾鐢佃〃')
         .then(() => {
@@ -141,8 +151,8 @@
       this.operateType = 'energy'
       meterApi.queryEnergy(row.id)
         .then(res => {
-          this.$tip.apiSuccess(res || '鏌ョ數閲忚姹傚凡鎻愪氦')
-          this.handlePageChange()
+          this.$tip.apiSuccess(res || '鏌ョ數閲忔垚鍔�')
+          this.search()
         })
         .catch(e => this.$tip.apiFailed(e))
         .finally(() => {
@@ -155,8 +165,8 @@
       this.operateType = 'power'
       meterApi.queryPower(row.id)
         .then(res => {
-          this.$tip.apiSuccess(res || '鏌ュ姛鐜囪姹傚凡鎻愪氦')
-          this.handlePageChange()
+          this.$tip.apiSuccess(res || '鏌ュ姛鐜囨垚鍔�')
+          this.search()
         })
         .catch(e => this.$tip.apiFailed(e))
         .finally(() => {
diff --git a/server/db/business.yw_conditioner_meter.dlj_mac.sql b/server/db/business.yw_conditioner_meter.dlj_mac.sql
new file mode 100644
index 0000000..9b4808d
--- /dev/null
+++ b/server/db/business.yw_conditioner_meter.dlj_mac.sql
@@ -0,0 +1,32 @@
+-- 绌鸿皟鐢佃〃锛氬鑱旀満 MAC銆佹尝鐗圭巼銆佹牎楠屼綅
+SET @db := DATABASE();
+
+SET @sql := IF(
+  (SELECT COUNT(*) FROM information_schema.COLUMNS
+   WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_conditioner_meter' AND COLUMN_NAME = 'dlj_mac') = 0,
+  'ALTER TABLE `yw_conditioner_meter` ADD COLUMN `dlj_mac` varchar(64) DEFAULT NULL COMMENT ''澶氳仈鏈篗AC'' AFTER `xy_name`',
+  'SELECT 1'
+);
+PREPARE stmt FROM @sql;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+SET @sql := IF(
+  (SELECT COUNT(*) FROM information_schema.COLUMNS
+   WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_conditioner_meter' AND COLUMN_NAME = 'btl') = 0,
+  'ALTER TABLE `yw_conditioner_meter` ADD COLUMN `btl` int DEFAULT NULL COMMENT ''娉㈢壒鐜�'' AFTER `dlj_mac`',
+  'SELECT 1'
+);
+PREPARE stmt FROM @sql;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+SET @sql := IF(
+  (SELECT COUNT(*) FROM information_schema.COLUMNS
+   WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_conditioner_meter' AND COLUMN_NAME = 'jy') = 0,
+  'ALTER TABLE `yw_conditioner_meter` ADD COLUMN `jy` int DEFAULT NULL COMMENT ''鏄惁鏍¢獙 0鏃犳牎楠� 1鏍¢獙'' AFTER `btl`',
+  'SELECT 1'
+);
+PREPARE stmt FROM @sql;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
diff --git a/server/db/yw_conditioner_module.sql b/server/db/yw_conditioner_module.sql
index 759a21c..5bd0486 100644
--- a/server/db/yw_conditioner_module.sql
+++ b/server/db/yw_conditioner_module.sql
@@ -53,6 +53,9 @@
   `wg_id` int DEFAULT NULL,
   `xy_id` int DEFAULT NULL,
   `xy_name` varchar(128) DEFAULT NULL,
+  `dlj_mac` varchar(64) DEFAULT NULL COMMENT '澶氳仈鏈篗AC',
+  `btl` int DEFAULT NULL COMMENT '娉㈢壒鐜�',
+  `jy` int DEFAULT NULL COMMENT '鏄惁鏍¢獙 0鏃犳牎楠� 1鏍¢獙',
   `db_bb` int DEFAULT NULL COMMENT '鍙樻瘮',
   `standby_share` varchar(32) DEFAULT NULL COMMENT '寰呮満鍒嗘憡',
   `outdoor_loop` int DEFAULT NULL COMMENT '澶栨満鍥炶矾鍙�',
diff --git a/server/system_timer/src/main/resources/bootstrap.yml b/server/system_timer/src/main/resources/bootstrap.yml
index 107b53b..05a83ce 100644
--- a/server/system_timer/src/main/resources/bootstrap.yml
+++ b/server/system_timer/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: dev
+    active: pro
   application:
     name: systemTimer
     # 瀹夊叏閰嶇疆
diff --git a/server/visits/admin_timer/src/main/java/com/doumee/api/InterfaceLogTimerController.java b/server/visits/admin_timer/src/main/java/com/doumee/api/InterfaceLogTimerController.java
index e963898..2c1a76c 100644
--- a/server/visits/admin_timer/src/main/java/com/doumee/api/InterfaceLogTimerController.java
+++ b/server/visits/admin_timer/src/main/java/com/doumee/api/InterfaceLogTimerController.java
@@ -31,5 +31,4 @@
         return ApiResponse.success("寮�鍚畾鏃舵帴鍙f棩蹇楁竻鐞嗘垚鍔�");
     }
 
-
 }
diff --git a/server/visits/admin_timer/src/main/resources/bootstrap.yml b/server/visits/admin_timer/src/main/resources/bootstrap.yml
index efae338..b5b65b7 100644
--- a/server/visits/admin_timer/src/main/resources/bootstrap.yml
+++ b/server/visits/admin_timer/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: dev
+    active: pro
   application:
     name: visitsTimer
     # 瀹夊叏閰嶇疆
diff --git a/server/visits/dmvisit_admin/src/main/resources/bootstrap.yml b/server/visits/dmvisit_admin/src/main/resources/bootstrap.yml
index 9dc10e9..2df12af 100644
--- a/server/visits/dmvisit_admin/src/main/resources/bootstrap.yml
+++ b/server/visits/dmvisit_admin/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: dev
+    active: pro
   application:
     name: visitsAdmin
     # 瀹夊叏閰嶇疆
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/core/conditoner/model/response/MeterDbInfoResponse.java b/server/visits/dmvisit_service/src/main/java/com/doumee/core/conditoner/model/response/MeterDbInfoResponse.java
index 4ecb48a..a69627b 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/core/conditoner/model/response/MeterDbInfoResponse.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/core/conditoner/model/response/MeterDbInfoResponse.java
@@ -13,6 +13,9 @@
     private Integer wg_id;
     private String xy_name;
     private Integer xy_id;
+    private String dlj_mac;
+    private Integer btl;
+    private Integer jy;
     private String db_adr;
     private String db_name;
     private Integer db_bb;
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwConditionerMeter.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwConditionerMeter.java
index 2221bb7..3232084 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwConditionerMeter.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwConditionerMeter.java
@@ -36,6 +36,12 @@
     private Integer wgId;
     private Integer xyId;
     private String xyName;
+    @ApiModelProperty("澶氳仈鏈篗AC")
+    private String dljMac;
+    @ApiModelProperty("娉㈢壒鐜�")
+    private Integer btl;
+    @ApiModelProperty("鏄惁鏍¢獙 0鏃犳牎楠� 1鏍¢獙")
+    private Integer jy;
     @ApiModelProperty("鍙樻瘮")
     private Integer dbBb;
     @ApiModelProperty("寰呮満鍒嗘憡")
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ConditionerBizServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ConditionerBizServiceImpl.java
index 5e2c44f..ff922bb 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ConditionerBizServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ConditionerBizServiceImpl.java
@@ -524,23 +524,8 @@
         if (!ok) {
             throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), apiMsg(resp, "鏌ヨ澶辫触"));
         }
-        if (ACTION_QUERY_DL == actionType && resp.getData() != null) {
-            try {
-                BigDecimal dl = new BigDecimal(String.valueOf(resp.getData()));
-                meter.setTotalDl(dl);
-            } catch (Exception ignored) {
-            }
-        }
-        if (ACTION_QUERY_POWER == actionType && resp.getData() != null) {
-            try {
-                BigDecimal kw = new BigDecimal(String.valueOf(resp.getData()));
-                meter.setPowerKw(kw);
-            } catch (Exception ignored) {
-            }
-        }
-        meter.setLastSyncDate(new Date());
-        meterMapper.updateById(meter);
-        return "鏌ヨ鎴愬姛";
+        String syncMsg = syncMeters();
+        return "鏌ヨ鎴愬姛锛�" + syncMsg;
     }
 
     @Override
@@ -772,6 +757,9 @@
         if (StringUtils.isBlank(meter.getXyName())) {
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "鐢佃〃鍗忚涓虹┖锛岃鍏堝悓姝ョ數琛�");
         }
+        if (StringUtils.isBlank(meter.getDljMac())) {
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "澶氳仈鏈篗AC涓虹┖锛岃鍏堝悓姝ョ數琛�");
+        }
         DevControlRequest req = new DevControlRequest();
         req.fillSessionDefaults();
         req.setWg_mac(meter.getWgMac());
@@ -781,6 +769,9 @@
         JSONObject setVal = new JSONObject();
         setVal.put("db_bb", meter.getDbBb() != null ? meter.getDbBb() : 1);
         setVal.put("xy_name", meter.getXyName());
+        setVal.put("dlj_mac", meter.getDljMac());
+        setVal.put("btl", meter.getBtl() != null ? meter.getBtl() : 4);
+        setVal.put("jy", meter.getJy() != null ? meter.getJy() : 0);
         req.setSet_val(setVal);
         return req;
     }
@@ -837,16 +828,60 @@
         local.setWgId(item.getWg_id());
         local.setXyId(item.getXy_id());
         local.setXyName(item.getXy_name());
+        local.setDljMac(item.getDlj_mac());
+        local.setBtl(item.getBtl());
+        local.setJy(item.getJy());
         local.setDbBb(item.getDb_bb());
         local.setOutdoorLoop(item.getDb_rhd());
         local.setDbUptime(item.getDb_uptime());
         if (item.getDb_data() != null) {
             local.setDbData(JSON.toJSONString(item.getDb_data()));
+            BigDecimal energy = parseDbDataEnergy(item.getDb_data());
+            if (energy != null) {
+                local.setTotalDl(energy);
+            }
         }
         local.setLastSyncDate(now);
         local.setEditDate(now);
     }
 
+    private BigDecimal parseDbDataEnergy(Object dbData) {
+        if (dbData == null) {
+            return null;
+        }
+        if (dbData instanceof Number) {
+            return new BigDecimal(dbData.toString());
+        }
+        if (dbData instanceof String) {
+            String text = ((String) dbData).trim();
+            if (StringUtils.isBlank(text)) {
+                return null;
+            }
+            try {
+                return new BigDecimal(text);
+            } catch (Exception ignored) {
+                try {
+                    return parseDbDataEnergy(JSON.parse(text));
+                } catch (Exception ignored2) {
+                    return null;
+                }
+            }
+        }
+        if (dbData instanceof JSONObject) {
+            JSONObject obj = (JSONObject) dbData;
+            for (String key : Arrays.asList("dl", "dn", "total_dl", "totalDl", "db_data", "energy")) {
+                if (obj.containsKey(key) && obj.get(key) != null) {
+                    return parseDbDataEnergy(obj.get(key));
+                }
+            }
+            return null;
+        }
+        if (dbData instanceof Map) {
+            return parseDbDataEnergy(new JSONObject((Map<String, Object>) dbData));
+        }
+        return null;
+    }
+
     private void fillConditionerFromStatus(YwConditioner local, DeviceStatusResponse item,
                                            DeviceArchiveResponse archive, Date now) {
         local.setPlatformDevId(item.getDev_id());

--
Gitblit v1.9.3