WorkOrderVerification.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. /**
  5. * 工单核验单维护接口
  6. */
  7. class WorkOrderVerification extends Api
  8. {
  9. protected $noNeedLogin = ['*'];
  10. protected $noNeedRight = ['*'];
  11. /**
  12. * 首页
  13. *
  14. */
  15. public function index()
  16. {
  17. $this->success('请求成功');
  18. }
  19. /**
  20. * 获取工单核验单侧边栏
  21. * @ApiMethod (GET)
  22. */
  23. public function getTab()
  24. {
  25. //get请求
  26. if(!$this->request->isGet()){
  27. $this->error('请求方式错误');
  28. }
  29. $rows = db()->table('db_qczl')
  30. ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts')
  31. ->group('date')
  32. ->order('UniqId desc')
  33. ->limit(30)
  34. ->select();
  35. $arr = db()->table('db_qczl')
  36. ->field('LEFT(sys_rq, 10) as date, rtrim(sys_id) as sys_id, COUNT(sys_id) as count')
  37. ->where('sys_rq','>=',$rows[29]['date'])
  38. ->group('date, sys_id')
  39. ->select();
  40. foreach($rows as $key=>$value){
  41. $rows[$key]['sys'] = [];
  42. foreach($arr as $k=>$v){
  43. if($value['date'] == $v['date']){
  44. unset($v['date']);
  45. array_push($rows[$key]['sys'],$v);
  46. unset($arr[$k]);
  47. }
  48. }
  49. }
  50. $this->success('成功',$rows);
  51. }
  52. /**
  53. * 获取工单核验单列表
  54. * @ApiMethod (GET)
  55. * @param string $date 时间
  56. * @param string $sys_id 用户
  57. */
  58. public function getList()
  59. {
  60. //get请求
  61. if(!$this->request->isGet()){
  62. $this->error('请求方式错误');
  63. }
  64. $req = $this->request->param();
  65. $page = 1;
  66. $limit = 15;
  67. if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
  68. if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
  69. $where = [];
  70. if (isset($req['date']) && !empty($req['date'])){
  71. $where['b.sys_rq'] = ['LIKE',$req['date'].'%'];
  72. }else{
  73. $this->error('参数错误');
  74. }
  75. if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['b.sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
  76. $rows = db()->table('db_qczl')->alias('b')
  77. ->field('b.qczl_gdbh, b.qczl_yjno, rtrim(g.Gd_cpmc) as Gd_cpmc, LEFT(b.qczl_rq, 10) as qczl_rq, b.qczl_num, rtrim(b.qczl_NumDesc) as qczl_NumDesc, b.qczl_fp,
  78. b.fp_lb1, b.fp_lb2, b.fp_lb3, b.fp_lb4, b.fp_lb5, b.fp_lb6, b.fp_lb7, b.fp_lb8, b.fp_lb9, b.fp_lb10, b.fp_lb11, b.fp_lb12, b.fp_lb13, b.fp_lb14, b.fp_lb15, b.fp_lb16, b.fp_lb17,
  79. b.fp_sl1, b.fp_sl2, b.fp_sl3, b.fp_sl4, b.fp_sl5, b.fp_sl6, b.fp_sl7, b.fp_sl8, b.fp_sl9, b.fp_sl10, b.fp_sl11, b.fp_sl12, b.fp_sl13, b.fp_sl14, b.fp_sl15, b.fp_sl16, b.fp_sl17,
  80. rtrim(b.sys_id) as sys_id')
  81. ->where($where)
  82. ->join(['工单_基本资料'=>'g'],'b.qczl_gdbh = g.Gd_gdbh')
  83. ->order('b.UniqId desc')
  84. ->page($page,$limit)
  85. ->select();
  86. foreach ($rows as $key=>$value){
  87. for ($i=1;$i<=17;$i++){
  88. if ($value['fp_sl'.$i]==0){
  89. $rows[$key]['sl_lb'.$i] = '';
  90. }else{
  91. $rows[$key]['sl_lb'.$i] = trim($value['fp_sl'.$i].'-->'.$value['fp_lb'.$i]);
  92. }
  93. unset($rows[$key]['fp_sl'.$i]);
  94. unset($rows[$key]['fp_lb'.$i]);
  95. }
  96. }
  97. $data = [
  98. 'rows' => $rows,
  99. ];
  100. $this->success('成功',$data);
  101. }
  102. /**
  103. * 获取工单核验单信息
  104. * @ApiMethod (GET)
  105. * @param string $UniqId UniqId
  106. */
  107. public function getInfo()
  108. {
  109. //get请求
  110. if(!$this->request->isGet()){
  111. $this->error('请求方式错误');
  112. }
  113. $req = $this->request->param();
  114. if (isset($req['UniqId']) && !empty($req['UniqId'])){
  115. $UniqId = $req['UniqId'];
  116. }else{
  117. $this->error('参数错误');
  118. }
  119. $rows = db()->table('db_qczl')->alias('d')
  120. ->field('d.*, ')
  121. ->join('工单_基本资料 g', 'd.')
  122. ->where('d.UniqId',$UniqId)
  123. ->select();
  124. $this->success('成功',$rows);
  125. }
  126. }