Ver Fonte

Merge branch 'master' of https://git.7in6.com/Minong/mes-server-api

曹鹤洋 há 1 ano atrás
pai
commit
2fc5f1b684

+ 26 - 10
application/api/controller/StaffSalary.php

@@ -7,7 +7,6 @@ use think\Db;
 use app\job\InsertDataJob;
 use think\Queue;
 use think\Cache;
-
 /**
  * 员工计件工资核算
 */
@@ -44,6 +43,15 @@ class StaffSalary extends Api
         {
             $this->error('参数错误');
         }
+        $startDate = $params['start_date'];
+        $endDate = $params['end_date'];
+        $attendanceMonth = $params['date'];
+        // 确保开始日期和结束日期在考勤年月的范围内
+        $startDateInRange = date('Ym', strtotime($startDate)) === $attendanceMonth;
+        $endDateInRange = date('Ym', strtotime($endDate)) === $attendanceMonth;
+        if (!$startDateInRange || !$endDateInRange) {
+           $this->error('日期参数错误');
+        }
         $vacationOneArr = [];
         if (!empty($params['vacation_one_start']) && !empty($params['vacation_one_end'])){
             $vacationOneStart = strtotime($params['vacation_one_start']);
@@ -62,8 +70,11 @@ class StaffSalary extends Api
                 array_push($vacationTwoArr,date("Y-m-d", $i));
             }
         }
-        $startDate = $params['start_date'];
-        $endDate = $params['end_date'];
+        //法定天数
+        $clocking_in_day = \db('人事_考勤资料')->where('kqzl_ny',$params['date'])->field('法定天数')->order('UniqId desc')->find();
+        if (!empty($clocking_in_day)){
+            $params['days'] = (int)$clocking_in_day['法定天数'];
+        }
         //将起止日期内数据删除
         $delRes = \db('绩效工资汇总')->where('sczl_rq','between',[$startDate,$endDate])->delete();
         $where = [];
@@ -468,14 +479,19 @@ class StaffSalary extends Api
             $data[$key]['法定天数'] = $params['days'];
             $data[$key]['sczl_type'] = trim($item['sczl_type']);
         }
-        $num = round(count($data)/10000);
-        for ($i = 0; $i <= $num; $i++){
-            $start = $i * 10000;
-            $res = array_slice($data,$start,10000);
-            $job = new InsertDataJob($res); // 创建任务实例
-            Queue::push($job,'','default'.$i); // 推送任务到队列
-        }
+//        $num = round(count($data)/10000);
+//        for ($i = 0; $i <= $num; $i++){
+//            $start = $i * 10000;
+//            $res = array_slice($data,$start,10000);
+//            $job = new InsertDataJob($res); // 创建任务实例
+//            Queue::push($job,'','default'.$i); // 推送任务到队列
+//        }
+
+        $job = new InsertDataJob($data); // 创建任务实例
+        Queue::push($job,'','default'); // 推送任务到队列
         $this->success('数据正在处理中,请等待...');
+
+
     }
 
 }

+ 1 - 1
application/job/InsertDataJob.php

@@ -51,7 +51,7 @@ class InsertDataJob
             $handData[$key]['sys_id'] = $value['sys_id'];
             $handData[$key]['法定天数'] = $value['法定天数'];
         }
-        $sql =Db::name('绩效工资汇总_temp')->fetchSql(true)->insertAll($handData);
+        $sql =Db::name('绩效工资汇总')->fetchSql(true)->insertAll($handData);
         $res = Db::query($sql);
         if ($res !== false){
             // 获取队列的键名