WorkOrderVerification.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']);
  50. }
  51. $this->success('成功',$rows);
  52. }
  53. /**
  54. * 获取工单核验单列表
  55. * @ApiMethod (GET)
  56. * @param string $date 时间
  57. * @param string $sys_id 用户
  58. */
  59. public function getList()
  60. {
  61. //get请求
  62. if(!$this->request->isGet()){
  63. $this->error('请求方式错误');
  64. }
  65. $req = $this->request->param();
  66. $page = 1;
  67. $limit = 15;
  68. if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
  69. if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
  70. $where = [];
  71. if (isset($req['date']) && !empty($req['date'])){
  72. $where['sys_rq'] = ['LIKE',$req['date'].'%'];
  73. }else{
  74. $this->error('参数错误');
  75. }
  76. if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['sys_id'] = ['LIKE','%'.$req['sys_id'].'%'];
  77. $rows = db()->table('db_qczl')
  78. ->field('qczl_gdbh, qczl_yjno, LEFT(qczl_rq, 10) as qczl_rq, qczl_num, rtrim(qczl_NumDesc) as qczl_NumDesc, qczl_fp,
  79. fp_lb1, fp_lb2, fp_lb3, fp_lb4, fp_lb5, fp_lb6, fp_lb7, fp_lb8, fp_lb9, fp_lb10, fp_lb11, fp_lb12, fp_lb13, fp_lb14, fp_lb15, fp_lb16, fp_lb17,
  80. fp_sl1, fp_sl2, fp_sl3, fp_sl4, fp_sl5, fp_sl6, fp_sl7, fp_sl8, fp_sl9, fp_sl10, fp_sl11, fp_sl12, fp_sl13, fp_sl14, fp_sl15, fp_sl16, fp_sl17,
  81. rtrim(sys_id) as sys_id')
  82. ->where($where)
  83. ->order('UniqId desc')
  84. ->page($page,$limit)
  85. ->select();
  86. $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc');
  87. foreach ($rows as $key=>$value){
  88. $rows[$key]['Gd_cpmc'] = array_key_exists($value['qczl_gdbh'],$gd) ? sprintf("%02d", $value['qczl_yjno']).'-'.trim($gd[$value['qczl_gdbh']]) : '';
  89. for ($i=1;$i<=17;$i++){
  90. if ($value['fp_sl'.$i]==0){
  91. $rows[$key]['sl_lb'.$i] = '';
  92. }else{
  93. $rows[$key]['sl_lb'.$i] = trim($value['fp_sl'.$i].'-->'.$value['fp_lb'.$i]);
  94. }
  95. unset($rows[$key]['fp_sl'.$i]);
  96. unset($rows[$key]['fp_lb'.$i]);
  97. }
  98. }
  99. $data = [
  100. 'rows' => $rows,
  101. ];
  102. $this->success('成功',$data);
  103. }
  104. /**
  105. * 获取工单核验单信息
  106. * @ApiMethod (GET)
  107. * @param string $UniqId UniqId
  108. */
  109. public function getInfo()
  110. {
  111. //get请求
  112. if(!$this->request->isGet()){
  113. $this->error('请求方式错误');
  114. }
  115. $req = $this->request->param();
  116. if (isset($req['UniqId']) && !empty($req['UniqId'])){
  117. $UniqId = $req['UniqId'];
  118. }else{
  119. $this->error('参数错误');
  120. }
  121. $rows = db()->table('db_qczl')->alias('d')
  122. ->field('d.*, ')
  123. ->join('工单_基本资料 g', 'd.')
  124. ->where('d.UniqId',$UniqId)
  125. ->select();
  126. $this->success('成功',$rows);
  127. }
  128. }