System.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use think\facade\Db;
  5. /**
  6. * Description of System
  7. *
  8. * @author sgq
  9. */
  10. class System extends AdminController {
  11. /**
  12. * 生成缓存
  13. * @return type
  14. */
  15. public function cache() {
  16. $step = $this->request->param("step");
  17. if ($step) {
  18. $cache_kvs = [
  19. ["func" => "\app\common\model\Company::cache", "stepName" => "部门"],
  20. ["func" => "\app\common\model\IntegralProject::cache", "stepName" => "积分项目"],
  21. ["func" => "\app\common\model\IntegralItem::cache", "stepName" => "积分标准"]
  22. ];
  23. $cache = $cache_kvs[$step - 1];
  24. if ($cache) {
  25. $time1 = microtime(true);
  26. $cache["func"]();
  27. $time2 = microtime(true);
  28. $runtime = round($time2 - $time1, 2);
  29. $step++;
  30. echo '<script>window.parent.setText("<span class=\"highlight\">' . $cache["stepName"] . '</span>缓存成功![用时 ' . $runtime . 's]");</script>';
  31. echo '<script>window.location.href="/admin/system/cache/step/' . $step . '";</script>';
  32. } else {
  33. echo '<script>window.parent.setText("缓存创建结束!");</script>';
  34. }
  35. } else {
  36. return view();
  37. }
  38. }
  39. public function add_talent_type_change_in_queue($id) {
  40. queue("app\job\Talent", ["type" => 5, "id" => $id]);
  41. }
  42. public function work_unit_change_recovery() {
  43. $id = $this->request["id"];
  44. if ($id) {
  45. queue("app\job\Recovery", ["id" => $id, "type" => 1]);
  46. echo "【撤销工作变更审核通过】任务已加入处理队列";
  47. exit();
  48. }
  49. echo "请传/admin/system/work_unit_change_recovery/id/new_talent_info.id";
  50. }
  51. /**
  52. * 恢复自动审核失败
  53. */
  54. public function recovery() {
  55. $batch = 2022; //得更改批次
  56. $type = 1; //人才类型 1:晋江人才 2:电路人才
  57. $where = [];
  58. $where[] = ["ti.apply_year", "=", $batch];
  59. $where[] = ["ti.checkState", "=", \app\common\api\TalentState::FST_VERIFY_FAIL];
  60. $where[] = ["e.type", "=", $type];
  61. $where[] = ["tl.createUser", "=", "系统"];
  62. $where[] = ["tl.state", "=", \app\common\api\TalentState::FST_VERIFY_FAIL];
  63. $where[] = ["ti.delete", "=", 0];
  64. $list = \app\enterprise\model\Talent::alias("ti")
  65. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  66. ->leftJoin("(select mainId,last_state,new_state,state,createUser,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")
  67. ->where($where)
  68. ->field("ti.*,e.type as enterpriseType")
  69. ->select()->toArray();
  70. if ($list) {
  71. foreach ($list as $ti) {
  72. queue("app\job\Talent", ["type" => 3, "talentInfo" => $ti]);
  73. }
  74. }
  75. }
  76. /**
  77. * 导入旧的电路人才到新库
  78. *
  79. -1 复核不通过 173
  80. 1 待提交 4
  81. 7 待初审 22
  82. 10 初审驳回 44
  83. 20 复审驳回 1
  84. 25 初审通过 71
  85. 35 复核通过,待核查征信 1281
  86. * isPublic 5:待发证 6:已发证
  87. * active 1:在职 2:离职
  88. * isEffect 1:有效 4:失效 其它:已过期
  89. * 需要增加字段
  90. * cur_quit_time离职时间
  91. * active在职状态
  92. * identifyMonth认证月份
  93. * identifyExpireTime
  94. * oldId 旧id
  95. */
  96. public function import_old_jcdl() {
  97. $where = [];
  98. $where[] = ["type", "=", 2];
  99. $where[] = ["name", "=", "杨忠宪"];
  100. $list = Db::table("un_talent_info")->where($where)->select();
  101. $count = session("oldJcjlTalentInfoToNewTable");
  102. $count += count($list);
  103. session("oldJcjlTalentInfoToNewTable", $count);
  104. foreach ($list as $item) {
  105. queue("app\job\Worker", ["type" => 99, "talent_info" => $item]);
  106. }
  107. echo "加入队列成功";
  108. }
  109. /**
  110. * 生成人才积分基础分日志
  111. */
  112. public function generate_integral_base_log() {
  113. $where = [];
  114. $where[] = ["e.type", "=", 2];
  115. $where[] = ["ti.checkState", "=", \app\common\api\TalentState::CERTIFICATED];
  116. $list = Db::table("new_talent_info")->alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->field("ti.*")->where($where)->order("ti.talent_arrange asc")->select();
  117. $already_in = [];
  118. foreach ($list as $item) {
  119. $unique_md5 = md5($item["card_type"] . "_" . $item["card_number"]);
  120. if (!in_array($unique_md5, $already_in)) {
  121. queue("app\job\Talent", ["type" => 4, "id" => $item["id"]]);
  122. $already_in[] = $unique_md5;
  123. }
  124. }
  125. echo "加入队列成功";
  126. }
  127. /**
  128. * 导入电路人才条款
  129. */
  130. public function import_old_ic_conditions() {
  131. $where = [];
  132. $where[] = ["type", "=", 2];
  133. $oldConditions = Db::table("un_identify_condition")->where($where)->select()->toArray();
  134. foreach ($oldConditions as $oldCondition) {
  135. queue("app\job\Worker", ["type" => 98, "id" => $oldCondition["id"]]);
  136. }
  137. }
  138. /**
  139. * 设置电路条款与旧版一致启用状态
  140. */
  141. public function set_ic_condition_active() {
  142. $where = [];
  143. $where[] = ["type", "=", 2];
  144. $upd["active"] = 2;
  145. Db::table("new_talent_condition")->where($where)->update($upd);
  146. $where = [];
  147. $where[] = ["type", "=", 2];
  148. $where[] = ["active", "=", 1];
  149. $oldActiveConditions = Db::table("un_identify_condition")->where($where)->select()->toArray();
  150. $oldActiveConditioinNames = array_column($oldActiveConditions, "name");
  151. $where = [];
  152. $where[] = ["type", "=", 2];
  153. $where[] = ["name", "in", $oldActiveConditioinNames];
  154. $upd["active"] = 1;
  155. Db::table("new_talent_condition")->where($where)->update($upd);
  156. }
  157. }