Talent.php 63 KB

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