System.php 5.8 KB

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