|
@@ -8,13 +8,9 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
|
|
use PhpOffice\PhpSpreadsheet\Style\Border;
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
-use \IGeTui,\IGtAppMessage,\IGtNotificationTemplate;
|
|
|
-//产品类
|
|
|
-define('APPKEY','hWPSNCBrnU6nk1SOLjZF67');
|
|
|
-define('APPID','xpoTHGLgyQ6ykBzyv42dt1');
|
|
|
-define('MASTERSECRET','aoY8L0SYeW8ofcV71W7097');
|
|
|
-define('CID','dd25afb14fa2485fcf050b5dbac482b3');
|
|
|
-define('HOST',"http://api.getui.com/apiex.htm");
|
|
|
+use MobTech\MobPush\Config\MobPushConfig;
|
|
|
+use MobTech\MobPush\Client\Push\PushV3Client;
|
|
|
+
|
|
|
/**
|
|
|
* @author lyuis
|
|
|
* 小程序首页相应功能类
|
|
@@ -478,6 +474,7 @@ class IndexController extends MainController
|
|
|
public function dataDetails()
|
|
|
{
|
|
|
$page = $this->request->param('page');
|
|
|
+ $index = $this->request->param('index',0);
|
|
|
$ALARMENDTIME = $this->request->param('ALARMENDTIME');//结束时间
|
|
|
$ALARMSTARTTIME = $this->request->param('ALARMSTARTTIME');//开始时间
|
|
|
$PRIMARYADDR = $this->request->param('PRIMARYADDR');//中继器ID
|
|
@@ -500,14 +497,14 @@ class IndexController extends MainController
|
|
|
->join('deviceinfo d', 're.DEVICEID=d.DEVICEID and re.PRIMARYADDR=d.PRIMARYADDR', 'left')
|
|
|
->field('d.*,re.ALARMSTARTTIME,re.ALARMENDTIME,re.REPORTINFO,re.STATIONNAME,rt.STATUS')
|
|
|
->order('ALARMSTARTTIME desc')
|
|
|
- ->page($page, $this->pages)
|
|
|
+ //->page($page, $this->pages)
|
|
|
->select();
|
|
|
//$arr = array(1 => '80℃', 2 => '100℃', 3 => '130℃');
|
|
|
$arrt = array(1 => 80, 2 => 100, 3 => 130);
|
|
|
$sta = array('在线', '报警', '不在线', '未配置');
|
|
|
$xAxis=$yValue=array();
|
|
|
foreach ($dataDetails as $k => &$v) {
|
|
|
- if($k==0){
|
|
|
+ if($k==$index){
|
|
|
$TEMPERTHRESHOLD=empty($v['TEMPERTHRESHOLD'])?0:$arrt[$v['TEMPERTHRESHOLD']];
|
|
|
if(!empty($v['ALARMSTARTTIME'])) {
|
|
|
array_push($xAxis, date('H:i:s',strtotime($v['ALARMSTARTTIME'])));
|
|
@@ -544,57 +541,52 @@ class IndexController extends MainController
|
|
|
|
|
|
//自动报警
|
|
|
public function autoBaojing(){
|
|
|
- $realtimedata=Db::table('realtimedata')->where(array('STATUS'=>1))->field('LASTTRANSDATE')->order('LASTTRANSDATE desc')->find();
|
|
|
- if(!empty($realtimedata['LASTTRANSDATE'])&&strtotime($realtimedata['LASTTRANSDATE'])>time()-10){
|
|
|
- $res=$this->sendPush();
|
|
|
- var_dump($res);
|
|
|
+ $where=array(array('ALARMENDTIME','=',''));//array('ALARMSTARTTIME','gt',date('Y-m-d').' 00:00:00')
|
|
|
+ $realtimedata=Db::table('reportdata')->where($where)->select();
|
|
|
+ foreach($realtimedata as $val){
|
|
|
+ $PID=$val['PRIMARYADDR'];
|
|
|
+ $res=Db::table('primarydev_user')->alias('l')
|
|
|
+ ->join('mobpush m','m.user_id=l.UID','left')
|
|
|
+ ->where(array('l.PID'=>$PID))
|
|
|
+ ->column('m.reg_id');
|
|
|
+ foreach($res as $k=>$v)
|
|
|
+ if(empty($v))
|
|
|
+ unset($res[$k]);
|
|
|
+ $admin_reg_id=Db::table('mobpush')->where(array('user_id'=>1))->column('reg_id');
|
|
|
+ $res=array_merge($admin_reg_id,$res);
|
|
|
+ if(!empty($res)){
|
|
|
+ $this->sendPush($res);
|
|
|
+ }
|
|
|
}
|
|
|
echo 'ok';
|
|
|
}
|
|
|
|
|
|
+ public function recordRegId(){
|
|
|
+ $reg_id = $this->request->param('reg_id','');
|
|
|
+ if(empty($this->userid))
|
|
|
+ $this->api_return_json(array('msg'=>'登录过期'));
|
|
|
+ if(empty($reg_id))
|
|
|
+ $this->api_return_json(array('msg'=>'no'),1);
|
|
|
+ $res=Db::table('mobpush')->where(array('user_id'=>$this->userid,'reg_id'=>$reg_id))->find();
|
|
|
+ if(empty($res))
|
|
|
+ Db::table('mobpush')->insert(array('reg_id'=>$reg_id,'user_id'=>$this->userid));
|
|
|
+ $this->api_return_json(array('msg'=>'ok'),1);
|
|
|
+ }
|
|
|
+ function pushtest(){
|
|
|
+ $this->sendPush(['65kykswdtgny41s','65kykt1a27wv3ls']);
|
|
|
+ }
|
|
|
//消息推送
|
|
|
- public function sendPush(){
|
|
|
- $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
|
|
|
- // STEP2:选择通知模板
|
|
|
- //定义透传模板,设置透传内容,和收到消息是否立即启动启用
|
|
|
- $template = $this->IGtNotificationTemplateDemo();
|
|
|
- // STEP5:定义"AppMessage"类型消息对象,设置消息内容模板、发送的目标App列表、是否支持离线发送、以及离线消息有效期(单位毫秒)
|
|
|
- $message = new IGtAppMessage();
|
|
|
- $message->set_isOffline(true);
|
|
|
- $message->set_offlineExpireTime(10 * 60 * 1000);//离线时间单位为毫秒,例,两个小时离线为3600*1000*2
|
|
|
- $message->set_data($template);
|
|
|
-
|
|
|
- $appIdList=array(APPID);
|
|
|
- // $phoneTypeList=array('ANDROID');
|
|
|
- // $provinceList=array('浙江');
|
|
|
- // $tagList=array('haha');
|
|
|
-
|
|
|
- $message->set_appIdList($appIdList);
|
|
|
- //$message->set_conditions($cdt->getCondition());
|
|
|
- // STEP6:执行推送
|
|
|
- $rep = $igt->pushMessageToApp($message,"任务组名");
|
|
|
-
|
|
|
+ public function sendPush($reg_id){
|
|
|
+ $mobPushConfig = new MobPushConfig();
|
|
|
+ $mobPushConfig::$appkey = '31c1fc57d33bf';
|
|
|
+ $mobPushConfig::$appSecret = '754bac00d98fbcfaaf1dc77277e9ee27';
|
|
|
+ $pushV3Client=new PushV3Client();
|
|
|
+ /* Registration ID推送 */
|
|
|
+ $rep=$pushV3Client->pushByRids('', '报警通知', 'FIPRES 收到报警
|
|
|
+信息一条,请前往查看', $reg_id);
|
|
|
return $rep;
|
|
|
}
|
|
|
|
|
|
- private function IGtNotificationTemplateDemo(){
|
|
|
- $template = new IGtNotificationTemplate();
|
|
|
- $template->set_appId(APPID); //应用appid
|
|
|
- $template->set_appkey(APPKEY); //应用appkey
|
|
|
- $template->set_transmissionType(1); //透传消息类型
|
|
|
- $template->set_transmissionContent("测试离线");//透传内容
|
|
|
- // STEP3:设置推送标题、推送内容
|
|
|
- $template->set_title("温度报警通知"); //通知栏标题
|
|
|
- $template->set_text("FIPRES收到报警信息一条,请前往查看 ".date('H:i:s')); //通知栏内容
|
|
|
- $template->set_logo(""); //通知栏logo
|
|
|
- $template->set_logoURL(""); //通知栏logo链接
|
|
|
- //STEP4:设置响铃、震动等推送效果
|
|
|
- $template->set_isRing(true); //是否响铃
|
|
|
- $template->set_isVibrate(true); //是否震动
|
|
|
- $template->set_isClearable(true); //通知栏是否可清除
|
|
|
-
|
|
|
- return $template;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|