فهرست منبع

部门并审逻辑修改

sugangqiang 2 سال پیش
والد
کامیت
e49018dc2e

+ 4 - 2
app/admin/controller/Index.php

@@ -51,13 +51,15 @@ class Index extends AdminController {
                                 ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
                                 ->where($where)->count();
             } else {
-                $where[] = ["tl.active", "=", 0];
-                $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
+                //$where[] = ["tl.active", "=", 0];
+                //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];                
+                $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
                 $count = Talent::alias("ti")
                                 ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
                                 ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
                                 ->leftJoin("(select mainId,active,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,companyId,mainId,`type`)) in (select md5(concat(max(createTime),companyId,mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step`=3 and companyId='{$companyId}' and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
                                 ->where($where)
+                                ->where($whereRaw)
                                 ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
             }
             if ($count > 0) {

+ 2 - 1
app/admin/controller/Talent.php

@@ -1140,7 +1140,8 @@ class Talent extends AdminController {
             return json(["msg" => "您的部门已经审核过了"]);
 
         if ($talent_info["re_check_companys"]) {
-            $companys = array_filter(explode(",", $talent_info["re_check_companys"]));
+            $re_check_companys = array_filter(explode(",", $talent_info["re_check_companys"]));
+            $companys = VerifyApi::getNewReCheckCompanyIds($re_check_companys, $companys, $pass_companyIds);
             $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"], $talent_info["first_dept_check_time"]); //重审单位中已经通过的单位
         }
 

+ 6 - 3
app/common/api/TalentLogApi.php

@@ -83,7 +83,7 @@ class TalentLogApi {
         $where[] = ["step", "=", 3];
         $where[] = ["companyId", "=", $companyId];
         //$where[] = ["active", "=", 1];
-        $one = TalentLog::where($where)->order("createTime desc")->findOrEmpty();
+        $one = TalentLog::where($where)->order("createTime desc")->find();
         return $one;
     }
 
@@ -92,7 +92,7 @@ class TalentLogApi {
         $where[] = ["mainId", "=", $mainId];
         $where[] = ["companyId", "=", $companyId];
         $where[] = ["createTime", ">=", $fst_dept_check_time];
-        $one = TalentLog::where($where)->findOrEmpty();
+        $one = TalentLog::where($where)->find();
         return $one;
     }
 
@@ -129,7 +129,7 @@ class TalentLogApi {
         }
     }
 
-    public static function write($type, $mainId, $state = [], $description = "", $active = 0, $fileType = null, $fileId = null) {
+    public static function write($type, $mainId, $state = [], $description = "", $active = 0, $fileType = null, $fileId = null, $companyId = null) {
         $user = session("user");
         $last_log = self::getLastLog($mainId, $type, 0, ["active", "=", 1]);
         $log["last_state"] = $last_log["state"] ?: 0;
@@ -150,6 +150,9 @@ class TalentLogApi {
         if ($user) {
             $log["companyId"] = $user["companyId"];
         }
+        if ($companyId) {
+            $log["companyId"] = $companyId;
+        }
         $log["active"] = $active;
         $log["description"] = $description;
         $log["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";

+ 50 - 27
app/common/api/VerifyApi.php

@@ -150,17 +150,27 @@ class VerifyApi {
     }
 
     /**
-     * 
+     * 获得新的需要重审的部门集合(如果$oriReCheckCompanyIds为空,返回认定条件审核部门集合$talentConditionCompanyIds)
      * @param type $oriReCheckCompanyIds 原来的需要再审核的部门id集合
-     * @param type $TalentConditionCompanyIds 认定条件中的审核部门id集合
+     * @param type $talentConditionCompanyIds 认定条件中的审核部门id集合
      * @param type $passedCompanyIds 已经通过审核的部门id集合
      * @return type
      */
-    public static function getReCheckCompanyIds($oriReCheckCompanyIds, $TalentConditionCompanyIds, $passedCompanyIds) {
-        if (!$oriReCheckCompanyIds || !$TalentConditionCompanyIds)
-            return null;
-        $removeReCheckCompanyIds = array_diff($oriReCheckCompanyIds, $TalentConditionCompanyIds);
-        $remainReCheckCompanyIds = array_diff($oriReCheckCompanyIds, $removeReCheckCompanyIds);
+    public static function getNewReCheckCompanyIds($oriReCheckCompanyIds, $talentConditionCompanyIds, $passedCompanyIds) {
+        if ($oriReCheckCompanyIds) {
+            //$removeReCheckCompanyIds:获得再审核部门中已经被移除的集合(修改认定条件审核部门后,已经不再在列表中的部门Id集合)
+            $removeReCheckCompanyIds = array_diff($oriReCheckCompanyIds, $talentConditionCompanyIds);
+            //$reCheckCompanyIds:获得再审核部门中仍需审核的部门集合
+            $reCheckCompanyIds = array_diff($oriReCheckCompanyIds, $removeReCheckCompanyIds);
+            //$notInReCheckCompanyIds:不在重审列表里面的审核部门集合(这里面存在新增的审核部门)
+            $notInReCheckCompanyIds = array_diff($talentConditionCompanyIds, $reCheckCompanyIds);
+            //$needReCheckCompanyIds:找出不在重审列表里面并且没有在已审核通过的列表中的部门Id集合
+            $needReCheckCompanyIds = array_diff($notInReCheckCompanyIds, $passedCompanyIds);
+            //合并新的需要重审的部门集合
+            $newReCheckCompanyIds = array_unique(array_merge($reCheckCompanyIds, $needReCheckCompanyIds));
+            return $newReCheckCompanyIds;
+        }
+        return $talentConditionCompanyIds;
     }
 
     public static function getFullDeptList($params, $where = []) {
@@ -222,6 +232,8 @@ class VerifyApi {
             foreach ($companys as $k => $companyId) {
                 $company = getCacheById("Company", $companyId);
                 $log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
+                if (!$log && in_array($item["realState"], [TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT]))
+                    continue;
                 $verifyDepts[$k]["id"] = $companyId;
                 $verifyDepts[$k]["shortName"] = $company["shortName"];
                 $verifyDepts[$k]["name"] = $company["name"];
@@ -242,16 +254,16 @@ class VerifyApi {
         $whereRaw = "";
         switch ($params["checkState"]) {
             case 1://待部门并审(首次提交)
-                $where[] = ["tl.active", "=", 0];
-                $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
-                $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
-                //$whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
+                //$where[] = ["tl.active", "=", 0];
+                //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
+                //$where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
+                $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
                 break;
             case 2://待部门并审(重新提交)
-                $where[] = ["tl.active", "=", 0];
-                $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
-                $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
-                //$whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is not null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
+                //$where[] = ["tl.active", "=", 0];
+                //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
+                //$where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
+                $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is not null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
                 break;
             case 3://部门并审通过
                 $where[] = ["tl.active", "=", 1];
@@ -262,7 +274,7 @@ class VerifyApi {
                 $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
                 break;
             default:
-                $whereRaw = sprintf("(tl.active=0 and tl.state=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
+                $whereRaw = sprintf("(((tl.active=0 and tl.state=%d) or (tl.active is null)) and ti.pass_dept_check=0 and ti.checkState=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
                 break;
         }
 
@@ -291,7 +303,7 @@ class VerifyApi {
             $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
             $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
             $lastCheckLog = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
-            $item["deptCheckState"] = $lastCheckLog["new_state"];
+            $item["deptCheckState"] = $lastCheckLog["new_state"] ?: TalentState::FST_VERIFY_PASS;
             $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
         }unset($item);
         return ["total" => $count, "rows" => $list];
@@ -705,6 +717,9 @@ class VerifyApi {
             if ($params["isMatchZhiren"]) {
                 $where[] = ["ti.isMatchZhiren", "=", $params["isMatchZhiren"]];
             }
+            if ($params["company_id"]) {
+                $where[] = ["tc.companyIds", "like", "%" . $params["company_id"] . "%"];
+            }
             switch ($process) {
                 case 1:
                     $where[] = ["ti.checkState", "in", [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];
@@ -784,14 +799,16 @@ class VerifyApi {
                     } else {
                         switch ($params["checkState"]) {
                             case 1://待部门并审(首次提交)
-                                $where[] = ["tl.active", "=", 0];
-                                $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
-                                $where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
+                                //$where[] = ["tl.active", "=", 0];
+                                //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
+                                //$where[] = ["tl2.resubmit", "EXP", Db::raw("is null")];
+                                $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
                                 break;
                             case 2://待部门并审(重新提交)
-                                $where[] = ["tl.active", "=", 0];
-                                $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
-                                $where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
+                                //$where[] = ["tl.active", "=", 0];
+                                //$where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
+                                //$where[] = ["tl2.resubmit", "EXP", Db::raw("is not null")];
+                                $whereRaw = sprintf("((tl.active=0 and tl.state=%d) or (tl.active is null)) and tl2.resubmit is not null and ti.pass_dept_check=0 and ti.checkState=%d", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS);
                                 break;
                             case 3://部门并审通过
                                 $where[] = ["tl.active", "=", 1];
@@ -802,7 +819,7 @@ class VerifyApi {
                                 $where[] = ["tl.new_state", "=", TalentState::SCND_SUBMIT];
                                 break;
                             default:
-                                $whereRaw = sprintf("(tl.active=0 and tl.state=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
+                                $whereRaw = sprintf("(((tl.active=0 and tl.state=%d) or (tl.active is null)) and ti.pass_dept_check=0 and ti.checkState=%d) or (tl.active=1 and (tl.new_state in (%d,%d)))", TalentState::FST_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_PASS);
                                 break;
                         }
                     }
@@ -865,7 +882,7 @@ class VerifyApi {
                                 ->select()->toArray();
             } else {
                 $fields[] = "tl.active";
-                $fields[] = "tl.new_state as deptCheckState";
+                $fields[] = "if(tl.new_state,tl.new_state,10) as deptCheckState";
                 $fields[] = "tl.createTime as first_dept_check_time";
                 $list = Talent::alias("ti")
                                 ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
@@ -944,9 +961,9 @@ class VerifyApi {
                 } else {
                     $item["checkState"] = "待初审(首次提交)";
                 }
-            } else if ($item["state"] == TalentState::FST_VERIFY_PASS) {
+            } else if ($item["state"] == TalentState::FST_VERIFY_PASS || (!$item["state"] && $item["deptCheckState"])) {
                 if ($item["deptCheckState"]) {
-                    if ($item["acitve"] == 0 && $item["state"] == TalentState::FST_VERIFY_PASS) {
+                    if (($item["acitve"] == 0 && $item["state"] == TalentState::FST_VERIFY_PASS) || !$item["active"]) {
                         if ($item["resubmit"]) {
                             $item["checkState"] = "待部门并审(重新提交)";
                         } else {
@@ -1027,6 +1044,8 @@ class VerifyApi {
                         while ($log = $deptChecklogs[$i]) {
                             if ($log["companyId"] == $companyId) {
                                 break;
+                            } else {
+                                $log = null;
                             }
                             $i++;
                         }
@@ -1043,6 +1062,10 @@ class VerifyApi {
                             }
                             $deptDescriptions[] = sprintf("%s:%s", $company["name"], $log["description"]);
                         } else {
+                            if (!$log && in_array($item["state"], [TalentState::DEPT_VERIFY_PASS, TalentState::DEPT_VERIFY_REJECT])) {
+                                unset($verifyDepts[$k]);
+                                continue;
+                            }
                             $verifyDepts[$k] .= "(待审核)";
                             $item["deptWait"]++;
                         }

+ 22 - 14
app/job/Talent.php

@@ -72,13 +72,16 @@ class Talent {
 
                     $companyIds = array_filter(explode(",", $talent_info["companyIds"]));
                     if ($companyIds) {
-                        if ($talent_info["re_check_companys"]) {
-                            $unpass_companyIds = array_filter(explode(",", $talent_info["re_check_companys"]));
-                        } else {
-                            //这边去除已经审核通过的单位,主要通过日志是否存在记录。
-                            $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
-                            $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
-                        }
+                        /* if ($talent_info["re_check_companys"]) {
+                          $unpass_companyIds = array_filter(explode(",", $talent_info["re_check_companys"]));
+                          } else {
+                          //这边去除已经审核通过的单位,主要通过日志是否存在记录。
+                          $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
+                          $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
+                          } */
+                        $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
+                        $companyIds = \app\common\api\VerifyApi::getNewReCheckCompanyIds($talent_info["re_check_companys"], $companyIds, $pass_companyIds);
+                        $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
                         if (!$unpass_companyIds) {
                             //没有未审部门
                             return true;
@@ -91,15 +94,20 @@ class Talent {
                             $fileTypes = $companyAndTypes[$companyId];
                             $modify_files = array_unique((array_merge((array) $modify_files, (array) $fileTypes)));
                             $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $companyId, $fst_dept_check_time);
-                            TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], "审核超时,系统自动驳回", 1);
+                            if ($dept_log) {
+                                TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], "审核超时,系统自动驳回", 1);
+                            } else {
+                                TalentLogApi::write(ProjectState::TALENT, $talent_info["id"], [$log_checkState, $checkState, 3], "审核超时,系统自动驳回", 1, null, null, $companyId); //补一条记录
+                                sleep(1);
+                            }
                         }
                         $log_checkState = TalentState::DEPT_VERIFY_REJECT;
-                        $data["id"] = $talent_info["id"];
-                        $data["modify_files"] = implode(",", $modify_files);
-                        $data["checkState"] = $checkState;
-                        $data["first_dept_check_time"] = null;
-                        $data["re_check_companys"] = null;
-                        TalentModel::update($data);
+                        $save["id"] = $talent_info["id"];
+                        $save["modify_files"] = implode(",", $modify_files);
+                        $save["checkState"] = $checkState;
+                        $save["first_dept_check_time"] = null;
+                        $save["re_check_companys"] = null;
+                        TalentModel::update($save);
                         TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "审核超时,系统自动驳回,部门审核结束", 1);
                     }
                     return true;

+ 1 - 1
public/static/modular/talentIdentify/talentInfo/talentInfo_base.js

@@ -64,7 +64,7 @@ TalentInfo.initColumn = function () {
         {title: '审核状态', field: 'checkState', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "100px",
             formatter: function (value, row, index) {
                 if (typeof row.deptCheckState != "undefined") {
-                    if (row.deptActive == 0 && row.realState == 10) {
+                    if ((row.deptActive == 0 && row.realState == 10) || !row.deptActive) {
                         if (row.resubmit) {
                             return "<span class='label label-success'>待部门并审(重新提交)</span>";
                         } else {