Onelevel.php 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764
  1. <?php
  2. namespace app\api\controller\screen;
  3. use app\hander\HelpHander;
  4. use think\Controller;
  5. use think\Db;
  6. use think\helper\Str;
  7. use think\Request;
  8. class Onelevel extends Controller{
  9. private $orgs = []; // 用户拥有的组织id集合,只区分大区管理员和总公司
  10. private $orgName = ''; //大区名称
  11. //取组合数组
  12. private $spOrgId = 5; //国天sp 厦门中山医院
  13. private $orgs2 = []; //去除研发中心id 有研发中心 取国天sp 厦门中山医院
  14. private $bjOrgId = 11; //霸洁云 贵州省黔西市人民医院
  15. protected function initialize()
  16. {
  17. parent::initialize();
  18. $token = input('token','','trim');
  19. $token = think_decrypt($token);
  20. if(!$token){
  21. HelpHander::success("无权限");
  22. }
  23. // $ts = explode('|',$token);
  24. // if($ts[1] != config('app.ucode')){
  25. // HelpHander::success("无权限");
  26. // }
  27. $map[] = ['type','=',2];
  28. $map[] = ['del','=',0];
  29. $map[] = ['enable','=',1];
  30. $orgids = Db::name('org')
  31. ->where($map)
  32. ->column('id');
  33. $this->orgs = $orgids?$orgids:[-1];
  34. foreach ($orgids as $k=>$v){
  35. if($v == 3){
  36. unset($orgids[$k]);
  37. }elseif($v == 24){
  38. unset($orgids[$k]);
  39. }
  40. }
  41. $this->orgs2 = array_values($orgids);
  42. }
  43. public function todayTodoInfo(){
  44. $date = date('Ymd');
  45. if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
  46. $map[] = ['CREATE_YYYYMMDD','=',$date];
  47. $map[] = ['DEL_REF','=',0];
  48. $count0 = gtspdb('todo')->where($map)->where('ORG_ID',$this->spOrgId)->count();
  49. $where[] = ['create_yyyymmdd','=',$date];
  50. $where[] = ['del','=',0];
  51. $count1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
  52. $count = $count0 + $count1;
  53. $map[] = ['TODO_MODE','=',3];
  54. $where[] = ['todo_mode','=',3];
  55. $overCount0 = gtspdb('todo')->where($map)->where('ORG_ID',$this->spOrgId)->count();
  56. $overCount1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
  57. $overCount = $overCount0+$overCount1;
  58. $list = [0,0,0,0,0,0];
  59. $overBl = 0;
  60. if($count > 0){
  61. $overBl = round($overCount/$count*100,0);
  62. $len = strlen($count);
  63. if($len == 1){
  64. $count = '00000'.$count;
  65. }elseif($len == 2){
  66. $count = '0000'.$count;
  67. }elseif($len == 3){
  68. $count = '000'.$count;
  69. }elseif($len == 4){
  70. $count = '00'.$count;
  71. }elseif($len == 5){
  72. $count = '0'.$count;
  73. }else{
  74. $count = '999999';
  75. }
  76. $list = str_split($count);
  77. }
  78. }elseif (!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  79. $map[] = ['create_yyyymmdd','=',$date];
  80. $map[] = ['del','=',0];
  81. $count0 = bjydb('todo')->where($map)->where('org_id',$this->bjOrgId)->count();
  82. $where[] = ['create_yyyymmdd','=',$date];
  83. $where[] = ['del','=',0];
  84. $count1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
  85. $count = $count0 + $count1;
  86. $map[] = ['todo_mode','=',3];
  87. $where[] = ['todo_mode','=',3];
  88. $overCount0 = bjydb('todo')->where($map)->where('org_id',$this->bjOrgId)->count();
  89. $overCount1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
  90. $overCount = $overCount0+$overCount1;
  91. $list = [0,0,0,0,0,0];
  92. $overBl = 0;
  93. if($count > 0){
  94. $overBl = round($overCount/$count*100,0);
  95. $len = strlen($count);
  96. if($len == 1){
  97. $count = '00000'.$count;
  98. }elseif($len == 2){
  99. $count = '0000'.$count;
  100. }elseif($len == 3){
  101. $count = '000'.$count;
  102. }elseif($len == 4){
  103. $count = '00'.$count;
  104. }elseif($len == 5){
  105. $count = '0'.$count;
  106. }else{
  107. $count = '999999';
  108. }
  109. $list = str_split($count);
  110. }
  111. }else if(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  112. $map[] = ['CREATE_YYYYMMDD','=',$date];
  113. $map[] = ['DEL_REF','=',0];
  114. $count0 = gtspdb('todo')->where($map)->where('ORG_ID',$this->spOrgId)->count();
  115. $where[] = ['create_yyyymmdd','=',$date];
  116. $where[] = ['del','=',0];
  117. $count1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
  118. $count2 = bjydb('todo')->where($where)->whereIn('org_id',$this->bjOrgId)->count();
  119. $count = $count0 + $count1 + $count2;
  120. $map[] = ['TODO_MODE','=',3];
  121. $where[] = ['todo_mode','=',3];
  122. $overCount0 = gtspdb('todo')->where($map)->where('ORG_ID',$this->spOrgId)->count();
  123. $overCount1 = Db::name('todo')->where($where)->whereIn('org_id',$this->orgs2)->count();
  124. $overCount2 = bjydb('todo')->where($where)->where('org_id',$this->bjOrgId)->count();
  125. $overCount = $overCount0+$overCount1+$overCount2;
  126. $list = [0,0,0,0,0,0];
  127. $overBl = 0;
  128. if($count > 0){
  129. $overBl = round($overCount/$count*100,0);
  130. $len = strlen($count);
  131. if($len == 1){
  132. $count = '00000'.$count;
  133. }elseif($len == 2){
  134. $count = '0000'.$count;
  135. }elseif($len == 3){
  136. $count = '000'.$count;
  137. }elseif($len == 4){
  138. $count = '00'.$count;
  139. }elseif($len == 5){
  140. $count = '0'.$count;
  141. }else{
  142. $count = '999999';
  143. }
  144. $list = str_split($count);
  145. }
  146. }else{
  147. $map[] = ['create_yyyymmdd','=',$date];
  148. $map[] = ['del','=',0];
  149. $count = Db::name('todo')->where($map)->where('org_id','in',$this->orgs)->count();
  150. $map[] = ['todo_mode','=',3];
  151. $overCount = Db::name('todo')->where($map)->where('org_id','in',$this->orgs)->count();
  152. $list = [0,0,0,0,0,0];
  153. $overBl = 0;
  154. if($count > 0){
  155. $overBl = round($overCount/$count*100,0);
  156. $len = strlen($count);
  157. if($len == 1){
  158. $count = '00000'.$count;
  159. }elseif($len == 2){
  160. $count = '0000'.$count;
  161. }elseif($len == 3){
  162. $count = '000'.$count;
  163. }elseif($len == 4){
  164. $count = '00'.$count;
  165. }elseif($len == 5){
  166. $count = '0'.$count;
  167. }else{
  168. $count = '999999';
  169. }
  170. $list = str_split($count);
  171. }
  172. }
  173. $data = [
  174. 'list'=>$list,
  175. 'bl'=>$overBl
  176. ];
  177. HelpHander::success($data);
  178. }
  179. public function todayTodoType(){
  180. $date = date('Ymd');
  181. $map[] = ['create_yyyymmdd','=',$date];
  182. $map[] = ['del','=',0];
  183. if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
  184. $map[] = ['create_yyyymmdd','=',$date];
  185. $map[] = ['del','=',0];
  186. $map[] = ['org_id','in',$this->orgs2];
  187. $where[] = ['CREATE_YYYYMMDD','=',$date];
  188. $where[] = ['ORG_ID','=',$this->spOrgId];
  189. $where[] = ['DEL_REF','=',0];
  190. $c1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
  191. $c2 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',1)->count();
  192. $count = $c1 + $c2;
  193. $c3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
  194. $c4 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',2)->count();
  195. $count2 = $c3 + $c4;
  196. $c5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
  197. $c6 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',3)->count();
  198. $count3 = $c5 + $c6;
  199. $c7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
  200. $c8 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',4)->count();
  201. $count4 = $c7 + $c8;
  202. $map[] = ['todo_mode','=',3];
  203. $where[] = ['TODO_MODE','=',3];
  204. //保修
  205. $o1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
  206. $o2 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',1)->count();
  207. $bxCount = $o1 + $o2;
  208. //保洁
  209. $o3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
  210. $o4 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',2)->count();
  211. $bjCount = $o3 + $o4;
  212. //运送
  213. $o5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
  214. $o6 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',3)->count();
  215. $ysCount = $o5 + $o6;
  216. //隐患
  217. $o7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
  218. $o8 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',4)->count();
  219. $yhCount = $o7 + $o8;
  220. }else if(!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  221. $map[] = ['create_yyyymmdd','=',$date];
  222. $map[] = ['del','=',0];
  223. $map[] = ['org_id','in',$this->orgs2];
  224. $where[] = ['create_yyyymmdd','=',$date];
  225. $where[] = ['del','=',0];
  226. $where[] = ['org_id','=',$this->bjOrgId];
  227. $c1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
  228. $c2 = bjydb('todo')->where($where)->where('work_type_mode',1)->count();
  229. $count = $c1 + $c2;
  230. $c3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
  231. $c4 = bjydb('todo')->where($where)->where('work_type_mode',2)->count();
  232. $count2 = $c3 + $c4;
  233. $c5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
  234. $c6 = bjydb('todo')->where($where)->where('work_type_mode',3)->count();
  235. $count3 = $c5 + $c6;
  236. $c7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
  237. $c8 = bjydb('todo')->where($where)->where('work_type_mode',4)->count();
  238. $count4 = $c7 + $c8;
  239. $map[] = ['todo_mode','=',3];
  240. $where[] = ['todo_mode','=',3];
  241. //保修
  242. $o1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
  243. $o2 = bjydb('todo')->where($where)->where('work_type_mode',1)->count();
  244. $bxCount = $o1 + $o2;
  245. //保洁
  246. $o3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
  247. $o4 = bjydb('todo')->where($where)->where('work_type_mode',2)->count();
  248. $bjCount = $o3 + $o4;
  249. //运送
  250. $o5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
  251. $o6 = bjydb('todo')->where($where)->where('work_type_mode',3)->count();
  252. $ysCount = $o5 + $o6;
  253. //隐患
  254. $o7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
  255. $o8 = bjydb('todo')->where($where)->where('work_type_mode',4)->count();
  256. $yhCount = $o7 + $o8;
  257. }elseif(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  258. $map[] = ['create_yyyymmdd','=',$date];
  259. $map[] = ['del','=',0];
  260. $map[] = ['org_id','in',$this->orgs2];
  261. $where[] = ['CREATE_YYYYMMDD','=',$date];
  262. $where[] = ['ORG_ID','=',$this->spOrgId];
  263. $where[] = ['DEL_REF','=',0];
  264. $map2[] = ['create_yyyymmdd','=',$date];
  265. $map2[] = ['del','=',0];
  266. $map2[] = ['org_id','in',$this->bjOrgId];
  267. $c1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
  268. $c2 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',1)->count();
  269. $c22 = bjydb('todo')->where($map2)->where('work_type_mode',1)->count();
  270. $count = $c1 + $c2 + $c22;
  271. $c3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
  272. $c4 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',2)->count();
  273. $c44 = bjydb('todo')->where($map2)->where('work_type_mode',2)->count();
  274. $count2 = $c3 + $c4 + $c44;
  275. $c5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
  276. $c6 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',3)->count();
  277. $c66 = bjydb('todo')->where($map2)->where('work_type_mode',3)->count();
  278. $count3 = $c5 + $c6 + $c66;
  279. $c7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
  280. $c8 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',4)->count();
  281. $c88 = bjydb('todo')->where($map2)->where('work_type_mode',4)->count();
  282. $count4 = $c7 + $c8 + $c88;
  283. $map[] = ['todo_mode','=',3];
  284. $where[] = ['TODO_MODE','=',3];
  285. $map2[] = ['todo_mode','=',3];
  286. //保修
  287. $o1 = Db::name('todo')->where($map)->where('work_type_mode',1)->count();
  288. $o2 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',1)->count();
  289. $o22 = bjydb('todo')->where($map2)->where('work_type_mode',1)->count();
  290. $bxCount = $o1 + $o2 + $o22;
  291. //保洁
  292. $o3 = Db::name('todo')->where($map)->where('work_type_mode',2)->count();
  293. $o4 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',2)->count();
  294. $o44 = bjydb('todo')->where($map2)->where('work_type_mode',2)->count();
  295. $bjCount = $o3 + $o4 + $o44;
  296. //运送
  297. $o5 = Db::name('todo')->where($map)->where('work_type_mode',3)->count();
  298. $o6 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',3)->count();
  299. $o66 = bjydb('todo')->where($map2)->where('work_type_mode',3)->count();
  300. $ysCount = $o5 + $o6 + $o66;
  301. //隐患
  302. $o7 = Db::name('todo')->where($map)->where('work_type_mode',4)->count();
  303. $o8 = gtspdb('todo')->where($where)->where('WORK_TYPE_MODE',4)->count();
  304. $o88 = bjydb('todo')->where($map2)->where('work_type_mode',4)->count();
  305. $yhCount = $o7 + $o8 + $o88;
  306. }else{
  307. $map[] = ['create_yyyymmdd','=',$date];
  308. $map[] = ['del','=',0];
  309. $count = Db::name('todo')->where($map)->where('work_type_mode',1)->where('org_id','in',$this->orgs)->count();
  310. $count2 = Db::name('todo')->where($map)->where('work_type_mode',2)->where('org_id','in',$this->orgs)->count();
  311. $count3 = Db::name('todo')->where($map)->where('work_type_mode',3)->where('org_id','in',$this->orgs)->count();
  312. $count4 = Db::name('todo')->where($map)->where('work_type_mode',4)->where('org_id','in',$this->orgs)->count();
  313. $map[] = ['todo_mode','=',3];
  314. //保修
  315. $bxCount = Db::name('todo')->where($map)->where('work_type_mode',1)->where('org_id','in',$this->orgs)->count();
  316. //保洁
  317. $bjCount = Db::name('todo')->where($map)->where('work_type_mode',2)->where('org_id','in',$this->orgs)->count();
  318. //运送
  319. $ysCount = Db::name('todo')->where($map)->where('work_type_mode',3)->where('org_id','in',$this->orgs)->count();
  320. //隐患
  321. $yhCount = Db::name('todo')->where($map)->where('work_type_mode',4)->where('org_id','in',$this->orgs)->count();
  322. }
  323. $bxBl = $bjBl = $ysBl = $yhBl =0;
  324. if($count > 0){
  325. $bxBl = round($bxCount/$count*100,0);
  326. }
  327. if($count2 >0){
  328. $bjBl = round($bjCount/$count2*100,0);
  329. }
  330. if($count3 >0){
  331. $ysBl = round($ysCount/$count3*100,0);
  332. }
  333. if($count4 >0){
  334. $yhBl = round($yhCount/$count4*100,0);
  335. }
  336. $data = [
  337. 'bx'=>['count'=>$bxCount,'bl'=>$bxBl],
  338. 'bj'=>['count'=>$bjCount,'bl'=>$bjBl],
  339. 'ys'=>['count'=>$ysCount,'bl'=>$ysBl],
  340. 'yh'=>['count'=>$yhCount,'bl'=>$yhBl],
  341. ];
  342. HelpHander::success($data);
  343. }
  344. public function moduleList(){
  345. if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
  346. $map[] = ['del','=',0];
  347. $map[] = ['enable','=',1];
  348. $map[] = ['type','=',2];
  349. $orgList = Db::name('org')
  350. ->field('id,name')
  351. ->where('id','in',$this->orgs2)
  352. ->where($map)
  353. ->select();
  354. $bxCount = $bjCount = $ysCount = $yhCount = $pzCount = $xgCount = $phCount = 0;
  355. foreach ($orgList as $k=>$v){
  356. $bx = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',1)->find();
  357. if($bx){
  358. $bxCount += 1;
  359. }
  360. $bj = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',2)->find();
  361. if($bj){
  362. $bjCount += 1;
  363. }
  364. $ys = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',3)->find();
  365. if($ys){
  366. $ysCount += 1;
  367. }
  368. $yh = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',4)->find();
  369. if($yh){
  370. $yhCount += 1;
  371. }
  372. $xg = Db::name('patrol_record')->where('org_id',$v['id'])->where('patrol_mode',1)->count();
  373. if($xg){
  374. $xgCount += 1;
  375. }
  376. $pzCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',15)->count();
  377. $phCount = Db::name('ph_todo')->where('org_id',$v['id'])->count();
  378. }
  379. $bx = gtspdb('todo')->where('ORG_ID',$this->spOrgId)->where('DEL_REF',0)->where('WORK_TYPE_MODE',1)->count();
  380. $bj = gtspdb('todo')->where('ORG_ID',$this->spOrgId)->where('DEL_REF',0)->where('WORK_TYPE_MODE',2)->count();
  381. $ys = gtspdb('todo')->where('ORG_ID',$this->spOrgId)->where('DEL_REF',0)->where('WORK_TYPE_MODE',3)->count();
  382. $yh = gtspdb('todo')->where('ORG_ID',$this->spOrgId)->where('DEL_REF',0)->where('WORK_TYPE_MODE',4)->count();
  383. $xg = gtspdb('patrol_record')->where('ORG_ID',$this->spOrgId)->where('PATROL_MODE',1)->count();
  384. $data = [
  385. ['name'=>'保修','value'=>$bxCount+$bx],
  386. ['name'=>'保洁','value'=>$bjCount+$bj],
  387. ['name'=>'运送','value'=>$ysCount+$ys],
  388. ['name'=>'隐患预警','value'=>$yhCount+$yh],
  389. ['name'=>'巡更','value'=>$xgCount+$xg],
  390. ['name'=>'陪护','value'=>$phCount],
  391. ['name'=>'品质整改','value'=>$pzCount],
  392. ];
  393. }elseif(!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  394. $map[] = ['del','=',0];
  395. $map[] = ['enable','=',1];
  396. $map[] = ['type','=',2];
  397. $orgList = Db::name('org')
  398. ->field('id,name')
  399. ->where('id','in',$this->orgs2)
  400. ->where($map)
  401. ->select();
  402. $bxCount = $bjCount = $ysCount = $yhCount = $pzCount = $xgCount = $phCount = 0;
  403. foreach ($orgList as $k=>$v){
  404. $bxCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',1)->count();
  405. $bjCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',2)->count();
  406. $ysCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',3)->count();
  407. $yhCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',4)->count();
  408. $xgCount = Db::name('patrol_record')->where('org_id',$v['id'])->where('patrol_mode',1)->count();
  409. $pzCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',15)->count();
  410. $phCount = Db::name('ph_todo')->where('org_id',$v['id'])->count();
  411. }
  412. $bx = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',1)->count();
  413. $bj = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',2)->count();
  414. $ys = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',3)->count();
  415. $yh = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',4)->count();
  416. $xg = bjydb('patrol_record')->where('org_id',$this->bjOrgId)->where('patrol_mode',1)->count();
  417. $data = [
  418. ['name'=>'保修','value'=>$bxCount+$bx],
  419. ['name'=>'保洁','value'=>$bjCount+$bj],
  420. ['name'=>'运送','value'=>$ysCount+$ys],
  421. ['name'=>'隐患预警','value'=>$yhCount+$yh],
  422. ['name'=>'巡更','value'=>$xgCount+$xg],
  423. ['name'=>'陪护','value'=>$phCount],
  424. ['name'=>'品质整改','value'=>$pzCount],
  425. ];
  426. }elseif(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  427. $map[] = ['del','=',0];
  428. $map[] = ['enable','=',1];
  429. $map[] = ['type','=',2];
  430. $orgList = Db::name('org')
  431. ->field('id,name')
  432. ->where('id','in',$this->orgs2)
  433. ->where($map)
  434. ->select();
  435. $bxCount = $bjCount = $ysCount = $yhCount = $pzCount = $xgCount = $phCount = 0;
  436. foreach ($orgList as $k=>$v){
  437. $bxCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',1)->count();
  438. $bjCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',2)->count();
  439. $ysCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',3)->count();
  440. $yhCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',4)->count();
  441. $xgCount = Db::name('patrol_record')->where('org_id',$v['id'])->where('patrol_mode',1)->count();
  442. $pzCount = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',15)->count();
  443. $phCount = Db::name('ph_todo')->where('org_id',$v['id'])->count();
  444. }
  445. $bx = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',1)->count();
  446. $bj = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',2)->count();
  447. $ys = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',3)->count();
  448. $yh = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',4)->count();
  449. $xg = bjydb('patrol_record')->where('org_id',$this->bjOrgId)->where('patrol_mode',1)->count();
  450. $bx2 = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',1)->count();
  451. $bj2 = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',2)->count();
  452. $ys2 = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',3)->count();
  453. $yh2 = bjydb('todo')->where('org_id',$this->bjOrgId)->where('del',0)->where('work_type_mode',4)->count();
  454. $xg2 = bjydb('patrol_record')->where('org_id',$this->bjOrgId)->where('patrol_mode',1)->count();
  455. $data = [
  456. ['name'=>'保修','value'=>$bxCount+$bx+$bx2],
  457. ['name'=>'保洁','value'=>$bjCount+$bj+$bj2],
  458. ['name'=>'运送','value'=>$ysCount+$ys+$ys2],
  459. ['name'=>'隐患预警','value'=>$yhCount+$yh+$yh2],
  460. ['name'=>'巡更','value'=>$xgCount+$xg+$xg2],
  461. ['name'=>'陪护','value'=>$phCount],
  462. ['name'=>'品质整改','value'=>$pzCount],
  463. ];
  464. }else{
  465. $map[] = ['del','=',0];
  466. $map[] = ['enable','=',1];
  467. $map[] = ['type','=',2];
  468. $orgList = Db::name('org')
  469. ->field('id,name')
  470. ->where('id','in',$this->orgs)
  471. ->where($map)
  472. ->select();
  473. $bxCount = $bjCount = $ysCount = $yhCount = $pzCount = $xgCount = $phCount = 0;
  474. foreach ($orgList as $k=>$v){
  475. $bx = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',1)->find();
  476. if($bx){
  477. $bxCount += 1;
  478. }
  479. $bj = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',2)->find();
  480. if($bj){
  481. $bjCount += 1;
  482. }
  483. $ys = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',3)->find();
  484. if($ys){
  485. $ysCount += 1;
  486. }
  487. $yh = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',4)->find();
  488. if($yh){
  489. $yhCount += 1;
  490. }
  491. $pz = Db::name('todo')->where('org_id',$v['id'])->where('del',0)->where('work_type_mode',15)->find();
  492. if($pz){
  493. $pzCount += 1;
  494. }
  495. $xg = Db::name('patrol_record')->where('org_id',$v['id'])->where('patrol_mode',1)->count();
  496. if($xg){
  497. $xgCount += 1;
  498. }
  499. $ph = Db::name('ph_todo')->where('org_id',$v['id'])->count();
  500. if($ph){
  501. $phCount += 1;
  502. }
  503. }
  504. $data = [
  505. ['name'=>'保修','value'=>$bxCount],
  506. ['name'=>'保洁','value'=>$bjCount],
  507. ['name'=>'运送','value'=>$ysCount],
  508. ['name'=>'隐患预警','value'=>$yhCount],
  509. ['name'=>'品质整改','value'=>$pzCount],
  510. ['name'=>'巡更','value'=>$xgCount],
  511. ['name'=>'陪护','value'=>$phCount],
  512. ];
  513. }
  514. HelpHander::success($data);
  515. }
  516. public function commentComplainList(){
  517. $date = [
  518. date('Y',strtotime('-5 years')),
  519. date('Y',strtotime('-4 years')),
  520. date('Y',strtotime('-3 years')),
  521. date('Y',strtotime('-2 years')),
  522. date('Y',strtotime('-1 years')),
  523. date('Y'),
  524. ];
  525. $list = $list2 = [];
  526. if(in_array(3,$this->orgs) && in_array(24,$this->orgs) ){
  527. foreach ($date as $k=>$v){
  528. $c1 = Db::name('comment')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->sum('score');
  529. $c2 = gtspdb('comment')->where('ORG_ID',$this->spOrgId)->where('CREATE_YYYY',$v)->sum('SCORE');
  530. $c22 = bjydb('comment')->where('org_id',$this->bjOrgId)->where('create_yyyy',$v)->sum('score');
  531. $list[] = $c1+$c2+$c22;
  532. $c3 = Db::name('complain')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->where('del',0)->count();
  533. $c4 = gtspdb('complain')->where('ORG_ID',$this->spOrgId)->where('CREATE_YYYY',$v)->where('DEL_REF',0)->count();
  534. $c44 = bjydb('complain')->where('org_id',$this->bjOrgId)->where('create_yyyy',$v)->where('del',0)->count();
  535. $list2[] = $c3+$c4+$c44;
  536. }
  537. }elseif(in_array(3,$this->orgs) && !in_array(24,$this->orgs) ){
  538. foreach ($date as $k=>$v){
  539. $c1 = Db::name('comment')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->sum('score');
  540. $c2 = gtspdb('comment')->where('ORG_ID',$this->spOrgId)->where('CREATE_YYYY',$v)->sum('SCORE');
  541. $list[] = $c1+$c2;
  542. $c3 = Db::name('complain')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->where('del',0)->count();
  543. $c4 = gtspdb('complain')->where('ORG_ID',$this->spOrgId)->where('CREATE_YYYY',$v)->where('DEL_REF',0)->count();
  544. $list2[] = $c3+$c4;
  545. }
  546. }elseif(!in_array(3,$this->orgs) && in_array(24,$this->orgs) ){
  547. foreach ($date as $k=>$v){
  548. $c1 = Db::name('comment')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->sum('score');
  549. $c2 = bjydb('comment')->where('org_id',$this->bjOrgId)->where('create_yyyy',$v)->sum('score');
  550. $list[] = $c1+$c2;
  551. $c3 = Db::name('complain')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->where('del',0)->count();
  552. $c4 = bjydb('complain')->where('org_id',$this->bjOrgId)->where('create_yyyy',$v)->where('del',0)->count();
  553. $list2[] = $c3+$c4;
  554. }
  555. }else{
  556. foreach ($date as $k=>$v){
  557. $list[] = Db::name('comment')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->sum('score');
  558. $list2[] = Db::name('complain')->where('org_id','in',$this->orgs2)->where('create_yyyy',$v)->where('del',0)->count();
  559. }
  560. }
  561. $data = [
  562. 'title'=>$date,
  563. 'list1'=>$list,
  564. 'list2'=>$list2,
  565. ];
  566. HelpHander::success($data);
  567. }
  568. public function projectCount(){
  569. if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
  570. $count = Db::name('org')->where('parent_id',1)->where('del',0)->where('enable',1)->where('type',1)->count();
  571. $count1 = Db::name('org')->where('del',0)->where('enable',1)->where('type',2)->count();
  572. $c1 = Db::name('user')
  573. ->alias('u')
  574. ->join('user_org uo','uo.user_id=u.id')
  575. ->join('org o','o.id=uo.org_id')
  576. ->where('u.del',0)
  577. ->where('u.type',0)
  578. ->where('o.enable',1)
  579. ->where('o.del',0)
  580. ->count();
  581. $c2 = gtspdb('user')
  582. ->alias('u')
  583. ->join('user_org uo','uo.USER_ID=u.USER_ID')
  584. ->where('u.DEL_REF',0)
  585. ->where('u.TYPE',0)
  586. ->where('uo.ORG_ID','in',$this->spOrgId)
  587. ->where('uo.ORG_TYPE',0)
  588. ->count();
  589. $count2 = $c1 + $c2;
  590. $oc1 = Db::name('orders')
  591. ->where('del',0)
  592. ->where('org_id','in',$this->orgs2)
  593. ->count();
  594. $oc2 = gtspdb('orders')
  595. ->where('DEL_REF',0)
  596. ->where('ORG_ID',$this->spOrgId)
  597. ->count();
  598. $orderCount = $oc1 + $oc2;
  599. $tc1= Db::name('todo')
  600. ->where('del',0)
  601. ->where('org_id','in',$this->orgs2)
  602. ->count();
  603. $tc2 = gtspdb('todo')
  604. ->where('DEL_REF',0)
  605. ->where('ORG_ID',$this->spOrgId)
  606. ->count();
  607. $todoCount = $tc1 + $tc2;
  608. $t1 = Db::name('patrol_task')
  609. ->where('del',0)
  610. ->where('org_id','in',$this->orgs2)
  611. ->count();
  612. $t2 = gtspdb('patrol_task')
  613. ->where('DEL_REF',0)
  614. ->where('ORG_ID',$this->spOrgId)
  615. ->count();
  616. $taskCount = $t1 + $t2;
  617. }elseif(!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  618. $count = Db::name('org')->where('parent_id',1)->where('del',0)->where('enable',1)->where('type',1)->count();
  619. $count1 = Db::name('org')->where('del',0)->where('enable',1)->where('type',2)->count();
  620. $c1 = Db::name('user')
  621. ->alias('u')
  622. ->join('user_org uo','uo.user_id=u.id')
  623. ->join('org o','o.id=uo.org_id')
  624. ->where('u.del',0)
  625. ->where('u.type',0)
  626. ->where('o.enable',1)
  627. ->where('o.del',0)
  628. ->count();
  629. $c2 = bjydb('user')
  630. ->alias('u')
  631. ->join('user_org uo','uo.user_id=u.id')
  632. ->join('org o','o.id=uo.org_id')
  633. ->where('u.del',0)
  634. ->where('u.type',0)
  635. ->where('o.enable',1)
  636. ->where('o.del',0)
  637. ->where('o.id',$this->bjOrgId)
  638. ->count();
  639. $count2 = $c1 + $c2;
  640. $oc1 = Db::name('orders')
  641. ->where('del',0)
  642. ->where('org_id','in',$this->orgs2)
  643. ->count();
  644. $oc2 = bjydb('orders')
  645. ->where('del',0)
  646. ->where('org_id',$this->bjOrgId)
  647. ->count();
  648. $orderCount = $oc1 + $oc2;
  649. $tc1= Db::name('todo')
  650. ->where('del',0)
  651. ->where('org_id','in',$this->orgs2)
  652. ->count();
  653. $tc2 = bjydb('todo')
  654. ->where('del',0)
  655. ->where('org_id',$this->bjOrgId)
  656. ->count();
  657. $todoCount = $tc1 + $tc2;
  658. $t1 = Db::name('patrol_task')
  659. ->where('del',0)
  660. ->where('org_id','in',$this->orgs2)
  661. ->count();
  662. $t2 = bjydb('patrol_task')
  663. ->where('del',0)
  664. ->where('org_id',$this->bjOrgId)
  665. ->count();
  666. $taskCount = $t1 + $t2;
  667. }elseif(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  668. $count = Db::name('org')->where('parent_id',1)->where('del',0)->where('enable',1)->where('type',1)->count();
  669. $count1 = Db::name('org')->where('del',0)->where('enable',1)->where('type',2)->count();
  670. $c1 = Db::name('user')
  671. ->alias('u')
  672. ->join('user_org uo','uo.user_id=u.id')
  673. ->join('org o','o.id=uo.org_id')
  674. ->where('u.del',0)
  675. ->where('u.type',0)
  676. ->where('o.enable',1)
  677. ->where('o.del',0)
  678. ->count();
  679. $c2 = gtspdb('user')
  680. ->alias('u')
  681. ->join('user_org uo','uo.USER_ID=u.USER_ID')
  682. ->where('u.DEL_REF',0)
  683. ->where('u.TYPE',0)
  684. ->where('uo.ORG_ID','in',$this->spOrgId)
  685. ->where('uo.ORG_TYPE',0)
  686. ->count();
  687. $c22 = bjydb('user')
  688. ->alias('u')
  689. ->join('user_org uo','uo.user_id=u.id')
  690. ->join('org o','o.id=uo.org_id')
  691. ->where('u.del',0)
  692. ->where('u.type',0)
  693. ->where('o.enable',1)
  694. ->where('o.del',0)
  695. ->where('o.id',$this->bjOrgId)
  696. ->count();
  697. $count2 = $c1 + $c2 + $c22;
  698. $oc1 = Db::name('orders')
  699. ->where('del',0)
  700. ->where('org_id','in',$this->orgs2)
  701. ->count();
  702. $oc2 = gtspdb('orders')
  703. ->where('DEL_REF',0)
  704. ->where('ORG_ID',$this->spOrgId)
  705. ->count();
  706. $oc3 = bjydb('orders')
  707. ->where('del',0)
  708. ->where('org_id',$this->bjOrgId)
  709. ->count();
  710. $orderCount = $oc1 + $oc2 + $oc3;
  711. $tc1= Db::name('todo')
  712. ->where('del',0)
  713. ->where('org_id','in',$this->orgs2)
  714. ->count();
  715. $tc2 = gtspdb('todo')
  716. ->where('DEL_REF',0)
  717. ->where('ORG_ID',$this->spOrgId)
  718. ->count();
  719. $tc3 = bjydb('todo')
  720. ->where('del',0)
  721. ->where('org_id',$this->bjOrgId)
  722. ->count();
  723. $todoCount = $tc1 + $tc2 + $tc3;
  724. $t1 = Db::name('patrol_task')
  725. ->where('del',0)
  726. ->where('org_id','in',$this->orgs2)
  727. ->count();
  728. $t2 = gtspdb('patrol_task')
  729. ->where('DEL_REF',0)
  730. ->where('ORG_ID',$this->spOrgId)
  731. ->count();
  732. $t3 = bjydb('patrol_task')
  733. ->where('del',0)
  734. ->where('org_id',$this->bjOrgId)
  735. ->count();
  736. $taskCount = $t1 + $t2 + $t3;
  737. }else{
  738. $count = Db::name('org')->where('parent_id',1)->where('del',0)->where('enable',1)->where('type',1)->count();
  739. $count1 = Db::name('org')->where('del',0)->where('enable',1)->where('type',2)->count();
  740. $count2 = Db::name('user')
  741. ->alias('u')
  742. ->join('user_org uo','uo.user_id=u.id')
  743. ->join('org o','o.id=uo.org_id')
  744. ->where('u.del',0)
  745. ->where('u.type',0)
  746. ->where('o.enable',1)
  747. ->where('o.del',0)
  748. ->count();
  749. $orderCount = Db::name('orders')
  750. ->where('del',0)
  751. ->count();
  752. $todoCount = Db::name('todo')
  753. ->where('del',0)
  754. ->count();
  755. $task1 = Db::name('patrol_task')
  756. ->where('del',0)
  757. ->count();
  758. $task2 = Db::name('device_task')
  759. ->where('del',0)
  760. ->count();
  761. $taskCount = $task1 + $task2;
  762. }
  763. $data = [
  764. 'count1'=>$count,
  765. 'count2'=>$count1,
  766. 'count3'=>$count2,
  767. 'count4'=>$orderCount,
  768. 'count5'=>$todoCount,
  769. 'count6'=>$taskCount,
  770. 'count7'=>23
  771. ];
  772. HelpHander::success($data);
  773. }
  774. public function cityList(){
  775. $org = Db::name('org')
  776. ->alias('o')
  777. ->field('o.city_id,c.title')
  778. ->join('city c','c.id=o.city_id')
  779. ->where('o.del',0)
  780. ->where('o.enable',1)
  781. ->where('o.type',2)
  782. ->group('o.city_id')
  783. ->select();
  784. foreach ($org as $k=>$v){
  785. $list = Db::name('org')->where('del',0)->where('enable',1)->where('type',2)->where('city_id',$v['city_id'])->select();
  786. foreach ($list as $kk=>$vv){
  787. $list[$kk]['id'] = think_encrypt($vv['id'].'|'.time());
  788. }
  789. $org[$k]['list'] = $list?$list:[];
  790. }
  791. HelpHander::success($org);
  792. }
  793. public function quarterScore(){
  794. $org = Db::name('org')
  795. ->field('id,name')
  796. ->where('parent_id',1)
  797. ->where('del',0)
  798. ->where('enable',1)
  799. ->where('type',1)
  800. ->select();
  801. foreach ($org as $k=>$v){
  802. $org[$k]['orgs'] = $this->getAllNextId($v['id']);
  803. }
  804. //获取当前季度
  805. $season = ceil((date('n'))/3);
  806. //当前季度开始时间戳
  807. $startTime = date('Y-m-d H:i:s', mktime(0,0,0,$season*3-3+1,1,date('Y')));
  808. //获取当前季度结束时间戳
  809. $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')));
  810. $where[] = ['create_yyyymm','>=',date('Ym',strtotime($startTime))];
  811. $where[] = ['create_yyyymm','<=',date('Ym',strtotime($overTime))];
  812. $where2[] = ['CREATE_YYYYMM','>=',date('Ym',strtotime($startTime))];
  813. $where2[] = ['CREATE_YYYYMM','<=',date('Ym',strtotime($overTime))];
  814. foreach ($org as $k=>$v){
  815. if(in_array(3,$v['orgs']) && !in_array(24,$v['orgs'])){
  816. $c1 = gtspdb('comment')->where('ORG_ID',$this->spOrgId)->where($where2)->sum('SCORE');
  817. $c2 = Db::name('comment')->whereIn('org_id',$v['orgs'])->where('org_id','<>',3)->where($where)->sum('score');
  818. $org[$k]['score'] = $c1 + $c2;
  819. }elseif(!in_array(3,$v['orgs']) && in_array(24,$v['orgs'])){
  820. $c1 = bjydb('comment')->where('org_id',$this->bjOrgId)->where($where)->sum('SCORE');
  821. $c2 = Db::name('comment')->whereIn('org_id',$v['orgs'])->where('org_id','<>',3)->where($where)->sum('score');
  822. $org[$k]['score'] = $c1 + $c2;
  823. }elseif(in_array(3,$v['orgs']) && in_array(24,$v['orgs'])){
  824. $c1 = bjydb('comment')->where('org_id',$this->bjOrgId)->where($where)->sum('SCORE');
  825. $c2 = Db::name('comment')->whereIn('org_id',$v['orgs'])->where('org_id','<>',3)->where($where)->sum('score');
  826. $c3 = gtspdb('comment')->where('ORG_ID',$this->spOrgId)->where($where2)->sum('SCORE');
  827. $org[$k]['score'] = $c1 + $c2 + $c3;
  828. }else{
  829. $org[$k]['score'] = Db::name('comment')->whereIn('org_id',$v['orgs'])->where($where)->sum('score');
  830. }
  831. }
  832. $list = list_sort_by($org,'score','desc');
  833. $top1 = isset($list[0])?$list[0]:null;
  834. $top2 = isset($list[1])?$list[1]:null;
  835. $top3 = isset($list[2])?$list[2]:null;
  836. $top4 = isset($list[3])?$list[3]:null;
  837. $top5 = isset($list[4])?$list[4]:null;
  838. HelpHander::success(['top1'=>$top1,'top2'=>$top2,'top3'=>$top3,'top4'=>$top4,'top5'=>$top5]);
  839. }
  840. public function quarterScore2(){
  841. $map[] = ['del','=',0];
  842. $map[] = ['enable','=',1];
  843. $map[] = ['type','=',2];
  844. $org = Db::name('org')
  845. ->field('id,name')
  846. ->where('parent_id',1)
  847. ->where('del',0)
  848. ->where('enable',1)
  849. ->where('type',1)
  850. ->select();
  851. foreach ($org as $k=>$v){
  852. $org[$k]['orgs'] = $this->getAllNextId($v['id']);
  853. }
  854. //获取当前季度
  855. $season = ceil((date('n'))/3);
  856. //当前季度开始时间戳
  857. $startTime = date('Y-m-d H:i:s', mktime(0,0,0,$season*3-3+1,1,date('Y')));
  858. //获取当前季度结束时间戳
  859. $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')));
  860. $where[] = ['create_yyyymm','>=',date('Ym',strtotime($startTime))];
  861. $where[] = ['create_yyyymm','<=',date('Ym',strtotime($overTime))];
  862. foreach ($org as $k=>$v){
  863. if(in_array(3,$v['orgs']) ){
  864. $org[$k]['price'] = 5.3;
  865. }else{
  866. $org[$k]['price'] = 0;
  867. }
  868. }
  869. $list = list_sort_by($org,'score','desc');
  870. $top1 = isset($list[0])?$list[0]:null;
  871. $top2 = isset($list[1])?$list[1]:null;
  872. $top3 = isset($list[2])?$list[2]:null;
  873. $top4 = isset($list[3])?$list[3]:null;
  874. $top5 = isset($list[4])?$list[4]:null;
  875. HelpHander::success(['top1'=>$top1,'top2'=>$top2,'top3'=>$top3,'top4'=>$top4,'top5'=>$top5]);
  876. }
  877. public function fcompanyList(){
  878. $map[] = ['del','=',0];
  879. $map[] = ['enable','=',1];
  880. $map[] = ['type','=',2];
  881. $org = Db::name('org')
  882. ->field('id,name')
  883. ->where('parent_id',1)
  884. ->where('del',0)
  885. ->where('enable',1)
  886. ->where('type',1)
  887. ->select();
  888. foreach ($org as $k=>$v){
  889. $org[$k]['orgs'] = $this->getAllNextId($v['id']);
  890. }
  891. $host = request()->domain(true);
  892. foreach ($org as $k=>$v){
  893. if(in_array(3,$v['orgs'])){
  894. $org[$k]['day'] = 256;
  895. $org[$k]['nums'] = 1;
  896. $org[$k]['nums2'] = 1;
  897. $org[$k]['bl'] = 100;
  898. $org[$k]['imgs'] = [
  899. $host.'/screen/images/nh1.png',
  900. $host.'/screen/images/nh2.png',
  901. $host.'/screen/images/nh3.png',
  902. ];
  903. }else{
  904. $org[$k]['day'] = 0;
  905. $org[$k]['nums'] = 0;
  906. $org[$k]['nums2'] = 0;
  907. $org[$k]['bl'] = 0;
  908. $org[$k]['imgs'] = [];
  909. }
  910. }
  911. HelpHander::success($org);
  912. }
  913. public function nlxhList(){
  914. $org = Db::name('org')
  915. ->field('id,name')
  916. ->where('parent_id',1)
  917. ->where('del',0)
  918. ->where('enable',1)
  919. ->where('type',1)
  920. ->select();
  921. foreach ($org as $k=>$v){
  922. $org[$k]['orgs'] = $this->getAllNextId($v['id']);
  923. if(isset($k) && $k==0){
  924. $org[$k]['value'] = 556;
  925. }else if(isset($k) && $k==1){
  926. $org[$k]['value'] = 875;
  927. }else if(isset($k) && $k==2){
  928. $org[$k]['value'] = 345;
  929. }else if(isset($k) && $k==3){
  930. $org[$k]['value'] = 234;
  931. }else if(isset($k) && $k==4){
  932. $org[$k]['value'] = 797;
  933. }else if(isset($k) && $k==5) {
  934. $org[$k]['value'] = 887;
  935. }
  936. }
  937. //获取当前季度
  938. $season = ceil((date('n'))/3);
  939. //当前季度开始时间戳
  940. $startTime = date('Y-m-d H:i:s', mktime(0,0,0,$season*3-3+1,1,date('Y')));
  941. //获取当前季度结束时间戳
  942. $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')));
  943. $list = array_slice(list_sort_by($org,'value','desc'),0,5);
  944. HelpHander::success($list);
  945. }
  946. //巡查图片
  947. public function patrolImg(){
  948. if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
  949. $data = gtspdb('patrol_record')
  950. ->where('IMAGES','<>','')
  951. ->where('ORG_ID',$this->spOrgId)
  952. ->limit(20)
  953. ->order('PATROL_RECORD_ID desc')
  954. ->select();
  955. foreach ($data as $k=>$v){
  956. $img = explode(',',$v['IMAGES']);
  957. if($img){
  958. $data[$k]['images'] = $img[0];
  959. }
  960. }
  961. if(count($data)>2){
  962. $key = array_rand($data,3);
  963. $list[] = $data[$key[0]];
  964. $list[] = $data[$key[1]];
  965. $list[] = $data[$key[2]];
  966. }
  967. }elseif(!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  968. $data = bjydb('patrol_record')
  969. ->where('images','<>','')
  970. ->where('org_id',$this->bjOrgId)
  971. ->limit(20)
  972. ->order('id desc')
  973. ->select();
  974. foreach ($data as $k=>$v){
  975. $img = explode(',',$v['images']);
  976. if($img){
  977. $data[$k]['images'] = $img[0];
  978. }
  979. }
  980. if(count($data)>2){
  981. $key = array_rand($data,3);
  982. $list[] = $data[$key[0]];
  983. $list[] = $data[$key[1]];
  984. $list[] = $data[$key[2]];
  985. }
  986. }elseif(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  987. $data1 = bjydb('patrol_record')
  988. ->where('images','<>','')
  989. ->where('org_id',$this->bjOrgId)
  990. ->limit(20)
  991. ->order('id desc')
  992. ->select();
  993. foreach ($data1 as $k=>$v){
  994. $img = explode(',',$v['images']);
  995. if($img){
  996. $data1[$k]['images'] = $img[0];
  997. }
  998. }
  999. $data2 = gtspdb('patrol_record')
  1000. ->where('IMAGES','<>','')
  1001. ->where('ORG_ID',$this->spOrgId)
  1002. ->limit(20)
  1003. ->order('PATROL_RECORD_ID desc')
  1004. ->select();
  1005. foreach ($data2 as $k=>$v){
  1006. $img = explode(',',$v['IMAGES']);
  1007. if($img){
  1008. $data2[$k]['images'] = $img[0];
  1009. }
  1010. }
  1011. $data = array_merge($data1,$data2);
  1012. if(count($data)>2){
  1013. $key = array_rand($data,3);
  1014. $list[] = $data[$key[0]];
  1015. $list[] = $data[$key[1]];
  1016. $list[] = $data[$key[2]];
  1017. }
  1018. }else{
  1019. $data = Db::name('patrol_record')
  1020. ->where('images','<>','')
  1021. ->whereIn('org_id',$this->orgs2)
  1022. ->limit(20)
  1023. ->order('id desc')
  1024. ->select();
  1025. foreach ($data as $k=>$v){
  1026. $img = explode(',',$v['images']);
  1027. if($img){
  1028. $data[$k]['images'] = $img[0];
  1029. }
  1030. }
  1031. if(count($data)>2){
  1032. $key = array_rand($data,3);
  1033. $list[] = $data[$key[0]];
  1034. $list[] = $data[$key[1]];
  1035. $list[] = $data[$key[2]];
  1036. }
  1037. }
  1038. $eList = isset($list)?$list:$data;
  1039. HelpHander::success($eList);
  1040. }
  1041. public function patrolRecordList(){
  1042. $dlist = [
  1043. date('Y-m-d',strtotime('-6 days')),
  1044. date('Y-m-d',strtotime('-5 days')),
  1045. date('Y-m-d',strtotime('-4 days')),
  1046. date('Y-m-d',strtotime('-3 days')),
  1047. date('Y-m-d',strtotime('-2 days')),
  1048. date('Y-m-d',strtotime('-1 days')),
  1049. date('Y-m-d'),
  1050. ];
  1051. $date = [];
  1052. $yCount = [];
  1053. $y2Count = [];
  1054. $y3Count = [];
  1055. $y4Count = [];
  1056. if(in_array(3,$this->orgs) && !in_array(24,$this->orgs)){
  1057. foreach ($dlist as $k=>$v){
  1058. $tt = date('Ymd',strtotime($v));
  1059. $c1 = gtspdb('patrol_record')
  1060. ->where('ORG_ID',$this->spOrgId)
  1061. ->where('CREATE_YYYYMMDD',$tt)
  1062. ->where('PATROL_MODE',1)
  1063. ->count();
  1064. $c2 = Db::name('patrol_record')
  1065. ->whereIn('org_id',$this->orgs2)
  1066. ->where('create_yyyymmdd',$tt)
  1067. ->where('patrol_mode',1)
  1068. ->count();
  1069. $count = $c1 + $c2;
  1070. $c3 = gtspdb('patrol_record')
  1071. ->where('ORG_ID',$this->spOrgId)
  1072. ->where('CREATE_YYYYMMDD',$tt)
  1073. ->where('PATROL_MODE',2)
  1074. ->count();
  1075. $c4 = Db::name('patrol_record')
  1076. ->whereIn('org_id',$this->orgs2)
  1077. ->where('create_yyyymmdd',$tt)
  1078. ->where('patrol_mode',2)
  1079. ->count();
  1080. $count2 = $c3 + $c4;
  1081. $c5 = gtspdb('patrol_record')
  1082. ->where('ORG_ID',$this->spOrgId)
  1083. ->where('CREATE_YYYYMMDD',$tt)
  1084. ->where('PATROL_MODE',3)
  1085. ->count();
  1086. $c6 = Db::name('patrol_record')
  1087. ->whereIn('org_id',$this->orgs2)
  1088. ->where('create_yyyymmdd',$tt)
  1089. ->where('patrol_mode',3)
  1090. ->count();
  1091. $count3 = $c5 + $c6;
  1092. $c7 = gtspdb('patrol_record')
  1093. ->where('ORG_ID',$this->spOrgId)
  1094. ->where('CREATE_YYYYMMDD',$tt)
  1095. ->where('PATROL_MODE',4)
  1096. ->count();
  1097. $c8 = Db::name('patrol_record')
  1098. ->whereIn('org_id',$this->orgs)
  1099. ->where('create_yyyymmdd',$tt)
  1100. ->where('patrol_mode',4)
  1101. ->count();
  1102. $count4 = $c7 + $c8;
  1103. $date[] = date('m-d',strtotime($v));
  1104. $yCount[] = $count;
  1105. $y2Count[] = $count2;
  1106. $y3Count[] = $count3;
  1107. $y4Count[] = $count4;
  1108. }
  1109. }elseif(!in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  1110. foreach ($dlist as $k=>$v){
  1111. $tt = date('Ymd',strtotime($v));
  1112. $c1 = bjydb('patrol_record')
  1113. ->where('org_id',$this->bjOrgId)
  1114. ->where('create_yyyymmdd',$tt)
  1115. ->where('patrol_mode',1)
  1116. ->count();
  1117. $c2 = Db::name('patrol_record')
  1118. ->whereIn('org_id',$this->orgs2)
  1119. ->where('create_yyyymmdd',$tt)
  1120. ->where('patrol_mode',1)
  1121. ->count();
  1122. $count = $c1 + $c2;
  1123. $c3 = bjydb('patrol_record')
  1124. ->where('org_id',$this->bjOrgId)
  1125. ->where('create_yyyymmdd',$tt)
  1126. ->where('patrol_mode',2)
  1127. ->count();
  1128. $c4 = Db::name('patrol_record')
  1129. ->whereIn('org_id',$this->orgs2)
  1130. ->where('create_yyyymmdd',$tt)
  1131. ->where('patrol_mode',2)
  1132. ->count();
  1133. $count2 = $c3 + $c4;
  1134. $c5 = bjydb('patrol_record')
  1135. ->where('org_id',$this->bjOrgId)
  1136. ->where('create_yyyymmdd',$tt)
  1137. ->where('patrol_mode',3)
  1138. ->count();
  1139. $c6 = Db::name('patrol_record')
  1140. ->whereIn('org_id',$this->orgs2)
  1141. ->where('create_yyyymmdd',$tt)
  1142. ->where('patrol_mode',3)
  1143. ->count();
  1144. $count3 = $c5 + $c6;
  1145. $c7 = bjydb('patrol_record')
  1146. ->where('org_id',$this->bjOrgId)
  1147. ->where('create_yyyymmdd',$tt)
  1148. ->where('patrol_mode',1)
  1149. ->count();
  1150. $c8 = Db::name('patrol_record')
  1151. ->whereIn('org_id',$this->orgs)
  1152. ->where('create_yyyymmdd',$tt)
  1153. ->where('patrol_mode',4)
  1154. ->count();
  1155. $count4 = $c7 + $c8;
  1156. $date[] = date('m-d',strtotime($v));
  1157. $yCount[] = $count;
  1158. $y2Count[] = $count2;
  1159. $y3Count[] = $count3;
  1160. $y4Count[] = $count4;
  1161. }
  1162. }elseif(in_array(3,$this->orgs) && in_array(24,$this->orgs)){
  1163. foreach ($dlist as $k=>$v){
  1164. $tt = date('Ymd',strtotime($v));
  1165. $c1 = gtspdb('patrol_record')
  1166. ->where('ORG_ID',$this->spOrgId)
  1167. ->where('CREATE_YYYYMMDD',$tt)
  1168. ->where('PATROL_MODE',1)
  1169. ->count();
  1170. $c2 = Db::name('patrol_record')
  1171. ->whereIn('org_id',$this->orgs2)
  1172. ->where('create_yyyymmdd',$tt)
  1173. ->where('patrol_mode',1)
  1174. ->count();
  1175. $c22 = bjydb('patrol_record')
  1176. ->where('org_id',$this->bjOrgId)
  1177. ->where('create_yyyymmdd',$tt)
  1178. ->where('patrol_mode',1)
  1179. ->count();
  1180. $count = $c1 + $c2 + $c22;
  1181. $c3 = gtspdb('patrol_record')
  1182. ->where('ORG_ID',$this->spOrgId)
  1183. ->where('CREATE_YYYYMMDD',$tt)
  1184. ->where('PATROL_MODE',2)
  1185. ->count();
  1186. $c4 = Db::name('patrol_record')
  1187. ->whereIn('org_id',$this->orgs2)
  1188. ->where('create_yyyymmdd',$tt)
  1189. ->where('patrol_mode',2)
  1190. ->count();
  1191. $c44 = bjydb('patrol_record')
  1192. ->where('org_id',$this->bjOrgId)
  1193. ->where('create_yyyymmdd',$tt)
  1194. ->where('patrol_mode',2)
  1195. ->count();
  1196. $count2 = $c3 + $c4 + $c44;
  1197. $c5 = gtspdb('patrol_record')
  1198. ->where('ORG_ID',$this->spOrgId)
  1199. ->where('CREATE_YYYYMMDD',$tt)
  1200. ->where('PATROL_MODE',3)
  1201. ->count();
  1202. $c6 = Db::name('patrol_record')
  1203. ->whereIn('org_id',$this->orgs2)
  1204. ->where('create_yyyymmdd',$tt)
  1205. ->where('patrol_mode',3)
  1206. ->count();
  1207. $c66 = bjydb('patrol_record')
  1208. ->where('org_id',$this->bjOrgId)
  1209. ->where('create_yyyymmdd',$tt)
  1210. ->where('patrol_mode',3)
  1211. ->count();
  1212. $count3 = $c5 + $c6 + $c66;
  1213. $c7 = gtspdb('patrol_record')
  1214. ->where('ORG_ID',$this->spOrgId)
  1215. ->where('CREATE_YYYYMMDD',$tt)
  1216. ->where('PATROL_MODE',4)
  1217. ->count();
  1218. $c8 = Db::name('patrol_record')
  1219. ->whereIn('org_id',$this->orgs)
  1220. ->where('create_yyyymmdd',$tt)
  1221. ->where('patrol_mode',4)
  1222. ->count();
  1223. $c88 = bjydb('patrol_record')
  1224. ->where('org_id',$this->bjOrgId)
  1225. ->where('create_yyyymmdd',$tt)
  1226. ->where('patrol_mode',4)
  1227. ->count();
  1228. $count4 = $c7 + $c8 + $c88;
  1229. $date[] = date('m-d',strtotime($v));
  1230. $yCount[] = $count;
  1231. $y2Count[] = $count2;
  1232. $y3Count[] = $count3;
  1233. $y4Count[] = $count4;
  1234. }
  1235. }else{
  1236. foreach ($dlist as $k=>$v){
  1237. $tt = date('Ymd',strtotime($v));
  1238. $count = Db::name('patrol_record')
  1239. ->whereIn('org_id',$this->orgs)
  1240. ->where('create_yyyymmdd',$tt)
  1241. ->where('patrol_mode',1)
  1242. ->count();
  1243. $count2 = Db::name('patrol_record')
  1244. ->whereIn('org_id',$this->orgs)
  1245. ->where('create_yyyymmdd',$tt)
  1246. ->where('patrol_mode',2)
  1247. ->count();
  1248. $count3 = Db::name('patrol_record')
  1249. ->whereIn('org_id',$this->orgs)
  1250. ->where('create_yyyymmdd',$tt)
  1251. ->where('patrol_mode',3)
  1252. ->count();
  1253. $count4 = Db::name('patrol_record')
  1254. ->whereIn('org_id',$this->orgs)
  1255. ->where('create_yyyymmdd',$tt)
  1256. ->where('patrol_mode',4)
  1257. ->count();
  1258. $date[] = date('m-d',strtotime($v));
  1259. $yCount[] = $count;
  1260. $y2Count[] = $count2;
  1261. $y3Count[] = $count3;
  1262. $y4Count[] = $count4;
  1263. }
  1264. }
  1265. $data = [
  1266. 'date'=>$date,
  1267. 'count1'=>$yCount,
  1268. 'count2'=>$y2Count,
  1269. 'count3'=>$y3Count,
  1270. 'count4'=>$y4Count,
  1271. ];
  1272. HelpHander::success($data);
  1273. }
  1274. // 获取所有下级的id集合
  1275. public function getAllNextId($id,$data=[]){
  1276. $pids = DB::name('org')->where('parent_id',$id)->column('id');
  1277. if(count($pids)>0){
  1278. foreach($pids as $v){
  1279. $data[] = $v;
  1280. $data = $this->getAllNextId($v,$data); //注意写$data 返回给上级
  1281. }
  1282. }
  1283. if(count($data)>0){
  1284. return $data;
  1285. }else{
  1286. return [];
  1287. }
  1288. }
  1289. public function getOrgs(){
  1290. $img1 = request()->domain(true).'/screen/images/hz01.png';
  1291. $img2 = request()->domain(true).'/screen/images/hz02.png';
  1292. $lists1 = [
  1293. [
  1294. 'id'=>think_encrypt('3|'.time()),
  1295. 'title'=>'新乡市中心医院',
  1296. 'img'=> $img1
  1297. ],
  1298. [
  1299. // 'id'=>think_encrypt('24|'.time()),
  1300. 'id'=>'',
  1301. 'title'=>'医院1',
  1302. 'img'=>$img2
  1303. ],
  1304. [
  1305. // 'id'=>think_encrypt('26|'.time()),
  1306. 'id'=>'',
  1307. 'title'=>'医院2',
  1308. 'img'=>$img2
  1309. ],
  1310. [
  1311. 'id'=>0,
  1312. 'title'=>'医院3',
  1313. 'img'=>$img2
  1314. ],
  1315. [
  1316. 'id'=>0,
  1317. 'title'=>'医院4',
  1318. 'img'=>$img2
  1319. ],
  1320. [
  1321. 'id'=>0,
  1322. 'title'=>'医院5',
  1323. 'img'=>$img2
  1324. ],
  1325. ];
  1326. $lists2 = [
  1327. [
  1328. 'id'=>0,
  1329. 'title'=>'医院11',
  1330. 'img'=>$img2
  1331. ],
  1332. [
  1333. 'id'=>0,
  1334. 'title'=>'医院12',
  1335. 'img'=>$img2
  1336. ],
  1337. [
  1338. 'id'=>0,
  1339. 'title'=>'医院13',
  1340. 'img'=>$img2
  1341. ],
  1342. [
  1343. 'id'=>0,
  1344. 'title'=>'医院14',
  1345. 'img'=>$img2
  1346. ],
  1347. [
  1348. 'id'=>0,
  1349. 'title'=>'医院15',
  1350. 'img'=>$img2
  1351. ],
  1352. [
  1353. 'id'=>0,
  1354. 'title'=>'医院16',
  1355. 'img'=>$img2
  1356. ],
  1357. ];
  1358. $lists3 = [
  1359. [
  1360. 'id'=>0,
  1361. 'title'=>'医院12',
  1362. 'img'=>$img2
  1363. ],
  1364. [
  1365. 'id'=>0,
  1366. 'title'=>'医院13',
  1367. 'img'=>$img2
  1368. ],
  1369. [
  1370. 'id'=>0,
  1371. 'title'=>'医院14',
  1372. 'img'=>$img2
  1373. ],
  1374. [
  1375. 'id'=>0,
  1376. 'title'=>'医院15',
  1377. 'img'=>$img2
  1378. ],
  1379. [
  1380. 'id'=>0,
  1381. 'title'=>'医院16',
  1382. 'img'=>$img2
  1383. ],
  1384. ];
  1385. $lists4 = [
  1386. [
  1387. 'id'=>0,
  1388. 'title'=>'医院6',
  1389. 'img'=>$img2
  1390. ],
  1391. [
  1392. 'id'=>0,
  1393. 'title'=>'医院7',
  1394. 'img'=>$img2
  1395. ],
  1396. [
  1397. 'id'=>0,
  1398. 'title'=>'医院8',
  1399. 'img'=>$img2
  1400. ],
  1401. [
  1402. 'id'=>0,
  1403. 'title'=>'医院9',
  1404. 'img'=>$img2
  1405. ],
  1406. [
  1407. 'id'=>0,
  1408. 'title'=>'医院10',
  1409. 'img'=>$img2
  1410. ],
  1411. ];
  1412. HelpHander::success([
  1413. 'lists1'=>$lists1,
  1414. 'lists2'=>$lists2,
  1415. 'lists3'=>$lists3,
  1416. 'lists4'=>$lists4,
  1417. ]);
  1418. }
  1419. public function dailyData(){
  1420. $lists = [
  1421. [
  1422. 'id'=>2,
  1423. 'title'=>'济南',
  1424. ],
  1425. [
  1426. 'id'=>8,
  1427. 'title'=>'青岛',
  1428. ],
  1429. [
  1430. 'id'=>10,
  1431. 'title'=>'烟台',
  1432. ],
  1433. [
  1434. 'id'=>11,
  1435. 'title'=>'威海',
  1436. ],
  1437. [
  1438. 'id'=>12,
  1439. 'title'=>'东营',
  1440. ],
  1441. [
  1442. 'id'=>13,
  1443. 'title'=>' 淄博',
  1444. ],
  1445. ];
  1446. $orgs = [];
  1447. $pzdata = [];
  1448. $rwdata = [];
  1449. $max = 0;
  1450. foreach ($lists as $k=>$v){
  1451. $map = [];
  1452. $orgs[] = $v['title'];
  1453. if($v['id'] == 0){
  1454. $pzdata[] = mt_rand(0,10);
  1455. $rwdata[] = mt_rand(0,$max);
  1456. }else{
  1457. $orgIds = $this->getAllNextId($v['id'],[]);
  1458. if($orgIds){
  1459. $map[] = ['org_id','in',$orgIds];
  1460. }else{
  1461. $map[] = ['org_id','=',-1];
  1462. }
  1463. $pzcount = Db::name('daily_record')->where($map)->where('order_id','>',0)->count();
  1464. $pzdata[] = $pzcount;
  1465. $rwcount = Db::name('daily_record')->where($map)->count();
  1466. if($rwcount > $max){
  1467. $max = $rwcount;
  1468. }
  1469. $rwdata[] = $rwcount;
  1470. }
  1471. }
  1472. HelpHander::success([
  1473. 'orgs'=>$orgs,
  1474. 'pzdata'=>$pzdata,
  1475. 'rwdata'=>$rwdata,
  1476. ]);
  1477. }
  1478. public function todoData(){
  1479. $lists = [
  1480. [
  1481. 'id'=>2,
  1482. 'title'=>'济南',
  1483. ],
  1484. [
  1485. 'id'=>8,
  1486. 'title'=>'青岛',
  1487. ],
  1488. [
  1489. 'id'=>10,
  1490. 'title'=>'烟台',
  1491. ],
  1492. [
  1493. 'id'=>11,
  1494. 'title'=>'威海',
  1495. ],
  1496. [
  1497. 'id'=>12,
  1498. 'title'=>'东营',
  1499. ],
  1500. [
  1501. 'id'=>13,
  1502. 'title'=>' 淄博',
  1503. ],
  1504. ];
  1505. $orgs = [];
  1506. $y1 = [];
  1507. $y2 = [];
  1508. $max1 = 0;
  1509. $max2 = 0;
  1510. foreach ($lists as $k=>$v){
  1511. $map = [];
  1512. $orgs[] = $v['title'];
  1513. if($v['id'] == 0){
  1514. $y1[] = mt_rand(0,$max1);
  1515. $y2[] = mt_rand(0,$max2);
  1516. }else{
  1517. $orgIds = $this->getAllNextId($v['id'],[]);
  1518. if($orgIds){
  1519. $map[] = ['org_id','in',$orgIds];
  1520. }else{
  1521. $map[] = ['org_id','=',-1];
  1522. }
  1523. $pzcount = Db::name('todo')->where($map)->where('todo_mode',3)->where('del',0)->count();
  1524. $xycount = Db::name('todo')->where($map)->where('todo_mode',3)->where('del',0)->sum('xy_time');
  1525. $wccount = Db::name('todo')->where($map)->where('todo_mode',3)->where('del',0)->sum('wc_time');
  1526. $y2c = $pzcount>0?round(($xycount/60)/$pzcount,1):0;
  1527. $y2[] = $y2c;
  1528. if($y2c > $max2){
  1529. $max2 = $y2c;
  1530. }
  1531. $y1c = $pzcount>0?round(($wccount/60)/$pzcount,1):0;
  1532. $y1[] = $y1c;
  1533. if($y1c > $max1){
  1534. $max1 = $y1c;
  1535. }
  1536. }
  1537. }
  1538. HelpHander::success([
  1539. 'orgs'=>$orgs,
  1540. 'y1'=>$y1,
  1541. 'y2'=>$y2,
  1542. ]);
  1543. }
  1544. }