success('请求成功'); } /** * 员工日工资查询侧边栏 * @ApiMethod (GET) */ public function getTab() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } // $rows = db()->table('绩效工资汇总') // ->whereTime('sczl_rq', '>=', strtotime('-15 months')) // ->group('sys_ny') // ->order('sys_ny desc') // ->limit(15) // ->column('sys_ny'); $rows = db()->table('db_大废品') ->whereTime('sys_rq', '>=', strtotime('-15 months')) ->group("DATE_FORMAT(`sys_rq`, '%Y%m')") ->order('sys_rq desc') ->limit(15) ->column("DATE_FORMAT(`sys_rq`, '%Y%m')"); $res=db()->table('绩效工资汇总') ->field('sys_ny,bh') ->group('sys_ny,bh') ->where(['sys_ny'=>['between',"$rows[14],$rows[0]"]]) ->order('sys_ny desc') ->select(); foreach($res as $v){ $arr[$v['sys_ny'].'-'][]=$v['bh']; } $rs = db()->table('人事_基本资料')->column('员工编号,所在部门'); foreach($arr as $k=>$v){ foreach($v as $key=>$value){ $data[$k][$key]=rtrim($rs[$value]); } $data[$k]=array_unique($data[$k]); usort($data[$k], function($a, $b) { $order = array( '胶印车间', '凹印车间', '丝印车间', '模切车间', '检验车间', '精品试验车间', '品保部', '人力资源部', '生产部', '营销部' ); $a_index = array_search($a, $order); $b_index = array_search($b, $order); return $a_index - $b_index; }); } $i=0; foreach($data as $k=>$v){ $datas[$i]['label']=str_replace('-','',$k); foreach($v as $value){ $datas[$i]['children'][]['label']=$value; } $i++; } $this->success('成功',$datas); } /** * 员工日工资查询上侧列表 * @ApiMethod (GET) * @param string $date 年月 * @param string $department 部门 */ public function getList() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $req = $this->request->param(); $res=db()->table('绩效工资汇总') ->join('人事_基本资料','人事_基本资料.员工编号=绩效工资汇总.bh','LEFT') ->field('bh,rtrim(xm) as 员工姓名,LEFT(sczl_rq, 10) as sczl_rq,sum(个人计件工资) as 计件工资, sum(个人加班工资) as 加班工资,(sum(个人计件工资)+sum(个人加班工资)) as 日工资合计') ->group('绩效工资汇总.bh,LEFT(sczl_rq, 10)') ->where('sys_ny',$req['date']) ->where(['人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); if(!$res){ $this->error('失败'); } $year=substr($req['date'],0,4); $month=substr($req['date'],-2); if($month==12){ $start_time=$year.'-12-01 00:00:00'; $end_time=($year+1).'-01-01 00:00:00'; }else{ $start_time=$year.'-'.$month.'-01 00:00:00'; $end_time=$year.'-'.($month+1).'-01 00:00:00'; } $res1=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh1 as wgjs_bh,wgjs_js1 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh1','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $res2=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh2 as wgjs_bh,wgjs_js2 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh2','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $res3=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh3 as wgjs_bh,wgjs_js3 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh3','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $res4=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh4 as wgjs_bh,wgjs_js4 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh4','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $res5=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh5 as wgjs_bh,wgjs_js5 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh5','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $res6=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh6 as wgjs_bh,wgjs_js6 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh6','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $arr=array_merge($res1,$res2,$res3,$res4,$res5,$res6); foreach($arr as $v){ if(isset($list[$v['wgjs_rq']][$v['wgjs_bh']])){ $list[$v['wgjs_rq']][$v['wgjs_bh']]+=$v['wgjs_js']; }else{ $list[$v['wgjs_rq']][$v['wgjs_bh']]=$v['wgjs_js']; } } foreach($res as &$v){ if(isset($list[$v['sczl_rq']][$v['bh']])){ $v['计时']=$list[$v['sczl_rq']][$v['bh']]; }else{ $v['计时']=''; } $v['sczl_rq']=str_replace('-','.',$v['sczl_rq']); } $this->success('成功',$res); } /** * 员工日工资查询下侧列表 * @ApiMethod (GET) * @param string $date 年月 * @param string $code 员工编号 */ public function getAllList() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $req = $this->request->param(); $res=db()->table('绩效工资汇总') ->field('LEFT(sczl_rq, 10) as sczl_rq,sczl_gdbh,rtrim(g.Gd_cpmc) as Gd_cpmc,sczl_yjno,sczl_gxh,sczl_type, sczl_jtbh,sum(班组车头产量) as 班组车头产量,sum(班组换算产量) as 班组换算产量,工序难度系数,sum(个人计件工资) as 个人计件工资,sum(个人加班工资) as 个人加班工资,sum(装版工时) as 装版工时,sum(保养工时) as 保养工时, sum(打样工时) as 打样工时,sum(异常停机工时) as 异常停机工时,sum(车头产量占用机时) as 车头产量占用机时,日定额, sum(达标定额) as 达标定额,千件工价,补产标准,bh,rtrim(xm) as xm,Rate') ->join('工单_基本资料 g','g.Gd_gdbh=绩效工资汇总.sczl_gdbh','LEFT') ->group('LEFT(sczl_rq, 10),sczl_gdbh') ->where(['sys_ny'=>$req['date'],'bh'=>$req['code']]) ->select(); if(!$res){ $this->error('失败'); } foreach($res as &$v){ $v['sczl_rq']=str_replace('-','.',$v['sczl_rq']); if($v['sczl_yjno']>9){ $sczl_yjno=$v['sczl_yjno']; }else{ $sczl_yjno='0'.$v['sczl_yjno']; } unset($v['sczl_yjno']); if($v['sczl_gxh']>9){ $sczl_gxh=$v['sczl_gxh']; }else{ $sczl_gxh='0'.$v['sczl_gxh']; } unset($v['sczl_gxh']); $v['sczl_type']=$sczl_yjno.'-'.$sczl_gxh.'-->'.$v['sczl_type']; } $this->success('成功',$res); } /** * 员工日工资查询详情 * @ApiMethod (GET) * @param string $date 日期 * @param string $code 员工编号 */ public function getDetail() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $req = $this->request->param(); $start_time=$req['date'].' 00:00:00'; $end_time=$req['date'].' 23:59:59'; $res=db()->table('绩效工资汇总') ->field('LEFT(sczl_rq, 10) as sczl_rq,sczl_gdbh,rtrim(g.Gd_cpmc) as Gd_cpmc,sczl_yjno,sczl_gxh,sczl_type, sczl_jtbh,sum(班组车头产量) as 班组车头产量,sum(班组换算产量) as 班组换算产量,工序难度系数,sum(个人计件工资) as 个人计件工资,sum(个人加班工资) as 个人加班工资,sum(装版工时) as 装版工时,sum(保养工时) as 保养工时, sum(打样工时) as 打样工时,sum(异常停机工时) as 异常停机工时,sum(车头产量占用机时) as 车头产量占用机时,日定额, sum(达标定额) as 达标定额,千件工价,补产标准,bh,rtrim(xm) as xm,Rate') ->join('工单_基本资料 g','g.Gd_gdbh=绩效工资汇总.sczl_gdbh','LEFT') ->group('LEFT(sczl_rq, 10),sczl_gdbh') ->where(['sczl_rq'=>['between',"$start_time,$end_time"],'bh'=>$req['code']]) ->select(); if(!$res){ $this->error('失败'); } foreach($res as &$v){ $v['sczl_rq']=str_replace('-','.',$v['sczl_rq']); if($v['sczl_yjno']>9){ $sczl_yjno=$v['sczl_yjno']; }else{ $sczl_yjno='0'.$v['sczl_yjno']; } unset($v['sczl_yjno']); if($v['sczl_gxh']>9){ $sczl_gxh=$v['sczl_gxh']; }else{ $sczl_gxh='0'.$v['sczl_gxh']; } unset($v['sczl_gxh']); $v['sczl_type']=$sczl_yjno.'-'.$sczl_gxh.'-->'.$v['sczl_type']; } $this->success('成功',$res); } /** * 获取计件工计时单信息 * @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_wgjs')->alias('d') ->field('d.*, ') ->join('工单_基本资料 g', 'd.') ->where('d.UniqId',$UniqId) ->select(); $this->success('成功',$rows); } /** * 定位 * @ApiMethod GET */ public function search(){ //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $req = $this->request->param(); $yg = db()->table('人事_基本资料')->where('员工姓名',$req['search'])->value('员工编号'); if($yg){ $req['search']=$yg; } $res=db()->table('绩效工资汇总') // ->join('人事_基本资料','人事_基本资料.员工编号=绩效工资汇总.bh','LEFT') ->field('bh,xm as 员工姓名,LEFT(sczl_rq, 10) as sczl_rq,sum(个人计件工资) as 计件工资, sum(个人加班工资) as 加班工资,(sum(个人计件工资)+sum(个人加班工资)) as 日工资合计') ->group('绩效工资汇总.bh,LEFT(sczl_rq, 10)') ->where('sys_ny',$req['date']) ->where('bh',$req['search']) // ->where('人事_基本资料.所在部门',$req['department']) ->select(); if(!$res){ $this->error('失败'); } $year=substr($req['date'],0,4); $month=substr($req['date'],-2); if($month==12){ $start_time=$year.'-12-01 00:00:00'; $end_time=($year+1).'-01-01 00:00:00'; }else{ $start_time=$year.'-'.$month.'-01 00:00:00'; $end_time=$year.'-'.($month+1).'-01 00:00:00'; } $res1=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh1 as wgjs_bh,wgjs_js1 as wgjs_js') // ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh1','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'wgjs_bh1'=>$req['search']]) ->select(); $res2=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh2 as wgjs_bh,wgjs_js2 as wgjs_js') // ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh2','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'wgjs_bh2'=>$req['search']]) ->select(); $res3=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh3 as wgjs_bh,wgjs_js3 as wgjs_js') // ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh3','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'wgjs_bh3'=>$req['search']]) ->select(); $res4=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh4 as wgjs_bh,wgjs_js4 as wgjs_js') // ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh4','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'wgjs_bh4'=>$req['search']]) ->select(); $res5=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh5 as wgjs_bh,wgjs_js5 as wgjs_js') // ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh5','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'wgjs_bh5'=>$req['search']]) ->select(); $res6=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh6 as wgjs_bh,wgjs_js6 as wgjs_js') // ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh6','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'wgjs_bh6'=>$req['search']]) ->select(); $arr=array_merge($res1,$res2,$res3,$res4,$res5,$res6); foreach($arr as $v){ if(isset($list[$v['wgjs_rq']][$v['wgjs_bh']])){ $list[$v['wgjs_rq']][$v['wgjs_bh']]+=$v['wgjs_js']; }else{ $list[$v['wgjs_rq']][$v['wgjs_bh']]=$v['wgjs_js']; } } foreach($res as &$v){ $v['sczl_rq']=str_replace('-','.',$v['sczl_rq']); if(isset($list[$v['sczl_rq']][$v['bh']])){ $v['计时']=$list[$v['sczl_rq']][$v['bh']]; }else{ $v['计时']=''; } } $this->success('成功',$res); } /** * 员工计件明细 * @ApiMethod (GET) * @param string $start_time * @param string $end_time * @param string $code 员工编号 */ public function getPieceDetail() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $req = $this->request->param(); $req['start_time']=str_replace('.','-',$req['start_time']); $req['end_time']=str_replace('.','-',$req['end_time']); $start_time=$req['start_time'].' 00:00:00'; $end_time=$req['end_time'].' 23:59:59'; $res=db()->table('绩效工资汇总') ->field('LEFT(sczl_rq, 10) as sczl_rq,sczl_gdbh,rtrim(g.员工姓名) as 员工资料,sczl_yjno,sczl_gxh,sczl_type, sczl_jtbh,班组车头产量,保养工时,装版工时,打样工时,异常停机工时,补产标准,计时补差额工资 as 班组补产,日定额,达标定额,千件工价, 个人计件工资,个人加班工资,Rate as 个人比例') ->join('人事_基本资料 g','人事_基本资料.员工编号=绩效工资汇总.bh','LEFT') ->where(['sczl_rq'=>['between',"$start_time,$end_time"],'bh'=>$req['code']]) ->select(); if(!$res){ $this->error('失败'); } foreach($res as &$v){ $v['sczl_rq']=str_replace('-','.',$v['sczl_rq']); if($v['sczl_yjno']>9){ $sczl_yjno=$v['sczl_yjno']; }else{ $sczl_yjno='0'.$v['sczl_yjno']; } unset($v['sczl_yjno']); if($v['sczl_gxh']>9){ $sczl_gxh=$v['sczl_gxh']; }else{ $sczl_gxh='0'.$v['sczl_gxh']; } unset($v['sczl_gxh']); $v['sczl_type']=$sczl_yjno.'-'.$sczl_gxh.'-->'.$v['sczl_type']; $v['班组补产']=$v['补产标准']*($v['保养工时']+$v['装版工时']+$v['打样工时']+$v['异常停机工时']); } $this->success('成功',$res); } /** * 每日工资统计 * @ApiMethod (GET) * @param string $date 年月 * @param string $department 部门 */ public function statistics() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $req = $this->request->param(); $res=db()->table('绩效工资汇总') ->join('人事_基本资料','人事_基本资料.员工编号=绩效工资汇总.bh','LEFT') ->field('bh,rtrim(xm) as 员工姓名,LEFT(sczl_rq, 10) as sczl_rq,sum(个人计件工资) as 计件工资, sum(个人加班工资) as 加班工资') ->group('绩效工资汇总.bh,LEFT(sczl_rq, 10)') ->where('sys_ny',$req['date']) ->where(['人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); if(!$res){ $this->error('失败'); } $year=substr($req['date'],0,4); $month=substr($req['date'],-2); if($month==12){ $start_time=$year.'-12-01 00:00:00'; $end_time=($year+1).'-01-01 00:00:00'; }else{ $start_time=$year.'-'.$month.'-01 00:00:00'; $end_time=$year.'-'.($month+1).'-01 00:00:00'; } $res1=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh1 as wgjs_bh,wgjs_js1 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh1','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $res2=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh2 as wgjs_bh,wgjs_js2 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh2','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $res3=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh3 as wgjs_bh,wgjs_js3 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh3','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $res4=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh4 as wgjs_bh,wgjs_js4 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh4','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $res5=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh5 as wgjs_bh,wgjs_js5 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh5','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $res6=db()->table('db_wgjs') ->field('LEFT(wgjs_rq, 10) as wgjs_rq,wgjs_bh6 as wgjs_bh,wgjs_js6 as wgjs_js') ->join('人事_基本资料','人事_基本资料.员工编号=db_wgjs.wgjs_bh6','LEFT') ->where(['wgjs_rq'=>['between',"$start_time,$end_time"],'人事_基本资料.所在部门'=>['like',$req['department'].'%']]) ->select(); $arr=array_merge($res1,$res2,$res3,$res4,$res5,$res6); foreach($arr as $v){ if(isset($list[$v['wgjs_rq']][$v['wgjs_bh']])){ $list[$v['wgjs_rq']][$v['wgjs_bh']]+=$v['wgjs_js']; }else{ $list[$v['wgjs_rq']][$v['wgjs_bh']]=$v['wgjs_js']; } } foreach($res as &$v){ if(isset($list[$v['sczl_rq']][$v['bh']])){ $v['计时工资']=$list[$v['sczl_rq']][$v['bh']]; }else{ $v['计时工资']=''; } $v['部门']=$req['department']; $v['sczl_rq']=str_replace('-','.',$v['sczl_rq']); } $this->success('成功',$res); } /** * 月度计时工资调整 * @ApiMethod (GET) * @param string $date 年月 * @param string $code 员工编号 */ public function wageAdjustment() { //get请求 if(!$this->request->isGet()){ $this->error('请求方式错误'); } $req = $this->request->param(); $res=db()->table('绩效加班工资月度修正') ->field('人事_基本资料.所在部门,bh,rtrim(xm) as xm,月计时时数,DATE_FORMAT(sczl_rq,"%Y.%m.%d") as sczl_rq,sczl_gdbh,sczl_yjno,sczl_gxh, 千件工价,Rate,sum(达标定额) as 达标定额,sum(个人计件工资) as 个人计件工资,sum(个人加班工资) as 个人加班工资,计时冲定额,sum(New_计件工资) as New_计件工资,sum(New_加班工资) as New_加班工资,调整量_合计') ->join('人事_基本资料','人事_基本资料.员工编号=绩效加班工资月度修正.bh','LEFT') ->group('LEFT(sczl_rq, 10),sczl_gdbh') ->where(['sys_ny'=>$req['date'],'bh'=>$req['code']]) ->select(); if(!$res){ $this->error('失败'); } foreach($res as &$v){ if($v['sczl_yjno']>9){ $sczl_yjno=$v['sczl_yjno']; }else{ $sczl_yjno='0'.$v['sczl_yjno']; } unset($v['sczl_yjno']); if($v['sczl_gxh']>9){ $sczl_gxh=$v['sczl_gxh']; }else{ $sczl_gxh='0'.$v['sczl_gxh']; } unset($v['sczl_gxh']); $v['sczl_gdbh']=$v['sczl_gdbh'].'-'.$sczl_yjno.'-'.$sczl_gxh; $v['bh']=$v['bh'].' '.$v['xm']; unset($v['xm']); } $this->success('成功',$res); } }