Talent.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  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. /**
  12. * Description of Talent
  13. *
  14. * @author sgq
  15. */
  16. class Talent extends AdminController {
  17. public function selectNeedCheckData() {
  18. $params = $this->request->param();
  19. return json(["code" => 200, "obj" => VerifyApi::getPublicList($params)]);
  20. }
  21. public function common_check() {
  22. $request = $this->request;
  23. $params = $request->param();
  24. $id = $params["id"];
  25. $info = VerifyApi::getTalentInfoById($id);
  26. if (in_array($info["checkState"], [-1, 2])) {
  27. return view("talentInfo_base_check", ["info" => $info]);
  28. } else {
  29. return view("talentInfo_common_check", ["info" => $info]);
  30. }
  31. }
  32. public function cancel_verify() {
  33. $params = $this->request->param();
  34. $ids = $params["ids"];
  35. $msg = $params["msg"];
  36. if ($msg == "") {
  37. return json(["msg" => "请填写审核不通过的原因"]);
  38. }
  39. $ids_arr = array_filter(explode(",", $ids));
  40. $counts = 0;
  41. foreach ($ids_arr as $id) {
  42. $ti = VerifyApi::getOne($id);
  43. $data["id"] = $id;
  44. if ($ti["checkState"] == TalentState::FST_SUBMIT) {
  45. $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
  46. TalentLogApi::write(1, $id, TalentState::BASE_VERIFY_FAIL, $msg, 1);
  47. TalentModel::update($data);
  48. $counts++;
  49. } else if ($ti["checkState"] == TalentState::SCND_SAVE) {
  50. $data["checkState"] = TalentState::FST_VERIFY_FAIL;
  51. TalentLogApi::write(1, $id, TalentState::FST_VERIFY_FAIL, $msg, 1);
  52. TalentModel::update($data);
  53. $counts++;
  54. } else {
  55. return json(["msg" => "不在审核范围"]);
  56. }
  57. }
  58. return json(["code" => 200, sprintf("%d个申请已审核失败", $counts)]);
  59. }
  60. public function base_verify() {
  61. return view();
  62. }
  63. public function base_verify_list() {
  64. $request = $this->request;
  65. return json(VerifyApi::getList($request));
  66. }
  67. /**
  68. * 部门初审
  69. * @auth {{/talentInfo/gotoIndex/-1}}
  70. */
  71. public function dept_fst_verify() {
  72. return view();
  73. }
  74. /**
  75. * 初审
  76. * @auth {{/talentInfo/gotoIndex/1}}
  77. */
  78. public function fst_verify() {
  79. return view();
  80. }
  81. /**
  82. * 初审-审核
  83. * @auth {{/talentInfo/firstCheck}}
  84. */
  85. public function fst_check() {
  86. }
  87. /**
  88. * 初审-修改驳回字段
  89. * @auth {{/talentInfo/updateFieldsAndFiles}}
  90. */
  91. public function updateFieldsAndFiles() {
  92. }
  93. /**
  94. * 初审-审核不通过
  95. * @auth {{/talentInfo/setNotPass}}
  96. */
  97. public function dis_pass() {
  98. }
  99. /**
  100. * 部门审核
  101. * @auth {{/talentInfo/gotoIndex/2}}
  102. */
  103. public function dept_verify() {
  104. return view();
  105. }
  106. /**
  107. * 复审
  108. * @auth {{/talentInfo/gotoIndex/3}}
  109. */
  110. public function re_verify() {
  111. return view();
  112. }
  113. /**
  114. * 复审-撤销复核
  115. * @auth {{/talentInfo/cancleThirdCheck}}
  116. */
  117. public function cancel_check() {
  118. }
  119. /**
  120. * 预备人才库
  121. * @auth {{/talentInfo/gotoIndex/4}}
  122. */
  123. public function pre_list() {
  124. return view();
  125. }
  126. /**
  127. * 预备人才库-公示
  128. * @auth {{/talentInfo/preparePublic}}
  129. */
  130. public function pre_public() {
  131. }
  132. /**
  133. * 预备人才库-核查征信
  134. * @auth {{/talentInfo/prepareHczx}}
  135. */
  136. public function pre_hczx() {
  137. }
  138. /**
  139. * 预备人才库-征信通过
  140. * @auth {{/talentInfo/hczxPass}}
  141. */
  142. public function hczxPass() {
  143. $params = $this->request->param();
  144. $ids = $params["ids"];
  145. $ids = array_filter(explode(",", $ids));
  146. $msg = "征信通过";
  147. $state = TalentState::ZX_PASS; //征信通过
  148. $total = count($ids);
  149. $error = 0;
  150. $success = 0;
  151. foreach ($ids as $id) {
  152. $talent_info = VerifyApi::getOne($id);
  153. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  154. $error++;
  155. continue;
  156. }
  157. if (VerifyApi::setPublic($id, $state, $msg)) {
  158. $success++;
  159. } else {
  160. $error++;
  161. }
  162. }
  163. return json(["code" => 200, "msg" => sprintf("核查征信成功:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  164. }
  165. /**
  166. * 预备人才库-征信失信
  167. * @auth {{/talentInfo/hczxReject}}
  168. */
  169. public function hczxReject() {
  170. $params = $this->request->param();
  171. $id = $params["id"];
  172. $msg = "征信失信:" . $params["outMsg"];
  173. $state = TalentState::ZX_FAIL; //征信不通过
  174. $talent_info = VerifyApi::getOne($id);
  175. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  176. return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
  177. }
  178. VerifyApi::setPublic($id, $state, $msg);
  179. return json(["code" => 200, "msg" => "已设置征信失信"]);
  180. }
  181. /**
  182. * 公示预览导出
  183. */
  184. public function exportPublic() {
  185. $params = $this->request->param();
  186. $ids_arr = array_filter(explode(",", $params["ids"]));
  187. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  188. if ($ids_arr) {
  189. $where[] = ["id", "in", $ids_arr];
  190. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  191. $rows = [];
  192. $i = 1;
  193. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  194. foreach ($list as $item) {
  195. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  196. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  197. $row = [
  198. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == 11 ? "审核通过" : "审核不通过", $enterprise["description"]
  199. ];
  200. $rows[] = $row;
  201. $i++;
  202. }
  203. }
  204. if ($rows) {
  205. $filename = "优秀人才公示预览导出";
  206. export($columns, $rows, $filename);
  207. }
  208. }
  209. /**
  210. * 公示
  211. */
  212. public function publicBatch() {
  213. $params = $this->request->param();
  214. $isMessage = $params["isMessage"] ?: 2;
  215. $ids = $params["ids"];
  216. $publicBatch = $params["batch"];
  217. if (!$publicBatch || strlen($publicBatch) != 6 || !is_numeric($publicBatch))
  218. return json(["msg" => "公示批次错误"]);
  219. $ids = array_filter(explode(",", $ids));
  220. $msg = "已公示";
  221. $state = TalentState::ANNOUNCED; //公示
  222. $total = count($ids);
  223. $error = 0;
  224. $success = 0;
  225. foreach ($ids as $id) {
  226. $talent_info = VerifyApi::getOne($id);
  227. if ($talent_info["checkState"] != TalentState::ZX_PASS) {
  228. $error++;
  229. continue;
  230. }
  231. if (VerifyApi::setPublic($id, $state, $msg, $publicBatch)) {
  232. $success++;
  233. } else {
  234. $error++;
  235. }
  236. }
  237. return json(["code" => 200, "msg" => sprintf("公示完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  238. }
  239. /**
  240. * 预备人才库-公示再审核
  241. * @auth {{/talentInfo/prepareCheck}}
  242. */
  243. public function pre_check() {
  244. }
  245. /**
  246. * 预备人才库-公布
  247. * @auth {{/talentInfo/preparePublish}}
  248. */
  249. public function pre_publish() {
  250. }
  251. /**
  252. * 预备人才库-发证
  253. * @auth {{/talentInfo/prepareCertification}}
  254. */
  255. public function pre_certification() {
  256. }
  257. /**
  258. * 预备人才库-撤销公布
  259. * @auth {{/talentInfo/prepareCanclePublish}}
  260. */
  261. public function pre_cancel_publish() {
  262. }
  263. /**
  264. * 预备人才库-公示预览
  265. * @auth {{/talentInfo/publicExportBefore}}
  266. */
  267. public function pre_public_preview() {
  268. }
  269. /**
  270. * 预备人才库-公布预览
  271. * @auth {{/talentInfo/publishExportBefore}}
  272. */
  273. public function pre_publish_preview() {
  274. }
  275. /**
  276. * 基本条件审核-提交未保存
  277. * @param \think\Request $request
  278. * @param type $talent_info
  279. * @return type json
  280. */
  281. private function baseCheck(\think\Request $request, $talent_info) {
  282. $params = $request->param();
  283. if ($params["checkState"] == 3) {
  284. //审核成功
  285. $log_checkState = $checkState = TalentState::BASE_VERIFY_PASS; //初审成功
  286. } else {
  287. //审核驳回并记录需要修改的字段和上传文件
  288. $checkState = TalentState::FST_SAVE; //退回提交材料阶段
  289. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  290. }
  291. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  292. if (!$log)
  293. return json(["msg" => "日志数据异常,保存失败"]);
  294. if ($log["active"] == 0) {
  295. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  296. } else {
  297. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  298. }
  299. $data["id"] = $talent_info["id"];
  300. $data["modify_files"] = $params["files"];
  301. $data["modify_fields"] = $params["fields"];
  302. TalentModel::update($data);
  303. return json(["code" => 200, "msg" => "保存成功"]);
  304. }
  305. /**
  306. * 基本条件审核-提交审核
  307. * @param type $talent_info
  308. * @return type json
  309. */
  310. private function baseSubmitCheck($talent_info) {
  311. return $this->commonSubmitCheck($talent_info, 1);
  312. }
  313. /**
  314. * 初审-提交未保存
  315. * @param \think\Request $request
  316. * @param type $talent_info
  317. * @return type json
  318. */
  319. private function fstCheck(\think\Request $request, $talent_info) {
  320. $params = $request->param();
  321. if ($params["checkState"] == 3) {
  322. //审核成功,并取消设置越过部门并审
  323. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  324. $data["pass_dept_check"] = 0;
  325. } else if ($params["checkState"] == 4) {
  326. if ($talent_info["highProcess"] < 3)
  327. return json(["msg" => "只有曾经通过部门并审,初审时才可以选择直接跳过部门并审阶段"]);
  328. //审核成功,并设置越过部门并审。附加条件:最高进度曾经通过部门并审3(包含部门并审)
  329. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  330. $data["pass_dept_check"] = $talent_info["highProcess"] >= 3 ? 1 : 0;
  331. } else {
  332. //审核驳回并记录需要修改的字段和上传文件
  333. $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
  334. $log_checkState = TalentState::FST_VERIFY_REJECT; //日志记录拒绝状态
  335. }
  336. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  337. if (!$log)
  338. return json(["msg" => "日志数据异常,保存失败"]);
  339. if ($log["active"] == 0) {
  340. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  341. } else {
  342. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  343. }
  344. $data["id"] = $talent_info["id"];
  345. $data["modify_files"] = $params["files"];
  346. $data["modify_fields"] = $params["fields"];
  347. TalentModel::update($data);
  348. return json(["code" => 200, "msg" => "保存成功"]);
  349. }
  350. /**
  351. * 初审-提交审核
  352. * @param type $talent_info
  353. * @return type json
  354. */
  355. private function fstSubmitCheck($talent_info) {
  356. $nowProcess = 2;
  357. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  358. if (!$log || $log["active"] == 1)
  359. return json(["msg" => "请先保存审核状态,再提交审核"]);
  360. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  361. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  362. }
  363. if ($log["new_state"] == TalentState::FST_VERIFY_PASS && $talent_info["pass_dept_check"] == 0) {
  364. $data["first_dept_check_time"] = date("Y-m-d H:i:s");
  365. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  366. $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
  367. //这边去除已经审核通过的单位,主要通过日志是否存在记录。
  368. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  369. $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
  370. sort($unpass_companyIds);
  371. TalentLogApi::writeDeptLogs($talent_info["id"], $unpass_companyIds, TalentState::FST_VERIFY_PASS);
  372. }
  373. $data["id"] = $talent_info["id"];
  374. $data["checkState"] = $log["new_state"];
  375. TalentModel::update($data);
  376. TalentLogApi::setActive($log["id"], 1);
  377. return json(["code" => 200, "msg" => "审核成功"]);
  378. }
  379. /**
  380. * 部门审核-提交未保存
  381. * @param \think\Request $request
  382. * @param type $talent_info
  383. * @return type json
  384. */
  385. private function deptCheck(\think\Request $request, $talent_info, $companys) {
  386. if ($talent_info["pass_dept_check"] == 1)
  387. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  388. if (!in_array($this->user["companyId"], $companys))
  389. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  390. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  391. if (in_array($this->user["companyId"], $pass_companyIds))
  392. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  393. $params = $request->param();
  394. if ($params["checkState"] == 3) {
  395. //审核成功
  396. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  397. $checkState = TalentState::DEPT_VERIFY_PASS; //审核成功
  398. } else {
  399. //审核驳回并记录需要修改的字段和上传文件
  400. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  401. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  402. $data["modify_files"] = $params["files"];
  403. $data["modify_fields"] = $params["fields"];
  404. }
  405. $fst_dept_check_time = $talent_info["first_dept_check_time"];
  406. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $fst_dept_check_time);
  407. if (!$dept_log)
  408. return json(["msg" => "未匹配日志,审核失败"]);
  409. if ($dept_log["active"] == 1)
  410. return json(["msg" => "您的部门已经审核过了"]);
  411. $data["id"] = $talent_info["id"];
  412. TalentModel::update($data);
  413. //修改日志
  414. TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  415. return json(["code" => 200, "msg" => "保存成功"]);
  416. }
  417. /**
  418. * 部门审核-提交审核
  419. * @param type $talent_info
  420. * @return type json
  421. */
  422. private function deptSubmitCheck($talent_info, $companys) {
  423. if ($talent_info["pass_dept_check"] == 1)
  424. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  425. if (!in_array($this->user["companyId"], $companys))
  426. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  427. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  428. if (in_array($this->user["companyId"], $pass_companyIds))
  429. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  430. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $talent_info["first_dept_check_time"]);
  431. $over = $pass_companyIds ? count($pass_companyIds) : 0; //完成度,如果重审之前已有通过审核的部门,不用再审,直接按通过算
  432. $error = 0; //失败数
  433. $nowProcess = 3;
  434. if (!$dept_log)
  435. return json(["msg" => "未匹配日志,审核失败"]);
  436. if ($dept_log["state"] == $dept_log["new_state"])
  437. return json(["msg" => "请先保存审核状态,再提交审核"]);
  438. if ($dept_log["active"] == 1)
  439. return json(["msg" => "您的部门已经审核过了"]);
  440. $over++;
  441. if ($dept_log["new_state"] == TalentState::SCND_SUBMIT) {
  442. $error++;
  443. }
  444. $logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
  445. for ($i = 0; $i < count($logs); $i++) {
  446. if (!in_array($logs[$i]["companyId"], $pass_companyIds)) {
  447. $over += $logs[$i]["active"] == 1 ? 1 : 0;
  448. if ($logs[$i]["new_state"] == TalentState::SCND_SUBMIT) {
  449. $error++;
  450. }
  451. }
  452. }
  453. if ($over == count($companys)) {
  454. //全部已审核
  455. $checkState = TalentState::SCND_SUBMIT;
  456. $log_checkState = TalentState::DEPT_VERIFY_REJECT;
  457. if ($error == 0) {
  458. $log_checkState = $checkState = TalentState::DEPT_VERIFY_PASS;
  459. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  460. }
  461. $data["id"] = $talent_info["id"];
  462. $data["checkState"] = $checkState;
  463. $data["first_dept_check_time"] = null;
  464. TalentModel::update($data);
  465. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "部门审核结束", 1);
  466. }
  467. TalentLogApi::setActive($dept_log["id"], 1);
  468. return json(["code" => 200, "msg" => "审核成功"]);
  469. }
  470. /**
  471. * 复审-提交未保存
  472. * @param \think\Request $request
  473. * @param type $talent_info
  474. * @param type json
  475. */
  476. private function reCheck(\think\Request $request, $talent_info) {
  477. $params = $request->param();
  478. if ($params["checkState"] == 3) {
  479. //审核成功
  480. $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
  481. } else if ($params["checkState"] == 2) {
  482. //审核驳回并记录需要修改的字段和上传文件
  483. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  484. $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
  485. } else {
  486. $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
  487. }
  488. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  489. if (!$log)
  490. return json(["msg" => "日志数据异常,保存失败"]);
  491. if ($log["active"] == 0) {
  492. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  493. } else {
  494. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  495. }
  496. $data["id"] = $talent_info["id"];
  497. $data["modify_files"] = $params["files"];
  498. $data["modify_fields"] = $params["fields"];
  499. TalentModel::update($data);
  500. return json(["code" => 200, "msg" => "保存成功"]);
  501. }
  502. /**
  503. * 复审-提交审核
  504. * @param type $talent_info
  505. * @return type json
  506. */
  507. private function reSubmitCheck($talent_info) {
  508. return $this->commonSubmitCheck($talent_info, 4);
  509. }
  510. private function commonSubmitCheck($talent_info, $nowProcess) {
  511. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  512. if (!$log || $log["active"] == 1)
  513. return json(["msg" => "请先保存审核状态,再提交审核"]);
  514. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  515. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  516. }
  517. $data["id"] = $talent_info["id"];
  518. $data["checkState"] = $log["new_state"];
  519. TalentModel::update($data);
  520. TalentLogApi::setActive($log["id"], 1);
  521. return json(["code" => 200, "msg" => "审核成功"]);
  522. }
  523. public function check() {
  524. //公共调度方法
  525. $request = $this->request;
  526. $params = $request->param();
  527. $check = $params["checkState"];
  528. $check_msg = trim($params["checkMsg"]);
  529. $files = $params["files"];
  530. $fields = $params["fields"];
  531. $id = $params["id"];
  532. $talent_info = VerifyApi::getOne($id);
  533. $checkState = $talent_info["checkState"];
  534. if (!$talent_info) {
  535. return json(["msg" => "数据错误"]);
  536. }
  537. if (!$check) {
  538. return json(["msg" => "请选择审核状态"]);
  539. }
  540. if (!$check_msg) {
  541. return json(["msg" => "请填写审核说明"]);
  542. }
  543. if ($checkState == TalentState::FST_SUBMIT) {
  544. return $this->baseCheck($request, $talent_info);
  545. } else if ($checkState == TalentState::SCND_SUBMIT) {
  546. return $this->fstCheck($request, $talent_info);
  547. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  548. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  549. $companys = array_filter(explode(",", $condition["companyIds"]));
  550. if ($companys && $talent_info["pass_dept_check"] != 1) {
  551. if (!in_array($this->user["companyId"], $companys))
  552. return json(["msg" => "你的部门不在并审部门列表"]);
  553. return $this->deptCheck($request, $talent_info, $companys);
  554. } else {
  555. return $this->reCheck($request, $talent_info);
  556. }
  557. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  558. return $this->reCheck($request, $talent_info);
  559. } else {
  560. return json(["msg" => "不在审核范围内,保存失败"]);
  561. }
  562. }
  563. public function submitCheck() {
  564. //公共调度方法
  565. $id = $this->request->param("id");
  566. $talent_info = VerifyApi::getOne($id);
  567. $checkState = $talent_info["checkState"];
  568. if (!$talent_info) {
  569. return json(["msg" => "数据错误"]);
  570. }
  571. if ($checkState == TalentState::FST_SUBMIT) {
  572. return $this->baseSubmitCheck($talent_info);
  573. } else if ($checkState == TalentState::SCND_SUBMIT) {
  574. return $this->fstSubmitCheck($talent_info);
  575. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  576. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  577. $companys = array_filter(explode(",", $condition["companyIds"]));
  578. if ($companys && $talent_info["pass_dept_check"] != 1) {
  579. if (!in_array($this->user["companyId"], $companys))
  580. return json(["msg" => "你的部门不在并审部门列表"]);
  581. return $this->deptSubmitCheck($talent_info, $companys);
  582. } else {
  583. return $this->reSubmitCheck($talent_info);
  584. }
  585. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  586. return $this->reSubmitCheck($talent_info);
  587. } else {
  588. return json(["msg" => "不在审核范围内,审核失败"]);
  589. }
  590. }
  591. public function validateIsCheck() {
  592. $params = $this->request->param();
  593. $id = $params["id"];
  594. $talent_info = VerifyApi::getOne($id);
  595. if ($talent_info) {
  596. $checkState = $talent_info["checkState"];
  597. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
  598. $process = 0;
  599. if (in_array($checkState, [2, 6, 7, 9])) {
  600. switch ($checkState) {
  601. case 2:
  602. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  603. $fields = DictApi::getTalentFields(1);
  604. $field_tmp = [];
  605. foreach ($fields as $key => $field) {
  606. $field_tmp[] = ["key" => $key, "value" => $field];
  607. }
  608. $where[] = ["project", "=", 1];
  609. $where[] = ["step", "=", 1];
  610. $where[] = ["active", "=", 1];
  611. $where[] = ["type", "=", $enterprise["type"]];
  612. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  613. $process = 1;
  614. break;
  615. case 6:
  616. $process = 2;
  617. break;
  618. case 7:
  619. $tc = TalentConditionApi::getOne($talent_info["talent_condition"]);
  620. if ($tc["companyIds"] && $talent_info["pass_dept_check"] != 1) {
  621. $process = 3;
  622. } else {
  623. $process = 4;
  624. }
  625. $fields = DictApi::getTalentFields(3);
  626. break;
  627. case 9:
  628. $fields = DictApi::getTalentFields(3);
  629. $process = 4;
  630. break;
  631. }
  632. if ($checkState != 2) {
  633. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  634. $fields = DictApi::getTalentFields(2);
  635. $field_tmp = [];
  636. foreach ($fields as $key => $field) {
  637. $field_tmp[] = ["key" => $key, "value" => $field];
  638. }
  639. $where = [];
  640. $whr = [];
  641. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  642. $where[] = ["project", "=", 1];
  643. $where[] = ["step", "=", 2];
  644. $where[] = ["active", "=", 1];
  645. $where[] = ["type", "=", $enterprise["type"]];
  646. $where[] = ["isConditionFile", "<>", 1];
  647. if ($condition && $condition["bindFileTypes"]) {
  648. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  649. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->select();
  650. } else {
  651. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  652. }
  653. }
  654. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  655. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  656. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files]]);
  657. } else {
  658. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  659. }
  660. }
  661. }
  662. public function findFieldsAndFiles() {
  663. }
  664. public function exportHczx() {
  665. $ids = $this->request->param("ids");
  666. $ids_arr = array_filter(explode(",", $ids));
  667. if (!$ids_arr) {
  668. $res = ["code" => 500, "msg" => "没有选择导出的名单"];
  669. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  670. }
  671. $where[] = ["ti.id", "in", $ids_arr];
  672. $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();
  673. if (!$list) {
  674. $res = ["code" => 500, "msg" => "没有可以导出的内容"];
  675. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  676. }
  677. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  678. $rows = [];
  679. $i = 1;
  680. $card_types = DictApi::selectByParentCode("card_type");
  681. foreach ($list as $item) {
  682. $row = [
  683. $i, $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], $item["description"]
  684. ];
  685. $rows[] = $row;
  686. $i++;
  687. }
  688. $filename = "优秀人才核查征信名单导出";
  689. if ($rows) {
  690. export($columns, $rows, $filename);
  691. }
  692. }
  693. public function commonExport() {
  694. $params = $this->request->param();
  695. $fields = $params["export"];
  696. if (!$fields)
  697. return json(["msg" => "请选择要导出的数据"]);
  698. $names = DictApi::getTalentFields(3);
  699. $names["industryFieldNew"] = "产业领域";
  700. $names["enterpriseName"] = "单位名称";
  701. $names["enterpriseTag"] = "单位标签";
  702. $names["street"] = "所属镇街";
  703. $names["checkState"] = "审核状态";
  704. $list = VerifyApi::getExportDatas($fields);
  705. foreach ($fields as $field) {
  706. $columns[] = $names[$field];
  707. }
  708. $datas = [];
  709. for ($i = 0; $i < count($list); $i++) {
  710. $data = [];
  711. for ($n = 0; $n < count($fields); $n++) {
  712. $data[] = $list[$i][$fields[$n]];
  713. }
  714. $datas[] = $data;
  715. }
  716. if ($datas) {
  717. export($columns, $datas);
  718. }
  719. }
  720. public function getPhones() {
  721. $list = VerifyApi::getListByProcess($this->request->param("process"));
  722. $result = [];
  723. if ($list) {
  724. foreach ($list as $item) {
  725. if ($item["phone"] && $item["name"]) {
  726. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  727. }
  728. }
  729. }
  730. return json(["code" => 200, "obj" => implode(";", $result)]);
  731. }
  732. public function getEnterprisePhones() {
  733. $list = VerifyApi::getListByProcess($this->request->param("process"));
  734. $result = [];
  735. if ($list) {
  736. foreach ($list as $item) {
  737. if ($item["agentName"] && $item["agentPhone"]) {
  738. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  739. }
  740. }
  741. }
  742. return json(["code" => 200, "obj" => implode(";", $result)]);
  743. }
  744. }