最新版本541200007最新版本541200007
| | |
| | | export function updateEntranceById (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/device/updateEntranceById', data) |
| | | } |
| | | export function updateUsedById (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/device/updateUsedById', data) |
| | | } |
| | | export function duanluqiCmd (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/device/duanluqiCmd', data) |
| | | } |
| | | // åçledå±å
容 |
| | | export function setLedContent (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/hksync/setLedContent', data) |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import request from '../../utils/request' |
| | | |
| | | // æ¥è¯¢ |
| | | export function fetchList (data) { |
| | | return request.post('/visitsAdmin/cloudService/business/deviceData/page', data, { |
| | | trim: true |
| | | }) |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | .tip-header{ |
| | | font-size: 16px; |
| | | font-weight: bold; |
| | | margin-bottom: 20px; |
| | | } |
| | | .tip { |
| | | em { |
| | | font-style: normal; |
| | | color: $primary-color; |
| | | font-weight: bold; |
| | | } |
| | | } |
| | | .main_app { |
| | | background-color: #fff; |
| | | margin-top: 10px; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <GlobalWindow |
| | | :title="title" |
| | | width="85%" |
| | | :visible.sync="visible" |
| | | > |
| | | <TableLayout > |
| | | <!-- æç´¢è¡¨å --> |
| | | <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline> |
| | | <div style="display: block;margin-bottom: 60px;padding: 20px; border: 1px solid #f2f2f2;"> |
| | | <div style="display: block;font-size: 16px;font-weight: 600;margin-bottom: 20px;">设å¤ä¿¡æ¯</div> |
| | | <div style="display: flex;"> |
| | | <div style="flex: 1"><span class="label">åç§°ï¼</span>{{model.name ||''}}</div> |
| | | <div style="flex: 1"><span class="label">æ å¿ç¬¦ï¼</span>{{model.no ||''}}</div> |
| | | <div style="flex: 1"><span class="label">设å¤å·ï¼</span>{{model.doorNo ||'-'}}</div> |
| | | <div style="flex: 1"><span class="label">å¼å
³åºå·ï¼</span>{{model.channelNo ||'-'}}</div> |
| | | <div style="flex: 1"><span class="label">æ§å¶å¼å
³ï¼</span>{{model.channelInfo ||'-'}}</div> |
| | | </div> |
| | | <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>{{model.remark||''}}</div> |
| | | </div> |
| | | </div> |
| | | <el-form-item label="å¼å
³åºå·" prop="val1"> |
| | | <el-input v-model="searchForm.val1" placeholder="请è¾å
¥å¼å
³åºå·" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <section> |
| | | <el-button type="primary" @click="search">æç´¢</el-button> |
| | | <el-button @click="reset">éç½®</el-button> |
| | | </section> |
| | | </el-form> |
| | | <!-- è¡¨æ ¼åå页 --> |
| | | <template v-slot:table-wrap> |
| | | <el-table |
| | | :height="tableHeightNew" |
| | | v-loading="isWorking.search" |
| | | :data="tableData.list" |
| | | stripe> |
| | | <el-table-column prop="happenTime" label="䏿¥æ¶é´" min-width="150px"></el-table-column> |
| | | <el-table-column prop="val1" label="å¼å
³åºå·" min-width="120px"></el-table-column> |
| | | <el-table-column prop="val7" label="é¸ç¶æ" min-width="120px"> |
| | | <template slot-scope="{row}"> |
| | | <span v-if=" row.val7 === '1'" class="green">åé¸</span> |
| | | <span v-else-if=" row.val7 === '0'" class="red">åé¸</span> |
| | | <span v-else>-</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="val2" label="çµæµ(A)" min-width="120px"></el-table-column> |
| | | <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> |
| | | <pagination |
| | | @size-change="handleSizeChange" |
| | | @current-change="handlePageChange" |
| | | :pagination="tableData.pagination" |
| | | > |
| | | </pagination> |
| | | </template> |
| | | </TableLayout> |
| | | <template v-slot:footer> |
| | | <el-button @click="visible=false">è¿å</el-button> |
| | | </template> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | export default { |
| | | name: 'OperaJkSketchCustomerWindow', |
| | | extends: BaseTable, |
| | | components: { GlobalWindow, TableLayout, Pagination }, |
| | | data () { |
| | | return { |
| | | // è¡¨åæ°æ® |
| | | visible: false, |
| | | title: '', |
| | | model:{}, |
| | | searchForm: { |
| | | deviceId: null, |
| | | val1:'' |
| | | } |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | module: 'è®¾å¤æ°æ®ä¿¡æ¯è¡¨', |
| | | api: '/business/deviceData', |
| | | 'field.id': 'id', |
| | | 'field.main': 'id' |
| | | }) |
| | | this.search() |
| | | }, |
| | | methods: { |
| | | open (title, row) { |
| | | this.title = title +' ã'+ (row.name)+'ã' |
| | | this.searchForm.deviceId = row.id |
| | | if(!row.doorNameObj) { |
| | | row.doorNameObj = {} |
| | | } |
| | | this.model=row |
| | | this.visible = true |
| | | this.tableData = { |
| | | // å·²éä¸çæ°æ® |
| | | selectedRows: [], |
| | | // æåºçåæ®µ |
| | | sorts: [], |
| | | // å½åé¡µæ°æ® |
| | | list: [], |
| | | // å页 |
| | | pagination: { |
| | | pageIndex: 1, |
| | | pageSize: 10, |
| | | total: 0 |
| | | } |
| | | } |
| | | this.search() |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | <style> |
| | | .label{ |
| | | /* width: 80px; |
| | | text-align: right;*/ |
| | | color: rgb(102, 102, 102); |
| | | display: inline-block; |
| | | |
| | | } |
| | | </style> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <GlobalWindow |
| | | :title="title" |
| | | :visible.sync="visible" |
| | | width="65%" |
| | | :confirm-working="isWorking" |
| | | @confirm="confirm" |
| | | > |
| | | <el-form :model="form" ref="form" :rules="rules"> |
| | | <p class="tip-header" >åºæ¬ä¿¡æ¯</p> |
| | | <el-form-item label="设å¤åç§°" prop="name"> |
| | | <el-input v-model="form.name" placeholder="请è¾å
¥åç§°" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="è®¾å¤æ è¯ç¬¦" prop="no"> |
| | | <el-input v-model="form.no" placeholder="请è¾å
¥è®¾å¤æ è¯ç¬¦" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="设å¤å·" prop="doorNo"> |
| | | <el-input v-model="form.doorNo" placeholder="请è¾å
¥åºåå·" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="åå" prop="manufature"> |
| | | <el-input v-model="form.manufature" placeholder="请è¾å
¥æå¨ä½ç½®" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="å®è£
ä½ç½®" prop="regionPathName"> |
| | | <el-input v-model="form.regionPathName" placeholder="请è¾å
¥è®¾å¤ä½ç½®" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="è¿æ¥IP" prop="ip"> |
| | | <el-input v-model="form.ip" placeholder="请è¾å
¥è®¾å¤è¿æ¥IPå°å" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="è¿æ¥ç«¯å£" prop="port"> |
| | | <el-input v-model="form.port" placeholder="请è¾å
¥è¿æ¥ç«¯å£" v-trim/> |
| | | </el-form-item> |
| | | <p class="tip-header" >é
ç½®åæ°</p> |
| | | <p class="tip-warn" style="width: 100%;"><i class="el-icon-warning"></i>é
ç½®åæ°è¯´æï¼<br> |
| | | 1.å
¨é¨å¼å
³åºå·ï¼åè设å¤å®é
é
ç½®ï¼å¤ä¸ªç¨è±æéå·éå¼ï¼å¦ 1,2,3;<br> |
| | | 2.æ§å¶å¼å
³åºå·ï¼ç³»ç»æ ¹æ®é
ç½®è§åï¼å¤æå¼å
³å½å空é²ä¸è¿è¡ãèªå¨åé¸ã,å¤ä¸ªç¨è±æéå·éå¼ï¼å¦ 1,2;<br> |
| | | 3.èªå¨åé¸è§åï¼é对æ§å¶å¼å
³åºå·çé
ç½®ï¼å®æ¶æ£æµãç©ºé²æ¶é¿ãå
满足å¼å
³çµæµå¼é½å¨ã空é²çµæµéå¼ãèå´å
ï¼åè¿è¡èªå¨å鏿§å¶;<br> |
| | | 4.ç©ºé²æ¶é¿: 请设置è³å°ç©ºé²æ¶é¿å¤§äºçäº300ç§ï¼5åéï¼ã |
| | | 5.å¦éè¿ç¨æ§å¶å¼å
³ï¼è¯·æ£ç¡®å¡«åä¸è¿°å
¨é¨åæ°ä¿¡æ¯ã |
| | | </p> |
| | | <div style="display: flex"> |
| | | <el-form-item label="å
¨é¨å¼å
³åºå·" prop="channelNo" style="display: inline-block;width:300px;"> |
| | | <el-input v-model="form.channelNo" placeholder="请è¾å
¥å¼å
³åºå·ï¼å¤ä¸ªç¨è±æéå·éå¼ï¼å¦ 1,2,3" v-trim style="width: 150px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="æ§å¶å¼å
³åºå·" prop="channelInfo" style="display: inline-block;width:300px;"> |
| | | <el-input v-model="form.channelInfo" placeholder="请è¾å
¥æ§å¶å¼å
³åºå·ï¼å¤ä¸ªç¨è±æéå·éå¼ï¼å¦ 1,2,3" v-trim style="width: 150px;" /> |
| | | </el-form-item> |
| | | </div> |
| | | <div style="display: flex"> |
| | | <!-- <el-form-item label="空é²çµæµéå¼" prop="mqttPassword" style="display: inline-block;width:250px;"> |
| | | <el-input v-model="form.doorNameObj.min" style="width: 150px;" disabled type="number" maxlength="30" placeholder="æå°å¼" > |
| | | <template slot="append">A</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <span style="margin: 5px 10px;">è³</span>--> |
| | | <el-form-item label="空é²çµæµéå¼" label-width="105px" prop="max" style="display: inline-block;width:300px"> |
| | | <el-input v-model="form.doorNameObj.max" style="width: 150px;" type="number" maxlength="30" placeholder="æå¤§å¼" > |
| | | <template slot="append">A</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="ç©ºé²æ¶é¿(ç§)" prop="level" style="display: inline-block;width:350px;margin-left: 0px;"> |
| | | <el-input v-model="form.level" style="width: 180px;" type="number" maxlength="30" placeholder="请è¾å
¥ç©ºé²æ¶é¿" > |
| | | <template slot="append">ç§</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | </div> |
| | | <el-form-item label="MQTTæå¡IP" prop="mqttIp"> |
| | | <el-input v-model="form.doorNameObj.mqttIp" placeholder="请è¾å
¥è®¾å¤è¿æ¥MQTT-IP" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="MQTTæå¡ç«¯å£" prop="mqttPort"> |
| | | <el-input v-model="form.doorNameObj.mqttPort" placeholder="请è¾å
¥è¿æ¥MQTTæå¡ç«¯å£" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="MQTTæå¡è´¦å·" prop="mqttUsername"> |
| | | <el-input v-model="form.doorNameObj.mqttUsername" placeholder="请è¾å
¥è®¾å¤è¿æ¥MQTTæå¡è´¦å·" v-trim/> |
| | | </el-form-item> |
| | | <el-form-item label="MQTTæå¡å¯ç " prop="mqttPassword"> |
| | | <el-input v-model="form.doorNameObj.mqttPassword" type="password" maxlength="30" show-password></el-input> |
| | | </el-form-item> |
| | | <p class="tip-warn" style="width: 100%;"><i class="el-icon-warning"></i> éå
çµç¶æçµæµå¤§å°æ¥å
¥è®¾å¤åï¼åç
§ç°åºå®é
åºæ¯é
ç½®;</p> |
| | | </el-form> |
| | | </GlobalWindow> |
| | | </template> |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | export default { |
| | | name: 'OperaDeviceDuanluqiWindow', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow }, |
| | | data () { |
| | | return { |
| | | // è¡¨åæ°æ® |
| | | form: { |
| | | id: null, |
| | | name: '', |
| | | regionPathName: '', |
| | | doorNo: '', |
| | | no: '', |
| | | type: 5, |
| | | ip: '', |
| | | port: '', |
| | | level: '', |
| | | doorName: '', |
| | | doorId: '', |
| | | doorNameObj: { |
| | | mqttUsername: '', |
| | | mqttPassword: '', |
| | | mqttIp: '', |
| | | mqttPort: '', |
| | | max: null, |
| | | min: null |
| | | }, |
| | | channelInfo: '', |
| | | manufature: '', |
| | | channelNo: '' |
| | | }, |
| | | // éªè¯è§å |
| | | rules: { |
| | | name: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤åç§°' } |
| | | ], |
| | | /* max: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤ç©ºé²çµæµéå¼' } |
| | | ],*/ |
| | | doorId: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤è¿æ¥è´¦å·' } |
| | | ], |
| | | doorName: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤è¿æ¥å¯ç ' } |
| | | ], |
| | | channelNo: [ |
| | | { required: true, message: '请è¾å
¥å¼å
³åºå·' } |
| | | ], |
| | | doorNo: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤å·' } |
| | | ], |
| | | no: [ |
| | | { required: true, message: '请è¾å
¥è®¾å¤æ è¯ç¬¦' } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | api: '/business/device', |
| | | 'field.id': 'id' |
| | | }) |
| | | }, |
| | | methods: { |
| | | open (title, target) { |
| | | this.title = title |
| | | this.visible = true |
| | | this.form.doorName = '' |
| | | this.form.doorNameObj = { |
| | | mqttUsername: '', |
| | | mqttPassword: '', |
| | | mqttIp: '', |
| | | mqttPort: '', |
| | | max: null, |
| | | min: 0 |
| | | } |
| | | // debugger |
| | | // æ°å»º |
| | | if (target == null) { |
| | | this.$nextTick(() => { |
| | | this.$refs.form.resetFields() |
| | | this.form[this.configData['field.id']] = null |
| | | }) |
| | | if(!this.form.doorNameObj){ |
| | | this.form.doorNameObj = { |
| | | mqttUsername: '', |
| | | mqttPassword: '', |
| | | mqttIp: '', |
| | | mqttPort: '', |
| | | max: null, |
| | | min: 0 |
| | | } |
| | | } |
| | | return |
| | | } |
| | | // ç¼è¾ |
| | | this.$nextTick(async () => { |
| | | for (const key in this.form) { |
| | | this.form[key] = target[key] |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | |
| | | import OperaJkSketchLineMapWindow from '@/components/business/OperaJkSketchLineMapWindow' |
| | | import { initOriginDistance } from '@/api/business/jkSketch' |
| | | export default { |
| | | name: 'OperaJkSketchLineWindow', |
| | | name: 'OperaDeviceDataListWindow', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow, OperaJkSketchCustomerWindow ,OperaJkSketchLineMapWindow}, |
| | | data () { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <TableLayout :permissions="['business:device:query']"> |
| | | <!-- æç´¢è¡¨å --> |
| | | <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline> |
| | | <el-form-item title="åç§°" prop="name"> |
| | | <el-input v-model="searchForm.name" placeholder="请è¾å
¥åç§°" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item title="æ è¯ç¬¦" prop="no"> |
| | | <el-input v-model="searchForm.no" placeholder="请è¾å
¥è®¾å¤æ è¯ç¬¦" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <el-form-item title="设å¤å·" prop="doorNo"> |
| | | <el-input v-model="searchForm.doorNo" placeholder="请è¾å
¥è®¾å¤å·" @keypress.enter.native="search"></el-input> |
| | | </el-form-item> |
| | | <section> |
| | | <el-button type="primary" @click="search">æç´¢</el-button> |
| | | <el-button @click="reset">éç½®</el-button> |
| | | </section> |
| | | </el-form> |
| | | <!-- è¡¨æ ¼åå页 --> |
| | | <template v-slot:table-wrap> |
| | | <ul class="toolbar" v-permissions="['business:device:create', 'business:device:delete']"> |
| | | <li><el-button type="primary" @click="$refs.operaDeviceWindow.open('æ°å»ºæè·¯å¨')" icon="el-icon-plus" v-permissions="['business:device:create']">æ°å»º</el-button></li> |
| | | <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:device:delete']">å é¤</el-button></li> |
| | | </ul> |
| | | <el-table |
| | | :height="tableHeightNew" |
| | | v-loading="isWorking.search" |
| | | :data="tableData.list" |
| | | stripe |
| | | > |
| | | <el-table-column type="selection" width="55"></el-table-column> |
| | | <el-table-column prop="name" label="åç§°" fixed min-width="150" align="center"></el-table-column> |
| | | <el-table-column prop="no" label="è®¾å¤æ è¯ç¬¦" min-width="100" align="center" ></el-table-column> |
| | | <el-table-column prop="doorNo" label="设å¤å·" min-width="120" align="center" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="channelNo" label="å¼å
³åºå·" align="center" min-width="100"></el-table-column> |
| | | <el-table-column prop="manufature" label="åå" align="center" min-width="100" show-overflow-tooltip></el-table-column> |
| | | <el-table-column prop="regionPathName" align="center" min-width="100" label="æå¨ä½ç½®"></el-table-column> |
| | | <el-table-column prop="ip" label="IP" min-width="150" align="center" show-overflow-tooltip ></el-table-column> |
| | | <el-table-column prop="port" label="端å£" align="center" ></el-table-column> |
| | | <el-table-column prop="isUsed" label="æ¯å¦ä½¿ç¨"> |
| | | <template slot-scope="{row}"> |
| | | <el-switch @change="changeUsed($event, row)" v-model="row.isUsed" active-color="#13ce66" |
| | | inactive-color="#ff4949" :active-value="0" :inactive-value="1"> |
| | | </el-switch> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="editDate" label="æè¿æ´æ°æ¶é´" align="center" min-width="150"></el-table-column> |
| | | <el-table-column prop="channelParam" label="æ§å¶å¼å
³åæ°" align="center" min-width="100"> |
| | | <el-table-column prop="channelInfo" label="æ§å¶å¼å
³åºå·" align="center" min-width="100"></el-table-column> |
| | | <el-table-column prop="level" label="ç©ºé²æ¶é´(ç§)" align="center" min-width="100"></el-table-column> |
| | | <el-table-column label="空é²çµæµéå¼" align="center" min-width="120"> |
| | | <template slot-scope="{row}"> |
| | | <span >{{ row.doorNameObj.max || '-'}}A</span> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table-column> |
| | | <el-table-column prop="doorNameObj" label="MQTTé
ç½®åæ°" align="center"> |
| | | <el-table-column prop="doorNameObj.mqttIp" label="IP" min-width="120" align="center"></el-table-column> |
| | | <el-table-column prop="doorNameObj.mqttPort" label="端å£" min-width="80" align="center"></el-table-column> |
| | | <el-table-column prop="doorNameObj.mqttUsername" label="è´¦å·" align="center"></el-table-column> |
| | | <el-table-column prop="doorNameObj.mqttPassword" label="å¯ç " align="center"> |
| | | <template slot-scope="{row}"> |
| | | <span :class=" 'blue'">{{row.showPwd?row.doorNameObj.mqttPassword:'******'}}</span> |
| | | <el-button style="margin-left: 10px" v-if="row.doorNameObj.mqttPassword!=null" |
| | | @click.native.p.prevent="showPassward(row)" type="text"> |
| | | <i class="el-icon-view" :class="row.showPwd?'red':'blue'" :title="row.showPwd?'éè':'æ¾ç¤º'"></i> |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table-column> |
| | | <el-table-column |
| | | label="æä½" |
| | | align="center" |
| | | min-width="280" |
| | | fixed="right" |
| | | > |
| | | <template slot-scope="{row}"> |
| | | <el-button type="text" @click="$refs.operaDeviceWindow.open('ç¼è¾æè·¯å¨', row)" icon="el-icon-edit" v-permissions="['business:device:update']">ç¼è¾</el-button> |
| | | <el-button type="text" @click="$refs.operaDeviceDataWindow.open('æ¥çæè·¯å¨æ°æ®', row)" icon="el-icon-view" v-permissions="['business:device:update']">æ°æ®</el-button> |
| | | <el-button type="text" @click="send(row,1)" icon="el-icon-circle-check" v-permissions="['business:device:update']">å¼é¸</el-button> |
| | | <el-button type="text" class="red" @click="send(row,0)" icon="el-icon-circle-close" v-permissions="['business:device:update']">å
³é¸</el-button> |
| | | <el-button type="text" class="red" @click="deleteById(row)" icon="el-icon-delete" v-permissions="['business:device:delete']">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | @size-change="handleSizeChange" |
| | | @current-change="handlePageChange" |
| | | :pagination="tableData.pagination" |
| | | > |
| | | </pagination> |
| | | </template> |
| | | <el-dialog |
| | | :visible.sync="visibleSend" |
| | | style="z-index: 100000" |
| | | append-to-body |
| | | width="50%" |
| | | height="50%" |
| | | :title="'æ§å¶å¼å
³-ã'+ form.name+'ã'" |
| | | > |
| | | <el-form :model="form" ref="form" :rules="rules"> |
| | | <el-form-item label="æ§è¡æä½ï¼" > |
| | | <b class="green" v-if="form.status ===1">å¼é¸</b> |
| | | <b class="red" v-else>å
³é¸</b> |
| | | </el-form-item> |
| | | <el-form-item label="å¼å
³åºå·" prop="channelNo"> |
| | | <el-input v-model="form.channelNo" type="text" placeholder="请è¾å
¥å¼å
³åºå· ï¼å¤ä¸ªç¨è±æéå·éå¼ï¼å¦ 1,2,3" v-trim/> |
| | | </el-form-item> |
| | | <p class="tip-warn" style="width: 100%;"><i class="el-icon-warning"></i>设å¤åå§å¼å
³åºå·ä¿¡æ¯ï¼{{form.channelNo1}}ï¼æ§å¶å¤ä¸ªå¼å
³ï¼è¯·ç¨è±æéå·éå¼ï¼å¦ 1,2;</p> |
| | | </el-form> |
| | | <template v-slot:footer > |
| | | <el-button @click="sendAction()" type="primary" v-if="form.status === 1" :loading="isWorkSending">确认å¼é¸</el-button> |
| | | <el-button @click="sendAction()" type="danger" v-if="form.status !== 1" :loading="isWorkSending">确认å
³é¸</el-button> |
| | | <el-button @click="sendClose()">è¿å</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | <!-- æ°å»º/ä¿®æ¹ --> |
| | | <OperaDeviceDuanluqiWindow ref="operaDeviceWindow" @success="handlePageChange"/> |
| | | <OperaDeviceDataListWindow ref="operaDeviceDataWindow" @success="handlePageChange"/> |
| | | </TableLayout> |
| | | </template> |
| | | <script> |
| | | import BaseTable from '@/components/base/BaseTable' |
| | | import TableLayout from '@/layouts/TableLayout' |
| | | import Pagination from '@/components/common/Pagination' |
| | | import OperaDeviceDataListWindow from '@/components/business/OperaDeviceDataListWindow' |
| | | import OperaDeviceDuanluqiWindow from '@/components/business/OperaDeviceDuanluqiWindow' |
| | | export default { |
| | | name: 'DeviceDuanluqi', |
| | | extends: BaseTable, |
| | | components: { TableLayout, Pagination, OperaDeviceDuanluqiWindow ,OperaDeviceDataListWindow}, |
| | | data () { |
| | | return { |
| | | // æç´¢ |
| | | searchForm: { |
| | | doorName: '', |
| | | doorNo: '', |
| | | no: '', |
| | | regionPathName: '', |
| | | type: 5 |
| | | }, |
| | | isWorkSending: false, |
| | | form: { |
| | | id: '', |
| | | name: '', |
| | | channelNo: '', |
| | | channelNo1: '', |
| | | status: null |
| | | }, |
| | | visibleSend: false, |
| | | options: [], |
| | | rules: { |
| | | channelNo: [{ required: true, message: '请è¾å
¥éè¦æä½çå¼å
³åºå·', trigger: 'blur' }], |
| | | } |
| | | } |
| | | }, |
| | | created () { |
| | | this.config({ |
| | | module: '设å¤ä¿¡æ¯è¡¨', |
| | | api: '/business/device', |
| | | 'field.id': 'id', |
| | | 'field.main': 'id' |
| | | }) |
| | | this.search() |
| | | }, |
| | | methods: { |
| | | changeUsed (e, row) { |
| | | this.api.updateUsedById({ |
| | | id: row.id, |
| | | isUsed: e |
| | | }) |
| | | }, |
| | | showPassward (row) { |
| | | if (!row.showPwd) { |
| | | this.$set(row, 'showPwd', true) |
| | | } else { |
| | | this.$set(row, 'showPwd', false) |
| | | } |
| | | }, |
| | | sendAction () { |
| | | if (!this.form.channelNo) { |
| | | return |
| | | } |
| | | this.$dialog.actionConfirm('确认è¿è¡æè·¯å¨ã' + (this.form.status === 1 ? 'å¼é¸' : 'å
³é¸') + 'ãæä½åï¼', 'æä½ç¡®è®¤æé') |
| | | .then(() => { |
| | | this.isWorkSending = true |
| | | this.api.duanluqiCmd(this.form) |
| | | .then(res => { |
| | | this.$tip.apiSuccess(res || 'è¯·æ±æå') |
| | | this.sendClose() |
| | | }) |
| | | .catch(e => { |
| | | }) |
| | | .finally(() => { |
| | | this.isWorkSending = false |
| | | }) |
| | | }) |
| | | .catch(() => {}) |
| | | }, |
| | | send (row, type) { |
| | | this.visibleSend = true |
| | | this.form = { id: row.id, name: row.name, channelNo: row.channelNo, status: type ,channelNo1:row.channelNo} |
| | | }, |
| | | sendClose () { |
| | | this.visibleSend = false |
| | | this.isWorkSending = false |
| | | this.form = { id: '', name: '', channelNo: '', status: '',channelNo1:'' } |
| | | } |
| | | |
| | | } |
| | | } |
| | | </script> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 `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` ( |
| | | `ID` int NOT NULL AUTO_INCREMENT COMMENT '主é®', |
| | | `CREATOR` int DEFAULT NULL COMMENT 'å建人ç¼ç ', |
| | | `CREATE_DATE` datetime DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `EDITOR` int DEFAULT NULL COMMENT 'æ´æ°äººç¼ç ', |
| | | `EDIT_DATE` datetime DEFAULT NULL COMMENT 'æ´æ°æ¶é´', |
| | | `ISDELETED` int DEFAULT NULL COMMENT 'æ¯å¦å é¤0å¦ 1æ¯', |
| | | `REMARK` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '夿³¨', |
| | | `DATA_JSON` text COLLATE utf8mb4_unicode_ci COMMENT 'æ°æ®json对象', |
| | | `DEVICE_ID` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '设å¤ç¼ç ï¼å
³èdevice)', |
| | | `HAPPEN_TIME` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'åçæ¶é´', |
| | | `VAL1` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '屿§å¼1', |
| | | `VAL2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '屿§å¼2', |
| | | `VAL3` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '屿§å¼3', |
| | | `VAL4` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '屿§å¼4', |
| | | `VAL5` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '屿§å¼5', |
| | | `VAL6` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '屿§å¼6', |
| | | `DATA_TYPE` int DEFAULT NULL COMMENT 'æ°æ®æ¥æº 0mqtt䏿¥ 1å
¶ä»', |
| | | PRIMARY KEY (`ID`), |
| | | UNIQUE KEY `eventIdnex` (`DEVICE_ID`,`HAPPEN_TIME`) USING BTREE |
| | | ) ENGINE=InnoDB AUTO_INCREMENT=106097 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='é¨ç¦äºä»¶æ¨éè®°å½è¡¨'; |
| | |
| | | <module>system_timer</module> |
| | | <module>system_gateway</module> |
| | | <module>emaysms</module> |
| | | <module>visits/device_service</module> |
| | | </modules> |
| | | <parent> |
| | | <groupId>org.springframework.boot</groupId> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.core.utils; |
| | | |
| | | /** |
| | | * è®¾å¤æä»¤åæ°éå |
| | | */ |
| | | public class CmdContants { |
| | | public interface T30A{ |
| | | String cmdParam ="{" + |
| | | " \"method\": 3," + |
| | | " \"dstID\" : 43008827854690816," +//设å¤å· |
| | | " \"msgCode\": 120," + |
| | | " \"timeMS\": 0," + |
| | | " \"data\":" + |
| | | " [{" + |
| | | " \"tag\":305," + |
| | | " \"cmd\":\"$CMD\", " +//æä»¤ |
| | | " \"count\":3," + |
| | | " \"busAddr\":[$BUSADDR]" +//模åå°å |
| | | " }]" + |
| | | "}"; |
| | | } |
| | | |
| | | /** |
| | | * 说æï¼ ï¼1ï¼é对空å¼è®¾å¤æä½ï¼ 䏿¬¡ä»
è½æ§è¡ä¸æ¡å½ä»¤ï¼å æ¤æ éæä¾"busAddr"ã"devID"å"count"åæ®µï¼å¦æå½ä»¤ä¸éè¦æºå¸¦åæ°ï¼"para"åæ®µä¹åæ ·æ éæä¾ã |
| | | * ï¼2ï¼ç©ºå¼æå¨åé¸ä¼è¿å
¥å¼å¸¸é宿¨¡å¼ï¼é对对åºçº¿è·¯è®¾å¤ä¸åå¼å¸¸è§£éæä»¤åææå¨åé¸ç©ºå¼æè½è¿ç¨æ§å¶ã |
| | | */ |
| | | public interface T30ACmd{ |
| | | String do_lock = "do_lock";//éå® |
| | | String do_unlock = "do_unlock";//è§£é |
| | | String do_err_clear = "do_err_clear";//å¼å¸¸è§£é |
| | | String doLeakageCheck = "do_leakage_check";//æå¨æ¼çµèªæ£ |
| | | String do_turn_off = "do_turn_off";//ä¸é®åé¸ |
| | | String do_turn_on = "do_turn_on";//ä¸é®åé¸ |
| | | String do_reboot = "do_reboot";//è¿ç¨éå¯ |
| | | String do_refresh_bus = "do_refresh_bus";//å·æ°æ»çº¿ |
| | | String do_set_factory = "do_set_factory";//æ¢å¤åºå设置 |
| | | String do_auto_address = "do_auto_address";//èªå¨åé
å°å |
| | | String do_mod_passwd = "do_mod_passwd";//ä¿®æ¹è®¾å¤å¯ç |
| | | String do_updrade = "do_updrade";//å¨çº¿å级æä»¤ |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | return JSONObject.toJSONString(map); |
| | | } |
| | | |
| | | public interface MqttTopic{ |
| | | String mts_attr = "/dev/+/+/attr/json";//屿§topic |
| | | String mts_status = "/dev/+/+/status/json";//ç¶ætopic |
| | | 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 { |
| | |
| | | @ApiOperation("ãé¥åæã宿¶åéé¥åæªåæ¶å½è¿éç¥") |
| | | @PostMapping("/timer/jkCabinet/timeOutUnBackAlarm") |
| | | ApiResponse timeOutUnBackAlarm(); |
| | | @ApiOperation("ãæè·¯å¨ãå¼å¯å®æ¶è¿ç¨æ§å¶æè·¯å¨åé¸") |
| | | @PostMapping("/timer/duanluqi/autoCloseCmd") |
| | | ApiResponse autoCloseCmd(); |
| | | } |
| | |
| | | spring: |
| | | profiles: |
| | | active: test |
| | | active: dev |
| | | application: |
| | | name: systemTimer |
| | | # å®å
¨é
ç½® |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.api; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.HttpsUtil; |
| | | import com.doumee.core.wx.WXConstant; |
| | | import com.doumee.dao.system.model.SystemDictData; |
| | | import com.doumee.service.business.DeviceService; |
| | | import com.doumee.service.business.third.model.ApiResponse; |
| | | import com.doumee.service.system.SystemDictDataService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.mgt.DefaultSecurityManager; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Date; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/11/30 15:33 |
| | | */ |
| | | @Api(tags = "æè·¯å¨è¿ç¨æ§å¶å®æ¶å¨") |
| | | @RestController |
| | | @RequestMapping("/timer/duanluqi") |
| | | public class DuanluqiTimerController extends BaseController { |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | |
| | | @ApiOperation("å¼å¯å®æ¶è¿ç¨æ§å¶æè·¯å¨åé¸") |
| | | @PostMapping("/autoCloseCmd") |
| | | public ApiResponse autoCloseCmd() { |
| | | deviceService.autoCloseCmdTimer(); |
| | | return ApiResponse.success("å¼å¯å®æ¶è¿ç¨æ§å¶æè·¯å¨å鏿å"); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | spring: |
| | | profiles: |
| | | active: pro |
| | | active: dev |
| | | application: |
| | | name: visitsTimer |
| | | # å®å
¨é
ç½® |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <parent> |
| | | <groupId>com.doumee</groupId> |
| | | <artifactId>dmvisit</artifactId> |
| | | <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> |
| | | </properties> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.eclipse.paho</groupId> |
| | | <artifactId>org.eclipse.paho.client.mqttv3</artifactId> |
| | | <version>1.2.2</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | </project> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee; |
| | | |
| | | public class Main { |
| | | public static void main(String[] args) { |
| | | System.out.println("Hello world!"); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.mqtt.config; |
| | | |
| | | import org.eclipse.paho.client.mqttv3.*; |
| | | import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; |
| | | |
| | | public class MqttClientInit { |
| | | static MqttClient client; |
| | | static MqttClient subClient; |
| | | public static synchronized MqttClient getPublishInstance(MqttConfig config ){ |
| | | if(client !=null){ |
| | | if(!client.isConnected()){ |
| | | try { |
| | | client.reconnect(); |
| | | } catch (MqttException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | return client; |
| | | } |
| | | try { |
| | | // host为主æºåï¼clientidå³è¿æ¥MQTTç客æ·ç«¯IDï¼ä¸è¬ä»¥å¯ä¸æ è¯ç¬¦è¡¨ç¤ºï¼MemoryPersistence设置clientidçä¿åå½¢å¼ï¼é»è®¤ä¸ºä»¥å
åä¿å |
| | | String clientId =config.getClientid() +config.getVersion(); |
| | | client = new org.eclipse.paho.client.mqttv3.MqttClient(config.getHost(), clientId,new MemoryPersistence()); |
| | | // MQTTçè¿æ¥è®¾ç½® |
| | | MqttConnectOptions options = new MqttConnectOptions(); |
| | | // 设置æ¯å¦æ¸
空session,è¿éå¦æè®¾ç½®ä¸ºfalse表示æå¡å¨ä¼ä¿ç客æ·ç«¯çè¿æ¥è®°å½ï¼è®¾ç½®ä¸ºtrueè¡¨ç¤ºæ¯æ¬¡è¿æ¥å°æå¡å¨é½ä»¥æ°çèº«ä»½è¿æ¥ |
| | | options.setCleanSession(false); |
| | | // è®¾ç½®è¿æ¥çç¨æ·å |
| | | options.setUserName(config.getUsername()); |
| | | // è®¾ç½®è¿æ¥çå¯ç |
| | | options.setPassword(config.getPassword().toCharArray()); |
| | | // 设置è¶
æ¶æ¶é´ åä½ä¸ºç§ |
| | | options.setConnectionTimeout(10); |
| | | // 设置ä¼è¯å¿è·³æ¶é´ åä½ä¸ºç§ æå¡å¨ä¼æ¯é1.5*20ç§çæ¶é´å客æ·ç«¯åéä¸ªæ¶æ¯å¤æå®¢æ·ç«¯æ¯å¦å¨çº¿ï¼ä½è¿ä¸ªæ¹æ³å¹¶æ²¡æéè¿çæºå¶ |
| | | options.setKeepAliveInterval(20); |
| | | //设置æå¼åéæ°è¿æ¥ |
| | | options.setAutomaticReconnect(true); |
| | | MqttTopic topic = client.getTopic(clientId+"_close"); |
| | | //éå± |
| | | options.setWill(topic, "close".getBytes(), 1, true); |
| | | client.connect(options); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return client; |
| | | } |
| | | public static synchronized MqttClient getSubInstance(MqttConfig config, MqttCallback callBack){ |
| | | if(subClient !=null){ |
| | | refreshClient(); |
| | | return subClient; |
| | | } |
| | | try { |
| | | // host为主æºåï¼clientidå³è¿æ¥MQTTç客æ·ç«¯IDï¼ä¸è¬ä»¥å¯ä¸æ è¯ç¬¦è¡¨ç¤ºï¼MemoryPersistence设置clientidçä¿åå½¢å¼ï¼é»è®¤ä¸ºä»¥å
åä¿å |
| | | String clientId =config.getSubclientid() +config.getVersion(); |
| | | subClient = new org.eclipse.paho.client.mqttv3.MqttClient(config.getHost(), clientId,new MemoryPersistence()); |
| | | // MQTTçè¿æ¥è®¾ç½® |
| | | MqttConnectOptions options = new MqttConnectOptions(); |
| | | // 设置æ¯å¦æ¸
空session,è¿éå¦æè®¾ç½®ä¸ºfalse表示æå¡å¨ä¼ä¿ç客æ·ç«¯çè¿æ¥è®°å½ï¼è®¾ç½®ä¸ºtrueè¡¨ç¤ºæ¯æ¬¡è¿æ¥å°æå¡å¨é½ä»¥æ°çèº«ä»½è¿æ¥ |
| | | options.setCleanSession(false); |
| | | // è®¾ç½®è¿æ¥çç¨æ·å |
| | | options.setUserName(config.getUsername()); |
| | | // è®¾ç½®è¿æ¥çå¯ç |
| | | options.setPassword(config.getPassword().toCharArray()); |
| | | // 设置è¶
æ¶æ¶é´ åä½ä¸ºç§ |
| | | options.setConnectionTimeout(10); |
| | | // 设置ä¼è¯å¿è·³æ¶é´ åä½ä¸ºç§ æå¡å¨ä¼æ¯é1.5*20ç§çæ¶é´å客æ·ç«¯åéä¸ªæ¶æ¯å¤æå®¢æ·ç«¯æ¯å¦å¨çº¿ï¼ä½è¿ä¸ªæ¹æ³å¹¶æ²¡æéè¿çæºå¶ |
| | | options.setKeepAliveInterval(20); |
| | | // 设置åè° |
| | | subClient.setCallback(callBack); |
| | | //设置æå¼åéæ°è¿æ¥ |
| | | options.setAutomaticReconnect(true); |
| | | MqttTopic topic = subClient.getTopic(clientId+"_close"); |
| | | //éå± |
| | | options.setWill(topic, "close".getBytes(), 1, true); |
| | | subClient.connect(options); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return subClient; |
| | | } |
| | | public static synchronized MqttClient getInstance(MqttClient clientModel,MqttConfig config, MqttCallback callBack){ |
| | | if(clientModel !=null){ |
| | | refreshClient(clientModel); |
| | | return clientModel; |
| | | } |
| | | try { |
| | | // host为主æºåï¼clientidå³è¿æ¥MQTTç客æ·ç«¯IDï¼ä¸è¬ä»¥å¯ä¸æ è¯ç¬¦è¡¨ç¤ºï¼MemoryPersistence设置clientidçä¿åå½¢å¼ï¼é»è®¤ä¸ºä»¥å
åä¿å |
| | | String clientId =config.getClientid() +config.getVersion(); |
| | | clientModel = new org.eclipse.paho.client.mqttv3.MqttClient(config.getHost(), clientId,new MemoryPersistence()); |
| | | // MQTTçè¿æ¥è®¾ç½® |
| | | MqttConnectOptions options = new MqttConnectOptions(); |
| | | // 设置æ¯å¦æ¸
空session,è¿éå¦æè®¾ç½®ä¸ºfalse表示æå¡å¨ä¼ä¿ç客æ·ç«¯çè¿æ¥è®°å½ï¼è®¾ç½®ä¸ºtrueè¡¨ç¤ºæ¯æ¬¡è¿æ¥å°æå¡å¨é½ä»¥æ°çèº«ä»½è¿æ¥ |
| | | options.setCleanSession(false); |
| | | // è®¾ç½®è¿æ¥çç¨æ·å |
| | | options.setUserName(config.getUsername()); |
| | | // è®¾ç½®è¿æ¥çå¯ç |
| | | options.setPassword(config.getPassword().toCharArray()); |
| | | // 设置è¶
æ¶æ¶é´ åä½ä¸ºç§ |
| | | options.setConnectionTimeout(10); |
| | | // 设置ä¼è¯å¿è·³æ¶é´ åä½ä¸ºç§ æå¡å¨ä¼æ¯é1.5*20ç§çæ¶é´å客æ·ç«¯åéä¸ªæ¶æ¯å¤æå®¢æ·ç«¯æ¯å¦å¨çº¿ï¼ä½è¿ä¸ªæ¹æ³å¹¶æ²¡æéè¿çæºå¶ |
| | | options.setKeepAliveInterval(20); |
| | | // 设置åè° |
| | | clientModel.setCallback(callBack); |
| | | //设置æå¼åéæ°è¿æ¥ |
| | | options.setAutomaticReconnect(true); |
| | | MqttTopic topic = clientModel.getTopic(clientId+"_close"); |
| | | //éå± |
| | | options.setWill(topic, "close".getBytes(), 1, true); |
| | | clientModel.connect(options); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return clientModel; |
| | | } |
| | | |
| | | |
| | | public static synchronized void refreshClient( ) { |
| | | try { |
| | | if(subClient !=null && !subClient.isConnected()){ |
| | | subClient.reconnect(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | public static synchronized void refreshClient(MqttClient clientModel ) { |
| | | try { |
| | | if(clientModel !=null && !clientModel.isConnected()){ |
| | | clientModel.reconnect(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.mqtt.config; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class MqttConfig { |
| | | /** |
| | | *æå¡å¨å°å ip+端å£ï¼å¦tcp://175.27.187.84:1883 |
| | | */ |
| | | private String host; |
| | | /** |
| | | * 客æ·ç«¯ç¼ç |
| | | */ |
| | | private String clientid; |
| | | /** |
| | | * 客æ·ç«¯ç¼ç ç¨æ·è®¢é
|
| | | */ |
| | | private String subclientid; |
| | | /** |
| | | * ææè´¦å· |
| | | */ |
| | | private String username ; |
| | | /** |
| | | * ææå¯ç |
| | | */ |
| | | private String password; |
| | | /** |
| | | * 客æ·ç«¯çæ¬åç¼ |
| | | */ |
| | | private String version; |
| | | |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.mqtt.service; |
| | | |
| | | import com.doumee.mqtt.config.MqttConfig; |
| | | import org.eclipse.paho.client.mqttv3.MqttClient; |
| | | import org.eclipse.paho.client.mqttv3.MqttMessage; |
| | | |
| | | /** |
| | | * ä¸ç¡¬ä»¶å¯¹æ¥æå¡ |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/09 18:06 |
| | | */ |
| | | public interface MqttBizService { |
| | | |
| | | /** |
| | | * æé
置订é
|
| | | * @param config |
| | | * @param topics |
| | | */ |
| | | MqttClient subscribe(MqttClient client,MqttConfig config, String[] topics); |
| | | MqttClient unsubscribe(MqttClient client,MqttConfig config, String[] topics); |
| | | /** |
| | | * æé
ç½®å叿¶æ¯ |
| | | * @param config |
| | | * @param topic |
| | | */ |
| | | MqttClient publish(MqttClient client,MqttConfig config,String topic,String param); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.mqtt.service; |
| | | |
| | | import com.doumee.mqtt.config.MqttClientInit; |
| | | import com.doumee.mqtt.config.MqttConfig; |
| | | import lombok.Data; |
| | | import org.eclipse.paho.client.mqttv3.MqttCallback; |
| | | import org.eclipse.paho.client.mqttv3.MqttClient; |
| | | import org.eclipse.paho.client.mqttv3.MqttMessage; |
| | | |
| | | @Data |
| | | public class MqttToolService { |
| | | /** |
| | | * 订é
æ¶æ¯ï¼å¯å¨å è½½ä¸æ¬¡ |
| | | * @param topics |
| | | */ |
| | | public static MqttClient subscribe(MqttClient clientTemp,MqttConfig config,String[] topics, MqttCallback callBack) { |
| | | try { |
| | | //订é
æ¶æ¯ |
| | | int[] Qos = new int[topics.length];//0ï¼æå¤ä¸æ¬¡ ã1ï¼æå°ä¸æ¬¡ ã2ï¼åªæä¸æ¬¡ |
| | | for (int i = 0; i < Qos.length; i++) { |
| | | Qos[i] = 1; |
| | | /*if(i ==2){ |
| | | Qos[i] = 2; |
| | | }else{ |
| | | Qos[i] = 1; |
| | | }*/ |
| | | } |
| | | clientTemp = MqttClientInit.getInstance(clientTemp,config,callBack); |
| | | try { |
| | | clientTemp.subscribe(topics, Qos); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return clientTemp; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return clientTemp; |
| | | } |
| | | public static MqttClient unsubscribe(MqttClient clientTemp,MqttConfig config,String[] topics, MqttCallback callBack) { |
| | | try { |
| | | //订é
æ¶æ¯ |
| | | int[] Qos = new int[topics.length];//0ï¼æå¤ä¸æ¬¡ ã1ï¼æå°ä¸æ¬¡ ã2ï¼åªæä¸æ¬¡ |
| | | for (int i = 0; i < Qos.length; i++) { |
| | | Qos[i] = 1; |
| | | /*if(i ==2){ |
| | | Qos[i] = 2; |
| | | }else{ |
| | | Qos[i] = 1; |
| | | }*/ |
| | | } |
| | | clientTemp = MqttClientInit.getInstance(clientTemp,config,callBack); |
| | | try { |
| | | clientTemp.unsubscribe(topics); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return clientTemp; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return clientTemp; |
| | | } |
| | | /** |
| | | * æ¶æ¯åé |
| | | * @param message |
| | | * @param topic |
| | | */ |
| | | public static MqttClient pubMessage(MqttClient clientTemp,MqttConfig config,String message,String topic, MqttCallback callBack){ |
| | | try { |
| | | MqttMessage mess = new MqttMessage(); |
| | | mess.setQos(1); |
| | | mess.setRetained(false); |
| | | mess.setPayload(message.getBytes()); |
| | | clientTemp = MqttClientInit.getInstance(clientTemp,config,callBack); |
| | | try { |
| | | clientTemp.publish(topic, mess); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return clientTemp; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return clientTemp; |
| | | } |
| | | public static void main(String[] args) { |
| | | 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"); |
| | | MqttToolService.pubMessage(null,config,"{" + |
| | | " \"method\": 3," + |
| | | " \"dstID\" :43008827854690816," + |
| | | " \"msgCode\": 120," + |
| | | " \"timeMS\": 0," + |
| | | " \"data\":" + |
| | | " [{" + |
| | | " \"tag\":305," + |
| | | " \"cmd\":\"do_turn_off\", " + |
| | | " \"count\":3," + |
| | | " \"busAddr\":[3]" + |
| | | " }]" + |
| | | "}","/dev/MTS/98CC4D121E5A/cmd/json",null); |
| | | } |
| | | |
| | | } |
| | |
| | | d.setId(param.getId()); |
| | | d.setEditDate(new Date()); |
| | | d.setIsEntrance(Constants.formatIntegerNum(param.getIsEntrance())); |
| | | d.setLoginUserInfo(this.getLoginUser(token)); |
| | | deviceService.updateById(d); |
| | | return ApiResponse.success(null); |
| | | } |
| | | @ApiOperation("ä¿®æ¹æ¯å¦ç³»ç»ä½¿ç¨") |
| | | @PostMapping("/updateUsedById") |
| | | @CloudRequiredPermission("business:company:update") |
| | | public ApiResponse updateUsedById(@RequestBody Device param,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | Device d = new Device(); |
| | | d.setId(param.getId()); |
| | | d.setEditDate(new Date()); |
| | | d.setLoginUserInfo(this.getLoginUser(token)); |
| | | d.setIsUsed(Constants.formatIntegerNum(param.getIsUsed())); |
| | | deviceService.updateUsedById(d); |
| | | return ApiResponse.success(null); |
| | | } |
| | | @ApiOperation("æ§è¡æè·¯å¨å¼å
³é¸æä½") |
| | | @PostMapping("/duanluqiCmd") |
| | | @CloudRequiredPermission("business:company:update") |
| | | public ApiResponse duanluqiCmd(@RequestBody Device param,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | param.setLoginUserInfo(this.getLoginUser(token)); |
| | | deviceService.duanluqiCmd(param); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ¹éå é¤") |
| | | @GetMapping("/delete/batch") |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.cloud.admin; |
| | | |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.config.annotation.CloudRequiredPermission; |
| | | import com.doumee.core.annotation.excel.ExcelExporter; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.business.model.Device; |
| | | import com.doumee.dao.business.model.DeviceData; |
| | | import com.doumee.service.business.DeviceDataService; |
| | | import com.doumee.service.business.DeviceService; |
| | | import com.doumee.service.business.third.model.ApiResponse; |
| | | import com.doumee.service.business.third.model.PageData; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/11/30 15:33 |
| | | */ |
| | | @Api(tags = "è®¾å¤æ°æ®ä¿¡æ¯è¡¨") |
| | | @RestController |
| | | @RequestMapping(Constants.CLOUD_SERVICE_URL_INDEX+"/business/deviceData") |
| | | public class DeviceDataCloudController extends BaseController { |
| | | |
| | | @Autowired |
| | | private DeviceDataService deviceDataService; |
| | | |
| | | |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | @PostMapping("/page") |
| | | @CloudRequiredPermission("business:device:query") |
| | | public ApiResponse<PageData<DeviceData>> findPage (@RequestBody PageWrap<DeviceData> pageWrap,@RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | return ApiResponse.success(deviceDataService.findPage(pageWrap)); |
| | | } |
| | | |
| | | @ApiOperation("导åºExcel") |
| | | @PostMapping("/exportExcel") |
| | | @CloudRequiredPermission("business:device:exportExcel") |
| | | public void exportExcel (@RequestBody PageWrap<DeviceData> pageWrap, HttpServletResponse response, @RequestHeader(Constants.HEADER_USER_TOKEN) String token){ |
| | | ExcelExporter.build(DeviceData.class).export(deviceDataService.findPage(pageWrap).getRecords(), "设å¤ä¿¡æ¯è¡¨", response); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.impl; |
| | | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.HKTools; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | | import com.doumee.core.haikang.model.param.request.EventSubRequest; |
| | | import com.doumee.core.haikang.model.param.respose.OrgInfoResponse; |
| | | import com.doumee.core.haikang.service.HKService; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.business.WarningMapper; |
| | | import com.doumee.dao.system.model.SystemDictData; |
| | | import com.doumee.service.business.DeviceService; |
| | | import com.doumee.service.business.InterfaceLogService; |
| | | import com.doumee.service.business.impl.hksync.HkSyncBaseServiceImpl; |
| | | import com.hikvision.artemis.sdk.config.ArtemisConfig; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 海康äºä»¶è®¢é
表Serviceå®ç° |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/11/30 15:33 |
| | | */ |
| | | @Service |
| | | public class DeviceInitServiceImpl extends HkSyncBaseServiceImpl { |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private InterfaceLogService interfaceLogService; |
| | | @Autowired |
| | | private WarningMapper warningMapper; |
| | | |
| | | @PostConstruct |
| | | public int startDuanluqiMqttJob(){ |
| | | //è·åæ ¹ç»ç»ç¼ç |
| | | deviceService.startCheckDuanluqiSubjob(); |
| | | return 0; |
| | | } |
| | | } |
| | |
| | | <version>1.0.0-SNAPSHOT</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.doumee</groupId> |
| | | <artifactId>device_service</artifactId> |
| | | <version>1.0.0-SNAPSHOT</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.google.ortools</groupId> |
| | | <artifactId>ortools-java</artifactId> |
| | | <version>9.14.6206</version> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.doumee.dao.business.model.DeviceData; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2025/12/25 10:04 |
| | | */ |
| | | public interface DeviceDataMapper extends BaseMapper<DeviceData> { |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | @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æ¯") |
| | |
| | | @ApiModelProperty(value = "é¨ç¦ç¹åç§°") |
| | | @ExcelColumn(name="é¨ç¦ç¹åç§°") |
| | | private String doorName; |
| | | |
| | | |
| | | @ApiModelProperty(value = "ææ¥å
容") |
| | | @TableField(exist = false) |
| | | private String sendInfo; |
| | | |
| | | @ApiModelProperty(value = "é
ç½®åæ°") |
| | | @TableField(exist = false) |
| | | private JSONObject doorNameObj; |
| | | |
| | | |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.model; |
| | | |
| | | import com.doumee.core.annotation.excel.ExcelColumn; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * é¨ç¦äºä»¶æ¨éè®°å½è¡¨ |
| | | * @author æ±è¹è¹ |
| | | * @date 2025/12/25 10:04 |
| | | */ |
| | | @Data |
| | | @ApiModel("é¨ç¦äºä»¶æ¨éè®°å½è¡¨") |
| | | @TableName("`device_data`") |
| | | public class DeviceData { |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | @ApiModelProperty(value = "主é®", example = "1") |
| | | @ExcelColumn(name="主é®") |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "å建人ç¼ç ", example = "1") |
| | | @ExcelColumn(name="å建人ç¼ç ") |
| | | private Integer creator; |
| | | |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | @ExcelColumn(name="å建æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date createDate; |
| | | |
| | | @ApiModelProperty(value = "æ´æ°äººç¼ç ", example = "1") |
| | | @ExcelColumn(name="æ´æ°äººç¼ç ") |
| | | private Integer editor; |
| | | |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´") |
| | | @ExcelColumn(name="æ´æ°æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date editDate; |
| | | |
| | | @ApiModelProperty(value = "æ¯å¦å é¤0å¦ 1æ¯", example = "1") |
| | | @ExcelColumn(name="æ¯å¦å é¤0å¦ 1æ¯") |
| | | private Integer isdeleted; |
| | | |
| | | @ApiModelProperty(value = "夿³¨") |
| | | @ExcelColumn(name="夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "æ°æ®json对象", example = "1") |
| | | @ExcelColumn(name="æ°æ®json对象") |
| | | private String dataJson; |
| | | |
| | | @ApiModelProperty(value = "设å¤ç¼ç ï¼å
³èdevice)") |
| | | @ExcelColumn(name="设å¤ç¼ç ï¼å
³èdevice)") |
| | | private String deviceId; |
| | | |
| | | @ApiModelProperty(value = "åçæ¶é´") |
| | | @ExcelColumn(name="åçæ¶é´") |
| | | private String happenTime; |
| | | |
| | | @ApiModelProperty(value = "屿§å¼1") |
| | | @ExcelColumn(name="屿§å¼1") |
| | | private String val1; |
| | | |
| | | @ApiModelProperty(value = "屿§å¼2") |
| | | @ExcelColumn(name="屿§å¼2") |
| | | private String val2; |
| | | |
| | | @ApiModelProperty(value = "屿§å¼3") |
| | | @ExcelColumn(name="屿§å¼3") |
| | | private String val3; |
| | | |
| | | @ApiModelProperty(value = "屿§å¼4") |
| | | @ExcelColumn(name="屿§å¼4") |
| | | private String val4; |
| | | |
| | | @ApiModelProperty(value = "屿§å¼5") |
| | | @ExcelColumn(name="屿§å¼5") |
| | | private String val5; |
| | | |
| | | @ApiModelProperty(value = "屿§å¼6") |
| | | @ExcelColumn(name="屿§å¼6") |
| | | private String val6; |
| | | @ApiModelProperty(value = "屿§å¼7") |
| | | @ExcelColumn(name="屿§å¼7") |
| | | private String val7; |
| | | |
| | | @ApiModelProperty(value = "æ°æ®æ¥æº 0mqtt䏿¥ 1å
¶ä»", example = "1") |
| | | @ExcelColumn(name="æ°æ®æ¥æº 0mqtt䏿¥ 1å
¶ä»") |
| | | private Integer dataType; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business; |
| | | |
| | | import com.doumee.dao.business.model.DeviceData; |
| | | import com.doumee.service.business.third.model.PageData; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * é¨ç¦äºä»¶æ¨éè®°å½è¡¨Serviceå®ä¹ |
| | | * @author æ±è¹è¹ |
| | | * @date 2025/12/25 10:04 |
| | | */ |
| | | public interface DeviceDataService { |
| | | |
| | | /** |
| | | * å建 |
| | | * |
| | | * @param deviceData å®ä½å¯¹è±¡ |
| | | * @return Integer |
| | | */ |
| | | Integer create(DeviceData deviceData); |
| | | |
| | | /** |
| | | * 主é®å é¤ |
| | | * |
| | | * @param id ä¸»é® |
| | | */ |
| | | void deleteById(Integer id); |
| | | |
| | | /** |
| | | * å é¤ |
| | | * |
| | | * @param deviceData å®ä½å¯¹è±¡ |
| | | */ |
| | | void delete(DeviceData deviceData); |
| | | |
| | | /** |
| | | * æ¹é主é®å é¤ |
| | | * |
| | | * @param ids 主é®é |
| | | */ |
| | | void deleteByIdInBatch(List<Integer> ids); |
| | | |
| | | /** |
| | | * 䏻鮿´æ° |
| | | * |
| | | * @param deviceData å®ä½å¯¹è±¡ |
| | | */ |
| | | void updateById(DeviceData deviceData); |
| | | |
| | | /** |
| | | * æ¹é䏻鮿´æ° |
| | | * |
| | | * @param deviceDatas å®ä½é |
| | | */ |
| | | void updateByIdInBatch(List<DeviceData> deviceDatas); |
| | | |
| | | /** |
| | | * 䏻鮿¥è¯¢ |
| | | * |
| | | * @param id ä¸»é® |
| | | * @return DeviceData |
| | | */ |
| | | DeviceData findById(Integer id); |
| | | |
| | | /** |
| | | * æ¡ä»¶æ¥è¯¢åæ¡è®°å½ |
| | | * |
| | | * @param deviceData å®ä½å¯¹è±¡ |
| | | * @return DeviceData |
| | | */ |
| | | DeviceData findOne(DeviceData deviceData); |
| | | |
| | | /** |
| | | * æ¡ä»¶æ¥è¯¢ |
| | | * |
| | | * @param deviceData å®ä½å¯¹è±¡ |
| | | * @return List<DeviceData> |
| | | */ |
| | | List<DeviceData> findList(DeviceData deviceData); |
| | | |
| | | /** |
| | | * å页æ¥è¯¢ |
| | | * |
| | | * @param pageWrap å页对象 |
| | | * @return PageData<DeviceData> |
| | | */ |
| | | PageData<DeviceData> findPage(PageWrap<DeviceData> pageWrap); |
| | | |
| | | /** |
| | | * æ¡ä»¶ç»è®¡ |
| | | * |
| | | * @param deviceData å®ä½å¯¹è±¡ |
| | | * @return long |
| | | */ |
| | | long count(DeviceData deviceData); |
| | | } |
| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | * @date 2023/11/30 15:33 |
| | | */ |
| | | public interface DeviceService { |
| | | |
| | | |
| | | /** |
| | | * å建 |
| | |
| | | |
| | | void setBroadcaseBobao(Device body); |
| | | String setBroadcaseBobaoHttp(Device body); |
| | | |
| | | void duanluqiCmd(Device param); |
| | | |
| | | void updateUsedById(Device d); |
| | | |
| | | void autoCloseCmdTimer(); |
| | | void startCheckDuanluqiSubjob(); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.DeviceDataMapper; |
| | | import com.doumee.dao.business.model.DeviceData; |
| | | import com.doumee.service.business.DeviceDataService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.doumee.service.business.third.model.PageData; |
| | | import com.doumee.service.business.third.model.PageWrap; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * é¨ç¦äºä»¶æ¨éè®°å½è¡¨Serviceå®ç° |
| | | * @author æ±è¹è¹ |
| | | * @date 2025/12/25 10:04 |
| | | */ |
| | | @Service |
| | | public class DeviceDataServiceImpl implements DeviceDataService { |
| | | |
| | | @Autowired |
| | | private DeviceDataMapper deviceDataMapper; |
| | | |
| | | @Override |
| | | public Integer create(DeviceData deviceData) { |
| | | deviceDataMapper.insert(deviceData); |
| | | return deviceData.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(Integer id) { |
| | | deviceDataMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(DeviceData deviceData) { |
| | | UpdateWrapper<DeviceData> deleteWrapper = new UpdateWrapper<>(deviceData); |
| | | deviceDataMapper.delete(deleteWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByIdInBatch(List<Integer> ids) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | deviceDataMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void updateById(DeviceData deviceData) { |
| | | deviceDataMapper.updateById(deviceData); |
| | | } |
| | | |
| | | @Override |
| | | public void updateByIdInBatch(List<DeviceData> deviceDatas) { |
| | | if (CollectionUtils.isEmpty(deviceDatas)) { |
| | | return; |
| | | } |
| | | for (DeviceData deviceData: deviceDatas) { |
| | | this.updateById(deviceData); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public DeviceData findById(Integer id) { |
| | | return deviceDataMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public DeviceData findOne(DeviceData deviceData) { |
| | | QueryWrapper<DeviceData> wrapper = new QueryWrapper<>(deviceData); |
| | | return deviceDataMapper.selectOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<DeviceData> findList(DeviceData deviceData) { |
| | | QueryWrapper<DeviceData> wrapper = new QueryWrapper<>(deviceData); |
| | | return deviceDataMapper.selectList(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public PageData<DeviceData> findPage(PageWrap<DeviceData> pageWrap) { |
| | | IPage<DeviceData> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<DeviceData> queryWrapper = new QueryWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | if (pageWrap.getModel().getId() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getId, pageWrap.getModel().getId()); |
| | | } |
| | | if (pageWrap.getModel().getCreator() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getCreator, pageWrap.getModel().getCreator()); |
| | | } |
| | | if (pageWrap.getModel().getCreateDate() != null) { |
| | | queryWrapper.lambda().ge(DeviceData::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); |
| | | queryWrapper.lambda().le(DeviceData::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); |
| | | } |
| | | if (pageWrap.getModel().getEditor() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getEditor, pageWrap.getModel().getEditor()); |
| | | } |
| | | if (pageWrap.getModel().getEditDate() != null) { |
| | | queryWrapper.lambda().ge(DeviceData::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); |
| | | queryWrapper.lambda().le(DeviceData::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); |
| | | } |
| | | if (pageWrap.getModel().getIsdeleted() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getIsdeleted, pageWrap.getModel().getIsdeleted()); |
| | | } |
| | | if (pageWrap.getModel().getRemark() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getRemark, pageWrap.getModel().getRemark()); |
| | | } |
| | | if (pageWrap.getModel().getDataJson() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getDataJson, pageWrap.getModel().getDataJson()); |
| | | } |
| | | if (pageWrap.getModel().getDeviceId() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getDeviceId, pageWrap.getModel().getDeviceId()); |
| | | } |
| | | if (pageWrap.getModel().getHappenTime() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getHappenTime, pageWrap.getModel().getHappenTime()); |
| | | } |
| | | if (pageWrap.getModel().getVal1() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getVal1, pageWrap.getModel().getVal1()); |
| | | } |
| | | if (pageWrap.getModel().getVal2() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getVal2, pageWrap.getModel().getVal2()); |
| | | } |
| | | if (pageWrap.getModel().getVal3() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getVal3, pageWrap.getModel().getVal3()); |
| | | } |
| | | if (pageWrap.getModel().getVal4() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getVal4, pageWrap.getModel().getVal4()); |
| | | } |
| | | if (pageWrap.getModel().getVal5() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getVal5, pageWrap.getModel().getVal5()); |
| | | } |
| | | if (pageWrap.getModel().getVal6() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getVal6, pageWrap.getModel().getVal6()); |
| | | } |
| | | if (pageWrap.getModel().getDataType() != null) { |
| | | queryWrapper.lambda().eq(DeviceData::getDataType, pageWrap.getModel().getDataType()); |
| | | } |
| | | queryWrapper.lambda().orderByDesc(DeviceData::getHappenTime); |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | return PageData.from(deviceDataMapper.selectPage(page, queryWrapper)); |
| | | } |
| | | |
| | | @Override |
| | | public long count(DeviceData deviceData) { |
| | | QueryWrapper<DeviceData> wrapper = new QueryWrapper<>(deviceData); |
| | | return deviceDataMapper.selectCount(wrapper); |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | public class DeviceServiceImpl implements DeviceService { |
| | | |
| | | @Autowired |
| | | private MqttBizService mqttBizService; |
| | | @Autowired |
| | | private DeviceMapper deviceMapper; |
| | | @Autowired |
| | | private DeviceDataMapper deviceDataMapper; |
| | | @Autowired |
| | | private PlatformMapper platformMapper; |
| | | @Autowired |
| | |
| | | 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(); |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | |
| | | @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 |
| | |
| | | .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 |
| | |
| | | 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 |
| | |
| | | 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)//å¼å¸¸è§£é |
| | | .replace("$BUSADDR",model.getChannelNo()); |
| | | mqttClient = mqttBizService.publish(mqttClient,config,cmdTopic, cmdParamAction);//è§£éå½ä»¤ |
| | | 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){ |
| | |
| | | } |
| | | 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("=======å¼å§èªå¨å®äºmqttä»»å¡å®æï¼"+model.getName() ); |
| | | }catch (Exception e){ |
| | | log.error("=======å¼å§èªå¨å®äºmqttä»»å¡å¤±è´¥ï¼"+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)//é
ç½®äºMQTTåæ° |
| | | .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; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business.impl.mqtt; |
| | | |
| | | import org.eclipse.paho.client.mqttv3.MqttClient; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | |
| | | public class MqttClientCache { |
| | | public static LinkedHashMap<String, MqttClient> clientMapCache = new LinkedHashMap<>(); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business.impl.mqtt; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.business.DeviceDataMapper; |
| | | import com.doumee.dao.business.DeviceMapper; |
| | | import com.doumee.dao.business.model.Device; |
| | | import com.doumee.dao.business.model.DeviceData; |
| | | import com.doumee.mqtt.config.MqttClientInit; |
| | | import com.doumee.mqtt.config.MqttConfig; |
| | | import com.doumee.mqtt.service.MqttBizService; |
| | | import com.doumee.service.business.DeviceService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import me.chanjar.weixin.common.util.DataUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.eclipse.paho.client.mqttv3.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author T14 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class MqttPushCallback implements MqttCallback { |
| | | |
| | | |
| | | @Autowired |
| | | private DeviceMapper deviceMapper; |
| | | @Autowired |
| | | private DeviceDataMapper deviceDataMapper; |
| | | @Override |
| | | public void connectionLost(Throwable cause) { |
| | | // è¿æ¥ä¸¢å¤±åï¼ä¸è¬å¨è¿éé¢è¿è¡éè¿ |
| | | log.error("è¿æ¥æå¼ï¼éè¿ä¸"); |
| | | MqttClientInit.refreshClient(); |
| | | } |
| | | |
| | | @Override |
| | | public void deliveryComplete(IMqttDeliveryToken token) { |
| | | log.error("deliveryComplete---------" + token.isComplete()); |
| | | } |
| | | @Override |
| | | public void messageArrived(String topic, MqttMessage message) throws Exception { |
| | | // subscribeåå¾å°çæ¶æ¯ä¼æ§è¡å°è¿éé¢ |
| | | try { |
| | | Date date = new Date(); |
| | | log.error("æ¥æ¶æ¶æ¯ä¸»é¢ : " + DateUtil.getPlusTime2(date) + topic); |
| | | log.error("æ¥æ¶æ¶æ¯Qos : " + DateUtil.getPlusTime2(date) + message.getQos()); |
| | | log.error("æ¥æ¶æ¶æ¯å
容 : " + DateUtil.getPlusTime2(date) + new String(message.getPayload())); |
| | | // ------------TODO-----------ç嬿°æ® |
| | | //-----------------/dev/MTS/98CC4D121E5A/status/json |
| | | if(StringUtils.contains(topic,"/status/json")){ |
| | | dealDeviceDataT30A(topic,message); |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private void dealDeviceDataT30A(String topic, MqttMessage message) { |
| | | try { |
| | | Date date = new Date(); |
| | | //妿æ¯ç©ºå¼ä¸æ¥æ°æ® |
| | | String t[] = topic.replace("/dev/","").replace("/status/json","").split("/"); |
| | | String no =t[0]; |
| | | String doorNo = t[1]; |
| | | Device device = deviceMapper.selectOne(new QueryWrapper<Device>().lambda() |
| | | .eq(Device::getNo,no) |
| | | .eq(Device::getIsdeleted,no) |
| | | .eq(Device::getDoorNo,doorNo)); |
| | | if(device!=null && Constants.equalsInteger(device.getIsUsed(),Constants.ZERO)){ |
| | | //å¦æè®¾å¤åå¨å¹¶ä¸è®¾å¤å¨ç¨ï¼è®°å½ä¸æ¥æ°æ® |
| | | List<DeviceData> dataList = new ArrayList<>(); |
| | | JSONObject jsob = JSONObject.parseObject(new String(message.getPayload())); |
| | | if(jsob.getJSONArray("data")!=null && jsob.getJSONArray("data").size()>0){ |
| | | for (int i = 0; i < jsob.getJSONArray("data").size(); i++) { |
| | | JSONObject jsonObject = jsob.getJSONArray("data").getJSONObject(i); |
| | | DeviceData data = new DeviceData(); |
| | | data.setDataJson(jsob.toJSONString()); |
| | | data.setCreateDate(date); |
| | | data.setEditDate(date); |
| | | data.setVal2("0");//çµæµå¼ |
| | | data.setVal3("0"); |
| | | data.setVal4("0"); |
| | | data.setVal5("0"); |
| | | data.setVal6("0"); |
| | | data.setHappenTime(DateUtil.getPlusTime2(new Date(jsob.getLong("timeMS")))); |
| | | //模ååºå· |
| | | if(jsonObject.getJSONObject("mcbComSta")!=null |
| | | && jsonObject.getJSONObject("mcbComSta").getString("busAddr")!=null){ |
| | | data.setVal1(jsonObject.getJSONObject("mcbComSta").getString("busAddr")); |
| | | //<0>表示åé¸ï¼<1>表示åé¸ï¼æ ç¬¦å· |
| | | data.setVal7(jsonObject.getJSONObject("mcbComSta").getString("on")); |
| | | } |
| | | if(jsonObject.getJSONObject("mcbSta")!=null){ |
| | | //çµæµ |
| | | if(jsonObject.getJSONObject("mcbSta").getString("cur")!=null){ |
| | | data.setVal2(jsonObject.getJSONObject("mcbSta").getString("cur")); |
| | | } |
| | | //çµå |
| | | if(jsonObject.getJSONObject("mcbSta").getString("vol")!=null){ |
| | | data.setVal3(jsonObject.getJSONObject("mcbSta").getString("vol")); |
| | | } |
| | | //温度 |
| | | if(jsonObject.getJSONObject("mcbSta").getString("tmp")!=null){ |
| | | data.setVal4(jsonObject.getJSONObject("mcbSta").getString("tmp")); |
| | | } |
| | | //æååçå¼ï¼åä½kW |
| | | if(jsonObject.getJSONObject("mcbSta").getString("pwrP")!=null){ |
| | | data.setVal5(jsonObject.getJSONObject("mcbSta").getString("pwrP")); |
| | | } |
| | | //Nç¸çµæµå¼ï¼åä½A |
| | | if(jsonObject.getJSONObject("mcbSta").getString("curN")!=null){ |
| | | data.setVal6(jsonObject.getJSONObject("mcbSta").getString("curN")); |
| | | } |
| | | } |
| | | data.setDeviceId(device.getId().toString()); |
| | | data.setDataType(Constants.ZERO); |
| | | if(StringUtils.isNotBlank(data.getVal1())){ |
| | | dataList.add(data ); |
| | | } |
| | | } |
| | | } |
| | | if(dataList.size()>0){ |
| | | deviceDataMapper.insert(dataList); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | log.error("===============topicæ°æ®è®°å½å¤±è´¥:"+topic+e.getMessage()); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business.impl.mqtt; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.mqtt.config.MqttConfig; |
| | | import com.doumee.mqtt.service.MqttBizService; |
| | | import com.doumee.mqtt.service.MqttToolService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.eclipse.paho.client.mqttv3.MqttClient; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | /** |
| | | * ä¸ç¡¬ä»¶å¯¹æ¥æå¡ |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/09 18:06 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class MqttSubServiceImpl implements MqttBizService { |
| | | @Autowired |
| | | private MqttPushCallback callBack ; |
| | | @Override |
| | | public MqttClient subscribe(MqttClient client,MqttConfig config,String[] topics){ |
| | | log.error("mqtt订é
å¼å§========å¼å§"+ JSONObject.toJSONString(config)); |
| | | client = MqttToolService.subscribe(client,config, topics,callBack); |
| | | log.error("mqtt订é
å¼å§========ç»æ"+ JSONObject.toJSONString(config)); |
| | | return client; |
| | | } |
| | | @Override |
| | | public MqttClient unsubscribe(MqttClient client,MqttConfig config,String[] topics){ |
| | | log.error("mqtt订é
å¼å§========å¼å§"+ JSONObject.toJSONString(config)); |
| | | client = MqttToolService.unsubscribe(client,config, topics,callBack); |
| | | log.error("mqtt订é
å¼å§========ç»æ"+ JSONObject.toJSONString(config)); |
| | | return client; |
| | | } |
| | | |
| | | @Override |
| | | public MqttClient publish(MqttClient client,MqttConfig config, String topic, String param){ |
| | | log.error("mqttå叿¶æ¯========å¼å§"+ JSONObject.toJSONString(config)+"\n"+param); |
| | | client = MqttToolService.pubMessage(client,config,param,topic,callBack); |
| | | log.error("mqttå叿¶æ¯========ç»æ"+ JSONObject.toJSONString(config)); |
| | | return client; |
| | | } |
| | | } |