|
@@ -124,14 +124,14 @@ class NoticeAction extends Action {
|
|
|
}';
|
|
|
*/
|
|
|
$single_push_type = array(
|
|
|
- C('OUTAGE_ALARM'), // 1-断电报警
|
|
|
- C('SOS_ALARM'), // 2-SOS报警
|
|
|
- C('LOWWER_BATTERY_ALARM'), // 3-低电量告警
|
|
|
- C('SHAKE_ALARM'), // 4-震动报警
|
|
|
- C('SHIFT_ALARM'), // 5-位移报警
|
|
|
- C('LOCK_VEHICLE_ALARM'), // 6-锁车告警
|
|
|
- C('STOLEN_ALARM'), // 7-被盗告警
|
|
|
- C('FENCE_ALARM'), // 8-电子围栏告警
|
|
|
+ \Rlfd\Alarm\PushTypeEnum::OUTAGE_ALARM, // C('OUTAGE_ALARM'),// 1-断电报警
|
|
|
+ \Rlfd\Alarm\PushTypeEnum::SOS_ALARM,// C('SOS_ALARM'), // 2-SOS报警
|
|
|
+ \Rlfd\Alarm\PushTypeEnum::LOWWER_BATTERY_ALARM,// C('LOWWER_BATTERY_ALARM'), // 3-低电量告警
|
|
|
+ \Rlfd\Alarm\PushTypeEnum::SHAKE_ALARM,// C('SHAKE_ALARM'), // 4-震动报警
|
|
|
+ \Rlfd\Alarm\PushTypeEnum::SHIFT_ALARM,// C('SHIFT_ALARM'), // 5-位移报警
|
|
|
+ \Rlfd\Alarm\PushTypeEnum::LOCK_VEHICLE_ALARM,// C('LOCK_VEHICLE_ALARM'), // 6-锁车告警
|
|
|
+ \Rlfd\Alarm\PushTypeEnum::STOLEN_ALARM,// C('STOLEN_ALARM'), // 7-被盗告警
|
|
|
+ \Rlfd\Alarm\PushTypeEnum::FENCE_ALARM,// C('FENCE_ALARM'), // 8-电子围栏告警
|
|
|
);
|
|
|
if(!is_array($msg_data)){
|
|
|
return array( 'success' => false , 'message' => 'invalid message data format!'.$msg_data);
|
|
@@ -142,7 +142,7 @@ class NoticeAction extends Action {
|
|
|
}
|
|
|
if( in_array($msg_data['type'],$single_push_type) && $msg_data['device_number'] ){
|
|
|
// 判断是否在围栏告警时间间隔内
|
|
|
- if( C('FENCE_ALARM_INTERVAL') && $msg_data['type'] == C('FENCE_ALARM') ){
|
|
|
+ if( C('FENCE_ALARM_INTERVAL') && $msg_data['type'] == \Rlfd\Alarm\PushTypeEnum::FENCE_ALARM ){
|
|
|
$last_alarm_time = S('last_fence_alarm_'.$msg_data['device_number']);
|
|
|
$interval_time = C('FENCE_ALARM_INTERVAL')*60;
|
|
|
if( time() - $last_alarm_time < $interval_time ){
|
|
@@ -160,7 +160,7 @@ class NoticeAction extends Action {
|
|
|
if(!$vehicle_info['JgClientRegistrationId']){
|
|
|
return array('success'=> false,'message'=>'jpush registration id not exists!');
|
|
|
}
|
|
|
- }elseif( $msg_data['type'] == C('BROADCASTING') ){
|
|
|
+ }elseif( $msg_data['type'] == \Rlfd\Alarm\PushTypeEnum::BROADCASTING ){
|
|
|
//广播
|
|
|
}else{
|
|
|
return array( 'success' => false , 'message' => '未知的告警类型:'.$msg_data['type'] );
|
|
@@ -195,7 +195,7 @@ class NoticeAction extends Action {
|
|
|
->androidNotification($alert, $android_notification)
|
|
|
->options($options);
|
|
|
|
|
|
- if( $msg_data['type'] == C('BROADCASTING') ){ // 9-广播
|
|
|
+ if( $msg_data['type'] == \Rlfd\Alarm\PushTypeEnum::BROADCASTING ){ // 9-广播
|
|
|
$push_payload->addAllAudience();
|
|
|
}elseif( isset($vehicle_info) && $vehicle_info ){ // 单推
|
|
|
$msg_data['vehicle_info'] = $vehicle_info;
|
|
@@ -216,7 +216,7 @@ class NoticeAction extends Action {
|
|
|
return array( 'success' => false , 'message' => 'add log failed 1' );
|
|
|
}
|
|
|
if( $response['http_code'] == 200 ){ //如果成功了
|
|
|
- if( C('FENCE_ALARM_INTERVAL') && $msg_data['type'] == C('FENCE_ALARM') ){
|
|
|
+ if( C('FENCE_ALARM_INTERVAL') && $msg_data['type'] == \Rlfd\Alarm\PushTypeEnum::FENCE_ALARM ){
|
|
|
//设置最后围栏告警时间缓存
|
|
|
S('last_fence_alarm_'.$msg_data['device_number'], time(), C('FENCE_ALARM_INTERVAL')*60);
|
|
|
}
|