Talent.php 29 KB

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