Commit ac06c1dd authored by Administrator's avatar Administrator

Merge branch 'map_model'

# Conflicts:
#	app/Http/Controllers/DevicesController.php
parents 03a67550 9589d331
Pipeline #56 canceled with stages
......@@ -125,19 +125,12 @@ class DevicesController extends Controller
public function adddevice(Request $request)
{
//验证用户提交表单
$addDeviceData = $request->all();
$validator = Validator::make($addDeviceData, $this->getValidationRulesdevice(false));
$validator = Validator::make($request->all(), $this->getValidationRulesdevice(false));
if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 403);
}
foreach ($addDeviceData as $k => $v) {
if ($k == 'isadmin') {
unset($addDeviceData[$k]);
}
}
$type = new Device();
return $this->jsonSuccessData($type->adddevice($addDeviceData, $request->input('isadmin') == 1 ? 1 : 2));
return $this->jsonSuccessData($type->adddevice($request->all()));
}
......@@ -195,7 +188,7 @@ class DevicesController extends Controller
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('BackgroundUser as u', "device.uid", '=', 'u.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')
->offset($pagenNum)
->limit($limit)
......@@ -237,7 +230,7 @@ class DevicesController extends Controller
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('BackgroundUser as u', "device.uid", '=', 'u.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')
->offset($pagenNum)
->limit($limit)
......@@ -257,7 +250,7 @@ class DevicesController extends Controller
public function deviceDataInfo($id)
{
$devicedata = Device::where('device.id', '=', $id)
->leftjoin('contactsuser as c', 'c.contactsid', '=', 'device.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)
......@@ -265,20 +258,17 @@ class DevicesController extends Controller
->get();
return $this->jsonSuccessData(['devicedata' => $devicedata, 'devicedatainfo' => $devicedatainfo]);
}
// 返回设备地图详情信息
public function device_info($id)
{
public function device_info($id){
$devicedata = Device::where('device.id', '=', $id)
->leftjoin('device_type as dy', "device.dtype", '=', 'dy.tid')
->leftjoin('gas as g', "device.status", '=', 'g.id')
->leftjoin('BackgroundUser as u', "device.uid", '=', 'u.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();
return $this->jsonSuccessData($devicedata);
}
//搜索设备账号
public function deviceDataSearch(Request $request)
{
......@@ -308,23 +298,21 @@ class DevicesController extends Controller
$this->devicemkdir($data); //写入文件
}
$devicelistopen = $this->devicelistopen();
if ($devicelistopen != 105) {
if($devicelistopen != 105){
return $this->jsonSuccessData($devicelistopen);
} else {
return $this->jsonErrorData(105, '暂无数据');
}else{
return $this->jsonErrorData(105,'暂无数据');
}
}
//历史数据查询
public function detedevice(Request $request)
{
public function detedevice(Request $request){
$dete = $request->input('dete');
$devicetime = $this->devicetime($dete);
if ($devicetime != 105) {
if($devicetime != 105){
return $this->jsonSuccessData($devicetime);
} else {
return $this->jsonErrorData(105, '暂无数据');
}else{
return $this->jsonErrorData(105,'暂无数据');
}
}
......@@ -346,11 +334,6 @@ class DevicesController extends Controller
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()
{
......@@ -387,12 +370,20 @@ class DevicesController extends Controller
return $this->jsonSuccessData(DB::table('device_type')->where('tid', '=', $id)->delete());
}
public function deviceLocation()
public function deviceLocation(Request $request)
{
$where = [];
if($request->has('uid')) {
$user_id = $request->get('uid');
$where['uid'] = $user_id;
}
$data = DB::table('device')
->select('id','uid','nd','deviceinfo','devicenum','devicecoord','devicepolice','deviceremark','devicelinkman')
->where($where)
->get();
//返回用户安装位置
return $this->jsonSuccessData(DB::table('device')->select('id', 'uid', 'nd', 'deviceinfo', 'devicenum', 'devicecoord', 'devicepolice', 'deviceremark', 'devicelinkman')->get());
return $this->jsonSuccessData($data);
}
//返回消防监测
public function control(Request $request)
{
......@@ -402,11 +393,11 @@ class DevicesController extends Controller
if ($pagenNum === '' || $limit == '' || $type === '') {
return $this->jsonErrorData(105, '页数或limit不能为空');
}
if ($type == 1) {//返回消防监测
$wherein = [2, 4, 6, 7, 8, 9, 11];
} else {
if($type ==1){//返回消防监测
$wherein = [2,4,6,7,8,9,11];
}else{
//返回危化
$wherein = [1, 5, 10];
$wherein = [1,5,10];
}
$databadevice = DB::table('device');
$devicelist = $databadevice
......@@ -420,7 +411,7 @@ class DevicesController extends Controller
->limit($limit)
->get()->toArray();
$count = $databadevice
->whereIn('dtype', $wherein)
->whereIn('dtype',$wherein)
->count();
return $this->jsonSuccessData(['devicelist' => $devicelist, 'count' => $count]);
}
......@@ -444,7 +435,7 @@ class DevicesController extends Controller
'devicecoord' => 'sometimes|required',
'contactsid' => 'sometimes|required',//绑定联系人id
'deviceinfo' => 'sometimes|required',
'devicenumber' => 'sometimes|required|unique:device,devicenumber|max:40'
'devicenumber' => 'required|unique:device,devicenumber|max:40'
];
}
......@@ -468,8 +459,8 @@ class DevicesController extends Controller
private function devicemkdir($data)
{
$path = public_path() . '/device/' . date('Y-m-d' . '/');
if (!is_dir($path)) {
$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);
......@@ -477,10 +468,10 @@ class DevicesController extends Controller
$this->devicelistopen($path);
}
private function devicelistopen(): array
private function devicelistopen() :array
{
$path = public_path() . '/device/' . date('Y-m-d' . '/');
if (is_file($path . 'devicelistdata.text')) {
$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 = [];
......@@ -490,15 +481,14 @@ class DevicesController extends Controller
array_push($datadevice, json_decode($newstring1, true));
}
return $datadevice;
} else {
}else{
return 105;
}
}
private function devicetime($dete)
{
$path = public_path() . '/device/' . $dete . '/';
if (is_file($path . 'devicelistdata.text')) {
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 = [];
......@@ -508,7 +498,7 @@ class DevicesController extends Controller
array_push($datadevice, json_decode($newstring1, true));
}
return $datadevice;
} else {
}else{
return 105;
}
}
......
......@@ -3373,34 +3373,6 @@
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg=="
},
"bmaplib.curveline": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/bmaplib.curveline/-/bmaplib.curveline-1.0.0.tgz",
"integrity": "sha512-9wcFMVhiYxNPqpvsLDAADn3qDhNzXp2mA6VyHSHg2XOAgSooC7ZiujdFhy0sp+0QYjTfJ/MjmLuNoUg2HHxH4Q=="
},
"bmaplib.heatmap": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/bmaplib.heatmap/-/bmaplib.heatmap-1.0.4.tgz",
"integrity": "sha512-rmhqUARBpUSJ9jXzUI2j7dIOqnc38bqubkx/8a349U2qtw/ulLUwyzRD535OrA8G7w5cz4aPKm6/rNvUAarg/Q=="
},
"bmaplib.lushu": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/bmaplib.lushu/-/bmaplib.lushu-1.0.7.tgz",
"integrity": "sha512-LVvgpESPii6xGxyjnQjq8u+ic4NjvhdCPV/RiSS/PGTUdZKeTDS7prSpleJLZH3ES0+oc0gYn8bw0LtPYUSz2w=="
},
"bmaplib.markerclusterer": {
"version": "1.0.13",
"resolved": "https://registry.npmjs.org/bmaplib.markerclusterer/-/bmaplib.markerclusterer-1.0.13.tgz",
"integrity": "sha512-VrLyWSiuDEVNi0yUfwOhFQ6z1oEEHS4w36GNu3iASu6p52QIx9uAXMUkuSCHReNR0bj2Cp9SA1dSx5RpojXajQ==",
"requires": {
"bmaplib.texticonoverlay": "^1.0.2"
}
},
"bmaplib.texticonoverlay": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/bmaplib.texticonoverlay/-/bmaplib.texticonoverlay-1.0.2.tgz",
"integrity": "sha512-4ZTWr4ZP3B6qEWput5Tut16CfZgII38YwM3bpyb4gFTQyORlKYryFp9WHWrwZZaHlOyYDAXG9SX0hka43jTADg=="
},
"bn.js": {
"version": "4.11.8",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz",
......@@ -8514,11 +8486,6 @@
"integrity": "sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==",
"dev": true
},
"js-md5": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.7.3.tgz",
"integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ=="
},
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
......@@ -11798,11 +11765,6 @@
"integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=",
"dev": true
},
"qqmap": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/qqmap/-/qqmap-1.0.1.tgz",
"integrity": "sha1-Rieej5zWgALi4MxaX8FV9wH0AdM="
},
"qs": {
"version": "6.7.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
......@@ -14545,7 +14507,7 @@
},
"uppercamelcase": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/uppercamelcase/-/uppercamelcase-1.1.0.tgz",
"resolved": "https://registry.npm.taobao.org/uppercamelcase/download/uppercamelcase-1.1.0.tgz",
"integrity": "sha1-Mk2YprOvx+iolT4QZBUJsOTiP5c=",
"requires": {
"camelcase": "^1.2.1"
......@@ -14553,7 +14515,7 @@
"dependencies": {
"camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"resolved": "https://registry.npm.taobao.org/camelcase/download/camelcase-1.2.1.tgz",
"integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk="
}
}
......@@ -14744,38 +14706,12 @@
},
"vue-amap": {
"version": "0.5.10",
"resolved": "https://registry.npmjs.org/vue-amap/-/vue-amap-0.5.10.tgz",
"integrity": "sha512-9ViNCev1vx32+zZ5RvF/TmUZNbwL9QrdA2/OnD2GlXMfQBkJy7D08Vb7379t6guqnopDPtWJ8K6gg72h9+4GUg==",
"resolved": "https://registry.npm.taobao.org/vue-amap/download/vue-amap-0.5.10.tgz",
"integrity": "sha1-RkUWIDrwwIXUBL2Kyr8kAeSjb/Y=",
"requires": {
"uppercamelcase": "^1.1.0"
}
},
"vue-baidu-map": {
"version": "0.21.22",
"resolved": "https://registry.npmjs.org/vue-baidu-map/-/vue-baidu-map-0.21.22.tgz",
"integrity": "sha512-WQMPCih4UTh0AZCKKH/OVOYnyAWjfRNeK6BIeoLmscyY5aF8zzlJhz/NOHLb3mdztIpB0Z6aohn4Jd9mfCSjQw==",
"requires": {
"bmaplib.curveline": "^1.0.0",
"bmaplib.heatmap": "^1.0.4",
"bmaplib.lushu": "^1.0.7",
"bmaplib.markerclusterer": "^1.0.13",
"markdown-it": "^8.4.0"
},
"dependencies": {
"markdown-it": {
"version": "8.4.2",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.2.tgz",
"integrity": "sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==",
"requires": {
"argparse": "^1.0.7",
"entities": "~1.1.1",
"linkify-it": "^2.0.0",
"mdurl": "^1.0.1",
"uc.micro": "^1.0.5"
}
}
}
},
"vue-count-to": {
"version": "1.0.13",
"resolved": "https://registry.npmjs.org/vue-count-to/-/vue-count-to-1.0.13.tgz",
......
......@@ -77,21 +77,18 @@
"file-saver": "^2.0.2",
"fuse.js": "^3.6.1",
"js-cookie": "^2.2.1",
"js-md5": "^0.7.3",
"jsonlint": "^1.6.3",
"jszip": "^3.2.2",
"node-sass": "^4.13.1",
"normalize.css": "^8.0.1",
"nprogress": "^0.2.0",
"path-to-regexp": "^3.1.0",
"qqmap": "^1.0.1",
"screenfull": "^4.2.1",
"sortablejs": "^1.10.2",
"tui-editor": "^1.4.6",
"v-viewer": "^1.5.1",
"vue": "2.6.10",
"vue-amap": "^0.5.10",
"vue-baidu-map": "^0.21.22",
"vue-count-to": "^1.0.13",
"vue-i18n": "^8.15.5",
"vue-loader": "^15.9.1",
......
import request from '@/utils/request';
export function getmap(key) {
export function devices(query) {
return request({
url: 'https://webapi.amap.com/maps?v=1.4.15&key=' + key + '&callback=onLoad',
url: '/devices/deviceLocation',
method: 'get',
params: query,
});
}
export function users() {
return request({
url: '/user/userLocation',
method: 'get',
});
}
export function deviceinfo(id) {
return request({
url: '/devices/device_info/' + id,
method: 'get',
});
}
This diff is collapsed.
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