Talent.php 64 KB

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