Sfoglia il codice sorgente

更新直认导入的批次问题

sandm 2 anni fa
parent
commit
67e92386d8
1 ha cambiato i file con 9 aggiunte e 5 eliminazioni
  1. 9 5
      app/job/Import.php

+ 9 - 5
app/job/Import.php

@@ -2,8 +2,10 @@
 
 namespace app\job;
 
+use app\common\api\BatchApi;
 use app\common\api\TalentLogApi;
 use app\common\model\TalentChecklog;
+use app\common\state\ProjectState;
 use think\queue\Job;
 use think\facade\Log;
 use think\facade\Db;
@@ -188,7 +190,7 @@ class Import {
                     $datas = $sheet->toArray();
                     $datas = array_slice($datas, 1); //去标题
                     $country = Db::table("sys_dict")->where("pid", 35)->column("code", "name");
-
+                    $batch = BatchApi::getValidBatch(ProjectState::TALENT, 1);
                     for ($index = 0; $index < count($datas); $index++) {
                         $row = $datas[$index];
                         $msg = [];
@@ -207,7 +209,7 @@ class Import {
                                     }
                                     break;
                                 case 1:
-                                    $info = Db::table("un_enterprise")->where('idCard', $row[$i])->where('delete',0)->findOrEmpty();
+                                    $info = Db::table("un_enterprise")->where('idCard', $row[$i])->where('delete',0)->where('apply_year',$batch["batch"])->findOrEmpty();
                                     if (!$info) {
                                         array_push($msg, "机构代码不存在,请检查");
                                     } else {
@@ -308,6 +310,7 @@ class Import {
                             } else {
                                 $item["highProcess"] = 5; //最高进度
                                 $item['createTime'] = date("Y-m-d H:i:s", time());
+                                $item['apply_year'] = $batch["batch"];
                                 Db::table("new_talent_info")->insert($item);
                                 $sheet->setCellValue('AL' . ($index + 2), '导入成功');
 
@@ -342,10 +345,9 @@ class Import {
                     $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($path ."/public/storage/" . $res['task_file']);
                     $sheet = $spreadsheet->getSheet(0);
                     $datas = $sheet->toArray();
-
                     $datas = array_slice($datas, 1); //去标题
                     $country = Db::table("sys_dict")->where("pid", 35)->column("code", "name");
-
+                    $batch = BatchApi::getValidBatch(ProjectState::TALENT, 1);
                     for ($index = 0; $index < count($datas); $index++) {
                         $row = $datas[$index];
                         $msg = [];
@@ -364,7 +366,8 @@ class Import {
                                     }
                                     break;
                                 case 1:
-                                    $info = Db::table("un_enterprise")->where('idCard', $row[$i])->where('delete',0)->findOrEmpty();
+
+                                    $info = Db::table("un_enterprise")->where('idCard', $row[$i])->where('delete',0)->where('apply_year',$batch["batch"])->findOrEmpty();
                                     if (!$info) {
                                         array_push($msg, "机构代码不存在,请检查");
                                     } else {
@@ -471,6 +474,7 @@ class Import {
                                 Db::table("new_talent_info")->where('id', $talent_info['id'])->update($item);
                                 $sheet->setCellValue('AC' . ($index + 2), '更新成功');
                             } else {
+                                $item['apply_year'] = $batch["batch"];
                                 $item['createTime'] = date("Y-m-d H:i:s", time());
                                 Db::table("new_talent_info")->insert($item);
                                 $sheet->setCellValue('AC' . ($index + 2), '导入成功');