DeptVerifyChecker.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\command;
  4. use think\console\Command;
  5. use think\console\Input;
  6. use think\console\input\Argument;
  7. use think\console\input\Option;
  8. use think\console\Output;
  9. use think\facade\Db;
  10. use think\facade\Log;
  11. use app\common\api\TalentState;
  12. use app\enterprise\model\Talent;
  13. use app\common\api\MenuApi;
  14. use app\admin\model\SysRelation;
  15. use app\admin\model\User;
  16. /**
  17. * 人才认定部门审核检查
  18. */
  19. class DeptVerifyChecker extends Command {
  20. protected function configure() {
  21. // 指令配置
  22. $this->setName('DeptVerifyChecker')
  23. ->setDescription('Dept Verify Checker');
  24. }
  25. protected function execute(Input $input, Output $output) {
  26. $where[] = ["e.type", "=", 1];
  27. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  28. $where[] = ["ti.pass_dept_check", "=", 0];
  29. $jjrc_list = Talent::alias("ti")
  30. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  31. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  32. ->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")
  33. ->where($where)->column("companyIds");
  34. $jjrc_counts = [];
  35. for ($i = 0; $i < count($jjrc_list); $i++) {
  36. $companys = array_filter(explode(",", $jjrc_list[$i]));
  37. for ($n = 0; $n < count($companys); $n++) {
  38. $jjrc_counts[$companys[$n]] += 1;
  39. }
  40. }
  41. $codes = ["talentInfo_dep"];
  42. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  43. $where = [];
  44. $where[] = ["menuid", "in", $menuIds];
  45. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  46. foreach ($jjrc_counts as $companyId => $count) {
  47. $where = [];
  48. $where[] = ["type", "=", 1];
  49. $where[] = ["status", "=", 1];
  50. $where[] = ["roleid", "<>", 1];
  51. $where[] = ["companyId", "=", $companyId];
  52. $regstr = ",(" . implode("|", $roleIds) . "),";
  53. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  54. $users = User::where($where)->whereRaw($whereRaw)->select()->toArray();
  55. foreach ($users as $user) {
  56. if ($user["phone"]) {
  57. queue("app\job\Messenger", ["type" => 3, "userId" => $user["id"], "name" => $user["name"], "phone" => $user["phone"], "count" => $count]);
  58. }
  59. }
  60. }
  61. }
  62. }