Talent.php 33 KB

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