Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
laravelzh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冯超鹏
laravelzh
Commits
de6c3ce2
Commit
de6c3ce2
authored
Dec 22, 2020
by
冯超鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新 短信操作
parent
4546c1c7
Pipeline
#240
canceled with stages
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
25 deletions
+34
-25
ZehongTcpController.php
app/Http/Controllers/Auth/ZehongTcpController.php
+30
-21
SmsailiyunController.php
app/Http/Controllers/SmsailiyunController.php
+2
-2
package-lock.json
package-lock.json
+2
-2
No files found.
app/Http/Controllers/Auth/ZehongTcpController.php
View file @
de6c3ce2
...
...
@@ -11,6 +11,7 @@ use App\Http\Controllers\DevicesController;
use
Illuminate\Support\Facades\Config
;
use
App\Http\Controllers\Auth\SwooleCommandMeTcpController
;
use
App\Http\Controllers\SmsailiyunController
;
class
ZehongTcpController
extends
Controller
{
...
...
@@ -35,15 +36,15 @@ class ZehongTcpController extends Controller
$devicecrc
=
substr
(
$data
,
22
,
4
);
$isdata
=
substr
(
$data
,
0
,
22
);
// return $this->jsonSuccessData([$this->getPrc($isdata),$devicecrc]);
if
(
$this
->
getPrc
(
$isdata
)
==
$devicecrc
)
{
$data
=
[
'id'
=>
$deviceId
,
'status'
=>
$status
,
'np'
=>
$devicenp
,
'famen'
=>
$devicefamen
,
'chongqi'
=>
$devicechongqi
,
'zijian'
=>
$devicezijian
];
$totcp
=
json_decode
(
$this
->
mysqldb
(
$data
),
true
);
if
(
$totcp
==
"No equipment"
){
if
(
$this
->
getPrc
(
$isdata
)
==
$devicecrc
)
{
$data
=
[
'id'
=>
$deviceId
,
'status'
=>
$status
,
'np'
=>
$devicenp
,
'famen'
=>
$devicefamen
,
'chongqi'
=>
$devicechongqi
,
'zijian'
=>
$devicezijian
];
$totcp
=
json_decode
(
$this
->
mysqldb
(
$data
),
true
);
if
(
$totcp
==
"No equipment"
)
{
return
$totcp
;
}
$totcpdata
=
$totcp
[
'devicenum'
]
.
$totcp
[
'device_control'
]
.
$devicechongqi
.
$devicezijian
;
$crcdata
=
$this
->
getPrc
(
$totcpdata
);
return
$totcpdata
.
$crcdata
;
return
$totcpdata
.
$crcdata
;
}
}
else
{
return
"Data format error"
;
...
...
@@ -83,37 +84,45 @@ class ZehongTcpController extends Controller
$crc2
=
strrev
(
substr
(
$data
,
2
,
2
));
return
$crc1
.
$crc2
;
}
//获取上报数据从数据库查询
public
function
mysqldb
(
$data
){
if
(
$data
!=
[]){
public
function
mysqldb
(
$data
)
{
if
(
$data
!=
[])
{
// 报警提醒
$meTcp
=
new
SwooleCommandMeTcpController
();
$alarmData
=
$data
[
'id'
]
.
'/'
.
$data
[
'status'
]
.
'/'
.
$data
[
'np'
];
$meTcp
->
swooletcplist
(
$alarmData
);
$this
->
smsphone
(
$data
);
$datainfo
=
DB
::
table
(
'device'
)
->
where
(
'devicenum'
,
'='
,
$data
[
'id'
])
->
update
([
'nd'
=>
intval
(
$data
[
'np'
]),
'devicepolice'
=>
$data
[
'status'
]
==
0
?
'1'
:
$data
[
'status'
],
'update_time'
=>
time
(),
'shutoff_status'
=>
$data
[
'famen'
]]);
->
where
(
'devicenum'
,
'='
,
$data
[
'id'
])
->
update
([
'nd'
=>
intval
(
$data
[
'np'
]),
'devicepolice'
=>
$data
[
'status'
]
==
0
?
'1'
:
$data
[
'status'
],
'update_time'
=>
time
(),
'shutoff_status'
=>
$data
[
'famen'
]]);
$todata
=
DB
::
table
(
'device'
)
->
where
(
'devicenum'
,
'='
,
$data
[
'id'
])
->
select
(
'devicenum'
,
'nd'
,
'device_control'
,
'devicepolice'
)
->
where
(
'devicenum'
,
'='
,
$data
[
'id'
])
->
select
(
'devicenum'
,
'nd'
,
'device_control'
,
'devicepolice'
)
->
first
();
if
(
$todata
){
if
(
$todata
)
{
return
json_encode
(
$todata
);
}
else
{
}
else
{
return
json_encode
(
"No equipment"
);
}
}
}
// 发送手机报警信息
public
function
smsphone
(
$data
){
if
(
Redis
::
get
(
'smsyanshi'
)
!=
''
){
if
(
$data
[
'status'
]
!=
1
||
$data
[
'status'
]
!=
0
){
public
function
smsphone
(
$data
)
{
if
(
Redis
::
get
(
$data
[
'id'
])
!=
''
)
{
if
(
$data
[
'status'
]
==
1
||
$data
[
'status'
]
==
0
)
{
Redis
::
del
(
$data
[
'id'
]);
}
else
{
if
(
$data
[
'status'
]
!=
1
||
$data
[
'status'
]
!=
0
)
{
$sms
=
new
SmsailiyunController
();
$code
=
json_encode
(
$sms
->
sendSms
(),
true
);
if
(
$code
[
'Message'
]
==
'OK'
&&
$code
[
'Code'
]
==
'OK'
){
Redis
::
set
(
'smsyanshi'
,
$code
);
$code
=
json_encode
(
$sms
->
sendSms
(),
true
);
if
(
$code
[
'Message'
]
==
'OK'
&&
$code
[
'Code'
]
==
'OK'
)
{
Redis
::
set
(
$data
[
'id'
],
$code
);
}
}
}
}
...
...
app/Http/Controllers/SmsailiyunController.php
View file @
de6c3ce2
...
...
@@ -66,7 +66,7 @@ class SmsailiyunController
// 必填,设置短信接收号码
// 15200013720
$request
->
setPhoneNumbers
(
"1
663115087
0"
);
$request
->
setPhoneNumbers
(
"1
520001372
0"
);
// 必填,设置签名名称,应严格按"签名名称"填写,请参考: https://dysms.console.aliyun.com/dysms.htm#/develop/sign
$request
->
setSignName
(
"泽宏云"
);
...
...
@@ -76,7 +76,7 @@ class SmsailiyunController
// 可选,设置模板参数, 假如模板中存在变量需要替换则为必填项
$request
->
setTemplateParam
(
json_encode
(
array
(
// 短信模板中字段的值
"cphone"
=>
"1
663115087
0"
,
"cphone"
=>
"1
520001372
0"
,
"position"
=>
"您的设备尾号为"
.
5712
,
"alarm"
=>
'离线'
),
JSON_UNESCAPED_UNICODE
));
...
...
package-lock.json
View file @
de6c3ce2
...
...
@@ -14520,7 +14520,7 @@
},
"uppercamelcase"
:
{
"version"
:
"1.1.0"
,
"resolved"
:
"https://registry.npm
.taobao.org/uppercamelcase/download
/uppercamelcase-1.1.0.tgz"
,
"resolved"
:
"https://registry.npm
js.org/uppercamelcase/-
/uppercamelcase-1.1.0.tgz"
,
"integrity"
:
"sha1-Mk2YprOvx+iolT4QZBUJsOTiP5c="
,
"requires"
:
{
"camelcase"
:
"^1.2.1"
...
...
@@ -14528,7 +14528,7 @@
"dependencies"
:
{
"camelcase"
:
{
"version"
:
"1.2.1"
,
"resolved"
:
"https://registry.npm
.taobao.org/camelcase/download
/camelcase-1.2.1.tgz"
,
"resolved"
:
"https://registry.npm
js.org/camelcase/-
/camelcase-1.2.1.tgz"
,
"integrity"
:
"sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk="
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment