Bläddra i källkod

取消自动审核失败

sugangqiang 2 år sedan
förälder
incheckning
80873884e2
3 ändrade filer med 69 tillägg och 1 borttagningar
  1. 26 0
      app/admin/controller/System.php
  2. 15 0
      app/common/api/TalentLogApi.php
  3. 28 1
      app/job/Talent.php

+ 26 - 0
app/admin/controller/System.php

@@ -40,4 +40,30 @@ class System extends AdminController {
         }
     }
 
+    /**
+     * 恢复自动审核失败
+     */
+    public function recovery() {
+        $batch = 2022; //得更改批次
+        $type = 1; //人才类型 1:晋江人才 2:电路人才
+
+        $where = [];
+        $where[] = ["ti.apply_year", "=", $batch];
+        $where[] = ["ti.checkState", "=", \app\common\api\TalentState::FST_VERIFY_FAIL];
+        $where[] = ["e.type", "=", $type];
+        $where[] = ["tl.createUser", "=", "系统"];
+        $where[] = ["tl.state", "=", \app\common\api\TalentState::FST_VERIFY_FAIL];
+        $list = \app\enterprise\model\Talent::alias("ti")
+                        ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
+                        ->leftJoin("(select mainId,last_state,new_state,state,createUser,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
+                        ->where($where)
+                        ->field("ti.*,e.type as enterpriseType")
+                        ->select()->toArray();
+        if ($list) {
+            foreach ($list as $ti) {
+                queue("app\job\Talent", ["type" => 3, "talentInfo" => $ti]);
+            }
+        }
+    }
+
 }

+ 15 - 0
app/common/api/TalentLogApi.php

@@ -77,6 +77,21 @@ class TalentLogApi {
         return $last_log;
     }
 
+    public static function getLastLogEx($mainId, $type, $companyId = 0, $extra_where = []) {
+        $where = [];
+        $where[] = ["mainId", "=", $mainId];
+        $where[] = ["type", "=", $type];
+        $where[] = ["typeFileId", "null"];
+        if ($companyId) {
+            $where[] = ["companyId", "=", $companyId];
+        }
+        if ($extra_where) {
+            $where = array_merge($where, (array) $extra_where);
+        }
+        $last_log = TalentLog::where($where)->order("createTime desc")->findOrEmpty()->toArray();
+        return $last_log;
+    }
+
     public static function getCompanyNewestCheckedLog($mainId, $companyId) {
         $where = [];
         $where[] = ["mainId", "=", $mainId];

+ 28 - 1
app/job/Talent.php

@@ -115,7 +115,7 @@ class Talent {
                 }
                 break;
             case 2:
-                //超过批次提交时间驳回
+                //超过批次提交时间审核失败
                 $talentInfo = $data["talentInfo"];
                 $projectType = ProjectState::TALENT; //项目类型
                 $mainId = $talentInfo["id"]; //申报id
@@ -137,6 +137,33 @@ class Talent {
                     return true;
                 }
                 break;
+            case 3:
+                //撤销超时审核失败
+                $talentInfo = $data["talentInfo"];
+                $projectType = ProjectState::TALENT; //项目类型
+                $mainId = $talentInfo["id"]; //申报id
+                $checkState = TalentState::SCND_SAVE; //系统审核失败状态,初审不通过
+                $last_log = TalentLogApi::getLastLog($mainId, $projectType, 0, ["active", "=", 1]);
+                if ($talentInfo["checkState"] == TalentState::FST_VERIFY_FAIL && $last_log["state"] == TalentState::FST_VERIFY_FAIL && $last_log["createUser"] == "系统") {
+                    $where = [];
+                    $where[] = ["active", "=", 1];
+                    $where[] = ["type", "=", $projectType];
+                    $where[] = ["source", "=", $talentInfo["enterpriseType"]];
+                    $where[] = ["batch", "=", $talentInfo["apply_year"]];
+                    $whereRaw = sprintf("submitEndTime is null or submitEndTime<>'' or submitEndTime > '%s'", date("Y-m-d H:i:s"));
+                    $batch = \app\common\model\Batch::where($where)->whereRaw($whereRaw)->find();
+                    $extra_where[] = ["active", "=", 1];
+                    $extra_where[] = ["createUser", "<>", "系统"];
+                    $last_log = TalentLogApi::getLastLogEx($mainId, $projectType, 0, $extra_where);
+                    if ($batch && $last_log) {
+                        $save["id"] = $mainId;
+                        $save["checkState"] = $checkState;
+                        TalentModel::update($save);
+                        TalentLogApi::write($projectType, $mainId, [$last_log["state"], $last_log["new_state"]], "该批次已经延长申报提交截止时间同时选择恢复被自动审核失败的申报,该申报已恢复至保存未提交状态", 1);
+                    }
+                    return true;
+                }
+                break;
         }
         return false;
     }