DeptVerifyChecker.php 2.8 KB

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