Talent.php 30 KB

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