├── .example_env ├── .gitignore ├── LICENSE.txt ├── README.md ├── Socket_server.php ├── application ├── .htaccess ├── addons │ └── cache │ │ ├── Common.php │ │ ├── hook │ │ ├── CacheChartInfo.php │ │ ├── ChartProcess.php │ │ └── Chartdata.php │ │ └── model │ │ ├── Datament.php │ │ ├── Screenchart.php │ │ └── Screencharttconfig.php ├── base │ └── controller │ │ ├── Addons.php │ │ └── Base.php ├── command.php ├── common.php ├── config.php ├── database.php ├── extra │ ├── addons.php │ ├── chartType.php │ └── queue.php ├── index │ ├── common.php │ ├── controller │ │ ├── Audit.php │ │ ├── Backdown.php │ │ ├── Carousel.php │ │ ├── Chart.php │ │ ├── Databasesource.php │ │ ├── Datamap.php │ │ ├── Datament.php │ │ ├── Datasource.php │ │ ├── Deviceinfo.php │ │ ├── Drilldown.php │ │ ├── File.php │ │ ├── Icon.php │ │ ├── Index.php │ │ ├── My.php │ │ ├── Page.php │ │ ├── Releasebinding.php │ │ ├── Rep.php │ │ ├── Screen.php │ │ ├── Setsystem.php │ │ ├── Socket.php │ │ ├── Socketscreen.php │ │ ├── System.php │ │ ├── Template.php │ │ ├── Template1.php │ │ ├── Test.php │ │ ├── Unity.php │ │ ├── User.php │ │ ├── Viewdata.php │ │ ├── Websocket.php │ │ ├── Windex.php │ │ └── Woperating.php │ └── model │ │ ├── Carousel.php │ │ ├── Deviceinfo.php │ │ ├── Gisdata.php │ │ ├── My.php │ │ ├── Publish.php │ │ ├── Screen.php │ │ ├── Screenchart.php │ │ ├── Unity.php │ │ ├── Unityjson.php │ │ ├── User.php │ │ └── sdata.php ├── plugins │ ├── common.php │ ├── controller │ │ ├── Demo.php │ │ ├── Index.php │ │ └── Upload.php │ └── model │ │ ├── FileUtil.php │ │ └── Plugins.php ├── release │ ├── config.php │ └── controller │ │ └── Index.php ├── route.php ├── tags.php ├── user │ ├── controller │ │ └── User.php │ └── model │ │ └── User.php └── websocket │ └── controller │ └── Setting.php ├── build.php ├── composer.json ├── composer.lock ├── data └── .gitignore ├── doc ├── FAQ.md └── plugin.md ├── docker-compose.yml ├── docker ├── Dockerfile ├── default.conf ├── fpm.service ├── nginx.conf ├── nginx.service └── php.ini ├── extend ├── DataSource.php └── datasource │ ├── Currency.php │ ├── Elasticsearch.php │ ├── Mongo.php │ └── Oracle.php ├── openbi.sql ├── public ├── .htaccess ├── CommonPlugins │ ├── echarts4.8 │ │ └── echarts.min.js │ ├── echarts5.0 │ │ └── echarts.min.js │ └── jquery3.5 │ │ └── jquery.min.js ├── ConvertIpNew.php ├── Cover │ └── .gitignore ├── KindEditor │ ├── JSON.php │ ├── attached │ │ └── 1.php │ └── upload_json.php ├── alg │ └── .gitignore ├── api.php ├── index.php ├── robots.txt ├── router.php ├── static │ ├── css │ │ └── wd.css │ ├── img │ │ ├── Oval.png │ │ ├── logo.png │ │ └── medical.png │ └── js │ │ └── my.js └── uploads │ ├── logo │ └── defualt │ │ └── logo.png │ └── staticimg │ ├── perview_avatar_1.png │ ├── perview_avatar_2.png │ └── perview_avatar_3.png ├── runtime └── .gitignore ├── think └── vendor └── .gitignore /.example_env: -------------------------------------------------------------------------------- 1 | [config] 2 | app_debug = true 3 | app_trace = true 4 | static_config_path = public/openv/static/config.json 5 | [database] 6 | hostname = 127.0.0.1 7 | database = openbi 8 | username = root 9 | password = 123456 10 | hostport = 3306 11 | charset = utf8mb4 12 | prefix = up_ 13 | debug = false 14 | [redis] 15 | host = 127.0.0.1 16 | port = 6379 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.log 3 | favicon.ico 4 | thinkphp 5 | openv 6 | .env 7 | .DS_Store 8 | .vscode 9 | thinkphp 10 | framework 11 | tests/ 12 | public/uploads -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | OpenBI 数据可视化软件,支持的是NC协议。 2 | 可以进行个人使用,但是不可以进行商业使用。 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 官方地址 2 | 3 | [http://www.openbi.com.cn/](http://www.openbi.com.cn/) 4 | 5 | ## 安装方式一 6 | 7 | - 环境要求PHP7.0以上。(建议PHP7.2) 8 | 9 | - 建议环境 lnmp 10 | 11 | - 从 [releases](https://github.com/openBI-kwc/openBI/releases/) 下载部署包openbi.zip 12 | 13 | - 将openbi.zip 上传到服务器并解压到指定位置 14 | 15 | - 将解压的目录授权到web服务启动用户(如: chown -R www:www /home/wwwroot/openbi) 16 | 17 | - 配置 nginx server模块新增webserver的ip或域名与openbi的路径绑定 18 | 19 | - 部署不支持二级目录,请直接将域名或ip定位到项目目录/public下 20 | 21 | - 添加重写规则 22 | 23 | ```bash 24 | if (!-e $request_filename) { 25 | rewrite ^(.*)$ /index.php?s=$1 last; 26 | break; 27 | } 28 | ``` 29 | 30 | - 进入到openbi解压目录 找到.example_env 并复制为 .env (linux执行:cp .example_env .env) 31 | 32 | - 导入openbi.sql 33 | 34 | - 修改 .env 相应配置(配置数据库信息) 35 | 36 | - 默认账号密码 admin / admin 37 | 38 | - 请取消禁用函数 putenv (php.ini中disable_function) 39 | 40 | ## 安装方式二 41 | 42 | - 使用宝塔面板一键部署安装 43 | 44 | ## 安装方式三 45 | 46 | - 从 [releases](https://github.com/openBI-kwc/openBI/releases/) 下载部署包openbi.zip (适用于**版本1.0.5**及以上) 47 | 48 | - 解压 49 | 50 | - 安装docker,docker-compose后运行 51 | 52 | ```bash 53 | docker-compose up 54 | # 后台运行 55 | docker-compose up -d 56 | ``` 57 | 58 | - 注意默认端口为80、3306、6379、若有端口占用,请修改docker-compoe.yml相关端口 59 | 60 | - 默认数据库mysql的密码为root 61 | 62 | - 将openbi.sql导入数据库 63 | 64 | - 进入到openbi解压目录 找到.example_env 并复制为 .env 65 | 66 | - 修改 .env 相关数据库配置 67 | 68 | - 默认访问地址:[ip:80]() 账号密码(默认账号密码 admin / admin) 69 | 70 | ## 其他文档 71 | 72 | - FAQ [doc/FAQ.md](doc/FAQ.md) 73 | 74 | - 插件开发[doc/plugin.md](doc/plugin.md) 75 | 76 | ## 数据源支持 77 | 78 | - excel/csv 79 | - API 80 | - websocket 81 | - mysql 82 | - pgsql 83 | - SQLServer 84 | - Oracle 85 | - es 86 | - redis 87 | - MongoDB 88 | ## 系统支持 89 | 90 | 稳定支持Linux CentOS系统 91 | 92 | ## 示例 93 | 94 | -  95 | -  96 | -  97 | -  98 | -  99 | -  100 | 101 | ## License 102 | 103 | 遵循nc开源协议发布,并提供个人免费使用。 104 | 105 | ## 官方QQ技术交流群 106 | 107 | 328601229 (QQ群号) 108 | 109 | 110 | ## 商务垂询 111 | 黄成:13370182900(非购买商业授权勿扰) 112 | -------------------------------------------------------------------------------- /Socket_server.php: -------------------------------------------------------------------------------- 1 | on('open' , function ($ws , $request){ 14 | var_dump("客户端-{$request->fd}连接"); 15 | }); 16 | 17 | 18 | $ws->on('message', function( $ws , $request ) { 19 | if($request->data == "ping") { 20 | $ws->push($request->fd, "pong"); 21 | }else { 22 | go(function () use ($ws , $request){ 23 | $GLOBALS[$request->fd] = swoole_timer_tick(1000, function ($timer_id) use ($ws , $request){ 24 | try{ 25 | //var_dump($request->data); 26 | $result = isJson($request->data , true); 27 | //var_dump($result); 28 | $id = $result["sid"]; 29 | $curlData = file_get_contents(WEB_PATH."/index/Websocket/index?id=".$id); 30 | $user_message = $curlData; 31 | if(!empty(json_decode($user_message, 1)["data"])){ 32 | $ws->push($request->fd, $user_message); 33 | } 34 | } catch (\Exception $e) { 35 | 36 | } 37 | //var_dump($user_message); 38 | }); 39 | }); 40 | } 41 | }); 42 | 43 | function isJson($data = '', $assoc = false) { 44 | $data = json_decode($data, $assoc); 45 | if ($data && (is_object($data)) || (is_array($data) && !empty(current($data)))) { 46 | return $data; 47 | } 48 | return false; 49 | } 50 | 51 | 52 | 53 | $ws->on('close',function($ws,$request){ 54 | if(isset($GLOBALS[$request])) { 55 | $result = swoole_timer_clear($GLOBALS[$request]); 56 | var_dump($result); 57 | } 58 | var_dump("客户端-{$request}断开连接"); 59 | }); 60 | 61 | $ws->start(); 62 | 63 | class Env 64 | { 65 | const ENV_PREFIX = 'PHP_'; 66 | 67 | /** 68 | * 加载配置文件 69 | * @access public 70 | * @param string $filePath 配置文件路径 71 | * @return void 72 | */ 73 | public static function loadFile(string $filePath):void 74 | { 75 | if (!file_exists($filePath)) throw new \Exception('配置文件' . $filePath . '不存在'); 76 | //返回二位数组 77 | $env = parse_ini_file($filePath, true); 78 | foreach ($env as $key => $val) { 79 | $prefix = static::ENV_PREFIX . strtoupper($key); 80 | if (is_array($val)) { 81 | foreach ($val as $k => $v) { 82 | $item = $prefix . '_' . strtoupper($k); 83 | putenv("$item=$v"); 84 | } 85 | } else { 86 | putenv("$prefix=$val"); 87 | } 88 | } 89 | } 90 | 91 | /** 92 | * 获取环境变量值 93 | * @access public 94 | * @param string $name 环境变量名(支持二级 . 号分割) 95 | * @param string $default 默认值 96 | * @return mixed 97 | */ 98 | public static function get(string $name, $default = null) 99 | { 100 | $result = getenv(static::ENV_PREFIX . strtoupper(str_replace('.', '_', $name))); 101 | 102 | if (false !== $result) { 103 | if ('false' === $result) { 104 | $result = false; 105 | } elseif ('true' === $result) { 106 | $result = true; 107 | } 108 | return $result; 109 | } 110 | return $default; 111 | } 112 | } -------------------------------------------------------------------------------- /application/.htaccess: -------------------------------------------------------------------------------- 1 | deny from all -------------------------------------------------------------------------------- /application/addons/cache/Common.php: -------------------------------------------------------------------------------- 1 | ['>=', $tid]]; 19 | self::cacheMore($where); 20 | } 21 | 22 | } 23 | 24 | public static function cacheMore($where) 25 | { 26 | $allChart = Screenchart::getChartInfo($where); 27 | foreach ($allChart as $chart) { 28 | self::cacheChart($chart); 29 | } 30 | } 31 | public static function cacheAll() 32 | { 33 | $allChart = Screenchart::getAllChart(); 34 | foreach ($allChart as $chart) { 35 | self::cacheChart($chart); 36 | } 37 | } 38 | // 缓存单图表 39 | public static function cacheSingle($tid) 40 | { 41 | $chart = Screenchart::getSingleChart($tid); 42 | self::cacheChart($chart); 43 | } 44 | // 缓存大屏图表 45 | public static function cacheScreen($screenid) 46 | { 47 | $allChart = Screenchart::getScreenchart($screenid); 48 | foreach ($allChart as $chart) { 49 | self::cacheChart($chart); 50 | } 51 | self::cacheScreen($allChart); 52 | } 53 | // public function getChartCache($tid) 54 | // { 55 | // return \think\Cache::get(Common::getTidDataCacheName($chart['tid'])); 56 | // } 57 | // public function getScreenCache($screenid) 58 | // { 59 | // return \think\Cache::get(Common::getScreenidDataCacheName($chart['screenid'])); 60 | // } 61 | 62 | // 缓存单一图表 63 | protected static function cacheChart($chart) 64 | { 65 | \think\Cache::set(Common::getTidDataCacheName($chart['tid']), $chart->toArray()); 66 | } 67 | // 缓存大屏图表 68 | protected static function cacheScreenchart() 69 | { 70 | \think\Cache::set(Common::getScreenidDataCacheName($chart['screenid']), collection($chart)->toArray()); 71 | } 72 | } -------------------------------------------------------------------------------- /application/addons/cache/hook/ChartProcess.php: -------------------------------------------------------------------------------- 1 | field('tid')->where('screenid', $screenid)->select(); 33 | // 无数据返回 34 | if (!$chartInfos) return []; 35 | $data = []; 36 | foreach ($chartInfos as $chartInfo) { 37 | $data += self::processChart($chartInfo['tid']); 38 | } 39 | return $data; 40 | } 41 | // 单图表处理 42 | public static function processChart($tid) 43 | { 44 | //根据id从缓存里拿到图表数据 45 | $chartCache = Common::getChartCache($tid); 46 | $data[$chartCache['tname']] = self::processSingleChart($chartCache); 47 | return $data; 48 | } 49 | protected static function processSingleChart($chartCache) 50 | { 51 | // 实时数据 52 | $realTimeData = self::getRealTimeData($chartCache); 53 | if (!isset($realTimeData[0]) && $chartCache['chartSourceType']) return $chartCache['name'].'无法获取数据'; 54 | $mapData = self::mapping($realTimeData, $chartCache['maps']); 55 | if (!$mapData) return $chartCache['name'].'数据映射有误!'; 56 | return Chart::index($chartCache['charttype'], $mapData, $chartCache['name']); 57 | } 58 | // 获取实时数据 59 | protected static function getRealTimeData($data) 60 | { 61 | // 图片等类型无数据类型的返回空 62 | if (!method_exists(__CLASS__, $data['chartSourceType'])) return $data['dataInfo']; 63 | // 其他有类型的 64 | return self::{$data['chartSourceType']}($data); 65 | } 66 | // 映射 67 | public static function mapping($realTimeData, $maps) 68 | { 69 | $realTimeData = is_array($realTimeData) ? $realTimeData : json_decode($realTimeData, true); 70 | if (!$maps) return $realTimeData; 71 | foreach ($realTimeData as &$value) { 72 | foreach ($maps as $newKey => $oldKey) { 73 | if (!isset($value[$oldKey])) return false; 74 | if ($oldKey == $newKey) continue; 75 | $value[$newKey] = $value[$oldKey]; 76 | unset($value[$oldKey]); 77 | } 78 | } 79 | return $realTimeData; 80 | } 81 | 82 | protected static function static($data) 83 | { 84 | return $data['tdata']; 85 | } 86 | protected static function api($data) 87 | { 88 | try{ 89 | //直接从API里面取值 90 | $results = file_get_contents($data['filepath'] , false , stream_context_create(array( 91 | "ssl"=>array( 92 | "verify_peer"=>false, 93 | "verify_peer_name"=>false, 94 | ), 95 | ))); 96 | //如果返回值为XML则转成json 97 | if(xml_parser($results)){ 98 | $xml =simplexml_load_string($results); 99 | $xmljson= json_encode($xml); 100 | $result=json_decode($xmljson,true); 101 | }else{ 102 | $result=json_decode($results,true); 103 | } 104 | 105 | return $result; 106 | } catch (\Exception $e) { 107 | return false; 108 | } 109 | } 110 | protected static function sql($data) 111 | { 112 | //通过数据库配置ID拿到数据库配置 113 | $config = Db::name('databasesource')->where('baseid' , $data['sid'])->find(); 114 | //判断是否查询成功 115 | if (!$config) return false; 116 | $config = json_decode($config['baseconfig'],1); 117 | $config['password'] = decrypt($config['password'],$config['len']); 118 | //连接数据库执行sql 119 | return \DataSource::connect($config)->query($data['returnsql']); 120 | } 121 | protected static function webSocket($data) 122 | { 123 | try{ 124 | //直接从API里面取值 125 | $results = file_get_contents($data['filepath'] , false , stream_context_create(array( 126 | "ssl"=>array( 127 | "verify_peer"=>false, 128 | "verify_peer_name"=>false, 129 | ), 130 | ))); 131 | //如果返回值为XML则转成json 132 | if(xml_parser($results)){ 133 | $xml =simplexml_load_string($results); 134 | $xmljson= json_encode($xml); 135 | $result=json_decode($xmljson,true); 136 | }else{ 137 | $result=json_decode($results,true); 138 | } 139 | return $result; 140 | } catch (\Exception $e) { 141 | return false; 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /application/addons/cache/model/Datament.php: -------------------------------------------------------------------------------- 1 | data['data']; 12 | } 13 | } -------------------------------------------------------------------------------- /application/addons/cache/model/Screenchart.php: -------------------------------------------------------------------------------- 1 | hasOne('Screencharttconfig','tid', 'tid')->bind('name,chartSourceType,charttype,dataOpt,maps'); 12 | } 13 | public function datament() 14 | { 15 | return $this->hasOne('Datament','daid', 'daid')->bind('filepath,datatype,returnsql,sid,dataInfo'); 16 | } 17 | 18 | 19 | // 获取所有图表数据 20 | public static function getAllChart() 21 | { 22 | return self::with('charttconfig,datament')->field('daid,screenid,tid,tname,tdata')->select(); 23 | } 24 | // 获取单个图表数据 25 | public static function getSingleChart($tid) 26 | { 27 | return self::with('charttconfig,datament')->field('daid,screenid,tid,tname,tdata')->where('tid', $tid)->find(); 28 | } 29 | // 获取大屏图表数据 30 | public static function getScreenChart($screenid) 31 | { 32 | return self::with('charttconfig,datament')->field('daid,screenid,tid,tname,tdata')->where('screenid', $screenid)->select(); 33 | } 34 | // 由条件获取图表数据 35 | public static function getChartInfo($where = []) 36 | { 37 | return self::with('charttconfig,datament')->field('daid,screenid,tid,tname,tdata')->where($where)->select(); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /application/addons/cache/model/Screencharttconfig.php: -------------------------------------------------------------------------------- 1 | dataOpt['map']) ? array_filter(array_combine(array_column($this->dataOpt['map'], 0), array_column($this->dataOpt['map'], 1))) : []; 16 | } 17 | } -------------------------------------------------------------------------------- /application/base/controller/Addons.php: -------------------------------------------------------------------------------- 1 | module()); 13 | $controller = strtolower(request()->controller()); 14 | $action = strtolower(request()->action()); 15 | $path = $module .'/'. $controller .'/'.$action; 16 | // 插件规则 17 | $addonConfig = config('addons'); 18 | foreach ($addonConfig as $pluginName => $pluginConfig) { 19 | $pluginConfig['enabled'] = $pluginConfig['enabled'] ?? 'true'; 20 | if (isset($pluginConfig['role'][$path]) && $pluginConfig['enabled']) { 21 | \think\Hook::add($pluginConfig['role'][$path][0], $pluginConfig['role'][$path][1]); 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /application/base/controller/Base.php: -------------------------------------------------------------------------------- 1 | request = $request; 44 | 45 | $request = Request::instance(); 46 | //获取当前模块 47 | $module = strtolower($request->module()); 48 | //获取当前控制器 49 | $controller = strtolower($request->controller()); 50 | //获取当前方法 51 | $action = strtolower($request->action()); 52 | 53 | 54 | 55 | //接口为index/index/index 不使用base; 56 | if($module ==='index' && $controller == 'index' && $action == 'index') { 57 | return 1; 58 | } 59 | //给定一个解救标识 60 | $getScreenInfo = 0; 61 | //接口为index/index/singlescreensummary 不使用base; 62 | if($module ==='index' && $controller == 'index' && $action == 'getscreeninfo') { 63 | //将接口标识设置为true 64 | $getScreenInfo = 1; 65 | } 66 | //接口为index/index/singlescreensummary 不使用base; 67 | if($module ==='index' && $controller == 'index' && $action == 'singlescreensummary') { 68 | //将接口标识设置为true 69 | $getScreenInfo = 1; 70 | } 71 | 72 | if(!$getScreenInfo){ 73 | //初始化userModel 74 | $this->userModel = new UserModel(); 75 | //获取uid和token 76 | $arr = get_all_header(); 77 | if(isset($arr['token'])){ 78 | $this->token = $arr['token']; 79 | }else { 80 | $data = get_status(1,'非法用户访问' ,10001 ); 81 | ajaxReturn($data); 82 | } 83 | $input['token'] = $arr['token']; 84 | $getUid = $this->userModel->getMessg('token' ,['token' => $arr['token']]); 85 | if(!$getUid) { 86 | $data = get_status(1,'Token验证失败' , 10002); 87 | ajaxReturn($data); 88 | } 89 | $input['uid'] = $getUid[0]['uid']; 90 | $uid = $input['uid']; 91 | 92 | //将用户信息存入变量 93 | $user = $this->userModel->getUser($uid); 94 | if($user){ 95 | $this->user = $user; 96 | } 97 | // 查询token过期时间 98 | $token = $this->userModel->getMessg('token' , ['token' => $input['token']]); 99 | //判断token是否存在 100 | if($token){ 101 | //判断token是否过期 102 | if(time() > $token[0]['tokentime']){ 103 | //token过期 删除token 同时登录-1 104 | $userTokenDel = $this->userModel->getMessg('user' , ['uid' => $input['uid']]); 105 | $online = $userTokenDel[0]['online'] - 1; 106 | //ajaxReturn($online); 107 | $userTokenDel = $this->userModel->updateMessg('user' , ['uid' => $input['uid']] , ['online' => $online]); 108 | $tokendel = $this->userModel->deleteMessg('token' , ['token' => $input['token']]); 109 | $data = get_status(1,'由于您长时间未操作系统自动退出' , 10003); 110 | ajaxReturn($data); 111 | }else { 112 | //token未过期 ,操作加token过期时间 113 | $data = [ 114 | 'tokentime' => time()+720000 115 | ]; 116 | $tokentime = $this->userModel->updateMessg('token' , ['token' => $input['token']] , $data); 117 | } 118 | }else{ 119 | $data = get_status(1,'请先登录' , 10004); 120 | ajaxReturn($data); 121 | } 122 | 123 | //通过用户id获得角色id 124 | $result = $this->userModel->getRole($this->user['uid']); 125 | if($result) { 126 | $rid = $result['rid']; 127 | }else{ 128 | $data = get_status(1,'该用户没有指定角色',1004 ); 129 | ajaxReturn($data); 130 | } 131 | 132 | //通过角色ID获得角色名称 133 | $result = $this->userModel->getRolename($rid); 134 | 135 | //将角色组存入用户变量 136 | $this->role = $result; 137 | 138 | //通过角色ID获得权限ID 139 | $result = $this->userModel->getPid($rid); 140 | if($result) { 141 | $pid = $result['pid']; 142 | }else{ 143 | $arr = get_status(1,'无权限访问',0005); 144 | ajaxReturn($arr); 145 | } 146 | 147 | //通过权限ID获取权限列表 148 | $result = $this->userModel->getPermission($pid); 149 | if($result) { 150 | //将用户权限存入变量 151 | $this->permission = $result; 152 | }else{ 153 | $arr = get_status(1,'无权限访问',0005); 154 | ajaxReturn($arr); 155 | } 156 | 157 | if(!$this->token){ 158 | $arr = get_status(1,'无权限访问',0005); 159 | ajaxReturn($arr); 160 | } 161 | 162 | 163 | 164 | //定义i判断条件 1为没有权限 0位通过权限验证 165 | $m = $module .'/'. $controller .'/'.$action; 166 | $i = 1; 167 | 168 | foreach ($this->permission as $value) { 169 | //判断用户有没有操作该操作的权利 170 | if(trim(strtolower($value['urlm'])) == strtolower($module) && trim(strtolower($value['urlc'])) == strtolower($controller) && trim(strtolower($value['urla'])) == strtolower($action)) { 171 | $i = 0; 172 | break; 173 | } 174 | } 175 | 176 | //处理lv为2的权限 177 | //查询接口 178 | $urlLv = $this->userModel->getMessg('permission' , ['urlm' =>$module , 'urlc' => $controller , 'urla' => $action]); 179 | 180 | //判断lv是否是2 181 | if($urlLv) { 182 | if($urlLv[0]['lv'] == 2){ 183 | $i = 0; 184 | } 185 | } 186 | 187 | if($i){ 188 | unset($i); 189 | $arr = get_status(1,'没有操作权限',0006); 190 | ajaxReturn($arr); 191 | } 192 | } 193 | } 194 | 195 | 196 | //获取用户权限列表 197 | public function getPermission($uid) 198 | { 199 | //将用户信息存入变量 200 | $user = $this->userModel->getUser($uid); 201 | if($user){ 202 | $this->user = $user; 203 | } 204 | 205 | //通过用户id获得角色id 206 | $result = $this->userModel->getRole($uid); 207 | if($result) { 208 | $rid = $result['rid']; 209 | }else{ 210 | // ajaxReturn_encode(['err' => 1 ,'data' => '该用户没有指定角色']); 211 | $data = get_status(1,'该用户没有指定角色' , 1004 ); 212 | return $data; 213 | } 214 | 215 | //通过角色ID获得角色名称 216 | $result = $this->userModel->getRolename($rid); 217 | 218 | //将角色名称存入用户变量 219 | $this->rolename = $result['rolename']; 220 | 221 | //通过角色ID获得权限ID 222 | $result = $this->userModel->getPid($rid); 223 | if($result) { 224 | $rid = $result['pid']; 225 | }else{ 226 | return false; 227 | } 228 | 229 | //通过权限ID获取权限列表 230 | $result = $this->userModel->getPermission($rid); 231 | if($result) { 232 | //将用户权限存入变量 233 | return $result; 234 | }else{ 235 | return false; 236 | } 237 | } 238 | 239 | } -------------------------------------------------------------------------------- /application/command.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return []; 13 | -------------------------------------------------------------------------------- /application/common.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | // 应用公共文件 13 | 14 | 15 | function get_status($err, $da, $status = null) 16 | { 17 | $data['err'] = $err; 18 | $data['data'] = $da; 19 | if ($data['err']) { 20 | $data['status'] = $status; 21 | } 22 | return $data; 23 | } 24 | 25 | 26 | function get_Log($username, $operation, $state) 27 | { 28 | Db::name('log')->insert(['username'=>$username,'operation'=>$operation,'state'=>$state]); 29 | } 30 | 31 | 32 | function get_types($filename) 33 | { 34 | $type = substr($filename, strrpos($filename, ".")+1); 35 | return $type; 36 | } 37 | 38 | function ajaxReturn($data) 39 | { 40 | exit(json_encode($data)) ; 41 | } 42 | 43 | 44 | //获取header头中的值(token) 45 | function get_all_header() 46 | { 47 | // 忽略获取的header数据。这个函数后面会用到。主要是起过滤作用 48 | $ignore = array('host','accept','content-length','content-type'); 49 | 50 | $headers = array(); 51 | //这里大家有兴趣的话,可以打印一下。会出来很多的header头信息。咱们想要的部分,都是‘http_'开头的。所以下面会进行过滤输出。 52 | /* var_dump($_SERVER); 53 | exit;*/ 54 | 55 | foreach ($_SERVER as $key=>$value) { 56 | if (substr($key, 0, 5)==='HTTP_') { 57 | //这里取到的都是'http_'开头的数据。 58 | //前去开头的前5位 59 | $key = substr($key, 5); 60 | //把$key中的'_'下划线都替换为空字符串 61 | $key = str_replace('_', ' ', $key); 62 | //再把$key中的空字符串替换成‘-’ 63 | $key = str_replace(' ', '-', $key); 64 | //把$key中的所有字符转换为小写 65 | $key = strtolower($key); 66 | 67 | //这里主要是过滤上面写的$ignore数组中的数据 68 | if (!in_array($key, $ignore)) { 69 | if ($key == "access-token") { 70 | $headers['token'] = $value; 71 | } else { 72 | $headers[$key] = $value; 73 | } 74 | } 75 | } 76 | } 77 | //输出获取到的header 78 | return $headers; 79 | } 80 | 81 | 82 | /** 83 | * 判断传过来的键是否存在 84 | * 85 | * */ 86 | function valiKeys($keys, $input) 87 | { 88 | //遍历键 89 | foreach ($keys as $k => $v) { 90 | if (!isset($input[$v])) { 91 | return get_status(1, $v.'未设置'); 92 | } 93 | } 94 | return get_status(0, []); 95 | } 96 | 97 | 98 | /** 99 | * 默认返回为html是返回json格式 100 | */ 101 | function jsonRetuen($err, $data, $status = null) 102 | { 103 | if ($status) { 104 | return json(['err' => $err , 'data' => $data,'status'=>$status]); 105 | } else { 106 | return json(['err' => $err , 'data' => $data]); 107 | } 108 | } 109 | 110 | 111 | /** 112 | * @Notes : 解密 113 | * @access : $password : 解密内容 114 | * @author : wwk 115 | * @Time: 2018/08/13 11:23 116 | */ 117 | function decrypt($password, $len) 118 | { 119 | $key = 'kwc.net'; 120 | $str = openssl_decrypt($password, 'aes-128-cbc', $key, 2); 121 | $pwd = substr($str, 0, $len); 122 | return $pwd; 123 | } 124 | 125 | //获取配置文件信息 126 | function configJson() 127 | { 128 | //获取配置文件信息 129 | $file = file_get_contents(config('static_config_path')); 130 | //将配置文件转换数组 131 | $arr = json_decode($file, 1); 132 | if (!$arr) { 133 | $arr = json_decode(trim($file,chr(239).chr(187).chr(191)),true); 134 | } 135 | //返回配置文件信息及路径 136 | return ['config' => $arr , 'path' => config('static_config_path')]; 137 | } 138 | 139 | 140 | //处理base64图片 141 | function base64Image($data) 142 | { 143 | if (!is_string($data) || $data == '') { 144 | return false; 145 | } 146 | $base64 = $data; 147 | $arr = explode(',', $base64); 148 | //取出后缀 149 | $ext = base64Ext($arr[0]); 150 | //取出base64图片字符串 151 | $base64Str = $arr[1]; 152 | $file = base64_decode($base64Str); 153 | //定义图片名称 154 | $fileName = md5(mt_rand(100, 999).time()).'.'.$ext; 155 | //定义图片路径 156 | $filePath = ROOT_PATH . 'public' . DS . 'uploads' . DS . date('Ymd', time()); 157 | if (!file_exists($filePath)) { 158 | mkdir($filePath, 0755); 159 | } 160 | //保存图片 161 | $r = file_put_contents($filePath.DS.$fileName, $file); 162 | 163 | if ($r) { 164 | //获取图片相对路径 165 | $imgPath = str_replace(ROOT_PATH, '', $filePath.DS.$fileName); 166 | return $imgPath; 167 | } else { 168 | return false; 169 | } 170 | } 171 | 172 | 173 | // 传入base64前部分带有照片后缀的字符串 174 | function base64Ext($str) 175 | { 176 | $step1 = explode('/', $str); 177 | $step2 = explode(';', $step1[1]); 178 | return $step2[0]; 179 | } 180 | 181 | 182 | //模型统一判断返回格式 183 | function agreeReturn($result) 184 | { 185 | if ($result) { 186 | return $result; 187 | } 188 | return false; 189 | } 190 | 191 | //判断键是否存在,不存在给默认值 192 | function issetKey($input, $key, $value) 193 | { 194 | if (!isset($input[$key])) { 195 | $input[$key] = $value; 196 | } else { 197 | $input[$key] = rtrim(strtolower($input[$key])); 198 | } 199 | return $input[$key]; 200 | } 201 | 202 | //判断xml格式 203 | //自定义xml验证函数xml_parser() 204 | function xml_parser($str) 205 | { 206 | $xml_parser = xml_parser_create(); 207 | if (!xml_parse($xml_parser, $str, true)) { 208 | xml_parser_free($xml_parser); 209 | return false; 210 | } else { 211 | return (json_decode(json_encode(simplexml_load_string($str)), true)); 212 | } 213 | } 214 | 215 | 216 | function curl_request($url, $opt = []) 217 | { 218 | $sec = $opt['sec'] ?? 3; 219 | $method = $opt['method'] ?? 'GET'; 220 | $headers = $opt['headers'] ?? []; 221 | $params = $opt['params'] ?? []; 222 | if (is_array($params)) { 223 | $requestString = http_build_query($params); 224 | } else { 225 | $requestString = $params ? : ''; 226 | } 227 | if (empty($headers)) { 228 | $headers = array('Content-type: text/json'); 229 | } elseif (!is_array($headers)) { 230 | parse_str($headers, $headers); 231 | } 232 | $ch = curl_init(); 233 | curl_setopt($ch, CURLOPT_URL, $url); 234 | curl_setopt($ch, CURLOPT_VERBOSE, 1); 235 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 236 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 237 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 238 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 239 | curl_setopt($ch, CURLOPT_TIMEOUT, $sec); 240 | curl_setopt($ch, CURLOPT_POST, 1); 241 | switch (strtoupper($method)) { 242 | case "GET": curl_setopt($ch, CURLOPT_HTTPGET, 1);break; 243 | case "POST": curl_setopt($ch, CURLOPT_POST, 1); 244 | curl_setopt($ch, CURLOPT_POSTFIELDS, $requestString);break; 245 | case "PUT": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); 246 | curl_setopt($ch, CURLOPT_POSTFIELDS, $requestString);break; 247 | case "DELETE": curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 248 | curl_setopt($ch, CURLOPT_POSTFIELDS, $requestString);break; 249 | } 250 | $response = curl_exec($ch); 251 | curl_close($ch); 252 | if (stristr($response, 'HTTP 404') || $response == '') { 253 | return array('Error' => '请求错误'); 254 | } 255 | return $response; 256 | } 257 | -------------------------------------------------------------------------------- /application/database.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | use think\Env; 13 | 14 | return [ 15 | // 数据库类型 16 | 'type' => 'mysql', 17 | // 服务器地址 18 | 'hostname' => Env::get('database.hostname'), 19 | // 数据库名 20 | 'database' => Env::get('database.database'), 21 | //用户名 22 | 'username' => Env::get('database.username'), 23 | // 密码 24 | 'password' => Env::get('database.password'), 25 | // 端口 26 | 'hostport' => Env::get('database.hostport'), 27 | // 连接dsn 28 | 'dsn' => '', 29 | // 数据库连接参数 30 | 'params' => [], 31 | // 数据库编码默认采用utf8 32 | 'charset' => Env::get('database.charset'), 33 | // 数据库表前缀 34 | 'prefix' => Env::get('database.prefix'), 35 | // 数据库调试模式 36 | 'debug' => Env::get('database.debug'), 37 | // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 38 | 'deploy' => 0, 39 | // 数据库读写是否分离 主从式有效 40 | 'rw_separate' => false, 41 | // 读写分离后 主服务器数量 42 | 'master_num' => 1, 43 | // 指定从服务器序号 44 | 'slave_no' => '', 45 | // 是否严格检查字段是否存在 46 | 'fields_strict' => true, 47 | // 数据集返回类型 48 | 'resultset_type' => 'array', 49 | // 自动写入时间戳字段 50 | 'auto_timestamp' => false, 51 | // 时间字段取出后的默认时间格式 52 | 'datetime_format' => 'Y-m-d H:i:s', 53 | // 是否需要进行SQL性能分析 54 | 'sql_explain' => false, 55 | ]; -------------------------------------------------------------------------------- /application/extra/addons.php: -------------------------------------------------------------------------------- 1 | [ 5 | // 是否开启缓存 6 | 'enabled' => true, 7 | // 图表数据(api,静态,sql等) 8 | 'config' => [ 9 | 'tidChartData' => 'tiddata', 10 | 'screenidChartData' => 'screeniddata', 11 | ], 12 | // 增加监听 13 | 'role'=>[ 14 | 'index/screen/updatechart' => ['app_end', 'app\\addons\\cache\\hook\\CacheChartInfo'], 15 | 'index/screen/addchart' => ['app_end', 'app\\addons\\cache\\hook\\CacheChartInfo'], 16 | 'index/screen/chartcopy' => ['app_end', 'app\\addons\\cache\\hook\\CacheChartInfo'], 17 | ], 18 | ], 19 | ]; -------------------------------------------------------------------------------- /application/extra/chartType.php: -------------------------------------------------------------------------------- 1 | 9 | //折线图,散点图,柱状图 10 | "line", 11 | 12 | "line"=> 13 | //折线图,散点图,柱状图 14 | "line", 15 | 16 | "pie" => 17 | //饼图 18 | "pie", 19 | 20 | "wangye" => 21 | //web 22 | "web", 23 | 24 | "lunbotu" => 25 | //轮播图 26 | "carousel", 27 | 28 | "fuwenben"=> 29 | //richtxt 30 | "web", 31 | 32 | "jishuban"=> 33 | //计数板 34 | "web", 35 | 36 | "duoxingwenben"=> 37 | //richtxt 38 | "web", 39 | 40 | "paomadeng"=> 41 | //richtxt 42 | "web", 43 | 44 | "jindutiao"=> 45 | //richtxt 46 | "web", 47 | 48 | "huanxingjindutiao"=> 49 | //richtxt 50 | "web", 51 | 52 | "biaoge" => 53 | //表格 54 | "lunbotable", 55 | 56 | "lunbobiaoge" => 57 | //表格 58 | "lunbotable", 59 | 60 | "scatter" => 61 | //散点图 62 | "scatter", 63 | 64 | //下面为大改之后 65 | "biaozhuduibibingtu" => 66 | "pie1", 67 | 68 | "daitubingtu" => 69 | //饼图 70 | "pie1", 71 | 72 | "jibenbingtu" => 73 | //饼图 74 | "pie1", 75 | 76 | "huanshanbingtu" => 77 | //饼图 78 | "pie1", 79 | 80 | "lunbobingtu" => 81 | //饼图 82 | "pie1", 83 | 84 | "zhibiaoduibibingtu" => 85 | //饼图 86 | "pie1", 87 | 88 | "zhibiaozhanbibingtu" => 89 | //饼图 90 | "pie3", 91 | 92 | "duoweidubingtu" => 93 | //饼图 94 | "pie", 95 | 96 | "banmazhutu" => 97 | //柱状图 98 | "bar1", 99 | 100 | "chuizhijibenzhutu" => 101 | //柱状图 102 | "bar1", 103 | 104 | "chuizhijiaonanzhutu" => 105 | //柱状图 106 | "bar1", 107 | 108 | "fenzuzhutu" => 109 | //柱状图 110 | "bar1", 111 | 112 | "huxingzhutu" => 113 | //柱状图 114 | "huxingzhutu", 115 | 116 | "jibenzhutu" => 117 | //柱状图 118 | "bar1", 119 | 120 | "shuipingjibenzhutu" => 121 | //柱状图 122 | "bar1", 123 | 124 | "shuipingjiaonanzhutu" => 125 | //柱状图 126 | "bar1", 127 | 128 | "tixingzhutu" => 129 | //柱状图 130 | "bar1", 131 | 132 | "zhexianzhutu" => 133 | //柱状图 134 | "bar2", 135 | 136 | "jibenzhexiantu" => 137 | //柱状图 138 | "bar1", 139 | 140 | "quyutu" => 141 | //柱状图 142 | "bar1", 143 | 144 | "quyufanpaiqi" => 145 | //柱状图 146 | "bar1", 147 | 148 | "shuangzhouzhexiantu" => 149 | //柱状图 150 | "line4", 151 | 152 | "qipaotu" => 153 | //散点图 154 | "scatter2", 155 | 156 | "sandiantu" => 157 | //散点图 158 | "scatter2", 159 | 160 | "ciyun" => 161 | //词云 162 | "wordCloud", 163 | 164 | "loudoutu" => 165 | //词云 166 | "funnel", 167 | 168 | "shuiqiutu" => 169 | //liquidFill 170 | "liquidFill", 171 | 172 | "yibiaopan" => 173 | //gauge 174 | "gauge", 175 | 176 | "leidatu" => 177 | //gauge 178 | "radar", 179 | 180 | "xiangxingtu" => 181 | //boxplot 182 | "boxplot", 183 | 184 | "relitu" => 185 | //gridheatmap 186 | "gridheatmap", 187 | 188 | "guanxiwangluo" => 189 | //graph 190 | "graph", 191 | 192 | "zhongguoditu" => 193 | //chinamap 194 | "chinamap", 195 | 196 | "3dzhongguoditu" => 197 | //chinamap 198 | "chinamap3d", 199 | 200 | "sandianzhexiantu" => 201 | //chinamap 202 | "scatter3", 203 | 204 | "qipaozhexiantu" => 205 | //chinamap 206 | "scatter3", 207 | 208 | "danzhouzhexianzhutu" => 209 | //chinamap 210 | "bar11", 211 | 212 | "3dzhuzhuangtu" => 213 | //chinamap 214 | "bar12", 215 | 216 | "juxingshutu" => 217 | //chinamap 218 | "rectangletree", 219 | 220 | "shijieditu" => 221 | //chinamap 222 | "worldMap", 223 | 224 | "diqiuyi" => 225 | //chinamap 226 | "globechart", 227 | 228 | "3dshijieditu" => 229 | //chinamap 230 | "worldMap3d", 231 | 232 | "gismap" => 233 | //chinamap 234 | "chinamap", 235 | 236 | "sangjitu" => 237 | //chinamap 238 | "sankey", 239 | 240 | "hexiantu" => 241 | //chinamap 242 | "graph", 243 | 244 | "shuangxianghengxiangzhuzhuangtu" => 245 | //chinamap 246 | "bar1", 247 | 248 | "jishubanpro" => 249 | //chinamap 250 | "web", 251 | 252 | "xuritu" => 253 | //chinamap 254 | "sunburst", 255 | 256 | "3dzhexiantu" => 257 | //chinamap 258 | "line5", 259 | 260 | "xuxianzhexiantu" => 261 | //chinamap 262 | "bar1", 263 | 264 | "huanzhuangfaguangzhanbitu" => 265 | //chinamap 266 | "pie11", 267 | 268 | "danzhibaifenbibingtu" => 269 | //chinamap 270 | "pie3", 271 | 272 | "mubiaozhanbibingtu" => 273 | //chinamap 274 | "pie3", 275 | "nengyuanbiaoge" => 276 | //chinamap 277 | "lunbotable", 278 | 279 | "paimingbiaoge" => 280 | //chinamap 281 | "lunbotable", 282 | 283 | "zhuixingzhutu" => 284 | //chinamap 285 | "bar1", 286 | 287 | "2.5dduidietu" => 288 | //chinamap 289 | "bar1", 290 | 291 | "baifenbiduibibintu" => 292 | //chinamap 293 | "baifenbiduibibintu", 294 | 295 | "jindutiaoxingma" => 296 | //chinamap 297 | "jindutiaoxingma", 298 | 299 | "jianbianzhuzhuangtu" => 300 | //chinamap 301 | "jianbianzhuzhuangtu", 302 | //chinamap 303 | "3dzhuzhuangqushibianhuatu" => 304 | "zhuzhuangqushibianhuatu3d", 305 | //chinamap 306 | "shuipingfaguangzhuzhuangtu" => 307 | "shuipingfaguangzhuzhuangtu", 308 | //chinamap 309 | "fenzujianbianzhuzhuangtu" => 310 | "bar1", 311 | //chinamap 312 | "timelinebar" => 313 | "timelinebar", 314 | //chinamap 315 | "zhexianzhuzhuangtu" => 316 | "zhexianzhuzhuangtu", 317 | //chinamap 318 | "leidabianxingtu" => 319 | "leidabianxingtu", 320 | //chinamap 321 | "shujubingtu" => 322 | "shujubingtu", 323 | 324 | "huanxingshujutu" => 325 | "huanxingshujutu", 326 | 327 | "huanxingbilitu" => 328 | "huanxingbilitu", 329 | 330 | "babianxingtutwo" => 331 | "babianxingtutwo", 332 | "siyecaotu" => 333 | "siyecaotu", 334 | "babianxingtu"=> 335 | "babianxingtu", 336 | //wwk新增 337 | "shebeizhuangtaijiankong" => 338 | "asItIs", //返回原数据 339 | "zhuangtaideng" => 340 | "asItIs",//返回原数据 341 | "shijianzhou" => 342 | "asItIs",//返回原数据 343 | "tixingtu" => 344 | "asItIs",//返回原数据 345 | "shuangyuanhudutu" => 346 | "asItIs",//返回原数据 347 | "banhuanbaifenbitu" => 348 | "asItIs",//返回原数据 349 | "polygongis" => 350 | "polygongis",//gis地图第一版 351 | "xingbienianlingtu" => 352 | "asItIs",//返回原数据 353 | "kxiantu2" => 354 | "kxiantu2",//返回原数据 355 | "amapgis" => 356 | "asItIs",//返回原数据 357 | "cloudComponent" => 358 | "cloudComponent",//需要处理 359 | ]; -------------------------------------------------------------------------------- /application/extra/queue.php: -------------------------------------------------------------------------------- 1 | 10 | // +---------------------------------------------------------------------- 11 | 12 | return [ 13 | 'connector' => 'Sync' 14 | ]; -------------------------------------------------------------------------------- /application/index/common.php: -------------------------------------------------------------------------------- 1 | ROOT_PATH.'data/',//数据库备份路径 23 | ); 24 | $db= new Backup($config);//实例化数据库备份类进行条用里面的方法。 25 | 26 | $str = trim($post['dataname'],'-1.sql'); 27 | $str = explode('-',$str); 28 | $str = join($str,''); 29 | //dump($str); 30 | $result = $db->downloadFile(strtotime($str)); 31 | if (!empty($result)) { 32 | return get_status(1,$result); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /application/index/controller/Carousel.php: -------------------------------------------------------------------------------- 1 | carousel = Loader::model("Carousel"); 35 | //初始化发布列表model 36 | $this->publish = Loader::model("Publish"); 37 | 38 | } 39 | 40 | public function index() 41 | { 42 | return 1; 43 | } 44 | 45 | /** 46 | * 获取一个ID 47 | * @return mixed 48 | */ 49 | public function getCarouselId() 50 | { 51 | //将创建时间加入data 52 | $data = [ 53 | 'createtime' => time() 54 | ]; 55 | //增加一条记录获取ID 56 | $id = $this->carousel->getInsertID($data); 57 | if($id) { 58 | return get_status(0,intval($id)); 59 | }else { 60 | return get_status(1, "网络繁忙" , 9001); 61 | } 62 | } 63 | 64 | /** 65 | * 添加轮播列表 66 | * @return mixed 67 | */ 68 | public function addCarouselScreen() 69 | { 70 | //获取input数据 71 | $input = input('post.'); 72 | 73 | //判断shareIds是否是数组 74 | if(is_array($input['screens'])) { 75 | $input['screens'] = implode(',' , $input['screens']); 76 | } 77 | $cname = Db::name('carouselrelease')->where('cname',$input['cname'])->find(); 78 | if($cname){ 79 | return get_status(1,'文件名重复',4006); 80 | } 81 | //组合data 82 | $data = [ 83 | 'animation' =>$input['animation'], 84 | 'remarks' =>$input['remarks'], 85 | 'controlPos' => $input['controlPos'], 86 | 'cname' => $input['cname'], 87 | 'screens' => $input['screens'], 88 | 'crIdent' => $input['crIdent'], 89 | 'crLink' => $input['crLink'], 90 | 'time' => intval($input['time']), 91 | 'createtime' =>time(), 92 | 'updatetime' =>time() 93 | ]; 94 | $insert = $this->carousel->getInsertID($data); 95 | 96 | if($insert) { 97 | return get_status(0,"添加成功"); 98 | }else { 99 | return get_status(1, "网络繁忙" , 9001); 100 | } 101 | 102 | } 103 | 104 | //获取轮播图表 105 | public function getCarousel() 106 | { 107 | //获取input数据 108 | $input = input('get.'); 109 | //搜索条件 110 | $where = isset($input['searchword']) ? $input['searchword'] : ''; 111 | //当前页 112 | $currentPage = isset($input['currentPage']) ? $input['currentPage'] : '1'; 113 | //每页显示数 114 | $pageSize = isset($input['pageSize']) ? $input['pageSize'] : '10'; 115 | //排序条件 116 | $order = isset($input['order']) ? $input['order'] : 'cname'; 117 | //查询列表 118 | $result['list'] = $this->carousel->getCarouselListAll($where,$currentPage,$pageSize,$order); 119 | //数据总数 120 | $result['total'] = count(Db::name('carouselrelease')->where('cname','like','%'.$where.'%')->select()); 121 | //将图表地址改为数组 122 | foreach($result['list'] as $k=>&$v){ 123 | $v['screens'] = explode(',',$v['screens']); 124 | } 125 | //直接返回数组 126 | return get_status(0,$result); 127 | } 128 | 129 | /** 130 | * 由ID装换成发布链接 131 | * @param $data 132 | */ 133 | protected function CarouselListURL($data) 134 | { 135 | //设置发布列表查询ID集合 136 | $publishIDs = []; 137 | //将查询出来的轮播列表中的发布ID提取出来 138 | foreach ($data as $key => $value) { 139 | //判断cpid是否有值 140 | if(!empty($value['cpid'])) { 141 | //将cpid切割为数组 142 | $tmpArr= explode(',' , $value['cpid']); 143 | foreach ($tmpArr as $v) { 144 | //提取cpid 145 | $publishIDs[] = $v; 146 | } 147 | //初始化$tmpArr 148 | $tmpArr = []; 149 | } 150 | } 151 | //定义where条件 152 | $where['scid'] =['in' , array_unique($publishIDs)]; 153 | //查询发布列表 154 | $selectList = $this->publish->getWhereList($where,"scid,link"); 155 | $publishList = []; 156 | //将查询结果以pid为键保存 157 | foreach ($selectList as $value) { 158 | $publishList[$value['scid']] = $value['link']; 159 | } 160 | //将$data中的cpid换成具体的link 161 | foreach ($data as $key => $value) { 162 | //判断cpid是否有值 163 | if(!empty($value['cpid'])) { 164 | //将cpid切割为数组 165 | $tmpArr= explode(',' , $value['cpid']); 166 | //将源cpid初始化 167 | $data[$key]['cpid'] = []; 168 | foreach ($tmpArr as $v) { 169 | if(isset($publishList[$v]) ){ 170 | //给cpid重新赋值 171 | $data[$key]['cpid'][] = $publishList[$v]; 172 | } 173 | } 174 | //初始化$tmpArr 175 | $tmpArr = []; 176 | } 177 | } 178 | //返回数组 179 | return $data; 180 | } 181 | 182 | //删除轮播列表 183 | public function delCarousel() 184 | { 185 | //获取input数据 186 | $input = input('get.'); 187 | //验证参数是否正确 188 | //判断shareIds是否是数组 189 | if(is_array($input['crid'])) { 190 | $input['crid'] = implode(',' , $input['crid']); 191 | } 192 | //设置where条件 193 | $where['crid'] = ["in" , $input['crid']]; 194 | //执行删除 195 | $delete = $this->carousel->deleteCarousel($where); 196 | //判断是否删除成功 197 | if($delete) { 198 | return get_status(0 , "删除成功"); 199 | }else { 200 | return get_status(1 , "网路繁忙" , 9001); 201 | } 202 | } 203 | //修改轮播图信息 204 | public function updateCarouselScreen() 205 | { 206 | $put = input('put.'); 207 | $cname = Db::name('carouselrelease')->where('crid','<>',$put['crid'])->where('cname',$put['cname'])->find(); 208 | if($cname){ 209 | return get_status(1,'文件名重复',4006); 210 | } 211 | $put['screens'] = implode(',',$put['screens']); 212 | $put['updatetime'] = time(); 213 | $crid = ['crid'=>$put['crid']]; 214 | //删除无用字段 215 | unset($put['crid']); 216 | unset($put['checked']); 217 | $update = $this->carousel->updateCarousel($put,$crid); 218 | if($update){ 219 | return get_status(0,'修改成功'); 220 | }else{ 221 | return get_status(1,'修改失败',6004); 222 | } 223 | } 224 | //展示一个轮播详情 225 | public function getCarouselDetail() 226 | { 227 | $input = input('get.'); 228 | // dump($input);die; 229 | $get = ['crIdent'=>$input['crIdent']]; 230 | $data = $this->carousel->getCarouselList($get); 231 | 232 | $data['screens'] = explode(',',$data['screens']); 233 | return get_status(0,$data); 234 | } 235 | 236 | } -------------------------------------------------------------------------------- /application/index/controller/Datamap.php: -------------------------------------------------------------------------------- 1 | select(); 19 | if(empty($result)){ 20 | return get_status(1,'没有相应数据类型'); 21 | }else{ 22 | return get_status(0,$result); 23 | } 24 | 25 | } 26 | //根据数据类型查出来的已有数据 27 | public function mapdata() 28 | { 29 | $put = file_get_contents('php://input'); 30 | //$put = '{"dtid":1}'; 31 | $post = json_decode($put,1); 32 | $result = Db::name('datasource')->where('dtid',$post['dtid'])->field('daid,dataname')->select(); 33 | if(empty($result)){ 34 | return get_status(1,'没有相应数据'); 35 | }else{ 36 | return get_status(0,$result); 37 | } 38 | 39 | } 40 | //返回的数据 41 | public function returndata() 42 | { 43 | $put = file_get_contents('php://input'); 44 | //$put = '{"daid":85,"dtid":4}'; 45 | if(empty($put)){ 46 | return get_status(1,NULL); 47 | } 48 | $post = json_decode($put,1); 49 | 50 | if($post['dtid'] == 2){ 51 | $select = Db::name('datasource')->where('daid',$post['daid'])->field('uploadpath')->select(); 52 | $fileSrc = ROOT_PATH . 'public'.$select[0]['uploadpath']; 53 | //$fileSrc = ROOT_PATH . 'public/updirs/国电泰州#3至#4机组对比报表(1月).xlsx'; 54 | //使用phpexcel 55 | Vendor('Classes.PHPExcel'); 56 | $objPHPExcel = IOFactory::load($fileSrc); 57 | //生成返回数据 58 | $result = $objPHPExcel->getSheet(0)->toArray(); 59 | //dump($result); 60 | }elseif($post['dtid'] == 3){ 61 | $result = Db::name('datasource')->where('daid',$post['daid'])->field('uploadpath,autoupdate,request,cookie')->select(); 62 | }else{ 63 | $find = Db::name('datasource')->where('daid',$post['daid'])->field('source,returnsql')->find(); 64 | $select = Db::name('datasource')->where('daid',$find['source'])->field('daid,dataname,host,username,password,port,dbname,len')->select(); 65 | $this->host = $select[0]['host']; 66 | $this->name = $select[0]['username']; 67 | //$this->pwd = $select[0]['password']; 68 | $this->dbname = $select[0]['dbname']; 69 | $port = $select[0]['port']; 70 | $key = 'kwc.net'; 71 | $str = openssl_decrypt($select[0]['password'], 'aes-128-cbc',$key,2); 72 | $pwd = substr($str, 0,$select[0]['len']); 73 | $link = @mysqli_connect($this->host,$this->name,$pwd,$this->dbname,$port); 74 | if(!$link){ 75 | //不成功,返回报错信息 76 | return mysqli_connect_error(); 77 | }else{ 78 | $sqls = mysqli_query($link,$find['returnsql']); 79 | //dump($sqls); 80 | while($row = mysqli_fetch_array($sqls,MYSQLI_ASSOC)){ 81 | $data[] = $row; 82 | } 83 | 84 | 85 | } 86 | foreach ($data as $k => $v) { 87 | $keys = array_keys($v); 88 | $result[] = array_values($v); 89 | 90 | } 91 | array_unshift($result, $keys); 92 | //dump($result); 93 | // $data = json_decode($select[0]['returnjson'],1); 94 | // if (empty($data)) { 95 | // return get_status(1,'没有相应的数据'); 96 | // } 97 | // foreach ($data as $k => $v) { 98 | // $keys = array_keys($v); 99 | // $result[] = array_values($v); 100 | 101 | // } 102 | 103 | // array_unshift($result, $keys); 104 | //dump($result); 105 | 106 | 107 | } 108 | if(empty($result)){ 109 | return get_status(1,'没有相应的数据'); 110 | }else{ 111 | return get_status(0,$result); 112 | } 113 | 114 | } 115 | //存入发布数据 116 | public function publish() 117 | { 118 | $put = file_get_contents('php://input'); 119 | 120 | if(empty($put)){ 121 | return get_status(1,NULL); 122 | } 123 | $post = json_decode($put,1); 124 | $result = Db::name('publish')->insertGetId($post); 125 | 126 | if(empty($result)){ 127 | return get_status(1,NULL); 128 | }else{ 129 | return get_status(0,$result); 130 | } 131 | } 132 | 133 | //发布内容修改 134 | public function pupdate() 135 | { 136 | $put = file_get_contents('php://input'); 137 | if(empty($put)){ 138 | return get_status(1,NULL); 139 | } 140 | $post = json_decode($put,1); 141 | 142 | $result = Db::name('publish')->where('pid',$post['pid'])->update($post); 143 | //dump($result); 144 | if(empty($result)){ 145 | return get_status(1,NULL); 146 | }else{ 147 | return get_status(0,$result); 148 | } 149 | 150 | } 151 | //发布 152 | public function release() 153 | { 154 | $put = file_get_contents('php://input'); 155 | //$put = '{"is_pwd":0,"scid":12,"password":12345}'; 156 | if(empty($put)){ 157 | return get_status(1,NULL); 158 | } 159 | $post = json_decode($put,1); 160 | //$insert = Db::name('publish')->insert($post); 161 | $select = Db::name('publish')->where('pid',$post['pid'])->select(); 162 | //dump($select); 163 | if($select[0]['is_pwd'] == 1){ 164 | // if ($select[0]['password'] == $post['password']) { 165 | // $data = Db::name('screen')->where('id',$post['scid'])->field('data')->select(); 166 | // }else{ 167 | // return get_status(1,'数据库密码错误'); 168 | // } 169 | return get_status(2,NULL); 170 | }else{ 171 | $data = Db::name('screen')->where('id',$select[0]['scid'])->field('data')->find(); 172 | } 173 | if(empty($data)){ 174 | return get_status(1,NULL); 175 | }else{ 176 | return get_status(0,$data['data']); 177 | } 178 | 179 | } 180 | //发布密码 181 | public function pwd() 182 | { 183 | $put = file_get_contents('php://input'); 184 | //$put = '{"is_pwd":0,"scid":12,"password":12345}'; 185 | if(empty($put)){ 186 | return get_status(1,NULL); 187 | } 188 | $post = json_decode($put,1); 189 | $select = Db::name('publish')->where('pid',$post['pid'])->find(); 190 | if($select['password'] == $post['password']){ 191 | $data = Db::name('screen')->where('id',$select['scid'])->field('data')->find(); 192 | }else{ 193 | return get_status(2,'数据库密码错误'); 194 | } 195 | if(empty($data)){ 196 | return get_status(1,NULL); 197 | }else{ 198 | return get_status(0,$data['data']); 199 | } 200 | 201 | } 202 | 203 | } -------------------------------------------------------------------------------- /application/index/controller/Deviceinfo.php: -------------------------------------------------------------------------------- 1 | deviceInfoModel = Loader::model('Deviceinfo'); 19 | } 20 | 21 | /** 22 | * 产线和设备的信息 23 | */ 24 | public function deviceAll() 25 | { 26 | //所有场景 27 | $Scenes = [ 28 | [ 29 | "value" => 1, 30 | "name" => "场景1", 31 | ], 32 | [ 33 | "value" => 2, 34 | "name" => "场景2", 35 | ], 36 | ]; 37 | //设备 38 | $device = [ 39 | [ 40 | "value" => 1, 41 | "name" => "吹风机1", 42 | ], 43 | [ 44 | "value" => 2, 45 | "name" => "吹风机3", 46 | ], 47 | [ 48 | "value" => 3, 49 | "name" => "吹风机2", 50 | ],[ 51 | "value" => 4, 52 | "name" => "打包机器1", 53 | ], 54 | [ 55 | "value" => 5, 56 | "name" => "打包机器2", 57 | ], 58 | [ 59 | "value" => 5, 60 | "name" => "打包机器3", 61 | ]]; 62 | 63 | //生产线 64 | $ProductionLine = [ 65 | [ 66 | "value" => 1, 67 | "name" => "产线1", 68 | ], 69 | [ 70 | "value" => 2, 71 | "name" => "产线2", 72 | ], 73 | [ 74 | "value" => 3, 75 | "name" => "产线3", 76 | ], 77 | ]; 78 | 79 | return ['err' => 0 ,'data' =>['device' => $device , 'ProductionLine' => $ProductionLine , 'scenes'=> $Scenes]]; 80 | } 81 | 82 | /** 83 | * 场景与设备的绑定 84 | * scenes chainId modelID guid = 3DModelID 对应 场景ID 生产线ID , 设备ID , 模型GUID 85 | */ 86 | public function bindDevice() 87 | { 88 | //获取前端传参 89 | $input = input('post.'); 90 | //验证数据是否是需要的键 91 | $vail = valiKeys(["scenesId","chainId" ,"modelID" ,"guid" ] , $input); 92 | if($vail['err']) { 93 | return get_status(1,$vail['data'].'不能为空',333); 94 | } 95 | //场景的配置 96 | $config = [ 97 | 'guid' => $input['guid'], //模型GUID 3DModelID 98 | 'scenes' => $input['scenesId'], //场景ID 99 | 'modelid' => $input['modelID'], //设备ID 100 | 'chainid' => $input['chainId'], //生产线ID 101 | 102 | ]; 103 | //数据库参数 104 | $data = [ 105 | "scenes" => $input['scenesId'], 106 | 'scenes_config' => json_encode($config), 107 | ]; 108 | //查询数据库是否存在一样的数据 109 | $result = $this->deviceInfoModel->vailBindDevice($data); 110 | if($result) { 111 | return get_status(0,'模型已绑定'); 112 | } 113 | //将创建时间加入到data中 114 | $data['scenes_createtime'] = time(); 115 | //存入数据库 116 | $res = $this->deviceInfoModel->bindDevice($data); 117 | if($res) { 118 | return get_status(0,'模型绑定成功'); 119 | }else { 120 | return get_status(1,'模型绑定失败',1111); 121 | } 122 | } 123 | 124 | } -------------------------------------------------------------------------------- /application/index/controller/Drilldown.php: -------------------------------------------------------------------------------- 1 | where('charttype',$post['drillconfig']['comkey'])->value('data'); 24 | //更新时间 25 | Db::name('screen')->where('id',$post['screenid'])->update(['updatetime' => time()]); 26 | //将默认数据存入数据库中 27 | $input['tid'] = Db::name('screenchart')->insertGetId($data); 28 | //判断是否插入成功 29 | if(!$input['tid']) { 30 | return get_status(1,'添加图表失败',2004); 31 | } 32 | $input['screenid'] = $post['screenid']; 33 | //将图表类型取出 34 | $input['chartSourceType'] = $post['drillconfig']['dataOpt']['source']['type']; 35 | //序列化 36 | $input['dataOpt'] = json_encode($post['drillconfig']['dataOpt']); 37 | 38 | //序列化 39 | $input['chartData'] = json_encode($post['drillconfig']['chartData']); 40 | 41 | $id = [ 42 | //当前下钻图表id 43 | 'drillid' =>$input['tid'], 44 | //下钻图表父级id 45 | 'drillpid'=>$post['tid'], 46 | //下钻图表大屏id 47 | 'drillsid'=>$post['screenid'] 48 | ]; 49 | $post['drillconfig']['drilling'] = Array_merge($id,$post['drillconfig']['drilling']); 50 | 51 | //序列化 52 | if(isset($post['drillconfig']['drilling'])){ 53 | $input['drilling'] = json_encode($post['drillconfig']['drilling']); 54 | } 55 | $input['charttype'] = $post['drillconfig']['charttype']; 56 | $input['name'] = $post['drillconfig']['name']; 57 | $input['comtype'] = $post['drillconfig']['comtype']; 58 | $input['comkey'] = $post['drillconfig']['comkey']; 59 | $input['width'] = $post['drillconfig']['width']; 60 | $input['height'] = $post['drillconfig']['height']; 61 | // $input['drilllevel'] = $post['drilllevel']; 62 | $input['parenttid'] = $post['tid']; 63 | $input['resizable'] = 0; 64 | //将tconfig存入表中 65 | $tconfig = Db::name('screencharttconfig')->insert($input); 66 | 67 | if(!$tconfig){ 68 | return get_status(1,'添加图表失败',2004); 69 | } 70 | return get_status(0,['tid'=>$input['tid']]); 71 | } 72 | 73 | //修改下钻图表 74 | public function updateDrillchart() 75 | { 76 | $post = input('put.'); 77 | $post['drillconfig']['chartData'] = json_encode($post['drillconfig']['chartData']); 78 | $post['drillconfig']['drilling'] = json_encode($post['drillconfig']['drilling']); 79 | $post['drillconfig']['dataOpt'] = json_encode($post['drillconfig']['dataOpt']); 80 | unset($post['drillconfig']['tid']); 81 | $res = Db::name('screencharttconfig')->where(['tid'=>$post['tid']])->where($post['drillconfig'])->find(); 82 | if($res){ 83 | return get_status(0,'修改成功'); 84 | } 85 | $update = Db::name('screencharttconfig')->where(['tid'=>$post['tid']])->update($post['drillconfig']); 86 | $upScreen['updatetime'] = time(); 87 | $upScreenchart['updatetime'] = time(); 88 | //更新图表更新时间 89 | Db::name('screenchart')->where('tid',$post['tid'])->update($upScreenchart); 90 | //更新大屏更新时间 91 | Db::name('screen')->where('id',$post['screenid'])->update($upScreen); 92 | if($update){ 93 | return get_status(0,'修改成功'); 94 | }else{ 95 | return get_status(1,'图表更新失败',2034); 96 | 97 | } 98 | 99 | } 100 | 101 | //展示下钻图表 102 | public function queryDrillChart() 103 | { 104 | $get = input('get.'); 105 | $res = Db::name('screencharttconfig')->where(['parenttid'=>$get['tid']])->field('id,parenttid,screenid,parenttid,showBorder,chartSourceType,collection,ishide,islock,key,resizable,x,y,selectDaid',true)->find(); 106 | if(!$res){ 107 | return get_status(1,'查询失败',5005); 108 | } 109 | $res['chartData'] = json_decode($res['chartData'],true); 110 | $res['dataOpt'] = json_decode($res['dataOpt'],true); 111 | $res['drilling'] = json_decode($res['drilling'],true); 112 | return get_status(0,['data'=>$res]); 113 | 114 | } 115 | 116 | //删除下钻图表 117 | public function deldrill() 118 | { 119 | $post = input('post.'); 120 | //根据父级tid查找对应的下钻数据 121 | $tid = Db::name('screencharttconfig')->where(['parenttid'=>$post['chid']])->field('tid')->find(); 122 | if(empty($tid)){ 123 | return get_status(1,'暂无下钻图表',7010); 124 | } 125 | //根据下钻tid进行删除下钻图表 126 | $del = Db::name('screencharttconfig')->where($tid)->delete(); 127 | if(!$del){ 128 | return get_status(1,'图表数据删除失败',2005); 129 | } 130 | 131 | $delete = Db::name('screenchart')->where($tid)->delete(); 132 | if(!$delete) { 133 | return get_status(1,'图表删除失败',2005); 134 | }else { 135 | return get_status(0 ,'图表删除成功'); 136 | } 137 | } 138 | 139 | //下钻数据筛选 140 | public function choosedata() 141 | { 142 | $post = [ 143 | 'category'=>'北京', 144 | 145 | ]; 146 | $data = json_decode(file_get_contents('http://192.168.30.119:8099/bingtu/xiazuan/biaozhuduibibingtu.php'),true); 147 | 148 | $data = $data['北京']; 149 | return $data; 150 | 151 | 152 | } 153 | } -------------------------------------------------------------------------------- /application/index/controller/Icon.php: -------------------------------------------------------------------------------- 1 | file('image'); 17 | 18 | if(empty($file)){ 19 | return get_status(1,'图片为空',5002); 20 | } 21 | //定义上传路径 22 | $info = $file->validate(['size'=>1567118])->move(ROOT_PATH . 'public' . DS . 'uploads'. DS . 'Icon'. DS); 23 | //获取路径 24 | $imgSrcWin = str_replace('\\', '/', DS . 'uploads'. DS . 'Icon' . DS . $info->getSaveName()); 25 | 26 | //设置存储路径 27 | $data['iconpath'] = $imgSrcWin; 28 | //设置更改语句 29 | $data = Db::name('icon')->insert($data); 30 | //判断是否更改成功 31 | if($data == null){ 32 | return get_status(1,"上传失败",5004); 33 | }else{ 34 | //查询所有icon地址 35 | $iconlist = Db::name('icon')->select(); 36 | $datas['url'] = $imgSrcWin; 37 | return get_status(0,$datas); 38 | } 39 | } 40 | 41 | //查询icon 42 | public function iconList() 43 | { 44 | $input['pageSize'] = 20; 45 | $input = input('get.'); 46 | if(!isset($input['currentPage'])) { 47 | //查询所有icon地址 48 | $iconlist = Db::name('icon')->select(); 49 | }else { 50 | $iconlist = Db::name('icon')->page($input['currentPage'] ,$input['pageSize'])->select(); 51 | } 52 | $count = Db::name('icon')->count(); 53 | $arr = [ 54 | "list" => $iconlist, 55 | "total" => $count 56 | ]; 57 | return get_status(0,$arr); 58 | } 59 | 60 | //删除icon 61 | public function iconDel() 62 | { 63 | $input = input('delete.'); 64 | //判断input 65 | if(empty($input['upid'])) { 66 | return get_status(1,'参数不能为空' ,5002); 67 | } 68 | 69 | //删除指定icon 70 | $del = Db::name('icon')->delete($input['upid']); 71 | if($del) { 72 | return get_status(0,"删除成功"); 73 | }else { 74 | return get_status(1,"删除失败",5006); 75 | } 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /application/index/controller/Releasebinding.php: -------------------------------------------------------------------------------- 1 | publish = Loader::model('publish'); 14 | } 15 | 16 | /** 17 | * 查询虽有的发布链接以及ID 18 | */ 19 | public function getAllPublish() 20 | { 21 | //获取所有的发布链接及ID 22 | $result = $this->publish->getAllPublish(); 23 | if($result) { 24 | return get_status(0,$result); 25 | }else { 26 | return get_status(1,'查询失败',1111); 27 | } 28 | } 29 | 30 | /** 31 | * 绑定爱创的用户和发布的连接 user 用户标识 linkID 链接 32 | * {"user" : ["token1","token2","token3"],"linkIDs" : 21} 33 | */ 34 | public function BindUserA() 35 | { 36 | $input = input('post.'); 37 | //验证键 38 | $vali = valiKeys(['user','linkID'] , $input); 39 | if($vali['err']) { 40 | return get_status(1,$vali['data'].'键未设置',000); 41 | } 42 | //将user装换为字符串 43 | $input['user'] = implode( ',' , $input['user']); 44 | //验证相同 45 | $result = $this->publish->valiSameBindUser($input); 46 | if($result) { 47 | return get_status(0,'绑定成功'); 48 | } 49 | //将数据用户绑定到数据库 50 | $result = $this->publish->BindUser($input); 51 | //判断绑定是否成功 52 | if($result) { 53 | return get_status(0,'绑定成功'); 54 | }else { 55 | return get_status(1,'绑定失败'); 56 | } 57 | } 58 | 59 | /** 60 | * 绑定爱创的用户和发布的连接 user 用户标识 linkID 链接 61 | * {"user" :"token1","linkID" : 21} 62 | */ 63 | public function BindUsersS() 64 | { 65 | $input = input('post.'); 66 | //验证键 67 | $vali = valiKeys(['user','linkID'] , $input); 68 | if($vali['err']) { 69 | return get_status(1,$vali['data'].'键未设置',000); 70 | } 71 | //获取当前发布链接的ACID 72 | 73 | //将当前ID拼接入原来ACID 74 | 75 | //验证相同 76 | $result = $this->publish->valiSameBindUser($input); 77 | if($result) { 78 | return get_status(0,'绑定成功'); 79 | } 80 | //将数据用户绑定到数据库 81 | $result = $this->publish->BindUser($input); 82 | //判断绑定是否成功 83 | if($result) { 84 | return get_status(0,'绑定成功'); 85 | }else { 86 | return get_status(1,'绑定失败'); 87 | } 88 | } 89 | 90 | 91 | } -------------------------------------------------------------------------------- /application/index/controller/Rep.php: -------------------------------------------------------------------------------- 1 | "biaozhuduibibingtu", 13 | "pie2" => "daitubingtu", 14 | "pie3" => "danzhibaifenbibingtu", 15 | "pie4" => "duoweidubingtu", 16 | "pie5" => "jibenbingtu", 17 | "pie6" => "huanshanbingtu", 18 | "pie7" => "lunbobingtu", 19 | "pie8" => "mubiaozhanbibingtu", 20 | "pie9" => "zhibiaoduibibingtu", 21 | "pie10" => "zhibiaozhanbibingtu", 22 | "pie11" => "huanzhuangfaguangzhanbitu", 23 | "line1" => "daitubingtu", 24 | "line2" => "quyutu", 25 | "line3" => "quyufanpaiqi", 26 | "line4" => "shuangzhouzhexiantu", 27 | "line5" => "3dzhexiantu", 28 | "line6" => "xuxianzhexiantu", 29 | "bar1" => "banmazhutu", 30 | "bar2" => "chuizhijibenzhutu", 31 | "bar3" => "chuizhijiaonanzhutu", 32 | "bar4" => "fenzuzhutu", 33 | "bar5" => "huxingzhutu", 34 | "bar6" => "jibenzhutu", 35 | "bar7" => "shuipingjibenzhutu", 36 | "bar8" => "shuipingjiaonanzhutu", 37 | "bar9" => "tixingzhutu", 38 | "bar10" => "zhexianzhutu", 39 | "bar11" => "danzhouzhexianzhutu", 40 | "bar13" => "shuangxianghengxiangzhuzhuangtu", 41 | "bar14" => "fenzhujianbianzhuzhuangtu", 42 | "bar12" => "3dzhuzhuangtu", 43 | "scatter1" => "qipaotu", 44 | "scatter2" => "sandiantu", 45 | "scatter3" => "sandianzhexiantu", 46 | "scatter4" => "qipaozhexiantu", 47 | "graph" => "guanxiwangluo", 48 | "radar" => "leidatu", 49 | "gauge" => "yibiaopan", 50 | "wordCloud" => "ciyun", 51 | "funnel" => "loudoutu", 52 | "liquidFill" => "shuiqiutu", 53 | "gridheatmap" => "relitu", 54 | "boxplot" => "xiangxingtu", 55 | "hexian" => "hexiantu", 56 | "sunburst" => "xuritu", 57 | "rectangletree" => "juxingshutu", 58 | "sankey" => "sangjitu", 59 | "chinamap" => "zhongguoditu", 60 | "chinamap3d" => "3dzhongguoditu", 61 | "worldMap" => "shijieditu", 62 | "worldMap3d" => "3dshijieditu", 63 | "globechart" => "diqiuyi", 64 | "gismap" => "gismap", 65 | "lunbotable" => "lunbobiaoge", 66 | "txt" => "biaoti", 67 | "time" => "shijian", 68 | "web" => "wangye", 69 | "carousel" => "lunbotu", 70 | "richtxt" => "fuwenben", 71 | "video" => "shipinbofangqi", 72 | "counting" => "jishuban", 73 | "counting2" => "jishuban2", 74 | "txts" => "duoxingwenben", 75 | "diversion" => "paomadeng", 76 | "link" => "chaolianjie", 77 | "progress" => "jindutiao", 78 | "table" => "biaoge", 79 | "circleProgress" => "huanxingjindutiao", 80 | "image" => "tupian", 81 | "icon" => "icon", 82 | "border" => "biankuang", 83 | "linellae" => "xiantiao", 84 | "lines" => "zhixian", 85 | ]; 86 | 87 | public function __construct() 88 | { 89 | $this->screenchartModel = Loader::model("Screenchart"); 90 | } 91 | 92 | public function start() 93 | { 94 | //获取总数 95 | $num = $this->screenchartModel->getCount(); 96 | //分页查询 97 | $p = 10; //每页数 98 | $maxPage = ceil($num / $p);//总页数 99 | //循环取值 100 | for ($i = 1 ; $i <= $maxPage ; $i++) { 101 | //每次10条处理 102 | $this->process($this->screenchartModel->pageSelect($i , $p)); 103 | } 104 | } 105 | 106 | public function process($arr) 107 | { 108 | //遍历数组 109 | foreach ($arr as $value){ 110 | //查找charttype字符串 111 | $charttypeH = substr($value['tconfig'] , strpos( $value['tconfig'], "charttype" )); //截取出现位置以后的 112 | $charttypestring = substr($charttypeH ,0 ,strpos( $charttypeH, '","' )+1); //截取出现未知以前的 113 | //获取charttype图表类型 114 | $charttypeArr = explode(":" , $charttypestring); //将字符串分割成数组 115 | $charttype = str_replace('"' , "" , $charttypeArr[1]); // 去数组后一个 图表类型 116 | if(isset($this->oldNew[$charttype])) { //判断是否在数组中 117 | $charttypeValue = $this->oldNew[$charttype]; //查询新类型 118 | $string = str_replace( $charttype ,$charttypeValue, $charttypestring); //替换 119 | $json = str_replace($charttypestring ,$string , $value); //替换到json 120 | $data[] = ["tconfig" => $json]; //加入到数组 121 | //修改图表 122 | $this->screenchartModel->updateScreenChart($value['tid'] , $json); 123 | } 124 | } 125 | } 126 | } -------------------------------------------------------------------------------- /application/index/controller/Socket.php: -------------------------------------------------------------------------------- 1 | ws = new \swoole_websocket_server("0.0.0.0", 9508); 19 | 20 | //初始化socket设置 21 | $this->ws->set([ 22 | 'heartbeat_check_interval' => 20, 23 | 'heartbeat_idle_time' => 45, 24 | ]); 25 | 26 | //初始化缓存 27 | Cache::rm('data'); 28 | } 29 | 30 | //socket主程序 31 | public function socket() 32 | { 33 | //open时处理 34 | $this->socketOpen(); 35 | 36 | //send时处理 37 | $this->socketSend(); 38 | 39 | //关闭连接时处理 40 | $this->socketClose(); 41 | 42 | //回调处理 43 | $this->socketRequest(); 44 | 45 | //开始服务 46 | $this->ws->start(); 47 | 48 | } 49 | 50 | //send时处理 51 | protected function socketOpen() 52 | { 53 | $this->ws->on('open' , function ( \swoole_websocket_server $ws, $request){ 54 | var_dump("客户端-{$request->fd}连接"); 55 | }); 56 | } 57 | 58 | //send时处理 59 | protected function socketSend() 60 | { 61 | $this->ws->on('message', function( \swoole_websocket_server $ws , $request ) { 62 | //接收数据 63 | $json = $request->data; 64 | //检查心跳 65 | if($json == "Are you still alive") { 66 | $ws->push($request->fd, "I am still alive"); 67 | }else { 68 | $type = json_decode($json,1); 69 | if(isset($type['scenesId'])) { 70 | $id = $type['scenesId']; 71 | //存入缓存 72 | $this->saveCache($request->fd, $id); 73 | } 74 | 75 | 76 | } 77 | }); 78 | } 79 | 80 | //关闭是处理 81 | protected function socketClose() 82 | { 83 | $this->ws->on('close',function(\swoole_websocket_server $ws,$request){ 84 | //删除缓存 85 | $this->deleteCache($request); 86 | var_dump("客户端-{$request}断开连接"); 87 | }); 88 | } 89 | 90 | //回调处理 91 | protected function socketRequest() 92 | { 93 | $this->ws->on('Request', function ($req, $respone) { 94 | //接收数据 95 | $data = $req->rawContent(); 96 | $data = json_decode($data,1); 97 | // dump($data); 98 | //写入日志 99 | Log::write($data,'notice'); 100 | // //获取当前在线用户 101 | $fileArr = json_decode(Cache::get('data'),1); 102 | //写入日志 103 | Log::write(json_encode($fileArr),'notice'); 104 | // //判断$fileArr是否为空 105 | if(!empty($fileArr)) { 106 | foreach ($fileArr as $value) { 107 | //遍历改fd的数据 108 | foreach ($data[$value['id']] as $k => $v) { 109 | if(!is_array($v)) { 110 | //将数据保持为数组状态 111 | $data[$value['id']][$k] = json_decode($v,1); 112 | } 113 | } 114 | //推送至客户端保持数据为json 115 | $this->ws->push($value['fd'], json_encode($data[$value['id']])); 116 | } 117 | } 118 | $respone->end("success"); 119 | }); 120 | } 121 | 122 | //存入缓存 123 | protected function saveCache($fd , $json) 124 | { 125 | //查看缓存 126 | $cache = Cache::get('data'); 127 | if($cache != '') { 128 | //将json转换为数组 129 | $cacheArr = json_decode($cache,1); 130 | $data = ['fd' => $fd , 'id' => $json]; 131 | //将本次连接记录 132 | $cacheArr[$fd] = $data; 133 | //数组转换为json方便存储 134 | $json = json_encode($cacheArr); 135 | }else { 136 | $cacheArr[$fd] = ['fd' => $fd , 'id' => $json]; 137 | $json = json_encode($cacheArr); 138 | } 139 | //将json存储缓存 140 | Cache::set('data', $json); 141 | } 142 | 143 | //删除缓存 144 | protected function deleteCache($fd) 145 | { 146 | //查看缓存 147 | $cache = Cache::get('data'); 148 | if($cache) { 149 | //将json转换为数组 150 | $cacheArr = json_decode($cache,1); 151 | //删除对应数据 152 | unset($cacheArr[$fd]); 153 | //判断是否还有连接 154 | if(empty($cacheArr)) { 155 | //没有连接初始化缓存 156 | Cache::rm('data'); 157 | }else { 158 | //数组转换为json方便存储 159 | $json = json_encode($cacheArr); 160 | //将剩余json化存储缓存 161 | Cache::set('data', $json); 162 | } 163 | }else { 164 | return; 165 | } 166 | } 167 | 168 | 169 | } -------------------------------------------------------------------------------- /application/index/controller/Socketscreen.php: -------------------------------------------------------------------------------- 1 | ws) { 18 | //实例化swoole对象 19 | $this->ws = new \swoole_websocket_server("0.0.0.0", 9577); 20 | //初始化缓存 21 | Cache::rm('screen'); 22 | } 23 | } 24 | 25 | //socket主程序 26 | public function socket() 27 | { 28 | //open时处理 29 | $this->socketOpen(); 30 | 31 | //send时处理 32 | $this->socketSend(); 33 | 34 | //关闭连接时处理 35 | $this->socketClose(); 36 | 37 | //回调处理 38 | $this->socketRequest(); 39 | 40 | //开始服务 41 | $this->ws->start(); 42 | 43 | } 44 | 45 | //send时处理 46 | protected function socketOpen() 47 | { 48 | $this->ws->on('open' , function ( \swoole_websocket_server $ws, $request){ 49 | var_dump("客户端-{$request->fd}连接"); 50 | }); 51 | } 52 | 53 | //send时处理 54 | protected function socketSend() 55 | { 56 | $this->ws->on('message', function( \swoole_websocket_server $ws , $request ) { 57 | //接收数据 58 | $json = $request->data; 59 | if($json == "heartbeat") { 60 | $ws->push($request->fd, "I am still alive"); 61 | }else { 62 | $json = json_decode($json,1); 63 | //存入缓存 64 | $this->saveCache($request->fd, $json['sid']); 65 | } 66 | }); 67 | } 68 | 69 | //关闭是处理 70 | protected function socketClose() 71 | { 72 | $this->ws->on('close',function(\swoole_websocket_server $ws,$request){ 73 | //删除缓存 74 | $this->deleteCache($request); 75 | var_dump("客户端-{$request}断开连接"); 76 | }); 77 | } 78 | 79 | //回调处理 80 | protected function socketRequest() 81 | { 82 | $this->ws->on('Request', function ($req, $respone) { 83 | //接收数据 84 | $data = $req->rawContent(); 85 | //写入日志 86 | Log::write($data,'notice'); 87 | //反序列化 88 | $data = json_decode($data,1); 89 | dump($data); 90 | // //获取当前在线用户 91 | $fileArr = json_decode(Cache::get('screen'),1); 92 | //写入日志 93 | Log::write(json_encode($fileArr),'notice'); 94 | dump($fileArr); 95 | // //判断$fileArr是否为空 96 | if(!empty($fileArr)) { 97 | foreach ($fileArr as $value) { 98 | $this->ws->push($value['fd'], $data[$value['sid']]); 99 | // $this->ws->push(1, "大屏"); 100 | } 101 | } 102 | $respone->end("success"); 103 | 104 | }); 105 | } 106 | 107 | //存入缓存 108 | protected function saveCache($fd , $sid) 109 | { 110 | //查看缓存 111 | $cache = Cache::get('screen'); 112 | if($cache != '') { 113 | //将json转换为数组 114 | $cacheArr = json_decode($cache,1); 115 | $data = ['fd' => $fd , 'sid' => $sid]; 116 | //将本次连接记录 117 | $cacheArr[$fd] = $data; 118 | //数组转换为json方便存储 119 | $json = json_encode($cacheArr); 120 | }else { 121 | $cacheArr[$fd] = ['fd' => $fd , 'sid' => $sid]; 122 | $json = json_encode($cacheArr); 123 | } 124 | //将json存储缓存 125 | Cache::set('screen', $json); 126 | } 127 | 128 | //删除缓存 129 | protected function deleteCache($fd) 130 | { 131 | //查看缓存 132 | $cache = Cache::get('screen'); 133 | if($cache) { 134 | //将json转换为数组 135 | $cacheArr = json_decode($cache,1); 136 | //删除对应数据 137 | unset($cacheArr[$fd]); 138 | //判断是否还有连接 139 | if(empty($cacheArr)) { 140 | //没有连接初始化缓存 141 | Cache::rm('screen'); 142 | }else { 143 | //数组转换为json方便存储 144 | $json = json_encode($cacheArr); 145 | //将剩余json化存储缓存 146 | Cache::set('screen', $json); 147 | } 148 | }else { 149 | return; 150 | } 151 | } 152 | 153 | 154 | } -------------------------------------------------------------------------------- /application/index/controller/System.php: -------------------------------------------------------------------------------- 1 | where('username',$username)->find(); 29 | 30 | //判断原始密码是否正确 31 | if($oldPassword != $passData['password']){ 32 | get_Log($username,'修改密码_旧密码错误','失败'); 33 | $data = get_status(1,2400,NULL); 34 | return $data; 35 | } 36 | //判断新密码是否与旧密码相同 37 | if($newPassword === $passData['password']){ 38 | get_Log($username,'修改密码_新旧密码相同','失败'); 39 | $data = get_status(1,2401,NULL); 40 | return $data; 41 | } 42 | //执行更新语句 43 | $udata['password'] = $newPassword; 44 | 45 | $change = Db::name('user')->where('username',$username)->update($udata); 46 | 47 | //判断是否更新成功 48 | if(empty($change)){ 49 | get_Log($username,'修改密码_更改密码执行sql','失败'); 50 | $data = get_status(1,NULL,NULL); 51 | return $data; 52 | }else{ 53 | get_Log($username,'修改密码_更改密码','成功'); 54 | $data = get_status(0,NULL,NULL); 55 | return $data; 56 | } 57 | 58 | } 59 | 60 | //修改用户名 changeUsername 61 | public function changeUsername() 62 | { 63 | //post接收来的数据 64 | $dataPost = file_get_contents('php://input'); 65 | $type =json_decode($dataPost,1); 66 | 67 | 68 | $username = $type['username']; 69 | $newUsername = $type['newusername']; 70 | $Password = md5($type['password']); 71 | if($username === $newUsername){ 72 | return get_status(1,NULL,NULL); 73 | } 74 | $data = Db::name('user')->where('username',$username)->find(); 75 | 76 | if($Password != $data['password']){ 77 | return get_status(1,NULL,NULL); 78 | } 79 | 80 | $return = Db::name('user')->where('username',$username)->update(['username'=>$newUsername]); 81 | 82 | 83 | 84 | if(empty($change)){ 85 | return get_status(0,NULL,NULL); 86 | }else{ 87 | return get_status(1,NULL,NULL); 88 | } 89 | 90 | } 91 | //服务器地址修改 92 | public function updateIp() 93 | { 94 | //post接收来的数据 95 | $dataPost = file_get_contents('php://input'); 96 | $type =json_decode($dataPost,1); 97 | 98 | $ip = $typr['ip']; 99 | 100 | $update = Db::name('system')->where('id','1')->update($ip); 101 | return $data['err'] = '0'; 102 | } 103 | 104 | //获取用户列表 105 | public function getUser() 106 | { 107 | $data = Db::name('user')->field('username,power')->select(); 108 | 109 | return get_status(0,0,$data); 110 | 111 | } 112 | //删除用户 113 | public function deleteUser() 114 | { 115 | //接收post来的数据 116 | $dataPost = file_get_contents('php://input'); 117 | //POST来的数据转换成json格式 118 | $post =json_decode($dataPost,1); 119 | //获取用户名 120 | $user = $post['user']; 121 | //获取删除用户名 122 | $username = $post['username']; 123 | //获取超级管理员密码 124 | $password = md5($post['password']); 125 | //判断操作用户是否为超级管理员 126 | if($user != 'admin'){ 127 | return get_status(1,0,NULL); 128 | } 129 | //验证超级管理员密码 130 | $Dbpassword = Db::name('user')->where('username', $user)->field('password')->find(); 131 | if($Dbpassword != $password){ 132 | return get_status(1,0,NULL); 133 | } 134 | 135 | //执行删除 136 | $delete = Db::name('user')->where('username',$username)->delete(); 137 | $DbUser = Db::name('user')->field('username')->select(); 138 | 139 | //返回删除后user列表 140 | return get_status(0,0,$DbUser); 141 | } 142 | 143 | //注册用户 144 | public function register() 145 | { 146 | //接收post来的数据 147 | $dataPost = file_get_contents('php://input'); 148 | //POST来的数据转换成json格式 149 | $post =json_decode($dataPost,1); 150 | //获取注册用户名 151 | $username = $post['username']; 152 | //获取注册用户的密码 153 | $password = md5($post['password']); 154 | //获取注册用户的重复密码 155 | $repassword = md5($post['repassword']); 156 | //获取注册用户的权限 157 | $power = $post['power']; 158 | //获取操作用户的用户名 159 | $user = $post['user']; 160 | //获取操作用户的密码 161 | $pass = $post['pass']; 162 | //验证操作用户身份 163 | if($user != 'admin'){ 164 | return get_status(1,0,NULL); 165 | } 166 | //验证注册用户的两次密码是否相同 167 | if($password != $repassword){ 168 | return get_status(1,0,NULL); 169 | } 170 | //验证用户名是否存在 171 | $Dbusername = Db::name('user')->where('username',$username)->find(); 172 | if(!empty($Dnusername)){ 173 | return get_status(1,0,NULL); 174 | } 175 | //执行添加语句 176 | $insertData['username'] = $username; 177 | $insertData['password'] = $password; 178 | $insertData['power'] = $power; 179 | $insert = Db::name('user')->insert($insertData); 180 | //查询数据表 181 | $data = Db::name('user')->select(); 182 | 183 | //返回数据列表 184 | return get_status(0,0,$data); 185 | 186 | } 187 | //获取日志 188 | public function getLog() 189 | { 190 | $data = Db::name('log')->select(); 191 | 192 | return get_status(0,0,$data); 193 | } 194 | //获取权限列表 195 | public function power() 196 | { 197 | $data = Db::name('power')->select(); 198 | 199 | return get_status(0,0,$data); 200 | 201 | } 202 | 203 | 204 | 205 | } 206 | -------------------------------------------------------------------------------- /application/index/controller/Test.php: -------------------------------------------------------------------------------- 1 | '\think\oracle\Connection', 20 | // 服务器地址 21 | 'hostname' => '192.168.30.189', 22 | // 数据库名 23 | 'database' => 'sdata', 24 | //用户名 25 | 'username' => 'root', 26 | // 密码 27 | 'password' => 'liwenkaihaha', 28 | // 端口 29 | 'hostport' => '', 30 | // 连接dsn 31 | 'dsn' => '', 32 | // 数据库连接参数 33 | 'params' => [], 34 | // 数据库编码默认采用utf8 35 | 'charset' => 'utf8', 36 | // 数据库表前缀 37 | 'prefix' => 'sdata_', 38 | // 数据库调试模式 39 | 'debug' => true, 40 | // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) 41 | 'deploy' => 0, 42 | // 数据库读写是否分离 主从式有效 43 | 'rw_separate' => false, 44 | // 读写分离后 主服务器数量 45 | 'master_num' => 1, 46 | // 指定从服务器序号 47 | 'slave_no' => '', 48 | // 是否严格检查字段是否存在 49 | 'fields_strict' => true, 50 | // 数据集返回类型 51 | 'resultset_type' => 'array', 52 | // 自动写入时间戳字段 53 | 'auto_timestamp' => false, 54 | // 时间字段取出后的默认时间格式 55 | 'datetime_format' => 'Y-m-d H:i:s', 56 | // 是否需要进行SQL性能分析 57 | 'sql_explain' => false, 58 | ]; 59 | //$db = new \think\db\connector\Oracle; 60 | $db = Db::connect($database)->name('users')->select(); 61 | dump($db); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /application/index/controller/Websocket.php: -------------------------------------------------------------------------------- 1 | screen)) { 19 | $this->screen = new Screen(); 20 | } 21 | } 22 | //主程序 23 | public function index() 24 | { 25 | $input = input('get.'); 26 | //判断数据是否接收成功 27 | if(!$input) { 28 | return get_status(1,'数据接收失败',000); 29 | } 30 | $id = intval($input['id']); 31 | //通过ID找到大屏对应的图表 32 | // $charts = Db::name('screenchart')->where('screenid', $id)->field('tid,tconfig')->select(); 33 | $charts = Db::name('screenchart')->field('screencharttconfig.dataOpt,screenchart.tid')->alias('screenchart')->join('screencharttconfig','screenchart.tid=screencharttconfig.tid')->where('screenchart.screenid', $id)->select(); 34 | //判断charts是否为空 35 | if(empty($charts)) { 36 | return get_status(0,[]); 37 | } 38 | //将自动刷新的图表ID提取出来 39 | $autoChart = $this->getAutoChart($charts); 40 | //判断autoChartID是否为空 41 | if(empty($autoChart)) { 42 | return get_status(0,[]); 43 | } 44 | //处理自动刷新获取返回值 45 | $autuResult = $this->autoChart($autoChart); 46 | //直接返回数据无需判断 47 | return get_status(0,$autuResult); 48 | } 49 | 50 | /** 51 | * 提取自动刷新图表 52 | */ 53 | protected function getAutoChart( array $charts) 54 | { 55 | //声明自动刷新图表ID集合数组 56 | $autu = []; 57 | $i = 0; 58 | //遍历图表数组 59 | foreach($charts as $key => $value) { 60 | //反序列化config 61 | // $config = json_decode($value['tconfig'],1); 62 | $value['dataOpt'] = json_decode($value['dataOpt'],1); 63 | if( isset($value['dataOpt']['source']['type']) && isset($value['dataOpt']['autoUpdate'])) { 64 | //拿到是否自动刷新字段 65 | $isAotu = $value['dataOpt']['autoUpdate']; 66 | //数据源类型部位websocket 67 | $type = $value['dataOpt']['source']['type']; 68 | //判断是否自动刷新 69 | if($isAotu && strtolower($type != 'websocket')) { 70 | //将自动刷新图表ID传入 71 | $autu[$i]['tid'] = $value['tid']; 72 | //自动刷新开始时间 73 | $autu[$i]['autoupdatetime'] = $value['dataOpt']['clockStart']; 74 | //自动刷新秒数 75 | $autu[$i]['timeClock'] = $value['dataOpt']['timeClock']; 76 | $i++; 77 | } 78 | } 79 | } 80 | //返回自动刷新图表ID集合 81 | return $autu; 82 | } 83 | 84 | /** 85 | * 处理自动刷新 86 | * */ 87 | protected function autoChart( array $autoChart) 88 | { 89 | //声明自动刷新图表数据 90 | $autuChartData = []; 91 | //遍历自动刷新数组 92 | foreach($autoChart as $key => $value) { 93 | //计算出当前时间与自动刷新开始时间差 94 | $chartDiff = intval(time() - $value['autoupdatetime']); 95 | //判断是否符合自动刷新时间 96 | if ($chartDiff % $value['timeClock'] == 0) { 97 | //执行图表数据获取方法 98 | $result = $this->screen->getAllChart(['chartid' => $value['tid']]); 99 | //提取返回数组中的图表名称及相对应的value 100 | foreach ($result['data'] as $k => $v) { 101 | //判断是否有数据 102 | if(!empty($v)) { 103 | //获取图表数据 104 | $autuChartData[$k] = $v; 105 | } 106 | 107 | } 108 | } 109 | } 110 | //返回图表数据集合 111 | return $autuChartData; 112 | } 113 | 114 | 115 | } -------------------------------------------------------------------------------- /application/index/model/Carousel.php: -------------------------------------------------------------------------------- 1 | table)->insertGetId($data); 43 | } 44 | 45 | //修改信息 46 | public function updateCarousel($data , $where) 47 | { 48 | if(empty($data['animation'])){ 49 | return false; 50 | } 51 | if(empty($data['cname'])){ 52 | return false; 53 | } 54 | if(empty($data['controlPos'])){ 55 | return false; 56 | } 57 | if(empty($data['crIdent'])){ 58 | return false; 59 | } 60 | if(empty($data['crLink'])){ 61 | return false; 62 | } 63 | if(empty($data['createtime'])){ 64 | return false; 65 | } 66 | if(empty($data['remarks'])){ 67 | return false; 68 | } 69 | if(empty($data['screens'])){ 70 | return false; 71 | } 72 | if(empty($data['time'])){ 73 | return false; 74 | } 75 | if(empty($data['updatetime'])){ 76 | return false; 77 | } 78 | return Db::name($this->table)->where($where)->update($data); 79 | } 80 | 81 | //通过条件获取详情信息列表 82 | public function getCarouselList($where) 83 | { 84 | return Db::name($this->table)->where($where)->find(); 85 | } 86 | 87 | //获取全部详情信息列表 88 | public function getCarouselListAll($where = null,$currentPage = null,$pageSize = null,$order = null) 89 | { 90 | return Db::name($this->table)->order($order,'desc')->where('cname','like','%'.$where.'%')->page($currentPage,$pageSize)->select(); 91 | } 92 | 93 | public function deleteCarousel($where) 94 | { 95 | return Db::name($this->table)->where($where)->delete(); 96 | 97 | } 98 | } -------------------------------------------------------------------------------- /application/index/model/Deviceinfo.php: -------------------------------------------------------------------------------- 1 | table)->where($data)->find(); 22 | } 23 | 24 | /** 25 | * 将绑定数据信息插入数据库 26 | * @param $data 27 | * @return bool 28 | */ 29 | public function bindDevice($data) 30 | { 31 | //绑定信息存入数据库 32 | return Db::name($this->table)->where("scenes" , $data['scenes'])->insert($data); 33 | } 34 | 35 | 36 | 37 | 38 | } -------------------------------------------------------------------------------- /application/index/model/Gisdata.php: -------------------------------------------------------------------------------- 1 | table)->where('gistype' , 'in' , $where)->column('gisdata','gistype'); 19 | } 20 | } -------------------------------------------------------------------------------- /application/index/model/My.php: -------------------------------------------------------------------------------- 1 | table)->field('pid,sname,link')->select(); 24 | } 25 | 26 | /**将发布绑定用于用户验证 27 | * @param $data 28 | * @return bool 29 | * @throws \think\Exception 30 | * @throws \think\exception\PDOException 31 | */ 32 | public function BindUser($data) 33 | { 34 | return Db::name($this->table)->where('pid',$data['linkID'])->update(['acid' => $data['user']]); 35 | } 36 | 37 | /**验证相同 38 | * @param $data 39 | * @return bool 40 | * @throws \think\db\exception\DataNotFoundException 41 | * @throws \think\db\exception\ModelNotFoundException 42 | * @throws \think\exception\DbException 43 | */ 44 | public function valiSameBindUser($data) 45 | { 46 | return Db::name($this->table)->where(['acid' => $data['user'] , 'pid' => $data['linkID']])->find(); 47 | } 48 | 49 | public function getWhereList($where ,$field = "*") 50 | { 51 | return Db::name($this->table)->where($where)->field($field)->select(); 52 | } 53 | } -------------------------------------------------------------------------------- /application/index/model/Screen.php: -------------------------------------------------------------------------------- 1 | table)->where("id" , $id)->field("data,name,lock,screentype,ratio,pixel")->find(); 23 | } 24 | 25 | //查询模板列表 26 | public function templateSummary($where,$order,$currentPage,$pageSize,$like) 27 | { 28 | //查询自定义模板 29 | // if($where['tempcate'] == 1){ 30 | // $data = Screen::where($where)-> 31 | // where('name','like','%'.$like.'%')-> 32 | // order($order,'DESC')-> 33 | // page($currentPage,$pageSize)-> 34 | // field('id,name,screenid,imgdata,publishuser,share')-> 35 | // select(); 36 | // $total = Screen::where($where)->where('name','like','%'.$like.'%')->count(); 37 | 38 | // }else{ 39 | // //查询通用模板列表 40 | // $data = Screen::where('tempcate=1 AND share=1')-> 41 | // whereOr('tempcate',0)-> 42 | // where('screentype',2)-> 43 | // where('name','like','%'.$like.'%')-> 44 | // order($order,'DESC')-> 45 | // page($currentPage,$pageSize)-> 46 | // field('id,name,screenid,imgdata,publishuser,share')-> 47 | // select(); 48 | // //查询列表总数 49 | // $total = Screen::where('tempcate=1 AND share=1')->whereOr('tempcate',0)->where('screentype',2)->where('name','like','%'.$like.'%')->count(); 50 | // } 51 | $data = Screen::where($where)-> 52 | where('name','like','%'.$like.'%')-> 53 | order($order,'DESC')-> 54 | page($currentPage,$pageSize)-> 55 | field('id,name,screen_sid,ratio,pixel,imgdata,publishuser,share')-> 56 | select(); 57 | $total = Screen::where($where)->where('name','like','%'.$like.'%')->count(); 58 | 59 | $data = ['list'=>$data,'total'=>$total]; 60 | return $data; 61 | } 62 | 63 | //对默认模板进行软删除 64 | public function softdel($id) 65 | { 66 | //进行软删除 67 | $del = Screen::destroy($id); 68 | if($del){ 69 | return $del; 70 | } 71 | } 72 | 73 | //恢复默认模版 74 | public function recsof() 75 | { 76 | $id = []; 77 | //查询软删除的模版 78 | $del = Screen::onlyTrashed()->select(); 79 | if(empty($del)){ 80 | return true; 81 | } 82 | foreach($del as $k=>$v){ 83 | $id[] = $v['id']; 84 | } 85 | foreach($id as $key=>$val){ 86 | //查询要恢复的模版 87 | $del = Screen::onlyTrashed()->find($val); 88 | //进行恢复 89 | $del->restore(); 90 | } 91 | return true; 92 | 93 | } 94 | } 95 | 96 | -------------------------------------------------------------------------------- /application/index/model/Screenchart.php: -------------------------------------------------------------------------------- 1 | table)->select(); 20 | } 21 | 22 | //获取总数 23 | public function getCount() 24 | { 25 | return Db::name($this->table)->count(); 26 | } 27 | 28 | //分页查询 29 | 30 | public function pageSelect( $p , $pageNum) 31 | { 32 | return Db::name($this->table)->field("tid,tconfig")->page($p,$pageNum)->select(); 33 | } 34 | 35 | public function updateScreenChart($id, $data) 36 | { 37 | return Db::name($this->table)->where("tid",$id)->update($data); 38 | } 39 | 40 | //获取指定大屏下的所有图表 41 | public function getScreenList($id) 42 | { 43 | return Db::name($this->table)->where("screenid" , $id)->field("tid,screenid,talias,tname,tdata,islock, 44 | link,collection,ishide,autoupdatetime,daid")->select(); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /application/index/model/Unity.php: -------------------------------------------------------------------------------- 1 | table)->select(); 25 | } 26 | 27 | public function deleteScenes($id) 28 | { 29 | return Db::name($this->table)->where('jsonid' , $id)->delete(); 30 | } 31 | 32 | /** 33 | * 查询所有的设备 34 | */ 35 | public function getAllDevice() 36 | { 37 | return Db::name($this->table)->select(); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /application/index/model/User.php: -------------------------------------------------------------------------------- 1 | select(); 13 | } 14 | 15 | //获取所有的权限 16 | public function permission() 17 | { 18 | return Db::name('permission')->select(); 19 | } 20 | 21 | //获取角色的名字 $rid 角色ID 22 | public function getRolename($rid) 23 | { 24 | return Db::name('role')->where(['rid' =>$rid])->find(); 25 | } 26 | 27 | //获取角色ID $uid 用户ID 28 | public function getRole($uid) 29 | { 30 | return Db::name('user_role')->where(['uid' => $uid])->find(); 31 | } 32 | 33 | //获取登录用户信息 $uid 用户ID 34 | public function getUser($uid) 35 | { 36 | return Db::name('user')->where(['uid' => $uid])->find(); 37 | } 38 | 39 | //获取权限ID $rid 角色ID 40 | public function getPid($rid) 41 | { 42 | return Db::name('role_permission')->where(['rid' => $rid])->find(); 43 | } 44 | 45 | //获取权限列表 $pid 权限ID 字符串 46 | public function getPermission($pid) 47 | { 48 | return Db::name('permission')->order('pid', 'asc')->select($pid); 49 | } 50 | 51 | //删除用户 $table 表名 $uid 用户ID 52 | public function del($table , $uid) 53 | { 54 | if($uid == 1) { 55 | return false; 56 | } 57 | return Db::name($table)->delete($uid); 58 | } 59 | 60 | 61 | //修改用户 $table 表名 $data 数据信息 $uid 用户ID 62 | public function userUpdate($table, $uid ,$data ) 63 | { 64 | return Db::name($table)->where(['uid' => $uid])->update($data); 65 | } 66 | 67 | //增加用户 $table 表名 $data 数据信息 68 | public function userAdd($table , $data) 69 | { 70 | return Db::name($table)->insert($data); 71 | } 72 | 73 | //查询信息 $table 表名 , $where 条件 数组or字符串 74 | public function getMessg($table,$where = null,$id = null , $page = "1,99999") 75 | { 76 | return Db::name($table)->where($where)->page($page)->select($id); 77 | } 78 | 79 | //查询信息 $table 表名 , $where 条件 数组or字符串 80 | public function updateMessg($table,$where,$data) 81 | { 82 | return Db::name($table)->where($where)->update($data); 83 | } 84 | 85 | //删除信息 $table 表名 , $where 条件 数组or字符串 86 | public function deleteMessg($table,$where) 87 | { 88 | return Db::name($table)->where($where)->delete(); 89 | } 90 | 91 | //查询列信息 $table 表名 , $where 条件 数组or字符串 92 | public function getColumn($table,$where = null , $column = null) 93 | { 94 | return Db::name($table)->where($where)->value($column); 95 | } 96 | 97 | //SQL查询 98 | public function sqlExec($sql) 99 | { 100 | return Db::query($sql); 101 | } 102 | 103 | 104 | //增加用户 return 自增ID 105 | public function messageAdd($table,$data) 106 | { 107 | return Db::name($table)->insertGetId($data); 108 | } 109 | 110 | //查询字段 table 表名 where 条件 field 字段名 111 | public function getField($table,$where = null ,$field, $id = null ,$page = "0,99999" , $order = null ) 112 | { 113 | return Db::name($table)->where($where)->field($field)->page($page)->order($order)->select($id); 114 | } 115 | 116 | //模糊查询 table 表名 field 字段名(str) value条件(str) 117 | public function messageLike($table , $field , $value) 118 | { 119 | return Db::name($table)->where($field , 'like' , '%'.$value.'%')->select(); 120 | } 121 | 122 | //计算总数 123 | public function countNember($table , $id) 124 | { 125 | return Db::name($table)->count($id); 126 | } 127 | 128 | 129 | } -------------------------------------------------------------------------------- /application/index/model/sdata.php: -------------------------------------------------------------------------------- 1 | query('show measurements'); 20 | dump($result); 21 | } 22 | 23 | public function demo() 24 | { 25 | $file = ROOT_PATH . 'plugins' . DS . 'demo2.zip'; 26 | // $zip = new \ZipArchive; 27 | // $open = $zip->open($file); 28 | $zip = zip_open($file); 29 | $zip = zip_read($file); 30 | dump($zip); 31 | // dump($zip);die; 32 | // if ($zip->open($file) === TRUE) { 33 | // for ($idx=0 ; $s = $zip->statIndex($idx) ; $idx++) { 34 | // dump($zip->getExternalAttributesIndex($idx)); 35 | // // if ($zip->extractTo('.', $s['name'])) { 36 | // // if ($zip->getExternalAttributesIndex($idx, $opsys, $attr) 37 | // // && $opsys==ZipArchive::OPSYS_UNIX) { 38 | // // chmod($s['name'], ($attr & 07777)); 39 | // // } 40 | // // } 41 | // } 42 | // // $zip->extractTo($this->pluginDir); 43 | // $zip->close(); 44 | // return true; 45 | // } else { 46 | // return false; 47 | // } 48 | } 49 | } -------------------------------------------------------------------------------- /application/plugins/controller/Index.php: -------------------------------------------------------------------------------- 1 | where($where)->count(); 35 | $result = $plugin->where($where)->order("$sortField desc")->page($page)->limit($limit)->select(); 36 | $return_data['sum_count'] = $sum_count; 37 | $return_data['result'] = $result; 38 | return get_status(0 , $return_data); 39 | } 40 | 41 | /** 42 | * 批量删除插件 43 | * 44 | * @param Plugins $plugin 45 | * @return void 46 | */ 47 | public function del(Plugins $plugin) 48 | { 49 | $ids = input('post.pluginIds/a'); 50 | $info = $plugin->where('id', 'in', $ids)->select(); 51 | if (!$info) return get_status(1 , '找不到插件信息'); 52 | $result = $plugin->where('id', 'in', $ids)->delete(); 53 | if (!$result) { 54 | return get_status(1 , '卸载失败'); 55 | } 56 | foreach ($info as $value) { 57 | removeDir(self::$pluginDir . $value['dir']); 58 | } 59 | return get_status(0 , '已卸载'); 60 | } 61 | 62 | public static function upSinglePlugin($path) 63 | { 64 | $dir = basename($path); 65 | self::$upSingleDir = $dir; 66 | return self::update(); 67 | } 68 | 69 | /** 70 | * 扫描插件目录 71 | * 72 | * @return void 73 | */ 74 | public static function update() 75 | { 76 | $dirs = self::scan(); 77 | $plugins = []; 78 | foreach ($dirs as $dir) { 79 | if ($dir == '.' || $dir == '..' || $dir == '.gitignore') continue; 80 | $pluginPath = self::$pluginDir . $dir; 81 | if (is_file($pluginPath)) continue; 82 | if (self::$upSingleDir && $dir != self::$upSingleDir) continue; 83 | $data['pluginPath'] = self::$pluginRelativePath . $dir; 84 | $data['xmlPath'] = $pluginPath . DS . 'plugin.xml'; 85 | $data['info'] = self::getXml($data['xmlPath']); 86 | $data['name'] = $data['info']['moduleId']; 87 | $data['dir'] = $dir; 88 | $data['version'] = $data['info']['moduleVersion']; 89 | $data['type'] = $data['info']['moduleType'] ?? 'chart'; 90 | 91 | $result = self::savePlugin($data); 92 | //静态数据 93 | $TestData = $pluginPath . DS . $data['info']['moduleTestData']; 94 | $TestData = file_get_contents($TestData); 95 | self::saveChartdata($TestData,$data['info']['moduleId']); 96 | 97 | $plugins[$dir]['result'] = true; 98 | $plugins[$dir]['msg'] = 'ok'; 99 | if (!$result) { 100 | $plugins[$dir]['result'] = false; 101 | $plugins[$dir]['msg'] = '写入失败'; 102 | } 103 | if ($result === -1) { 104 | $plugins[$dir]['result'] = false; 105 | $plugins[$dir]['msg'] = '插件版本已存在'; 106 | } 107 | $plugins[$dir]['name'] = $data['name']; 108 | } 109 | return get_status(0 , $plugins); 110 | } 111 | 112 | /** 113 | * 保存入库 114 | * 115 | * @param [type] $plugin 116 | * @return void 117 | */ 118 | public static function savePlugin($plugin) 119 | { 120 | $time = time(); 121 | $plugin['info'] = json_encode($plugin['info'], JSON_UNESCAPED_UNICODE); 122 | $plugin['update_time'] = date('Y-m-d H:i:s', $time); 123 | $data = new Plugins(); 124 | $findPlugin = $data->where(['name' => $plugin['name']])->find(); 125 | if ($findPlugin) { 126 | // if ($findPlugin['version'] == $plugin['version']) return -1; 127 | return $data->allowField(true)->save($plugin, ['id' => $findPlugin['id']]); 128 | } 129 | $plugin['create_time'] = $plugin['update_time']; 130 | return $data->allowField(true)->save($plugin); 131 | } 132 | public static function saveChartdata($data,$charttype) 133 | { 134 | $result = Db::table('up_chartdata')->where('charttype',$charttype)->find(); 135 | if(empty($result)){ 136 | //添加操作 137 | $data = ['data' => $data, 'charttype' => $charttype]; 138 | Db::table('up_chartdata')->insert($data); 139 | }else{ 140 | //修改操作 141 | Db::table('up_chartdata')->where('charttype', $charttype)->update(['data' =>$data]); 142 | 143 | } 144 | } 145 | 146 | public static function scan() 147 | { 148 | //扫描文件夹 149 | return scandir(self::$pluginDir); 150 | } 151 | 152 | /** 153 | * 由路径解析xml 154 | * 155 | * @param [type] $xmlPath 156 | * @return void 157 | */ 158 | public static function getXml($xmlPath) 159 | { 160 | $json = json_encode((array) simplexml_load_file($xmlPath), JSON_UNESCAPED_UNICODE); 161 | $info = str_replace('{}', '""', $json); 162 | $info = str_replace(array('\n\t'), "", $info); 163 | // dump($info);die; 164 | $result = json_decode($info, true); 165 | return $result; 166 | // dump($result);die; 167 | // $modifyData = self::modifyDataType($result); 168 | // dump($modifyData);die; 169 | } 170 | 171 | // protected static function modifyDataType( $data) 172 | // { 173 | // foreach ($data as $key => $value) { 174 | // if (is_array($value)) { 175 | // $data[$key] = self::modifyDataType($value); 176 | // } else { 177 | // if (in_array($key, self::$xmlDataType)) { 178 | // $data[$key] = self::getType($key, $value); 179 | // } 180 | // } 181 | // } 182 | // return $data; 183 | // } 184 | 185 | // protected static function getType($type, $value) 186 | // { 187 | // switch ($type) { 188 | // case 'boolean': 189 | // return ($value == 'true') ? true : false; 190 | // case 'int': 191 | // return (int) $value; 192 | // case 'float': 193 | // return (float) $value; 194 | // default: 195 | // return ''; 196 | // } 197 | // } 198 | } -------------------------------------------------------------------------------- /application/plugins/controller/Upload.php: -------------------------------------------------------------------------------- 1 | 17 | 18 |
19 | 23 | 24 | 25 |