sugangqiang 2 жил өмнө
parent
commit
cd2b94514f

+ 21 - 0
app/common.php

@@ -599,3 +599,24 @@ function proSearch($str, $arr) {
         }
     });
 }
+
+//冒泡排序
+function bubbleSort($array, $sortkey, $order = "asc") {
+    sort($array); //重新分配索引
+    $length = count($array);
+    for ($i = 0; $i < $length - 1; $i++) {
+        for ($j = 0; $j < $length - $i - 1; $j++) {
+            $v1 = intval($array[$j][$sortkey]) ?: 0;
+            $v2 = intval($array[$j + 1][$sortkey]) ?: 0;
+            if ($v1 > $v2) {
+                $temp = $array[$j];
+                $array[$j] = $array[$j + 1];
+                $array[$j + 1] = $temp;
+            }
+        }
+    }
+    if ($order != "asc") {
+        $array = array_reverse($array);
+    }
+    return $array;
+}

+ 12 - 1
app/common/api/VerifyApi.php

@@ -833,12 +833,14 @@ class VerifyApi {
         $fields[] = "tc.companyIds";
         if ($process == 4) {
             $fields[] = "tl2.resubmit";
+            $fields[] = "tl3.deptVerifyJsonData";
             if ($company_info["code"] == "super" || $company_info["code"] == "rsj") {
                 $list = 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,description,last_state,new_state,state,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")
                                 ->leftJoin(sprintf("(select id as resubmit,mainId from new_talent_checklog where state in(%d,%d) and step is null and `type`=1 and `active`=1 group by mainId) as tl2", TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT), "`tl2`.mainId=`ti`.id")
+                                ->leftJoin("(select mainId,JSON_ARRAYAGG(JSON_OBJECT('companyId',companyId,'active',`active`,'description',`description`,'new_state',`new_state`,'createTime',unix_timestamp(`createTime`))) as deptVerifyJsonData from new_talent_checklog where `step`=3 and `type`=1 group by mainId) as tl3", "tl3.mainId=ti.`id`")
                                 ->where($where)
                                 ->where($whereRaw)
                                 ->field($fields)
@@ -991,6 +993,8 @@ class VerifyApi {
             }
             if ($process == 4 && in_array($company_info["code"], ["super", "rsj"])) {
                 $companys = array_filter(explode(",", $item["companyIds"]));
+                $deptChecklogs = json_decode($item["deptVerifyJsonData"], true);
+                $deptChecklogs = bubbleSort($deptChecklogs, "createTime", "desc");
                 $verifyDepts = [];
                 $item["deptReject"] = 0;
                 $item["deptPass"] = 0;
@@ -998,7 +1002,14 @@ class VerifyApi {
                 $deptDescriptions = [];
                 foreach ($companys as $k => $companyId) {
                     $company = getCacheById("Company", $companyId);
-                    $log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
+                    //$log = TalentLogApi::getCompanyNewestCheckedLog($item["id"], $companyId);
+                    $i = 0;
+                    while ($log = $deptChecklogs[$i]) {
+                        if ($log["companyId"] == $companyId) {
+                            break;
+                        }
+                        $i++;
+                    }
                     $item["first_dept_check_time"] = $log["createTime"];
                     $verifyDepts[$k] = $company["name"];
                     if ($log["active"] == 1) {