Talent.php 68 KB

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