where($where)->whereAge('>', 80)->count(); //61-80岁 $num2 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<=', 80)->whereAge('>', 60)->count(); //36-60岁 $num3 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<=', 60)->whereAge('>=', 36)->count(); //18-35岁 $num4 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 36)->whereAge('>', 17)->count(); //0-17岁 $num5 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 18)->count(); $return = [ ['value'=>$num1,'name'=>'80岁以上'], ['value'=>$num2,'name'=>'61-80岁'], ['value'=>$num3,'name'=>'36-60岁'], ['value'=>$num4,'name'=>'18-35岁'], ['value'=>$num5,'name'=>'0-17岁'] ]; $this->apiSuccess('获取成功',$return); } //人群关爱(特困人员、高龄老人、低保人员、空巢老人、残疾人员、留守儿童) public function get_people2($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 特困人员 $num1 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>', 80)->count(); //高龄老人 $num2 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>', 80)->count(); //空巢老人 $num4 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<=', 80)->whereAge('>', 60)->count(); //留守儿童 $num6 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 18)->count(); foreach ($where as $key =>$value){ $where[$key][0] = 'm.'.$value[0]; } //低保人员 $num3 = 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(); //残疾人员 $num5 = 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(); $return = [ ['value'=>$num1,'name'=>'特困人员'], ['value'=>$num2,'name'=>'高龄老人'], ['value'=>$num3,'name'=>'空巢老人'], ['value'=>$num4,'name'=>'留守儿童'], ['value'=>$num5,'name'=>'低保人员'], ['value'=>$num6,'name'=>'残疾人员'] ]; $this->apiSuccess('获取成功',$return); } //事项办理(待办事项、延期待办、总计办理、办理结率) public function get_num($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['county', '=', $area_id]; } if ($street_id){ $where[] = ['township', '=', $street_id]; } if ($village_id){ $where[] = ['village', '=', $village_id]; } // 待办事项 $shuqiu = Db::table('fa_article')->where('is_solve', 0)->where($where)->where('category_id', 'in',[165,150,149,148,147])->whereTime('end_time','>', date('Y-m-d h:i:s'))->count(); // 延期待办 $time = Db::table('fa_article')->where('is_solve', 0)->where($where)->where('category_id', 'in',[165,150,149,148,147])->whereTime('end_time','<=', date('Y-m-d h:i:s'))->count(); // 总计办理 $is_solve = Db::table('fa_article')->where('is_solve', 1)->where($where)->count(); if($is_solve){ // 办理结率 $num4 = ($is_solve-$shuqiu-$time)/$is_solve; }else{ $num4 = 0; } $num4 = round($num4*100,2).'%'; $return = [ ['value'=>$shuqiu,'name'=>'待办事项'], ['value'=>$time,'name'=>'延期待办'], ['value'=>$is_solve,'name'=>'总计办理'], ['value'=>$num4,'name'=>'办理结率'] ]; $this->apiSuccess('获取成功',$return); } //资产情况(总耕地面积、人均耕地面积、退林还耕面积、种植物种类、养殖物种类) public function get_num2($area_id=0,$street_id=0,$village_id=0){ $where = $map = []; if ($area_id){ $where[] = ['b.area_id', '=', $area_id]; $map[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['b.street_id', '=', $street_id]; $map[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['b.village_id', '=', $village_id]; $map[] = ['village_id', '=', $village_id]; } // 总耕地面积 $num1 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where($where)->sum('land_area'); //人均耕地面积 $all = Db::table('fa_szxc_information_usermsg')->where($map)->whereStatus('=', 1)->count(); if($all){ $num2 = $num1/$all; }else{ $num2 = 0; } //退林还耕面积 $num3 = $num1*0.3; //种植物种类 $num4 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where($where)->column('crops_msg'); $a = 0; foreach ($num4 as $k=>$v){ $v = json_decode($v,true); $v = array_filter(array_column($v,'name')); $v = array_filter($v); $a = $a + count($v); } $num4 = $a; //养殖物种类 $num5 = 12; $return = [ ['value'=>$num1,'name'=>'总耕地面积'], ['value'=>$num2,'name'=>'人均耕地面积'], ['value'=>$num3,'name'=>'退林还耕面积'], ['value'=>$num4,'name'=>'种植物种类'], ['value'=>$num5,'name'=>'养殖物种类'] ]; $this->apiSuccess('获取成功',$return); } //消费数据(农资消费总计、食品消费总计、衣着消费总计、居住消费总计、生活用品及服务总计、交通通信总计、教育文化娱乐总计、医疗服务总计) public function get_num3($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 农资消费总计 $num1 = 3687; // 食品消费总计 $num2 = 42222; // 衣着消费总计 $num3 = 25841; // 居住消费总计 $num4 = 84511; // 生活用品及服务总计 $num5 = 4254; // 交通通信总计 $num6 = 12631; // 教育文化娱乐总计 $num7 = 8571; //医疗服务总计 $num8 = 63541; $return = [ ['value'=>$num1,'name'=>'农资消费总计'], ['value'=>$num2,'name'=>'食品消费总计'], ['value'=>$num3,'name'=>'衣着消费总计'], ['value'=>$num4,'name'=>'居住消费总计'], ['value'=>$num5,'name'=>'生活用品及服务总计'], ['value'=>$num6,'name'=>'交通通信总计'], ['value'=>$num7,'name'=>'教育文化娱乐总计'], ['value'=>$num8,'name'=>'医疗服务总计'] ]; $this->apiSuccess('获取成功',$return); } //收入构成(工资性收入、生产经营性收入、财产性收入、保险性收入) public function get_num4($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 工资性收入 $num1 = 12; // 生产经营性收入 $num2 = 123; // 财产性收入 $num3 = 124; // 保险性收入 $num4 = 125; $return = [ ['value'=>$num1,'name'=>'工资性收入'], ['value'=>$num2,'name'=>'生产经营性收入'], ['value'=>$num3,'name'=>'财产性收入'], ['value'=>$num4,'name'=>'保险性收入'] ]; $this->apiSuccess('获取成功',$return); } //土地性质(园地 //耕地 //林地 //牧草地 //养殖 //坑塘 //农田水利设施用地) public function get_num5($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['b.area_id', '=', $area_id]; } if ($street_id){ $where[] = ['b.street_id', '=', $street_id]; } if ($village_id){ $where[] = ['b.village_id', '=', $village_id]; } // 总耕地面积 $num1 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',70)->where($where)->sum('land_area'); //园地 $num2 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',69)->where($where)->sum('land_area'); //林地 $num3 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',214)->where($where)->sum('land_area'); //牧草地 $num4 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',215)->where($where)->sum('land_area'); //养殖 $num5 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',216)->where($where)->sum('land_area'); //坑塘 $num6 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',217)->where($where)->sum('land_area'); //农田水利设施用地 $num7 = Db::table('fa_szxc_information_planting')->alias('a')->join(['fa_szxc_information_usermsg' => 'b'],'a.user_id = b.user_id')->where('nature_of_land',218)->where($where)->sum('land_area'); $return = [ ['value'=>$num1,'name'=>'耕地面积'], ['value'=>$num2,'name'=>'园地'], ['value'=>$num3,'name'=>'林地'], ['value'=>$num4,'name'=>'牧草地'], ['value'=>$num5,'name'=>'养殖'], ['value'=>$num6,'name'=>'坑塘'], ['value'=>$num7,'name'=>'农田水利设施用地'] ]; $this->apiSuccess('获取成功',$return); } //文化程度( //文盲及半文盲 //小学 //初中 //高中/技校/中专 //大学专科及以上 //不详) public function get_num6($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 文盲及半文盲 $num1 = Db::table('fa_szxc_information_usermsg')->where('education',71)->where($where)->count(); //小学 $num2 = Db::table('fa_szxc_information_usermsg')->where('education',72)->where($where)->count(); //初中 $num3 = Db::table('fa_szxc_information_usermsg')->where('education',73)->where($where)->count(); //高中/技校/中专 $num4 = Db::table('fa_szxc_information_usermsg')->where('education',74)->where($where)->count(); //大学专科及以上 $num5 = Db::table('fa_szxc_information_usermsg')->where('education',75)->where($where)->count(); //不详 $num6 = Db::table('fa_szxc_information_usermsg')->where('education',76)->where($where)->count(); $return = [ ['value'=>$num1,'name'=>'文盲及半文盲'], ['value'=>$num2,'name'=>'小学'], ['value'=>$num3,'name'=>'初中'], ['value'=>$num4,'name'=>'高中/技校/中专'], ['value'=>$num5,'name'=>'大学专科及以上'], ['value'=>$num6,'name'=>'不详'], ]; $this->apiSuccess('获取成功',$return); } //政治面貌( //群众 //团员 //党员 //预备役) public function get_num7($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 群众 $num1 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',2)->where($where)->count(); //团员 $num2 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',3)->where($where)->count(); //党员 $num3 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',4)->where($where)->count(); //预备役 $num4 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',177)->where($where)->count(); $return = [ ['value'=>$num1,'name'=>'群众'], ['value'=>$num2,'name'=>'团员'], ['value'=>$num3,'name'=>'党员'], ['value'=>$num4,'name'=>'预备役'], ]; $this->apiSuccess('获取成功',$return); } //优秀村民 public function get_num8($area_id=0,$street_id=0,$village_id=0,$page=1,$limit=10){ // $where[] = ['user_id','in','1,3,5']; $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 群众 $return = Db::table('fa_szxc_information_usermsg') ->field('name,age,address_name as address,gender') ->where($where) ->page($page,$limit) ->withAttr('gender', function ($value, $data) { if($value == 1){ return '男'; }elseif($value == 2){ return '女'; }else{ return '暂无'; } }) ->select(); $this->apiSuccess('获取成功',$return); } //是否参保 public function get_num9($area_id=0,$street_id=0,$village_id=0){ if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ ['yi'=>346], ['wei'=>30], ['type' => [['value'=>30,'name'=>'未参保'], ['value'=>60,'name'=>'低保'], ['value'=>45,'name'=>'城乡居民基本医保'], ['value'=>77,'name'=>'新农合'], ['value'=>82,'name'=>'城镇居民医保'], ['value'=>62,'name'=>'职工医保'], ['value'=>20,'name'=>'其他']] ] ]; $this->apiSuccess('获取成功',$return); } //农业结构 public function get_num10($area_id=0,$street_id=0,$village_id=0){ if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ ['value'=>135,'name'=>'萝卜'], ['value'=>24,'name'=>'白菜'], ['value'=>87,'name'=>'芋头'], ['value'=>51,'name'=>'地瓜'], ['value'=>102,'name'=>'土豆'], ['value'=>24,'name'=>'山药'], ]; $this->apiSuccess('获取成功',$return); } //村名数量 男 女 已婚 未婚 技能培训次数 农业指导次数 政策指导次数 求职人数 土地总面积 荒地总面积 养殖面积 种植面积 public function get_num11() { // $return = "{villagernum:1000,mannum:600,wumannum:400,married:600,unmarried:400,skillnum:20,policynum:20,agriculture:20,Jobnum:105,landsum:800,wasteland:100,breeding:200,planting500}"; $return = [ 'villagernum' => 1000, 'mannum' => 600, 'wumannum' => 400, 'married' => 600, 'unmarried' => 400, 'skillnum' => 20, 'policynum' => 20, 'agriculture' => 20, 'Jobnum' => 105, 'landsum' => 800, 'wasteland' => 100, 'breeding' => 200, 'planting' => 500 ]; $this->apiSuccess('获取成功', $return); } //优秀工作人员 public function get_num12($area_id=0,$street_id=0,$village_id=0,$page=1,$limit=10){ $where[] = ['user_id','in','77,78,79']; // $where = []; // if ($area_id){ // $where[] = ['area_id', '=', $area_id]; // } // if ($street_id){ // $where[] = ['street_id', '=', $street_id]; // } // if ($village_id){ // $where[] = ['village_id', '=', $village_id]; // } // 群众 $return = Db::table('fa_szxc_information_usermsg') ->field('name,phone as telephone') ->where($where) ->page($page,$limit) ->select()->toArray(); foreach ($return as $k=>$v){ $return[$k]['pic'] = "https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230118/a32db5b98f8cf2aa8d1fa07dce0ca9a3.png"; } $this->apiSuccess('获取成功',$return); } //职业 // 国家机关、党群组织、企业、事业单位负责人 // 专业技术人员 // 办事人员和有关人员 // 社会生产服务和生活服务人员 // 农、林、牧、渔业生产及辅助人员 // 生产、运输设备操作人员及有关人员 // 军人 // 不便分类的其他从业人员 public function get_num13($area_id=0,$street_id=0,$village_id=0){ $where = []; if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } // 国家机关、党群组织、企业、事业单位负责人 $num1 = 1358; // 专业技术人员 $num2 = 2578; // 办事人员和有关人员 $num3 = 3684; // 社会生产服务和生活服务人员 $num4 = 8524; // 农、林、牧、渔业生产及辅助人员 $num5 = 9687; // 生产、运输设备操作人员及有关人员 $num6 = 1458; // 军人 $num7 = 998; // 不便分类的其他从业人员 $num8 = 8745; $return = [ ['value'=>$num1,'name'=>'国家机关、党群组织、企业、事业单位负责人'], ['value'=>$num2,'name'=>'专业技术人员'], ['value'=>$num3,'name'=>'办事人员和有关人员'], ['value'=>$num4,'name'=>'社会生产服务和生活服务人员'], ['value'=>$num5,'name'=>'农、林、牧、渔业生产及辅助人员'], ['value'=>$num6,'name'=>'生产、运输设备操作人员及有关人员'], ['value'=>$num7,'name'=>'军人'], ['value'=>$num8,'name'=>'不便分类的其他从业人员'] ]; $this->apiSuccess('获取成功',$return); } //农业产量 public function get_num14($area_id=0,$street_id=0,$village_id=0){ if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ ['value'=>1351,'name'=>'萝卜'], ['value'=>245,'name'=>'白菜'], ['value'=>874,'name'=>'芋头'], ['value'=>511,'name'=>'地瓜'], ['value'=>1024,'name'=>'土豆'], ['value'=>249,'name'=>'山药'], ]; $this->apiSuccess('获取成功',$return); } //农业销量 public function get_num15($area_id=0,$street_id=0,$village_id=0){ if ($area_id){ $where[] = ['area_id', '=', $area_id]; } if ($street_id){ $where[] = ['street_id', '=', $street_id]; } if ($village_id){ $where[] = ['village_id', '=', $village_id]; } $return = [ ['value'=>835,'name'=>'萝卜'], ['value'=>124,'name'=>'白菜'], ['value'=>187,'name'=>'芋头'], ['value'=>251,'name'=>'地瓜'], ['value'=>902,'name'=>'土豆'], ['value'=>214,'name'=>'山药'], ]; $this->apiSuccess('获取成功',$return); } }