Browse Source

修改部门审核短信提醒逻辑

sugangqiang 1 year ago
parent
commit
a126d152b1
1 changed files with 29 additions and 16 deletions
  1. 29 16
      app/command/DeptVerifyChecker.php

+ 29 - 16
app/command/DeptVerifyChecker.php

@@ -17,6 +17,9 @@ use app\admin\model\SysRelation;
 use app\admin\model\User;
 use app\common\model\TalentChecklog;
 use app\common\state\ProjectState;
+use app\common\api\TalentLogApi;
+use app\common\api\VerifyApi;
+use app\enterprise\model\Talent as TalentModel;
 
 /**
  * 人才认定部门审核检查
@@ -30,24 +33,34 @@ 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[] = ["type", "=", ProjectState::TALENT];
-        $where[] = ["step", "=", 3];
-        $where[] = ["active", "=", 0];
-        $jjrc_list = TalentChecklog::where($where)->column("companyId");
-
+        $where[] = ["e.type", "=", 1];
+        $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
+        $where[] = ["ti.pass_dept_check", "=", 0];
+        $jjrc_list = TalentModel::alias("ti")
+                        ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
+                        ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
+                        ->where($where)->field("ti.id,tc.companyIds,ti.re_check_companys")->select()->toArray();
         $jjrc_counts = [];
-        for ($i = 0; $i < count($jjrc_list); $i++) {
-            $jjrc_counts[$jjrc_list[$i]] += 1;
+        foreach ($jjrc_list as $item) {
+            $companyIds = array_filter(explode(",", $item["companyIds"]));
+            $pass_companyIds = TalentLogApi::getPassDepts($item["id"]); //已经通过的单位
+            $re_check_companys = $item["re_check_companys"] ? array_filter(explode(",", $item["re_check_companys"])) : [];
+            $companyIds = VerifyApi::getNewReCheckCompanyIds($re_check_companys, $companyIds, $pass_companyIds);
+            $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
+            foreach ($unpass_companyIds as $companyId) {
+                $jjrc_counts[$companyId] += 1;
+            }
         }
+
+        /* $where[] = ["type", "=", ProjectState::TALENT];
+          $where[] = ["step", "=", 3];
+          $where[] = ["active", "=", 0];
+          $jjrc_list = TalentChecklog::where($where)->column("companyId");
+
+          $jjrc_counts = [];
+          for ($i = 0; $i < count($jjrc_list); $i++) {
+          $jjrc_counts[$jjrc_list[$i]] += 1;
+          } */
         $codes = ["talentInfo_depCheck"];
         $menuIds = MenuApi::getMenuIdsByCodes($codes);