Talent.php 66 KB

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