Talent.php 31 KB

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