Talent.php 21 KB

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