System.php 5.7 KB

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