LargeWasteRewardPunish.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. /**
  5. * 工序大废品惩奖记录接口
  6. */
  7. class LargeWasteRewardPunish 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_大废品')
  30. ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts')
  31. ->group('date')
  32. ->order('UniqId desc')
  33. ->limit(40)
  34. ->select();
  35. foreach($rows as $key=>$value){
  36. $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']);
  37. }
  38. $this->success('成功',$rows);
  39. }
  40. /**
  41. * 获取工序大废品惩奖列表
  42. * @ApiMethod (GET)
  43. * @param string $date 时间
  44. */
  45. public function getList()
  46. {
  47. //get请求
  48. if(!$this->request->isGet()){
  49. $this->error('请求方式错误');
  50. }
  51. $req = $this->request->param();
  52. $page = 1;
  53. $limit = 15;
  54. if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
  55. if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
  56. $where = [];
  57. if (isset($req['date']) && !empty($req['date'])){
  58. $where['sys_rq'] = ['LIKE',$req['date'].'%'];
  59. }else{
  60. $this->error('参数错误');
  61. }
  62. $rows = db()->table('db_大废品')
  63. ->field('sczl_gdbh, LEFT(sczl_rq, 10) as sczl_rq, rtrim(sczl_numDesc) as sczl_numDesc, sczl_ls, sczl_yjno,
  64. rtrim(责任部门) as 责任部门, CAST(sczl_cl AS SIGNED) as sczl_cl,
  65. rtrim(sczl_fplxA) as sczl_fplxA, sczl_fplxB, Jl_bzdh, JL_bh1,
  66. sczl_bzdh, sczl_bh1, sczl_bh2, rtrim(sys_id) as sys_id, sys_rq, UniqId')
  67. ->where($where)
  68. ->order('UniqId desc')
  69. ->page($page,$limit)
  70. ->select();
  71. $total = db()->table('db_大废品')->where($where)->count();
  72. $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc');
  73. $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名');
  74. foreach ($rows as $key=>$value) {
  75. $rows[$key]['Gd_cpmc'] = array_key_exists($value['sczl_gdbh'],$gd) ? sprintf("%02d", $value['sczl_yjno']).'-'.trim($gd[$value['sczl_gdbh']]) : '';
  76. $rows[$key]['JL_bh1'] = array_key_exists($value['JL_bh1'],$rs) ? trim($rs[$value['JL_bh1']]) : '';
  77. $rows[$key]['sczl_bh1'] = array_key_exists($value['sczl_bh1'],$rs) ? trim($rs[$value['sczl_bh1']]) : '';
  78. $rows[$key]['sczl_bh2'] = array_key_exists($value['sczl_bh2'],$rs) ? trim($rs[$value['sczl_bh2']]) : '';
  79. $rows[$key]['sczl_fplxB'] = $value['sczl_fplxB'] == 1 ? '制程废' : '';
  80. unset($rows[$key]['sczl_yjno']);
  81. }
  82. $data = [
  83. 'total' => $total,
  84. 'rows' => $rows,
  85. ];
  86. $this->success('成功',$data);
  87. }
  88. /**
  89. * 获取工序大废品惩奖信息
  90. * @ApiMethod (GET)
  91. * @param string $UniqId UniqId
  92. */
  93. public function getInfo()
  94. {
  95. //get请求
  96. if(!$this->request->isGet()){
  97. $this->error('请求方式错误');
  98. }
  99. $req = $this->request->param();
  100. if (isset($req['UniqId']) && !empty($req['UniqId'])){
  101. $UniqId = $req['UniqId'];
  102. }else{
  103. $this->error('参数错误');
  104. }
  105. $rows = db()->table('db_大废品')->alias('d')
  106. ->field('d.*, ')
  107. ->join('工单_基本资料 g', 'd.')
  108. ->where('d.UniqId',$UniqId)
  109. ->select();
  110. $this->success('成功',$rows);
  111. }
  112. }