Talent.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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"] == 2) {
  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. return view();
  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. $nowProcess = 2;
  261. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  262. if (!$log || $log["active"] == 1)
  263. return json(["msg" => "日志数据异常,审核失败"]);
  264. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  265. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  266. }
  267. $data["id"] = $talent_info["id"];
  268. $data["checkState"] = $log["new_state"];
  269. $data["first_dept_check_time"] = date("Y-m-d H:i:s");
  270. TalentModel::update($data);
  271. TalentLogApi::setActive($log["id"], 1);
  272. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  273. $companyIds = array_filter(explode(",", $condition["companyIds"]));
  274. TalentLogApi::writeDeptLogs($talent_info["id"], $companyIds, TalentState::FST_VERIFY_PASS);
  275. return json(["code" => 200, "msg" => "审核成功"]);
  276. }
  277. /**
  278. * 部门审核-提交未保存
  279. * @param \think\Request $request
  280. * @param type $talent_info
  281. * @return type json
  282. */
  283. private function deptCheck(\think\Request $request, $talent_info, $companys) {
  284. $params = $request->param();
  285. if ($params["checkState"] == 3) {
  286. //审核成功
  287. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  288. $checkState = TalentState::DEPT_VERIFY_PASS; //审核成功
  289. } else {
  290. //审核驳回并记录需要修改的字段和上传文件
  291. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  292. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  293. }
  294. $fst_dept_check_time = $talent_info["first_dept_check_time"];
  295. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $fst_dept_check_time);
  296. if (!$dept_log)
  297. return json(["msg" => "未匹配日志,审核失败"]);
  298. if ($dept_log["active"] == 1)
  299. return json(["msg" => "您的部门已经审核过了"]);
  300. $data["id"] = $talent_info["id"];
  301. $data["modify_files"] = $params["files"];
  302. $data["modify_fields"] = $params["fields"];
  303. TalentModel::update($data);
  304. //修改日志
  305. TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  306. return json(["code" => 200, "msg" => "保存成功"]);
  307. }
  308. /**
  309. * 部门审核-提交审核
  310. * @param type $talent_info
  311. * @return type json
  312. */
  313. private function deptSubmitCheck($talent_info, $companys) {
  314. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $talent_info["first_dept_check_time"]);
  315. $over = 0; //完成度
  316. $error = 0; //失败数
  317. $nowProcess = 3;
  318. if (!$dept_log)
  319. return json(["msg" => "未匹配日志,审核失败"]);
  320. if ($dept_log["active"] == 1)
  321. return json(["msg" => "您的部门已经审核过了"]);
  322. $over++;
  323. if ($dept_log["new_state"] == TalentState::DEPT_VERIFY_REJECT) {
  324. $error++;
  325. }
  326. $logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
  327. for ($i = 0; $i < count($logs); $i++) {
  328. $over += $logs[$i]["active"] == 1 ? 1 : 0;
  329. if ($logs["new_state"] == TalentState::DEPT_VERIFY_REJECT) {
  330. $error++;
  331. }
  332. }
  333. if ($over == count($companys)) {
  334. //全部已审核
  335. $checkState = TalentState::DEPT_VERIFY_REJECT;
  336. if ($error == 0) {
  337. $checkState = TalentState::DEPT_VERIFY_PASS;
  338. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  339. }
  340. $data["id"] = $talent_info["id"];
  341. $data["checkState"] = $checkState;
  342. $data["first_dept_check_time"] = null;
  343. TalentModel::update($data);
  344. TalentLogApi::write(1, $talent_info["id"], $checkState, "部门审核结束", 1);
  345. }
  346. TalentLogApi::setActive($dept_log["id"], 1);
  347. return json(["code" => 200, "msg" => "审核成功"]);
  348. }
  349. /**
  350. * 复审-提交未保存
  351. * @param \think\Request $request
  352. * @param type $talent_info
  353. * @param type json
  354. */
  355. private function reCheck(\think\Request $request, $talent_info) {
  356. $params = $request->param();
  357. if ($params["checkState"] == 3) {
  358. //审核成功
  359. $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
  360. } else if ($params["checkState"] == 2) {
  361. //审核驳回并记录需要修改的字段和上传文件
  362. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  363. $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
  364. } else {
  365. $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
  366. }
  367. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  368. if (!$log)
  369. return json(["msg" => "日志数据异常,保存失败"]);
  370. if ($log["active"] == 0) {
  371. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  372. } else {
  373. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  374. }
  375. $data["id"] = $talent_info["id"];
  376. $data["modify_files"] = $params["files"];
  377. $data["modify_fields"] = $params["fields"];
  378. TalentModel::update($data);
  379. return json(["code" => 200, "msg" => "保存成功"]);
  380. }
  381. /**
  382. * 复审-提交审核
  383. * @param type $talent_info
  384. * @return type json
  385. */
  386. private function reSubmitCheck($talent_info) {
  387. return $this->commonSubmitCheck($talent_info, 4);
  388. }
  389. private function commonSubmitCheck($talent_info, $nowProcess) {
  390. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  391. if (!$log || $log["active"] == 1)
  392. return json(["msg" => "日志数据异常,审核失败"]);
  393. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  394. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  395. }
  396. $data["id"] = $talent_info["id"];
  397. $data["checkState"] = $log["new_state"];
  398. TalentModel::update($data);
  399. TalentLogApi::setActive($log["id"], 1);
  400. return json(["code" => 200, "msg" => "审核成功"]);
  401. }
  402. public function check() {
  403. //公共调度方法
  404. $request = $this->request;
  405. $params = $request->param();
  406. $check = $params["checkState"];
  407. $check_msg = trim($params["checkMsg"]);
  408. $files = $params["files"];
  409. $fields = $params["fields"];
  410. $id = $params["id"];
  411. $talent_info = VerifyApi::getOne($id);
  412. $checkState = $talent_info["checkState"];
  413. if (!$talent_info) {
  414. return json(["msg" => "数据错误"]);
  415. }
  416. if (!$check) {
  417. return json(["msg" => "请选择审核状态"]);
  418. }
  419. if (!$check_msg) {
  420. return json(["msg" => "请填写审核说明"]);
  421. }
  422. if ($checkState == TalentState::FST_SUBMIT) {
  423. return $this->baseCheck($request, $talent_info);
  424. } else if ($checkState == TalentState::SCND_SUBMIT) {
  425. return $this->fstCheck($request, $talent_info);
  426. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  427. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  428. $companys = array_filter(explode(",", $condition["companyIds"]));
  429. if ($companys) {
  430. if (!in_array($this->user["companyId"], $companys))
  431. return json(["msg" => "你的部门不在并审部门列表"]);
  432. return $this->deptCheck($request, $talent_info, $companys);
  433. } else {
  434. return $this->reCheck($request, $talent_info);
  435. }
  436. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  437. return $this->reCheck($request, $talent_info);
  438. } else {
  439. return json(["msg" => "不在审核范围内,保存失败"]);
  440. }
  441. }
  442. public function submitCheck() {
  443. //公共调度方法
  444. $id = $this->request->param("id");
  445. $talent_info = VerifyApi::getOne($id);
  446. $checkState = $talent_info["checkState"];
  447. if (!$talent_info) {
  448. return json(["msg" => "数据错误"]);
  449. }
  450. if ($checkState == TalentState::FST_SUBMIT) {
  451. return $this->baseSubmitCheck($talent_info);
  452. } else if ($checkState == TalentState::SCND_SUBMIT) {
  453. return $this->fstSubmitCheck($talent_info);
  454. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  455. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  456. $companys = array_filter(explode(",", $condition["companyIds"]));
  457. if ($companys) {
  458. if (!in_array($this->user["companyId"], $companys))
  459. return json(["msg" => "你的部门不在并审部门列表"]);
  460. return $this->deptSubmitCheck($talent_info, $companys);
  461. } else {
  462. return $this->reSubmitCheck($talent_info);
  463. }
  464. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  465. return $this->reSubmitCheck($talent_info);
  466. } else {
  467. return json(["msg" => "不在审核范围内,审核失败"]);
  468. }
  469. }
  470. public function validateIsCheck() {
  471. $params = $this->request->param();
  472. $id = $params["id"];
  473. $talent_info = VerifyApi::getOne($id);
  474. if ($talent_info) {
  475. $checkState = $talent_info["checkState"];
  476. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
  477. $process = 0;
  478. if (in_array($checkState, [2, 6, 7, 9])) {
  479. switch ($checkState) {
  480. case 2:
  481. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  482. $fields = \app\common\api\DictApi::getTalentFields(1);
  483. $field_tmp = [];
  484. foreach ($fields as $key => $field) {
  485. $field_tmp[] = ["key" => $key, "value" => $field];
  486. }
  487. $where[] = ["project", "=", 1];
  488. $where[] = ["step", "=", 1];
  489. $where[] = ["active", "=", 1];
  490. $where[] = ["type", "=", $enterprise["type"]];
  491. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  492. $process = 1;
  493. break;
  494. case 6:
  495. $process = 2;
  496. break;
  497. case 7:
  498. $fields = \app\common\api\DictApi::getTalentFields(3);
  499. $process = 3;
  500. break;
  501. case 9:
  502. $fields = \app\common\api\DictApi::getTalentFields(3);
  503. $process = 4;
  504. break;
  505. }
  506. if ($checkState != 2) {
  507. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  508. $fields = \app\common\api\DictApi::getTalentFields(3);
  509. $field_tmp = [];
  510. foreach ($fields as $key => $field) {
  511. $field_tmp[] = ["key" => $key, "value" => $field];
  512. }
  513. $where[] = ["project", "=", 1];
  514. $where[] = ["active", "=", 1];
  515. $where[] = ["type", "=", $enterprise["type"]];
  516. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  517. }
  518. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files]]);
  519. } else {
  520. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  521. }
  522. }
  523. }
  524. }