Talent.php 65 KB

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