From b3adc414c51e229f10172985911373ed90b1334f Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期五, 06 三月 2026 10:02:20 +0800
Subject: [PATCH] 最新版本541200007最新版本541200007
---
admin/src/components/business/OperaDeviceDataListWindow.vue | 72 -------
server/system_service/src/main/java/com/doumee/core/utils/Constants.java | 18 ++
admin/src/views/business/deviceDuanluqi.vue | 3
server/doc/新增断路器设备功能(2025-12-24).sql | 10
server/visits/admin_timer/src/main/resources/bootstrap.yml | 2
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/DeviceData.java | 6
server/visits/device_service/pom.xml | 7
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java | 326 +++++++++++++++++++++++++++++++++++
server/system_timer/src/main/resources/bootstrap.yml | 2
server/visits/dmvisit_service/pom.xml | 5
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java | 10 +
server/pom.xml | 2
admin/src/components/business/OperaDeviceDuanluqiWindow.vue | 7
server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java | 12
14 files changed, 376 insertions(+), 106 deletions(-)
diff --git a/admin/src/components/business/OperaDeviceDataListWindow.vue b/admin/src/components/business/OperaDeviceDataListWindow.vue
index b23d1b4..69c4a7d 100644
--- a/admin/src/components/business/OperaDeviceDataListWindow.vue
+++ b/admin/src/components/business/OperaDeviceDataListWindow.vue
@@ -1,7 +1,7 @@
<template>
<GlobalWindow
:title="title"
- width="100%"
+ width="85%"
:visible.sync="visible"
>
<TableLayout >
@@ -19,30 +19,20 @@
<div style="display: flex;margin-top: 20px;">
<div style="flex: 1"><span class="label">MQTT IP锛�</span>{{model.doorNameObj.mqttIp ||''}}</div>
<div style="flex: 1"><span class="label">MQTT绔彛锛�</span>{{model.doorNameObj.mqttPort||''}}</div>
- <div style="flex: 3">
- <span class="label">鏈�杩戞帶鍒舵搷浣滐細</span>
- <span class="orange" >{{model.remark||''}}</span>
- </div>
+ <div style="flex: 3"> <span class="label">鏈�杩戞帶鍒舵搷浣滐細</span>{{model.remark||''}}</div>
</div>
</div>
- <div class="platgroup_tabs">
- <div class="tab" :class="{ active: activeGroup === item.id }" @click="groupClick(item)"
- v-for="(item, i) in groupList" :key="i">
- {{ item.name }}
- </div>
- </div>
- <el-form-item label="寮�鍏冲簭鍙�" v-if="activeGroup==0" prop="val1">
+ <el-form-item label="寮�鍏冲簭鍙�" prop="val1">
<el-input v-model="searchForm.val1" placeholder="璇疯緭鍏ュ紑鍏冲簭鍙�" @keypress.enter.native="search"></el-input>
</el-form-item>
- <section v-if="activeGroup==0">
+ <section>
<el-button type="primary" @click="search">鎼滅储</el-button>
<el-button @click="reset">閲嶇疆</el-button>
</section>
</el-form>
<!-- 琛ㄦ牸鍜屽垎椤� -->
- <template v-slot:table-wrap>
+ <template v-slot:table-wrap>
<el-table
- v-if="activeGroup===0"
:height="tableHeightNew"
v-loading="isWorking.search"
:data="tableData.list"
@@ -60,24 +50,6 @@
<el-table-column prop="val3" label="鐢靛湩(V)" min-width="120px"></el-table-column>
<el-table-column prop="val4" label="娓╁害(鈩�)" min-width="180px" ></el-table-column>
<el-table-column prop="val5" label="鏈夊姛鍔熺巼鍊硷紙kW锛�" min-width="120px"></el-table-column>
- </el-table>
- <el-table
- v-if="activeGroup===1"
- :height="tableHeightNew"
- v-loading="isWorking.search"
- :data="tableData.list"
- stripe>
- <el-table-column prop="createDate" label="鎿嶄綔鏃堕棿" min-width="150px"></el-table-column>
- <el-table-column prop="val4" label="鎿嶄綔浜�" min-width="100px" ></el-table-column>
- <el-table-column prop="val3" label="鎿嶄綔鍐呭" min-width="100px">
- <template slot-scope="{row}">
- <span v-if=" row.val3 === '銆愬悎闂搞��'" class="green">{{row.val3||''}}</span>
- <span v-else-if=" row.val3 === '銆愬垎闂搞��'" class="red">{{row.val3||''}}</span>
- <span v-else>{{row.val3||''}}</span>
- </template>
- </el-table-column>
- <el-table-column prop="val5" label="寮�鍏冲簭鍙�" min-width="120px"></el-table-column>
- <el-table-column prop="val2" label="鍐呭" min-width="300px" show-overflow-tooltip></el-table-column>
</el-table>
<pagination
@size-change="handleSizeChange"
@@ -107,13 +79,10 @@
// 琛ㄥ崟鏁版嵁
visible: false,
title: '',
- activeGroup:0,
model:{},
- groupList: [{ id: 0, name: '鏁版嵁涓婃姤璁板綍', type: 0 }, { id: 1, name: '杩滅▼鎺у埗璁板綍', type: 1 }],
searchForm: {
deviceId: null,
- val1: '',
- dataType:0
+ val1:''
}
}
},
@@ -127,12 +96,6 @@
this.search()
},
methods: {
- groupClick (item) {
- this.activeGroup = item.id
- this.searchForm.val1 = ''
- this.searchForm.dataType = item.type
- this.search()
- },
open (title, row) {
this.title = title +' 銆�'+ (row.name)+'銆�'
this.searchForm.deviceId = row.id
@@ -155,33 +118,12 @@
total: 0
}
}
- this.groupClick(this.groupList[0])
+ this.search()
}
}
}
</script>
<style>
-.platgroup_tabs {
- flex: 1;
- display: flex;
- border-bottom: 1px solid #dfe2e8;
- margin-bottom:30px;
-
- .tab {
- color: #666666;
- margin-right: 40px;
- cursor: pointer;
- padding-bottom: 18px;
- border-bottom: 2px solid #fff;
- }
-
- .active {
- font-weight: 500;
- font-size: 15px;
- color: #2080f7;
- border-bottom: 2px solid $primary-color;
- }
-}
.label{
/* width: 80px;
text-align: right;*/
diff --git a/admin/src/components/business/OperaDeviceDuanluqiWindow.vue b/admin/src/components/business/OperaDeviceDuanluqiWindow.vue
index 9cd78ab..99021aa 100644
--- a/admin/src/components/business/OperaDeviceDuanluqiWindow.vue
+++ b/admin/src/components/business/OperaDeviceDuanluqiWindow.vue
@@ -34,9 +34,8 @@
1.鍏ㄩ儴寮�鍏冲簭鍙凤細鍙傝�冭澶囧疄闄呴厤缃紝澶氫釜鐢ㄨ嫳鏂囬�楀彿闅斿紑锛屽 1,2,3;<br>
2.鎺у埗寮�鍏冲簭鍙凤細绯荤粺鏍规嵁閰嶇疆瑙勫垯锛屽垽鏂紑鍏冲綋鍓嶇┖闂蹭腑杩涜銆愯嚜鍔ㄥ垎闂搞��,澶氫釜鐢ㄨ嫳鏂囬�楀彿闅斿紑锛屽 1,2;<br>
3.鑷姩鍒嗛椄瑙勫垯锛氶拡瀵规帶鍒跺紑鍏冲簭鍙风殑閰嶇疆锛屽畾鏃舵娴嬨�愮┖闂叉椂闀裤�戝唴婊¤冻寮�鍏崇數娴佸�奸兘鍦ㄣ�愮┖闂茬數娴侀槇鍊笺�戣寖鍥村唴锛屽垯杩涜鑷姩鍒嗛椄鎺у埗;<br>
- 4.绌洪棽鏃堕暱: 璇疯缃嚦灏戠┖闂叉椂闀垮ぇ浜庣瓑浜�300绉掞紙5鍒嗛挓锛夈��<br>
- 5.淇敼閲嶅惎: 淇敼閰嶇疆鍙傛暟鍚庯紝杩斿洖鍒楄〃椤碉紝鐐瑰嚮閲嶅惎銆愬惎鐢ㄣ�戯紝鏄弬鏁扮敓鏁堬紒<br>
- 6.濡傞渶杩滅▼鎺у埗寮�鍏筹紝璇锋纭~鍐欎笅杩板叏閮ㄥ弬鏁颁俊鎭��
+ 4.绌洪棽鏃堕暱: 璇疯缃嚦灏戠┖闂叉椂闀垮ぇ浜庣瓑浜�300绉掞紙5鍒嗛挓锛夈��
+ 5.濡傞渶杩滅▼鎺у埗寮�鍏筹紝璇锋纭~鍐欎笅杩板叏閮ㄥ弬鏁颁俊鎭��
</p>
<div style="display: flex">
<el-form-item label="鍏ㄩ儴寮�鍏冲簭鍙�" prop="channelNo" style="display: inline-block;width:300px;">
@@ -119,7 +118,7 @@
name: [
{ required: true, message: '璇疯緭鍏ヨ澶囧悕绉�' }
],
- /*max: [
+ /* max: [
{ required: true, message: '璇疯緭鍏ヨ澶囩┖闂茬數娴侀槇鍊�' }
],*/
doorId: [
diff --git a/admin/src/views/business/deviceDuanluqi.vue b/admin/src/views/business/deviceDuanluqi.vue
index f7851fd..368c0e3 100644
--- a/admin/src/views/business/deviceDuanluqi.vue
+++ b/admin/src/views/business/deviceDuanluqi.vue
@@ -133,9 +133,10 @@
return {
// 鎼滅储
searchForm: {
+ doorName: '',
doorNo: '',
no: '',
- name: '',
+ regionPathName: '',
type: 5
},
isWorkSending: false,
diff --git "a/server/doc/\346\226\260\345\242\236\346\226\255\350\267\257\345\231\250\350\256\276\345\244\207\345\212\237\350\203\275\357\274\2102025-12-24\357\274\211.sql" "b/server/doc/\346\226\260\345\242\236\346\226\255\350\267\257\345\231\250\350\256\276\345\244\207\345\212\237\350\203\275\357\274\2102025-12-24\357\274\211.sql"
index 63acdcc..305191d 100644
--- "a/server/doc/\346\226\260\345\242\236\346\226\255\350\267\257\345\231\250\350\256\276\345\244\207\345\212\237\350\203\275\357\274\2102025-12-24\357\274\211.sql"
+++ "b/server/doc/\346\226\260\345\242\236\346\226\255\350\267\257\345\231\250\350\256\276\345\244\207\345\212\237\350\203\275\357\274\2102025-12-24\357\274\211.sql"
@@ -1,13 +1,7 @@
-ALTER TABLE `device`
+ALTER TABLE `wuhuyancao`.`device`
MODIFY COLUMN `door_no` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '闂ㄧ鐐圭紪鍙�' AFTER `install_location`;
-INSERT INTO `quartz_job` (`id`, `bean_name`, `params`, `cron_expres`, `state`, `remark`, `create_time`, `module`) VALUES (NULL, 'visitServiceJob', '{}', '0 0/5 * * * ? *', 1, '銆愭柇璺櫒銆戝紑鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄', '2023-07-26 13:17:17', 'autoCloseCmd');
-
-
-INSERT INTO `system_dict_data` (`ID`, `DICT_ID`, `CODE`, `LABEL`, `SORT`, `DISABLED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`, `REMARK`) VALUES (314, 18, 'yKSKuO0LoFf06jWGrwwuGudK', 'JDY_SECRET', 0, 0, 1, '2025-12-29 10:32:54', NULL, '2025-12-29 10:31:45', 0, '鏁版嵁鎺ㄩ�佺閽�');
-INSERT INTO `system_dict_data` (`ID`, `DICT_ID`, `CODE`, `LABEL`, `SORT`, `DISABLED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`, `REMARK`) VALUES (315, 18, 'https://api.jiandaoyun.com/api/v1/automation/tenant/6909b792324dc197821895d1/hooks/6909d0fbdb93695219faa27eb068192dc4a9532972993159', 'JDY_MEMBER_PUSH_STATUS_URL', 0, 0, 1, '2025-12-29 14:06:56', NULL, '2025-12-29 14:05:46', 0, '绠�閬撲簯浜哄憳鎺ㄩ�佸鐞嗙粨鏋滈�氱煡鍦板潃');
-INSERT INTO `system_dict_data` (`ID`, `DICT_ID`, `CODE`, `LABEL`, `SORT`, `DISABLED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`, `REMARK`) VALUES (316, 1, '鑺滄箹鐑熻崏鍏徃', 'SYSTEM_TITLE', 0, 0, 1, '2025-12-30 14:49:57', NULL, '2025-12-30 14:48:47', 0, '绯荤粺涓绘爣棰�');
-INSERT INTO `system_dict_data` (`ID`, `DICT_ID`, `CODE`, `LABEL`, `SORT`, `DISABLED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`, `REMARK`) VALUES (317, 1, '鏅烘収鐗╂祦鍥尯瀹夋秷涓�浣撳寲骞冲彴', 'SYSTEM_SUBTITLE', 0, 0, 1, '2025-12-30 14:50:40', NULL, '2025-12-30 14:49:30', 0, '绯荤粺鍓爣棰�');
+INSERT INTO `wuhuyancao`.`quartz_job` (`id`, `bean_name`, `params`, `cron_expres`, `state`, `remark`, `create_time`, `module`) VALUES (NULL, 'visitServiceJob', '{}', '0 0/5 * * * ? *', 1, '銆愭柇璺櫒銆戝紑鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄', '2023-07-26 13:17:17', 'autoCloseCmd');
CREATE TABLE `device_data` (
diff --git a/server/pom.xml b/server/pom.xml
index 8b2bb0f..60f3dff 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -18,8 +18,6 @@
<module>system_gateway</module>
<module>emaysms</module>
<module>visits/device_service</module>
- <module>jiandaoyun_service</module>
- <module>base_serivce</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
diff --git a/server/system_service/src/main/java/com/doumee/core/utils/Constants.java b/server/system_service/src/main/java/com/doumee/core/utils/Constants.java
index 406fbac..a8a4e93 100644
--- a/server/system_service/src/main/java/com/doumee/core/utils/Constants.java
+++ b/server/system_service/src/main/java/com/doumee/core/utils/Constants.java
@@ -218,6 +218,7 @@
public static boolean DEALING_HK_NOTICE_LIST = false;
public static boolean DEALING_FROM_HK_VISIT = false;
public static boolean DEALING_HK_EMPOWER = false;
+ public static boolean DEALING_DUANLUQI_CLOSE = false;
public static boolean DEALING_HK_EMPOWER_DETAIL = false;
public static boolean DEALING_HK_EMPOWER_RESULT = false;
public static boolean DEALING_HK_PARKBOOK = false;
@@ -288,6 +289,15 @@
public static final int depart = 3;
public static final int custom = 4;
public static final int self = -1;
+ }
+ //绫诲瀷 0闂ㄧ 1杞﹀簱 2LED 3骞挎挱鐐� 4骞挎挱璁惧 5鏂矾鍣ㄧ┖寮�
+ public interface DEVICE_TYPE{
+ public static final int door = 0;
+ public static final int park = 1;
+ public static final int led = 2;
+ public static final int broadcaset = 3;
+ public static final int broadcasetChannel = 4;
+ public static final int duanluqi = 5;
}
/**
@@ -1529,6 +1539,14 @@
return JSONObject.toJSONString(map);
}
+ public interface MqttTopic{
+ String mts_attr = "/dev/+/+/attr/json";//灞炴�opic
+ String mts_status = "/dev/+/+/status/json";//鐘舵�乼opic
+ String mts_event= "/dev/+/+/event/json";//浜嬩欢topic
+ String mts_echo= "/dev/+/+/echo/json";//娑堟伅鍥炲topic
+ String mts_cmd= "/dev/$CATE/$DEVID/cmd/json";//鍛戒护topic
+ String mts_resp= "/dev/+/+/resp/json";//鍛戒护鍝嶅簲topic
+ }
public enum WarningConfig {
diff --git a/server/system_timer/src/main/resources/bootstrap.yml b/server/system_timer/src/main/resources/bootstrap.yml
index 5eb6d62..107b53b 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: test
+ active: dev
application:
name: systemTimer
# 瀹夊叏閰嶇疆
diff --git a/server/visits/admin_timer/src/main/resources/bootstrap.yml b/server/visits/admin_timer/src/main/resources/bootstrap.yml
index b5b65b7..efae338 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: pro
+ active: dev
application:
name: visitsTimer
# 瀹夊叏閰嶇疆
diff --git a/server/visits/device_service/pom.xml b/server/visits/device_service/pom.xml
index bdd8398..248de40 100644
--- a/server/visits/device_service/pom.xml
+++ b/server/visits/device_service/pom.xml
@@ -9,13 +9,13 @@
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
+
<artifactId>device_service</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <fastjson.version>1.2.70</fastjson.version>
</properties>
<dependencies>
@@ -27,11 +27,6 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
- </dependency>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>fastjson</artifactId>
- <version>${fastjson.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/server/visits/dmvisit_service/pom.xml b/server/visits/dmvisit_service/pom.xml
index 9aff8b7..f2ae256 100644
--- a/server/visits/dmvisit_service/pom.xml
+++ b/server/visits/dmvisit_service/pom.xml
@@ -24,11 +24,6 @@
</dependency>
<dependency>
<groupId>com.doumee</groupId>
- <artifactId>jiandaoyun_service</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>com.doumee</groupId>
<artifactId>device_service</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
index b95469d..b7d2440 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
@@ -1,5 +1,6 @@
package com.doumee.dao.business.model;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.doumee.core.annotation.excel.ExcelColumn;
import com.doumee.service.business.third.model.LoginUserModel;
@@ -10,6 +11,7 @@
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
+import java.math.BigDecimal;
import java.util.Date;
/**
@@ -71,8 +73,8 @@
@ExcelColumn(name="鎺掑簭鐮�")
private Integer sortnum;
- @ApiModelProperty(value = "绫诲瀷 0闂ㄧ 1杞﹀簱 2LED 3骞挎挱鐐� 4骞挎挱璁惧", example = "1")
- @ExcelColumn(name="绫诲瀷 0闂ㄧ 1杞﹀簱 2LED 3骞挎挱鐐� 4骞挎挱璁惧")
+ @ApiModelProperty(value = "绫诲瀷 0闂ㄧ 1杞﹀簱 2LED 3骞挎挱鐐� 4骞挎挱璁惧 5鏂矾鍣ㄧ┖寮�", example = "1")
+ @ExcelColumn(name="绫诲瀷 0闂ㄧ 1杞﹀簱 2LED 3骞挎挱鐐� 4骞挎挱璁惧 5鏂矾鍣ㄧ┖寮�")
private Integer type;
@ApiModelProperty(value = "鏄惁鍥尯鍑哄叆鍙� 0涓嶆槸 1鏄�", example = "1")
@ExcelColumn(name="鏄惁鍥尯鍑哄叆鍙� 0涓嶆槸 1鏄�")
@@ -154,12 +156,12 @@
@ApiModelProperty(value = "闂ㄧ鐐瑰悕绉�")
@ExcelColumn(name="闂ㄧ鐐瑰悕绉�")
private String doorName;
-
-
@ApiModelProperty(value = "鎾姤鍐呭")
@TableField(exist = false)
private String sendInfo;
-
+ @ApiModelProperty(value = "閰嶇疆鍙傛暟")
+ @TableField(exist = false)
+ private JSONObject doorNameObj;
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/DeviceData.java b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/DeviceData.java
index 11ba7cf..bf917f3 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/DeviceData.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/dao/business/model/DeviceData.java
@@ -31,6 +31,7 @@
@ApiModelProperty(value = "鍒涘缓鏃堕棿")
@ExcelColumn(name="鍒涘缓鏃堕棿")
+ @JsonFormat(pattern = "yyyy-MM-dd")
private Date createDate;
@ApiModelProperty(value = "鏇存柊浜虹紪鐮�", example = "1")
@@ -39,6 +40,7 @@
@ApiModelProperty(value = "鏇存柊鏃堕棿")
@ExcelColumn(name="鏇存柊鏃堕棿")
+ @JsonFormat(pattern = "yyyy-MM-dd")
private Date editDate;
@ApiModelProperty(value = "鏄惁鍒犻櫎0鍚� 1鏄�", example = "1")
@@ -88,8 +90,8 @@
@ExcelColumn(name="灞炴�у��7")
private String val7;
- @ApiModelProperty(value = "鏁版嵁鏉ユ簮 0mqtt涓婃姤缁煎悎鐘舵�� 1杩滅▼鎺у埗 ", example = "1")
- @ExcelColumn(name="鏁版嵁鏉ユ簮 0mqtt涓婃姤缁煎悎鐘舵�� 1杩滅▼鎺у埗")
+ @ApiModelProperty(value = "鏁版嵁鏉ユ簮 0mqtt涓婃姤 1鍏朵粬", example = "1")
+ @ExcelColumn(name="鏁版嵁鏉ユ簮 0mqtt涓婃姤 1鍏朵粬")
private Integer dataType;
}
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java
index ceced8e..3aef46e 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java
@@ -5,6 +5,8 @@
import com.doumee.service.business.third.model.PageData;
import com.doumee.service.business.third.model.PageWrap;
import com.doumee.dao.business.model.Device;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+
import java.util.List;
/**
@@ -13,6 +15,7 @@
* @date 2023/11/30 15:33
*/
public interface DeviceService {
+
/**
* 鍒涘缓
@@ -109,4 +112,11 @@
void setBroadcaseBobao(Device body);
String setBroadcaseBobaoHttp(Device body);
+
+ void duanluqiCmd(Device param);
+
+ void updateUsedById(Device d);
+
+ void autoCloseCmdTimer();
+ void startCheckDuanluqiSubjob();
}
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
index d66c345..b72835a 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
@@ -11,14 +11,15 @@
import com.doumee.core.haikang.model.param.request.CustomBroadcastRequest;
import com.doumee.core.haikang.model.param.request.TransparentChannelSingleRequest;
import com.doumee.core.haikang.service.HKService;
-import com.doumee.core.utils.HttpsUtil;
+import com.doumee.core.utils.*;
import com.doumee.dao.business.*;
import com.doumee.dao.business.model.*;
+import com.doumee.mqtt.config.MqttConfig;
+import com.doumee.mqtt.service.MqttBizService;
+import com.doumee.service.business.impl.mqtt.MqttClientCache;
import com.doumee.service.business.third.model.LoginUserInfo;
import com.doumee.service.business.third.model.PageData;
import com.doumee.service.business.third.model.PageWrap;
-import com.doumee.core.utils.Constants;
-import com.doumee.core.utils.Utils;
import com.doumee.service.business.DeviceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -28,11 +29,14 @@
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
+import java.util.Date;
import java.util.stream.Collectors;
/**
@@ -45,7 +49,11 @@
public class DeviceServiceImpl implements DeviceService {
@Autowired
+ private MqttBizService mqttBizService;
+ @Autowired
private DeviceMapper deviceMapper;
+ @Autowired
+ private DeviceDataMapper deviceDataMapper;
@Autowired
private PlatformMapper platformMapper;
@Autowired
@@ -65,6 +73,14 @@
model.setIsdeleted(Constants.ZERO);
model.setEditDate(new Date());
model.setCreateDate(model.getEditDate());
+ if(model.getDoorNameObj()!=null && Constants.equalsInteger(model.getType(),Constants.DEVICE_TYPE.duanluqi)){
+ model.setDoorName(JSONObject.toJSONString(model.getDoorNameObj()));
+ if(StringUtils.isNotBlank(model.getLevel())){
+ if(getNumberByStr(model.getLevel()) <300){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝鎺у埗鏃堕暱蹇呴』澶т簬绛変簬300绉�");
+ }
+ }
+ }
deviceMapper.insert(model);
return model.getId();
}
@@ -99,6 +115,9 @@
public void updateById(Device device) {
device.setEdirot(device.getLoginUserInfo().getId()+"");
device.setEditDate(new Date());
+ if(device.getDoorNameObj()!=null && Constants.equalsInteger(device.getType(),Constants.DEVICE_TYPE.duanluqi)){
+ device.setDoorName(JSONObject.toJSONString(device.getDoorNameObj()));
+ }
deviceMapper.updateById(device);
}
@@ -114,7 +133,16 @@
@Override
public Device findById(Integer id) {
- return deviceMapper.selectById(id);
+ Device d = deviceMapper.selectById(id);
+ if(StringUtils.isNotBlank(d.getDoorName()) &&Constants.equalsInteger(d.getType(),Constants.DEVICE_TYPE.duanluqi)){
+ try {
+ //鏂矾鍣ㄨ澶囧弬鏁�
+ d.setDoorNameObj(JSONObject.parseObject(d.getDoorName()));
+ }catch (Exception e){
+
+ }
+ }
+ return d;
}
@Override
@@ -138,7 +166,20 @@
.eq(null !=param.getIsdeleted(),Device::getIsdeleted,param.getIsdeleted())
.eq(Objects.isNull(param.getIsdeleted()),Device::getIsdeleted,Constants.ZERO)
.eq(null != param.getHkStatus(),Device::getHkStatus,param.getHkStatus());
- return deviceMapper.selectList(wrapper);
+ List<Device> list = deviceMapper.selectList(wrapper);
+ if(list!=null){
+ for(Device d : list){
+ if(StringUtils.isNotBlank(d.getDoorName()) &&Constants.equalsInteger(d.getType(),Constants.DEVICE_TYPE.duanluqi)){
+ try {
+ //鏂矾鍣ㄨ澶囧弬鏁�
+ d.setDoorNameObj(JSONObject.parseObject(d.getDoorName()));
+ }catch (Exception e){
+
+ }
+ }
+ }
+ }
+ return list;
}
@Override
@@ -247,7 +288,20 @@
queryWrapper.orderByAsc(sortData.getProperty());
}
}
- return PageData.from(deviceMapper.selectPage(page, queryWrapper));
+ IPage<Device> result = deviceMapper.selectPage(page, queryWrapper);
+ if(result!=null){
+ for(Device d : result.getRecords()){
+ if(StringUtils.isNotBlank(d.getDoorName()) &&Constants.equalsInteger(d.getType(),Constants.DEVICE_TYPE.duanluqi)){
+ try {
+ //鏂矾鍣ㄨ澶囧弬鏁�
+ d.setDoorNameObj(JSONObject.parseObject(d.getDoorName()));
+ }catch (Exception e){
+
+ }
+ }
+ }
+ }
+ return PageData.from(result);
}
@Override
@@ -271,6 +325,125 @@
if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){
throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"鍙戦�佸け璐ワ細"+ JSONObject.toJSONString(response));
}
+ }
+
+ @Override
+ public void updateUsedById(Device param){
+ Device model = deviceMapper.selectById(param.getId());
+ if(model ==null && Constants.equalsInteger(param.getType(),Constants.DEVICE_TYPE.duanluqi)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+
+ MqttConfig config = getMqttConfigByParam(model,"device_");
+ MqttClient mqttClient = MqttClientCache.clientMapCache.get("device"+param.getId());
+ String[] topics =new String[]{Constants.MqttTopic.mts_status,
+ Constants.MqttTopic.mts_attr,
+ Constants.MqttTopic.mts_resp};
+ if(Constants.equalsInteger(param.getIsUsed(),Constants.ONE)){
+ //濡傛灉绯荤粺涓嶇敤浜嗭紝绔彛mqtt杩炴帴
+ try {
+ mqttClient = mqttBizService.unsubscribe(mqttClient,config ,topics);
+ if(mqttClient ==null){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"寤虹珛杩炴帴澶辫触锛�");
+ }
+ if(mqttClient.isConnected()){
+ mqttClient.disconnect();
+ }
+ }catch (Exception e){
+ log.error("==============绔彛mqtt閾炬帴澶辫触锛�"+model.getName()+e.getMessage());
+ }
+ }else{
+ //濡傛灉寮�濮嬩娇鐢紝寮�濮嬭闃�
+ mqttClient = mqttBizService.subscribe(mqttClient,config ,topics);
+ if(mqttClient ==null){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"寤虹珛杩炴帴澶辫触锛�");
+ }
+ MqttClientCache.clientMapCache.put("device"+param.getId(),mqttClient);
+ }
+
+ this.updateById(param);
+ }
+ @Override
+ public void duanluqiCmd(Device param){
+ Device model = deviceMapper.selectById(param.getId());
+ if(model ==null && Constants.equalsInteger(param.getType(),Constants.DEVICE_TYPE.duanluqi)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+ dealDuanluqiCmd(model,param,"device_");
+
+ }
+
+ private void dealDuanluqiCmd(Device model, Device param,String clientIndex) {
+ MqttConfig config = getMqttConfigByParam(model,clientIndex);
+ MqttClient mqttClient = MqttClientCache.clientMapCache.get("device"+param.getId());
+ String cmdTopic = Constants.MqttTopic.mts_cmd.replace("$CATE",model.getNo()).replace("$DEVID",model.getDoorNo());
+ if(Constants.equalsInteger(param.getStatus(),Constants.ONE)){
+ //濡傛灉鏄紑闂革紝鍏堣В閿�
+ String cmdParamAction = CmdContants.T30A.cmdParam.replace("$DEVID", model.getDoorNo())
+ .replace("$CMD", CmdContants.T30ACmd.do_err_clear)//寮傚父瑙i攣
+ .replace("$BUSADDR",model.getChannelNo());
+ mqttClient = mqttBizService.publish(mqttClient,config,cmdTopic, cmdParamAction);//瑙i攣鍛戒护
+ if(mqttClient ==null){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"鎸囦护鍙戦�佸け璐ワ紒");
+ }
+ }
+ String cmdParamAction =CmdContants.T30A.cmdParam.replace("$DEVID", model.getDoorNo())
+ .replace("$CMD",(Constants.equalsInteger(param.getStatus(),Constants.ONE)?CmdContants.T30ACmd.do_turn_on:CmdContants.T30ACmd.do_turn_off))
+ .replace("$BUSADDR", param.getChannelNo());
+ mqttClient = mqttBizService.publish(mqttClient,config,cmdTopic, cmdParamAction);//寮�鍏抽椄鍛戒护
+ if(mqttClient ==null){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"鎸囦护鍙戦�佸け璐ワ紒");
+ }
+ MqttClientCache.clientMapCache.put("device"+param.getId(),mqttClient);
+ String curremak = "銆�"+param.getLoginUserInfo().getRealname()
+ +"銆戜簬"+ DateUtil.getPlusTime2(new Date()) +"杩涜浜�"+(Constants.equalsInteger(param.getStatus(),Constants.ONE)?"銆愬紑闂搞��":"銆愬叧闂搞��")+"鎿嶄綔,寮�鍏炽��"+param.getChannelNo()+"銆戯紱";
+ deviceMapper.update(null,new UpdateWrapper<Device>().lambda()
+// .setSql("remark = concat(ifnull(remark,''),'"+curremak+"','\n')")
+ .set(Device::getRemark,curremak)
+ .set(Device::getEditDate,new Date())
+ .set(Device::getEdirot,param.getLoginUserInfo().getId())
+ .eq(Device::getId,param.getId()));
+ }
+
+ private MqttConfig getMqttConfigByParam(Device model,String index) {
+ MqttConfig config = new MqttConfig();
+ JSONObject mqtt = new JSONObject();
+ if(StringUtils.isBlank(model.getNo())
+ ||StringUtils.isBlank(model.getDoorNo()) ){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璁惧鏍囪瘑绗﹀拰璁惧鍙锋湭閰嶇疆锛�");
+ }
+ if(StringUtils.isNotBlank(model.getDoorName())){
+ try {
+ //鏂矾鍣ㄨ澶囧弬鏁�
+ mqtt = (JSONObject.parseObject(model.getDoorName()));
+ }catch (Exception e){
+ }
+ }
+ if(mqtt == null
+ ||StringUtils.isBlank(mqtt.getString("mqttUsername"))
+ ||StringUtils.isBlank(mqtt.getString("mqttIp"))
+ ||StringUtils.isBlank(mqtt.getString("mqttPort"))
+ ||StringUtils.isBlank(mqtt.getString("mqttPassword"))){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璁惧mqtt鏈嶅姟鍙傛暟閰嶇疆涓嶆纭紒");
+ }
+ /**
+ * MqttConfig config = (new MqttConfig());
+ * config.setHost("tcp://192.168.0.7:1883");
+ * config.setClientid("doumee1");
+ * config.setPassword("doumee@168");
+ * config.setUsername("doumee");
+ * config.setVersion("003");
+ */
+ config.setVersion("003");
+ config.setUsername( mqtt.getString("mqttUsername"));
+ config.setPassword( mqtt.getString("mqttPassword"));
+ config.setHost("tcp://"+ mqtt.getString("mqttIp")+":"+mqtt.getString("mqttPort"));
+ config.setClientid(index+model.getId());
+ return config;
+ }
+ public void mqttCallbackService(String topic, MqttMessage message){
+ log.error("mqtt鏀跺埌娑堟伅=====topic锛�",topic);
+ log.error("mqtt鏀跺埌娑堟伅=====message锛�",JSONObject.toJSONString(message));
}
@Override
public String setBroadcaseBobaoHttp(Device param){
@@ -382,4 +555,145 @@
}
log.error( "灞忓箷鍐呭璁剧疆=======================缁撴潫========" );
}
+
+
+ /**
+ * 鏈嶅姟寮�鍚闃呬换鍔�
+ */
+ @Override
+ public void startCheckDuanluqiSubjob() {
+ List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>().lambda()
+ .eq(Device::getType,Constants.DEVICE_TYPE.duanluqi)//鏂矾鍣�
+ .eq(Device::getIsUsed,Constants.ZERO)
+ .eq(Device::getIsdeleted,Constants.ZERO)
+ );
+ if(devices!=null && devices.size()>0){
+ for (Device model : devices){
+ try {
+ MqttConfig config = getMqttConfigByParam(model,"device_");
+ MqttClient mqttClient = MqttClientCache.clientMapCache.get("device"+model.getId());
+ String[] topics =new String[]{Constants.MqttTopic.mts_status,
+ Constants.MqttTopic.mts_attr,
+ Constants.MqttTopic.mts_resp};
+ //濡傛灉寮�濮嬩娇鐢紝寮�濮嬭闃�
+ mqttClient = mqttBizService.subscribe(mqttClient,config ,topics);
+ if(mqttClient ==null){
+ throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"寤虹珛杩炴帴澶辫触锛�");
+ }
+ MqttClientCache.clientMapCache.put("device"+model.getId(),mqttClient);
+ log.error("=======寮�濮嬭嚜鍔ㄥ畾浜巑qtt浠诲姟瀹屾垚锛�"+model.getName() );
+ }catch (Exception e){
+ log.error("=======寮�濮嬭嚜鍔ㄥ畾浜巑qtt浠诲姟澶辫触锛�"+model.getName()+e.getMessage());
+ }
+ }
+
+ }
+ }
+ /**
+ * 鏂矾鍣ㄥ垽鏂槸鍚﹂渶瑕佽繙绋嬪垎闂稿畾浜轰换鍔�
+ */
+ @Override
+ public void autoCloseCmdTimer(){
+ if(Constants.DEALING_DUANLUQI_CLOSE){
+ return;
+ }
+ log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒寮�濮�=========");
+ Constants.DEALING_DUANLUQI_CLOSE = true;
+ try {
+ List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>().lambda()
+ .eq(Device::getType,Constants.DEVICE_TYPE.duanluqi)//鏂矾鍣�
+ .isNotNull(Device::getLevel)//閰嶇疆浜嗙┖闂叉椂闀块檺鍒�
+ .isNotNull(Device::getDoorName)//閰嶇疆浜哅QTT鍙傛暟
+ .isNotNull(Device::getChannelInfo)//閰嶇疆浜嗘帶鍒跺紑鍏冲簭鍙�
+ .eq(Device::getIsUsed,Constants.ZERO)
+ .eq(Device::getIsdeleted,Constants.ZERO)
+ );
+ if(devices!=null && devices.size()>0){
+ for(Device device : devices){
+ try {
+ long time = (long)getNumberByStr(device.getLevel());//鎺у埗鏃堕暱
+ if(time < 300 ){
+ log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄澶辫触=========绌洪棽鏃堕暱鏈纭厤缃�"+time);
+ continue;
+ }
+ double closeDianliu = getCloseDianliuByParam(device);
+ if(closeDianliu < 0 ){
+ log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄澶辫触=========绌洪棽鐢垫祦闃堝�艰缃敊璇�"+closeDianliu);
+ continue;
+ }
+ List<String> closeBtn = new ArrayList<>();
+ String[] btns = device.getChannelInfo().split(",");
+ Date startDate = new Date((System.currentTimeMillis()-time*1000));//鏌ヨ寮�濮嬫椂闂�
+ List<DeviceData> dataList = deviceDataMapper.selectList(new QueryWrapper<DeviceData>().lambda()
+ .eq(DeviceData::getDeviceId,device.getId())
+ .in(DeviceData::getVal1,btns)
+ .ge(DeviceData::getHappenTime,DateUtil.getPlusTime2(startDate))
+ .orderByDesc(DeviceData::getHappenTime));
+ if(dataList != null && dataList.size()>0 ){
+ for(String b : btns){
+ DeviceData last = getLastDataByVal1(b,dataList,closeDianliu);
+ if(last !=null && StringUtils.equals(last.getVal7(),"1")){
+ closeBtn.add(b);//闇�瑕佸垎闂�
+ }
+ }
+ if(StringUtils.equals( dataList.get(0).getVal7(),"0")){
+ log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄缁撴潫======鍒嗛椄鐘舵�佹棤闇�鎿嶄綔==="+device.getName());
+ continue;
+ }
+ }
+ if(closeBtn.size()>0){
+ Device param = new Device();
+ param.setLoginUserInfo(new LoginUserInfo());
+ param.getLoginUserInfo().setRealname("绯荤粺鑷姩鎺у埗");
+ param.setChannelNo(String.join(",",closeBtn));
+ param.setId(device.getId());
+ param.setStatus(Constants.ZERO);
+ dealDuanluqiCmd(device,param,"deviceTimer_");
+ }
+ }catch (Exception e){
+ log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄澶辫触========="+device.getName()+e.getMessage());
+ }
+ }
+ }
+ log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄鏁伴噺========="+devices.size());
+ }catch (Exception e){
+ log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄寮傚父========="+e.getMessage());
+ }finally {
+ Constants.DEALING_DUANLUQI_CLOSE = false;
+ }
+ log.error("寮�鍚畾鏃惰繙绋嬫帶鍒舵柇璺櫒鍒嗛椄缁撴潫=========");
+ }
+
+ private double getCloseDianliuByParam(Device device) {
+ try {
+ JSONObject json = JSONObject.parseObject(device.getDoorName() );
+ return json.getDouble("max");
+ }catch (Exception e){
+
+ }
+ return 0;
+ }
+
+ private DeviceData getLastDataByVal1(String b, List<DeviceData> dataList,double limit) {
+ List<DeviceData> list = new ArrayList<>();
+ for(DeviceData d :dataList){
+ if(StringUtils.equals(d.getVal1(),b)){
+ if(limit <= getNumberByStr(d.getVal2())){
+ //濡傛灉鏈夊疄鏃剁數娴佸�煎ぇ浜庣┖闂查槇鍊硷紝鍒欒〃绀哄伐浣滀腑锛屼笉鍋氬鐞�
+ return null;
+ }
+ list.add(d);
+ }
+ }
+ return list.size()>0?list.get(0):null;
+ }
+
+ private double getNumberByStr(String level) {
+ try {
+ return Double.parseDouble(level);
+ }catch (Exception e){
+
+ }
+ return 0;
+ }
}
--
Gitblit v1.9.3