DeptVerifyChecker.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. use app\common\api\TalentLogApi;
  18. use app\common\api\VerifyApi;
  19. use app\enterprise\model\Talent as TalentModel;
  20. /**
  21. * 人才认定部门审核检查
  22. */
  23. class DeptVerifyChecker extends Command {
  24. protected function configure() {
  25. // 指令配置
  26. $this->setName('DeptVerifyChecker')
  27. ->setDescription('Dept Verify Checker');
  28. }
  29. protected function execute(Input $input, Output $output) {
  30. $where[] = ["e.type", "=", 1];
  31. $where[] = ["ti.checkState", "=", TalentState::FST_VERIFY_PASS];
  32. $where[] = ["ti.pass_dept_check", "=", 0];
  33. $jjrc_list = TalentModel::alias("ti")
  34. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  35. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  36. ->where($where)->field("ti.id,tc.companyIds,ti.re_check_companys")->select()->toArray();
  37. $jjrc_counts = [];
  38. foreach ($jjrc_list as $item) {
  39. $companyIds = array_filter(explode(",", $item["companyIds"]));
  40. $pass_companyIds = TalentLogApi::getPassDepts($item["id"]); //已经通过的单位
  41. $re_check_companys = $item["re_check_companys"] ? array_filter(explode(",", $item["re_check_companys"])) : [];
  42. $companyIds = VerifyApi::getNewReCheckCompanyIds($re_check_companys, $companyIds, $pass_companyIds);
  43. $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
  44. foreach ($unpass_companyIds as $companyId) {
  45. $jjrc_counts[$companyId] += 1;
  46. }
  47. }
  48. /* $where[] = ["type", "=", ProjectState::TALENT];
  49. $where[] = ["step", "=", 3];
  50. $where[] = ["active", "=", 0];
  51. $jjrc_list = TalentChecklog::where($where)->column("companyId");
  52. $jjrc_counts = [];
  53. for ($i = 0; $i < count($jjrc_list); $i++) {
  54. $jjrc_counts[$jjrc_list[$i]] += 1;
  55. } */
  56. $codes = ["talentInfo_depCheck"];
  57. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  58. $where = [];
  59. $where[] = ["menuid", "in", $menuIds];
  60. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  61. foreach ($jjrc_counts as $companyId => $count) {
  62. $where = [];
  63. $where[] = ["type", "=", 1];
  64. $where[] = ["status", "=", 1];
  65. $where[] = ["roleid", "<>", 1];
  66. $where[] = ["companyId", "=", $companyId];
  67. $regstr = ",(" . implode("|", $roleIds) . "),";
  68. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  69. $users = User::where($where)->whereRaw($whereRaw)->select()->toArray();
  70. foreach ($users as $user) {
  71. if ($user["phone"]) {
  72. queue("app\job\Messenger", ["type" => 3, "userId" => $user["id"], "name" => $user["name"], "phone" => $user["phone"], "count" => $count]);
  73. }
  74. }
  75. }
  76. }
  77. }