Commit 3781ff76 authored by Administrator's avatar Administrator

回滚

parent ac06c1dd
Pipeline #57 failed with stages
...@@ -125,12 +125,19 @@ class DevicesController extends Controller ...@@ -125,12 +125,19 @@ class DevicesController extends Controller
public function adddevice(Request $request) public function adddevice(Request $request)
{ {
//验证用户提交表单 //验证用户提交表单
$validator = Validator::make($request->all(), $this->getValidationRulesdevice(false)); $addDeviceData = $request->all();
$validator = Validator::make($addDeviceData, $this->getValidationRulesdevice(false));
if ($validator->fails()) { if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403); return response()->json(['errors' => $validator->errors()], 403);
} }
foreach ($addDeviceData as $k => $v) {
if ($k == 'isadmin') {
unset($addDeviceData[$k]);
}
}
$type = new Device(); $type = new Device();
return $this->jsonSuccessData($type->adddevice($request->all())); return $this->jsonSuccessData($type->adddevice($addDeviceData, $request->input('isadmin') == 1 ? 1 : 2));
} }
...@@ -188,7 +195,7 @@ class DevicesController extends Controller ...@@ -188,7 +195,7 @@ class DevicesController extends Controller
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('BackgroundUser as u', "device.uid", '=', 'u.id') ->leftjoin('BackgroundUser as u', "device.uid", '=', 'u.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id') ->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name','u.nickname as usernickname') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'u.nickname as usernickname')
->orderBy('device.id', 'desc') ->orderBy('device.id', 'desc')
->offset($pagenNum) ->offset($pagenNum)
->limit($limit) ->limit($limit)
...@@ -230,7 +237,7 @@ class DevicesController extends Controller ...@@ -230,7 +237,7 @@ class DevicesController extends Controller
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('BackgroundUser as u', "device.uid", '=', 'u.id') ->leftjoin('BackgroundUser as u', "device.uid", '=', 'u.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id') ->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name','u.nickname as usernickname') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'u.nickname as usernickname')
->orderBy('device.id', 'desc') ->orderBy('device.id', 'desc')
->offset($pagenNum) ->offset($pagenNum)
->limit($limit) ->limit($limit)
...@@ -250,7 +257,7 @@ class DevicesController extends Controller ...@@ -250,7 +257,7 @@ class DevicesController extends Controller
public function deviceDataInfo($id) public function deviceDataInfo($id)
{ {
$devicedata = Device::where('device.id', '=', $id) $devicedata = Device::where('device.id', '=', $id)
->leftjoin('contactsuser as c', 'c.contactsid', '=', 'device.contactsid') ->leftjoin('contactsuser as c', 'c.contactsid', '=', 'device.id')
->select('c.*', 'device.deviceuuid', 'device.devicelinkman', 'device.devicephone', 'device.devicecoord') ->select('c.*', 'device.deviceuuid', 'device.devicelinkman', 'device.devicephone', 'device.devicecoord')
->get(); ->get();
$devicedatainfo = Device::where('id', '=', $id) $devicedatainfo = Device::where('id', '=', $id)
...@@ -258,17 +265,20 @@ class DevicesController extends Controller ...@@ -258,17 +265,20 @@ class DevicesController extends Controller
->get(); ->get();
return $this->jsonSuccessData(['devicedata' => $devicedata, 'devicedatainfo' => $devicedatainfo]); return $this->jsonSuccessData(['devicedata' => $devicedata, 'devicedatainfo' => $devicedatainfo]);
} }
// 返回设备地图详情信息 // 返回设备地图详情信息
public function device_info($id){ public function device_info($id)
{
$devicedata = Device::where('device.id', '=', $id) $devicedata = Device::where('device.id', '=', $id)
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid') ->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id') ->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('BackgroundUser as u', "device.uid", '=', 'u.id') ->leftjoin('BackgroundUser as u', "device.uid", '=', 'u.id')
->leftjoin('status as p', "device.devicepolice", '=', 'p.id') ->leftjoin('status as p', "device.devicepolice", '=', 'p.id')
->select('dy.tname', 'g.gas', 'device.*', 'p.status_name','u.nickname as usernickname') ->select('dy.tname', 'g.gas', 'device.*', 'p.status_name', 'u.nickname as usernickname')
->first(); ->first();
return $this->jsonSuccessData($devicedata); return $this->jsonSuccessData($devicedata);
} }
//搜索设备账号 //搜索设备账号
public function deviceDataSearch(Request $request) public function deviceDataSearch(Request $request)
{ {
...@@ -298,21 +308,23 @@ class DevicesController extends Controller ...@@ -298,21 +308,23 @@ class DevicesController extends Controller
$this->devicemkdir($data); //写入文件 $this->devicemkdir($data); //写入文件
} }
$devicelistopen = $this->devicelistopen(); $devicelistopen = $this->devicelistopen();
if($devicelistopen != 105){ if ($devicelistopen != 105) {
return $this->jsonSuccessData($devicelistopen); return $this->jsonSuccessData($devicelistopen);
}else{ } else {
return $this->jsonErrorData(105,'暂无数据'); return $this->jsonErrorData(105, '暂无数据');
} }
} }
//历史数据查询 //历史数据查询
public function detedevice(Request $request){ public function detedevice(Request $request)
{
$dete = $request->input('dete'); $dete = $request->input('dete');
$devicetime = $this->devicetime($dete); $devicetime = $this->devicetime($dete);
if($devicetime != 105){ if ($devicetime != 105) {
return $this->jsonSuccessData($devicetime); return $this->jsonSuccessData($devicetime);
}else{ } else {
return $this->jsonErrorData(105,'暂无数据'); return $this->jsonErrorData(105, '暂无数据');
} }
} }
...@@ -334,6 +346,11 @@ class DevicesController extends Controller ...@@ -334,6 +346,11 @@ class DevicesController extends Controller
return $this->jsonSuccessData(DB::table('device')->where('delete', '=', '1')->count()); return $this->jsonSuccessData(DB::table('device')->where('delete', '=', '1')->count());
} }
public function addUserDevice()
{
return $this->jsonSuccessData(DB::table('BackgroundUser')->where('state', '=', '2')->select('nickname', 'id')->get());
}
//返回设备废纸篓和禁用设备 //返回设备废纸篓和禁用设备
public function deviceBasketList() public function deviceBasketList()
{ {
...@@ -384,6 +401,7 @@ class DevicesController extends Controller ...@@ -384,6 +401,7 @@ class DevicesController extends Controller
//返回用户安装位置 //返回用户安装位置
return $this->jsonSuccessData($data); return $this->jsonSuccessData($data);
} }
//返回消防监测 //返回消防监测
public function control(Request $request) public function control(Request $request)
{ {
...@@ -393,11 +411,11 @@ class DevicesController extends Controller ...@@ -393,11 +411,11 @@ class DevicesController extends Controller
if ($pagenNum === '' || $limit == '' || $type === '') { if ($pagenNum === '' || $limit == '' || $type === '') {
return $this->jsonErrorData(105, '页数或limit不能为空'); return $this->jsonErrorData(105, '页数或limit不能为空');
} }
if($type ==1){//返回消防监测 if ($type == 1) {//返回消防监测
$wherein = [2,4,6,7,8,9,11]; $wherein = [2, 4, 6, 7, 8, 9, 11];
}else{ } else {
//返回危化 //返回危化
$wherein = [1,5,10]; $wherein = [1, 5, 10];
} }
$databadevice = DB::table('device'); $databadevice = DB::table('device');
$devicelist = $databadevice $devicelist = $databadevice
...@@ -411,7 +429,7 @@ class DevicesController extends Controller ...@@ -411,7 +429,7 @@ class DevicesController extends Controller
->limit($limit) ->limit($limit)
->get()->toArray(); ->get()->toArray();
$count = $databadevice $count = $databadevice
->whereIn('dtype',$wherein) ->whereIn('dtype', $wherein)
->count(); ->count();
return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]); return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]);
} }
...@@ -435,7 +453,7 @@ class DevicesController extends Controller ...@@ -435,7 +453,7 @@ class DevicesController extends Controller
'devicecoord' => 'sometimes|required', 'devicecoord' => 'sometimes|required',
'contactsid' => 'sometimes|required',//绑定联系人id 'contactsid' => 'sometimes|required',//绑定联系人id
'deviceinfo' => 'sometimes|required', 'deviceinfo' => 'sometimes|required',
'devicenumber' => 'required|unique:device,devicenumber|max:40' 'devicenumber' => 'sometimes|required|unique:device,devicenumber|max:40'
]; ];
} }
...@@ -459,8 +477,8 @@ class DevicesController extends Controller ...@@ -459,8 +477,8 @@ class DevicesController extends Controller
private function devicemkdir($data) private function devicemkdir($data)
{ {
$path = public_path().'/device/' . date('Y-m-d' . '/'); $path = public_path() . '/device/' . date('Y-m-d' . '/');
if (!is_dir($path)){ if (!is_dir($path)) {
mkdir($path); mkdir($path);
} }
file_put_contents($path . "devicelistdata.text", json_encode($data) . PHP_EOL, FILE_APPEND); file_put_contents($path . "devicelistdata.text", json_encode($data) . PHP_EOL, FILE_APPEND);
...@@ -468,10 +486,10 @@ class DevicesController extends Controller ...@@ -468,10 +486,10 @@ class DevicesController extends Controller
$this->devicelistopen($path); $this->devicelistopen($path);
} }
private function devicelistopen() :array private function devicelistopen(): array
{ {
$path = public_path().'/device/' . date('Y-m-d' . '/'); $path = public_path() . '/device/' . date('Y-m-d' . '/');
if (is_file( $path . 'devicelistdata.text')) { if (is_file($path . 'devicelistdata.text')) {
$myfile = file_get_contents($path . 'devicelistdata.text'); $myfile = file_get_contents($path . 'devicelistdata.text');
$exp = explode("\n", $myfile); $exp = explode("\n", $myfile);
$datadevice = []; $datadevice = [];
...@@ -481,14 +499,15 @@ class DevicesController extends Controller ...@@ -481,14 +499,15 @@ class DevicesController extends Controller
array_push($datadevice, json_decode($newstring1, true)); array_push($datadevice, json_decode($newstring1, true));
} }
return $datadevice; return $datadevice;
}else{ } else {
return 105; return 105;
} }
} }
private function devicetime($dete) { private function devicetime($dete)
$path = public_path().'/device/' . $dete . '/'; {
if (is_file( $path . 'devicelistdata.text')) { $path = public_path() . '/device/' . $dete . '/';
if (is_file($path . 'devicelistdata.text')) {
$myfile = file_get_contents($path . 'devicelistdata.text'); $myfile = file_get_contents($path . 'devicelistdata.text');
$exp = explode("\n", $myfile); $exp = explode("\n", $myfile);
$datadevice = []; $datadevice = [];
...@@ -498,7 +517,7 @@ class DevicesController extends Controller ...@@ -498,7 +517,7 @@ class DevicesController extends Controller
array_push($datadevice, json_decode($newstring1, true)); array_push($datadevice, json_decode($newstring1, true));
} }
return $datadevice; return $datadevice;
}else{ } else {
return 105; return 105;
} }
} }
......
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