Browse Source

工资核算优化

曹鹤洋 1 năm trước cách đây
mục cha
commit
67b1dc3b18
1 tập tin đã thay đổi với 11 bổ sung4 xóa
  1. 11 4
      application/api/controller/StaffSalary.php

+ 11 - 4
application/api/controller/StaffSalary.php

@@ -224,9 +224,9 @@ class StaffSalary extends Api
          * 拆片工序数据
         */
         $query = Db::name('db_sczl')->alias('a')
-            ->field('a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, sczl_type, a.sczl_rq, a.sczl_jtbh,
-            a.sczl_ms, a.sczl_cl as 班组车头产量, a.sczl_fp as sczl_zcfp, a.sczl_装版工时 as 装版工时, a.sczl_保养工时 as 保养工时,
-            a.sczl_打样工时 as 打样工时, a.sczl_异常停机工时 as 异常停机工时, a.sczl_设备运行工时 as 车头产量占用机时, a.sczl_bh1,
+            ->field('a.sczl_gdbh, a.sczl_yjno, a.sczl_gxh, sczl_type, a.sczl_rq, a.sczl_jtbh, 
+            a.sczl_ms, a.sczl_cl as 班组车头产量, a.sczl_fp as sczl_zcfp, a.sczl_装版工时 as 装版工时, a.sczl_保养工时 as 保养工时, 
+            a.sczl_打样工时 as 打样工时, a.sczl_异常停机工时 as 异常停机工时, a.sczl_设备运行工时 as 车头产量占用机时, a.sczl_bh1, 
             a.sczl_rate1, b.千件工价, b.日定额, b.补产标准,a.sczl_工价系数 as 工序难度系数,a.拆片联拼系数,a.拆片条小盒系数, d.员工姓名')
             ->join('dic_lzde b', 'a.sczl_dedh = b.sys_bh','left')
             ->join('工单_工艺资料 c', 'a.sczl_gdbh = c.Gy0_gdbh AND a.sczl_yjno = c.Gy0_yjno AND a.sczl_gxh = c.Gy0_gxh','left')
@@ -442,7 +442,7 @@ class StaffSalary extends Api
                         $item['班组车头产量'] = $cl;
                     }
                     $item['工价系数'] = '0.0000';
-                    $item['工序难度系数'] = $value[$jcxsKey];
+                    $item['工序难度系数'] = $value[$gxKey];
                     if ($value[$gxKey] <= 0){
                         $item['工序难度系数'] = '1.0000';
                     }
@@ -472,6 +472,7 @@ class StaffSalary extends Api
                 }
             }
         }
+//        halt($data);
         // 用于存储bh对应的工时占比总和
         $bhTotals = [];
         // 遍历原始数据
@@ -490,6 +491,7 @@ class StaffSalary extends Api
             $day_bh = $item['bh'];
             if (!isset($days[$day_bh])){
                 $days[$day_bh] = [];
+                array_push($days[$day_bh],$item['sczl_rq']);
             }else{
                 if (in_array($item['sczl_rq'],$days[$day_bh]) == false){
                     array_push($days[$day_bh],$item['sczl_rq']);
@@ -510,6 +512,10 @@ class StaffSalary extends Api
                 $pieceWorkWage = 0;
                 //加班工资
                 $overTimePay = $item['核算产量'] / 1000 *$item['千件工价'] * $item['Rate'] *3;
+                //法定节假日,去除这天的考勤天数
+                $days[$day_bh] = array_filter($days[$day_bh], function($value) use ($item) {
+                    return $value !== $item['sczl_rq'];
+                });
             }else{
                 //如果出勤天数小于法定天数,按正常计算
                 if (count($days[$day_bh]) <= $params['days']){
@@ -529,6 +535,7 @@ class StaffSalary extends Api
             $data[$key]['法定天数'] = $params['days'];
             $data[$key]['sczl_type'] = trim($item['sczl_type']);
         }
+
         // 检查任务是否已经存在于队列中,如果不存在则推送任务到队列
         if (!$redis->has($taskIdentifier)) {
             $job = new InsertDataJob($data); // 创建任务实例