Browse Source

优化部门审核提醒sql

sugangqiang 2 years ago
parent
commit
0574178a34
1 changed files with 18 additions and 13 deletions
  1. 18 13
      app/command/DeptVerifyChecker.php

+ 18 - 13
app/command/DeptVerifyChecker.php

@@ -12,10 +12,11 @@ use think\console\Output;
 use think\facade\Db;
 use think\facade\Log;
 use app\common\api\TalentState;
-use app\enterprise\model\Talent;
 use app\common\api\MenuApi;
 use app\admin\model\SysRelation;
 use app\admin\model\User;
+use app\common\model\TalentChecklog;
+use app\common\state\ProjectState;
 
 /**
  * 人才认定部门审核检查
@@ -29,20 +30,24 @@ class DeptVerifyChecker extends Command {
     }
 
     protected function execute(Input $input, Output $output) {
-        $where[] = ["e.type", "=", 1];
-        $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
-        $where[] = ["ti.pass_dept_check", "=", 0];
-        $jjrc_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 description,mainId,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")
-                        ->where($where)->column("companyIds");
+        /* $where[] = ["e.type", "=", 1];
+          $where[] = ["tl.state", "=", TalentState::FST_VERIFY_PASS];
+          $where[] = ["ti.pass_dept_check", "=", 0];
+          $jjrc_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 description,mainId,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")
+          ->where($where)->column("companyIds"); */
+
+        $where[] = ["type", "=", ProjectState::TALENT];
+        $where[] = ["new_state", "=", TalentState::FST_VERIFY_PASS];
+        $where[] = ["step", "=", 3];
+        $where[] = ["active", "=", 0];
+        $jjrc_list = TalentChecklog::where($where)->column("companyId");
+
         $jjrc_counts = [];
         for ($i = 0; $i < count($jjrc_list); $i++) {
-            $companys = array_filter(explode(",", $jjrc_list[$i]));
-            for ($n = 0; $n < count($companys); $n++) {
-                $jjrc_counts[$companys[$n]] += 1;
-            }
+            $jjrc_counts[$jjrc_list[$i]] += 1;
         }
         $codes = ["talentInfo_dep"];
         $menuIds = MenuApi::getMenuIdsByCodes($codes);