Talent.php 38 KB

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