Talent.php 58 KB

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