Talent.php 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\ChuanglanSmsApi;
  5. use app\common\api\VerifyApi;
  6. use app\common\api\TalentLogApi;
  7. use app\common\api\TalentState;
  8. use app\common\model\MessageRecord;
  9. use app\enterprise\model\Talent as TalentModel;
  10. use app\common\api\TalentConditionApi;
  11. use app\common\api\DictApi;
  12. use app\common\api\EnterpriseApi;
  13. use think\facade\Db;
  14. /**
  15. * Description of Talent
  16. *
  17. * @author sgq
  18. */
  19. class Talent extends AdminController {
  20. public function common_check() {
  21. $request = $this->request;
  22. $params = $request->param();
  23. $id = $params["id"];
  24. $info = VerifyApi::getTalentInfoById($id);
  25. if (in_array($info["checkState"], [-1, 2])) {
  26. return view("talentInfo_base_check", ["info" => $info]);
  27. } else {
  28. return view("talentInfo_common_check", ["info" => $info]);
  29. }
  30. }
  31. public function cancel_verify() {
  32. $params = $this->request->param();
  33. $ids = $params["ids"];
  34. $msg = $params["msg"];
  35. if ($msg == "") {
  36. return json(["msg" => "请填写审核不通过的原因"]);
  37. }
  38. $ids_arr = array_filter(explode(",", $ids));
  39. $counts = 0;
  40. foreach ($ids_arr as $id) {
  41. $ti = VerifyApi::getOne($id);
  42. $data["id"] = $id;
  43. if ($ti["checkState"] == TalentState::FST_SUBMIT) {
  44. $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
  45. TalentLogApi::write(1, $id, TalentState::BASE_VERIFY_FAIL, $msg, 1);
  46. TalentModel::update($data);
  47. $counts++;
  48. } else if ($ti["checkState"] == TalentState::SCND_SAVE) {
  49. $data["checkState"] = TalentState::FST_VERIFY_FAIL;
  50. TalentLogApi::write(1, $id, TalentState::FST_VERIFY_FAIL, $msg, 1);
  51. TalentModel::update($data);
  52. $counts++;
  53. } else {
  54. return json(["msg" => "不在审核范围"]);
  55. }
  56. }
  57. return json(["code" => 200, sprintf("%d个申请已审核失败", $counts)]);
  58. }
  59. public function base_verify() {
  60. return view();
  61. }
  62. public function base_verify_list() {
  63. $request = $this->request;
  64. return json(VerifyApi::getList($request));
  65. }
  66. /**
  67. * 部门初审
  68. * @auth {{/talentInfo/gotoIndex/-1}}
  69. */
  70. public function dept_fst_verify() {
  71. return view();
  72. }
  73. /**
  74. * 初审
  75. * @auth {{/talentInfo/gotoIndex/1}}
  76. */
  77. public function fst_verify() {
  78. return view();
  79. }
  80. /**
  81. * 初审-审核
  82. * @auth {{/talentInfo/firstCheck}}
  83. */
  84. public function fst_check() {
  85. }
  86. /**
  87. * 初审-修改驳回字段
  88. * @auth {{/talentInfo/updateFieldsAndFiles}}
  89. */
  90. public function updateFieldsAndFiles() {
  91. }
  92. /**
  93. * 初审-审核不通过
  94. * @auth {{/talentInfo/setNotPass}}
  95. */
  96. public function dis_pass() {
  97. }
  98. /**
  99. * 部门审核
  100. * @auth {{/talentInfo/gotoIndex/2}}
  101. */
  102. public function dept_verify() {
  103. return view();
  104. }
  105. /**
  106. * 复审
  107. * @auth {{/talentInfo/gotoIndex/3}}
  108. */
  109. public function re_verify() {
  110. return view();
  111. }
  112. /**
  113. * 复审-撤销复核
  114. * @auth {{/talentInfo/cancleThirdCheck}}
  115. */
  116. public function cancel_check() {
  117. }
  118. /**
  119. * 预备人才库
  120. * @auth {{/talentInfo/gotoIndex/4}}
  121. */
  122. public function pre_list() {
  123. if (session("user")["type"] == 1) {
  124. $message = [
  125. "typeName" => "晋江市优秀人才认定", "address" => "聚才网/人才晋江微信公众号", "dep" => "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心",
  126. "phone" => "0595-85633128", "email" => "jjrc85661234@163.com"
  127. ];
  128. } else {
  129. $message = [
  130. "typeName" => "晋江市集成电路产业优秀人才认定", "address" => "福建(晋江)集成电路产业园官方网站及微信公众号", "dep" => "集成电路产业园区",
  131. "phone" => "0595-82250007、0595-82250001", "email" => "jjjcdr@163.com"
  132. ];
  133. }
  134. return view("", ["message" => $message]);
  135. }
  136. public function selectNeedCheckData() {
  137. $params = $this->request->param();
  138. return json(["code" => 200, "obj" => VerifyApi::getPublicList($params)]);
  139. }
  140. /**
  141. * 预备人才库-核查征信
  142. * @auth {{/talentInfo/prepareHczx}}
  143. */
  144. public function prepareHczx() {
  145. $ids = $this->request->param("ids");
  146. $ids_arr = array_filter(explode(",", $ids));
  147. if (!$ids_arr) {
  148. $res = ["code" => 500, "msg" => "没有选择导出的名单"];
  149. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  150. }
  151. $where[] = ["ti.id", "in", $ids_arr];
  152. $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();
  153. if (!$list) {
  154. $res = ["code" => 500, "msg" => "没有可以导出的内容"];
  155. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  156. }
  157. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  158. $rows = [];
  159. $i = 1;
  160. $card_types = DictApi::selectByParentCode("card_type");
  161. foreach ($list as $item) {
  162. $row = [
  163. $i, $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], $item["description"]
  164. ];
  165. $rows[] = $row;
  166. $i++;
  167. }
  168. $filename = "优秀人才核查征信名单导出";
  169. if ($rows) {
  170. export($columns, $rows, $filename);
  171. exit();
  172. }
  173. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  174. }
  175. /**
  176. * 预备人才库-征信通过
  177. * @auth {{/talentInfo/hczxPass}}
  178. */
  179. public function hczxPass() {
  180. $params = $this->request->param();
  181. $ids = $params["ids"];
  182. $ids = array_filter(explode(",", $ids));
  183. $msg = "征信通过";
  184. $state = TalentState::ZX_PASS; //征信通过
  185. $total = count($ids);
  186. $error = 0;
  187. $success = 0;
  188. foreach ($ids as $id) {
  189. $talent_info = VerifyApi::getOne($id);
  190. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  191. $error++;
  192. continue;
  193. }
  194. if (VerifyApi::setPublic($id, $state, $msg)) {
  195. $success++;
  196. } else {
  197. $error++;
  198. }
  199. }
  200. return json(["code" => 200, "msg" => sprintf("核查征信完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  201. }
  202. /**
  203. * 预备人才库-征信失信
  204. * @auth {{/talentInfo/hczxReject}}
  205. */
  206. public function hczxReject() {
  207. $params = $this->request->param();
  208. $id = $params["id"];
  209. $msg = $params["outMsg"];
  210. if (!$msg)
  211. return json(["msg" => "请填写审核意见"]);
  212. $msg = "征信失信:" . $msg;
  213. $state = TalentState::ZX_FAIL; //征信不通过
  214. $talent_info = VerifyApi::getOne($id);
  215. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  216. return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
  217. }
  218. if (VerifyApi::setPublic($id, $state, $msg)) {
  219. return json(["code" => 200, "msg" => "已设置征信失信"]);
  220. }
  221. return json(["msg" => "设置征信失信失败"]);
  222. }
  223. /**
  224. * 预备人才库-公示预览
  225. * @auth {{/talentInfo/publicExportBefore}}
  226. */
  227. public function publicExportBefore() {
  228. $params = $this->request->param();
  229. $ids_arr = array_filter(explode(",", $params["ids"]));
  230. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  231. if ($ids_arr) {
  232. $where[] = ["id", "in", $ids_arr];
  233. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  234. $rows = [];
  235. $i = 1;
  236. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  237. foreach ($list as $item) {
  238. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  239. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  240. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  241. $row = [
  242. $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"]
  243. ];
  244. $rows[] = $row;
  245. $i++;
  246. }
  247. }
  248. if ($rows) {
  249. $filename = "优秀人才公示预览导出";
  250. export($columns, $rows, $filename);
  251. exit();
  252. }
  253. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  254. }
  255. /**
  256. * 预备人才库-公示导出
  257. * @auth {{/talentInfo/publicExport}}
  258. */
  259. public function publicExport() {
  260. $params = $this->request->param();
  261. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  262. $startTime = $params["startTime"];
  263. $endTime = $params["endTime"];
  264. if (!strtotime($startTime) || !strtotime($endTime))
  265. return json(["msg" => "时间格式错误"]);
  266. $where[] = ["checkState", "=", TalentState::ANNOUNCED];
  267. $where[] = ["publicBatch", "between", [$startTime, $endTime]];
  268. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  269. $rows = [];
  270. $i = 1;
  271. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  272. foreach ($list as $item) {
  273. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  274. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  275. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  276. $row = [
  277. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED ? "审核通过" : "审核不通过", $checkLog["description"]
  278. ];
  279. $rows[] = $row;
  280. $i++;
  281. }
  282. if ($rows) {
  283. $filename = "优秀人才公示导出";
  284. export($columns, $rows, $filename);
  285. exit();
  286. }
  287. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  288. }
  289. /**
  290. * 预备人才库-公示
  291. * @auth {{/talentInfo/preparePublic}}
  292. */
  293. public function preparePublic() {
  294. $params = $this->request->param();
  295. $ids = $params["ids"];
  296. $publicBatch = $params["batch"];
  297. if (!$publicBatch || strlen($publicBatch) != 6 || !is_numeric($publicBatch))
  298. return json(["msg" => "公示批次错误"]);
  299. $isMessage = $params["isMessage"] == 1 ? true : false;
  300. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  301. return json(["msg" => "短信参数不能为空"]);
  302. }
  303. $ids = array_filter(explode(",", $ids));
  304. $msg = "已公示";
  305. $state = TalentState::ANNOUNCED; //公示
  306. $total = count($ids);
  307. $error = 0;
  308. $success = 0;
  309. $phones = [];
  310. foreach ($ids as $id) {
  311. $talent_info = VerifyApi::getOne($id);
  312. if ($talent_info["checkState"] != TalentState::ZX_PASS) {
  313. $error++;
  314. continue;
  315. }
  316. if (VerifyApi::setPublic($id, $state, $msg, $publicBatch)) {
  317. $success++;
  318. $phones[] = $talent_info["phone"];
  319. } else {
  320. $error++;
  321. }
  322. }
  323. $phones = array_unique(array_filter($phones));
  324. if ($isMessage && $phones) {
  325. $sms = new \app\common\api\ChuanglanSmsApi();
  326. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  327. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  328. while ($phone = array_shift($phones)) {
  329. $sms->sendSMS($phone, $tpl_content);
  330. }
  331. }
  332. return json(["code" => 200, "msg" => sprintf("公示完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  333. }
  334. /**
  335. * 预备人才库-公示再审核
  336. * @auth {{/talentInfo/prepareCheck}}
  337. */
  338. public function prepareCheck() {
  339. $params = $this->request->param();
  340. $id = $params["id"];
  341. $checkState = $params["checkState"];
  342. $msg = $params["checkMsg"];
  343. if (!$msg)
  344. return json(["msg" => "请填写审核意见"]);
  345. if ($checkState == 1) {
  346. $msg = "公示再审核通过:" . $msg;
  347. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  348. } else {
  349. $msg = "公示再审核不通过:" . $msg;
  350. $state = TalentState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
  351. }
  352. $talent_info = VerifyApi::getOne($id);
  353. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  354. return json(["msg" => "当前记录不是公示状态,无法审核"]);
  355. }
  356. if (VerifyApi::setPublic($id, $state, $msg)) {
  357. return json(["code" => 200, "msg" => "公示再审核完成"]);
  358. }
  359. return json(["msg" => "公示再审核失败"]);
  360. }
  361. /**
  362. * 预备人才库-公示通过(批量)
  363. * @auth {{/talentInfo/publicPass}}
  364. */
  365. public function publicPass() {
  366. $params = $this->request->param();
  367. $ids = $params["ids"];
  368. $ids = array_filter(explode(",", $ids));
  369. $msg = "公示再审核批量通过";
  370. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  371. $total = count($ids);
  372. $error = 0;
  373. $success = 0;
  374. foreach ($ids as $id) {
  375. $talent_info = VerifyApi::getOne($id);
  376. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  377. $error++;
  378. continue;
  379. }
  380. if (VerifyApi::setPublic($id, $state, $msg)) {
  381. $success++;
  382. } else {
  383. $error++;
  384. }
  385. }
  386. return json(["code" => 200, "msg" => sprintf("公示再审核完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  387. }
  388. /**
  389. * 预备人才库-公布预览
  390. * @auth {{/talentInfo/publishExportBefore}}
  391. */
  392. public function publishExportBefore() {
  393. $params = $this->request->param();
  394. $ids = $params["ids"];
  395. $ids = array_filter(explode(",", $ids));
  396. if ($ids) {
  397. $where[] = ["id", "in", $ids];
  398. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  399. $rows = [];
  400. $i = 1;
  401. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  402. foreach ($list as $item) {
  403. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  404. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  405. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  406. $row = [
  407. $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"]
  408. ];
  409. $rows[] = $row;
  410. $i++;
  411. }
  412. }
  413. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  414. $filename = "优秀人才" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  415. if ($rows) {
  416. export($columns, $rows, $filename);
  417. exit();
  418. }
  419. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  420. }
  421. /**
  422. * 预备人才库-公布导出
  423. * @auth {{/talentInfo/publishExport}}
  424. */
  425. public function publishExport() {
  426. $params = $this->request->param();
  427. $startTime = $params["startTime"];
  428. $endTime = $params["endTime"];
  429. if (!strtotime($startTime) || !strtotime($endTime))
  430. return json(["msg" => "时间格式错误"]);
  431. $where[] = ["checkState", "=", TalentState::PUBLISH_PASS];
  432. $where[] = ["certificateGetTime", "between", [$startTime, $endTime]];
  433. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  434. $rows = [];
  435. $i = 1;
  436. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  437. foreach ($list as $item) {
  438. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  439. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  440. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  441. $row = [
  442. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::PUBLISH_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
  443. ];
  444. $rows[] = $row;
  445. $i++;
  446. }
  447. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  448. $filename = "优秀人才" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  449. if ($rows) {
  450. export($columns, $rows, $filename);
  451. exit();
  452. }
  453. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  454. }
  455. /**
  456. * 预备人才库-公布
  457. * @auth {{/talentInfo/publish}}
  458. */
  459. public function publish() {
  460. $params = $this->request->param();
  461. $id = $params["id"];
  462. $msg = $params["checkMsg"];
  463. $checkState = $params["checkState"];
  464. $batch = $params["batch"];
  465. if ($checkState == 1) {
  466. $state = TalentState::PUBLISH_PASS;
  467. $msg = "公布审核通过:" . $msg;
  468. } else {
  469. $state = TalentState::PUBLISH_FAIL;
  470. $msg = "公布审核不通过:" . $msg;
  471. }
  472. if (!$batch || !strtotime($batch))
  473. return json(["msg" => "公布批次时间错误"]);
  474. if (!$msg)
  475. return json(["msg" => "请填写审核意见"]);
  476. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  477. $batch = $params["batch"];
  478. if (!strtotime($batch))
  479. return json(["msg" => "公布批次时间错误"]);
  480. $talent_info = VerifyApi::getOne($id);
  481. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  482. return json(["msg" => "当前记录不是公示再审核通过状态,无法审核"]);
  483. }
  484. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  485. return json(["code" => 200, "msg" => "公布审核完成"]);
  486. }
  487. return json(["msg" => "公布审核失败"]);
  488. }
  489. /**
  490. * 预备人才库-批量公布通过
  491. * @auth {{/talentInfo/preparePublish}}
  492. */
  493. public function preparePublish() {
  494. $params = $this->request->param();
  495. $ids = $params["ids"];
  496. $ids = array_filter(explode(",", $ids));
  497. $msg = "批量公布";
  498. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  499. $batch = $params["batch"];
  500. if (!strtotime($batch))
  501. return json(["msg" => "公布批次时间错误"]);
  502. $total = count($ids);
  503. $error = 0;
  504. $success = 0;
  505. foreach ($ids as $id) {
  506. $talent_info = VerifyApi::getOne($id);
  507. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  508. $error++;
  509. continue;
  510. }
  511. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  512. $success++;
  513. } else {
  514. $error++;
  515. }
  516. }
  517. return json(["code" => 200, "msg" => sprintf("公布完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  518. }
  519. /**
  520. * 预备人才库-批量发证
  521. * @auth {{/talentInfo/prepareCertification}}
  522. */
  523. public function prepareCertification() {
  524. $lockFile = fopen("send_certificate.lock", "a");
  525. if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
  526. //查询所有待发证的数据
  527. $params = $this->request->param();
  528. $ids = array_filter(explode(",", $params["ids"]));
  529. //晋江市优秀人才证书:当前年份+层次+四位递增数字
  530. //集成电路优秀人才证书:IC+当前年份+递增四位数,如IC20190001
  531. Db::startTrans();
  532. $talent_max_no = [];
  533. $user = session("user");
  534. try {
  535. $talent_list = VerifyApi::getListByIds($ids);
  536. $year = date("Y");
  537. foreach ($talent_list as $talent_info) {
  538. if ($talent_info["checkState"] != TalentState::PUBLISH_PASS) {
  539. Db::rollback();
  540. return json(["msg" => "只能对公布通过的对象进行发证,请核查待发证名单后再重新发证"]);
  541. }
  542. $no_prefix = $year . $talent_info["talent_arrange"];
  543. $where[] = ["certificateNo", "like", $no_prefix . "%"];
  544. $max_no = $talent_max_no[$talent_info["talent_arrange"]] ?: Db::table("new_talent_info")->where($where)->max("certificateNo");
  545. if (!$max_no) {
  546. $max_no = $no_prefix . "0001";
  547. } else {
  548. $new_no = intval(substr($max_no, 5)) + 1;
  549. $max_no = $no_prefix . str_pad($new_no, 4, "0", STR_PAD_LEFT);
  550. }
  551. //更新证书编号
  552. $data["id"] = $talent_info["id"];
  553. $data["certificateNo"] = $max_no;
  554. $data["checkState"] = TalentState::CERTIFICATED;
  555. $data["isPublic"] = 5;
  556. Db::table("new_talent_info")->update($data);
  557. //写入日志
  558. $log["last_state"] = TalentState::PUBLISH_PASS;
  559. $log["id"] = getStringId();
  560. $log["state"] = $log["new_state"] = TalentState::CERTIFICATED;
  561. $log["type"] = 1;
  562. $log["mainId"] = $talent_info["id"];
  563. $log["companyId"] = $user["companyId"];
  564. $log["active"] = 1;
  565. $log["description"] = "人才编号为:" . $max_no;
  566. $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);
  567. $log["createTime"] = date("Y-m-d H:i:s");
  568. Db::table("new_talent_checklog")->insert($log);
  569. $talent_max_no[$talent_info["talent_arrange"]] = $max_no;
  570. }
  571. Db::commit();
  572. return json(["code" => 200, "msg" => "发证成功"]);
  573. } catch (\Exception $e) {
  574. Db::rollback();
  575. return json(["msg" => "发证失败:" . $e->getMessage()]);
  576. }
  577. flock($lockFile, LOCK_UN);
  578. } else {
  579. return json(["msg" => "同一时间只能有一个管理员进行发证操作"]);
  580. }
  581. }
  582. /**
  583. * 预备人才库-撤销公布
  584. * @auth {{/talentInfo/prepareCanclePublish}}
  585. */
  586. public function pre_cancel_publish() {
  587. }
  588. /**
  589. * 基本条件审核-提交未保存
  590. * @param \think\Request $request
  591. * @param type $talent_info
  592. * @return type json
  593. */
  594. private function baseCheck(\think\Request $request, $talent_info) {
  595. $params = $request->param();
  596. if ($params["checkState"] == 3) {
  597. //审核成功
  598. $log_checkState = $checkState = TalentState::BASE_VERIFY_PASS; //初审成功
  599. } else {
  600. //审核驳回并记录需要修改的字段和上传文件
  601. $checkState = TalentState::FST_SAVE; //退回提交材料阶段
  602. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  603. }
  604. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  605. if (!$log)
  606. return json(["msg" => "日志数据异常,保存失败"]);
  607. if ($log["active"] == 0) {
  608. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  609. } else {
  610. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  611. }
  612. $data["id"] = $talent_info["id"];
  613. $data["modify_files"] = $params["files"];
  614. $data["modify_fields"] = $params["fields"];
  615. TalentModel::update($data);
  616. return json(["code" => 200, "msg" => "保存成功"]);
  617. }
  618. /**
  619. * 基本条件审核-提交审核
  620. * @param type $talent_info
  621. * @return type json
  622. */
  623. private function baseSubmitCheck($talent_info) {
  624. return $this->commonSubmitCheck($talent_info, 1);
  625. }
  626. /**
  627. * 初审-提交未保存
  628. * @param \think\Request $request
  629. * @param type $talent_info
  630. * @return type json
  631. */
  632. private function fstCheck(\think\Request $request, $talent_info) {
  633. $params = $request->param();
  634. if ($params["checkState"] == 3) {
  635. //审核成功,并取消设置越过部门并审
  636. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  637. $data["pass_dept_check"] = 0;
  638. } else if ($params["checkState"] == 4) {
  639. if ($talent_info["highProcess"] < 3)
  640. return json(["msg" => "只有曾经通过部门并审,初审时才可以选择直接跳过部门并审阶段"]);
  641. //审核成功,并设置越过部门并审。附加条件:最高进度曾经通过部门并审3(包含部门并审)
  642. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  643. $data["pass_dept_check"] = $talent_info["highProcess"] >= 3 ? 1 : 0;
  644. } else {
  645. //审核驳回并记录需要修改的字段和上传文件
  646. $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
  647. $log_checkState = TalentState::FST_VERIFY_REJECT; //日志记录拒绝状态
  648. }
  649. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  650. if (!$log)
  651. return json(["msg" => "日志数据异常,保存失败"]);
  652. if ($log["active"] == 0) {
  653. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  654. } else {
  655. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  656. }
  657. $data["id"] = $talent_info["id"];
  658. $data["modify_files"] = $params["files"];
  659. $data["modify_fields"] = $params["fields"];
  660. TalentModel::update($data);
  661. return json(["code" => 200, "msg" => "保存成功"]);
  662. }
  663. /**
  664. * 初审-提交审核
  665. * @param type $talent_info
  666. * @return type json
  667. */
  668. private function fstSubmitCheck($talent_info) {
  669. $nowProcess = 2;
  670. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  671. if (!$log || $log["active"] == 1)
  672. return json(["msg" => "请先保存审核状态,再提交审核"]);
  673. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  674. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  675. }
  676. if ($log["new_state"] == TalentState::FST_VERIFY_PASS && $talent_info["pass_dept_check"] == 0) {
  677. $data["first_dept_check_time"] = date("Y-m-d H:i:s");
  678. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  679. $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
  680. //这边去除已经审核通过的单位,主要通过日志是否存在记录。
  681. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  682. $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
  683. if (!$unpass_companyIds) {
  684. $data["pass_dept_check"] = 1; //部门已经全部审核过了,跳过部门审核
  685. } else {
  686. sort($unpass_companyIds);
  687. TalentLogApi::writeDeptLogs($talent_info["id"], $unpass_companyIds, TalentState::FST_VERIFY_PASS);
  688. }
  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. /**
  697. * 部门审核-提交未保存
  698. * @param \think\Request $request
  699. * @param type $talent_info
  700. * @return type json
  701. */
  702. private function deptCheck(\think\Request $request, $talent_info, $companys) {
  703. if ($talent_info["pass_dept_check"] == 1)
  704. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  705. if (!in_array($this->user["companyId"], $companys))
  706. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  707. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  708. if (in_array($this->user["companyId"], $pass_companyIds))
  709. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  710. $params = $request->param();
  711. if ($params["checkState"] == 3) {
  712. //审核成功
  713. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  714. $checkState = TalentState::DEPT_VERIFY_PASS; //审核成功
  715. } else {
  716. //审核驳回并记录需要修改的字段和上传文件
  717. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  718. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  719. $talent_condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  720. if (!$talent_condition["companyWithFileType"])
  721. return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
  722. $cwfts = explode(";", $talent_condition["companyWithFileType"]);
  723. $company_setting = [];
  724. foreach ($cwfts as $cwft) {
  725. $_company_setting = explode(":", $cwft);
  726. if ($_company_setting[0] == $this->user["companyId"]) {
  727. $company_setting = explode(",", $_company_setting[1]);
  728. break;
  729. }
  730. }
  731. if (!$company_setting)
  732. return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
  733. //$data["modify_fields"] = $params["fields"];
  734. $original_modify_files = explode(",", $talent_info["modify_files"]);
  735. $_current_modify_files = explode(",", $params["files"]);
  736. $unselect_files = array_diff($company_setting, $_current_modify_files); //比较设置和当前提交的,取差值集,既是可选而未选的附件集合
  737. $new_modify_files = array_unique(array_merge($original_modify_files, $_current_modify_files)); //合并当前提交及库中原来保存的值
  738. foreach ($new_modify_files as $key => $item) {
  739. if (in_array($item, $unselect_files))
  740. unset($new_modify_files[$key]);
  741. }
  742. $data["modify_files"] = implode(",", array_unique($new_modify_files));
  743. }
  744. $fst_dept_check_time = $talent_info["first_dept_check_time"];
  745. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $fst_dept_check_time);
  746. if (!$dept_log)
  747. return json(["msg" => "未匹配日志,审核失败"]);
  748. if ($dept_log["active"] == 1)
  749. return json(["msg" => "您的部门已经审核过了"]);
  750. $data["id"] = $talent_info["id"];
  751. TalentModel::update($data);
  752. //修改日志
  753. TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  754. return json(["code" => 200, "msg" => "保存成功"]);
  755. }
  756. /**
  757. * 部门审核-提交审核
  758. * @param type $talent_info
  759. * @return type json
  760. */
  761. private function deptSubmitCheck($talent_info, $companys) {
  762. if ($talent_info["pass_dept_check"] == 1)
  763. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  764. if (!in_array($this->user["companyId"], $companys))
  765. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  766. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  767. if (in_array($this->user["companyId"], $pass_companyIds))
  768. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  769. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $talent_info["first_dept_check_time"]);
  770. $over = $pass_companyIds ? count($pass_companyIds) : 0; //完成度,如果重审之前已有通过审核的部门,不用再审,直接按通过算
  771. $error = 0; //失败数
  772. $nowProcess = 3;
  773. if (!$dept_log)
  774. return json(["msg" => "未匹配日志,审核失败"]);
  775. if ($dept_log["state"] == $dept_log["new_state"])
  776. return json(["msg" => "请先保存审核状态,再提交审核"]);
  777. if ($dept_log["active"] == 1)
  778. return json(["msg" => "您的部门已经审核过了"]);
  779. $over++;
  780. if ($dept_log["new_state"] == TalentState::SCND_SUBMIT) {
  781. $error++;
  782. }
  783. $logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
  784. for ($i = 0; $i < count($logs); $i++) {
  785. if (!in_array($logs[$i]["companyId"], $pass_companyIds)) {
  786. $over += $logs[$i]["active"] == 1 ? 1 : 0;
  787. if ($logs[$i]["new_state"] == TalentState::SCND_SUBMIT) {
  788. $error++;
  789. }
  790. }
  791. }
  792. if ($over == count($companys)) {
  793. //全部已审核
  794. $checkState = TalentState::SCND_SUBMIT;
  795. $log_checkState = TalentState::DEPT_VERIFY_REJECT;
  796. if ($error == 0) {
  797. $log_checkState = $checkState = TalentState::DEPT_VERIFY_PASS;
  798. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  799. }
  800. $data["id"] = $talent_info["id"];
  801. $data["checkState"] = $checkState;
  802. $data["first_dept_check_time"] = null;
  803. TalentModel::update($data);
  804. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "部门审核结束", 1);
  805. }
  806. TalentLogApi::setActive($dept_log["id"], 1);
  807. return json(["code" => 200, "msg" => "审核成功"]);
  808. }
  809. /**
  810. * 复审-提交未保存
  811. * @param \think\Request $request
  812. * @param type $talent_info
  813. * @param type json
  814. */
  815. private function reCheck(\think\Request $request, $talent_info) {
  816. $params = $request->param();
  817. if ($params["checkState"] == 3) {
  818. //审核成功
  819. $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
  820. } else if ($params["checkState"] == 2) {
  821. //审核驳回并记录需要修改的字段和上传文件
  822. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  823. $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
  824. } else {
  825. $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
  826. }
  827. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  828. if (!$log)
  829. return json(["msg" => "日志数据异常,保存失败"]);
  830. if ($log["active"] == 0) {
  831. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  832. } else {
  833. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  834. }
  835. $data["id"] = $talent_info["id"];
  836. $data["modify_files"] = $params["files"];
  837. $data["modify_fields"] = $params["fields"];
  838. TalentModel::update($data);
  839. return json(["code" => 200, "msg" => "保存成功"]);
  840. }
  841. /**
  842. * 复审-提交审核
  843. * @param type $talent_info
  844. * @return type json
  845. */
  846. private function reSubmitCheck($talent_info) {
  847. return $this->commonSubmitCheck($talent_info, 4);
  848. }
  849. private function commonSubmitCheck($talent_info, $nowProcess) {
  850. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  851. if (!$log || $log["active"] == 1)
  852. return json(["msg" => "请先保存审核状态,再提交审核"]);
  853. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  854. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  855. }
  856. $smsapi = new ChuanglanSmsApi();
  857. if($log['last_state'] == 1){ //TODO 审核结果判断待强哥修复
  858. //基础信息审核通过,发送短信
  859. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核通过,请及时登录申报系统并进行人才认定的信息申报填写。";
  860. }else{
  861. //基础信息审核通过,发送短信
  862. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
  863. }
  864. $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
  865. $result = $smsapi->sendSMS($ep->agentPhone,$template);
  866. $result = json_decode($result,true);
  867. $id = getStringId();
  868. $record_data = [
  869. 'id' => $id,
  870. 'bizId' => $id,
  871. 'type' => 2,
  872. 'smsType' => 1,
  873. 'phone' => $ep->agentPhone,
  874. 'params' => '基础信息审核',
  875. 'templateCode' => $template,
  876. 'state' => $result['code'] == 0 ? 2 : 3,
  877. 'sendingDate' => date("Y-m-d H:i:s",time()),
  878. 'createTime' => date("Y-m-d H:i:s",time()),
  879. 'msg' => $result['errorMsg']
  880. ];
  881. MessageRecord::create($record_data);
  882. $data["id"] = $talent_info["id"];
  883. $data["checkState"] = $log["new_state"];
  884. TalentModel::update($data);
  885. TalentLogApi::setActive($log["id"], 1);
  886. return json(["code" => 200, "msg" => "审核成功"]);
  887. }
  888. public function check() {
  889. //公共调度方法
  890. $request = $this->request;
  891. $params = $request->param();
  892. $check = $params["checkState"];
  893. $check_msg = trim($params["checkMsg"]);
  894. $files = $params["files"];
  895. $fields = $params["fields"];
  896. $id = $params["id"];
  897. $talent_info = VerifyApi::getOne($id);
  898. $checkState = $talent_info["checkState"];
  899. if (!$talent_info) {
  900. return json(["msg" => "数据错误"]);
  901. }
  902. if (!$check) {
  903. return json(["msg" => "请选择审核状态"]);
  904. }
  905. if (!$check_msg) {
  906. return json(["msg" => "请填写审核说明"]);
  907. }
  908. if ($checkState == TalentState::FST_SUBMIT) {
  909. return $this->baseCheck($request, $talent_info);
  910. } else if ($checkState == TalentState::SCND_SUBMIT) {
  911. return $this->fstCheck($request, $talent_info);
  912. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  913. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  914. $companys = array_filter(explode(",", $condition["companyIds"]));
  915. if ($companys && $talent_info["pass_dept_check"] != 1) {
  916. if (!in_array($this->user["companyId"], $companys))
  917. return json(["msg" => "你的部门不在并审部门列表"]);
  918. return $this->deptCheck($request, $talent_info, $companys);
  919. } else {
  920. return $this->reCheck($request, $talent_info);
  921. }
  922. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  923. return $this->reCheck($request, $talent_info);
  924. } else {
  925. return json(["msg" => "不在审核范围内,保存失败"]);
  926. }
  927. }
  928. public function submitCheck() {
  929. //公共调度方法
  930. $id = $this->request->param("id");
  931. $talent_info = VerifyApi::getOne($id);
  932. $checkState = $talent_info["checkState"];
  933. if (!$talent_info) {
  934. return json(["msg" => "数据错误"]);
  935. }
  936. if ($checkState == TalentState::FST_SUBMIT) {
  937. return $this->baseSubmitCheck($talent_info);
  938. } else if ($checkState == TalentState::SCND_SUBMIT) {
  939. return $this->fstSubmitCheck($talent_info);
  940. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  941. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  942. $companys = array_filter(explode(",", $condition["companyIds"]));
  943. if ($companys && $talent_info["pass_dept_check"] != 1) {
  944. if (!in_array($this->user["companyId"], $companys))
  945. return json(["msg" => "你的部门不在并审部门列表"]);
  946. return $this->deptSubmitCheck($talent_info, $companys);
  947. } else {
  948. return $this->reSubmitCheck($talent_info);
  949. }
  950. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  951. return $this->reSubmitCheck($talent_info);
  952. } else {
  953. return json(["msg" => "不在审核范围内,审核失败"]);
  954. }
  955. }
  956. public function validateIsCheck() {
  957. $params = $this->request->param();
  958. $id = $params["id"];
  959. $talent_info = VerifyApi::getOne($id);
  960. if ($talent_info) {
  961. $checkState = $talent_info["checkState"];
  962. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
  963. $process = 0;
  964. if (in_array($checkState, [2, 6, 7, 9])) {
  965. switch ($checkState) {
  966. case 2:
  967. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  968. $fields = DictApi::getTalentFields(1);
  969. $field_tmp = [];
  970. foreach ($fields as $key => $field) {
  971. $field_tmp[] = ["key" => $key, "value" => $field];
  972. }
  973. $where[] = ["project", "=", 1];
  974. $where[] = ["step", "=", 1];
  975. $where[] = ["active", "=", 1];
  976. $where[] = ["type", "=", $enterprise["type"]];
  977. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  978. $process = 1;
  979. break;
  980. case 6:
  981. $fields = DictApi::getTalentFields(2);
  982. $process = 2;
  983. break;
  984. case 7:
  985. $tc = TalentConditionApi::getOne($talent_info["talent_condition"]);
  986. if ($tc["companyIds"] && $talent_info["pass_dept_check"] != 1) {
  987. $process = 3;
  988. $fields = DictApi::getTalentFields(3);
  989. } else {
  990. $process = 4;
  991. $fields = DictApi::getTalentFields(2);
  992. }
  993. break;
  994. case 9:
  995. $process = 4;
  996. $fields = DictApi::getTalentFields(2);
  997. break;
  998. }
  999. if ($checkState != 2) {
  1000. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  1001. //$fields = DictApi::getTalentFields(2);
  1002. $field_tmp = [];
  1003. if ($fields) {
  1004. foreach ($fields as $key => $field) {
  1005. $field_tmp[] = ["key" => $key, "value" => $field];
  1006. }
  1007. }
  1008. $where = [];
  1009. $whr = [];
  1010. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1011. $where[] = ["project", "=", 1];
  1012. $where[] = ["step", "=", 2];
  1013. $where[] = ["active", "=", 1];
  1014. $where[] = ["type", "=", $enterprise["type"]];
  1015. $where[] = ["isConditionFile", "<>", 1];
  1016. if ($process == 3) {
  1017. $where = [];
  1018. $cwfts = explode(";", $condition["companyWithFileType"]);
  1019. foreach ($cwfts as $cwft) {
  1020. $_company_setting = explode(":", $cwft);
  1021. if ($_company_setting[0] == $this->user["companyId"]) {
  1022. $where[] = ["id", "in", explode(",", $_company_setting[1])];
  1023. break;
  1024. }
  1025. }
  1026. if ($where) {
  1027. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1028. } else {
  1029. $files = [];
  1030. }
  1031. } else {
  1032. if ($condition && $condition["bindFileTypes"]) {
  1033. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  1034. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->select();
  1035. } else {
  1036. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1037. }
  1038. }
  1039. }
  1040. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  1041. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  1042. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files]]);
  1043. } else {
  1044. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  1045. }
  1046. }
  1047. }
  1048. public function findFieldsAndFiles() {
  1049. }
  1050. public function commonExport() {
  1051. $params = $this->request->param();
  1052. $fields = $params["export"];
  1053. if (!$fields)
  1054. return json(["msg" => "请选择要导出的数据"]);
  1055. $names = DictApi::getTalentFields(4);
  1056. $names["industryFieldNew"] = "产业领域";
  1057. $names["enterpriseName"] = "单位名称";
  1058. $names["enterpriseTag"] = "单位标签";
  1059. $names["street"] = "所属镇街";
  1060. $names["checkState"] = "审核状态";
  1061. $list = VerifyApi::getExportDatas($fields);
  1062. foreach ($fields as $field) {
  1063. $columns[] = $names[$field];
  1064. }
  1065. $datas = [];
  1066. for ($i = 0; $i < count($list); $i++) {
  1067. $data = [];
  1068. for ($n = 0; $n < count($fields); $n++) {
  1069. $data[] = $list[$i][$fields[$n]];
  1070. }
  1071. $datas[] = $data;
  1072. }
  1073. if ($datas) {
  1074. export($columns, $datas);
  1075. exit();
  1076. }
  1077. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  1078. }
  1079. public function getPhones() {
  1080. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1081. $result = [];
  1082. if ($list) {
  1083. foreach ($list as $item) {
  1084. if ($item["phone"] && $item["name"]) {
  1085. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  1086. }
  1087. }
  1088. }
  1089. return json(["code" => 200, "obj" => implode(";", $result)]);
  1090. }
  1091. public function getEnterprisePhones() {
  1092. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1093. $result = [];
  1094. if ($list) {
  1095. foreach ($list as $item) {
  1096. if ($item["agentName"] && $item["agentPhone"]) {
  1097. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  1098. }
  1099. }
  1100. }
  1101. return json(["code" => 200, "obj" => implode(";", $result)]);
  1102. }
  1103. }