Talent.php 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416
  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. $process = 1;
  1168. break;
  1169. case TalentState::BASE_VERIFY_PASS:
  1170. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  1171. $fields = DictApi::getTalentFields(1);
  1172. $field_tmp = [];
  1173. foreach ($fields as $key => $field) {
  1174. $field_tmp[] = ["key" => $key, "value" => $field];
  1175. }
  1176. $where[] = ["project", "=", 1];
  1177. $where[] = ["step", "=", 1];
  1178. $where[] = ["active", "=", 1];
  1179. $where[] = ["type", "=", $enterprise["type"]];
  1180. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1181. $process = 2;
  1182. break;
  1183. case TalentState::SCND_SUBMIT:
  1184. $fields = DictApi::getTalentFields(2);
  1185. $process = 3;
  1186. break;
  1187. case TalentState::FST_VERIFY_PASS:
  1188. $tc = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1189. if ($tc["companyIds"] && $talent_info["pass_dept_check"] != 1) {
  1190. $process = 4;
  1191. $fields = DictApi::getTalentFields(3);
  1192. } else {
  1193. $process = 5;
  1194. $fields = DictApi::getTalentFields(2);
  1195. }
  1196. break;
  1197. case TalentState::DEPT_VERIFY_PASS:
  1198. $process = 5;
  1199. $fields = DictApi::getTalentFields(2);
  1200. break;
  1201. }
  1202. if ($checkState != TalentState::FST_SUBMIT) {
  1203. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  1204. //$fields = DictApi::getTalentFields(2);
  1205. $field_tmp = [];
  1206. if ($fields) {
  1207. foreach ($fields as $key => $field) {
  1208. $field_tmp[] = ["key" => $key, "value" => $field];
  1209. }
  1210. }
  1211. $where = [];
  1212. $whr = [];
  1213. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1214. $where[] = ["project", "=", 1];
  1215. $where[] = ["step", "=", 2];
  1216. $where[] = ["active", "=", 1];
  1217. $where[] = ["type", "=", $enterprise["type"]];
  1218. $where[] = ["isConditionFile", "<>", 1];
  1219. if ($process == 4) {
  1220. $where = [];
  1221. $cwfts = explode(";", $condition["companyWithFileType"]);
  1222. foreach ($cwfts as $cwft) {
  1223. $_company_setting = explode(":", $cwft);
  1224. if ($_company_setting[0] == $this->user["companyId"]) {
  1225. $where[] = ["id", "in", explode(",", $_company_setting[1])];
  1226. break;
  1227. }
  1228. }
  1229. if ($where) {
  1230. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1231. } else {
  1232. $files = [];
  1233. }
  1234. } else {
  1235. if ($condition && $condition["bindFileTypes"]) {
  1236. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  1237. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->select();
  1238. } else {
  1239. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1240. }
  1241. }
  1242. }
  1243. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  1244. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  1245. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files]]);
  1246. } else {
  1247. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  1248. }
  1249. }
  1250. }
  1251. public function findFieldsAndFiles() {
  1252. }
  1253. public function baseVerifyListExport() {
  1254. $this->commonExport(1);
  1255. }
  1256. public function fstVerifyListExport() {
  1257. $this->commonExport(3);
  1258. }
  1259. public function deptVerifyListExport() {
  1260. $this->commonExport(4);
  1261. }
  1262. public function reVerifyListExport() {
  1263. $this->commonExport(5);
  1264. }
  1265. public function preListExport() {
  1266. $this->commonExport(6);
  1267. }
  1268. private function commonExport($process) {
  1269. $params = $this->request->param();
  1270. $fields = $params["export"];
  1271. if (!$fields)
  1272. return json(["msg" => "请选择要导出的数据"]);
  1273. $names = DictApi::getTalentFields(4);
  1274. $names["industryFieldNew"] = "产业领域";
  1275. $names["enterpriseName"] = "单位名称";
  1276. $names["enterpriseTag"] = "单位标签";
  1277. $names["street"] = "所属镇街";
  1278. $names["checkState"] = "审核状态";
  1279. $names["checkMsg"] = "审核意见";
  1280. $list = VerifyApi::getExportDatas($process, $fields);
  1281. foreach ($fields as $field) {
  1282. $columns[] = $names[$field];
  1283. }
  1284. $datas = [];
  1285. for ($i = 0; $i < count($list); $i++) {
  1286. $data = [];
  1287. for ($n = 0; $n < count($fields); $n++) {
  1288. $data[] = $list[$i][$fields[$n]];
  1289. }
  1290. $datas[] = $data;
  1291. }
  1292. if ($datas) {
  1293. export($columns, $datas);
  1294. exit();
  1295. }
  1296. echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
  1297. }
  1298. public function getPhones() {
  1299. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1300. $result = [];
  1301. if ($list) {
  1302. foreach ($list as $item) {
  1303. if ($item["phone"] && $item["name"]) {
  1304. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  1305. }
  1306. }
  1307. }
  1308. return json(["code" => 200, "obj" => implode(";", $result)]);
  1309. }
  1310. public function getEnterprisePhones() {
  1311. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1312. $result = [];
  1313. if ($list) {
  1314. foreach ($list as $item) {
  1315. if ($item["agentName"] && $item["agentPhone"]) {
  1316. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  1317. }
  1318. }
  1319. }
  1320. return json(["code" => 200, "obj" => implode(";", $result)]);
  1321. }
  1322. }