From 3c7399c25c0f35c8aa7cb6af1935e31d1a3f0102 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期二, 02 六月 2026 17:43:50 +0800
Subject: [PATCH] 新增智能电表、空调管理

---
 admin/public/template/yw_device.xlsx                                                                  |    0 
 server/visits/dmvisit_service/src/main/java/com/doumee/dao/admin/request/DeviceImport.java            |   33 +++++++++-------
 h5/utils/config.js                                                                                    |    4 +-
 server/visits/dmvisit_admin/src/main/resources/bootstrap.yml                                          |    2 
 h5/pages/login.vue                                                                                    |    6 +-
 server/db/business.yw_device.device_num.sql                                                           |   12 ++++++
 admin/src/views/operation/components/deviceDetail.vue                                                 |    4 ++
 admin/src/components/business/OperaDeviceImportWindow.vue                                             |    2 
 admin/src/views/operation/components/deviceEdit.vue                                                   |   13 ++++++
 admin/src/views/operation/device.vue                                                                  |    1 
 server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwDevice.java               |    4 ++
 h5/manifest.json                                                                                      |    6 +-
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java |   31 +++++++++++++++
 13 files changed, 92 insertions(+), 26 deletions(-)

diff --git a/admin/public/template/yw_device.xlsx b/admin/public/template/yw_device.xlsx
index 4dda1d0..423b128 100644
--- a/admin/public/template/yw_device.xlsx
+++ b/admin/public/template/yw_device.xlsx
Binary files differ
diff --git a/admin/src/components/business/OperaDeviceImportWindow.vue b/admin/src/components/business/OperaDeviceImportWindow.vue
index 58f0daa..641e911 100644
--- a/admin/src/components/business/OperaDeviceImportWindow.vue
+++ b/admin/src/components/business/OperaDeviceImportWindow.vue
@@ -10,7 +10,7 @@
   >
     <p class="tip-warn"><i class="el-icon-warning"></i>瀵煎叆璇存槑锛�<br>
       1.璇峰厛涓嬭浇鏂囦欢妯℃澘锛屽苟鎸夌収妯℃澘瑕佹眰濉啓琛ㄦ牸鍐呭;<br>
-      2.甯�*涓哄繀濉」锛屽叧鑱旀埧婧愭牸寮忎负锛氭ゼ瀹�/妤煎眰/鎴挎簮;<br>
+      2.甯�*涓哄繀濉」锛堝惈*璁惧鏁伴噺锛夛紝鍏宠仈鎴挎簮鏍煎紡涓猴細妤煎畤/妤煎眰/鎴挎簮;<br>
       3.璁惧鍒嗙被鏍煎紡涓猴細涓�绾у垎绫�/浜岀骇鍒嗙被;<br>
     </p>
     <el-form class="demo-form-inline">
diff --git a/admin/src/views/operation/components/deviceDetail.vue b/admin/src/views/operation/components/deviceDetail.vue
index 1dcab14..862267f 100644
--- a/admin/src/views/operation/components/deviceDetail.vue
+++ b/admin/src/views/operation/components/deviceDetail.vue
@@ -23,6 +23,10 @@
             <div class="val">{{ info.name }}</div>
           </div>
           <div class="item">
+            <div class="la">璁惧鏁伴噺</div>
+            <div class="val">{{ info.deviceNum || 1 }}</div>
+          </div>
+          <div class="item">
             <div class="la">璁惧鍨嬪彿</div>
             <div class="val">{{ info.modelNo }}</div>
           </div>
diff --git a/admin/src/views/operation/components/deviceEdit.vue b/admin/src/views/operation/components/deviceEdit.vue
index f727966..83802bc 100644
--- a/admin/src/views/operation/components/deviceEdit.vue
+++ b/admin/src/views/operation/components/deviceEdit.vue
@@ -15,6 +15,11 @@
           </el-form-item>
         </div>
         <div style="width: 31%;">
+          <el-form-item label="璁惧鏁伴噺" prop="deviceNum">
+            <el-input-number v-model="param.deviceNum" :min="1" :precision="0" controls-position="right" />
+          </el-form-item>
+        </div>
+        <div style="width: 31%;">
           <el-form-item label="璁惧鍨嬪彿" prop="modelNo">
             <el-input v-model="param.modelNo" placeholder="璇疯緭鍏�" v-trim />
           </el-form-item>
