Todo.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <?php
  2. namespace app\h5\controller;
  3. use app\hander\HelpHander;
  4. use EasyWeChat\Factory;
  5. use think\Controller;
  6. use think\Db;
  7. class Todo extends Controller
  8. {
  9. private $spOrgId = 5; //国天sp 厦门中山医院
  10. private $bjOrgId = 11; //霸洁云 贵州省黔西市人民医院
  11. private $xcOrgId = 18; //新城悦 嘉善县中医院
  12. public function lists(){
  13. $dd = think_decrypt(input('orgId','','trim'));
  14. if(!$dd){
  15. HelpHander::error('参数错误');
  16. }
  17. $dd = explode('|',$dd);
  18. if(count($dd) != 2){
  19. HelpHander::error('参数错误');
  20. }
  21. $orgId = (int)$dd[0];
  22. $this->assign('orgId',input('orgId','','trim'));
  23. if($orgId == 3){
  24. // $data = [];
  25. // $header = ['状态', '类型', '始发地', '目的地', '需求时间', '执行人', '派工时间', '接收时间'];
  26. // if($mode == 1){
  27. // $header = ['状态', '科室', '报修事项', '内容', '下单时间'];
  28. // }else if($mode == 2||$mode == 4){
  29. // $header = ['状态', '科室', '内容', '下单时间'];
  30. // }
  31. $lists = gtspdb('orders')
  32. ->where('ORG_ID',$this->spOrgId)
  33. ->where('CURR_ORDER_MODE','in',[1,5])
  34. // ->where('WORK_TYPE_MODE',$mode)
  35. ->where('DEL_REF',0)
  36. ->order('ORDER_ID DESC')
  37. ->limit(20)
  38. ->field('ORDER_ID as id,CURR_ORDER_MODE as order_mode,CREATTE_TIME as create_time,SEND_TIME as send_time,CONTENT as content,DEP_ID as dep_id,WORK_TYPE_MODE as mode')
  39. ->select();
  40. foreach ($lists as $k=>$v){
  41. $dep = gtspdb('org')->where('ORG_ID',$v['dep_id'])->value('NAME');
  42. $status = gtspdb('order_mode')->where('ORDER_MODE',$v['order_mode'])->value('OUT_CONTENT');
  43. $lists[$k]['dep'] = $dep;
  44. $lists[$k]['status'] = $status;
  45. $todos = gtspdb('todo')
  46. ->alias('t')
  47. ->join('user u','u.USER_ID = t.TO_USER_ID')
  48. ->where('t.ORDER_ID',$v['id'])
  49. ->where('t.DEL_REF',0)
  50. ->where('t.TODO_MODE','in',[1,2,3])
  51. ->field('t.CONFIRM_TIME,u.REAL_NAME')
  52. ->select();
  53. $todos = $todos?$todos:[];
  54. $unames = [];
  55. foreach ($todos as $tk=>$tv){
  56. $unames[] = $tv['REAL_NAME'];
  57. }
  58. $un = $unames?implode(',',$unames):'';
  59. $lists[$k]['names'] = $un;
  60. }
  61. }elseif ($orgId == 24){
  62. // $data = [];
  63. // $header = ['状态', '类型', '始发地', '目的地', '需求时间', '执行人', '派工时间', '接收时间'];
  64. // if($mode == 1){
  65. // $header = ['状态', '科室', '报修事项', '内容', '下单时间'];
  66. // }else if($mode == 2||$mode == 4){
  67. // $header = ['状态', '科室', '内容', '下单时间'];
  68. // }
  69. $lists = bjydb('orders')
  70. ->where('org_id',$this->bjOrgId)
  71. ->where('order_mode','in',[1,4])
  72. // ->where('work_type_mode',$mode)
  73. ->where('del',0)
  74. ->order('id desc')
  75. ->limit(20)
  76. ->field('id,order_mode,create_time,send_time,content,dep_id,work_type_mode as mode')
  77. ->select();
  78. foreach ($lists as $k=>$v){
  79. $dep = bjydb('dep')->where('id',$v['dep_id'])->value('title');
  80. $status = bjydb('order_mode')->where('id',$v['order_mode'])->value('out_content');
  81. $lists[$k]['dep'] = $dep;
  82. $lists[$k]['status'] = $status;
  83. $todos = bjydb('todo')
  84. ->alias('t')
  85. ->join('user u','u.id = t.to_user_id')
  86. ->where('t.order_id',$v['id'])
  87. ->where('t.del',0)
  88. ->where('t.todo_mode','in',[1,2,3])
  89. ->field('t.confirm_time,u.real_name')
  90. ->select();
  91. $todos = $todos?$todos:[];
  92. $unames = [];
  93. foreach ($todos as $tk=>$tv){
  94. $unames[] = $tv['real_name'];
  95. }
  96. $un = $unames?implode(',',$unames):'';
  97. $lists[$k]['names'] = $un;
  98. }
  99. }elseif ($orgId == 26){
  100. // $data = [];
  101. // $header = ['状态', '类型', '始发地', '目的地', '需求时间', '执行人', '派工时间', '接收时间'];
  102. // if($mode == 1){
  103. // $header = ['状态', '科室', '报修事项', '内容', '下单时间'];
  104. // }else if($mode == 2||$mode == 4){
  105. // $header = ['状态', '科室', '内容', '下单时间'];
  106. // }
  107. $lists = xcydb('orders')
  108. ->where('org_id',$this->xcOrgId)
  109. ->where('order_mode','in',[1,4])
  110. // ->where('work_type_mode',$mode)
  111. ->where('del',0)
  112. ->order('id desc')
  113. ->limit(20)
  114. ->field('id,order_mode,create_time,send_time,content,dep_id,work_type_mode as mode')
  115. ->select();
  116. foreach ($lists as $k=>$v){
  117. $dep = xcydb('dep')->where('id',$v['dep_id'])->value('title');
  118. $status = xcydb('order_mode')->where('id',$v['order_mode'])->value('out_content');
  119. $lists[$k]['dep'] = $dep;
  120. $lists[$k]['status'] = $status;
  121. $todos = xcydb('todo')
  122. ->alias('t')
  123. ->join('user u','u.id = t.to_user_id')
  124. ->where('t.order_id',$v['id'])
  125. ->where('t.del',0)
  126. ->where('t.todo_mode','in',[1,2,3])
  127. ->field('t.confirm_time,u.real_name')
  128. ->select();
  129. $todos = $todos?$todos:[];
  130. $unames = [];
  131. foreach ($todos as $tk=>$tv){
  132. $unames[] = $tv['real_name'];
  133. }
  134. $un = $unames?implode(',',$unames):'';
  135. $lists[$k]['names'] = $un;
  136. }
  137. }else{
  138. // if($mode == 1){
  139. // $header = ['状态', '科室', '报修事项', '内容', '下单时间'];
  140. // }else if($mode == 2||$mode == 4){
  141. // $header = ['状态', '科室', '内容', '下单时间'];
  142. // }
  143. $lists = Db::name('orders')
  144. ->where('org_id',$orgId)
  145. ->where('order_mode','in',[1,4])
  146. // ->where('work_type_mode',$mode)
  147. ->where('del',0)
  148. ->order('id desc')
  149. ->limit(20)
  150. ->field('id,order_mode,create_time,send_time,content,dep_id,work_type_mode as mode')
  151. ->select();
  152. foreach ($lists as $k=>$v){
  153. $dep = Db::name('dep')->where('id',$v['dep_id'])->value('title');
  154. $status = Db::name('order_mode')->where('id',$v['order_mode'])->value('out_content');
  155. $lists[$k]['dep'] = $dep;
  156. $lists[$k]['status'] = $status;
  157. $todos = Db::name('todo')
  158. ->alias('t')
  159. ->join('user u','u.id = t.to_user_id')
  160. ->where('t.order_id',$v['id'])
  161. ->where('t.del',0)
  162. ->where('t.todo_mode','in',[1,2,3])
  163. ->field('t.confirm_time,u.real_name')
  164. ->select();
  165. $todos = $todos?$todos:[];
  166. $unames = [];
  167. foreach ($todos as $tk=>$tv){
  168. $unames[] = $tv['real_name'];
  169. }
  170. $un = $unames?implode(',',$unames):'';
  171. $lists[$k]['names'] = $un;
  172. }
  173. }
  174. $this->assign('lists',$lists);
  175. return $this->fetch();
  176. }
  177. public function detail(){
  178. $dd = think_decrypt(input('orgId','','trim'));
  179. if(!$dd){
  180. HelpHander::error('参数错误');
  181. }
  182. $dd = explode('|',$dd);
  183. if(count($dd) != 2){
  184. HelpHander::error('参数错误');
  185. }
  186. $orgId = (int)$dd[0];
  187. $this->assign('orgId',input('orgId','','trim'));
  188. $id = input('id/d',0);
  189. $type = input('type/d',0);
  190. $this->assign('type',$type);
  191. if($orgId == 3 && $type == 0){
  192. $info = gtspdb('orders')
  193. ->where('ORG_ID',$this->spOrgId)
  194. ->where('ORDER_ID',$id)
  195. ->where('DEL_REF',0)
  196. ->field('ORDER_ID as id,CURR_ORDER_MODE as order_mode,CREATTE_TIME as create_time,SEND_TIME as send_time,CONTENT as content,DEP_ID as dep_id,WORK_TYPE_MODE as mode')
  197. ->find();
  198. if($info){
  199. $dep = gtspdb('org')->where('ORG_ID',$info['dep_id'])->value('NAME');
  200. $status = gtspdb('order_mode')->where('ORDER_MODE',$info['order_mode'])->value('OUT_CONTENT');
  201. $info['dep'] = $dep;
  202. $info['status'] = $status;
  203. $todos = gtspdb('todo')
  204. ->alias('t')
  205. ->join('user u','u.USER_ID = t.TO_USER_ID')
  206. ->where('t.ORDER_ID',$info['id'])
  207. ->where('t.DEL_REF',0)
  208. ->where('t.TODO_MODE','in',[1,2,3])
  209. ->column('u.REAL_NAME');
  210. $un = $todos?implode(',',$todos):'';
  211. $info['names'] = $un;
  212. if($info['mode'] == 1){
  213. $type = gtspdb('order_repair')
  214. ->alias('or')
  215. ->leftJoin('order_type ot','ot.ORDER_TYPE_ID = or.TYPE_ID')
  216. ->where('or.ORDER_ID',$info['id'])
  217. ->value('NAME');
  218. $info['repair_name'] = $type?$type:'';
  219. }else if($info['mode'] == 3){
  220. $convey = gtspdb('order_convey')
  221. ->alias('oc')
  222. ->join('convey_cate cc','cc.ID = oc.TYPE')
  223. ->where('oc.ORDER_ID',$info['id'])
  224. ->field('oc.*,cc.NAME as cate_title')
  225. ->find();
  226. $info['cate_title'] = '';
  227. $info['start'] = '';
  228. $info['end'] = '';
  229. if($convey){
  230. $sa = gtspdb('address')->where('ADDRESS_ID',$convey['START'])->find();
  231. $sa1 = $ea1 = '';
  232. if($sa){
  233. $sa1 = gtspdb('address')->where('PARENT_ID',$sa['ADDRESS_ID'])->value('NAME');
  234. }
  235. $start = $sa1.$sa['NAME'];
  236. $info['start'] = $start;
  237. $ea = gtspdb('address')->where('ADDRESS_ID',$convey['END'])->find();
  238. if($ea){
  239. $ea1 = gtspdb('address')->where('PARENT_ID',$sa['ADDRESS_ID'])->value('NAME');
  240. }
  241. $end = $ea1.$ea['NAME'];
  242. $info['end'] = $end;
  243. $info['cate_title'] = $convey['cate_title'];
  244. }
  245. }
  246. }
  247. }elseif ($orgId == 24 && $type == 0){
  248. $info = bjydb('orders')
  249. ->where('org_id',$this->bjOrgId)
  250. ->where('id',$id)
  251. ->where('del',0)
  252. ->field('id,order_mode,create_time,send_time,content,dep_id,work_type_mode as mode')
  253. ->find();
  254. if($info){
  255. $dep = bjydb('dep')->where('id',$info['dep_id'])->value('title');
  256. $status = bjydb('order_mode')->where('id',$info['order_mode'])->value('out_content');
  257. $info['dep'] = $dep;
  258. $info['status'] = $status;
  259. $todos = bjydb('todo')
  260. ->alias('t')
  261. ->join('user u','u.id = t.to_user_id')
  262. ->where('t.order_id',$info['id'])
  263. ->where('t.del',0)
  264. ->where('t.todo_mode','in',[1,2,3])
  265. ->column('u.real_name');
  266. $un = $todos?implode(',',$todos):'';
  267. $info['names'] = $un;
  268. if($info['mode'] == 1){
  269. $type = bjydb('order_repair')
  270. ->alias('or')
  271. ->leftJoin('order_type ot','ot.id = or.type_id')
  272. ->where('or.order_id',$info['id'])
  273. ->value('title');
  274. $info['repair_name'] = $type?$type:'';
  275. }else if($info['mode'] == 3){
  276. $convey = bjydb('order_convey')
  277. ->alias('oc')
  278. ->join('convey_cate cc','cc.id = oc.type')
  279. ->where('oc.order_id',$info['id'])
  280. ->field('oc.*,cc.title as cate_title')
  281. ->find();
  282. $info['cate_title'] = '';
  283. $info['start'] = '';
  284. $info['end'] = '';
  285. if($convey){
  286. $start = bjydb('address')->where('id',$convey['start'])->value('title');
  287. $end = bjydb('address')->where('id',$convey['end'])->value('title');
  288. $info['start'] = $start;
  289. $info['end'] = $end;
  290. $info['cate_title'] = $convey['cate_title'];
  291. }
  292. }
  293. }
  294. }elseif ($orgId == 26 && $type == 0){
  295. $info = xcydb('orders')
  296. ->where('org_id',$this->xcOrgId)
  297. ->where('id',$id)
  298. ->where('del',0)
  299. ->field('id,order_mode,create_time,send_time,content,dep_id,work_type_mode as mode')
  300. ->find();
  301. if($info){
  302. $dep = xcydb('dep')->where('id',$info['dep_id'])->value('title');
  303. $status = xcydb('order_mode')->where('id',$info['order_mode'])->value('out_content');
  304. $info['dep'] = $dep;
  305. $info['status'] = $status;
  306. $todos = xcydb('todo')
  307. ->alias('t')
  308. ->join('user u','u.id = t.to_user_id')
  309. ->where('t.order_id',$info['id'])
  310. ->where('t.del',0)
  311. ->where('t.todo_mode','in',[1,2,3])
  312. ->column('u.real_name');
  313. $un = $todos?implode(',',$todos):'';
  314. $info['names'] = $un;
  315. if($info['mode'] == 1){
  316. $type = xcydb('order_repair')
  317. ->alias('or')
  318. ->leftJoin('order_type ot','ot.id = or.type_id')
  319. ->where('or.order_id',$info['id'])
  320. ->value('title');
  321. $info['repair_name'] = $type?$type:'';
  322. }else if($info['mode'] == 3){
  323. $convey = xcydb('order_convey')
  324. ->alias('oc')
  325. ->join('convey_cate cc','cc.id = oc.type')
  326. ->where('oc.order_id',$info['id'])
  327. ->field('oc.*,cc.title as cate_title')
  328. ->find();
  329. $info['cate_title'] = '';
  330. $info['start'] = '';
  331. $info['end'] = '';
  332. if($convey){
  333. $start = xcydb('address')->where('id',$convey['start'])->value('title');
  334. $end = xcydb('address')->where('id',$convey['end'])->value('title');
  335. $info['start'] = $start;
  336. $info['end'] = $end;
  337. $info['cate_title'] = $convey['cate_title'];
  338. }
  339. }
  340. }
  341. }else{
  342. if($type == 1){
  343. $orgId = 3; // 停车场违停订单
  344. $id = '539';
  345. }
  346. $info = Db::name('orders')
  347. ->where('org_id',$orgId)
  348. ->where('id',$id)
  349. ->where('del',0)
  350. ->field('id,order_mode,create_time,send_time,content,dep_id,work_type_mode as mode')
  351. ->find();
  352. if($info){
  353. $dep = Db::name('dep')->where('id',$info['dep_id'])->value('title');
  354. $status = Db::name('order_mode')->where('id',$info['order_mode'])->value('out_content');
  355. $info['dep'] = $dep;
  356. $info['status'] = $status;
  357. $todos = Db::name('todo')
  358. ->alias('t')
  359. ->join('user u','u.id = t.to_user_id')
  360. ->where('t.order_id',$info['id'])
  361. ->where('t.del',0)
  362. ->where('t.todo_mode','in',[1,2,3])
  363. ->column('u.real_name');
  364. $un = $todos?implode(',',$todos):'';
  365. $info['names'] = $un;
  366. if($info['mode'] == 1){
  367. $type = Db::name('order_repair')
  368. ->alias('or')
  369. ->leftJoin('order_type ot','ot.id = or.type_id')
  370. ->where('or.order_id',$info['id'])
  371. ->value('title');
  372. $info['repair_name'] = $type?$type:'';
  373. }else if($info['mode'] == 3){
  374. $convey = Db::name('order_convey')
  375. ->alias('oc')
  376. ->join('convey_cate cc','cc.id = oc.type')
  377. ->where('oc.order_id',$info['id'])
  378. ->field('oc.*,cc.title as cate_title')
  379. ->find();
  380. $info['cate_title'] = '';
  381. $info['start'] = '';
  382. $info['end'] = '';
  383. if($convey){
  384. $start = Db::name('address')->where('id',$convey['start'])->value('title');
  385. $end = Db::name('address')->where('id',$convey['end'])->value('title');
  386. $info['start'] = $start;
  387. $info['end'] = $end;
  388. $info['cate_title'] = $convey['cate_title'];
  389. }
  390. }
  391. }
  392. }
  393. $this->assign('info',$info);
  394. return $this->fetch();
  395. }
  396. public function daily(){
  397. $dd = think_decrypt(input('orgId','','trim'));
  398. if(!$dd){
  399. HelpHander::error('参数错误');
  400. }
  401. $dd = explode('|',$dd);
  402. if(count($dd) != 2){
  403. HelpHander::error('参数错误');
  404. }
  405. $orgId = (int)$dd[0];
  406. // $orgId = 23;
  407. $id = input('id/d',0);
  408. $this->assign('orgId',input('orgId','','trim'));
  409. $hours = model('Daily')->getTimeDaily($orgId);
  410. $s = $hours['start'];
  411. $e = $hours['end'];
  412. $order = 'id desc';
  413. $map[] = ['dr.daily_id','=',$id];
  414. $map[] = ['dr.create_time','>=',$s];
  415. $map[] = ['dr.create_time','<',$e];
  416. $map[] = ['dr.org_id', '=', $orgId];
  417. //数据查询
  418. $lists = Db::name('daily_record')
  419. ->alias('dr')
  420. ->join('daily d', 'd.id=dr.daily_id')
  421. ->field('dr.*,d.title,d.content as daily_details')
  422. ->where($map)
  423. ->order($order)
  424. ->select();
  425. foreach ($lists as $k => $v) {
  426. $lists[$k]['user_name'] = Db::name('user')
  427. ->where('id', $v['user_id'])
  428. ->value('real_name');
  429. // $lists[$k]['zc'] = 0;
  430. // if($v['order_id'] > 0){
  431. // $lists[$k]['zc'] = 1;
  432. // $res = Db::name('orders')->where('id',$v['order_id'])->where('del',0)->where('order_mode','in',[1,4])->find();
  433. // if($res){
  434. // $lists[$k]['zc'] = 2;
  435. // }
  436. // }
  437. }
  438. $this->assign('lists',$lists);
  439. return $this->fetch();
  440. }
  441. public function ddetail(){
  442. $dd = think_decrypt(input('orgId','','trim'));
  443. if(!$dd){
  444. HelpHander::error('参数错误');
  445. }
  446. $dd = explode('|',$dd);
  447. if(count($dd) != 2){
  448. HelpHander::error('参数错误');
  449. }
  450. $orgId = (int)$dd[0];
  451. // $orgId = 23;
  452. $this->assign('orgId',input('orgId','','trim'));
  453. $id = input('id/d',0);
  454. $ret = Db::name('daily_record')->where('id', $id)->where('org_id', $orgId)->find();
  455. $daily = Db::name('daily')->field('title,content')
  456. ->where('id', $ret['daily_id'])->find();
  457. $ret['daily_name'] = $daily['title'];
  458. $ret['daily_details'] = $daily['content'];
  459. $ret['check_json'] = json_decode($ret['check_json'], true);
  460. $ret['user_name'] = Db::name('user')
  461. ->where('id', $ret['user_id'])->value('real_name');
  462. $this->assign('info', $ret);
  463. return $this->fetch();
  464. }
  465. public function patrol(){
  466. $dd = think_decrypt(input('orgId','','trim'));
  467. if(!$dd){
  468. HelpHander::error('参数错误');
  469. }
  470. $dd = explode('|',$dd);
  471. if(count($dd) != 2){
  472. HelpHander::error('参数错误');
  473. }
  474. $orgId = (int)$dd[0];
  475. // $orgId = 23;
  476. $this->assign('orgId',input('orgId','','trim'));
  477. $lists = Db::name('patrol_task')
  478. ->where('org_id',$orgId)
  479. ->where('del',0)
  480. ->where('start_time','<=',date('Y-m-d H:i:s',time()+12*60*60))
  481. ->field('id,title,status,start_time,end_time')
  482. ->order('start_time desc,id desc')
  483. ->limit(20)
  484. ->select();
  485. $lists = $lists?$lists:[];
  486. // $data = [];
  487. foreach ($lists as $k=>$v){
  488. // if($v['status'] == 0){ //0=未执行 1=执行中 2=已完成 3=未完成 5=中断 6=已关闭
  489. // $status = "未执行";
  490. // }else if($v['status'] == 1){
  491. // $status = "执行中";
  492. // }else if($v['status'] == 2){
  493. // $status = "已完成";
  494. // }else if($v['status'] == 3){
  495. // $status = "未完成";
  496. // }else if($v['status'] == 5){
  497. // $status = "中断";
  498. // }else{
  499. // $status = "已关闭";
  500. // }
  501. $users = Db::name('patrol_task_user')
  502. ->alias('a')
  503. ->join('user u','u.id = a.user_id')
  504. ->where('a.patrol_task_id',$v['id'])
  505. ->column('real_name');
  506. // $arr = [$v['title'],$status,$users?implode(',',$users):''];
  507. // $data[] = $arr;
  508. $lists[$k]['users'] = $users?implode(',',$users):'';
  509. }
  510. $this->assign('lists',$lists);
  511. return $this->fetch();
  512. }
  513. public function pdetail(){
  514. $dd = think_decrypt(input('orgId','','trim'));
  515. if(!$dd){
  516. HelpHander::error('参数错误');
  517. }
  518. $dd = explode('|',$dd);
  519. if(count($dd) != 2){
  520. HelpHander::error('参数错误');
  521. }
  522. $orgId = (int)$dd[0];
  523. // $orgId = 23;
  524. $this->assign('orgId',input('orgId','','trim'));
  525. $id = input('id/d',0);
  526. $info=Db::name('patrol_task')
  527. ->field('id,start_time,end_time,status,title,interrupt_img,interrupt_reson')
  528. ->where('id',$id)
  529. ->where('org_id',$orgId)
  530. ->find();
  531. if(!$info){
  532. HelpHander::error('记录不存在');
  533. }
  534. $info['start_time']=date('Y-m-d H:i',strtotime($info['start_time']));
  535. $info['end_time']=date('Y-m-d H:i',strtotime($info['end_time']));
  536. //获取执行用户
  537. $task_user=Db::name('patrol_task_user')
  538. ->alias('ptu')
  539. ->join('user u','u.id=ptu.user_id')
  540. ->where('ptu.patrol_task_id',$info['id'])
  541. ->column('u.real_name');
  542. $info['task_user']=implode(',',$task_user);
  543. $addrForms = Db::name('patrol_task_addr')
  544. ->alias('a')
  545. ->join('patrol_addr_form b','a.patrol_form_id = b.id')
  546. ->join('address c','c.id = a.address_id')
  547. ->where('a.patrol_task_id',$info['id'])
  548. ->field('a.*,b.title as formTitle,c.title as addrTitle')
  549. ->select();
  550. $addrForms = $addrForms?$addrForms:[];
  551. foreach ($addrForms as $k=>$v){
  552. $record = Db::name('patrol_record')
  553. ->alias('a')
  554. ->join('user b','a.user_id = b.id')
  555. ->where('a.patrol_task_id',$v['patrol_task_id'])
  556. ->where('a.patrol_addr_id',$v['address_id'])
  557. ->field('b.real_name as uname,a.*')
  558. ->find();
  559. if($record){
  560. $cj = $record['check_json']?json_decode($record['check_json'],true):[];
  561. $record['check_json'] = $cj;
  562. $record['images'] = $record['images']?explode(',',$record['images']):[];
  563. }
  564. $addrForms[$k]['record'] = $record?$record:[];
  565. }
  566. $info['addrForms'] = $addrForms;
  567. $this->assign('info',$info);
  568. return $this->fetch();
  569. }
  570. }