success('请求成功'); } /** * 获取其他计件单据侧边栏 * @ApiMethod (GET) */ public function getTab() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $rows = db()->table('db_拉料计件') ->field('LEFT(Sczl_rq, 7) as date, CAST(sum(Sczl_cl) AS SIGNED) as counts') ->group('date') ->order('UniqId desc') ->limit(13) ->select(); $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名'); foreach($rows as $key=>$value){ $arr = db()->table('db_拉料计件') ->field('rtrim(Sczl_bh1) as Sczl_bh1, CAST(sum(Sczl_cl) AS SIGNED) as count') ->where('sczl_rq','LIKE',$value['date'].'%') ->group('Sczl_bh1') ->select(); foreach ($arr as $k=>$v) { $arr[$k]['name'] = array_key_exists($v['Sczl_bh1'],$rs) ? trim($rs[$v['Sczl_bh1']]) : ''; } $rows[$key]['sys'] = $arr; $rows[$key]['date'] = str_replace('-', '', $rows[$key]['date']); } $this->success('成功',$rows); } /** * 获取其他计件单据列表 * @ApiMethod (GET) * @param string $date 时间 * @param string $Sczl_bh1 员工编号 */ public function getList() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $req = $this->request->param(); $page = 1; $limit = 15; if (isset($req['page']) && !empty($req['page'])) $page = $req['page']; if (isset($req['limit']) && !empty($req['limit'])) $limit = $req['limit']; $where = []; if (isset($req['date']) && !empty($req['date'])){ $where['Sczl_rq'] = ['LIKE',$req['date'].'%']; }else{ $this->error('参数错误'); } if (isset($req['Sczl_bh1']) && !empty($req['Sczl_bh1'])) $where['Sczl_bh1'] = $req['Sczl_bh1']; $rows = db()->table('db_拉料计件') ->field('rtrim(sczl_Type) as sczl_Type, LEFT(Sczl_rq, 10) as Sczl_rq, Sczl_bh1, sczl_gdbh, CAST(Sczl_cl AS SIGNED) as Sczl_cl, rtrim(Sczl_desc) as Sczl_desc, rtrim(Sczl_gxmc) as Sczl_gxmc, sczl_yjno, sczl_gxh, rtrim(sys_id) as sys_id, sys_rq, mod_rq, UniqId') ->where($where) ->page($page,$limit) ->order('Sczl_rq asc, UniqId asc') ->select(); $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc'); $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名'); foreach ($rows as $key=>$value) { $rows[$key]['mod_rq'] = $value['mod_rq']=='1900-01-01 00:00:00' ? '' :$value['mod_rq']; $rows[$key]['Gd_cpmc'] = array_key_exists($value['sczl_gdbh'],$gd) ? trim($gd[$value['sczl_gdbh']]) : ''; $rows[$key]['name'] = array_key_exists($value['Sczl_bh1'],$rs) ? trim($rs[$value['Sczl_bh1']]) : ''; } $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); } }