Talent.php 30 KB

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