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

记记录模块

parent 203bdf7b
Pipeline #49 failed with stages
......@@ -16,12 +16,29 @@ class SwooleCommandMeTcpController extends Controller
{
if ($data != '') {
$datadevice = $this->stringdata($data);
Redis::set('dbtype',0);
if(Redis::get('sbjc:' . $datadevice[0]) == ''){
Redis::set('sbjc:' . $datadevice[0], $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);
$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
}
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 = [])
......@@ -58,12 +87,9 @@ class SwooleCommandMeTcpController extends Controller
->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')
->first();
if($devicedata != ''){
Redis::lPush('Devicesdata', serialize($devicedata));//进入队列进行
$dalen = Redis::llen('Devicesdata');//返回队列长度
if ($dalen == 2) {
$Devices->equipment();//推送前台
}
}
}
......
......@@ -15,6 +15,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Redis;
use Validator;
class DevicesController extends Controller
{
//设备列表
......@@ -23,14 +24,15 @@ class DevicesController extends Controller
* type 不传默认是第一个
* @type 设备类型id
* */
public function devicelist(Request $request){
public function devicelist(Request $request)
{
$type = $request->input('type');//设备类型id
$pagenNum=$request->input('page')-1;//页数
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit');
if($pagenNum === '' || $limit == ''){
return $this->jsonErrorData(105,'页数或limit不能为空');
if ($pagenNum === '' || $limit == '') {
return $this->jsonErrorData(105, '页数或limit不能为空');
}
return $this->jsonSuccessData($this->whertype($type==''? '1':$type,$pagenNum,$limit));
return $this->jsonSuccessData($this->whertype($type == '' ? '1' : $type, $pagenNum, $limit));
}
//用户设备列表
......@@ -39,73 +41,77 @@ class DevicesController extends Controller
* type 不传默认是第一个
* @type 设备类型id
* */
public function userdevicelist(Request $request){
public function userdevicelist(Request $request)
{
$type = $request->input('type');//设备类型id
$pagenNum=$request->input('page')-1;//页数
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit');
if($pagenNum === '' || $limit == ''){
return $this->jsonErrorData(105,'页数或limit不能为空');
if ($pagenNum === '' || $limit == '') {
return $this->jsonErrorData(105, '页数或limit不能为空');
}
return $this->jsonSuccessData($this->userdevice($type==''? '1':$type,$pagenNum,$limit));
return $this->jsonSuccessData($this->userdevice($type == '' ? '1' : $type, $pagenNum, $limit));
}
/*
* 删除设备
* type 1==逻辑删除
* type 2== 物理删除
* */
public function deletedecice(Request $request){
public function deletedecice(Request $request)
{
$type = (int)$request->input('type');
$deviceid = (int)$request->input('deviceid');//设备id
if ($type == '' || $deviceid == ''){
return $this->jsonErrorData(105,'参数不能为空');
if ($type == '' || $deviceid == '') {
return $this->jsonErrorData(105, '参数不能为空');
}
if ($type == 1){//逻辑删除
$dete = Device::where('id','=',$deviceid)
if ($type == 1) {//逻辑删除
$dete = Device::where('id', '=', $deviceid)
->value('delete');
if ($dete != 1){
$update = Device::where('id','=',$deviceid)
->update(['delete'=>1]);
if ($dete != 1) {
$update = Device::where('id', '=', $deviceid)
->update(['delete' => 1]);
return $this->jsonSuccessData($update);
}else{
return $this->jsonErrorData(105,'数据异常');
} else {
return $this->jsonErrorData(105, '数据异常');
}
}else if ($type == 2){//物理删除
$dete = Device::where('id','=',$deviceid)
} else if ($type == 2) {//物理删除
$dete = Device::where('id', '=', $deviceid)
->value('delete');
if ($dete != 2){
$delete = Device::where('id','=',$deviceid)
if ($dete != 2) {
$delete = Device::where('id', '=', $deviceid)
->delete();
return $this->jsonSuccessData($delete);
}else{
return $this->jsonErrorData(105,'数据异常');
} else {
return $this->jsonErrorData(105, '数据异常');
}
}
}
//返回逻辑删除的设备和修复设备
public function physicsdelete(Request $request){
public function physicsdelete(Request $request)
{
$deviceid = $request->input('deviceid');
$databadevice = DB::table('device');
if($_POST){
if ($_POST) {
$up = $databadevice
->where('id','=',$deviceid)
->update(['delete'=>2]);
->where('id', '=', $deviceid)
->update(['delete' => 2]);
return $this->jsonSuccessData($up);
}else{
} else {
//返回物理删除设备列表
$type = (int)$request->input('type');//设备类型
$pagenNum=$request->input('page')-1;//页数
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit');//条数
if($pagenNum === '' || $limit == ''){
return $this->jsonErrorData(105,'页数或limit不能为空');
if ($pagenNum === '' || $limit == '') {
return $this->jsonErrorData(105, '页数或limit不能为空');
}
$devicelist = $databadevice
->where('dtype','=',$type == '' ? '1':$type)
->where('delete','=','1')//设备逻辑删除状态
->join('device_type as dy',"device.dtype",'=','dy.tid')
->join('gas as g',"device.status",'=','g.id')
->select('dy.tname','g.gas','device.*')
->where('dtype', '=', $type == '' ? '1' : $type)
->where('delete', '=', '1')//设备逻辑删除状态
->join('device_type as dy', "device.dtype", '=', 'dy.tid')
->join('gas as g', "device.status", '=', 'g.id')
->select('dy.tname', 'g.gas', 'device.*')
->orderBy('device.id', 'desc')
->offset($pagenNum)
->limit($limit)
......@@ -116,7 +122,8 @@ class DevicesController extends Controller
}
//添加设备
public function adddevice(Request $request){
public function adddevice(Request $request)
{
//验证用户提交表单
$validator = Validator::make($request->all(), $this->getValidationRulesdevice(false));
if ($validator->fails()) {
......@@ -128,191 +135,240 @@ class DevicesController extends Controller
//编辑设备
public function updatedevice(Request $request){
public function updatedevice(Request $request)
{
$deid = $request->input('deid');
$data = $request->all();
if(is_null($deid)){
return $this->jsonErrorData(105,'设备ID不能为空');
if (is_null($deid)) {
return $this->jsonErrorData(105, '设备ID不能为空');
}
if ($_POST){
if ($_POST) {
$validator = Validator::make($request->all(), $this->getValidationRulesupdevice(false));
if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403);
}
foreach ($data as $k=>$v){
foreach ($data as $k => $v) {
if ($k == 'deid') {
unset($data[$k]);
}
}
return $this->jsonSuccessData(Device::where('id','=',$deid)->update($data));
}else{
return $this->jsonSuccessData(Device::where('id', '=', $deid)->update($data));
} else {
$devi = DB::table('device as de')
->where('de.id','=',$deid)
->leftjoin('device_type as dt','de.dtype','=','dt.tid')
->leftjoin('gas','de.status','=','gas.id')
->leftjoin('danwei as da','de.devicemonad','=','da.id')
->select('dt.*','gas.*','da.*','de.*')
->where('de.id', '=', $deid)
->leftjoin('device_type as dt', 'de.dtype', '=', 'dt.tid')
->leftjoin('gas', 'de.status', '=', 'gas.id')
->leftjoin('danwei as da', 'de.devicemonad', '=', 'da.id')
->select('dt.*', 'gas.*', 'da.*', 'de.*')
->first();
return $this->jsonSuccessData($devi);
}
}
//返回设备类型和单位和介质
public function devicetype(){
public function devicetype()
{
$gas = DB::table('gas')->get();
$danwei = DB::table('danwei')->get();
$devicetypecount = DB::table('device_type as t')
->leftjoin('device as d', 'd.dtype','=','t.tid')
->leftjoin('device as d', 'd.dtype', '=', 't.tid')
->selectRaw('t.*,count(d.id) as counnum')
->groupBy('t.tid')
->get();
return $this->jsonSuccessData(['devicetype'=>$devicetypecount,'gas'=>$gas,'danwei'=>$danwei]);
return $this->jsonSuccessData(['devicetype' => $devicetypecount, 'gas' => $gas, 'danwei' => $danwei]);
}
//返回设备列表
private function whertype($type,$pagenNum,$limit) : array {
private function whertype($type, $pagenNum, $limit): array
{
$databadevice = DB::table('device');
$devicelist = $databadevice
->where('dtype','=',$type)
->where('dtype', '=', $type)
//->where('delete','=','2')//设备不是删除状态
//->where('devicestatus','=','1')//
->leftjoin('device_type as dy',"device.dtype",'=','dy.tid')
->leftjoin('gas as g',"device.status",'=','g.id')
->leftjoin('status as p',"device.devicepolice",'=','p.id')
->select('dy.tname','g.gas','device.*','p.status_name')
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name')
->orderBy('device.id', 'desc')
->offset($pagenNum)
->limit($limit)
->get()->toArray();
$count = $databadevice
->where('dtype','=',$type)
->where('dtype', '=', $type)
//->where('delete','=','2')//设备不是删除状态
//->where('devicestatus','=','1')//
->count();
return ['devicelist'=>$devicelist,'count'=>$count];
return ['devicelist' => $devicelist, 'count' => $count];
}
//返回用户设备列表
private function userdevice($type,$pagenNum,$limit) : array {
private function userdevice($type, $pagenNum, $limit): array
{
$databadevice = DB::table('device');
$devicelist = $databadevice
->where('dtype','=',$type)
->where('uid','=',Auth::id())
->where('dtype', '=', $type)
->where('uid', '=', Auth::id())
//->where('delete','=','2')//设备不是删除状态
//->where('devicestatus','=','1')//
->leftjoin('device_type as dy',"device.dtype",'=','dy.tid')
->leftjoin('gas as g',"device.status",'=','g.id')
->leftjoin('status as p',"device.devicepolice",'=','p.id')
->select('dy.tname','g.gas','device.*','p.status_name')
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name')
->orderBy('device.id', 'desc')
->offset($pagenNum)
->limit($limit)
->get()->toArray();
$count = $databadevice
->where('dtype','=',$type)
->where('uid','=',Auth::id())
->where('dtype', '=', $type)
->where('uid', '=', Auth::id())
// ->where('delete','=','2')//设备不是删除状态
//->where('devicestatus','=','1')//
->count();
return ['devicelist'=>$devicelist,'count'=>$count];
return ['devicelist' => $devicelist, 'count' => $count];
}
private function deviceDataSearchData($devicenum,$pagenNum,$limit) : array {
private function deviceDataSearchData($devicenum, $pagenNum, $limit): array
{
$databadevice = DB::table('device');
$devicelist = $databadevice
->where('devicenum','=',$devicenum)
->where('devicenum', '=', $devicenum)
//->where('delete','=','2')//设备不是删除状态
//->where('devicestatus','=','1')//
->leftjoin('device_type as dy',"device.dtype",'=','dy.tid')
->leftjoin('gas as g',"device.status",'=','g.id')
->leftjoin('status as p',"device.devicepolice",'=','p.id')
->select('dy.tname','g.gas','device.*','p.status_name')
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name')
->orderBy('device.id', 'desc')
->offset($pagenNum)
->limit($limit)
->get()->toArray();
$count = $databadevice
->where('dtype','=',$devicenum)
->where('dtype', '=', $devicenum)
//->where('delete','=','2')//设备不是删除状态
//->where('devicestatus','=','1')//
->count();
return ['devicelist'=>$devicelist,'count'=>$count];
return ['devicelist' => $devicelist, 'count' => $count];
}
//批量上传设备
public function batchdevice(){
public function batchdevice()
{
}
//获取设备详情信息
public function deviceDataInfo($id){
$devicedata = Device::where('device.id','=',$id)
->leftjoin('contactsuser as c','c.contactsid','=','device.contactsid')
->select('c.*','device.deviceuuid','device.devicelinkman','device.devicephone','device.devicecoord')
public function deviceDataInfo($id)
{
$devicedata = Device::where('device.id', '=', $id)
->leftjoin('contactsuser as c', 'c.contactsid', '=', 'device.contactsid')
->select('c.*', 'device.deviceuuid', 'device.devicelinkman', 'device.devicephone', 'device.devicecoord')
->get();
$devicedatainfo = Device::where('id','=',$id)
->select('deviceuuid','devicelinkman','devicephone','devicecoord')
$devicedatainfo = Device::where('id', '=', $id)
->select('deviceuuid', 'devicelinkman', 'devicephone', 'devicecoord')
->get();
return $this->jsonSuccessData(['devicedata'=>$devicedata,'devicedatainfo'=>$devicedatainfo]);
return $this->jsonSuccessData(['devicedata' => $devicedata, 'devicedatainfo' => $devicedatainfo]);
}
//搜索设备账号
public function deviceDataSearch(Request $request){
public function deviceDataSearch(Request $request)
{
$data = $request->input('deviceName');
$pagenNum=$request->input('page')-1;//页数
$pagenNum = $request->input('page') - 1;//页数
$limit = $request->input('limit');
if($pagenNum === '' || $limit == '' || $data == ''){
return $this->jsonErrorData(105,'请求参数不能为空');
if ($pagenNum === '' || $limit == '' || $data == '') {
return $this->jsonErrorData(105, '请求参数不能为空');
}
return $this->jsonSuccessData($this->deviceDataSearchData($data,$pagenNum,$limit));
return $this->jsonSuccessData($this->deviceDataSearchData($data, $pagenNum, $limit));
}
//推送获取数据监测数据
public function equipment(){
public function equipment()
{
$dalen = Redis::llen('Devicesdata');//返回队列长度
if ($dalen > 0){
return $this->jsonSuccessData(unserialize(Redis::lpop('Devicesdata')));
// $num = round($dalen / 2);
$data = [];
if ($dalen > 0) {
for ($i = 0; $i < $dalen; $i++) {
array_push($data, unserialize(Redis::lpop('Devicesdata')));
}
}
if ($data != []) {
$this->devicemkdir($data); //写入文件
}
$devicelistopen = $this->devicelistopen();
if($devicelistopen != 105){
return $this->jsonSuccessData($devicelistopen);
}else{
return $this->jsonErrorData(105,'暂无数据');
}
}
//历史数据查询
public function detedevice(Request $request){
$dete = $request->input('dete');
$devicetime = $this->devicetime($dete);
if($devicetime != 105){
return $this->jsonSuccessData($devicetime);
}else{
return $this->jsonErrorData(105,'暂无数据');
}
}
//返回设备当前报警
public function police(){
return DB::table('reportpolice as r')
->where('r.status','=','1')
->join('status as s','r.policestatus','=','s.id')
->select('r.*','s.status_name')
->get()->toArray();
public function police()
{
$data = DB::table('reportpolice as r')
//->where('r.status', '=', '1')
->join('status as s', 'r.policestatus', '=', 's.id')
->select('r.*', 's.status_name')
->get();
return $this->jsonSuccessData($data);
}
//返回设备废纸篓数量
public function deviceBasket(){
return $this->jsonSuccessData(DB::table('device')->where('delete','=','1')->count());
public function deviceBasket()
{
return $this->jsonSuccessData(DB::table('device')->where('delete', '=', '1')->count());
}
//返回设备废纸篓和禁用设备
public function deviceBasketList(){
$paper = DB::table('device')->where('delete','=','1')->get()->toArray();
public function deviceBasketList()
{
$paper = DB::table('device')->where('delete', '=', '1')->get()->toArray();
return $this->jsonSuccessData($paper);
}
public function deviceDelete(Request $request){
public function deviceDelete(Request $request)
{
$id = $request->input('id');
$type = $request->input('type');
if ($type == 1){//丢弃废纸篓
return $this->jsonSuccessData(DB::table('device')->where('id','=',$id)->update(['delete'=>1,'devicestatus'=>6]));
}else{
return $this->jsonSuccessData(DB::table('device')->where('id','=',$id)->update(['devicestatus'=>6]));
if ($type == 1) {//丢弃废纸篓
return $this->jsonSuccessData(DB::table('device')->where('id', '=', $id)->update(['delete' => 1, 'devicestatus' => 6]));
} else {
return $this->jsonSuccessData(DB::table('device')->where('id', '=', $id)->update(['devicestatus' => 6]));
}
}
public function UpPaperBasket($id){
return $this->jsonSuccessData(DB::table('device')->where('id','=',$id)->update(['delete'=>2,'devicestatus'=>1]));
public function UpPaperBasket($id)
{
return $this->jsonSuccessData(DB::table('device')->where('id', '=', $id)->update(['delete' => 2, 'devicestatus' => 1]));
}
public function addClassify($data){
public function addClassify($data)
{
//添加分类
return $this->jsonSuccessData(DB::table('device_type')->insertGetId(['tname'=>$data]));
return $this->jsonSuccessData(DB::table('device_type')->insertGetId(['tname' => $data]));
}
public function delteClassify($id){
public function delteClassify($id)
{
//删除分类
return $this->jsonSuccessData(DB::table('device_type')->where('tid','=',$id)->delete());
return $this->jsonSuccessData(DB::table('device_type')->where('tid', '=', $id)->delete());
}
/**
* @param bool $isNew
* @return array
......@@ -321,36 +377,82 @@ class DevicesController extends Controller
private function getValidationRulesdevice($isNew = true)
{
return [
'devicenum'=>'required|between:2,25|unique:device,devicenum',//设备编号
'username'=>'required|unique:device,username|max:40',//设备名称
'devicephone'=> 'sometimes|required|regex:/^1[3465789]\d{9}$/|max:11',//联系人手机号
'devicelinkman'=>'sometimes|required|max:15',
'dtype'=>'required',
'status'=>'required',
'devicemonad'=>'required',
'deviceremark'=>'sometimes|required|max:15',
'devicecoord'=>'sometimes|required',
'contactsid'=>'sometimes|required',//绑定联系人id
'deviceinfo'=>'sometimes|required',
'devicenumber'=>'required|unique:device,devicenumber|max:40'
'devicenum' => 'required|between:2,25|unique:device,devicenum',//设备编号
'username' => 'required|unique:device,username|max:40',//设备名称
'devicephone' => 'sometimes|required|regex:/^1[3465789]\d{9}$/|max:11',//联系人手机号
'devicelinkman' => 'sometimes|required|max:15',
'dtype' => 'required',
'status' => 'required',
'devicemonad' => 'required',
'deviceremark' => 'sometimes|required|max:15',
'devicecoord' => 'sometimes|required',
'contactsid' => 'sometimes|required',//绑定联系人id
'deviceinfo' => 'sometimes|required',
'devicenumber' => 'required|unique:device,devicenumber|max:40'
];
}
//更新设备列表
private function getValidationRulesupdevice($isNew = true)
{
return [
'username'=>'sometimes|required|unique:device,username|max:40',//设备名称
'devicephone'=> 'sometimes|required|regex:/^1[3465789]\d{9}$/|max:11',//联系人手机号
'devicelinkman'=>'sometimes|required|max:15',
'dtype'=>'sometimes|required',
'status'=>'sometimes|required',
'devicemonad'=>'sometimes|required',
'deviceremark'=>'sometimes|required|max:15',//备注
'devicecoord'=>'sometimes|required',
'contactsid'=>'sometimes|required',//绑定联系人id
'deviceinfo'=>'sometimes|required',
'devicenumber'=>'sometimes|required|unique:device,devicenumber|max:40'
'username' => 'sometimes|required|unique:device,username|max:40',//设备名称
'devicephone' => 'sometimes|required|regex:/^1[3465789]\d{9}$/|max:11',//联系人手机号
'devicelinkman' => 'sometimes|required|max:15',
'dtype' => 'sometimes|required',
'status' => 'sometimes|required',
'devicemonad' => 'sometimes|required',
'deviceremark' => 'sometimes|required|max:15',//备注
'devicecoord' => 'sometimes|required',
'contactsid' => 'sometimes|required',//绑定联系人id
'deviceinfo' => 'sometimes|required',
'devicenumber' => 'sometimes|required|unique:device,devicenumber|max:40'
];
}
private function devicemkdir($data)
{
$path = public_path().'/device/' . date('Y-m-d' . '/');
if (!is_dir($path)){
mkdir($path);
}
file_put_contents($path . "devicelistdata.text", json_encode($data) . PHP_EOL, FILE_APPEND);
$this->devicelistopen($path);
}
private function devicelistopen() :array
{
$path = public_path().'/device/' . date('Y-m-d' . '/');
if (is_file( $path . 'devicelistdata.text')) {
$myfile = file_get_contents($path . 'devicelistdata.text');
$exp = explode("\n", $myfile);
$datadevice = [];
foreach (array_filter($exp) as $key => $vel) {
$newstring = str_replace('[', '', $vel);
$newstring1 = str_replace(']', '', $newstring);
array_push($datadevice, json_decode($newstring1, true));
}
return $datadevice;
}else{
return 105;
}
}
private function devicetime($dete) {
$path = public_path().'/device/' . $dete . '/';
if (is_file( $path . 'devicelistdata.text')) {
$myfile = file_get_contents($path . 'devicelistdata.text');
$exp = explode("\n", $myfile);
$datadevice = [];
foreach (array_filter($exp) as $key => $vel) {
$newstring = str_replace('[', '', $vel);
$newstring1 = str_replace(']', '', $newstring);
array_push($datadevice, json_decode($newstring1, true));
}
return $datadevice;
}else{
return 105;
}
}
}
\ No newline at end of file
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) {
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);
import Layout from '@/layout';
/* Router for modules */
import elementUiRoutes from './modules/element-ui';
import componentRoutes from './modules/components';
import chartsRoutes from './modules/charts';
import tableRoutes from './modules/table';
// import componentRoutes from './modules/components';
// import chartsRoutes from './modules/charts';
// import tableRoutes from './modules/table';
import adminRoutes from './modules/admin';
import deviceRoutes from './modules/device';
import usersRoutes from './modules/users';
import nestedRoutes from './modules/nested';
import errorRoutes from './modules/error';
import excelRoutes from './modules/excel';
import permissionRoutes from './modules/permission';
// import nestedRoutes from './modules/nested';
// import errorRoutes from './modules/error';
// import permissionRoutes from './modules/permission';
import historyRoutes from './modules/history.js';
import monitorRoutes from './modules/monitor.js';
......@@ -119,117 +117,115 @@ export const constantRoutes = [
deviceRoutes,
usersRoutes,
adminRoutes,
{
path: '/documentation',
component: Layout,
redirect: '/documentation/index',
children: [
{
path: 'index',
component: () => import('@/views/documentation/index'),
name: 'Documentation',
meta: { title: 'documentation', icon: 'documentation', noCache: true },
},
],
},
{
path: '/guide',
component: Layout,
redirect: '/guide/index',
children: [
{
path: 'index',
component: () => import('@/views/guide/index'),
name: 'Guide',
meta: { title: 'guide', icon: 'guide', noCache: true },
},
],
},
elementUiRoutes,
// {
// path: '/documentation',
// component: Layout,
// redirect: '/documentation/index',
// children: [
// {
// path: 'index',
// component: () => import('@/views/documentation/index'),
// name: 'Documentation',
// meta: { title: 'documentation', icon: 'documentation', noCache: true },
// },
// ],
// },
// {
// path: '/guide',
// component: Layout,
// redirect: '/guide/index',
// children: [
// {
// path: 'index',
// component: () => import('@/views/guide/index'),
// name: 'Guide',
// meta: { title: 'guide', icon: 'guide', noCache: true },
// },
// ],
// },
];
export const asyncRoutes = [
permissionRoutes,
componentRoutes,
chartsRoutes,
nestedRoutes,
tableRoutes,
{
path: '/theme',
component: Layout,
redirect: 'noredirect',
children: [
{
path: 'index',
component: () => import('@/views/theme/index'),
name: 'Theme',
meta: { title: 'theme', icon: 'theme' },
},
],
},
{
path: '/clipboard',
component: Layout,
redirect: 'noredirect',
meta: { permissions: ['view menu clipboard'] },
children: [
{
path: 'index',
component: () => import('@/views/clipboard/index'),
name: 'ClipboardDemo',
meta: { title: 'clipboardDemo', icon: 'clipboard', roles: ['admin', 'manager', 'editor', 'user'] },
},
],
},
errorRoutes,
excelRoutes,
{
path: '/zip',
component: Layout,
redirect: '/zip/download',
alwaysShow: true,
meta: { title: 'zip', icon: 'zip', permissions: ['view menu zip'] },
children: [
{
path: 'download',
component: () => import('@/views/zip'),
name: 'ExportZip',
meta: { title: 'exportZip' },
},
],
},
{
path: '/pdf',
component: Layout,
redirect: '/pdf/index',
meta: { title: 'pdf', icon: 'pdf', permissions: ['view menu pdf'] },
children: [
{
path: 'index',
component: () => import('@/views/pdf'),
name: 'Pdf',
meta: { title: 'pdf' },
},
],
},
{
path: '/pdf/download',
component: () => import('@/views/pdf/Download'),
hidden: true,
},
{
path: '/i18n',
component: Layout,
meta: { permissions: ['view menu i18n'] },
children: [
{
path: 'index',
component: () => import('@/views/i18n'),
name: 'I18n',
meta: { title: 'i18n', icon: 'international' },
},
],
},
// permissionRoutes,
// componentRoutes,
// chartsRoutes,
// nestedRoutes,
// tableRoutes,
// {
// path: '/theme',
// component: Layout,
// redirect: 'noredirect',
// children: [
// {
// path: 'index',
// component: () => import('@/views/theme/index'),
// name: 'Theme',
// meta: { title: 'theme', icon: 'theme' },
// },
// ],
// },
// {
// path: '/clipboard',
// component: Layout,
// redirect: 'noredirect',
// meta: { permissions: ['view menu clipboard'] },
// children: [
// {
// path: 'index',
// component: () => import('@/views/clipboard/index'),
// name: 'ClipboardDemo',
// meta: { title: 'clipboardDemo', icon: 'clipboard', roles: ['admin', 'manager', 'editor', 'user'] },
// },
// ],
// },
// errorRoutes,
// {
// path: '/zip',
// component: Layout,
// redirect: '/zip/download',
// alwaysShow: true,
// meta: { title: 'zip', icon: 'zip', permissions: ['view menu zip'] },
// children: [
// {
// path: 'download',
// component: () => import('@/views/zip'),
// name: 'ExportZip',
// meta: { title: 'exportZip' },
// },
// ],
// },
// {
// path: '/pdf',
// component: Layout,
// redirect: '/pdf/index',
// meta: { title: 'pdf', icon: 'pdf', permissions: ['view menu pdf'] },
// children: [
// {
// path: 'index',
// component: () => import('@/views/pdf'),
// name: 'Pdf',
// meta: { title: 'pdf' },
// },
// ],
// },
// {
// path: '/pdf/download',
// component: () => import('@/views/pdf/Download'),
// hidden: true,
// },
// {
// path: '/i18n',
// component: Layout,
// meta: { permissions: ['view menu i18n'] },
// children: [
// {
// path: 'index',
// component: () => import('@/views/i18n'),
// name: 'I18n',
// meta: { title: 'i18n', icon: 'international' },
// },
// ],
// },
{ path: '*', redirect: '/404', hidden: true },
];
......
import Layout from '@/layout';
//
const elementUiRoutes = {
path: '/element-ui',
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>
<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>
<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>
<style>
......
<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>
<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>
<style>
<style scoped lang="scss">
.placeholder-container {
ul {
li {
margin: 10px;
list-style-type: none;
}
}
}
</style>
......@@ -80,6 +80,7 @@ Route::group(['middleware'=>'auth:api'],function (){
Route::get('devices/deviceBasketList','DevicesController@deviceBasketList');//返回禁用设备和废纸篓设备
Route::get('devices/addClassify/{data}','DevicesController@addClassify');//添加分类
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