OtherCountDocument.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. /**
  5. * 其他计件单据维护接口
  6. */
  7. class OtherCountDocument 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(Sczl_rq, 7) as date, sum(Sczl_cl) as counts')
  31. ->group('date')
  32. ->order('UniqId desc')
  33. ->limit(13)
  34. ->select();
  35. foreach($rows as $key=>$value){
  36. $arr = db()->table('db_拉料计件')->alias('l')
  37. ->field('rtrim(l.Sczl_bh1) as Sczl_bh1, rtrim(r.员工姓名) as name, sum(l.Sczl_cl) as count')
  38. ->where('l.sczl_rq','LIKE',$value['date'].'%')
  39. ->join(['人事_基本资料'=>'r'],'l.Sczl_bh1 = r.员工编号')
  40. ->group('Sczl_bh1')
  41. ->select();
  42. $rows[$key]['sys'] = [];
  43. array_push($rows[$key]['sys'],$arr);
  44. }
  45. $this->success('成功',$rows);
  46. }
  47. /**
  48. * 获取其他计件单据列表
  49. * @ApiMethod (GET)
  50. * @param string $date 时间
  51. * @param string $Sczl_bh1 员工编号
  52. */
  53. public function getList()
  54. {
  55. //get请求
  56. if(!$this->request->isGet()){
  57. $this->error('请求方式错误');
  58. }
  59. $req = $this->request->param();
  60. $page = 1;
  61. $limit = 15;
  62. if (isset($req['page']) && !empty($req['page'])) $page = $req['page'];
  63. if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit'];
  64. $where = [];
  65. if (isset($req['date']) && !empty($req['date'])){
  66. $where['b.Sczl_rq'] = ['LIKE',$req['date'].'%'];
  67. }else{
  68. $this->error('参数错误');
  69. }
  70. if (isset($req['Sczl_bh1']) && !empty($req['Sczl_bh1'])) $where['b.Sczl_bh1'] = $req['Sczl_bh1'];
  71. $rows = db()->table('db_拉料计件')->alias('b')
  72. ->field('rtrim(b.sczl_Type) as sczl_Type, b.Sczl_rq, b.Sczl_bh1, rtrim(r.员工姓名) as name, b.sczl_gdbh, rtrim(g.Gd_cpmc) as Gd_cpmc, b.Sczl_cl,
  73. rtrim(b.Sczl_desc) as Sczl_desc, rtrim(b.Sczl_gxmc) as Sczl_gxmc, b.sczl_yjno, b.sczl_gxh, rtrim(b.sys_id) as sys_id, b.sys_rq, b.mod_rq, b.UniqId')
  74. ->where($where)
  75. ->join(['人事_基本资料'=>'r'],'b.Sczl_bh1 = r.员工编号')
  76. ->join(['工单_基本资料'=>'g'],'b.sczl_gdbh = g.Gd_gdbh')
  77. ->page($page,$limit)
  78. ->group('b.sys_rq')
  79. ->order('b.Sczl_rq asc, b.UniqId asc')
  80. ->select();
  81. $data = [
  82. 'rows' => $rows,
  83. ];
  84. $this->success('成功',$data);
  85. }
  86. /**
  87. * 获取其他计件单据信息
  88. * @ApiMethod (GET)
  89. * @param string $UniqId UniqId
  90. */
  91. public function getInfo()
  92. {
  93. //get请求
  94. if(!$this->request->isGet()){
  95. $this->error('请求方式错误');
  96. }
  97. $req = $this->request->param();
  98. if (isset($req['UniqId']) && !empty($req['UniqId'])){
  99. $UniqId = $req['UniqId'];
  100. }else{
  101. $this->error('参数错误');
  102. }
  103. $rows = db()->table('db_拉料计件')->alias('d')
  104. ->field('d.*, ')
  105. ->join('工单_基本资料 g', 'd.')
  106. ->where('d.UniqId',$UniqId)
  107. ->select();
  108. $this->success('成功',$rows);
  109. }
  110. }