Commit 39e053e5 authored by 冯超鹏's avatar 冯超鹏

记记录模块

parent 203bdf7b
Pipeline #49 failed with stages
...@@ -16,12 +16,29 @@ class SwooleCommandMeTcpController extends Controller ...@@ -16,12 +16,29 @@ class SwooleCommandMeTcpController extends Controller
{ {
if ($data != '') { if ($data != '') {
$datadevice = $this->stringdata($data); $datadevice = $this->stringdata($data);
Redis::set('dbtype',0);
if(Redis::get('sbjc:' . $datadevice[0]) == ''){
Redis::set('sbjc:' . $datadevice[0], $data); Redis::set('sbjc:' . $datadevice[0], $data);
$this->dbdevice($this->stringdata($data)); $this->dbdevice($this->stringdata($data));
}else if (Redis::get('sbjc:' . $datadevice[0]) != $data){
$this->dbdevice($this->stringdata($data));
Redis::set('sbjc:' . $datadevice[0], $data);
}
Redis::lpush('police',$data); Redis::lpush('police',$data);
$this->police(); $this->police();
} }
$dalen = Redis::llen('Devicesdata');//返回队列长度
if ($dalen > 5000 ) { //当队列值达到巅峰以后切换数据库
Redis::select(1);//使用备用数据库//释放主数据库
Redis::set('dbtype',1);
$this->deleteDbRedis();
}
if($dalen > 5000 && Redis::get('dbtype') == 1){
Redis::select(0);
Redis::set('dbtype',0);
$this->deleteDb();
}
} }
//分割字符串 //分割字符串
...@@ -44,6 +61,18 @@ class SwooleCommandMeTcpController extends Controller ...@@ -44,6 +61,18 @@ class SwooleCommandMeTcpController extends Controller
} }
return $arrdata; return $arrdata;
} }
//清楚指定数据库 redis
private function deleteDbRedis (){
Redis::select(0);
Redis::flushdb();
Redis::select(1);
}
private function deleteDb(){
Redis::select(1);
Redis::flushdb();
Redis::select(0);
}
//查询出返回值 //查询出返回值
private function dbdevice($data = []) private function dbdevice($data = [])
...@@ -58,12 +87,9 @@ class SwooleCommandMeTcpController extends Controller ...@@ -58,12 +87,9 @@ class SwooleCommandMeTcpController extends Controller
->leftjoin('status as s', 's.id', '=', 'd.devicepolice') ->leftjoin('status as s', 's.id', '=', 'd.devicepolice')
->select('d.devicenum', 'd.username', 'd.deviceremark', 'd.devicelinkman', 'd.devicephone', 'd.deviceinfo', 't.tname', 'g.gas', 'c.danwei', 's.status_name') ->select('d.devicenum', 'd.username', 'd.deviceremark', 'd.devicelinkman', 'd.devicephone', 'd.deviceinfo', 't.tname', 'g.gas', 'c.danwei', 's.status_name')
->first(); ->first();
if($devicedata != ''){
Redis::lPush('Devicesdata', serialize($devicedata));//进入队列进行 Redis::lPush('Devicesdata', serialize($devicedata));//进入队列进行
$dalen = Redis::llen('Devicesdata');//返回队列长度
if ($dalen == 2) {
$Devices->equipment();//推送前台
} }
} }
} }
......
This diff is collapsed.
No preview for this file type
[{"devicenum":"ZHGAS000131031","username":"123214","deviceremark":null,"devicelinkman":"1","devicephone":"16631150870","deviceinfo":null,"tname":"\u5bb6\u7528\u62a5\u8b66\u5668(IOT)","gas":"\u7532\u70f7","danwei":"%LEL","status_name":"\u62a5\u8b66"}]
[{"devicenum":"ZHGAS000131031","username":"123214","deviceremark":null,"devicelinkman":"1","devicephone":"16631150870","deviceinfo":null,"tname":"\u5bb6\u7528\u62a5\u8b66\u5668(IOT)","gas":"\u7532\u70f7","danwei":"%LEL","status_name":"\u4f20\u611f\u5668\u6545\u969c"}]
[{"devicenum":"ZHGAS000131031","username":"123214","deviceremark":null,"devicelinkman":"1","devicephone":"16631150870","deviceinfo":null,"tname":"\u5bb6\u7528\u62a5\u8b66\u5668(IOT)","gas":"\u7532\u70f7","danwei":"%LEL","status_name":"\u9ad8\u62a5"}]
...@@ -70,3 +70,25 @@ export function delteClassify(id) { ...@@ -70,3 +70,25 @@ export function delteClassify(id) {
method: 'get', method: 'get',
}); });
} }
export function equipment() {
return request({
url: '/devices/equipment',
method: 'get',
});
}
export function detedevice(dete) {
return request({
url: '/devices/detedevice?dete=' + dete,
method: 'get',
});
}
export function police(dete) {
return request({
url: '/devices/police',
method: 'get',
});
}
...@@ -13,17 +13,15 @@ Vue.use(Router); ...@@ -13,17 +13,15 @@ Vue.use(Router);
import Layout from '@/layout'; import Layout from '@/layout';
/* Router for modules */ /* Router for modules */
import elementUiRoutes from './modules/element-ui'; // import componentRoutes from './modules/components';
import componentRoutes from './modules/components'; // import chartsRoutes from './modules/charts';
import chartsRoutes from './modules/charts'; // import tableRoutes from './modules/table';
import tableRoutes from './modules/table';
import adminRoutes from './modules/admin'; import adminRoutes from './modules/admin';
import deviceRoutes from './modules/device'; import deviceRoutes from './modules/device';
import usersRoutes from './modules/users'; import usersRoutes from './modules/users';
import nestedRoutes from './modules/nested'; // import nestedRoutes from './modules/nested';
import errorRoutes from './modules/error'; // import errorRoutes from './modules/error';
import excelRoutes from './modules/excel'; // import permissionRoutes from './modules/permission';
import permissionRoutes from './modules/permission';
import historyRoutes from './modules/history.js'; import historyRoutes from './modules/history.js';
import monitorRoutes from './modules/monitor.js'; import monitorRoutes from './modules/monitor.js';
...@@ -119,117 +117,115 @@ export const constantRoutes = [ ...@@ -119,117 +117,115 @@ export const constantRoutes = [
deviceRoutes, deviceRoutes,
usersRoutes, usersRoutes,
adminRoutes, adminRoutes,
{ // {
path: '/documentation', // path: '/documentation',
component: Layout, // component: Layout,
redirect: '/documentation/index', // redirect: '/documentation/index',
children: [ // children: [
{ // {
path: 'index', // path: 'index',
component: () => import('@/views/documentation/index'), // component: () => import('@/views/documentation/index'),
name: 'Documentation', // name: 'Documentation',
meta: { title: 'documentation', icon: 'documentation', noCache: true }, // meta: { title: 'documentation', icon: 'documentation', noCache: true },
}, // },
], // ],
}, // },
{ // {
path: '/guide', // path: '/guide',
component: Layout, // component: Layout,
redirect: '/guide/index', // redirect: '/guide/index',
children: [ // children: [
{ // {
path: 'index', // path: 'index',
component: () => import('@/views/guide/index'), // component: () => import('@/views/guide/index'),
name: 'Guide', // name: 'Guide',
meta: { title: 'guide', icon: 'guide', noCache: true }, // meta: { title: 'guide', icon: 'guide', noCache: true },
}, // },
], // ],
}, // },
elementUiRoutes,
]; ];
export const asyncRoutes = [ export const asyncRoutes = [
permissionRoutes, // permissionRoutes,
componentRoutes, // componentRoutes,
chartsRoutes, // chartsRoutes,
nestedRoutes, // nestedRoutes,
tableRoutes, // tableRoutes,
{ // {
path: '/theme', // path: '/theme',
component: Layout, // component: Layout,
redirect: 'noredirect', // redirect: 'noredirect',
children: [ // children: [
{ // {
path: 'index', // path: 'index',
component: () => import('@/views/theme/index'), // component: () => import('@/views/theme/index'),
name: 'Theme', // name: 'Theme',
meta: { title: 'theme', icon: 'theme' }, // meta: { title: 'theme', icon: 'theme' },
}, // },
], // ],
}, // },
{ // {
path: '/clipboard', // path: '/clipboard',
component: Layout, // component: Layout,
redirect: 'noredirect', // redirect: 'noredirect',
meta: { permissions: ['view menu clipboard'] }, // meta: { permissions: ['view menu clipboard'] },
children: [ // children: [
{ // {
path: 'index', // path: 'index',
component: () => import('@/views/clipboard/index'), // component: () => import('@/views/clipboard/index'),
name: 'ClipboardDemo', // name: 'ClipboardDemo',
meta: { title: 'clipboardDemo', icon: 'clipboard', roles: ['admin', 'manager', 'editor', 'user'] }, // meta: { title: 'clipboardDemo', icon: 'clipboard', roles: ['admin', 'manager', 'editor', 'user'] },
}, // },
], // ],
}, // },
errorRoutes, // errorRoutes,
excelRoutes, // {
{ // path: '/zip',
path: '/zip', // component: Layout,
component: Layout, // redirect: '/zip/download',
redirect: '/zip/download', // alwaysShow: true,
alwaysShow: true, // meta: { title: 'zip', icon: 'zip', permissions: ['view menu zip'] },
meta: { title: 'zip', icon: 'zip', permissions: ['view menu zip'] }, // children: [
children: [ // {
{ // path: 'download',
path: 'download', // component: () => import('@/views/zip'),
component: () => import('@/views/zip'), // name: 'ExportZip',
name: 'ExportZip', // meta: { title: 'exportZip' },
meta: { title: 'exportZip' }, // },
}, // ],
], // },
}, // {
{ // path: '/pdf',
path: '/pdf', // component: Layout,
component: Layout, // redirect: '/pdf/index',
redirect: '/pdf/index', // meta: { title: 'pdf', icon: 'pdf', permissions: ['view menu pdf'] },
meta: { title: 'pdf', icon: 'pdf', permissions: ['view menu pdf'] }, // children: [
children: [ // {
{ // path: 'index',
path: 'index', // component: () => import('@/views/pdf'),
component: () => import('@/views/pdf'), // name: 'Pdf',
name: 'Pdf', // meta: { title: 'pdf' },
meta: { title: 'pdf' }, // },
}, // ],
], // },
}, // {
{ // path: '/pdf/download',
path: '/pdf/download', // component: () => import('@/views/pdf/Download'),
component: () => import('@/views/pdf/Download'), // hidden: true,
hidden: true, // },
}, // {
{ // path: '/i18n',
path: '/i18n', // component: Layout,
component: Layout, // meta: { permissions: ['view menu i18n'] },
meta: { permissions: ['view menu i18n'] }, // children: [
children: [ // {
{ // path: 'index',
path: 'index', // component: () => import('@/views/i18n'),
component: () => import('@/views/i18n'), // name: 'I18n',
name: 'I18n', // meta: { title: 'i18n', icon: 'international' },
meta: { title: 'i18n', icon: 'international' }, // },
}, // ],
], // },
},
{ path: '*', redirect: '/404', hidden: true }, { path: '*', redirect: '/404', hidden: true },
]; ];
......
import Layout from '@/layout'; import Layout from '@/layout';
//
const elementUiRoutes = { const elementUiRoutes = {
path: '/element-ui', path: '/element-ui',
component: Layout, component: Layout,
......
<template>
<div class="app-container documentation-container">
<a class="document-btn" target="_blank" href="https://laravel.com/docs/5.8">{{ $t('documentation.laravel') }}</a>
<a class="document-btn" target="_blank" href="https://vuejs.org/">VueJS</a>
<a class="document-btn" target="_blank" href="https://github.com/tuandm/laravue/">{{ $t('documentation.github') }}</a>
<dropdown-menu :items="articleList" style="float:left;margin-left:50px;" title="Components" />
</div>
</template>
<script>
import DropdownMenu from '@/components/Share/DropdownMenu';
export default {
name: 'Documentation',
components: { DropdownMenu },
data() {
return {
articleList: [
{ title: 'Laravel Envoy', href: 'https://laravel.com/docs/5.8/envoy' },
{ title: 'Vuex', href: 'https://vuex.vuejs.org/' },
{ title: 'Vue Router', href: 'https://router.vuejs.org/' },
{ title: 'laravue-core', href: 'https://github.com/tuandm/laravue-core' },
{ title: 'vue-admin-template', href: 'https://github.com/PanJiaChen/vue-admin-template' },
{ title: 'Axios', href: 'https://github.com/axios/axios' },
],
};
},
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.documentation-container {
margin: 50px;
.document-btn {
float: left;
margin-left: 50px;
display: block;
cursor: pointer;
background: black;
color: white;
height: 60px;
width: 200px;
line-height: 60px;
font-size: 20px;
text-align: center;
}
}
</style>
<template> <template>
<div>报警记录</div> <div class="app-container">
<el-table :key="tableKey" :data="reportpolice" border fit highlight-current-rows>
<el-table-column label="设备编号" width="150">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.devicenumber,$event)">{{ scope.row.devicenumber }}</span>
</template>
</el-table-column>
<el-table-column label="设备报警开始时间" width="150">
<template slot-scope="scope">
<span>{{ scope.row.starttime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template>
</el-table-column>
<el-table-column label="设备结束报警时间" width="150">
<template slot-scope="scope">
<span>{{ scope.row.endtime=='0-0-0 0:0' ? '' : scope.row.endtime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
</template>
</el-table-column>
<el-table-column label="报警浓度" width="150">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.concentration,$event)">{{ scope.row.concentration }}</span>
</template>
</el-table-column>
<el-table-column label="报警位置" width="150">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.location,$event)">{{ scope.row.location }}</span>
</template>
</el-table-column>
<el-table-column label="报警类型" width="150">
<template slot-scope="scope">
<span>{{ scope.row.status_name }}</span>
</template>
</el-table-column>
<el-table-column label="设备状态" width="155">
<template slot-scope="scope">
<el-tag :type="scope.row.status==1 ? 'danger' : 'success' " effect="dark">{{ scope.row.status==1 ? '报警' : '正常' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="设备是否当前报警" width="150">
<template slot-scope="scope">
<el-tag :type="scope.row.status==1 ? 'danger' : 'success' " effect="dark">{{ scope.row.status==1 ? '当前正在报警' : '已结束报警' }}</el-tag>
</template>
</el-table-column>
</el-table>
<el-tooltip placement="top" content="tooltip">
<back-to-top :custom-style="myBackToTopStyle" :visibility-height="300" :back-position="50" transition-name="fade" />
</el-tooltip>
</div>
</template> </template>
<script> <script>
import { police } from '@/api/device';
import clip from '@/utils/clipboard';
import BackToTop from '@/components/BackToTop';
export default {
components: { BackToTop },
data() {
return {
tableKey: 0,
reportpolice: [],
myBackToTopStyle: {
right: '50px',
bottom: '50px',
width: '40px',
height: '40px',
'border-radius': '4px',
'line-height': '45px', // Please keep consistent with height to center vertically
background: '#e7eaf1', // The background color of the button
},
};
},
created() {
this.police(); // 列表
},
methods: {
police() {
police()
.then(response => {
if (response.code === 200) {
this.reportpolice = response.data;
} else if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
}
})
.catch(err => {
console.log(err);
});
},
handleCopy(text, event) {
clip(text, event);
},
},
};
</script> </script>
<style> <style>
......
<template> <template>
<div>设备记录</div> <div class="app-container">
<div class="filter-container">
<el-date-picker v-model="value2" align="right" type="date" placeholder="选择日期" :picker-options="pickerOptions" value-format="yyyy-MM-dd" @change="dataSearch"></el-date-picker>
</div>
<el-table :key="tableKey" :data="equipment" border fit highlight-current-rows>
<el-table-column label="设备编号" width="130">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.devicenum,$event)">{{ scope.row.devicenum }}</span>
</template>
</el-table-column>
<el-table-column label="用户姓名" width="130">
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
</template>
</el-table-column>
<el-table-column label="设备备注" width="130">
<template slot-scope="scope">
<span>{{ scope.row.deviceremark }}</span>
</template>
</el-table-column>
<el-table-column label="设备联系人" width="130">
<template slot-scope="scope">
<span>{{ scope.row.devicelinkman }}</span>
</template>
</el-table-column>
<el-table-column label="设备手机号" width="130">
<template slot-scope="scope">
<span @click="handleCopy(scope.row.devicephone,$event)">{{ scope.row.devicephone }}</span>
</template>
</el-table-column>
<el-table-column label="设备详情" width="130">
<template slot-scope="scope">
<span>{{ scope.row.deviceinfo }}</span>
</template>
</el-table-column>
<el-table-column label="设备分类" width="130">
<template slot-scope="scope">
<span>{{ scope.row.tname }}</span>
</template>
</el-table-column>
<el-table-column label="设备介质" width="130">
<template slot-scope="scope">
<span>{{ scope.row.gas }}</span>
</template>
</el-table-column>
<el-table-column label="设备单位" width="130">
<template slot-scope="scope">
<span>{{ scope.row.danwei }}</span>
</template>
</el-table-column>
<el-table-column label="设备状态" width="130">
<template slot-scope="scope">
<span>{{ scope.row.status_name }}</span>
</template>
</el-table-column>
</el-table>
<el-tooltip placement="top" content="tooltip">
<back-to-top :custom-style="myBackToTopStyle" :visibility-height="300" :back-position="50" transition-name="fade" />
</el-tooltip>
</div>
</template> </template>
<script> <script>
import { equipment, detedevice } from '@/api/device';
import clip from '@/utils/clipboard';
import BackToTop from '@/components/BackToTop';
export default {
components: { BackToTop },
data() {
return {
equipment: [],
tableKey: 0,
value2: undefined,
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
},
shortcuts: [{
text: '今天',
onClick(picker) {
picker.$emit('pick', new Date());
},
}, {
text: '昨天',
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24);
picker.$emit('pick', date);
},
}, {
text: '一周前',
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', date);
},
}],
},
myBackToTopStyle: {
right: '50px',
bottom: '50px',
width: '40px',
height: '40px',
'border-radius': '4px',
'line-height': '45px', // Please keep consistent with height to center vertically
background: '#e7eaf1', // The background color of the button
},
};
},
created() {
this.equipmentlist(); // 列表
},
methods: {
equipmentlist() {
equipment()
.then(response => {
if (response.code === 200) {
this.equipment = response.data;
} else if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
}
})
.catch(err => {
console.log(err);
});
},
handleCopy(text, event) {
clip(text, event);
},
dataSearch() {
detedevice(this.value2)
.then(response => {
if (response.code === 200) {
this.equipment = response.data;
} else if (response.code === 105) {
this.$message({
message: response.msg,
type: 'warning',
});
this.equipment = response.data;
}
})
.catch(err => {
console.log(err);
});
},
},
};
</script> </script>
<style scoped lang="scss">
<style> .placeholder-container {
ul {
li {
margin: 10px;
list-style-type: none;
}
}
}
</style> </style>
...@@ -80,6 +80,7 @@ Route::group(['middleware'=>'auth:api'],function (){ ...@@ -80,6 +80,7 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/deviceBasketList','DevicesController@deviceBasketList');//返回禁用设备和废纸篓设备 Route::get('devices/deviceBasketList','DevicesController@deviceBasketList');//返回禁用设备和废纸篓设备
Route::get('devices/addClassify/{data}','DevicesController@addClassify');//添加分类 Route::get('devices/addClassify/{data}','DevicesController@addClassify');//添加分类
Route::get('devices/delteClassify/{id}','DevicesController@delteClassify');//删除分类 Route::get('devices/delteClassify/{id}','DevicesController@delteClassify');//删除分类
Route::get('devices/detedevice','DevicesController@detedevice');//查看历史数据
}); });
//装维中心 //装维中心
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment