request->isGet() === false){ $this->error('请求错误'); } $param = $this->request->param(); $where = [ 'gd_statu' => '1-已完工', ]; if (isset($param['search'])){ $where['Gd_gdbh|Gd_客户代号|成品名称'] = ['like','%'.$param['search'].'%']; }else{ $where['Mod_rq'] = ['between',[date('Y-m-d 00:00:00',time()-1209600),date('Y-m-d H:i:s',time())]]; } $list = \db('工单_基本资料') ->field('Gd_gdbh,Gd_cpmc,行号') ->where($where) ->group('行号') ->select(); if (empty($list)){ $this->success('未找到工单'); } foreach ($list as $key=>$value){ $list[$key]['工单'] = $value['Gd_gdbh'].'-'.$value['行号'].'-'.$value['Gd_cpmc']; } $this->success('成功',$list); } /** * 获取左侧菜单栏 * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function GetList() { if ($this->request->isGet() === false){ $this->error('参数错误'); } $param = $this->request->param(); if (empty($param) || isset($param['gdbh']) === false || isset($param['yjno']) === false){ $this->error('参数错误'); } $list = db('设备_产量计酬') ->field('DISTINCT(sczl_num) as num') ->where('sczl_gdbh',$param['gdbh']) ->where('sczl_yjno',$param['yjno']) ->order('num') ->select(); if (empty($list)){ $this->success('未找到流程单信息'); } foreach ($list as $key => $value){ $list[$key]['流程单'] = '第'.$value['num'].'个流程单'; } $cpmc = db('工单_基本资料') ->where('Gd_gdbh',$param['gdbh']) ->where('行号',$param['yjno']) ->column('Gd_cpmc')[0]; $data[$param['gdbh'].'-'.$cpmc]['印件'.$param['yjno']] = $list; $this->success('成功',$data); } /** * 获取工单信息 * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function GetOrderDetail() { if ($this->request->isGet() === false){ $this->error('请求错误'); } $param = $this->request->param(); if (empty($param) || isset($param['gdbh']) === false || isset($param['yjno']) === false){ $this->error('参数错误'); } $list = db('工单_基本资料') ->field('Gd_gdbh,Gd_cpdh,Gd_cpmc,订单数量,实际投料,计量单位,投料率') ->where('Gd_gdbh',$param['gdbh']) ->where('行号',$param['yjno']) ->find(); if (empty($list)){ $this->success('未找到该工单信息'); }else{ $this->success('成功',$list); } } /** * 工艺及生产班组数据获取 * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function ProcessList() { if ($this->request->isGet() === false){ $this->error('请求错误'); } $param = $this->request->param(); if (!isset($param['gdbh']) || !isset($param['yjno']) || !isset($param['num'])){ $this->error('参数错误'); } $query= db('设备_产量计酬') ->alias('a') ->field('a.sczl_num as 流程单号,a.sczl_gxh as 工序号,a.sczl_gxmc as 工序名称,a.sczl_rq as 生产日期, a.sczl_jtbh as 机台编号,a.sczl_bh1,a.sczl_bh2,a.sczl_bh3,a.sczl_bh4,a.sczl_bh5,a.sczl_bh6,a.sczl_bh7, a.sczl_bh8,a.sczl_bh9,a.sczl_bh10,d1.员工姓名 as name1,d2.员工姓名 as name2,d3.员工姓名 as name3,d4.员工姓名 as name4,d5.员工姓名 as name5,d6.员工姓名 as name6,d7.员工姓名 as name7,d8.员工姓名 as name8 ,d9.员工姓名 as name9,d10.员工姓名 as name10'); // 循环连接 人事_基本资料 表(仅当 sczl_bh 不为空时才连接) for ($i = 1; $i <= 10; $i++) { $field = 'a.sczl_bh' . $i; $alias = 'd' . $i; $query->join("人事_基本资料 $alias", "$field = {$alias}.员工编号 AND {$field} IS NOT NULL", 'LEFT'); } $list = $query->where('a.sczl_gdbh',$param['gdbh']) ->where('a.sczl_yjno',$param['yjno']) ->where('a.sczl_num',$param['num']) ->order('工序号,生产日期') ->select(); if (empty($list)){ $this->success('未找到该流程单的工艺数据'); }else{ $this->success('成功',$list); } } /** * 制程异常记录 * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function ProcessAnomaly() { if ($this->request->isGet() === false){ $this->error('请求错误'); } $param = $this->request->param(); if (!isset($param['gdbh']) || !isset($param['yjno'])){ $this->error('参数错误'); } $list = db('制程检验_记录附加') ->field('流程单号,缺陷备注') ->where('工单编号',$param['gdbh']) ->where('印件号',$param['yjno']) ->order('流程单号') ->select(); if (empty($list)){ $this->success('未找到记录'); } foreach ($list as $key => $value){ $list[$key]['数量'] = ''; $list[$key]['用户'] = ''; } $this->success('成功',$list); } }