@@ -187,6 +192,7 @@
       param: {
         code: '',
         name: '',
+        deviceNum: 1,
         modelNo: '',
         cateIds: '',
         userId: '',
@@ -310,7 +316,11 @@
         if (valid) {
           let fn = param.id ? updateById : create
           this.subLoading = true
-          fn(param).then(res => {
+          const payload = {
+            ...param,
+            deviceNum: !param.deviceNum || param.deviceNum < 1 ? 1 : param.deviceNum
+          }
+          fn(payload).then(res => {
             this.subLoading = false
             this.$emit('success')
             Message.success('淇濆瓨鎴愬姛')
@@ -324,6 +334,7 @@
     getDetail(id) {
       detailById(id).then(res => {
         this.param = res
+        this.param.deviceNum = res.deviceNum || 1
         this.param.rooms = [res.projectId, res.buildingId, res.floorId, res.roomId]
         console.log(this.param.rooms)
         if (res.multifileList && res.multifileList.length > 0) {
diff --git a/admin/src/views/operation/device.vue b/admin/src/views/operation/device.vue
index 767a196..2f8d8ee 100644
--- a/admin/src/views/operation/device.vue
+++ b/admin/src/views/operation/device.vue
@@ -10,6 +10,7 @@
     <el-table v-loading="loading" :data="list" stripe>
       <el-table-column prop="code" label="璁惧缂栧彿" min-width="100" show-overflow-tooltip />
       <el-table-column prop="name" label="璁惧鍚嶇О" min-width="100" show-overflow-tooltip />
+      <el-table-column prop="deviceNum" label="璁惧鏁伴噺" min-width="90" show-overflow-tooltip />
       <el-table-column prop="categoryName" label="璁惧鍒嗙被" min-width="100" show-overflow-tooltip />
       <el-table-column prop="modelNo" label="璁惧鍨嬪彿" min-width="100" show-overflow-tooltip />
       <el-table-column prop="realName" label="绠$悊鍛�" min-width="100" show-overflow-tooltip />
diff --git a/h5/manifest.json b/h5/manifest.json
index 056e3b0..63db328 100644
--- a/h5/manifest.json
+++ b/h5/manifest.json
@@ -1,6 +1,6 @@
 {
-    "name" : "laborVisitors",
-    "appid" : "__UNI__BCCF400",
+    "name" : "闃滃畞杩愮淮绯荤粺",
+    "appid" : "__UNI__E3BA820",
     "description" : "",
     "versionName" : "1.0.0",
     "versionCode" : "100",
@@ -86,7 +86,7 @@
     "quickapp" : {},
     /* 灏忕▼搴忕壒鏈夌浉鍏� */
     "mp-weixin" : {
-        "appid" : "wx4d7c10bdec51942b",
+        "appid" : "wx15dfdae9a19177f3",
         "setting" : {
             "urlCheck" : false,
             "es6" : true,
diff --git a/h5/pages/login.vue b/h5/pages/login.vue
index 134d69c..bfa42da 100644
--- a/h5/pages/login.vue
+++ b/h5/pages/login.vue
@@ -116,10 +116,10 @@
 					}
 				})
 			} else {
-				// let url = 'https://zhcg.fnwtzx.com/yunwei_h5'
+				let url = 'https://zhcg.fnwtzx.com/fn_h5'
 				// const appID = 'wx95ac1efb67f0330d'
-				let url = 'https://dmtest.ahapp.net/yunwei_h5'
-				const appID = 'wx4d7c10bdec51942b'
+								//let url = 'https://dmtest.ahapp.net/yunwei_h5'
+				const appID = 'wx15dfdae9a19177f3'
 				let uri = encodeURIComponent(url)
 				let authURL =
 					`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appID}&redirect_uri=${uri}&response_type=code&scope=snsapi_base#wechat_redirect`
diff --git a/h5/utils/config.js b/h5/utils/config.js
index 705924a..c779cdc 100644
--- a/h5/utils/config.js
+++ b/h5/utils/config.js
@@ -1,6 +1,6 @@
  // export const baseUrl = 'gateway_interface/'
-export const baseUrl = 'http://localhost:10010/gateway_interface/'
-// export const baseUrl = 'https://zhcg.fnwtzx.com/gateway_interface/'
+//export const baseUrl = 'http://localhost:10010/gateway_interface/'
+export const baseUrl = 'https://zhcg.fnwtzx.com/gateway_interface/'
 //export const baseUrl = 'https://dmtest.ahapp.net/gateway_interface/'
 
 export const uploadAvatar = `${baseUrl}visitsAdmin/cloudService/web/public/uploadFtp.do`
diff --git a/server/db/business.yw_device.device_num.sql b/server/db/business.yw_device.device_num.sql
new file mode 100644
index 0000000..f16fb7d
--- /dev/null
+++ b/server/db/business.yw_device.device_num.sql
@@ -0,0 +1,12 @@
+-- 杩愮淮璁惧锛氳澶囨暟閲�
+SET @db := DATABASE();
+
+SET @sql := IF(
+  (SELECT COUNT(*) FROM information_schema.COLUMNS
+   WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_device' AND COLUMN_NAME = 'device_num') = 0,
+  'ALTER TABLE `yw_device` ADD COLUMN `device_num` int NOT NULL DEFAULT 1 COMMENT ''璁惧鏁伴噺'' AFTER `name`',
+  'SELECT 1'
+);
+PREPARE stmt FROM @sql;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
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/dao/admin/request/DeviceImport.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/admin/request/DeviceImport.java
index f97c65b..01fc723 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/admin/request/DeviceImport.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/admin/request/DeviceImport.java
@@ -17,48 +17,51 @@
     @ExcelColumn(name = "*璁惧鍚嶇О", value = "name", index = 1)
     private String name;
 
-    @ExcelColumn(name = "*璁惧鍒嗙被", value = "categoryPath", index = 2)
+    @ExcelColumn(name = "*璁惧鏁伴噺", value = "deviceNum", index = 2)
+    private String deviceNum;
+
+    @ExcelColumn(name = "*璁惧鍒嗙被", value = "categoryPath", index = 3)
     private String categoryPath;
 
-    @ExcelColumn(name = "璁惧鍨嬪彿", value = "modelNo", index = 3)
+    @ExcelColumn(name = "璁惧鍨嬪彿", value = "modelNo", index = 4)
     private String modelNo;
 
-    @ExcelColumn(name = "璁惧绠$悊鍛�", value = "adminUserName", index = 4)
+    @ExcelColumn(name = "璁惧绠$悊鍛�", value = "adminUserName", index = 5)
     private String adminUserName;
 
-    @ExcelColumn(name = "鎵�鍦ㄤ綅缃�", value = "addr", index = 5)
+    @ExcelColumn(name = "鎵�鍦ㄤ綅缃�", value = "addr", index = 6)
     private String addr;
 
-    @ExcelColumn(name = "*鎵�灞為」鐩�", value = "projectName", index = 6)
+    @ExcelColumn(name = "*鎵�灞為」鐩�", value = "projectName", index = 7)
     private String projectName;
 
-    @ExcelColumn(name = "*鍏宠仈鎴挎簮", value = "roomPath", index = 7)
+    @ExcelColumn(name = "*鍏宠仈鎴挎簮", value = "roomPath", index = 8)
     private String roomPath;
 
-    @ExcelColumn(name = "璐叆鏃堕棿", value = "buyDate", index = 8)
+    @ExcelColumn(name = "璐叆鏃堕棿", value = "buyDate", index = 9)
     private String buyDate;
 
-    @ExcelColumn(name = "璁惧鐘舵��", value = "statusText", index = 9)
+    @ExcelColumn(name = "璁惧鐘舵��", value = "statusText", index = 10)
     private String statusText;
 
-    @ExcelColumn(name = "杩愮淮鍐呭", value = "content", index = 10)
+    @ExcelColumn(name = "杩愮淮鍐呭", value = "content", index = 11)
     private String content;
 
-    @ExcelColumn(name = "璁惧渚涘簲鍟�", value = "supplier", index = 11)
+    @ExcelColumn(name = "璁惧渚涘簲鍟�", value = "supplier", index = 12)
     private String supplier;
 
-    @ExcelColumn(name = "渚涘簲鍟嗚仈绯讳汉", value = "supplierLinker", index = 12)
+    @ExcelColumn(name = "渚涘簲鍟嗚仈绯讳汉", value = "supplierLinker", index = 13)
     private String supplierLinker;
 
-    @ExcelColumn(name = "渚涘簲鍟嗚仈绯绘柟寮�", value = "supplierPhone", index = 13)
+    @ExcelColumn(name = "渚涘簲鍟嗚仈绯绘柟寮�", value = "supplierPhone", index = 14)
     private String supplierPhone;
 
-    @ExcelColumn(name = "缁翠繚璐熻矗浜�", value = "maintenanceUserName", index = 14)
+    @ExcelColumn(name = "缁翠繚璐熻矗浜�", value = "maintenanceUserName", index = 15)
     private String maintenanceUserName;
 
-    @ExcelColumn(name = "缁翠繚鍒版湡鏃�", value = "maintenanceOverDate", index = 15)
+    @ExcelColumn(name = "缁翠繚鍒版湡鏃�", value = "maintenanceOverDate", index = 16)
     private String maintenanceOverDate;
 
-    @ExcelColumn(name = "缁翠繚璇存槑", value = "maintenanceContent", index = 16)
+    @ExcelColumn(name = "缁翠繚璇存槑", value = "maintenanceContent", index = 17)
     private String maintenanceContent;
 }
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwDevice.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwDevice.java
index 2d95c9c..5eae443 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwDevice.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/YwDevice.java
@@ -55,6 +55,10 @@
     @ExcelColumn(name="鍚嶇О")
     private String name;
 
+    @ApiModelProperty(value = "璁惧鏁伴噺")
+    @ExcelColumn(name = "璁惧鏁伴噺")
+    private Integer deviceNum;
+
     @ApiModelProperty(value = "澶囨敞")
     @ExcelColumn(name="澶囨敞")
     private String remark;
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java
index 4754f5a..d494162 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java
@@ -99,6 +99,7 @@
         if(ywDeviceMapper.selectCount(new QueryWrapper<YwDevice>().lambda().eq(YwDevice::getIsdeleted,Constants.ZERO).eq(YwDevice::getCode,ywDevice.getCode()))>Constants.ZERO){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璁惧缂栧彿閲嶅!");
         }
+        ywDevice.setDeviceNum(normalizeDeviceNum(ywDevice.getDeviceNum()));
         ywDevice.setCreateDate(new Date());
         ywDevice.setCreator(loginUserInfo.getId());
         ywDevice.setIsdeleted(Constants.ZERO);
@@ -187,6 +188,7 @@
                 .ne(YwDevice::getId,ywDevice.getId()))>Constants.ZERO){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"璁惧缂栧彿閲嶅!");
         }
+        ywDevice.setDeviceNum(normalizeDeviceNum(ywDevice.getDeviceNum()));
         ywDevice.setEditDate(new Date());
         ywDevice.setEditor(loginUserInfo.getId());
         ywDeviceMapper.updateById(ywDevice);
@@ -504,6 +506,7 @@
     private boolean isImportBlankRow(DeviceImport row) {
         return StringUtils.isBlank(row.getCode())
                 && StringUtils.isBlank(row.getName())
+                && StringUtils.isBlank(row.getDeviceNum())
                 && StringUtils.isBlank(row.getProjectName())
                 && StringUtils.isBlank(row.getRoomPath());
     }
@@ -612,6 +615,7 @@
         if (StringUtils.isBlank(row.getName())) {
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝绗�" + rowNum + "琛岃澶囧悕绉颁笉鑳戒负绌猴紝璇锋鏌ヨ〃鏍煎唴瀹癸紒");
         }
+        Integer deviceNum = parseImportDeviceNum(row.getDeviceNum(), rowNum);
         if (StringUtils.isBlank(row.getProjectName())) {
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝绗�" + rowNum + "琛屾墍灞為」鐩笉鑳戒负绌猴紝璇锋鏌ヨ〃鏍煎唴瀹癸紒");
         }
@@ -668,6 +672,7 @@
         YwDevice device = new YwDevice();
         device.setCode(code);
         device.setName(row.getName().trim());
+        device.setDeviceNum(deviceNum);
         device.setCateId(cateId);
         device.setModelNo(StringUtils.trimToNull(row.getModelNo()));
         device.setUserId(userId);
@@ -697,6 +702,32 @@
         return device;
     }
 
+    private Integer normalizeDeviceNum(Integer deviceNum) {
+        if (deviceNum == null || deviceNum <= 0) {
+            return 1;
+        }
+        return deviceNum;
+    }
+
+    private Integer parseImportDeviceNum(String deviceNumText, int rowNum) {
+        if (StringUtils.isBlank(deviceNumText)) {
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝绗�" + rowNum + "琛岃澶囨暟閲忎笉鑳戒负绌猴紝璇锋鏌ヨ〃鏍煎唴瀹癸紒");
+        }
+        String text = deviceNumText.trim();
+        if (StringUtils.endsWith(text, ".0")) {
+            text = StringUtils.substringBefore(text, ".0");
+        }
+        try {
+            double value = Double.parseDouble(text);
+            if (value <= 0 || value != Math.floor(value)) {
+                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝绗�" + rowNum + "琛岃澶囨暟閲忓繀椤讳负姝f暣鏁帮紝璇锋鏌ヨ〃鏍煎唴瀹癸紒");
+            }
+            return (int) value;
+        } catch (NumberFormatException e) {
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝绗�" + rowNum + "琛岃澶囨暟閲忓繀椤讳负姝f暣鏁帮紝璇锋鏌ヨ〃鏍煎唴瀹癸紒");
+        }
+    }
+
     private Integer resolveInternalUserId(String userName, int rowNum, String fieldLabel, DeviceImportCache cache) {
         if (StringUtils.isBlank(userName)) {
             return null;

--
Gitblit v1.9.3