success('请求成功'); } /** * 获取包装计件单据侧边栏 * @ApiMethod (GET) */ public function getTab() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $rows = db()->table('db_包装计件') ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts') ->group('date') ->order('UniqId desc') ->limit(30) ->select(); $arr = db()->table('db_包装计件') ->field('LEFT(sys_rq, 10) as date, rtrim(sys_id) as sys_id, COUNT(sys_id) as count') ->where('sys_rq','>=',$rows[29]['date']) ->group('date, sys_id') ->select(); foreach($rows as $key=>$value){ $rows[$key]['sys'] = []; foreach($arr as $k=>$v){ if($value['date'] == $v['date']){ unset($v['date']); array_push($rows[$key]['sys'],$v); unset($arr[$k]); } } } $this->success('成功',$rows); } /** * 获取包装计件单据列表 * @ApiMethod (GET) * @param string $date 时间 * @param string $sys_id 用户 */ public function getList() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $req = $this->request->param(); $where = []; if (isset($req['date']) && !empty($req['date'])){ $where['b.sys_rq'] = ['LIKE',$req['date'].'%']; }else{ $this->error('参数错误'); } if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['b.sys_id'] = ['LIKE','%'.$req['sys_id'].'%']; $rows = db()->table('db_包装计件')->alias('b') ->field('b.sczl_bh, rtrim(r.员工姓名) as name, b.sczl_rq, b.sczl_bzdh, b.sczl_cl1 + b.sczl_cl2 + b.sczl_cl3 + b.sczl_cl4 + b.sczl_cl5 + b.sczl_cl6 as sczl_cl, b.sczl_返工产量1 + b.sczl_返工产量2 + b.sczl_返工产量3 + b.sczl_返工产量4 + b.sczl_返工产量5 + b.sczl_返工产量6 as sczl_fgsl, b.sczl_cl1 + b.sczl_cl2 + b.sczl_cl3 + b.sczl_cl4 + b.sczl_cl5 + b.sczl_cl6 + b.sczl_返工产量1 + b.sczl_返工产量2 + b.sczl_返工产量3 + b.sczl_返工产量4 + b.sczl_返工产量5 + b.sczl_返工产量6 as sczl_jjcl, b.sczl_gdbh1, rtrim(b.sys_id) as sys_id, b.sys_rq, b.mod_rq, b.UniqId') ->where($where) ->join(['人事_基本资料'=>'r'],'b.sczl_bh = r.员工编号') ->select(); $data = [ 'rows' => $rows, ]; $this->success('成功',$data); } /** * 获取包装计件单据信息 * @ApiMethod (GET) * @param string $UniqId UniqId */ public function getInfo() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $req = $this->request->param(); if (isset($req['UniqId']) && !empty($req['UniqId'])){ $UniqId = $req['UniqId']; }else{ $this->error('参数错误'); } $rows = db()->table('db_包装计件')->alias('d') ->field('d.*, ') ->join('工单_基本资料 g', 'd.') ->where('d.UniqId',$UniqId) ->select(); $this->success('成功',$rows); } }