123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764 |
- <?php
- namespace app\api\controller\screen;
- use app\hander\HelpHander;
- use think\Controller;
- use think\Db;
- use think\helper\Str;
- use think\Request;
- class Onelevel extends Controller{
- private $orgs = []; // 用户拥有的组织id集合,只区分大区管理员和总公司
- private $orgName = ''; //大区名称
- //取组合数组
- private $spOrgId = 5; //国天sp 厦门中山医院
- private $orgs2 = []; //去除研发中心id 有研发中心 取国天sp 厦门中山医院
- private $bjOrgId = 11; //霸洁云 贵州省黔西市人民医院
- protected function initialize()
- {
- parent::initialize();
- $token = input('token','','trim');
- $token = think_decrypt($token);
- if(!$token){
- HelpHander::success("无权限");
- }
- // $ts = explode('|',$token);
- // if($ts[1] != config('app.ucode')){
- // HelpHander::success("无权限");
- // }
- $map[] = ['type','=',2];
- $map[] = ['del','=',0];
- $map[] = ['enable','=',1];
- $orgids = Db::name('org')
- ->where($map)
- ->column('id');
- $this->orgs = $orgids?$orgids:[-1];
- foreach ($orgids as $k=>$v){
- if($v == 3){
- unset($orgids[$k]);
- }elseif($v == 24){
- unset($orgids[$k]);
- }
- }
- $this->orgs2 = array_values($orgids);
- }
- public function todayTodoInfo(){
- $date = date('Ymd');
- if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
- $map[] = ['CREATE_YYYYMMDD','=',$date];
- $map[] = ['DEL_REF','=',0];
- $count0 = gtspdb('todo')->where($map)->where('ORG_ID',$this->spOrgId)->count();
- $where[] = ['create_yyyymmdd','=',$date];
- $where[] = ['del','=',0];
- $count1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
- $count = $count0 + $count1;
- $map[] = ['TODO_MODE','=',3];
- $where[] = ['todo_mode','=',3];
- $overCount0 = gtspdb('todo')->where($map)->where('ORG_ID',$this->spOrgId)->count();
- $overCount1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
- $overCount = $overCount0+$overCount1;
- $list = [0,0,0,0,0,0];
- $overBl = 0;
- if($count > 0){
- $overBl = round($overCount/$count*100,0);
- $len = strlen($count);
- if($len == 1){
- $count = '00000'.$count;
- }elseif($len == 2){
- $count = '0000'.$count;
- }elseif($len == 3){
- $count = '000'.$count;
- }elseif($len == 4){
- $count = '00'.$count;
- }elseif($len == 5){
- $count = '0'.$count;
- }else{
- $count = '999999';
- }
- $list = str_split($count);
- }
- }elseif (!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- $map[] = ['create_yyyymmdd','=',$date];
- $map[] = ['del','=',0];
- $count0 = bjydb('todo')->where($map)->where('org_id',$this->bjOrgId)->count();
- $where[] = ['create_yyyymmdd','=',$date];
- $where[] = ['del','=',0];
- $count1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
- $count = $count0 + $count1;
- $map[] = ['todo_mode','=',3];
- $where[] = ['todo_mode','=',3];
- $overCount0 = bjydb('todo')->where($map)->where('org_id',$this->bjOrgId)->count();
- $overCount1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
- $overCount = $overCount0+$overCount1;
- $list = [0,0,0,0,0,0];
- $overBl = 0;
- if($count > 0){
- $overBl = round($overCount/$count*100,0);
- $len = strlen($count);
- if($len == 1){
- $count = '00000'.$count;
- }elseif($len == 2){
- $count = '0000'.$count;
- }elseif($len == 3){
- $count = '000'.$count;
- }elseif($len == 4){
- $count = '00'.$count;
- }elseif($len == 5){
- $count = '0'.$count;
- }else{
- $count = '999999';
- }
- $list = str_split($count);
- }
- }else if(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- $map[] = ['CREATE_YYYYMMDD','=',$date];
- $map[] = ['DEL_REF','=',0];
- $count0 = gtspdb('todo')->where($map)->where('ORG_ID',$this->spOrgId)->count();
- $where[] = ['create_yyyymmdd','=',$date];
- $where[] = ['del','=',0];
- $count1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
- $count2 = bjydb('todo')->where($where)->whereIn('org_id',$this->bjOrgId)->count();
- $count = $count0 + $count1 + $count2;
- $map[] = ['TODO_MODE','=',3];
- $where[] = ['todo_mode','=',3];
- $overCount0 = gtspdb('todo')->where($map)->where('ORG_ID',$this->spOrgId)->count();
- $overCount1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
- $overCount2 = bjydb('todo')->where($where)->where('org_id',$this->bjOrgId)->count();
- $overCount = $overCount0+$overCount1+$overCount2;
- $list = [0,0,0,0,0,0];
- $overBl = 0;
- if($count > 0){
- $overBl = round($overCount/$count*100,0);
- $len = strlen($count);
- if($len == 1){
- $count = '00000'.$count;
- }elseif($len == 2){
- $count = '0000'.$count;
- }elseif($len == 3){
- $count = '000'.$count;
- }elseif($len == 4){
- $count = '00'.$count;
- }elseif($len == 5){
- $count = '0'.$count;
- }else{
- $count = '999999';
- }
- $list = str_split($count);
- }
- }else{
- $map[] = ['create_yyyymmdd','=',$date];
- $map[] = ['del','=',0];
- $count = Db::name('todo')->where($map)->where('org_id','in',$this->orgs)->count();
- $map[] = ['todo_mode','=',3];
- $overCount = Db::name('todo')->where($map)->where('org_id','in',$this->orgs)->count();
- $list = [0,0,0,0,0,0];
- $overBl = 0;
- if($count > 0){
- $overBl = round($overCount/$count*100,0);
- $len = strlen($count);
- if($len == 1){
- $count = '00000'.$count;
- }elseif($len == 2){
- $count = '0000'.$count;
- }elseif($len == 3){
- $count = '000'.$count;
- }elseif($len == 4){
- $count = '00'.$count;
- }elseif($len == 5){
- $count = '0'.$count;
- }else{
- $count = '999999';
- }
- $list = str_split($count);
- }
- }
- $data = [
- 'list'=>$list,
- 'bl'=>$overBl
- ];
- HelpHander::success($data);
- }
- public function todayTodoType(){
- $date = date('Ymd');
- $map[] = ['create_yyyymmdd','=',$date];
- $map[] = ['del','=',0];
- if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
- $map[] = ['create_yyyymmdd','=',$date];
- $map[] = ['del','=',0];
- $map[] = ['org_id','in',$this->orgs2];
- $where[] = ['CREATE_YYYYMMDD','=',$date];
- $where[] = ['ORG_ID','=',$this->spOrgId];
- $where[] = ['DEL_REF','=',0];
- $c1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
- $c2 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',1)->count();
- $count = $c1 + $c2;
- $c3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
- $c4 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',2)->count();
- $count2 = $c3 + $c4;
- $c5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
- $c6 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',3)->count();
- $count3 = $c5 + $c6;
- $c7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
- $c8 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',4)->count();
- $count4 = $c7 + $c8;
- $map[] = ['todo_mode','=',3];
- $where[] = ['TODO_MODE','=',3];
- //保修
- $o1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
- $o2 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',1)->count();
- $bxCount = $o1 + $o2;
- //保洁
- $o3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
- $o4 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',2)->count();
- $bjCount = $o3 + $o4;
- //运送
- $o5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
- $o6 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',3)->count();
- $ysCount = $o5 + $o6;
- //隐患
- $o7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
- $o8 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',4)->count();
- $yhCount = $o7 + $o8;
- }else if(!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- $map[] = ['create_yyyymmdd','=',$date];
- $map[] = ['del','=',0];
- $map[] = ['org_id','in',$this->orgs2];
- $where[] = ['create_yyyymmdd','=',$date];
- $where[] = ['del','=',0];
- $where[] = ['org_id','=',$this->bjOrgId];
- $c1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
- $c2 = bjydb('todo')->where($where)->where('work_type_mode',1)->count();
- $count = $c1 + $c2;
- $c3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
- $c4 = bjydb('todo')->where($where)->where('work_type_mode',2)->count();
- $count2 = $c3 + $c4;
- $c5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
- $c6 = bjydb('todo')->where($where)->where('work_type_mode',3)->count();
- $count3 = $c5 + $c6;
- $c7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
- $c8 = bjydb('todo')->where($where)->where('work_type_mode',4)->count();
- $count4 = $c7 + $c8;
- $map[] = ['todo_mode','=',3];
- $where[] = ['todo_mode','=',3];
- //保修
- $o1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
- $o2 = bjydb('todo')->where($where)->where('work_type_mode',1)->count();
- $bxCount = $o1 + $o2;
- //保洁
- $o3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
- $o4 = bjydb('todo')->where($where)->where('work_type_mode',2)->count();
- $bjCount = $o3 + $o4;
- //运送
- $o5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
- $o6 = bjydb('todo')->where($where)->where('work_type_mode',3)->count();
- $ysCount = $o5 + $o6;
- //隐患
- $o7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
- $o8 = bjydb('todo')->where($where)->where('work_type_mode',4)->count();
- $yhCount = $o7 + $o8;
- }elseif(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- $map[] = ['create_yyyymmdd','=',$date];
- $map[] = ['del','=',0];
- $map[] = ['org_id','in',$this->orgs2];
- $where[] = ['CREATE_YYYYMMDD','=',$date];
- $where[] = ['ORG_ID','=',$this->spOrgId];
- $where[] = ['DEL_REF','=',0];
- $map2[] = ['create_yyyymmdd','=',$date];
- $map2[] = ['del','=',0];
- $map2[] = ['org_id','in',$this->bjOrgId];
- $c1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
- $c2 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',1)->count();
- $c22 = bjydb('todo')->where($map2)->where('work_type_mode',1)->count();
- $count = $c1 + $c2 + $c22;
- $c3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
- $c4 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',2)->count();
- $c44 = bjydb('todo')->where($map2)->where('work_type_mode',2)->count();
- $count2 = $c3 + $c4 + $c44;
- $c5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
- $c6 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',3)->count();
- $c66 = bjydb('todo')->where($map2)->where('work_type_mode',3)->count();
- $count3 = $c5 + $c6 + $c66;
- $c7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
- $c8 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',4)->count();
- $c88 = bjydb('todo')->where($map2)->where('work_type_mode',4)->count();
- $count4 = $c7 + $c8 + $c88;
- $map[] = ['todo_mode','=',3];
- $where[] = ['TODO_MODE','=',3];
- $map2[] = ['todo_mode','=',3];
- //保修
- $o1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
- $o2 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',1)->count();
- $o22 = bjydb('todo')->where($map2)->where('work_type_mode',1)->count();
- $bxCount = $o1 + $o2 + $o22;
- //保洁
- $o3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
- $o4 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',2)->count();
- $o44 = bjydb('todo')->where($map2)->where('work_type_mode',2)->count();
- $bjCount = $o3 + $o4 + $o44;
- //运送
- $o5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
- $o6 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',3)->count();
- $o66 = bjydb('todo')->where($map2)->where('work_type_mode',3)->count();
- $ysCount = $o5 + $o6 + $o66;
- //隐患
- $o7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
- $o8 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',4)->count();
- $o88 = bjydb('todo')->where($map2)->where('work_type_mode',4)->count();
- $yhCount = $o7 + $o8 + $o88;
- }else{
- $map[] = ['create_yyyymmdd','=',$date];
- $map[] = ['del','=',0];
- $count = Db::name('todo')->where($map)->where('work_type_mode',1)->where('org_id','in',$this->orgs)->count();
- $count2 = Db::name('todo')->where($map)->where('work_type_mode',2)->where('org_id','in',$this->orgs)->count();
- $count3 = Db::name('todo')->where($map)->where('work_type_mode',3)->where('org_id','in',$this->orgs)->count();
- $count4 = Db::name('todo')->where($map)->where('work_type_mode',4)->where('org_id','in',$this->orgs)->count();
- $map[] = ['todo_mode','=',3];
- //保修
- $bxCount = Db::name('todo')->where($map)->where('work_type_mode',1)->where('org_id','in',$this->orgs)->count();
- //保洁
- $bjCount = Db::name('todo')->where($map)->where('work_type_mode',2)->where('org_id','in',$this->orgs)->count();
- //运送
- $ysCount = Db::name('todo')->where($map)->where('work_type_mode',3)->where('org_id','in',$this->orgs)->count();
- //隐患
- $yhCount = Db::name('todo')->where($map)->where('work_type_mode',4)->where('org_id','in',$this->orgs)->count();
- }
- $bxBl = $bjBl = $ysBl = $yhBl =0;
- if($count > 0){
- $bxBl = round($bxCount/$count*100,0);
- }
- if($count2 >0){
- $bjBl = round($bjCount/$count2*100,0);
- }
- if($count3 >0){
- $ysBl = round($ysCount/$count3*100,0);
- }
- if($count4 >0){
- $yhBl = round($yhCount/$count4*100,0);
- }
- $data = [
- 'bx'=>['count'=>$bxCount,'bl'=>$bxBl],
- 'bj'=>['count'=>$bjCount,'bl'=>$bjBl],
- 'ys'=>['count'=>$ysCount,'bl'=>$ysBl],
- 'yh'=>['count'=>$yhCount,'bl'=>$yhBl],
- ];
- HelpHander::success($data);
- }
- public function moduleList(){
- if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
- $map[] = ['del','=',0];
- $map[] = ['enable','=',1];
- $map[] = ['type','=',2];
- $orgList = Db::name('org')
- ->field('id,name')
- ->where('id','in',$this->orgs2)
- ->where($map)
- ->select();
- $bxCount = $bjCount = $ysCount = $yhCount = $pzCount = $xgCount = $phCount = 0;
- foreach ($orgList as $k=>$v){
- $bx = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',1)->find();
- if($bx){
- $bxCount += 1;
- }
- $bj = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',2)->find();
- if($bj){
- $bjCount += 1;
- }
- $ys = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',3)->find();
- if($ys){
- $ysCount += 1;
- }
- $yh = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',4)->find();
- if($yh){
- $yhCount += 1;
- }
- $xg = Db::name('patrol_record')->where('org_id',$v['id'])->where('patrol_mode',1)->count();
- if($xg){
- $xgCount += 1;
- }
- $pzCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',15)->count();
- $phCount = Db::name('ph_todo')->where('org_id',$v['id'])->count();
- }
- $bx = gtspdb('todo')->where('ORG_ID',$this->spOrgId)->where('DEL_REF',0)->where('WORK_TYPE_MODE',1)->count();
- $bj = gtspdb('todo')->where('ORG_ID',$this->spOrgId)->where('DEL_REF',0)->where('WORK_TYPE_MODE',2)->count();
- $ys = gtspdb('todo')->where('ORG_ID',$this->spOrgId)->where('DEL_REF',0)->where('WORK_TYPE_MODE',3)->count();
- $yh = gtspdb('todo')->where('ORG_ID',$this->spOrgId)->where('DEL_REF',0)->where('WORK_TYPE_MODE',4)->count();
- $xg = gtspdb('patrol_record')->where('ORG_ID',$this->spOrgId)->where('PATROL_MODE',1)->count();
- $data = [
- ['name'=>'保修','value'=>$bxCount+$bx],
- ['name'=>'保洁','value'=>$bjCount+$bj],
- ['name'=>'运送','value'=>$ysCount+$ys],
- ['name'=>'隐患预警','value'=>$yhCount+$yh],
- ['name'=>'巡更','value'=>$xgCount+$xg],
- ['name'=>'陪护','value'=>$phCount],
- ['name'=>'品质整改','value'=>$pzCount],
- ];
- }elseif(!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- $map[] = ['del','=',0];
- $map[] = ['enable','=',1];
- $map[] = ['type','=',2];
- $orgList = Db::name('org')
- ->field('id,name')
- ->where('id','in',$this->orgs2)
- ->where($map)
- ->select();
- $bxCount = $bjCount = $ysCount = $yhCount = $pzCount = $xgCount = $phCount = 0;
- foreach ($orgList as $k=>$v){
- $bxCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',1)->count();
- $bjCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',2)->count();
- $ysCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',3)->count();
- $yhCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',4)->count();
- $xgCount = Db::name('patrol_record')->where('org_id',$v['id'])->where('patrol_mode',1)->count();
- $pzCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',15)->count();
- $phCount = Db::name('ph_todo')->where('org_id',$v['id'])->count();
- }
- $bx = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',1)->count();
- $bj = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',2)->count();
- $ys = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',3)->count();
- $yh = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',4)->count();
- $xg = bjydb('patrol_record')->where('org_id',$this->bjOrgId)->where('patrol_mode',1)->count();
- $data = [
- ['name'=>'保修','value'=>$bxCount+$bx],
- ['name'=>'保洁','value'=>$bjCount+$bj],
- ['name'=>'运送','value'=>$ysCount+$ys],
- ['name'=>'隐患预警','value'=>$yhCount+$yh],
- ['name'=>'巡更','value'=>$xgCount+$xg],
- ['name'=>'陪护','value'=>$phCount],
- ['name'=>'品质整改','value'=>$pzCount],
- ];
- }elseif(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- $map[] = ['del','=',0];
- $map[] = ['enable','=',1];
- $map[] = ['type','=',2];
- $orgList = Db::name('org')
- ->field('id,name')
- ->where('id','in',$this->orgs2)
- ->where($map)
- ->select();
- $bxCount = $bjCount = $ysCount = $yhCount = $pzCount = $xgCount = $phCount = 0;
- foreach ($orgList as $k=>$v){
- $bxCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',1)->count();
- $bjCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',2)->count();
- $ysCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',3)->count();
- $yhCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',4)->count();
- $xgCount = Db::name('patrol_record')->where('org_id',$v['id'])->where('patrol_mode',1)->count();
- $pzCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',15)->count();
- $phCount = Db::name('ph_todo')->where('org_id',$v['id'])->count();
- }
- $bx = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',1)->count();
- $bj = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',2)->count();
- $ys = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',3)->count();
- $yh = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',4)->count();
- $xg = bjydb('patrol_record')->where('org_id',$this->bjOrgId)->where('patrol_mode',1)->count();
- $bx2 = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',1)->count();
- $bj2 = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',2)->count();
- $ys2 = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',3)->count();
- $yh2 = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',4)->count();
- $xg2 = bjydb('patrol_record')->where('org_id',$this->bjOrgId)->where('patrol_mode',1)->count();
- $data = [
- ['name'=>'保修','value'=>$bxCount+$bx+$bx2],
- ['name'=>'保洁','value'=>$bjCount+$bj+$bj2],
- ['name'=>'运送','value'=>$ysCount+$ys+$ys2],
- ['name'=>'隐患预警','value'=>$yhCount+$yh+$yh2],
- ['name'=>'巡更','value'=>$xgCount+$xg+$xg2],
- ['name'=>'陪护','value'=>$phCount],
- ['name'=>'品质整改','value'=>$pzCount],
- ];
- }else{
- $map[] = ['del','=',0];
- $map[] = ['enable','=',1];
- $map[] = ['type','=',2];
- $orgList = Db::name('org')
- ->field('id,name')
- ->where('id','in',$this->orgs)
- ->where($map)
- ->select();
- $bxCount = $bjCount = $ysCount = $yhCount = $pzCount = $xgCount = $phCount = 0;
- foreach ($orgList as $k=>$v){
- $bx = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',1)->find();
- if($bx){
- $bxCount += 1;
- }
- $bj = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',2)->find();
- if($bj){
- $bjCount += 1;
- }
- $ys = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',3)->find();
- if($ys){
- $ysCount += 1;
- }
- $yh = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',4)->find();
- if($yh){
- $yhCount += 1;
- }
- $pz = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',15)->find();
- if($pz){
- $pzCount += 1;
- }
- $xg = Db::name('patrol_record')->where('org_id',$v['id'])->where('patrol_mode',1)->count();
- if($xg){
- $xgCount += 1;
- }
- $ph = Db::name('ph_todo')->where('org_id',$v['id'])->count();
- if($ph){
- $phCount += 1;
- }
- }
- $data = [
- ['name'=>'保修','value'=>$bxCount],
- ['name'=>'保洁','value'=>$bjCount],
- ['name'=>'运送','value'=>$ysCount],
- ['name'=>'隐患预警','value'=>$yhCount],
- ['name'=>'品质整改','value'=>$pzCount],
- ['name'=>'巡更','value'=>$xgCount],
- ['name'=>'陪护','value'=>$phCount],
- ];
- }
- HelpHander::success($data);
- }
- public function commentComplainList(){
- $date = [
- date('Y',strtotime('-5 years')),
- date('Y',strtotime('-4 years')),
- date('Y',strtotime('-3 years')),
- date('Y',strtotime('-2 years')),
- date('Y',strtotime('-1 years')),
- date('Y'),
- ];
- $list = $list2 = [];
- if(in_array(3,$this->orgs) && in_array(24,$this->orgs) ){
- foreach ($date as $k=>$v){
- $c1 = Db::name('comment')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->sum('score');
- $c2 = gtspdb('comment')->where('ORG_ID',$this->spOrgId)->where('CREATE_YYYY',$v)->sum('SCORE');
- $c22 = bjydb('comment')->where('org_id',$this->bjOrgId)->where('create_yyyy',$v)->sum('score');
- $list[] = $c1+$c2+$c22;
- $c3 = Db::name('complain')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->where('del',0)->count();
- $c4 = gtspdb('complain')->where('ORG_ID',$this->spOrgId)->where('CREATE_YYYY',$v)->where('DEL_REF',0)->count();
- $c44 = bjydb('complain')->where('org_id',$this->bjOrgId)->where('create_yyyy',$v)->where('del',0)->count();
- $list2[] = $c3+$c4+$c44;
- }
- }elseif(in_array(3,$this->orgs) && !in_array(24,$this->orgs) ){
- foreach ($date as $k=>$v){
- $c1 = Db::name('comment')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->sum('score');
- $c2 = gtspdb('comment')->where('ORG_ID',$this->spOrgId)->where('CREATE_YYYY',$v)->sum('SCORE');
- $list[] = $c1+$c2;
- $c3 = Db::name('complain')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->where('del',0)->count();
- $c4 = gtspdb('complain')->where('ORG_ID',$this->spOrgId)->where('CREATE_YYYY',$v)->where('DEL_REF',0)->count();
- $list2[] = $c3+$c4;
- }
- }elseif(!in_array(3,$this->orgs) && in_array(24,$this->orgs) ){
- foreach ($date as $k=>$v){
- $c1 = Db::name('comment')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->sum('score');
- $c2 = bjydb('comment')->where('org_id',$this->bjOrgId)->where('create_yyyy',$v)->sum('score');
- $list[] = $c1+$c2;
- $c3 = Db::name('complain')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->where('del',0)->count();
- $c4 = bjydb('complain')->where('org_id',$this->bjOrgId)->where('create_yyyy',$v)->where('del',0)->count();
- $list2[] = $c3+$c4;
- }
- }else{
- foreach ($date as $k=>$v){
- $list[] = Db::name('comment')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->sum('score');
- $list2[] = Db::name('complain')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->where('del',0)->count();
- }
- }
- $data = [
- 'title'=>$date,
- 'list1'=>$list,
- 'list2'=>$list2,
- ];
- HelpHander::success($data);
- }
- public function projectCount(){
- if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
- $count = Db::name('org')->where('parent_id',1)->where('del',0)->where('enable',1)->where('type',1)->count();
- $count1 = Db::name('org')->where('del',0)->where('enable',1)->where('type',2)->count();
- $c1 = Db::name('user')
- ->alias('u')
- ->join('user_org uo','uo.user_id=u.id')
- ->join('org o','o.id=uo.org_id')
- ->where('u.del',0)
- ->where('u.type',0)
- ->where('o.enable',1)
- ->where('o.del',0)
- ->count();
- $c2 = gtspdb('user')
- ->alias('u')
- ->join('user_org uo','uo.USER_ID=u.USER_ID')
- ->where('u.DEL_REF',0)
- ->where('u.TYPE',0)
- ->where('uo.ORG_ID','in',$this->spOrgId)
- ->where('uo.ORG_TYPE',0)
- ->count();
- $count2 = $c1 + $c2;
- $oc1 = Db::name('orders')
- ->where('del',0)
- ->where('org_id','in',$this->orgs2)
- ->count();
- $oc2 = gtspdb('orders')
- ->where('DEL_REF',0)
- ->where('ORG_ID',$this->spOrgId)
- ->count();
- $orderCount = $oc1 + $oc2;
- $tc1= Db::name('todo')
- ->where('del',0)
- ->where('org_id','in',$this->orgs2)
- ->count();
- $tc2 = gtspdb('todo')
- ->where('DEL_REF',0)
- ->where('ORG_ID',$this->spOrgId)
- ->count();
- $todoCount = $tc1 + $tc2;
- $t1 = Db::name('patrol_task')
- ->where('del',0)
- ->where('org_id','in',$this->orgs2)
- ->count();
- $t2 = gtspdb('patrol_task')
- ->where('DEL_REF',0)
- ->where('ORG_ID',$this->spOrgId)
- ->count();
- $taskCount = $t1 + $t2;
- }elseif(!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- $count = Db::name('org')->where('parent_id',1)->where('del',0)->where('enable',1)->where('type',1)->count();
- $count1 = Db::name('org')->where('del',0)->where('enable',1)->where('type',2)->count();
- $c1 = Db::name('user')
- ->alias('u')
- ->join('user_org uo','uo.user_id=u.id')
- ->join('org o','o.id=uo.org_id')
- ->where('u.del',0)
- ->where('u.type',0)
- ->where('o.enable',1)
- ->where('o.del',0)
- ->count();
- $c2 = bjydb('user')
- ->alias('u')
- ->join('user_org uo','uo.user_id=u.id')
- ->join('org o','o.id=uo.org_id')
- ->where('u.del',0)
- ->where('u.type',0)
- ->where('o.enable',1)
- ->where('o.del',0)
- ->where('o.id',$this->bjOrgId)
- ->count();
- $count2 = $c1 + $c2;
- $oc1 = Db::name('orders')
- ->where('del',0)
- ->where('org_id','in',$this->orgs2)
- ->count();
- $oc2 = bjydb('orders')
- ->where('del',0)
- ->where('org_id',$this->bjOrgId)
- ->count();
- $orderCount = $oc1 + $oc2;
- $tc1= Db::name('todo')
- ->where('del',0)
- ->where('org_id','in',$this->orgs2)
- ->count();
- $tc2 = bjydb('todo')
- ->where('del',0)
- ->where('org_id',$this->bjOrgId)
- ->count();
- $todoCount = $tc1 + $tc2;
- $t1 = Db::name('patrol_task')
- ->where('del',0)
- ->where('org_id','in',$this->orgs2)
- ->count();
- $t2 = bjydb('patrol_task')
- ->where('del',0)
- ->where('org_id',$this->bjOrgId)
- ->count();
- $taskCount = $t1 + $t2;
- }elseif(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- $count = Db::name('org')->where('parent_id',1)->where('del',0)->where('enable',1)->where('type',1)->count();
- $count1 = Db::name('org')->where('del',0)->where('enable',1)->where('type',2)->count();
- $c1 = Db::name('user')
- ->alias('u')
- ->join('user_org uo','uo.user_id=u.id')
- ->join('org o','o.id=uo.org_id')
- ->where('u.del',0)
- ->where('u.type',0)
- ->where('o.enable',1)
- ->where('o.del',0)
- ->count();
- $c2 = gtspdb('user')
- ->alias('u')
- ->join('user_org uo','uo.USER_ID=u.USER_ID')
- ->where('u.DEL_REF',0)
- ->where('u.TYPE',0)
- ->where('uo.ORG_ID','in',$this->spOrgId)
- ->where('uo.ORG_TYPE',0)
- ->count();
- $c22 = bjydb('user')
- ->alias('u')
- ->join('user_org uo','uo.user_id=u.id')
- ->join('org o','o.id=uo.org_id')
- ->where('u.del',0)
- ->where('u.type',0)
- ->where('o.enable',1)
- ->where('o.del',0)
- ->where('o.id',$this->bjOrgId)
- ->count();
- $count2 = $c1 + $c2 + $c22;
- $oc1 = Db::name('orders')
- ->where('del',0)
- ->where('org_id','in',$this->orgs2)
- ->count();
- $oc2 = gtspdb('orders')
- ->where('DEL_REF',0)
- ->where('ORG_ID',$this->spOrgId)
- ->count();
- $oc3 = bjydb('orders')
- ->where('del',0)
- ->where('org_id',$this->bjOrgId)
- ->count();
- $orderCount = $oc1 + $oc2 + $oc3;
- $tc1= Db::name('todo')
- ->where('del',0)
- ->where('org_id','in',$this->orgs2)
- ->count();
- $tc2 = gtspdb('todo')
- ->where('DEL_REF',0)
- ->where('ORG_ID',$this->spOrgId)
- ->count();
- $tc3 = bjydb('todo')
- ->where('del',0)
- ->where('org_id',$this->bjOrgId)
- ->count();
- $todoCount = $tc1 + $tc2 + $tc3;
- $t1 = Db::name('patrol_task')
- ->where('del',0)
- ->where('org_id','in',$this->orgs2)
- ->count();
- $t2 = gtspdb('patrol_task')
- ->where('DEL_REF',0)
- ->where('ORG_ID',$this->spOrgId)
- ->count();
- $t3 = bjydb('patrol_task')
- ->where('del',0)
- ->where('org_id',$this->bjOrgId)
- ->count();
- $taskCount = $t1 + $t2 + $t3;
- }else{
- $count = Db::name('org')->where('parent_id',1)->where('del',0)->where('enable',1)->where('type',1)->count();
- $count1 = Db::name('org')->where('del',0)->where('enable',1)->where('type',2)->count();
- $count2 = Db::name('user')
- ->alias('u')
- ->join('user_org uo','uo.user_id=u.id')
- ->join('org o','o.id=uo.org_id')
- ->where('u.del',0)
- ->where('u.type',0)
- ->where('o.enable',1)
- ->where('o.del',0)
- ->count();
- $orderCount = Db::name('orders')
- ->where('del',0)
- ->count();
- $todoCount = Db::name('todo')
- ->where('del',0)
- ->count();
- $task1 = Db::name('patrol_task')
- ->where('del',0)
- ->count();
- $task2 = Db::name('device_task')
- ->where('del',0)
- ->count();
- $taskCount = $task1 + $task2;
- }
- $data = [
- 'count1'=>$count,
- 'count2'=>$count1,
- 'count3'=>$count2,
- 'count4'=>$orderCount,
- 'count5'=>$todoCount,
- 'count6'=>$taskCount,
- 'count7'=>23
- ];
- HelpHander::success($data);
- }
- public function cityList(){
- $org = Db::name('org')
- ->alias('o')
- ->field('o.city_id,c.title')
- ->join('city c','c.id=o.city_id')
- ->where('o.del',0)
- ->where('o.enable',1)
- ->where('o.type',2)
- ->group('o.city_id')
- ->select();
- foreach ($org as $k=>$v){
- $list = Db::name('org')->where('del',0)->where('enable',1)->where('type',2)->where('city_id',$v['city_id'])->select();
- foreach ($list as $kk=>$vv){
- $list[$kk]['id'] = think_encrypt($vv['id'].'|'.time());
- }
- $org[$k]['list'] = $list?$list:[];
- }
- HelpHander::success($org);
- }
- public function quarterScore(){
- $org = Db::name('org')
- ->field('id,name')
- ->where('parent_id',1)
- ->where('del',0)
- ->where('enable',1)
- ->where('type',1)
- ->select();
- foreach ($org as $k=>$v){
- $org[$k]['orgs'] = $this->getAllNextId($v['id']);
- }
- //获取当前季度
- $season = ceil((date('n'))/3);
- //当前季度开始时间戳
- $startTime = date('Y-m-d H:i:s', mktime(0,0,0,$season*3-3+1,1,date('Y')));
- //获取当前季度结束时间戳
- $overTime = date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0,0,0,$season*3,1,date("Y"))),date('Y')));
- $where[] = ['create_yyyymm','>=',date('Ym',strtotime($startTime))];
- $where[] = ['create_yyyymm','<=',date('Ym',strtotime($overTime))];
- $where2[] = ['CREATE_YYYYMM','>=',date('Ym',strtotime($startTime))];
- $where2[] = ['CREATE_YYYYMM','<=',date('Ym',strtotime($overTime))];
- foreach ($org as $k=>$v){
- if(in_array(3,$v['orgs']) && !in_array(24,$v['orgs'])){
- $c1 = gtspdb('comment')->where('ORG_ID',$this->spOrgId)->where($where2)->sum('SCORE');
- $c2 = Db::name('comment')->whereIn('org_id',$v['orgs'])->where('org_id','<>',3)->where($where)->sum('score');
- $org[$k]['score'] = $c1 + $c2;
- }elseif(!in_array(3,$v['orgs']) && in_array(24,$v['orgs'])){
- $c1 = bjydb('comment')->where('org_id',$this->bjOrgId)->where($where)->sum('SCORE');
- $c2 = Db::name('comment')->whereIn('org_id',$v['orgs'])->where('org_id','<>',3)->where($where)->sum('score');
- $org[$k]['score'] = $c1 + $c2;
- }elseif(in_array(3,$v['orgs']) && in_array(24,$v['orgs'])){
- $c1 = bjydb('comment')->where('org_id',$this->bjOrgId)->where($where)->sum('SCORE');
- $c2 = Db::name('comment')->whereIn('org_id',$v['orgs'])->where('org_id','<>',3)->where($where)->sum('score');
- $c3 = gtspdb('comment')->where('ORG_ID',$this->spOrgId)->where($where2)->sum('SCORE');
- $org[$k]['score'] = $c1 + $c2 + $c3;
- }else{
- $org[$k]['score'] = Db::name('comment')->whereIn('org_id',$v['orgs'])->where($where)->sum('score');
- }
- }
- $list = list_sort_by($org,'score','desc');
- $top1 = isset($list[0])?$list[0]:null;
- $top2 = isset($list[1])?$list[1]:null;
- $top3 = isset($list[2])?$list[2]:null;
- $top4 = isset($list[3])?$list[3]:null;
- $top5 = isset($list[4])?$list[4]:null;
- HelpHander::success(['top1'=>$top1,'top2'=>$top2,'top3'=>$top3,'top4'=>$top4,'top5'=>$top5]);
- }
- public function quarterScore2(){
- $map[] = ['del','=',0];
- $map[] = ['enable','=',1];
- $map[] = ['type','=',2];
- $org = Db::name('org')
- ->field('id,name')
- ->where('parent_id',1)
- ->where('del',0)
- ->where('enable',1)
- ->where('type',1)
- ->select();
- foreach ($org as $k=>$v){
- $org[$k]['orgs'] = $this->getAllNextId($v['id']);
- }
- //获取当前季度
- $season = ceil((date('n'))/3);
- //当前季度开始时间戳
- $startTime = date('Y-m-d H:i:s', mktime(0,0,0,$season*3-3+1,1,date('Y')));
- //获取当前季度结束时间戳
- $overTime = date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0,0,0,$season*3,1,date("Y"))),date('Y')));
- $where[] = ['create_yyyymm','>=',date('Ym',strtotime($startTime))];
- $where[] = ['create_yyyymm','<=',date('Ym',strtotime($overTime))];
- foreach ($org as $k=>$v){
- if(in_array(3,$v['orgs']) ){
- $org[$k]['price'] = 5.3;
- }else{
- $org[$k]['price'] = 0;
- }
- }
- $list = list_sort_by($org,'score','desc');
- $top1 = isset($list[0])?$list[0]:null;
- $top2 = isset($list[1])?$list[1]:null;
- $top3 = isset($list[2])?$list[2]:null;
- $top4 = isset($list[3])?$list[3]:null;
- $top5 = isset($list[4])?$list[4]:null;
- HelpHander::success(['top1'=>$top1,'top2'=>$top2,'top3'=>$top3,'top4'=>$top4,'top5'=>$top5]);
- }
- public function fcompanyList(){
- $map[] = ['del','=',0];
- $map[] = ['enable','=',1];
- $map[] = ['type','=',2];
- $org = Db::name('org')
- ->field('id,name')
- ->where('parent_id',1)
- ->where('del',0)
- ->where('enable',1)
- ->where('type',1)
- ->select();
- foreach ($org as $k=>$v){
- $org[$k]['orgs'] = $this->getAllNextId($v['id']);
- }
- $host = request()->domain(true);
- foreach ($org as $k=>$v){
- if(in_array(3,$v['orgs'])){
- $org[$k]['day'] = 256;
- $org[$k]['nums'] = 1;
- $org[$k]['nums2'] = 1;
- $org[$k]['bl'] = 100;
- $org[$k]['imgs'] = [
- $host.'/screen/images/nh1.png',
- $host.'/screen/images/nh2.png',
- $host.'/screen/images/nh3.png',
- ];
- }else{
- $org[$k]['day'] = 0;
- $org[$k]['nums'] = 0;
- $org[$k]['nums2'] = 0;
- $org[$k]['bl'] = 0;
- $org[$k]['imgs'] = [];
- }
- }
- HelpHander::success($org);
- }
- public function nlxhList(){
- $org = Db::name('org')
- ->field('id,name')
- ->where('parent_id',1)
- ->where('del',0)
- ->where('enable',1)
- ->where('type',1)
- ->select();
- foreach ($org as $k=>$v){
- $org[$k]['orgs'] = $this->getAllNextId($v['id']);
- if(isset($k) && $k==0){
- $org[$k]['value'] = 556;
- }else if(isset($k) && $k==1){
- $org[$k]['value'] = 875;
- }else if(isset($k) && $k==2){
- $org[$k]['value'] = 345;
- }else if(isset($k) && $k==3){
- $org[$k]['value'] = 234;
- }else if(isset($k) && $k==4){
- $org[$k]['value'] = 797;
- }else if(isset($k) && $k==5) {
- $org[$k]['value'] = 887;
- }
- }
- //获取当前季度
- $season = ceil((date('n'))/3);
- //当前季度开始时间戳
- $startTime = date('Y-m-d H:i:s', mktime(0,0,0,$season*3-3+1,1,date('Y')));
- //获取当前季度结束时间戳
- $overTime = date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0,0,0,$season*3,1,date("Y"))),date('Y')));
- $list = array_slice(list_sort_by($org,'value','desc'),0,5);
- HelpHander::success($list);
- }
- //巡查图片
- public function patrolImg(){
- if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
- $data = gtspdb('patrol_record')
- ->where('IMAGES','<>','')
- ->where('ORG_ID',$this->spOrgId)
- ->limit(20)
- ->order('PATROL_RECORD_ID desc')
- ->select();
- foreach ($data as $k=>$v){
- $img = explode(',',$v['IMAGES']);
- if($img){
- $data[$k]['images'] = $img[0];
- }
- }
- if(count($data)>2){
- $key = array_rand($data,3);
- $list[] = $data[$key[0]];
- $list[] = $data[$key[1]];
- $list[] = $data[$key[2]];
- }
- }elseif(!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- $data = bjydb('patrol_record')
- ->where('images','<>','')
- ->where('org_id',$this->bjOrgId)
- ->limit(20)
- ->order('id desc')
- ->select();
- foreach ($data as $k=>$v){
- $img = explode(',',$v['images']);
- if($img){
- $data[$k]['images'] = $img[0];
- }
- }
- if(count($data)>2){
- $key = array_rand($data,3);
- $list[] = $data[$key[0]];
- $list[] = $data[$key[1]];
- $list[] = $data[$key[2]];
- }
- }elseif(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- $data1 = bjydb('patrol_record')
- ->where('images','<>','')
- ->where('org_id',$this->bjOrgId)
- ->limit(20)
- ->order('id desc')
- ->select();
- foreach ($data1 as $k=>$v){
- $img = explode(',',$v['images']);
- if($img){
- $data1[$k]['images'] = $img[0];
- }
- }
- $data2 = gtspdb('patrol_record')
- ->where('IMAGES','<>','')
- ->where('ORG_ID',$this->spOrgId)
- ->limit(20)
- ->order('PATROL_RECORD_ID desc')
- ->select();
- foreach ($data2 as $k=>$v){
- $img = explode(',',$v['IMAGES']);
- if($img){
- $data2[$k]['images'] = $img[0];
- }
- }
- $data = array_merge($data1,$data2);
- if(count($data)>2){
- $key = array_rand($data,3);
- $list[] = $data[$key[0]];
- $list[] = $data[$key[1]];
- $list[] = $data[$key[2]];
- }
- }else{
- $data = Db::name('patrol_record')
- ->where('images','<>','')
- ->whereIn('org_id',$this->orgs2)
- ->limit(20)
- ->order('id desc')
- ->select();
- foreach ($data as $k=>$v){
- $img = explode(',',$v['images']);
- if($img){
- $data[$k]['images'] = $img[0];
- }
- }
- if(count($data)>2){
- $key = array_rand($data,3);
- $list[] = $data[$key[0]];
- $list[] = $data[$key[1]];
- $list[] = $data[$key[2]];
- }
- }
- $eList = isset($list)?$list:$data;
- HelpHander::success($eList);
- }
- public function patrolRecordList(){
- $dlist = [
- date('Y-m-d',strtotime('-6 days')),
- date('Y-m-d',strtotime('-5 days')),
- date('Y-m-d',strtotime('-4 days')),
- date('Y-m-d',strtotime('-3 days')),
- date('Y-m-d',strtotime('-2 days')),
- date('Y-m-d',strtotime('-1 days')),
- date('Y-m-d'),
- ];
- $date = [];
- $yCount = [];
- $y2Count = [];
- $y3Count = [];
- $y4Count = [];
- if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
- foreach ($dlist as $k=>$v){
- $tt = date('Ymd',strtotime($v));
- $c1 = gtspdb('patrol_record')
- ->where('ORG_ID',$this->spOrgId)
- ->where('CREATE_YYYYMMDD',$tt)
- ->where('PATROL_MODE',1)
- ->count();
- $c2 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs2)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',1)
- ->count();
- $count = $c1 + $c2;
- $c3 = gtspdb('patrol_record')
- ->where('ORG_ID',$this->spOrgId)
- ->where('CREATE_YYYYMMDD',$tt)
- ->where('PATROL_MODE',2)
- ->count();
- $c4 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs2)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',2)
- ->count();
- $count2 = $c3 + $c4;
- $c5 = gtspdb('patrol_record')
- ->where('ORG_ID',$this->spOrgId)
- ->where('CREATE_YYYYMMDD',$tt)
- ->where('PATROL_MODE',3)
- ->count();
- $c6 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs2)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',3)
- ->count();
- $count3 = $c5 + $c6;
- $c7 = gtspdb('patrol_record')
- ->where('ORG_ID',$this->spOrgId)
- ->where('CREATE_YYYYMMDD',$tt)
- ->where('PATROL_MODE',4)
- ->count();
- $c8 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',4)
- ->count();
- $count4 = $c7 + $c8;
- $date[] = date('m-d',strtotime($v));
- $yCount[] = $count;
- $y2Count[] = $count2;
- $y3Count[] = $count3;
- $y4Count[] = $count4;
- }
- }elseif(!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- foreach ($dlist as $k=>$v){
- $tt = date('Ymd',strtotime($v));
- $c1 = bjydb('patrol_record')
- ->where('org_id',$this->bjOrgId)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',1)
- ->count();
- $c2 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs2)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',1)
- ->count();
- $count = $c1 + $c2;
- $c3 = bjydb('patrol_record')
- ->where('org_id',$this->bjOrgId)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',2)
- ->count();
- $c4 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs2)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',2)
- ->count();
- $count2 = $c3 + $c4;
- $c5 = bjydb('patrol_record')
- ->where('org_id',$this->bjOrgId)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',3)
- ->count();
- $c6 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs2)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',3)
- ->count();
- $count3 = $c5 + $c6;
- $c7 = bjydb('patrol_record')
- ->where('org_id',$this->bjOrgId)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',1)
- ->count();
- $c8 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',4)
- ->count();
- $count4 = $c7 + $c8;
- $date[] = date('m-d',strtotime($v));
- $yCount[] = $count;
- $y2Count[] = $count2;
- $y3Count[] = $count3;
- $y4Count[] = $count4;
- }
- }elseif(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
- foreach ($dlist as $k=>$v){
- $tt = date('Ymd',strtotime($v));
- $c1 = gtspdb('patrol_record')
- ->where('ORG_ID',$this->spOrgId)
- ->where('CREATE_YYYYMMDD',$tt)
- ->where('PATROL_MODE',1)
- ->count();
- $c2 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs2)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',1)
- ->count();
- $c22 = bjydb('patrol_record')
- ->where('org_id',$this->bjOrgId)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',1)
- ->count();
- $count = $c1 + $c2 + $c22;
- $c3 = gtspdb('patrol_record')
- ->where('ORG_ID',$this->spOrgId)
- ->where('CREATE_YYYYMMDD',$tt)
- ->where('PATROL_MODE',2)
- ->count();
- $c4 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs2)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',2)
- ->count();
- $c44 = bjydb('patrol_record')
- ->where('org_id',$this->bjOrgId)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',2)
- ->count();
- $count2 = $c3 + $c4 + $c44;
- $c5 = gtspdb('patrol_record')
- ->where('ORG_ID',$this->spOrgId)
- ->where('CREATE_YYYYMMDD',$tt)
- ->where('PATROL_MODE',3)
- ->count();
- $c6 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs2)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',3)
- ->count();
- $c66 = bjydb('patrol_record')
- ->where('org_id',$this->bjOrgId)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',3)
- ->count();
- $count3 = $c5 + $c6 + $c66;
- $c7 = gtspdb('patrol_record')
- ->where('ORG_ID',$this->spOrgId)
- ->where('CREATE_YYYYMMDD',$tt)
- ->where('PATROL_MODE',4)
- ->count();
- $c8 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',4)
- ->count();
- $c88 = bjydb('patrol_record')
- ->where('org_id',$this->bjOrgId)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',4)
- ->count();
- $count4 = $c7 + $c8 + $c88;
- $date[] = date('m-d',strtotime($v));
- $yCount[] = $count;
- $y2Count[] = $count2;
- $y3Count[] = $count3;
- $y4Count[] = $count4;
- }
- }else{
- foreach ($dlist as $k=>$v){
- $tt = date('Ymd',strtotime($v));
- $count = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',1)
- ->count();
- $count2 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',2)
- ->count();
- $count3 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',3)
- ->count();
- $count4 = Db::name('patrol_record')
- ->whereIn('org_id',$this->orgs)
- ->where('create_yyyymmdd',$tt)
- ->where('patrol_mode',4)
- ->count();
- $date[] = date('m-d',strtotime($v));
- $yCount[] = $count;
- $y2Count[] = $count2;
- $y3Count[] = $count3;
- $y4Count[] = $count4;
- }
- }
- $data = [
- 'date'=>$date,
- 'count1'=>$yCount,
- 'count2'=>$y2Count,
- 'count3'=>$y3Count,
- 'count4'=>$y4Count,
- ];
- HelpHander::success($data);
- }
- // 获取所有下级的id集合
- public function getAllNextId($id,$data=[]){
- $pids = DB::name('org')->where('parent_id',$id)->column('id');
- if(count($pids)>0){
- foreach($pids as $v){
- $data[] = $v;
- $data = $this->getAllNextId($v,$data); //注意写$data 返回给上级
- }
- }
- if(count($data)>0){
- return $data;
- }else{
- return [];
- }
- }
- public function getOrgs(){
- $img1 = request()->domain(true).'/screen/images/hz01.png';
- $img2 = request()->domain(true).'/screen/images/hz02.png';
- $lists1 = [
- [
- 'id'=>think_encrypt('3|'.time()),
- 'title'=>'新乡市中心医院',
- 'img'=> $img1
- ],
- [
- // 'id'=>think_encrypt('24|'.time()),
- 'id'=>'',
- 'title'=>'医院1',
- 'img'=>$img2
- ],
- [
- // 'id'=>think_encrypt('26|'.time()),
- 'id'=>'',
- 'title'=>'医院2',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院3',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院4',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院5',
- 'img'=>$img2
- ],
- ];
- $lists2 = [
- [
- 'id'=>0,
- 'title'=>'医院11',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院12',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院13',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院14',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院15',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院16',
- 'img'=>$img2
- ],
- ];
- $lists3 = [
- [
- 'id'=>0,
- 'title'=>'医院12',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院13',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院14',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院15',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院16',
- 'img'=>$img2
- ],
- ];
- $lists4 = [
- [
- 'id'=>0,
- 'title'=>'医院6',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院7',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院8',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院9',
- 'img'=>$img2
- ],
- [
- 'id'=>0,
- 'title'=>'医院10',
- 'img'=>$img2
- ],
- ];
- HelpHander::success([
- 'lists1'=>$lists1,
- 'lists2'=>$lists2,
- 'lists3'=>$lists3,
- 'lists4'=>$lists4,
- ]);
- }
- public function dailyData(){
- $lists = [
- [
- 'id'=>2,
- 'title'=>'济南',
- ],
- [
- 'id'=>8,
- 'title'=>'青岛',
- ],
- [
- 'id'=>10,
- 'title'=>'烟台',
- ],
- [
- 'id'=>11,
- 'title'=>'威海',
- ],
- [
- 'id'=>12,
- 'title'=>'东营',
- ],
- [
- 'id'=>13,
- 'title'=>' 淄博',
- ],
- ];
- $orgs = [];
- $pzdata = [];
- $rwdata = [];
- $max = 0;
- foreach ($lists as $k=>$v){
- $map = [];
- $orgs[] = $v['title'];
- if($v['id'] == 0){
- $pzdata[] = mt_rand(0,10);
- $rwdata[] = mt_rand(0,$max);
- }else{
- $orgIds = $this->getAllNextId($v['id'],[]);
- if($orgIds){
- $map[] = ['org_id','in',$orgIds];
- }else{
- $map[] = ['org_id','=',-1];
- }
- $pzcount = Db::name('daily_record')->where($map)->where('order_id','>',0)->count();
- $pzdata[] = $pzcount;
- $rwcount = Db::name('daily_record')->where($map)->count();
- if($rwcount > $max){
- $max = $rwcount;
- }
- $rwdata[] = $rwcount;
- }
- }
- HelpHander::success([
- 'orgs'=>$orgs,
- 'pzdata'=>$pzdata,
- 'rwdata'=>$rwdata,
- ]);
- }
- public function todoData(){
- $lists = [
- [
- 'id'=>2,
- 'title'=>'济南',
- ],
- [
- 'id'=>8,
- 'title'=>'青岛',
- ],
- [
- 'id'=>10,
- 'title'=>'烟台',
- ],
- [
- 'id'=>11,
- 'title'=>'威海',
- ],
- [
- 'id'=>12,
- 'title'=>'东营',
- ],
- [
- 'id'=>13,
- 'title'=>' 淄博',
- ],
- ];
- $orgs = [];
- $y1 = [];
- $y2 = [];
- $max1 = 0;
- $max2 = 0;
- foreach ($lists as $k=>$v){
- $map = [];
- $orgs[] = $v['title'];
- if($v['id'] == 0){
- $y1[] = mt_rand(0,$max1);
- $y2[] = mt_rand(0,$max2);
- }else{
- $orgIds = $this->getAllNextId($v['id'],[]);
- if($orgIds){
- $map[] = ['org_id','in',$orgIds];
- }else{
- $map[] = ['org_id','=',-1];
- }
- $pzcount = Db::name('todo')->where($map)->where('todo_mode',3)->where('del',0)->count();
- $xycount = Db::name('todo')->where($map)->where('todo_mode',3)->where('del',0)->sum('xy_time');
- $wccount = Db::name('todo')->where($map)->where('todo_mode',3)->where('del',0)->sum('wc_time');
- $y2c = $pzcount>0?round(($xycount/60)/$pzcount,1):0;
- $y2[] = $y2c;
- if($y2c > $max2){
- $max2 = $y2c;
- }
- $y1c = $pzcount>0?round(($wccount/60)/$pzcount,1):0;
- $y1[] = $y1c;
- if($y1c > $max1){
- $max1 = $y1c;
- }
- }
- }
- HelpHander::success([
- 'orgs'=>$orgs,
- 'y1'=>$y1,
- 'y2'=>$y2,
- ]);
- }
- }
|