OtherCountDocument.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. $where = [];
  61. if (isset($req['date']) && !empty($req['date'])){
  62. $where['b.Sczl_rq'] = ['LIKE',$req['date'].'%'];
  63. }else{
  64. $this->error('参数错误');
  65. }
  66. if (isset($req['Sczl_bh1']) && !empty($req['Sczl_bh1'])) $where['b.Sczl_bh1'] = $req['Sczl_bh1'];
  67. $rows = db()->table('db_拉料计件')->alias('b')
  68. ->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,
  69. 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')
  70. ->where($where)
  71. ->join(['人事_基本资料'=>'r'],'b.Sczl_bh1 = r.员工编号')
  72. ->join(['工单_基本资料'=>'g'],'b.sczl_gdbh = g.Gd_gdbh')
  73. ->group('b.sys_rq')
  74. ->order('b.Sczl_rq asc, b.UniqId asc')
  75. ->select();
  76. $data = [
  77. 'rows' => $rows,
  78. ];
  79. $this->success('成功',$data);
  80. }
  81. /**
  82. * 获取其他计件单据信息
  83. * @ApiMethod (GET)
  84. * @param string $UniqId UniqId
  85. */
  86. public function getInfo()
  87. {
  88. //get请求
  89. if(!$this->request->isGet()){
  90. $this->error('请求方式错误');
  91. }
  92. $req = $this->request->param();
  93. if (isset($req['UniqId']) && !empty($req['UniqId'])){
  94. $UniqId = $req['UniqId'];
  95. }else{
  96. $this->error('参数错误');
  97. }
  98. $rows = db()->table('db_拉料计件')->alias('d')
  99. ->field('d.*, ')
  100. ->join('工单_基本资料 g', 'd.')
  101. ->where('d.UniqId',$UniqId)
  102. ->select();
  103. $this->success('成功',$rows);
  104. }
  105. }