From 410114c2fdde6a7ed96288429985a0174ea08458 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 29 Jan 2023 17:23:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B06?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Api.php | 27 +++++-- app/admin/controller/Index.php | 89 +++++++++++++++++++---- app/admin/view/index/index.html | 20 +++--- app/admin/view/index/main.html | 122 ++++++++++---------------------- composer.json | 3 +- config/filesystem.php | 11 +++ 6 files changed, 155 insertions(+), 117 deletions(-) diff --git a/app/admin/controller/Api.php b/app/admin/controller/Api.php index 20ce1b4..d06feb8 100644 --- a/app/admin/controller/Api.php +++ b/app/admin/controller/Api.php @@ -12,6 +12,8 @@ namespace app\admin\controller; use app\admin\BaseController; use app\admin\model\AdminLog; use app\admin\validate\AdminCheck; +use OSS\Core\OssException; +use OSS\OssClient; use think\exception\ValidateException; use think\facade\Db; use think\facade\Session; @@ -70,19 +72,34 @@ class Api extends BaseController // 日期前綴 $dataPath = date('Ym'); $use = 'thumb'; - $filename = \think\facade\Filesystem::disk('public')->putFile($dataPath, $file, function () use ($md5) { - return $md5; - }); + $accessKeyId = "LTAI5t7mhH3ij2cNWs1zhPmv"; ; + $accessKeySecret = "gqo2wMpvi8h5bDBmCpMje6BaiXvcPu"; + $endpoint = "oss-cn-chengdu.aliyuncs.com"; + try { + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint); + } catch (OssException $e) { + return to_assign(1, $e->getMessage()); + } + $bucket = "lihai001"; + $object = 'storage/'.$dataPath.'/'.$md5.'.jpg'; +// $filename = \think\facade\Filesystem::disk('public')->putFile($dataPath, $file, function () use ($md5) { +// return $md5; +// }); + try { + $filename=$ossClient->uploadFile($bucket, $object,$file); + } catch (OssException $e) { + return to_assign(1, $e->getMessage()); + } if ($filename) { //写入到附件表 $data = []; $path = get_config('filesystem.disks.public.url'); - $data['filepath'] = $path . '/' . $filename; + $data['filepath'] = $filename['info']['url']; $data['name'] = $file->getOriginalName(); $data['mimetype'] = $file->getOriginalMime(); $data['fileext'] = $file->extension(); $data['filesize'] = $file->getSize(); - $data['filename'] = $filename; + $data['filename'] = $object; $data['sha1'] = $sha1; $data['md5'] = $md5; $data['module'] = \think\facade\App::initialize()->http->getName(); diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 94d04a0..e502868 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -15,6 +15,10 @@ use think\facade\View; class Index extends BaseController { + public function __construct() + { + $this->adminInfo = get_login_admin(); + } public function index() { $admin = get_login_admin(); @@ -40,22 +44,77 @@ class Index extends BaseController public function main() { - $adminCount = Db::name('Admin')->where('status', '1')->count(); - $userCount = Db::name('User')->where('status', '1')->count(); - $articleCount = Db::name('Article')->where('status', '1')->count(); - $goodsCount = Db::name('Goods')->where('status', '1')->count(); - $fileCount = Db::name('File')->count(); - $install = false; - if (file_exists(CMS_ROOT . 'app/install')) { - $install = true; + if ($this->adminInfo['id']!=1){ + $find = Db::name('szxc_information_useraddress')->where('user_id', $this->adminInfo['id'])->find(); + if ($find) { + if ($find['auth_range']==1){ + $where[] = ['village_id', '=', $find['village_id']]; + }elseif ($find['auth_range']==2){ + $where[] = ['street_id', '=', $find['street_id']]; + }elseif ($find['auth_range']==3){ + $where[] = ['area_id', '=', $find['area_id']]; + } + } + }else{ + $where=[]; } - View::assign('adminCount', $adminCount); - View::assign('userCount', $userCount); - View::assign('articleCount', $articleCount); - View::assign('goodsCount', $goodsCount); - View::assign('fileCount', $fileCount); - View::assign('install', $install); - View::assign('TP_VERSION',\think\facade\App::version()); + $num =Db::table('fa_szxc_information_usermsg')->where($where)->count(); + +// 大于60岁人数 + $old_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>=', 60)->count(); +// 儿童人数 + $children_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 15)->count(); +// 未婚男 + $unmarried_man_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 1], ['marital_status', '=', 169]])->count(); +// 未婚女 + $unmarried_woman_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 2], ['marital_status', '=', 169]])->count(); +// 少数民族 + $nation_s_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereBetween('nation', [13, 68])->count(); +// 汉族 + $nation_h_num = Db::table('fa_szxc_information_usermsg')->where($where)->where('nation', 12)->count(); +// 土地性质 + + foreach ($where as $key =>$value){ + $where[$key][0] = 'm.'.$value[0]; + } + // 残疾人数 + $whether_disabled_num = Db::table('fa_szxc_information_usermsg') + ->alias('m') + ->where($where) + ->join(['fa_szxc_information_insurance'=>'i'],'m.user_id=i.user_id and i.whether_disabled!=112')->count(); +// 参保人数 + $insurance_type_num = Db::table('fa_szxc_information_usermsg') + ->alias('m') + ->where($where) + ->join(['fa_szxc_information_insurance'=>'i'],'m.user_id=i.user_id and i.insurance_type!=219')->count(); + + if ($this->adminInfo['id']!=1){ + // 工作人员数 + $work_num = Db::table('fa_szxc_information_usermsg') + ->alias('m') + ->where($where) + ->join(['user'=>'u'],'m.user_id=u.id and u.group_id = 3')->count(); + }else{ + $work_num = Db::table('fa_user') + ->alias('u') + ->where($where) + ->where('u.group_id',3) + ->join(['fa_szxc_information_usermsg'=>'m'],'u.id = m.user_id')->count(); + } + View::assign( + [ + 'totaluser' => $num,//User::where($whe)->count(),// 总用户数 + 'old_num' => $old_num, + 'children_num' => $children_num, + 'unmarried_man_num' => $unmarried_man_num, + 'unmarried_woman_num' => $unmarried_woman_num, + 'whether_disabled_num' => $whether_disabled_num, + 'insurance_type_num' => $insurance_type_num, + 'nation_s_num' => $nation_s_num, + 'nation_h_num' => $nation_h_num, + 'work_num' => $work_num, + ] + ); return View(); } diff --git a/app/admin/view/index/index.html b/app/admin/view/index/index.html index d2cb8e6..fd90e54 100644 --- a/app/admin/view/index/index.html +++ b/app/admin/view/index/index.html @@ -16,9 +16,9 @@ - - - + + +
@@ -37,13 +37,13 @@ - - - - -
99
-
-
+ + + + + + +