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(40) ->select(); foreach($rows as $key=>$value){ $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']); } $this->success('成功',$rows); } /** * 获取工序大废品惩奖列表 * @ApiMethod (GET) * @param string $date 时间 */ 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['sys_rq'] = ['LIKE',$req['date'].'%']; }else{ $this->error('参数错误'); } $rows = db()->table('db_大废品') ->field('sczl_gdbh, LEFT(sczl_rq, 10) as sczl_rq, rtrim(sczl_numDesc) as sczl_numDesc, sczl_ls, sczl_yjno, rtrim(责任部门) as 责任部门, CAST(sczl_cl AS SIGNED) as sczl_cl, rtrim(sczl_fplxA) as sczl_fplxA, sczl_fplxB, Jl_bzdh, JL_bh1, sczl_bzdh, sczl_bh1, sczl_bh2, rtrim(sys_id) as sys_id, sys_rq, UniqId') ->where($where) ->order('UniqId desc') ->page($page,$limit) ->select(); $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc'); $rs = db()->table('人事_基本资料')->column('员工编号, 员工姓名'); foreach ($rows as $key=>$value) { $rows[$key]['Gd_cpmc'] = array_key_exists($value['sczl_gdbh'],$gd) ? sprintf("%02d", $value['sczl_yjno']).'-'.trim($gd[$value['sczl_gdbh']]) : ''; $rows[$key]['JL_bh1'] = array_key_exists($value['JL_bh1'],$rs) ? trim($rs[$value['JL_bh1']]) : ''; $rows[$key]['sczl_bh1'] = array_key_exists($value['sczl_bh1'],$rs) ? trim($rs[$value['sczl_bh1']]) : ''; $rows[$key]['sczl_bh2'] = array_key_exists($value['sczl_bh2'],$rs) ? trim($rs[$value['sczl_bh2']]) : ''; $rows[$key]['sczl_fplxB'] = $value['sczl_fplxB'] == 1 ? '制程废' : ''; unset($rows[$key]['sczl_yjno']); } $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); } }