Talent.php 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\VerifyApi;
  5. use app\common\api\TalentLogApi;
  6. use app\common\api\TalentState;
  7. use app\enterprise\model\Talent as TalentModel;
  8. use app\common\api\TalentConditionApi;
  9. use app\common\api\DictApi;
  10. use app\common\api\EnterpriseApi;
  11. use think\facade\Db;
  12. /**
  13. * Description of Talent
  14. *
  15. * @author sgq
  16. */
  17. class Talent extends AdminController {
  18. public function common_check() {
  19. $request = $this->request;
  20. $params = $request->param();
  21. $id = $params["id"];
  22. $info = VerifyApi::getTalentInfoById($id);
  23. if (in_array($info["checkState"], [-1, 2])) {
  24. return view("talentInfo_base_check", ["info" => $info]);
  25. } else {
  26. return view("talentInfo_common_check", ["info" => $info]);
  27. }
  28. }
  29. public function cancel_verify() {
  30. $params = $this->request->param();
  31. $ids = $params["ids"];
  32. $msg = $params["msg"];
  33. if ($msg == "") {
  34. return json(["msg" => "请填写审核不通过的原因"]);
  35. }
  36. $ids_arr = array_filter(explode(",", $ids));
  37. $counts = 0;
  38. foreach ($ids_arr as $id) {
  39. $ti = VerifyApi::getOne($id);
  40. $data["id"] = $id;
  41. if ($ti["checkState"] == TalentState::FST_SUBMIT) {
  42. $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
  43. TalentLogApi::write(1, $id, TalentState::BASE_VERIFY_FAIL, $msg, 1);
  44. TalentModel::update($data);
  45. $counts++;
  46. } else if ($ti["checkState"] == TalentState::SCND_SAVE) {
  47. $data["checkState"] = TalentState::FST_VERIFY_FAIL;
  48. TalentLogApi::write(1, $id, TalentState::FST_VERIFY_FAIL, $msg, 1);
  49. TalentModel::update($data);
  50. $counts++;
  51. } else {
  52. return json(["msg" => "不在审核范围"]);
  53. }
  54. }
  55. return json(["code" => 200, sprintf("%d个申请已审核失败", $counts)]);
  56. }
  57. public function base_verify() {
  58. return view();
  59. }
  60. public function base_verify_list() {
  61. $request = $this->request;
  62. return json(VerifyApi::getList($request));
  63. }
  64. /**
  65. * 部门初审
  66. * @auth {{/talentInfo/gotoIndex/-1}}
  67. */
  68. public function dept_fst_verify() {
  69. return view();
  70. }
  71. /**
  72. * 初审
  73. * @auth {{/talentInfo/gotoIndex/1}}
  74. */
  75. public function fst_verify() {
  76. return view();
  77. }
  78. /**
  79. * 初审-审核
  80. * @auth {{/talentInfo/firstCheck}}
  81. */
  82. public function fst_check() {
  83. }
  84. /**
  85. * 初审-修改驳回字段
  86. * @auth {{/talentInfo/updateFieldsAndFiles}}
  87. */
  88. public function updateFieldsAndFiles() {
  89. }
  90. /**
  91. * 初审-审核不通过
  92. * @auth {{/talentInfo/setNotPass}}
  93. */
  94. public function dis_pass() {
  95. }
  96. /**
  97. * 部门审核
  98. * @auth {{/talentInfo/gotoIndex/2}}
  99. */
  100. public function dept_verify() {
  101. return view();
  102. }
  103. /**
  104. * 复审
  105. * @auth {{/talentInfo/gotoIndex/3}}
  106. */
  107. public function re_verify() {
  108. return view();
  109. }
  110. /**
  111. * 复审-撤销复核
  112. * @auth {{/talentInfo/cancleThirdCheck}}
  113. */
  114. public function cancel_check() {
  115. }
  116. /**
  117. * 预备人才库
  118. * @auth {{/talentInfo/gotoIndex/4}}
  119. */
  120. public function pre_list() {
  121. return view();
  122. }
  123. public function selectNeedCheckData() {
  124. $params = $this->request->param();
  125. return json(["code" => 200, "obj" => VerifyApi::getPublicList($params)]);
  126. }
  127. /**
  128. * 预备人才库-核查征信
  129. * @auth {{/talentInfo/prepareHczx}}
  130. */
  131. public function prepareHczx() {
  132. $ids = $this->request->param("ids");
  133. $ids_arr = array_filter(explode(",", $ids));
  134. if (!$ids_arr) {
  135. $res = ["code" => 500, "msg" => "没有选择导出的名单"];
  136. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  137. }
  138. $where[] = ["ti.id", "in", $ids_arr];
  139. $list = TalentModel::alias("ti")->leftJoin("new_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();
  140. if (!$list) {
  141. $res = ["code" => 500, "msg" => "没有可以导出的内容"];
  142. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  143. }
  144. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  145. $rows = [];
  146. $i = 1;
  147. $card_types = DictApi::selectByParentCode("card_type");
  148. foreach ($list as $item) {
  149. $row = [
  150. $i, $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], $item["description"]
  151. ];
  152. $rows[] = $row;
  153. $i++;
  154. }
  155. $filename = "优秀人才核查征信名单导出";
  156. if ($rows) {
  157. export($columns, $rows, $filename);
  158. exit();
  159. }
  160. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  161. }
  162. /**
  163. * 预备人才库-征信通过
  164. * @auth {{/talentInfo/hczxPass}}
  165. */
  166. public function hczxPass() {
  167. $params = $this->request->param();
  168. $ids = $params["ids"];
  169. $ids = array_filter(explode(",", $ids));
  170. $msg = "征信通过";
  171. $state = TalentState::ZX_PASS; //征信通过
  172. $total = count($ids);
  173. $error = 0;
  174. $success = 0;
  175. foreach ($ids as $id) {
  176. $talent_info = VerifyApi::getOne($id);
  177. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  178. $error++;
  179. continue;
  180. }
  181. if (VerifyApi::setPublic($id, $state, $msg)) {
  182. $success++;
  183. } else {
  184. $error++;
  185. }
  186. }
  187. return json(["code" => 200, "msg" => sprintf("核查征信完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  188. }
  189. /**
  190. * 预备人才库-征信失信
  191. * @auth {{/talentInfo/hczxReject}}
  192. */
  193. public function hczxReject() {
  194. $params = $this->request->param();
  195. $id = $params["id"];
  196. $msg = $params["outMsg"];
  197. if (!$msg)
  198. return json(["msg" => "请填写审核意见"]);
  199. $msg = "征信失信:" . $msg;
  200. $state = TalentState::ZX_FAIL; //征信不通过
  201. $talent_info = VerifyApi::getOne($id);
  202. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  203. return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
  204. }
  205. if (VerifyApi::setPublic($id, $state, $msg)) {
  206. return json(["code" => 200, "msg" => "已设置征信失信"]);
  207. }
  208. return json(["msg" => "设置征信失信失败"]);
  209. }
  210. /**
  211. * 预备人才库-公示预览
  212. * @auth {{/talentInfo/publicExportBefore}}
  213. */
  214. public function publicExportBefore() {
  215. $params = $this->request->param();
  216. $ids_arr = array_filter(explode(",", $params["ids"]));
  217. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  218. if ($ids_arr) {
  219. $where[] = ["id", "in", $ids_arr];
  220. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  221. $rows = [];
  222. $i = 1;
  223. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  224. foreach ($list as $item) {
  225. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  226. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  227. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  228. $row = [
  229. $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"]
  230. ];
  231. $rows[] = $row;
  232. $i++;
  233. }
  234. }
  235. if ($rows) {
  236. $filename = "优秀人才公示预览导出";
  237. export($columns, $rows, $filename);
  238. exit();
  239. }
  240. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  241. }
  242. /**
  243. * 预备人才库-公示导出
  244. * @auth {{/talentInfo/publicExport}}
  245. */
  246. public function publicExport() {
  247. $params = $this->request->param();
  248. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  249. $startTime = $params["startTime"];
  250. $endTime = $params["endTime"];
  251. if (!strtotime($startTime) || !strtotime($endTime))
  252. return json(["msg" => "时间格式错误"]);
  253. $where[] = ["checkState", "=", TalentState::ANNOUNCED];
  254. $where[] = ["publicBatch", "between", [$startTime, $endTime]];
  255. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  256. $rows = [];
  257. $i = 1;
  258. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  259. foreach ($list as $item) {
  260. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  261. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  262. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  263. $row = [
  264. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED ? "审核通过" : "审核不通过", $checkLog["description"]
  265. ];
  266. $rows[] = $row;
  267. $i++;
  268. }
  269. if ($rows) {
  270. $filename = "优秀人才公示导出";
  271. export($columns, $rows, $filename);
  272. exit();
  273. }
  274. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  275. }
  276. /**
  277. * 预备人才库-公示
  278. * @auth {{/talentInfo/preparePublic}}
  279. */
  280. public function preparePublic() {
  281. $params = $this->request->param();
  282. $isMessage = $params["isMessage"] ?: 2;
  283. $ids = $params["ids"];
  284. $publicBatch = $params["batch"];
  285. if (!$publicBatch || strlen($publicBatch) != 6 || !is_numeric($publicBatch))
  286. return json(["msg" => "公示批次错误"]);
  287. $ids = array_filter(explode(",", $ids));
  288. $msg = "已公示";
  289. $state = TalentState::ANNOUNCED; //公示
  290. $total = count($ids);
  291. $error = 0;
  292. $success = 0;
  293. foreach ($ids as $id) {
  294. $talent_info = VerifyApi::getOne($id);
  295. if ($talent_info["checkState"] != TalentState::ZX_PASS) {
  296. $error++;
  297. continue;
  298. }
  299. if (VerifyApi::setPublic($id, $state, $msg, $publicBatch)) {
  300. $success++;
  301. } else {
  302. $error++;
  303. }
  304. }
  305. return json(["code" => 200, "msg" => sprintf("公示完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  306. }
  307. /**
  308. * 预备人才库-公示再审核
  309. * @auth {{/talentInfo/prepareCheck}}
  310. */
  311. public function prepareCheck() {
  312. $params = $this->request->param();
  313. $id = $params["id"];
  314. $checkState = $params["checkState"];
  315. $msg = $params["checkMsg"];
  316. if (!$msg)
  317. return json(["msg" => "请填写审核意见"]);
  318. if ($checkState == 1) {
  319. $msg = "公示再审核通过:" . $msg;
  320. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  321. } else {
  322. $msg = "公示再审核不通过:" . $msg;
  323. $state = TalentState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
  324. }
  325. $talent_info = VerifyApi::getOne($id);
  326. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  327. return json(["msg" => "当前记录不是公示状态,无法审核"]);
  328. }
  329. if (VerifyApi::setPublic($id, $state, $msg)) {
  330. return json(["code" => 200, "msg" => "公示再审核完成"]);
  331. }
  332. return json(["msg" => "公示再审核失败"]);
  333. }
  334. /**
  335. * 预备人才库-公示通过(批量)
  336. * @auth {{/talentInfo/publicPass}}
  337. */
  338. public function publicPass() {
  339. $params = $this->request->param();
  340. $ids = $params["ids"];
  341. $ids = array_filter(explode(",", $ids));
  342. $msg = "公示再审核批量通过";
  343. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  344. $total = count($ids);
  345. $error = 0;
  346. $success = 0;
  347. foreach ($ids as $id) {
  348. $talent_info = VerifyApi::getOne($id);
  349. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  350. $error++;
  351. continue;
  352. }
  353. if (VerifyApi::setPublic($id, $state, $msg)) {
  354. $success++;
  355. } else {
  356. $error++;
  357. }
  358. }
  359. return json(["code" => 200, "msg" => sprintf("公示再审核完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  360. }
  361. /**
  362. * 预备人才库-公布预览
  363. * @auth {{/talentInfo/publishExportBefore}}
  364. */
  365. public function publishExportBefore() {
  366. $params = $this->request->param();
  367. $ids = $params["ids"];
  368. $ids = array_filter(explode(",", $ids));
  369. if ($ids) {
  370. $where[] = ["id", "in", $ids];
  371. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  372. $rows = [];
  373. $i = 1;
  374. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  375. foreach ($list as $item) {
  376. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  377. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  378. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  379. $row = [
  380. $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"]
  381. ];
  382. $rows[] = $row;
  383. $i++;
  384. }
  385. }
  386. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  387. $filename = "优秀人才" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  388. if ($rows) {
  389. export($columns, $rows, $filename);
  390. exit();
  391. }
  392. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  393. }
  394. /**
  395. * 预备人才库-公布导出
  396. * @auth {{/talentInfo/publishExport}}
  397. */
  398. public function publishExport() {
  399. $params = $this->request->param();
  400. $startTime = $params["startTime"];
  401. $endTime = $params["endTime"];
  402. if (!strtotime($startTime) || !strtotime($endTime))
  403. return json(["msg" => "时间格式错误"]);
  404. $where[] = ["checkState", "=", TalentState::PUBLISH_PASS];
  405. $where[] = ["certificateGetTime", "between", [$startTime, $endTime]];
  406. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  407. $rows = [];
  408. $i = 1;
  409. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  410. foreach ($list as $item) {
  411. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  412. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  413. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  414. $row = [
  415. $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"]
  416. ];
  417. $rows[] = $row;
  418. $i++;
  419. }
  420. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  421. $filename = "优秀人才" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  422. if ($rows) {
  423. export($columns, $rows, $filename);
  424. exit();
  425. }
  426. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  427. }
  428. /**
  429. * 预备人才库-公布
  430. * @auth {{/talentInfo/publish}}
  431. */
  432. public function publish() {
  433. $params = $this->request->param();
  434. $id = $params["id"];
  435. $msg = $params["checkMsg"];
  436. $checkState = $params["checkState"];
  437. $batch = $params["batch"];
  438. if ($checkState == 1) {
  439. $state = TalentState::PUBLISH_PASS;
  440. $msg = "公布审核通过:" . $msg;
  441. } else {
  442. $state = TalentState::PUBLISH_FAIL;
  443. $msg = "公布审核不通过:" . $msg;
  444. }
  445. if (!$batch || !strtotime($batch))
  446. return json(["msg" => "公布批次时间错误"]);
  447. if (!$msg)
  448. return json(["msg" => "请填写审核意见"]);
  449. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  450. $batch = $params["batch"];
  451. if (!strtotime($batch))
  452. return json(["msg" => "公布批次时间错误"]);
  453. $talent_info = VerifyApi::getOne($id);
  454. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  455. return json(["msg" => "当前记录不是公示再审核通过状态,无法审核"]);
  456. }
  457. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  458. return json(["code" => 200, "msg" => "公布审核完成"]);
  459. }
  460. return json(["msg" => "公布审核失败"]);
  461. }
  462. /**
  463. * 预备人才库-批量公布通过
  464. * @auth {{/talentInfo/preparePublish}}
  465. */
  466. public function preparePublish() {
  467. $params = $this->request->param();
  468. $ids = $params["ids"];
  469. $ids = array_filter(explode(",", $ids));
  470. $msg = "批量公布";
  471. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  472. $batch = $params["batch"];
  473. if (!strtotime($batch))
  474. return json(["msg" => "公布批次时间错误"]);
  475. $total = count($ids);
  476. $error = 0;
  477. $success = 0;
  478. foreach ($ids as $id) {
  479. $talent_info = VerifyApi::getOne($id);
  480. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  481. $error++;
  482. continue;
  483. }
  484. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  485. $success++;
  486. } else {
  487. $error++;
  488. }
  489. }
  490. return json(["code" => 200, "msg" => sprintf("公布完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  491. }
  492. /**
  493. * 预备人才库-批量发证
  494. * @auth {{/talentInfo/prepareCertification}}
  495. */
  496. public function prepareCertification() {
  497. $lockFile = fopen("send_certificate.lock", "a");
  498. if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
  499. //查询所有待发证的数据
  500. $params = $this->request->param();
  501. $ids = array_filter(explode(",", $params["ids"]));
  502. //晋江市优秀人才证书:当前年份+层次+四位递增数字
  503. //集成电路优秀人才证书:IC+当前年份+递增四位数,如IC20190001
  504. Db::startTrans();
  505. $talent_max_no = [];
  506. $user = session("user");
  507. try {
  508. $talent_list = VerifyApi::getListByIds($ids);
  509. $year = date("Y");
  510. foreach ($talent_list as $talent_info) {
  511. if ($talent_info["checkState"] != TalentState::PUBLISH_PASS) {
  512. Db::rollback();
  513. return json(["msg" => "只能对公布通过的对象进行发证,请核查待发证名单后再重新发证"]);
  514. }
  515. $no_prefix = $year . $talent_info["talent_arrange"];
  516. $where[] = ["certificateNo", "like", $no_prefix . "%"];
  517. $max_no = $talent_max_no[$talent_info["talent_arrange"]] ?: Db::table("new_talent_info")->where($where)->max("certificateNo");
  518. if (!$max_no) {
  519. $max_no = $no_prefix . "0001";
  520. } else {
  521. $new_no = intval(substr($max_no, 5)) + 1;
  522. $max_no = $no_prefix . str_pad($new_no, 4, "0", STR_PAD_LEFT);
  523. }
  524. //更新证书编号
  525. $data["id"] = $talent_info["id"];
  526. $data["certificateNo"] = $max_no;
  527. $data["checkState"] = TalentState::CERTIFICATED;
  528. $data["isPublic"] = 5;
  529. Db::table("new_talent_info")->update($data);
  530. //写入日志
  531. $log["last_state"] = TalentState::PUBLISH_PASS;
  532. $log["id"] = getStringId();
  533. $log["state"] = $log["new_state"] = TalentState::CERTIFICATED;
  534. $log["type"] = 1;
  535. $log["mainId"] = $talent_info["id"];
  536. $log["companyId"] = $user["companyId"];
  537. $log["active"] = 1;
  538. $log["description"] = "人才编号为:" . $max_no;
  539. $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);
  540. $log["createTime"] = date("Y-m-d H:i:s");
  541. Db::table("new_talent_checklog")->insert($log);
  542. $talent_max_no[$talent_info["talent_arrange"]] = $max_no;
  543. }
  544. Db::commit();
  545. return json(["code" => 200, "msg" => "发证成功"]);
  546. } catch (\Exception $e) {
  547. Db::rollback();
  548. return json(["msg" => "发证失败:" . $e->getMessage()]);
  549. }
  550. flock($lockFile, LOCK_UN);
  551. } else {
  552. return json(["msg" => "同一时间只能有一个管理员进行发证操作"]);
  553. }
  554. }
  555. /**
  556. * 预备人才库-撤销公布
  557. * @auth {{/talentInfo/prepareCanclePublish}}
  558. */
  559. public function pre_cancel_publish() {
  560. }
  561. /**
  562. * 基本条件审核-提交未保存
  563. * @param \think\Request $request
  564. * @param type $talent_info
  565. * @return type json
  566. */
  567. private function baseCheck(\think\Request $request, $talent_info) {
  568. $params = $request->param();
  569. if ($params["checkState"] == 3) {
  570. //审核成功
  571. $log_checkState = $checkState = TalentState::BASE_VERIFY_PASS; //初审成功
  572. } else {
  573. //审核驳回并记录需要修改的字段和上传文件
  574. $checkState = TalentState::FST_SAVE; //退回提交材料阶段
  575. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  576. }
  577. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  578. if (!$log)
  579. return json(["msg" => "日志数据异常,保存失败"]);
  580. if ($log["active"] == 0) {
  581. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  582. } else {
  583. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  584. }
  585. $data["id"] = $talent_info["id"];
  586. $data["modify_files"] = $params["files"];
  587. $data["modify_fields"] = $params["fields"];
  588. TalentModel::update($data);
  589. return json(["code" => 200, "msg" => "保存成功"]);
  590. }
  591. /**
  592. * 基本条件审核-提交审核
  593. * @param type $talent_info
  594. * @return type json
  595. */
  596. private function baseSubmitCheck($talent_info) {
  597. return $this->commonSubmitCheck($talent_info, 1);
  598. }
  599. /**
  600. * 初审-提交未保存
  601. * @param \think\Request $request
  602. * @param type $talent_info
  603. * @return type json
  604. */
  605. private function fstCheck(\think\Request $request, $talent_info) {
  606. $params = $request->param();
  607. if ($params["checkState"] == 3) {
  608. //审核成功,并取消设置越过部门并审
  609. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  610. $data["pass_dept_check"] = 0;
  611. } else if ($params["checkState"] == 4) {
  612. if ($talent_info["highProcess"] < 3)
  613. return json(["msg" => "只有曾经通过部门并审,初审时才可以选择直接跳过部门并审阶段"]);
  614. //审核成功,并设置越过部门并审。附加条件:最高进度曾经通过部门并审3(包含部门并审)
  615. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  616. $data["pass_dept_check"] = $talent_info["highProcess"] >= 3 ? 1 : 0;
  617. } else {
  618. //审核驳回并记录需要修改的字段和上传文件
  619. $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
  620. $log_checkState = TalentState::FST_VERIFY_REJECT; //日志记录拒绝状态
  621. }
  622. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  623. if (!$log)
  624. return json(["msg" => "日志数据异常,保存失败"]);
  625. if ($log["active"] == 0) {
  626. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  627. } else {
  628. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  629. }
  630. $data["id"] = $talent_info["id"];
  631. $data["modify_files"] = $params["files"];
  632. $data["modify_fields"] = $params["fields"];
  633. TalentModel::update($data);
  634. return json(["code" => 200, "msg" => "保存成功"]);
  635. }
  636. /**
  637. * 初审-提交审核
  638. * @param type $talent_info
  639. * @return type json
  640. */
  641. private function fstSubmitCheck($talent_info) {
  642. $nowProcess = 2;
  643. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  644. if (!$log || $log["active"] == 1)
  645. return json(["msg" => "请先保存审核状态,再提交审核"]);
  646. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  647. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  648. }
  649. if ($log["new_state"] == TalentState::FST_VERIFY_PASS && $talent_info["pass_dept_check"] == 0) {
  650. $data["first_dept_check_time"] = date("Y-m-d H:i:s");
  651. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  652. $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
  653. //这边去除已经审核通过的单位,主要通过日志是否存在记录。
  654. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  655. $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
  656. sort($unpass_companyIds);
  657. TalentLogApi::writeDeptLogs($talent_info["id"], $unpass_companyIds, TalentState::FST_VERIFY_PASS);
  658. }
  659. $data["id"] = $talent_info["id"];
  660. $data["checkState"] = $log["new_state"];
  661. TalentModel::update($data);
  662. TalentLogApi::setActive($log["id"], 1);
  663. return json(["code" => 200, "msg" => "审核成功"]);
  664. }
  665. /**
  666. * 部门审核-提交未保存
  667. * @param \think\Request $request
  668. * @param type $talent_info
  669. * @return type json
  670. */
  671. private function deptCheck(\think\Request $request, $talent_info, $companys) {
  672. if ($talent_info["pass_dept_check"] == 1)
  673. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  674. if (!in_array($this->user["companyId"], $companys))
  675. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  676. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  677. if (in_array($this->user["companyId"], $pass_companyIds))
  678. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  679. $params = $request->param();
  680. if ($params["checkState"] == 3) {
  681. //审核成功
  682. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  683. $checkState = TalentState::DEPT_VERIFY_PASS; //审核成功
  684. } else {
  685. //审核驳回并记录需要修改的字段和上传文件
  686. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  687. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  688. $data["modify_files"] = $params["files"];
  689. $data["modify_fields"] = $params["fields"];
  690. }
  691. $fst_dept_check_time = $talent_info["first_dept_check_time"];
  692. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $fst_dept_check_time);
  693. if (!$dept_log)
  694. return json(["msg" => "未匹配日志,审核失败"]);
  695. if ($dept_log["active"] == 1)
  696. return json(["msg" => "您的部门已经审核过了"]);
  697. $data["id"] = $talent_info["id"];
  698. TalentModel::update($data);
  699. //修改日志
  700. TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  701. return json(["code" => 200, "msg" => "保存成功"]);
  702. }
  703. /**
  704. * 部门审核-提交审核
  705. * @param type $talent_info
  706. * @return type json
  707. */
  708. private function deptSubmitCheck($talent_info, $companys) {
  709. if ($talent_info["pass_dept_check"] == 1)
  710. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  711. if (!in_array($this->user["companyId"], $companys))
  712. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  713. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  714. if (in_array($this->user["companyId"], $pass_companyIds))
  715. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  716. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $talent_info["first_dept_check_time"]);
  717. $over = $pass_companyIds ? count($pass_companyIds) : 0; //完成度,如果重审之前已有通过审核的部门,不用再审,直接按通过算
  718. $error = 0; //失败数
  719. $nowProcess = 3;
  720. if (!$dept_log)
  721. return json(["msg" => "未匹配日志,审核失败"]);
  722. if ($dept_log["state"] == $dept_log["new_state"])
  723. return json(["msg" => "请先保存审核状态,再提交审核"]);
  724. if ($dept_log["active"] == 1)
  725. return json(["msg" => "您的部门已经审核过了"]);
  726. $over++;
  727. if ($dept_log["new_state"] == TalentState::SCND_SUBMIT) {
  728. $error++;
  729. }
  730. $logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
  731. for ($i = 0; $i < count($logs); $i++) {
  732. if (!in_array($logs[$i]["companyId"], $pass_companyIds)) {
  733. $over += $logs[$i]["active"] == 1 ? 1 : 0;
  734. if ($logs[$i]["new_state"] == TalentState::SCND_SUBMIT) {
  735. $error++;
  736. }
  737. }
  738. }
  739. if ($over == count($companys)) {
  740. //全部已审核
  741. $checkState = TalentState::SCND_SUBMIT;
  742. $log_checkState = TalentState::DEPT_VERIFY_REJECT;
  743. if ($error == 0) {
  744. $log_checkState = $checkState = TalentState::DEPT_VERIFY_PASS;
  745. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  746. }
  747. $data["id"] = $talent_info["id"];
  748. $data["checkState"] = $checkState;
  749. $data["first_dept_check_time"] = null;
  750. TalentModel::update($data);
  751. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "部门审核结束", 1);
  752. }
  753. TalentLogApi::setActive($dept_log["id"], 1);
  754. return json(["code" => 200, "msg" => "审核成功"]);
  755. }
  756. /**
  757. * 复审-提交未保存
  758. * @param \think\Request $request
  759. * @param type $talent_info
  760. * @param type json
  761. */
  762. private function reCheck(\think\Request $request, $talent_info) {
  763. $params = $request->param();
  764. if ($params["checkState"] == 3) {
  765. //审核成功
  766. $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
  767. } else if ($params["checkState"] == 2) {
  768. //审核驳回并记录需要修改的字段和上传文件
  769. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  770. $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
  771. } else {
  772. $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
  773. }
  774. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  775. if (!$log)
  776. return json(["msg" => "日志数据异常,保存失败"]);
  777. if ($log["active"] == 0) {
  778. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  779. } else {
  780. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  781. }
  782. $data["id"] = $talent_info["id"];
  783. $data["modify_files"] = $params["files"];
  784. $data["modify_fields"] = $params["fields"];
  785. TalentModel::update($data);
  786. return json(["code" => 200, "msg" => "保存成功"]);
  787. }
  788. /**
  789. * 复审-提交审核
  790. * @param type $talent_info
  791. * @return type json
  792. */
  793. private function reSubmitCheck($talent_info) {
  794. return $this->commonSubmitCheck($talent_info, 4);
  795. }
  796. private function commonSubmitCheck($talent_info, $nowProcess) {
  797. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  798. if (!$log || $log["active"] == 1)
  799. return json(["msg" => "请先保存审核状态,再提交审核"]);
  800. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  801. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  802. }
  803. $data["id"] = $talent_info["id"];
  804. $data["checkState"] = $log["new_state"];
  805. TalentModel::update($data);
  806. TalentLogApi::setActive($log["id"], 1);
  807. return json(["code" => 200, "msg" => "审核成功"]);
  808. }
  809. public function check() {
  810. //公共调度方法
  811. $request = $this->request;
  812. $params = $request->param();
  813. $check = $params["checkState"];
  814. $check_msg = trim($params["checkMsg"]);
  815. $files = $params["files"];
  816. $fields = $params["fields"];
  817. $id = $params["id"];
  818. $talent_info = VerifyApi::getOne($id);
  819. $checkState = $talent_info["checkState"];
  820. if (!$talent_info) {
  821. return json(["msg" => "数据错误"]);
  822. }
  823. if (!$check) {
  824. return json(["msg" => "请选择审核状态"]);
  825. }
  826. if (!$check_msg) {
  827. return json(["msg" => "请填写审核说明"]);
  828. }
  829. if ($checkState == TalentState::FST_SUBMIT) {
  830. return $this->baseCheck($request, $talent_info);
  831. } else if ($checkState == TalentState::SCND_SUBMIT) {
  832. return $this->fstCheck($request, $talent_info);
  833. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  834. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  835. $companys = array_filter(explode(",", $condition["companyIds"]));
  836. if ($companys && $talent_info["pass_dept_check"] != 1) {
  837. if (!in_array($this->user["companyId"], $companys))
  838. return json(["msg" => "你的部门不在并审部门列表"]);
  839. return $this->deptCheck($request, $talent_info, $companys);
  840. } else {
  841. return $this->reCheck($request, $talent_info);
  842. }
  843. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  844. return $this->reCheck($request, $talent_info);
  845. } else {
  846. return json(["msg" => "不在审核范围内,保存失败"]);
  847. }
  848. }
  849. public function submitCheck() {
  850. //公共调度方法
  851. $id = $this->request->param("id");
  852. $talent_info = VerifyApi::getOne($id);
  853. $checkState = $talent_info["checkState"];
  854. if (!$talent_info) {
  855. return json(["msg" => "数据错误"]);
  856. }
  857. if ($checkState == TalentState::FST_SUBMIT) {
  858. return $this->baseSubmitCheck($talent_info);
  859. } else if ($checkState == TalentState::SCND_SUBMIT) {
  860. return $this->fstSubmitCheck($talent_info);
  861. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  862. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  863. $companys = array_filter(explode(",", $condition["companyIds"]));
  864. if ($companys && $talent_info["pass_dept_check"] != 1) {
  865. if (!in_array($this->user["companyId"], $companys))
  866. return json(["msg" => "你的部门不在并审部门列表"]);
  867. return $this->deptSubmitCheck($talent_info, $companys);
  868. } else {
  869. return $this->reSubmitCheck($talent_info);
  870. }
  871. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  872. return $this->reSubmitCheck($talent_info);
  873. } else {
  874. return json(["msg" => "不在审核范围内,审核失败"]);
  875. }
  876. }
  877. public function validateIsCheck() {
  878. $params = $this->request->param();
  879. $id = $params["id"];
  880. $talent_info = VerifyApi::getOne($id);
  881. if ($talent_info) {
  882. $checkState = $talent_info["checkState"];
  883. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
  884. $process = 0;
  885. if (in_array($checkState, [2, 6, 7, 9])) {
  886. switch ($checkState) {
  887. case 2:
  888. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  889. $fields = DictApi::getTalentFields(1);
  890. $field_tmp = [];
  891. foreach ($fields as $key => $field) {
  892. $field_tmp[] = ["key" => $key, "value" => $field];
  893. }
  894. $where[] = ["project", "=", 1];
  895. $where[] = ["step", "=", 1];
  896. $where[] = ["active", "=", 1];
  897. $where[] = ["type", "=", $enterprise["type"]];
  898. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  899. $process = 1;
  900. break;
  901. case 6:
  902. $process = 2;
  903. break;
  904. case 7:
  905. $tc = TalentConditionApi::getOne($talent_info["talent_condition"]);
  906. if ($tc["companyIds"] && $talent_info["pass_dept_check"] != 1) {
  907. $process = 3;
  908. } else {
  909. $process = 4;
  910. }
  911. $fields = DictApi::getTalentFields(3);
  912. break;
  913. case 9:
  914. $fields = DictApi::getTalentFields(3);
  915. $process = 4;
  916. break;
  917. }
  918. if ($checkState != 2) {
  919. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  920. $fields = DictApi::getTalentFields(2);
  921. $field_tmp = [];
  922. foreach ($fields as $key => $field) {
  923. $field_tmp[] = ["key" => $key, "value" => $field];
  924. }
  925. $where = [];
  926. $whr = [];
  927. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  928. $where[] = ["project", "=", 1];
  929. $where[] = ["step", "=", 2];
  930. $where[] = ["active", "=", 1];
  931. $where[] = ["type", "=", $enterprise["type"]];
  932. $where[] = ["isConditionFile", "<>", 1];
  933. if ($condition && $condition["bindFileTypes"]) {
  934. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  935. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->select();
  936. } else {
  937. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  938. }
  939. }
  940. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  941. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  942. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files]]);
  943. } else {
  944. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  945. }
  946. }
  947. }
  948. public function findFieldsAndFiles() {
  949. }
  950. public function commonExport() {
  951. $params = $this->request->param();
  952. $fields = $params["export"];
  953. if (!$fields)
  954. return json(["msg" => "请选择要导出的数据"]);
  955. $names = DictApi::getTalentFields(3);
  956. $names["industryFieldNew"] = "产业领域";
  957. $names["enterpriseName"] = "单位名称";
  958. $names["enterpriseTag"] = "单位标签";
  959. $names["street"] = "所属镇街";
  960. $names["checkState"] = "审核状态";
  961. $list = VerifyApi::getExportDatas($fields);
  962. foreach ($fields as $field) {
  963. $columns[] = $names[$field];
  964. }
  965. $datas = [];
  966. for ($i = 0; $i < count($list); $i++) {
  967. $data = [];
  968. for ($n = 0; $n < count($fields); $n++) {
  969. $data[] = $list[$i][$fields[$n]];
  970. }
  971. $datas[] = $data;
  972. }
  973. if ($datas) {
  974. export($columns, $datas);
  975. exit();
  976. }
  977. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  978. }
  979. public function getPhones() {
  980. $list = VerifyApi::getListByProcess($this->request->param("process"));
  981. $result = [];
  982. if ($list) {
  983. foreach ($list as $item) {
  984. if ($item["phone"] && $item["name"]) {
  985. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  986. }
  987. }
  988. }
  989. return json(["code" => 200, "obj" => implode(";", $result)]);
  990. }
  991. public function getEnterprisePhones() {
  992. $list = VerifyApi::getListByProcess($this->request->param("process"));
  993. $result = [];
  994. if ($list) {
  995. foreach ($list as $item) {
  996. if ($item["agentName"] && $item["agentPhone"]) {
  997. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  998. }
  999. }
  1000. }
  1001. return json(["code" => 200, "obj" => implode(";", $result)]);
  1002. }
  1003. }