Talent.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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. /**
  10. * Description of Talent
  11. *
  12. * @author sgq
  13. */
  14. class Talent extends AdminController {
  15. public function common_check() {
  16. $request = $this->request;
  17. $params = $request->param();
  18. $id = $params["id"];
  19. $info = VerifyApi::getTalentInfoById($id);
  20. if ($info["checkState"] == 3) {
  21. return view("talentInfo_base_check", ["info" => $info]);
  22. } else {
  23. return view("talentInfo_common_check", ["info" => $info]);
  24. }
  25. }
  26. public function cancel_verify() {
  27. $params = $this->request->param();
  28. $ids = $params["ids"];
  29. $msg = $params["msg"];
  30. if ($msg == "") {
  31. return json(["msg" => "请填写审核不通过的原因"]);
  32. }
  33. $ids_arr = array_filter(explode(",", $ids));
  34. $counts = 0;
  35. foreach ($ids_arr as $id) {
  36. $ti = VerifyApi::getOne($id);
  37. $data["id"] = $id;
  38. if ($ti["checkState"] == TalentState::FST_SUBMIT) {
  39. $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
  40. TalentLogApi::write(1, $id, [TalentState::BASE_VERIFY_FAIL], $msg, 1);
  41. TalentModel::update($data);
  42. $counts++;
  43. } else if ($ti["checkState"] == TalentState::SCND_SAVE) {
  44. $data["checkState"] = TalentState::FST_VERIFY_FAIL;
  45. TalentLogApi::write(1, $id, [TalentState::FST_VERIFY_FAIL], $msg, 1);
  46. TalentModel::update($data);
  47. $counts++;
  48. } else {
  49. //return json(["msg" => "不在审核范围"]);
  50. }
  51. }
  52. return json(["code" => 200, sprintf("%d个申请已审核失败", $counts)]);
  53. }
  54. public function base_verify() {
  55. return view();
  56. }
  57. public function base_verify_list() {
  58. $request = $this->request;
  59. return json(VerifyApi::getList($request));
  60. }
  61. /**
  62. * 部门初审
  63. * @auth {{/talentInfo/gotoIndex/-1}}
  64. */
  65. public function dept_fst_verify() {
  66. return view();
  67. }
  68. /**
  69. * 初审
  70. * @auth {{/talentInfo/gotoIndex/1}}
  71. */
  72. public function fst_verify() {
  73. return view();
  74. }
  75. /**
  76. * 初审-审核
  77. * @auth {{/talentInfo/firstCheck}}
  78. */
  79. public function fst_check() {
  80. }
  81. /**
  82. * 初审-修改驳回字段
  83. * @auth {{/talentInfo/updateFieldsAndFiles}}
  84. */
  85. public function updateFieldsAndFiles() {
  86. }
  87. /**
  88. * 初审-审核不通过
  89. * @auth {{/talentInfo/setNotPass}}
  90. */
  91. public function dis_pass() {
  92. }
  93. /**
  94. * 部门审核
  95. * @auth {{/talentInfo/gotoIndex/2}}
  96. */
  97. public function dept_verify() {
  98. return view();
  99. }
  100. /**
  101. * 复审
  102. * @auth {{/talentInfo/gotoIndex/3}}
  103. */
  104. public function re_verify() {
  105. return view();
  106. }
  107. /**
  108. * 复审-撤销复核
  109. * @auth {{/talentInfo/cancleThirdCheck}}
  110. */
  111. public function cancel_check() {
  112. }
  113. /**
  114. * 预备人才库
  115. * @auth {{/talentInfo/gotoIndex/4}}
  116. */
  117. public function pre_list() {
  118. $this->common_verify(4);
  119. }
  120. /**
  121. * 预备人才库-公示
  122. * @auth {{/talentInfo/preparePublic}}
  123. */
  124. public function pre_public() {
  125. }
  126. /**
  127. * 预备人才库-核查征信
  128. * @auth {{/talentInfo/prepareHczx}}
  129. */
  130. public function pre_hczx() {
  131. }
  132. /**
  133. * 预备人才库-征信通过
  134. * @auth {{/talentInfo/hczxPass}}
  135. */
  136. public function pre_zx_pass() {
  137. }
  138. /**
  139. * 预备人才库-征信失信
  140. * @auth {{/talentInfo/hczxReject}}
  141. */
  142. public function pre_zx_reject() {
  143. }
  144. /**
  145. * 预备人才库-公示再审核
  146. * @auth {{/talentInfo/prepareCheck}}
  147. */
  148. public function pre_check() {
  149. }
  150. /**
  151. * 预备人才库-公示通过
  152. * @auth {{/talentInfo/publicPass}}
  153. */
  154. public function pre_public_pass() {
  155. }
  156. /**
  157. * 预备人才库-公布
  158. * @auth {{/talentInfo/preparePublish}}
  159. */
  160. public function pre_publish() {
  161. }
  162. /**
  163. * 预备人才库-发证
  164. * @auth {{/talentInfo/prepareCertification}}
  165. */
  166. public function pre_certification() {
  167. }
  168. /**
  169. * 预备人才库-撤销公布
  170. * @auth {{/talentInfo/prepareCanclePublish}}
  171. */
  172. public function pre_cancel_publish() {
  173. }
  174. /**
  175. * 预备人才库-公示预览
  176. * @auth {{/talentInfo/publicExportBefore}}
  177. */
  178. public function pre_public_preview() {
  179. }
  180. /**
  181. * 预备人才库-公布预览
  182. * @auth {{/talentInfo/publishExportBefore}}
  183. */
  184. public function pre_publish_preview() {
  185. }
  186. /**
  187. * 基本条件审核-提交未保存
  188. * @param \think\Request $request
  189. * @param type $talent_info
  190. * @return type json
  191. */
  192. private function baseCheck(\think\Request $request, $talent_info) {
  193. $params = $request->param();
  194. if ($params["checkState"] == 3) {
  195. //审核成功
  196. $log_checkState = $checkState = TalentState::BASE_VERIFY_PASS; //初审成功
  197. } else {
  198. //审核驳回并记录需要修改的字段和上传文件
  199. $checkState = TalentState::FST_SAVE; //退回提交材料阶段
  200. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  201. }
  202. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  203. if (!$log)
  204. return json(["msg" => "日志数据异常,保存失败"]);
  205. if ($log["active"] == 0) {
  206. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  207. } else {
  208. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  209. }
  210. $data["id"] = $talent_info["id"];
  211. $data["modify_files"] = $params["files"];
  212. $data["modify_fields"] = $params["fields"];
  213. TalentModel::update($data);
  214. return json(["code" => 200, "msg" => "保存成功"]);
  215. }
  216. /**
  217. * 基本条件审核-提交审核
  218. * @param type $talent_info
  219. * @return type json
  220. */
  221. private function baseSubmitCheck($talent_info) {
  222. return $this->commonSubmitCheck($talent_info, 1);
  223. }
  224. /**
  225. * 初审-提交未保存
  226. * @param \think\Request $request
  227. * @param type $talent_info
  228. * @return type json
  229. */
  230. private function fstCheck(\think\Request $request, $talent_info) {
  231. $params = $request->param();
  232. if ($params["checkState"] == 3) {
  233. //审核成功
  234. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  235. } else {
  236. //审核驳回并记录需要修改的字段和上传文件
  237. $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
  238. $log_checkState = TalentState::FST_VERIFY_REJECT; //日志记录拒绝状态
  239. }
  240. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  241. if (!$log)
  242. return json(["msg" => "日志数据异常,保存失败"]);
  243. if ($log["active"] == 0) {
  244. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  245. } else {
  246. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  247. }
  248. $data["id"] = $talent_info["id"];
  249. $data["modify_files"] = $params["files"];
  250. $data["modify_fields"] = $params["fields"];
  251. TalentModel::update($data);
  252. return json(["code" => 200, "msg" => "保存成功"]);
  253. }
  254. /**
  255. * 初审-提交审核
  256. * @param type $talent_info
  257. * @return type json
  258. */
  259. private function fstSubmitCheck($talent_info) {
  260. return $this->commonSubmitCheck($talent_info, 2);
  261. }
  262. /**
  263. * 部门审核-提交未保存
  264. * @param \think\Request $request
  265. * @param type $talent_info
  266. * @return type json
  267. */
  268. private function deptCheck(\think\Request $request, $talent_info, $companys) {
  269. $params = $request->param();
  270. if ($params["checkState"] == 3) {
  271. //审核成功
  272. $log_checkState = $checkState = TalentState::DEPT_VERIFY_PASS; //初审成功
  273. } else {
  274. //审核驳回并记录需要修改的字段和上传文件
  275. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  276. $log_checkState = TalentState::DEPT_VERIFY_REJECT; //日志记录拒绝状态
  277. }
  278. $fst_dept_check_time = $talent_info["first_dept_check_time"];
  279. if (!$fst_dept_check_time) {
  280. //第一次部门审核
  281. $data["first_dept_check_time"] = date("Y-m-d H:i:s");
  282. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  283. } else {
  284. $dept_logs = TalentLogApi::getListLogByTime($talent_info["id"], $fst_dept_check_time);
  285. $tmp_log = null;
  286. foreach ($dept_logs as $dept_log) {
  287. if ($dept_log["companyId"] == $this->user["companyId"]) {
  288. //检察在第一次部门审核后产生的日志记录中是否存在当前部门记录,有就修改,没有就新增
  289. $tmp_log = $dept_log;
  290. break;
  291. }
  292. }
  293. if ($tmp_log) {
  294. //修改
  295. TalentLogApi::rewrite($tmp_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  296. } else {
  297. //新增
  298. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  299. }
  300. }
  301. $data["id"] = $talent_info["id"];
  302. $data["modify_files"] = $params["files"];
  303. $data["modify_fields"] = $params["fields"];
  304. TalentModel::update($data);
  305. return json(["code" => 200, "msg" => "保存成功"]);
  306. }
  307. /**
  308. * 部门审核-提交审核
  309. * @param type $talent_info
  310. * @return type json
  311. */
  312. private function deptSubmitCheck($talent_info, $companys) {
  313. $dept_logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
  314. $tmp_log = null;
  315. $succeed = 0;
  316. foreach ($dept_logs as $dept_log) {
  317. $succeed += $dept_log["active"] == 1 ? 1 : 0;
  318. if ($dept_log["companyId"] == $this->user["companyId"]) {
  319. $tmp_log = $dept_log;
  320. }
  321. }
  322. if (!$tmp_log || $tmp_log["active"] == 1)
  323. return json(["msg" => "日志数据异常,审核失败"]);
  324. $refused = false;
  325. if ($dept_log["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  326. $succeed++;
  327. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  328. } else {
  329. //有一个审核失败就结束
  330. $refused = true;
  331. }
  332. if ($refused || ($succeed == count($companys))) {
  333. $nowProcess = 1;
  334. $data["id"] = $talent_info["id"];
  335. $data["checkState"] = $dept_log["new_state"];
  336. $data["first_dept_check_time"] = null;
  337. TalentModel::update($data);
  338. }
  339. TalentLogApi::setActive($tmp_log["id"], 1);
  340. return json(["code" => 200, "msg" => "审核成功"]);
  341. }
  342. /**
  343. * 复审-提交未保存
  344. * @param \think\Request $request
  345. * @param type $talent_info
  346. * @param type json
  347. */
  348. private function reCheck(\think\Request $request, $talent_info) {
  349. $params = $request->param();
  350. if ($params["checkState"] == 3) {
  351. //审核成功
  352. $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
  353. } else if ($params["checkState"] == 2) {
  354. //审核驳回并记录需要修改的字段和上传文件
  355. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  356. $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
  357. } else {
  358. $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
  359. }
  360. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  361. if (!$log)
  362. return json(["msg" => "日志数据异常,保存失败"]);
  363. if ($log["active"] == 0) {
  364. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  365. } else {
  366. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  367. }
  368. $data["id"] = $talent_info["id"];
  369. $data["modify_files"] = $params["files"];
  370. $data["modify_fields"] = $params["fields"];
  371. TalentModel::update($data);
  372. return json(["code" => 200, "msg" => "保存成功"]);
  373. }
  374. /**
  375. * 复审-提交审核
  376. * @param type $talent_info
  377. * @return type json
  378. */
  379. private function reSubmitCheck($talent_info) {
  380. return $this->commonSubmitCheck($talent_info, 4);
  381. }
  382. private function commonSubmitCheck($talent_info, $nowProcess) {
  383. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  384. if (!$log || $log["active"] == 1)
  385. return json(["msg" => "日志数据异常,审核失败"]);
  386. if (in_array($log["checkState"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  387. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  388. }
  389. $data["id"] = $talent_info["id"];
  390. $data["checkState"] = $log["new_state"];
  391. TalentModel::update($data);
  392. TalentLogApi::setActive($log["id"], 1);
  393. return json(["code" => 200, "msg" => "审核成功"]);
  394. }
  395. public function check() {
  396. //公共调度方法
  397. $request = $this->request;
  398. $params = $request->param();
  399. $check = $params["checkState"];
  400. $check_msg = trim($params["checkMsg"]);
  401. $files = $params["files"];
  402. $fields = $params["fields"];
  403. $id = $params["id"];
  404. $talent_info = VerifyApi::getOne($id);
  405. $checkState = $talent_info["checkState"];
  406. if (!$talent_info) {
  407. return json(["msg" => "数据错误"]);
  408. }
  409. if (!$check) {
  410. return json(["msg" => "请选择审核状态"]);
  411. }
  412. if (!$check_msg) {
  413. return json(["msg" => "请填写审核说明"]);
  414. }
  415. if ($checkState == TalentState::FST_SUBMIT) {
  416. return $this->baseCheck($request, $talent_info);
  417. } else if ($checkState == TalentState::SCND_SUBMIT) {
  418. return $this->fstCheck($request, $talent_info);
  419. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  420. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  421. $companys = array_filter(explode(",", $condition["companyIds"]));
  422. if ($companys) {
  423. if (in_array($this->user["companyId"], $companys))
  424. return json(["msg" => "你的部门不在并审部门列表"]);
  425. return $this->deptCheck($request, $talent_info, $companys);
  426. } else {
  427. return $this->reCheck($request, $talent_info);
  428. }
  429. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  430. return $this->reCheck($request, $talent_info);
  431. } else {
  432. return json(["msg" => "不在审核范围内,保存失败"]);
  433. }
  434. }
  435. public function submitCheck() {
  436. //公共调度方法
  437. $id = $this->request->param("id");
  438. $talent_info = VerifyApi::getOne($id);
  439. $checkState = $talent_info["checkState"];
  440. if (!$talent_info) {
  441. return json(["msg" => "数据错误"]);
  442. }
  443. if ($checkState == TalentState::FST_SUBMIT) {
  444. return $this->baseSubmitCheck($talent_info);
  445. } else if ($checkState == TalentState::SCND_SUBMIT) {
  446. return $this->fstSubmitCheck($talent_info);
  447. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  448. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  449. $companys = array_filter(explode(",", $condition["companyIds"]));
  450. if ($companys) {
  451. if (in_array($this->user["companyId"], $companys))
  452. return json(["msg" => "你的部门不在并审部门列表"]);
  453. return $this->deptSubmitCheck($talent_info, $companys);
  454. } else {
  455. return $this->reSubmitCheck($talent_info);
  456. }
  457. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  458. return $this->reSubmitCheck($talent_info);
  459. } else {
  460. return json(["msg" => "不在审核范围内,审核失败"]);
  461. }
  462. }
  463. public function validateIsCheck() {
  464. $params = $this->request->param();
  465. $id = $params["id"];
  466. $talent_info = VerifyApi::getOne($id);
  467. if ($talent_info) {
  468. $checkState = $talent_info["checkState"];
  469. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
  470. $process = 0;
  471. if (in_array($checkState, [2, 6, 7, 9])) {
  472. switch ($checkState) {
  473. case 2:
  474. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  475. $fields = \app\common\api\DictApi::getTalentFields(1);
  476. $field_tmp = [];
  477. foreach ($fields as $key => $field) {
  478. $field_tmp[] = ["key" => $key, "value" => $field];
  479. }
  480. $where[] = ["project", "=", 1];
  481. $where[] = ["step", "=", 1];
  482. $where[] = ["active", "=", 1];
  483. $where[] = ["type", "=", $enterprise["type"]];
  484. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  485. $process = 1;
  486. break;
  487. case 6:
  488. $process = 2;
  489. break;
  490. case 7:
  491. $fields = \app\common\api\DictApi::getTalentFields(3);
  492. $process = 3;
  493. break;
  494. case 9:
  495. $fields = \app\common\api\DictApi::getTalentFields(3);
  496. $process = 4;
  497. break;
  498. }
  499. if ($checkState != 2) {
  500. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  501. $fields = \app\common\api\DictApi::getTalentFields(3);
  502. $field_tmp = [];
  503. foreach ($fields as $key => $field) {
  504. $field_tmp[] = ["key" => $key, "value" => $field];
  505. }
  506. $where[] = ["project", "=", 1];
  507. $where[] = ["active", "=", 1];
  508. $where[] = ["type", "=", $enterprise["type"]];
  509. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  510. }
  511. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files]]);
  512. } else {
  513. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  514. }
  515. }
  516. }
  517. }