|
|
@@ -32,23 +32,11 @@ class OvertimeVerification extends Api
|
|
|
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('db_大废品')->cache(true,86400)
|
|
|
- ->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('绩效工资汇总')->cache(true,86400)
|
|
|
- ->field('sys_ny,bh')
|
|
|
- ->group('sys_ny,bh')
|
|
|
- ->where(['sys_ny'=>['between',"$rows[14],$rows[0]"]])
|
|
|
- ->order('sys_ny desc')
|
|
|
+ $res=db('绩效工资汇总')
|
|
|
+ ->field('DATE_FORMAT(`sczl_rq`, "%Y%m") as sys_ny,bh')
|
|
|
+ ->group('DATE_FORMAT(`sczl_rq`, "%Y%m"),bh')
|
|
|
+ ->whereTime('sczl_rq', '>=', strtotime('-14 months'))
|
|
|
+ ->order('sczl_rq desc')
|
|
|
->select();
|
|
|
foreach($res as $v){
|
|
|
$arr[$v['sys_ny'].'('][]=$v['bh'];
|
|
|
@@ -118,7 +106,7 @@ class OvertimeVerification extends Api
|
|
|
->group('j.bh')
|
|
|
->where('j.sys_ny',$req['date'])
|
|
|
->where(['r.所在部门'=>['like',$req['department'].'%']])
|
|
|
- ->column('CONCAT(j.bh, "-", DATE_FORMAT(sczl_rq,"%Y.%m")) AS rq_bh,j.bh,rtrim(j.xm) as 员工姓名,r.工资表类别,DATE_FORMAT(r.聘用日期,"%Y.%m.%d") as 聘用日期,j.法定天数,
|
|
|
+ ->column('CONCAT(j.bh, "-", DATE_FORMAT(j.sczl_rq,"%Y.%m")) AS rq_bh,j.bh,rtrim(j.xm) as 员工姓名,r.工资表类别,DATE_FORMAT(r.聘用日期,"%Y.%m.%d") as 聘用日期,j.法定天数,
|
|
|
sum(j.达标定额) as 当月定额,(sum(j.班组车头产量*j.工序难度系数)+sum(j.班组换算产量)) as 月度合计产量,sum(j.个人计件工资) as 个人计件工资,
|
|
|
sum(j.个人加班工资) as 个人加班工资,sum(j.异常停机工时) as 月计时时数,LEFT(j.sczl_rq, 7) as sczl_rq');
|
|
|
|
|
|
@@ -128,11 +116,10 @@ class OvertimeVerification extends Api
|
|
|
$end_time = date('Y-m-t', strtotime("$year-$month-01")) . ' 23:59:59';
|
|
|
$arr = [];
|
|
|
$columns = ['wgjs_bh1', 'wgjs_bh2', 'wgjs_bh3', 'wgjs_bh4', 'wgjs_bh5', 'wgjs_bh6'];
|
|
|
- $field = 'wgjs_js';
|
|
|
for ($i = 1; $i <= 6; $i++) {
|
|
|
$column = $columns[$i-1];
|
|
|
$r = db('db_wgjs')->cache(true, 86400)
|
|
|
- ->field("DATE_FORMAT(wgjs_rq,'%Y.%m') as wgjs_rq, $column as wgjs_bh, ${field}${i} as wgjs_js")
|
|
|
+ ->field("DATE_FORMAT(wgjs_rq,'%Y.%m') as wgjs_rq, $column as wgjs_bh, wgjs_js$i as wgjs_js, wgjs_冲定额$i as wgjs_冲定额")
|
|
|
->join('人事_基本资料', "人事_基本资料.员工编号=db_wgjs.$column")
|
|
|
->where(['wgjs_rq' => ['between', "$start_time,$end_time"], '人事_基本资料.所在部门' => ['like', $req['department'] . '%']])
|
|
|
->select();
|
|
|
@@ -143,14 +130,58 @@ class OvertimeVerification extends Api
|
|
|
$list = [];
|
|
|
foreach($arr as $v){
|
|
|
if(isset($list[$v['wgjs_bh'].'-'.$v['wgjs_rq']])){
|
|
|
- $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']+=$v['wgjs_js'];
|
|
|
+ if($v['wgjs_冲定额']=='是'){
|
|
|
+ $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']+=$v['wgjs_js'];
|
|
|
+ }
|
|
|
}else{
|
|
|
$list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['bh']=$v['wgjs_bh'];
|
|
|
$list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['sczl_rq']=$v['wgjs_rq'];
|
|
|
- $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']=$v['wgjs_js'];
|
|
|
+ if($v['wgjs_冲定额']=='是'){
|
|
|
+ $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']=$v['wgjs_js'];
|
|
|
+ }else{
|
|
|
+ $list[$v['wgjs_bh'].'-'.$v['wgjs_rq']]['月计时时数']=0;
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
+ //获取每个员工计时补差天数
|
|
|
+ $arr1 = db('绩效工资汇总')->alias('j')
|
|
|
+ ->field('j.bh,j.sczl_rq')
|
|
|
+ ->join('人事_基本资料 r','r.员工编号=j.bh')
|
|
|
+ ->group('j.bh,j.sczl_rq')
|
|
|
+ ->where('j.sys_ny',$req['date'])
|
|
|
+ ->where('j.达标定额','<>',0)
|
|
|
+ ->where(['r.所在部门'=>['like',$req['department'].'%']])
|
|
|
+ ->buildSql();
|
|
|
+ $arr1 = db()->table($arr1 . ' t')
|
|
|
+ ->group('t.bh, LEFT(t.sczl_rq, 7)')
|
|
|
+ ->column('t.bh,count(LEFT(t.sczl_rq, 7)) as num');
|
|
|
+
|
|
|
+ //查询每条记录
|
|
|
+ $arr2 = db('绩效工资汇总')->alias('j')
|
|
|
+ ->field('j.bh, DATE_FORMAT(j.sczl_rq,"%Y.%m") as sczl_rq,
|
|
|
+ sum(j.达标定额) as 达标定额, j.Rate, j.千件工价')
|
|
|
+ ->join('人事_基本资料 r','r.员工编号=j.bh')
|
|
|
+ ->where('j.sys_ny',$req['date'])
|
|
|
+ ->where('j.达标定额','<>',0)
|
|
|
+ ->where(['r.所在部门'=>['like',$req['department'].'%']])
|
|
|
+ ->group('j.bh,j.sczl_rq,j.sczl_gdbh')
|
|
|
+ ->select();
|
|
|
+ //计算每条记录的计时补差
|
|
|
+ $brr = [];
|
|
|
+ foreach($arr2 as $v){
|
|
|
+ $yjsss1 = array_key_exists($v['bh'].'-'.$v['sczl_rq'],$list) ? $list[$v['bh'].'-'.$v['sczl_rq']]['月计时时数'] : 0;
|
|
|
+ $yjsss2 = array_key_exists($v['bh'].'-'.$v['sczl_rq'],$res) ? $res[$v['bh'].'-'.$v['sczl_rq']]['月计时时数'] : 0;
|
|
|
+ $yjsss = $yjsss1 + $yjsss2;
|
|
|
+ $a = $yjsss/$arr1[$v['bh']]/11*0.6*$v['达标定额']*$v['Rate']*0.5/1000*$v['千件工价'];
|
|
|
+
|
|
|
+ if(array_key_exists($v['bh'].'-'.$v['sczl_rq'],$brr)){
|
|
|
+ $brr[$v['bh'].'-'.$v['sczl_rq']] += $a;
|
|
|
+ }else{
|
|
|
+ $brr[$v['bh'].'-'.$v['sczl_rq']] = $a;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
foreach($res as $k=>&$v){
|
|
|
if(array_key_exists($k,$list)){
|
|
|
$v['月计时时数'] += $list[$k]['月计时时数'];
|
|
|
@@ -160,7 +191,7 @@ class OvertimeVerification extends Api
|
|
|
$v['当月定额'] = round($v['当月定额']);
|
|
|
$v['月度合计产量'] = round($v['月度合计产量']);
|
|
|
$v['月计时时数'] = floatval(number_format($v['月计时时数'],2));
|
|
|
- $v['计时补差'] = floatval(bcmul($v['月计时时数'], 9.5, 2));
|
|
|
+ $v['计时补差'] = floatval(number_format($brr[$k],2));
|
|
|
unset($v['rq_bh']);
|
|
|
}
|
|
|
$res = array_values($res);
|