success('请求成功'); } /** * 获取工单核验单侧边栏 * @ApiMethod (GET) */ public function getTab() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $rows = db()->table('db_qczl') ->field('LEFT(sys_rq, 10) as date, COUNT(*) as counts') ->group('date') ->order('UniqId desc') ->limit(30) ->select(); $arr = db()->table('db_qczl') ->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]); } } $rows[$key]['date'] = str_replace('-', '.', $rows[$key]['date']); } $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(); $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('参数错误'); } if (isset($req['sys_id']) && !empty($req['sys_id'])) $where['sys_id'] = ['LIKE','%'.$req['sys_id'].'%']; if (isset($req['order']) && !empty($req['order'])) $where['qczl_gdbh'] = $req['order']; $rows = db()->table('db_qczl') ->field('qczl_gdbh, qczl_yjno, LEFT(qczl_rq, 10) as qczl_rq, qczl_num, rtrim(qczl_NumDesc) as qczl_NumDesc, qczl_fp, fp_lb1, fp_lb2, fp_lb3, fp_lb4, fp_lb5, fp_lb6, fp_lb7, fp_lb8, fp_lb9, fp_lb10, fp_lb11, fp_lb12, fp_lb13, fp_lb14, fp_lb15, fp_lb16, fp_lb17, fp_sl1, fp_sl2, fp_sl3, fp_sl4, fp_sl5, fp_sl6, fp_sl7, fp_sl8, fp_sl9, fp_sl10, fp_sl11, fp_sl12, fp_sl13, fp_sl14, fp_sl15, fp_sl16, fp_sl17, rtrim(sys_id) as sys_id,UniqId') ->where($where) ->order('UniqId desc') ->page($page,$limit) ->select(); $total = db()->table('db_qczl')->where($where)->count(); $gd = db()->table('工单_基本资料')->column('Gd_gdbh, Gd_cpmc'); foreach ($rows as $key=>$value){ $rows[$key]['Gd_cpmc'] = array_key_exists($value['qczl_gdbh'],$gd) ? sprintf("%02d", $value['qczl_yjno']).'-'.trim($gd[$value['qczl_gdbh']]) : ''; for ($i=1;$i<=17;$i++){ if ($value['fp_sl'.$i]==0){ $rows[$key]['sl_lb'.$i] = ''; }else{ $rows[$key]['sl_lb'.$i] = trim($value['fp_sl'.$i].'-->'.$value['fp_lb'.$i]); } unset($rows[$key]['fp_sl'.$i]); unset($rows[$key]['fp_lb'.$i]); } } $data = [ 'total' => $total, '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_qczl')->alias('d') ->field('d.*, ') ->join('工单_基本资料 g', 'd.') ->where('d.UniqId',$UniqId) ->select(); $this->success('成功',$rows); } /** * 获取单个工单核检单信息 * @ApiMethod GET * @params string UniqId */ public function getOneWorkOrder(){ if (Request::instance()->isGet() == false){ $this->error('非法请求'); } $params = Request::instance()->param(); if (!isset($params['UniqId']) || empty($params['UniqId'])){ $this->error('参数错误'); } $list = Db::name('db_qczl')->where('UniqId',$params['UniqId'])->find(); $list['fp_name1'] = ''; if (!empty($list['fp_bh1'])){ $list['fp_name1'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh1'])->value('rtrim(员工姓名)'); } $list['fp_name2'] = ''; if (!empty($list['fp_bh2'])){ $list['fp_name2'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh2'])->value('rtrim(员工姓名)'); } $list['fp_name3'] = ''; if (!empty($list['fp_bh3'])){ $list['fp_name3'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh3'])->value('rtrim(员工姓名)'); } $list['fp_name4'] = ''; if (!empty($list['fp_bh4'])){ $list['fp_name4'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh4'])->value('rtrim(员工姓名)'); } $list['fp_name5'] = ''; if (!empty($list['fp_bh5'])){ $list['fp_name5'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh5'])->value('rtrim(员工姓名)'); } $list['fp_name6'] = ''; if (!empty($list['fp_bh6'])){ $list['fp_name6'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh6'])->value('rtrim(员工姓名)'); } $list['fp_name7'] = ''; if (!empty($list['fp_bh7'])){ $list['fp_name7'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh7'])->value('rtrim(员工姓名)'); } $list['fp_name8'] = ''; if (!empty($list['fp_bh8'])){ $list['fp_name8'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh8'])->value('rtrim(员工姓名)'); } $list['fp_name9'] = ''; if (!empty($list['fp_bh9'])){ $list['fp_name9'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh9'])->value('rtrim(员工姓名)'); } $list['fp_name10'] = ''; if (!empty($list['fp_bh10'])){ $list['fp_name10'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh10'])->value('rtrim(员工姓名)'); } $list['fp_name11'] = ''; if (!empty($list['fp_bh11'])){ $list['fp_name11'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh11'])->value('rtrim(员工姓名)'); } $list['fp_name12'] = ''; if (!empty($list['fp_bh12'])){ $list['fp_name12'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh12'])->value('rtrim(员工姓名)'); } $list['fp_name13'] = ''; if (!empty($list['fp_bh13'])){ $list['fp_name13'] = Db::name('人事_基本资料')->where('员工编号',$list['fp_bh13'])->value('rtrim(员工姓名)'); } $max = Db::name('设备_产量计酬')->where('sczl_gdbh',$list['qczl_gdbh'])->field('MAX(sczl_num) as sczl_num')->find(); $list['total_liucheng'] = $max['sczl_num']; $this->success('请求成功',$list); } /** * 获取工单基本信息 * @ApiMethod GET * @params string order */ public function getOrderInfo(){ if (Request::instance()->isGet() == false){ $this->error('非法请求'); } $params = Request::instance()->param(); if (!isset($params['order']) || empty($params['order'])){ $this->error('参数错误'); } $list = Db::name('工单_基本资料')->alias('a') ->join('工单_印件资料 b','a.Gd_gdbh = b.Yj_Gdbh','left') ->where('a.Gd_gdbh',$params['order']) ->where('a.行号',1) ->field('a.Gd_cpmc,b.yj_Yjno,b.yj_yjmc') ->find(); $this->success('请求成功',$list); } /** * 获取印件名称及工序 * @ApiMethod GET * @params string order * @params string yj_no */ public function getYjInfo(){ if (Request::instance()->isGet() == false){ $this->error('非法请求'); } $params = Request::instance()->param(); if (!isset($params['order']) || empty($params['order'])){ $this->error('参数错误'); } if (!isset($params['yj_no']) || empty($params['yj_no'])){ $this->error('参数错误'); } $where['Yj_Gdbh'] = $params['order']; $where['yj_Yjno'] = $params['yj_no']; $list = Db::name('工单_印件资料')->where($where)->field('yj_yjmc')->find(); $option['Gy0_gdbh'] = $params['order']; $option['Gy0_yjno'] = $params['yj_no']; $option['Gy0_site'] = '检验车间'; $option['Gy0_gxmc'] = array('not in',['包装','外发加工','废挑正','成品防护']); $gxList = Db::name('工单_工艺资料')->where($option)->field('Gy0_gxh,rtrim(Gy0_gxmc) as Gy0_gxmc,rtrim(Add_gxmc) as Add_gxmc')->select(); $max = Db::name('设备_产量计酬')->where('sczl_gdbh',$params['order'])->where('sczl_yjno',$params['yj_no'])->field('MAX(sczl_num) as sczl_num')->value('sczl_num'); $list['gx_data'] = $gxList; $list['max_num'] = $max; $this->success('请求成功',$list); } /** * 获取废品分类 * @ApiMethod GET * @params string search */ public function getWastInfo(){ if (Request::instance()->isGet() == false){ $this->error('非法请求'); } $params = Request::instance()->param(); if (!isset($params['search']) || empty($params['search'])){ $this->error('参数错误'); } $where['分类'] = '废品分类'; $where['名称'] = array('like','%'.$params['search'].'%'); $data = Db::name('erp_常用字典')->where($where)->column('名称'); // 分割字符串并合并相同项 $resultArray = []; foreach ($data as $item) { $parts = explode('_', $item); // 使用第一个部分作为一级键,第二个部分作为二级键 $firstKey = $parts[0]; $secondKey = $parts[1]; $thirdValue = $parts[2]; $resultArray[$firstKey][$secondKey][] = $thirdValue; } // 对废品分类下的数组进行升序排序 if (isset($resultArray['data']['废品分类'])) { foreach ($resultArray['data']['废品分类'] as &$category) { // 判断是关联数组(单凹等)还是索引数组(分切等) if (is_array($category) && !empty($category) && is_array(current($category))) { foreach ($category as &$subCategory) { ksort($subCategory); } } else { ksort($category); } } } $this->success('请求成功',$resultArray); } /** *获取工序及责任组长 * @ApiMethod GET * @params string type * @params string order */ public function getGxAndLeader(){ if (Request::instance()->isGet() == false){ $this->error('非法请求'); } $params = Request::instance()->param(); if (!isset($params['type']) || empty($params['type'])){ $this->error('参数错误'); } if (!isset($params['order']) || empty($params['order'])){ $this->error('参数错误'); } $type = trim($params['type']); $waste = Db::name('erp_常用字典')->where('名称','like','%'.$type.'%')->find(); if (empty($waste)){ $this->error('未查询到废品分类'); } $wasteType = explode('_',substr($waste['名称'],0,-1)); $searchArr = explode('-',$wasteType[1]); $search = substr($searchArr[1],0,6); $where['a.sczl_gdbh'] = $params['order']; $where['a.sczl_type'] = array('like','%'.$search.'%'); $list = Db::name('设备_产量计酬')->alias('a') ->join('人事_基本资料 b','a.sczl_bh1 = b.员工编号','left') ->where($where)->field('distinct(a.sczl_gxmc),a.sczl_bzdh,a.sczl_jtbh,a.sczl_bh1,b.员工姓名 as name') ->select(); $count = count($list); $list[$count]['sczl_gxmc'] = '99-外发加工'; $list[$count]['sczl_bzdh'] = 'A班'; $list[$count]['sczl_jtbh'] = ''; $list[$count]['sczl_bh1'] = '000000'; $list[$count]['name'] = '计时工'; $this->success('请求成功',$list); } }