Talent.php 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\ChuanglanSmsApi;
  5. use app\common\api\VerifyApi;
  6. use app\common\api\TalentLogApi;
  7. use app\common\api\TalentState;
  8. use app\common\model\MessageRecord;
  9. use app\enterprise\model\Talent as TalentModel;
  10. use app\common\api\TalentConditionApi;
  11. use app\common\api\DictApi;
  12. use app\common\api\EnterpriseApi;
  13. use think\facade\Db;
  14. use app\admin\model\User;
  15. use app\common\api\MenuApi;
  16. use app\admin\model\Menu;
  17. use app\admin\model\SysRelation;
  18. use app\common\api\CompanyApi;
  19. /**
  20. * Description of Talent
  21. *
  22. * @author sgq
  23. */
  24. class Talent extends AdminController {
  25. public function common_check() {
  26. $request = $this->request;
  27. $params = $request->param();
  28. $id = $params["id"];
  29. $info = VerifyApi::getTalentInfoById($id);
  30. if (in_array($info["checkState"], [TalentState::BASE_VERIFY_FAIL, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_REJECT, TalentState::BASE_REVERIFY_FAIL])) {
  31. return view("talentInfo_base_check", ["info" => $info]);
  32. } else {
  33. switch ($info["enterpriseType"]) {
  34. case 1:
  35. $tpl = $info["isImport"] ? "nofile_talentInfo_common_check" : "talentInfo_common_check";
  36. return view($tpl, ["info" => $info]);
  37. case 2:
  38. return view("talentInfo_common_checkIC", ["info" => $info]);
  39. }
  40. }
  41. }
  42. public function cancel_verify() {
  43. $params = $this->request->param();
  44. $ids = $params["ids"];
  45. $msg = $params["msg"];
  46. if ($msg == "") {
  47. return json(["msg" => "请填写审核不通过的原因"]);
  48. }
  49. $ids_arr = array_filter(explode(",", $ids));
  50. $counts = 0;
  51. foreach ($ids_arr as $id) {
  52. $ti = VerifyApi::getOne($id);
  53. $data["id"] = $id;
  54. if ($ti["checkState"] == TalentState::FST_SUBMIT) {
  55. $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
  56. TalentLogApi::write(1, $id, TalentState::BASE_VERIFY_FAIL, $msg, 1);
  57. TalentModel::update($data);
  58. $counts++;
  59. } else if ($ti["checkState"] == TalentState::SCND_SAVE) {
  60. $data["checkState"] = TalentState::FST_VERIFY_FAIL;
  61. TalentLogApi::write(1, $id, TalentState::FST_VERIFY_FAIL, $msg, 1);
  62. TalentModel::update($data);
  63. $counts++;
  64. } else {
  65. return json(["msg" => "不在审核范围"]);
  66. }
  67. }
  68. return json(["code" => 200, sprintf("%d个申请已审核失败", $counts)]);
  69. }
  70. public function base_verify() {
  71. $enterprises = EnterpriseApi::getSimpleList();
  72. return view("", ["enterprises" => $enterprises]);
  73. }
  74. public function base_verify_list() {
  75. $params = $this->request->param();
  76. return json(VerifyApi::getList($params));
  77. }
  78. public function base_reverify() {
  79. $enterprises = EnterpriseApi::getSimpleList();
  80. return view("", ["enterprises" => $enterprises]);
  81. }
  82. public function base_reverify_list() {
  83. $params = $this->request->param();
  84. return json(VerifyApi::getList($params));
  85. }
  86. /**
  87. * 部门初审
  88. * @auth {{/talentInfo/gotoIndex/-1}}
  89. */
  90. public function dept_fst_verify() {
  91. return view();
  92. }
  93. /**
  94. * 初审
  95. * @auth {{/talentInfo/gotoIndex/1}}
  96. */
  97. public function fst_verify() {
  98. $enterprises = EnterpriseApi::getSimpleList();
  99. return view("", ["enterprises" => $enterprises]);
  100. }
  101. /**
  102. * 初审-审核
  103. * @auth {{/talentInfo/firstCheck}}
  104. */
  105. public function fst_check() {
  106. }
  107. /**
  108. * 初审-修改驳回字段
  109. * @auth {{/talentInfo/updateFieldsAndFiles}}
  110. */
  111. public function updateFieldsAndFiles() {
  112. }
  113. /**
  114. * 初审-审核不通过
  115. * @auth {{/talentInfo/setNotPass}}
  116. */
  117. public function dis_pass() {
  118. }
  119. /**
  120. * 部门审核
  121. * @auth {{/talentInfo/gotoIndex/2}}
  122. */
  123. public function dept_verify() {
  124. $enterprises = EnterpriseApi::getSimpleList();
  125. return view("", ["enterprises" => $enterprises]);
  126. }
  127. /**
  128. * 复审
  129. * @auth {{/talentInfo/gotoIndex/3}}
  130. */
  131. public function re_verify() {
  132. $enterprises = EnterpriseApi::getSimpleList();
  133. return view("", ["enterprises" => $enterprises]);
  134. }
  135. /**
  136. * 复审-撤销复核
  137. * @auth {{/talentInfo/cancleThirdCheck}}
  138. */
  139. public function cancel_check() {
  140. }
  141. /**
  142. * 预备人才库
  143. * @auth {{/talentInfo/gotoIndex/4}}
  144. */
  145. public function pre_list() {
  146. if (session("user")["type"] == 1) {
  147. $message = [
  148. "typeName" => "晋江市优秀人才认定", "address" => "聚才网/人才晋江微信公众号", "dep" => "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心",
  149. "phone" => "0595-85633128", "email" => "jjrc85661234@163.com"
  150. ];
  151. } else {
  152. $message = [
  153. "typeName" => "晋江市集成电路产业优秀人才认定", "address" => "福建(晋江)集成电路产业园官方网站及微信公众号", "dep" => "集成电路产业园区",
  154. "phone" => "0595-82250007、0595-82250001", "email" => "jjjcdr@163.com"
  155. ];
  156. }
  157. $enterprises = EnterpriseApi::getSimpleList();
  158. return view("", ["message" => $message, "enterprises" => $enterprises]);
  159. }
  160. public function selectNeedCheckData() {
  161. $params = $this->request->param();
  162. return json(["code" => 200, "obj" => VerifyApi::getPublicList($params)]);
  163. }
  164. /**
  165. * 预备人才库-核查征信
  166. * @auth {{/talentInfo/prepareHczx}}
  167. */
  168. public function prepareHczx() {
  169. $ids = $this->request->param("ids");
  170. $ids_arr = array_filter(explode(",", $ids));
  171. if (!$ids_arr) {
  172. $res = ["code" => 500, "msg" => "没有选择导出的名单"];
  173. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  174. }
  175. $where[] = ["ti.id", "in", $ids_arr];
  176. $list = TalentModel::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->field("ti.name,ti.card_type,ti.card_number,e.name as enterpriseName,e.description")->where($where)->select();
  177. if (!$list) {
  178. $res = ["code" => 500, "msg" => "没有可以导出的内容"];
  179. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  180. }
  181. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  182. $rows = [];
  183. $i = 1;
  184. $card_types = DictApi::selectByParentCode("card_type");
  185. foreach ($list as $item) {
  186. $row = [
  187. $i, $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], $item["description"]
  188. ];
  189. $rows[] = $row;
  190. $i++;
  191. }
  192. $filename = "优秀人才核查征信名单导出";
  193. if ($rows) {
  194. export($columns, $rows, $filename);
  195. exit();
  196. }
  197. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  198. }
  199. /**
  200. * 预备人才库-征信通过
  201. * @auth {{/talentInfo/hczxPass}}
  202. */
  203. public function hczxPass() {
  204. $params = $this->request->param();
  205. $ids = $params["ids"];
  206. $ids = array_filter(explode(",", $ids));
  207. $msg = "征信通过";
  208. $state = TalentState::ZX_PASS; //征信通过
  209. $total = count($ids);
  210. $error = 0;
  211. $success = 0;
  212. foreach ($ids as $id) {
  213. $talent_info = VerifyApi::getOne($id);
  214. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  215. $error++;
  216. continue;
  217. }
  218. if (VerifyApi::setPublic($id, $state, $msg)) {
  219. $success++;
  220. } else {
  221. $error++;
  222. }
  223. }
  224. return json(["code" => 200, "msg" => sprintf("核查征信完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  225. }
  226. /**
  227. * 预备人才库-征信失信
  228. * @auth {{/talentInfo/hczxReject}}
  229. */
  230. public function hczxReject() {
  231. $params = $this->request->param();
  232. $id = $params["id"];
  233. $msg = $params["outMsg"];
  234. if (!$msg)
  235. return json(["msg" => "请填写审核意见"]);
  236. $msg = "征信失信:" . $msg;
  237. $state = TalentState::ZX_FAIL; //征信不通过
  238. $talent_info = VerifyApi::getOne($id);
  239. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  240. return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
  241. }
  242. if (VerifyApi::setPublic($id, $state, $msg)) {
  243. return json(["code" => 200, "msg" => "已设置征信失信"]);
  244. }
  245. return json(["msg" => "设置征信失信失败"]);
  246. }
  247. /**
  248. * 预备人才库-公示预览
  249. * @auth {{/talentInfo/publicExportBefore}}
  250. */
  251. public function publicExportBefore() {
  252. $params = $this->request->param();
  253. $ids_arr = array_filter(explode(",", $params["ids"]));
  254. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  255. if ($ids_arr) {
  256. $where[] = ["id", "in", $ids_arr];
  257. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  258. $rows = [];
  259. $i = 1;
  260. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  261. foreach ($list as $item) {
  262. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  263. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  264. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  265. $row = [
  266. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ZX_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
  267. ];
  268. $rows[] = $row;
  269. $i++;
  270. }
  271. }
  272. if ($rows) {
  273. $filename = "优秀人才公示预览导出";
  274. export($columns, $rows, $filename);
  275. exit();
  276. }
  277. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  278. }
  279. /**
  280. * 预备人才库-公示导出
  281. * @auth {{/talentInfo/publicExport}}
  282. */
  283. public function publicExport() {
  284. $params = $this->request->param();
  285. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  286. $startTime = $params["startTime"];
  287. $endTime = $params["endTime"];
  288. if (!strtotime($startTime) || !strtotime($endTime))
  289. return json(["msg" => "时间格式错误"]);
  290. $where[] = ["checkState", "=", TalentState::ANNOUNCED];
  291. $where[] = ["publicBatch", "between", [$startTime, $endTime]];
  292. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  293. $rows = [];
  294. $i = 1;
  295. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  296. foreach ($list as $item) {
  297. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  298. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  299. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  300. $row = [
  301. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED ? "审核通过" : "审核不通过", $checkLog["description"]
  302. ];
  303. $rows[] = $row;
  304. $i++;
  305. }
  306. if ($rows) {
  307. $filename = "优秀人才公示导出";
  308. export($columns, $rows, $filename);
  309. exit();
  310. }
  311. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  312. }
  313. /**
  314. * 预备人才库-公示
  315. * @auth {{/talentInfo/preparePublic}}
  316. */
  317. public function preparePublic() {
  318. $params = $this->request->param();
  319. $ids = $params["ids"];
  320. $publicBatch = $params["batch"];
  321. if (!$publicBatch || strlen($publicBatch) != 6 || !is_numeric($publicBatch))
  322. return json(["msg" => "公示批次错误"]);
  323. $isMessage = $params["isMessage"] == 1 ? true : false;
  324. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  325. return json(["msg" => "短信参数不能为空"]);
  326. }
  327. $ids = array_filter(explode(",", $ids));
  328. $msg = "已公示";
  329. $state = TalentState::ANNOUNCED; //公示
  330. $total = count($ids);
  331. $error = 0;
  332. $success = 0;
  333. $phones = [];
  334. foreach ($ids as $id) {
  335. $talent_info = VerifyApi::getOne($id);
  336. if ($talent_info["checkState"] != TalentState::ZX_PASS) {
  337. $error++;
  338. continue;
  339. }
  340. if (VerifyApi::setPublic($id, $state, $msg, $publicBatch)) {
  341. $success++;
  342. $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
  343. $phones[] = $ep->agentPhone;
  344. } else {
  345. $error++;
  346. }
  347. }
  348. $phones = array_unique(array_filter($phones));
  349. if ($isMessage && $phones) {
  350. $sms = new \app\common\api\ChuanglanSmsApi();
  351. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  352. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  353. while ($phone = array_shift($phones)) {
  354. $result = $sms->sendSMS($phone, $tpl_content);
  355. $result = json_decode($result, true);
  356. $recordId = getStringId();
  357. $record_data = [
  358. 'id' => $recordId,
  359. 'bizId' => $recordId,
  360. 'type' => 2,
  361. 'smsType' => 1,
  362. 'phone' => $phone,
  363. 'params' => '公示',
  364. 'templateCode' => $tpl_content,
  365. 'state' => $result['code'] == 0 ? 2 : 3,
  366. 'sendingDate' => date("Y-m-d H:i:s", time()),
  367. 'createTime' => date("Y-m-d H:i:s", time()),
  368. 'msg' => $result['errorMsg']
  369. ];
  370. MessageRecord::create($record_data);
  371. }
  372. }
  373. return json(["code" => 200, "msg" => sprintf("公示完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  374. }
  375. /**
  376. * 预备人才库-公示再审核
  377. * @auth {{/talentInfo/prepareCheck}}
  378. */
  379. public function prepareCheck() {
  380. $params = $this->request->param();
  381. $id = $params["id"];
  382. $checkState = $params["checkState"];
  383. $msg = $params["checkMsg"];
  384. if (!$msg)
  385. return json(["msg" => "请填写审核意见"]);
  386. if ($checkState == 1) {
  387. $msg = "公示再审核通过:" . $msg;
  388. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  389. } else {
  390. $msg = "公示再审核不通过:" . $msg;
  391. $state = TalentState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
  392. }
  393. $talent_info = VerifyApi::getOne($id);
  394. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  395. return json(["msg" => "当前记录不是公示状态,无法审核"]);
  396. }
  397. if (VerifyApi::setPublic($id, $state, $msg)) {
  398. return json(["code" => 200, "msg" => "公示再审核完成"]);
  399. }
  400. return json(["msg" => "公示再审核失败"]);
  401. }
  402. /**
  403. * 预备人才库-公示通过(批量)
  404. * @auth {{/talentInfo/publicPass}}
  405. */
  406. public function publicPass() {
  407. $params = $this->request->param();
  408. $ids = $params["ids"];
  409. $ids = array_filter(explode(",", $ids));
  410. $msg = "公示再审核批量通过";
  411. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  412. $total = count($ids);
  413. $error = 0;
  414. $success = 0;
  415. foreach ($ids as $id) {
  416. $talent_info = VerifyApi::getOne($id);
  417. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  418. $error++;
  419. continue;
  420. }
  421. if (VerifyApi::setPublic($id, $state, $msg)) {
  422. $success++;
  423. } else {
  424. $error++;
  425. }
  426. }
  427. return json(["code" => 200, "msg" => sprintf("公示再审核完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  428. }
  429. /**
  430. * 预备人才库-公布预览
  431. * @auth {{/talentInfo/publishExportBefore}}
  432. */
  433. public function publishExportBefore() {
  434. $params = $this->request->param();
  435. $ids = $params["ids"];
  436. $ids = array_filter(explode(",", $ids));
  437. if ($ids) {
  438. $where[] = ["id", "in", $ids];
  439. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  440. $rows = [];
  441. $i = 1;
  442. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  443. foreach ($list as $item) {
  444. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  445. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  446. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  447. $row = [
  448. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED_REVERIFY_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
  449. ];
  450. $rows[] = $row;
  451. $i++;
  452. }
  453. }
  454. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  455. $filename = "优秀人才" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  456. if ($rows) {
  457. export($columns, $rows, $filename);
  458. exit();
  459. }
  460. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  461. }
  462. /**
  463. * 预备人才库-公布导出
  464. * @auth {{/talentInfo/publishExport}}
  465. */
  466. public function publishExport() {
  467. $params = $this->request->param();
  468. $startTime = $params["startTime"];
  469. $endTime = $params["endTime"];
  470. if (!strtotime($startTime) || !strtotime($endTime))
  471. return json(["msg" => "时间格式错误"]);
  472. $where[] = ["checkState", "=", TalentState::PUBLISH_PASS];
  473. $where[] = ["certificateGetTime", "between", [$startTime, $endTime]];
  474. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  475. $rows = [];
  476. $i = 1;
  477. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  478. foreach ($list as $item) {
  479. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  480. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  481. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  482. $row = [
  483. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::PUBLISH_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
  484. ];
  485. $rows[] = $row;
  486. $i++;
  487. }
  488. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  489. $filename = "优秀人才" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  490. if ($rows) {
  491. export($columns, $rows, $filename);
  492. exit();
  493. }
  494. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  495. }
  496. /**
  497. * 预备人才库-公布
  498. * @auth {{/talentInfo/publish}}
  499. */
  500. public function publish() {
  501. $params = $this->request->param();
  502. $id = $params["id"];
  503. $msg = $params["checkMsg"];
  504. $checkState = $params["checkState"];
  505. $batch = $params["batch"];
  506. if ($checkState == 1) {
  507. $state = TalentState::PUBLISH_PASS;
  508. $msg = "公布审核通过:" . $msg;
  509. } else {
  510. $state = TalentState::PUBLISH_FAIL;
  511. $msg = "公布审核不通过:" . $msg;
  512. }
  513. if (!$batch || !strtotime($batch))
  514. return json(["msg" => "公布批次时间错误"]);
  515. if (!$msg)
  516. return json(["msg" => "请填写审核意见"]);
  517. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  518. $batch = $params["batch"];
  519. if (!strtotime($batch))
  520. return json(["msg" => "公布批次时间错误"]);
  521. $talent_info = VerifyApi::getOne($id);
  522. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  523. return json(["msg" => "当前记录不是公示再审核通过状态,无法审核"]);
  524. }
  525. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  526. return json(["code" => 200, "msg" => "公布审核完成"]);
  527. }
  528. return json(["msg" => "公布审核失败"]);
  529. }
  530. /**
  531. * 预备人才库-批量公布通过
  532. * @auth {{/talentInfo/preparePublish}}
  533. */
  534. public function preparePublish() {
  535. $params = $this->request->param();
  536. $ids = $params["ids"];
  537. $ids = array_filter(explode(",", $ids));
  538. $msg = "批量公布";
  539. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  540. $batch = $params["batch"];
  541. if (!strtotime($batch))
  542. return json(["msg" => "公布批次时间错误"]);
  543. $total = count($ids);
  544. $error = 0;
  545. $success = 0;
  546. foreach ($ids as $id) {
  547. $talent_info = VerifyApi::getOne($id);
  548. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  549. $error++;
  550. continue;
  551. }
  552. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  553. $success++;
  554. } else {
  555. $error++;
  556. }
  557. }
  558. return json(["code" => 200, "msg" => sprintf("公布完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  559. }
  560. /**
  561. * 预备人才库-批量发放人才码
  562. * @auth {{/talentInfo/prepareCertification}}
  563. */
  564. public function prepareCertification() {
  565. $lockFile = fopen("send_certificate.lock", "a");
  566. if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
  567. //查询所有待发放人才码的数据
  568. $params = $this->request->param();
  569. $ids = array_filter(explode(",", $params["ids"]));
  570. //晋江市优秀人才证书:当前年份+层次+四位递增数字
  571. //集成电路优秀人才证书:IC+当前年份+递增四位数,如IC20190001
  572. Db::startTrans();
  573. $talent_max_no = [];
  574. $user = session("user");
  575. try {
  576. $talent_list = VerifyApi::getListByIds($ids);
  577. $year = date("Y");
  578. foreach ($talent_list as $talent_info) {
  579. if ($talent_info["checkState"] != TalentState::PUBLISH_PASS) {
  580. Db::rollback();
  581. return json(["msg" => "只能对公布通过的对象发放人才码,请核查待发放人才码名单后再重新发放人才码"]);
  582. }
  583. $no_prefix = $year . $talent_info["talent_arrange"];
  584. $where[] = ["certificateNo", "like", $no_prefix . "%"];
  585. $max_no = $talent_max_no[$talent_info["talent_arrange"]] ?: Db::table("new_talent_info")->where($where)->max("certificateNo");
  586. if (!$max_no) {
  587. $max_no = $no_prefix . "0001";
  588. } else {
  589. $new_no = intval(substr($max_no, 5)) + 1;
  590. $max_no = $no_prefix . str_pad($new_no, 4, "0", STR_PAD_LEFT);
  591. }
  592. //更新证书编号
  593. $data["id"] = $talent_info["id"];
  594. $data["certificateNo"] = $max_no;
  595. $data["checkState"] = TalentState::CERTIFICATED;
  596. $data["isPublic"] = 5;
  597. Db::table("new_talent_info")->update($data);
  598. //写入日志
  599. $log["last_state"] = TalentState::PUBLISH_PASS;
  600. $log["id"] = getStringId();
  601. $log["state"] = $log["new_state"] = TalentState::CERTIFICATED;
  602. $log["type"] = 1;
  603. $log["mainId"] = $talent_info["id"];
  604. $log["companyId"] = $user["companyId"];
  605. $log["active"] = 1;
  606. $log["description"] = "人才码为:" . $max_no;
  607. $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);
  608. $log["createTime"] = date("Y-m-d H:i:s");
  609. Db::table("new_talent_checklog")->insert($log);
  610. $talent_max_no[$talent_info["talent_arrange"]] = $max_no;
  611. }
  612. Db::commit();
  613. return json(["code" => 200, "msg" => "发放人才码成功"]);
  614. } catch (\Exception $e) {
  615. Db::rollback();
  616. return json(["msg" => "发放人才码失败:" . $e->getMessage()]);
  617. }
  618. flock($lockFile, LOCK_UN);
  619. } else {
  620. return json(["msg" => "同一时间只能有一个管理员进行发放人才码操作"]);
  621. }
  622. }
  623. /**
  624. * 预备人才库-撤销公布
  625. * @auth {{/talentInfo/prepareCanclePublish}}
  626. */
  627. public function pre_cancel_publish() {
  628. }
  629. /**
  630. * 基本条件审核-提交未保存
  631. * @param \think\Request $request
  632. * @param type $talent_info
  633. * @return type json
  634. */
  635. private function baseCheck(\think\Request $request, $talent_info) {
  636. $params = $request->param();
  637. if ($params["checkState"] == 3) {
  638. //审核成功
  639. $log_checkState = $checkState = TalentState::BASE_VERIFY_PASS; //基础信息审核成功
  640. } else {
  641. //审核驳回并记录需要修改的字段和上传文件
  642. $checkState = TalentState::FST_SAVE; //退回提交材料阶段
  643. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  644. }
  645. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  646. if (!$log)
  647. return json(["msg" => "日志数据异常,保存失败"]);
  648. if ($log["active"] == 0) {
  649. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  650. } else {
  651. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  652. }
  653. $data["id"] = $talent_info["id"];
  654. $data["modify_files"] = $params["files"];
  655. $data["modify_fields"] = $params["fields"];
  656. TalentModel::update($data);
  657. return json(["code" => 200, "msg" => "保存成功"]);
  658. }
  659. /**
  660. * 基本条件审核-提交审核
  661. * @param type $talent_info
  662. * @return type json
  663. */
  664. private function baseSubmitCheck($talent_info) {
  665. return $this->commonSubmitCheck($talent_info, 1);
  666. }
  667. /**
  668. * 基本条件复审-提交未保存
  669. * @param \think\Request $request
  670. * @param type $talent_info
  671. * @return type json
  672. */
  673. private function baseReCheck(\think\Request $request, $talent_info) {
  674. $params = $request->param();
  675. if ($params["checkState"] == 3) {
  676. //审核成功
  677. $log_checkState = $checkState = TalentState::BASE_REVERIFY_PASS; //基础信息复审成功
  678. } else if ($params["checkState"] == 2) {
  679. //审核驳回并记录需要修改的字段和上传文件
  680. $checkState = TalentState::FST_SUBMIT; //退回待基础审核状态
  681. $log_checkState = TalentState::BASE_REVERIFY_REJECT; //日志记录拒绝状态
  682. } else {
  683. $log_checkState = $checkState = TalentState::BASE_REVERIFY_FAIL; //审核失败
  684. }
  685. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  686. if (!$log)
  687. return json(["msg" => "日志数据异常,保存失败"]);
  688. if ($log["active"] == 0) {
  689. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  690. } else {
  691. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  692. }
  693. $data["id"] = $talent_info["id"];
  694. $data["modify_files"] = $params["files"];
  695. $data["modify_fields"] = $params["fields"];
  696. TalentModel::update($data);
  697. return json(["code" => 200, "msg" => "保存成功"]);
  698. }
  699. /**
  700. * 基本条件复审-提交审核
  701. * @param type $talent_info
  702. * @return type json
  703. */
  704. private function baseReSubmitCheck($talent_info) {
  705. return $this->commonSubmitCheck($talent_info, 2);
  706. }
  707. /**
  708. * 初审-提交未保存
  709. * @param \think\Request $request
  710. * @param type $talent_info
  711. * @return type json
  712. */
  713. private function fstCheck(\think\Request $request, $talent_info) {
  714. $params = $request->param();
  715. if ($params["checkState"] == 3) {
  716. //审核成功,并取消设置越过部门并审
  717. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  718. $data["pass_dept_check"] = 0;
  719. } else if ($params["checkState"] == 4) {
  720. if ($talent_info["highProcess"] < 4)
  721. return json(["msg" => "只有曾经通过部门并审,初审时才可以选择直接跳过部门并审阶段"]);
  722. //审核成功,并设置越过部门并审。附加条件:最高进度曾经通过部门并审4(包含部门并审)
  723. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  724. $data["pass_dept_check"] = $talent_info["highProcess"] >= 4 ? 1 : 0;
  725. } else if ($params["checkState"] == 5) {
  726. //选择重审部门
  727. if ($talent_info["highProcess"] < 4)
  728. return json(["msg" => "只有曾经通过部门并审,初审时才可以选择再次审核的部门"]);
  729. if (!$params["companys"])
  730. return json(["msg" => "请选择需要再次审核的部门"]);
  731. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  732. $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
  733. $re_check_companys = array_filter(explode(",", $talent_info["re_check_companys"]));
  734. foreach ($re_check_companys as $reCompanyId) {
  735. if (!in_array($reCompanyId, $companyIds)) {
  736. return json(["msg" => "错误的部门"]);
  737. }
  738. }
  739. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  740. $data["pass_dept_check"] = 0;
  741. } else {
  742. //审核驳回并记录需要修改的字段和上传文件
  743. $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
  744. $log_checkState = TalentState::FST_VERIFY_REJECT; //日志记录拒绝状态
  745. }
  746. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  747. if (!$log)
  748. return json(["msg" => "日志数据异常,保存失败"]);
  749. if ($log["active"] == 0) {
  750. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  751. } else {
  752. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  753. }
  754. $data["id"] = $talent_info["id"];
  755. $data["modify_files"] = $params["files"];
  756. $data["modify_fields"] = $params["fields"];
  757. $data["re_check_companys"] = $params["companys"];
  758. TalentModel::update($data);
  759. return json(["code" => 200, "msg" => "保存成功"]);
  760. }
  761. /**
  762. * 初审-提交审核
  763. * @param type $talent_info
  764. * @return type json
  765. */
  766. private function fstSubmitCheck($talent_info) {
  767. $nowProcess = 3;
  768. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  769. if (!$log || $log["active"] == 1)
  770. return json(["msg" => "请先保存审核状态,再提交审核"]);
  771. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  772. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  773. }
  774. $userIds = [];
  775. if ($log["new_state"] == TalentState::FST_VERIFY_PASS && $talent_info["pass_dept_check"] == 0) {
  776. $data["first_dept_check_time"] = date("Y-m-d H:i:s");
  777. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  778. $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
  779. if ($talent_info["re_check_companys"]) {
  780. $unpass_companyIds = array_filter(explode(",", $talent_info["re_check_companys"]));
  781. } else {
  782. //这边去除已经审核通过的单位,主要通过日志是否存在记录。
  783. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  784. $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
  785. if (!$unpass_companyIds) {
  786. $data["pass_dept_check"] = 1; //部门已经全部审核过了,跳过部门审核
  787. }
  788. }
  789. if ($unpass_companyIds) {
  790. sort($unpass_companyIds);
  791. TalentLogApi::writeDeptLogs($talent_info["id"], $unpass_companyIds, TalentState::FST_VERIFY_PASS);
  792. //初审通过发送短信通知并审部门
  793. $privs = ["/admin/talent/dept_check"];
  794. $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
  795. $where[] = ["menuid", "in", $menuIds];
  796. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
  797. $where = [];
  798. $where[] = ["status", "=", 1];
  799. $where[] = ["companyId", "in", $unpass_companyIds];
  800. $where[] = ["roleid", "in", $roleIds];
  801. $where[] = ["roleid", "<>", 1];
  802. $userIds = User::where($where)->column("id");
  803. }
  804. }
  805. $data["id"] = $talent_info["id"];
  806. $data["checkState"] = $log["new_state"];
  807. TalentModel::update($data);
  808. TalentLogApi::setActive($log["id"], 1);
  809. $this->sendMsgByState($talent_info, $log["new_state"], $userIds);
  810. return json(["code" => 200, "msg" => "审核成功"]);
  811. }
  812. /**
  813. * 部门审核-提交未保存
  814. * @param \think\Request $request
  815. * @param type $talent_info
  816. * @return type json
  817. */
  818. private function deptCheck(\think\Request $request, $talent_info, $companys) {
  819. if ($talent_info["pass_dept_check"] == 1)
  820. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  821. if (!in_array($this->user["companyId"], $companys))
  822. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  823. //$pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  824. //if (in_array($this->user["companyId"], $pass_companyIds))
  825. //return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  826. $un_check_companyIds = TalentLogApi::getUnCheckDepts($talent_info["id"]); //未审核提交的单位
  827. if (!in_array($this->user["companyId"], $un_check_companyIds))
  828. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  829. $params = $request->param();
  830. if ($params["checkState"] == 3) {
  831. //审核成功
  832. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  833. $checkState = TalentState::DEPT_VERIFY_PASS; //审核成功
  834. } else {
  835. //审核驳回并记录需要修改的字段和上传文件
  836. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  837. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  838. $talent_condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  839. if (!$talent_condition["companyWithFileType"])
  840. return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
  841. $cwfts = explode(";", $talent_condition["companyWithFileType"]);
  842. $company_setting = [];
  843. foreach ($cwfts as $cwft) {
  844. $_company_setting = explode(":", $cwft);
  845. if ($_company_setting[0] == $this->user["companyId"]) {
  846. $company_setting = explode(",", $_company_setting[1]);
  847. break;
  848. }
  849. }
  850. if (!$company_setting)
  851. return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
  852. //$data["modify_fields"] = $params["fields"];
  853. $original_modify_files = explode(",", $talent_info["modify_files"]);
  854. $_current_modify_files = explode(",", $params["files"]);
  855. $unselect_files = array_diff($company_setting, $_current_modify_files); //比较设置和当前提交的,取差值集,既是可选而未选的附件集合
  856. $new_modify_files = array_unique(array_merge($original_modify_files, $_current_modify_files)); //合并当前提交及库中原来保存的值
  857. foreach ($new_modify_files as $key => $item) {
  858. if (in_array($item, $unselect_files))
  859. unset($new_modify_files[$key]);
  860. }
  861. $data["modify_files"] = implode(",", array_unique($new_modify_files));
  862. }
  863. $fst_dept_check_time = $talent_info["first_dept_check_time"];
  864. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $fst_dept_check_time);
  865. if (!$dept_log)
  866. return json(["msg" => "未匹配日志,审核失败"]);
  867. if ($dept_log["active"] == 1)
  868. return json(["msg" => "您的部门已经审核过了"]);
  869. $data["id"] = $talent_info["id"];
  870. TalentModel::update($data);
  871. //修改日志
  872. TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  873. return json(["code" => 200, "msg" => "保存成功"]);
  874. }
  875. /**
  876. * 部门审核-提交审核
  877. * @param type $talent_info
  878. * @return type json
  879. */
  880. private function deptSubmitCheck($talent_info, $companys) {
  881. if ($talent_info["pass_dept_check"] == 1)
  882. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  883. if (!in_array($this->user["companyId"], $companys))
  884. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  885. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  886. if (in_array($this->user["companyId"], $pass_companyIds))
  887. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  888. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $talent_info["first_dept_check_time"]);
  889. if (!$dept_log)
  890. return json(["msg" => "未匹配日志,审核失败"]);
  891. if ($dept_log["state"] == $dept_log["new_state"])
  892. return json(["msg" => "请先保存审核状态,再提交审核"]);
  893. if ($dept_log["active"] == 1)
  894. return json(["msg" => "您的部门已经审核过了"]);
  895. if ($talent_info["re_check_companys"]) {
  896. $companys = array_filter(explode(",", $talent_info["re_check_companys"]));
  897. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"], $talent_info["first_dept_check_time"]); //重审单位中已经通过的单位
  898. }
  899. $over = $pass_companyIds ? count($pass_companyIds) : 0; //完成度,如果重审之前已有通过审核的部门,不用再审,直接按通过算
  900. $error = 0; //失败数
  901. $nowProcess = 4;
  902. $over++;
  903. if ($dept_log["new_state"] == TalentState::SCND_SUBMIT) {
  904. $error++;
  905. }
  906. $logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
  907. for ($i = 0; $i < count($logs); $i++) {
  908. if (!in_array($logs[$i]["companyId"], $pass_companyIds)) {
  909. $over += $logs[$i]["active"] == 1 ? 1 : 0;
  910. if ($logs[$i]["new_state"] == TalentState::SCND_SUBMIT) {
  911. $error++;
  912. }
  913. }
  914. }
  915. if ($over == count($companys)) {
  916. //全部已审核
  917. $checkState = TalentState::SCND_SUBMIT;
  918. $log_checkState = TalentState::DEPT_VERIFY_REJECT;
  919. if ($error == 0) {
  920. $log_checkState = $checkState = TalentState::DEPT_VERIFY_PASS;
  921. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  922. }
  923. $data["id"] = $talent_info["id"];
  924. $data["checkState"] = $checkState;
  925. $data["first_dept_check_time"] = null;
  926. $data["re_check_companys"] = null;
  927. TalentModel::update($data);
  928. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "部门审核结束", 1);
  929. if ($log_checkState == TalentState::DEPT_VERIFY_REJECT) {
  930. //部门驳回发送短信通知
  931. $privs = ["admin/talent/fst_check"];
  932. $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
  933. $where[] = ["menuid", "in", $menuIds];
  934. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
  935. $where = [];
  936. $where[] = ["status", "=", 1];
  937. $where[] = ["roleid", "in", $roleIds];
  938. $where[] = ["roleid", "<>", 1];
  939. $userIds = User::where($where)->column("id");
  940. $this->sendMsgByState($talent_info, $log_checkState, $userIds);
  941. }
  942. }
  943. TalentLogApi::setActive($dept_log["id"], 1);
  944. return json(["code" => 200, "msg" => "审核成功"]);
  945. }
  946. /**
  947. * 复审-提交未保存
  948. * @param \think\Request $request
  949. * @param type $talent_info
  950. * @param type json
  951. */
  952. private function reCheck(\think\Request $request, $talent_info) {
  953. $params = $request->param();
  954. if ($params["checkState"] == 3) {
  955. //审核成功
  956. $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
  957. } else if ($params["checkState"] == 2) {
  958. //审核驳回并记录需要修改的字段和上传文件
  959. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  960. $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
  961. } else {
  962. $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
  963. }
  964. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  965. if (!$log)
  966. return json(["msg" => "日志数据异常,保存失败"]);
  967. if ($log["active"] == 0) {
  968. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  969. } else {
  970. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  971. }
  972. $data["id"] = $talent_info["id"];
  973. $data["modify_files"] = $params["files"];
  974. $data["modify_fields"] = $params["fields"];
  975. TalentModel::update($data);
  976. return json(["code" => 200, "msg" => "保存成功"]);
  977. }
  978. /**
  979. * 复审-提交审核
  980. * @param type $talent_info
  981. * @return type json
  982. */
  983. private function reSubmitCheck($talent_info) {
  984. return $this->commonSubmitCheck($talent_info, 5);
  985. }
  986. private function commonSubmitCheck($talent_info, $nowProcess) {
  987. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  988. if (!$log || $log["active"] == 1)
  989. return json(["msg" => "请先保存审核状态,再提交审核"]);
  990. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  991. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  992. }
  993. $data["id"] = $talent_info["id"];
  994. $data["checkState"] = $log["new_state"];
  995. TalentModel::update($data);
  996. TalentLogApi::setActive($log["id"], 1);
  997. $userIds = [];
  998. if (in_array($data["checkState"], [TalentState::REVERIFY_PASS, TalentState::REVERIFY_REJECT])) {
  999. //复核成功需要发送短信给征信部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
  1000. //从征信审核权限,逆推征信部门
  1001. if ($data["checkState"] == TalentState::REVERIFY_PASS) {
  1002. $privs = ["/admin/talent/hczxReject", "/admin/talent/hczxPass"];
  1003. } else {
  1004. $privs = ["admin/talent/fst_check"];
  1005. }
  1006. $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
  1007. $where = [];
  1008. $where[] = ["menuid", "in", $menuIds];
  1009. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
  1010. $where = [];
  1011. $where[] = ["status", "=", 1];
  1012. $where[] = ["roleid", "in", $roleIds];
  1013. $where[] = ["roleid", "<>", 1];
  1014. $userIds = User::where($where)->column("id");
  1015. }
  1016. $this->sendMsgByState($talent_info, $data["checkState"], $userIds);
  1017. return json(["code" => 200, "msg" => "审核成功"]);
  1018. }
  1019. private function sendMsgByState($talent_info, $state, $userIds = []) {
  1020. $phones = [];
  1021. $template = "";
  1022. $type = 0;
  1023. $processName = "";
  1024. $userId = 0;
  1025. $name = null;
  1026. switch ($state) {
  1027. case TalentState::BASE_VERIFY_PASS://基础信息审核通过发送短信通知用户
  1028. $type = 2;
  1029. $processName = "基础信息审核";
  1030. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核通过,请及时登录申报系统并进行人才认定的信息申报填写。";
  1031. break;
  1032. case TalentState::BASE_REJECT://基础信息审核驳回发送短信通知用户
  1033. $type = 2;
  1034. $processName = "基础信息审核";
  1035. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
  1036. break;
  1037. case TalentState::BASE_VERIFY_FAIL://基础信息审核不通过发送短信通知用户
  1038. $type = 2;
  1039. $processName = "基础信息审核";
  1040. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核不通过,原因是:{$log['description']}。";
  1041. break;
  1042. case TalentState::FST_VERIFY_PASS://初审通过发送短信通知并审部门
  1043. $type = 1;
  1044. $processName = "初级审核";
  1045. $template = "【晋江市人才服务平台】您的部门有新的人才认定申报需要审批,请及时登录审批系统处理。";
  1046. break;
  1047. case TalentState::FST_VERIFY_REJECT; //初审驳回发送短信通知用户
  1048. $type = 2;
  1049. $processName = "初级审核";
  1050. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
  1051. break;
  1052. case TalentState::FST_VERIFY_FAIL://初审不通过发送短信通知用户
  1053. $type = 2;
  1054. $processName = "初级审核";
  1055. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核不通过,原因是:{$log['description']}。";
  1056. break;
  1057. case TalentState::DEPT_VERIFY_REJECT://并审驳回发送短信通知初审部门
  1058. $type = 1;
  1059. $processName = "部门并审";
  1060. $template = "【晋江市人才服务平台】有人才认定申报在并审阶段被驳回,原因是:{$log['description']},请及时登录审批系统处理。";
  1061. break;
  1062. case TalentState::REVERIFY_PASS://复核通过发短信通知征信部门
  1063. $type = 1;
  1064. $processName = "复审";
  1065. $template = "【晋江市人才服务平台】有新的人才认定申报通过复审进入征信阶段,请及时登录审批系统处理。";
  1066. break;
  1067. case TalentState::REVERIFY_REJECT://复核驳回发短信通知初审部门
  1068. $type = 1;
  1069. $processName = "复审";
  1070. $template = "【晋江市人才服务平台】有人才认定申报在复审阶段被驳回,原因是:{$log['description']},请及时登录审批系统处理。";
  1071. break;
  1072. }
  1073. if ($type == 1) {
  1074. $where = [];
  1075. $where[] = ["id", "in", $userIds];
  1076. $phones = User::where($where)->column("phone");
  1077. $phones = array_unique(array_filter($phones));
  1078. }
  1079. if ($type == 2) {
  1080. $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
  1081. $phones[] = $ep->agentPhone;
  1082. $userId = $ep->id;
  1083. $name = $ep->name;
  1084. }
  1085. if ($phones && $template) {
  1086. while ($phone = array_shift($phones)) {
  1087. $smsapi = new ChuanglanSmsApi();
  1088. $result = $smsapi->sendSMS($phone, $template);
  1089. $result = json_decode($result, true);
  1090. $id = getStringId();
  1091. $record_data = [
  1092. 'id' => $id,
  1093. 'userId' => $userId,
  1094. 'bizId' => $id,
  1095. 'type' => $type,
  1096. 'smsType' => 2,
  1097. 'name' => $name,
  1098. 'phone' => $phone,
  1099. 'params' => $processName,
  1100. 'templateCode' => $template,
  1101. 'state' => $result['code'] == 0 ? 2 : 3,
  1102. 'sendingDate' => date("Y-m-d H:i:s", time()),
  1103. 'createTime' => date("Y-m-d H:i:s", time()),
  1104. 'msg' => $result['errorMsg']
  1105. ];
  1106. MessageRecord::create($record_data);
  1107. }
  1108. }
  1109. }
  1110. public function check() {
  1111. //公共调度方法
  1112. $request = $this->request;
  1113. $params = $request->param();
  1114. $check = $params["checkState"];
  1115. $check_msg = trim($params["checkMsg"]);
  1116. $files = $params["files"];
  1117. $fields = $params["fields"];
  1118. $id = $params["id"];
  1119. $talent_info = VerifyApi::getOne($id);
  1120. $checkState = $talent_info["checkState"];
  1121. if (!$talent_info) {
  1122. return json(["msg" => "数据错误"]);
  1123. }
  1124. if (!$check) {
  1125. return json(["msg" => "请选择审核状态"]);
  1126. }
  1127. if (!$check_msg) {
  1128. return json(["msg" => "请填写审核说明"]);
  1129. }
  1130. if ($checkState == TalentState::FST_SUBMIT) {
  1131. return $this->baseCheck($request, $talent_info);
  1132. } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
  1133. return $this->baseReCheck($request, $talent_info);
  1134. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1135. return $this->fstCheck($request, $talent_info);
  1136. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  1137. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1138. $companys = array_filter(explode(",", $condition["companyIds"]));
  1139. if ($companys && $talent_info["pass_dept_check"] != 1) {
  1140. if (!in_array($this->user["companyId"], $companys))
  1141. return json(["msg" => "你的部门不在并审部门列表"]);
  1142. return $this->deptCheck($request, $talent_info, $companys);
  1143. } else {
  1144. return $this->reCheck($request, $talent_info);
  1145. }
  1146. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  1147. return $this->reCheck($request, $talent_info);
  1148. } else {
  1149. return json(["msg" => "不在审核范围内,保存失败"]);
  1150. }
  1151. }
  1152. public function submitCheck() {
  1153. //公共调度方法
  1154. $id = $this->request->param("id");
  1155. $talent_info = VerifyApi::getOne($id);
  1156. $checkState = $talent_info["checkState"];
  1157. if (!$talent_info) {
  1158. return json(["msg" => "数据错误"]);
  1159. }
  1160. if ($checkState == TalentState::FST_SUBMIT) {
  1161. return $this->baseSubmitCheck($talent_info);
  1162. } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
  1163. return $this->baseReSubmitCheck($talent_info);
  1164. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1165. return $this->fstSubmitCheck($talent_info);
  1166. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  1167. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1168. $companys = array_filter(explode(",", $condition["companyIds"]));
  1169. if ($companys && $talent_info["pass_dept_check"] != 1) {
  1170. if (!in_array($this->user["companyId"], $companys))
  1171. return json(["msg" => "你的部门不在并审部门列表"]);
  1172. return $this->deptSubmitCheck($talent_info, $companys);
  1173. } else {
  1174. return $this->reSubmitCheck($talent_info);
  1175. }
  1176. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  1177. return $this->reSubmitCheck($talent_info);
  1178. } else {
  1179. return json(["msg" => "不在审核范围内,审核失败"]);
  1180. }
  1181. }
  1182. public function validateIsCheck() {
  1183. $params = $this->request->param();
  1184. $id = $params["id"];
  1185. $talent_info = VerifyApi::getOne($id);
  1186. $fstLog = TalentLogApi::getFstLog($id, 1);
  1187. $isMix = false;
  1188. if (in_array($fstLog["state"], [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT])) {
  1189. //初次提交是待初审状态,则为新的混合基础信息和人才认证信息的申报
  1190. $isMix = true;
  1191. }
  1192. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  1193. if ($talent_info) {
  1194. $checkState = $talent_info["checkState"];
  1195. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5基审复核通过 6基审复核驳回 7基审复核失败 8保存补充材料未提交 9提交补充材料进入初审 10初审通过 11初审驳回 12部门审核通过 13部门审核驳回 14复核通过 15复核驳回 16复核失败
  1196. $process = 0;
  1197. if (in_array($checkState, [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS])) {
  1198. switch ($checkState) {
  1199. case TalentState::FST_SUBMIT:
  1200. $fields = DictApi::getTalentFields(1);
  1201. $field_tmp = [];
  1202. foreach ($fields as $key => $field) {
  1203. $field_tmp[] = ["key" => $key, "value" => $field];
  1204. }
  1205. $where[] = ["project", "=", 1];
  1206. $where[] = ["step", "=", 1];
  1207. $where[] = ["active", "=", 1];
  1208. $where[] = ["type", "=", $enterprise["type"]];
  1209. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1210. /* foreach ($files as $key => $file) {
  1211. $options = array_filter(explode(",", $file["option"]));
  1212. if ($options) {
  1213. switch ($file["rel"]) {
  1214. case "talent_type":
  1215. $allow_tags = array_filter(explode(",", $file["enterprise_tag"]));
  1216. if ($allow_tags && !in_array($enterprise["enterpriseTag"], $allow_tags)) {
  1217. unset($files[$key]);
  1218. break;
  1219. }
  1220. if (!in_array($talent_info["talent_type"], $options)) {
  1221. unset($files[$key]);
  1222. break;
  1223. }
  1224. break;
  1225. case "birthday":
  1226. $birthYear = substr($talent_info["birthday"], 0, 4);
  1227. $currentYear = date("Y");
  1228. $age = $currentYear - $birthYear;
  1229. if ($age < $options[0]) {
  1230. unset($files[$key]);
  1231. break;
  1232. }
  1233. break;
  1234. }
  1235. }
  1236. } */
  1237. $process = 1;
  1238. break;
  1239. case TalentState::BASE_VERIFY_PASS:
  1240. $fields = DictApi::getTalentFields(1);
  1241. $field_tmp = [];
  1242. foreach ($fields as $key => $field) {
  1243. $field_tmp[] = ["key" => $key, "value" => $field];
  1244. }
  1245. $where[] = ["project", "=", 1];
  1246. $where[] = ["step", "=", 1];
  1247. $where[] = ["active", "=", 1];
  1248. $where[] = ["type", "=", $enterprise["type"]];
  1249. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1250. $process = 2;
  1251. break;
  1252. case TalentState::SCND_SUBMIT:
  1253. $fields = DictApi::getTalentFields(2);
  1254. $process = 3;
  1255. break;
  1256. case TalentState::FST_VERIFY_PASS:
  1257. $tc = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1258. if ($tc["companyIds"] && $talent_info["pass_dept_check"] != 1) {
  1259. $process = 4;
  1260. $fields = DictApi::getTalentFields(3);
  1261. } else {
  1262. $process = 5;
  1263. $fields = DictApi::getTalentFields(2);
  1264. }
  1265. break;
  1266. case TalentState::DEPT_VERIFY_PASS:
  1267. $process = 5;
  1268. $fields = DictApi::getTalentFields(2);
  1269. break;
  1270. }
  1271. if ($isMix && $process != 4) {
  1272. if ($enterprise["type"] == 2) {
  1273. $fields = DictApi::getTalentFields_IC();
  1274. } else {
  1275. $fields = DictApi::getTalentFields(4);
  1276. }
  1277. }
  1278. if ($checkState != TalentState::FST_SUBMIT) {
  1279. //$fields = DictApi::getTalentFields(2);
  1280. $field_tmp = [];
  1281. if ($fields) {
  1282. foreach ($fields as $key => $field) {
  1283. $field_tmp[] = ["key" => $key, "value" => $field];
  1284. }
  1285. }
  1286. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1287. $companys = array_filter(explode(",", $condition["companyIds"]));
  1288. $_companys = [];
  1289. foreach ($companys as $companyId) {
  1290. $company = CompanyApi::getOne($companyId);
  1291. $_companys[] = $company;
  1292. }
  1293. if ($process == 4 && $enterprise["type"] == 1) {
  1294. $where = [];
  1295. $where[] = ["delete", "=", 0];
  1296. $cwfts = explode(";", $condition["companyWithFileType"]);
  1297. foreach ($cwfts as $cwft) {
  1298. $_company_setting = explode(":", $cwft);
  1299. if ($_company_setting[0] == $this->user["companyId"]) {
  1300. $where[] = ["id", "in", explode(",", $_company_setting[1])];
  1301. break;
  1302. }
  1303. }
  1304. if ($where) {
  1305. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1306. } else {
  1307. $files = [];
  1308. }
  1309. } else {
  1310. $where = [];
  1311. $whr = [];
  1312. if (!$isMix) {
  1313. $where[] = ["step", "=", 2];
  1314. }
  1315. $where[] = ["project", "=", 1];
  1316. $where[] = ["active", "=", 1];
  1317. $where[] = ["type", "=", $enterprise["type"]];
  1318. $where[] = ["isConditionFile", "<>", 1];
  1319. $where[] = ["delete", "=", 0];
  1320. if ($condition && $condition["bindFileTypes"]) {
  1321. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  1322. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->select();
  1323. } else {
  1324. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1325. }
  1326. }
  1327. }
  1328. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  1329. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  1330. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files, "companys" => $_companys]]);
  1331. } else {
  1332. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  1333. }
  1334. }
  1335. }
  1336. public function findFieldsAndFiles() {
  1337. }
  1338. public function baseVerifyListExport() {
  1339. $this->commonExport(1);
  1340. }
  1341. public function baseReverifyListExport() {
  1342. $this->commonExport(2);
  1343. }
  1344. public function fstVerifyListExport() {
  1345. $this->commonExport(3);
  1346. }
  1347. public function deptVerifyListExport() {
  1348. $this->commonExport(4);
  1349. }
  1350. public function reVerifyListExport() {
  1351. $this->commonExport(5);
  1352. }
  1353. public function preListExport() {
  1354. $this->commonExport(6);
  1355. }
  1356. private function commonExport($process) {
  1357. $params = $this->request->param();
  1358. $fields = $params["export"];
  1359. if (!$fields)
  1360. return json(["msg" => "请选择要导出的数据"]);
  1361. $names = DictApi::getTalentFields(4);
  1362. $names["industryFieldNew"] = "产业领域";
  1363. $names["enterpriseName"] = "单位名称";
  1364. $names["enterpriseTag"] = "单位标签";
  1365. $names["street"] = "所属镇街";
  1366. $names["checkState"] = "审核状态";
  1367. $names["checkMsg"] = "审核意见";
  1368. $list = VerifyApi::getExportDatas($process, $fields);
  1369. foreach ($fields as $field) {
  1370. $columns[] = $names[$field];
  1371. }
  1372. $datas = [];
  1373. for ($i = 0; $i < count($list); $i++) {
  1374. $data = [];
  1375. for ($n = 0; $n < count($fields); $n++) {
  1376. $data[] = $list[$i][$fields[$n]];
  1377. }
  1378. $datas[] = $data;
  1379. }
  1380. if ($datas) {
  1381. export($columns, $datas);
  1382. exit();
  1383. }
  1384. echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
  1385. }
  1386. public function getPhones() {
  1387. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1388. $result = [];
  1389. if ($list) {
  1390. foreach ($list as $item) {
  1391. if ($item["phone"] && $item["name"]) {
  1392. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  1393. }
  1394. }
  1395. }
  1396. return json(["code" => 200, "obj" => implode(";", $result)]);
  1397. }
  1398. public function getEnterprisePhones() {
  1399. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1400. $result = [];
  1401. if ($list) {
  1402. foreach ($list as $item) {
  1403. if ($item["agentName"] && $item["agentPhone"]) {
  1404. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  1405. }
  1406. }
  1407. }
  1408. return json(["code" => 200, "obj" => implode(";", $result)]);
  1409. }
  1410. }