System.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 work_unit_change_recovery() {
  40. $id = $this->request["id"];
  41. if ($id) {
  42. queue("app\job\Recovery", ["id" => $id, "type" => 1]);
  43. echo "【撤销工作变更审核通过】任务已加入处理队列";
  44. exit();
  45. }
  46. echo "请传/admin/system/work_unit_change_recovery/id/new_talent_info.id";
  47. }
  48. /**
  49. * 恢复自动审核失败
  50. */
  51. public function recovery() {
  52. $batch = 2022; //得更改批次
  53. $type = 1; //人才类型 1:晋江人才 2:电路人才
  54. $where = [];
  55. $where[] = ["ti.apply_year", "=", $batch];
  56. $where[] = ["ti.checkState", "=", \app\common\api\TalentState::FST_VERIFY_FAIL];
  57. $where[] = ["e.type", "=", $type];
  58. $where[] = ["tl.createUser", "=", "系统"];
  59. $where[] = ["tl.state", "=", \app\common\api\TalentState::FST_VERIFY_FAIL];
  60. $where[] = ["ti.delete", "=", 0];
  61. $list = \app\enterprise\model\Talent::alias("ti")
  62. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  63. ->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")
  64. ->where($where)
  65. ->field("ti.*,e.type as enterpriseType")
  66. ->select()->toArray();
  67. if ($list) {
  68. foreach ($list as $ti) {
  69. queue("app\job\Talent", ["type" => 3, "talentInfo" => $ti]);
  70. }
  71. }
  72. }
  73. /**
  74. * 导入旧的电路人才到新库
  75. *
  76. -1 复核不通过 173
  77. 1 待提交 4
  78. 7 待初审 22
  79. 10 初审驳回 44
  80. 20 复审驳回 1
  81. 25 初审通过 71
  82. 35 复核通过,待核查征信 1281
  83. * isPublic 5:待发证 6:已发证
  84. * active 1:在职 2:离职
  85. * isEffect 1:有效 4:失效 其它:已过期
  86. * 需要增加字段
  87. * cur_quit_time离职时间
  88. * active在职状态
  89. * identifyMonth认证月份
  90. * identifyExpireTime
  91. * oldId 旧id
  92. */
  93. public function import_old_jcdl() {
  94. $where = [];
  95. $where[] = ["type", "=", 2];
  96. $where[] = ["name", "=", "杨忠宪"];
  97. $list = Db::table("un_talent_info")->where($where)->select();
  98. $count = session("oldJcjlTalentInfoToNewTable");
  99. $count += count($list);
  100. session("oldJcjlTalentInfoToNewTable", $count);
  101. foreach ($list as $item) {
  102. queue("app\job\Worker", ["type" => 99, "talent_info" => $item]);
  103. }
  104. echo "加入队列成功";
  105. }
  106. /**
  107. * 生成人才积分基础分日志
  108. */
  109. public function generate_integral_base_log() {
  110. $where = [];
  111. $where[] = ["e.type", "=", 2];
  112. $where[] = ["ti.checkState", "=", \app\common\api\TalentState::CERTIFICATED];
  113. $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();
  114. $already_in = [];
  115. foreach ($list as $item) {
  116. $unique_md5 = md5($item["card_type"] . "_" . $item["card_number"]);
  117. if (!in_array($unique_md5, $already_in)) {
  118. queue("app\job\Talent", ["type" => 4, "id" => $item["id"]]);
  119. $already_in[] = $unique_md5;
  120. }
  121. }
  122. echo "加入队列成功";
  123. }
  124. /**
  125. * 导入电路人才条款
  126. */
  127. public function import_old_ic_conditions() {
  128. $where = [];
  129. $where[] = ["type", "=", 2];
  130. $oldConditions = Db::table("un_identify_condition")->where($where)->select()->toArray();
  131. foreach ($oldConditions as $oldCondition) {
  132. queue("app\job\Worker", ["type" => 98, "id" => $oldCondition["id"]]);
  133. }
  134. }
  135. /**
  136. * 设置电路条款与旧版一致启用状态
  137. */
  138. public function set_ic_condition_active() {
  139. $where = [];
  140. $where[] = ["type", "=", 2];
  141. $upd["active"] = 2;
  142. Db::table("new_talent_condition")->where($where)->update($upd);
  143. $where = [];
  144. $where[] = ["type", "=", 2];
  145. $where[] = ["active", "=", 1];
  146. $oldActiveConditions = Db::table("un_identify_condition")->where($where)->select()->toArray();
  147. $oldActiveConditioinNames = array_column($oldActiveConditions, "name");
  148. $where = [];
  149. $where[] = ["type", "=", 2];
  150. $where[] = ["name", "in", $oldActiveConditioinNames];
  151. $upd["active"] = 1;
  152. Db::table("new_talent_condition")->where($where)->update($upd);
  153. }
  154. }