Index.php 2.3 KB
<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use think\Db;
use app\api\controller\Excel;
use qx\Qx;
use isc\Api;

class Index extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
//        $qx = new Qx();
        //$info = $qx->geturl("http://openapi.qxwz.com/rest/linkx.devices.list/ack/U48c2jnr9901?pageNo=1&pageSize=2000");
//        $info = $qx->geturl("http://openapi.qxwz.com/rest/linkx.devices.data/ack/U48c2jnr9901?deviceId=1000000792&startTime=1642643359000&endTime=1644544164936");
//        var_dump(json_decode($info,true));
//        exit;
        // $api = new Api();
        // var_dump($api->getPreviewUrl('1ef84de21c0e4aa19cde1c17b38bd065'));
    }


    public function test()
    {
        $number = 100000;
        $min = 0;
        $max = 1;
        $total = 0;
        for ($i = 0; $i < $number; $i++) {
            $num = $min + mt_rand() / mt_getrandmax() * ($max - $min);
            $res = sprintf("%.10f", $num);  //控制小数后几位
            if ($res <= 0.0000010207) {
                echo '有' . $res . '</br>';
            } else {
                echo '没有' . $res . '</br>';
            }
            if ($res <= 0.000001) {
                $total++;
            }
        }
        echo $total;
    }

    public function apptoken()
    {
        $appid = 'wx5488f94eb1c0bded';
        $secret = 'db6ac40041ecf6c7447620392ce59357';
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
        $res = json_decode(file_get_contents($url), true);
        Db::name('weixin_apptoken')->where('id', '=', 1)->update(['token' => $res['access_token']]);
    }

    //变更模板消息状态
    public function updateWxtemplate()
    {
        $code = input('get.code');
        $openid = input('get.openid');
        if (!$code || !$openid) {
            $this->error('非法操作', '');
        } else {
            $res = Db::name('inspection_wxtemplatelog')->where('openid', '=', $openid)->where('code', '=', $code)->update(['status' => '1']);
            if ($res) {
                $this->success('告警接收成功', '');
            } else {
                $this->error('非法操作2', '');
            }
        }
    }

}