Talent.php 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505
  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. $un_check_companyIds = TalentLogApi::getUnCheckDepts($talent_info["id"]); //未审核提交的单位
  826. if (!in_array($this->user["companyId"], $un_check_companyIds))
  827. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  828. $params = $request->param();
  829. if ($params["checkState"] == 3) {
  830. //审核成功
  831. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  832. $checkState = TalentState::DEPT_VERIFY_PASS; //审核成功
  833. } else {
  834. //审核驳回并记录需要修改的字段和上传文件
  835. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  836. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  837. $talent_condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  838. if (!$talent_condition["companyWithFileType"])
  839. return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
  840. $cwfts = explode(";", $talent_condition["companyWithFileType"]);
  841. $company_setting = [];
  842. foreach ($cwfts as $cwft) {
  843. $_company_setting = explode(":", $cwft);
  844. if ($_company_setting[0] == $this->user["companyId"]) {
  845. $company_setting = explode(",", $_company_setting[1]);
  846. break;
  847. }
  848. }
  849. if (!$company_setting)
  850. return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
  851. //$data["modify_fields"] = $params["fields"];
  852. $original_modify_files = explode(",", $talent_info["modify_files"]);
  853. $_current_modify_files = explode(",", $params["files"]);
  854. $unselect_files = array_diff($company_setting, $_current_modify_files); //比较设置和当前提交的,取差值集,既是可选而未选的附件集合
  855. $new_modify_files = array_unique(array_merge($original_modify_files, $_current_modify_files)); //合并当前提交及库中原来保存的值
  856. foreach ($new_modify_files as $key => $item) {
  857. if (in_array($item, $unselect_files))
  858. unset($new_modify_files[$key]);
  859. }
  860. $data["modify_files"] = implode(",", array_unique($new_modify_files));
  861. }
  862. $fst_dept_check_time = $talent_info["first_dept_check_time"];
  863. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $fst_dept_check_time);
  864. if (!$dept_log)
  865. return json(["msg" => "未匹配日志,审核失败"]);
  866. if ($dept_log["active"] == 1)
  867. return json(["msg" => "您的部门已经审核过了"]);
  868. $data["id"] = $talent_info["id"];
  869. TalentModel::update($data);
  870. //修改日志
  871. TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  872. return json(["code" => 200, "msg" => "保存成功"]);
  873. }
  874. /**
  875. * 部门审核-提交审核
  876. * @param type $talent_info
  877. * @return type json
  878. */
  879. private function deptSubmitCheck($talent_info, $companys) {
  880. if ($talent_info["pass_dept_check"] == 1)
  881. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  882. if (!in_array($this->user["companyId"], $companys))
  883. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  884. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  885. if (in_array($this->user["companyId"], $pass_companyIds))
  886. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  887. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $talent_info["first_dept_check_time"]);
  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. if ($talent_info["re_check_companys"]) {
  895. $companys = array_filter(explode(",", $talent_info["re_check_companys"]));
  896. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"], $talent_info["first_dept_check_time"]); //重审单位中已经通过的单位
  897. }
  898. $over = $pass_companyIds ? count($pass_companyIds) : 0; //完成度,如果重审之前已有通过审核的部门,不用再审,直接按通过算
  899. $error = 0; //失败数
  900. $nowProcess = 4;
  901. $over++;
  902. if ($dept_log["new_state"] == TalentState::SCND_SUBMIT) {
  903. $error++;
  904. }
  905. $logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
  906. for ($i = 0; $i < count($logs); $i++) {
  907. if (!in_array($logs[$i]["companyId"], $pass_companyIds)) {
  908. $over += $logs[$i]["active"] == 1 ? 1 : 0;
  909. if ($logs[$i]["new_state"] == TalentState::SCND_SUBMIT) {
  910. $error++;
  911. }
  912. }
  913. }
  914. if ($over == count($companys)) {
  915. //全部已审核
  916. $checkState = TalentState::SCND_SUBMIT;
  917. $log_checkState = TalentState::DEPT_VERIFY_REJECT;
  918. if ($error == 0) {
  919. $log_checkState = $checkState = TalentState::DEPT_VERIFY_PASS;
  920. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  921. }
  922. $data["id"] = $talent_info["id"];
  923. $data["checkState"] = $checkState;
  924. $data["first_dept_check_time"] = null;
  925. $data["re_check_companys"] = null;
  926. TalentModel::update($data);
  927. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "部门审核结束", 1);
  928. if ($log_checkState == TalentState::DEPT_VERIFY_REJECT) {
  929. //部门驳回发送短信通知
  930. $privs = ["admin/talent/fst_check"];
  931. $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
  932. $where[] = ["menuid", "in", $menuIds];
  933. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
  934. $where = [];
  935. $where[] = ["status", "=", 1];
  936. $where[] = ["roleid", "in", $roleIds];
  937. $where[] = ["roleid", "<>", 1];
  938. $userIds = User::where($where)->column("id");
  939. $this->sendMsgByState($talent_info, $log_checkState, $userIds);
  940. }
  941. }
  942. TalentLogApi::setActive($dept_log["id"], 1);
  943. return json(["code" => 200, "msg" => "审核成功"]);
  944. }
  945. /**
  946. * 复审-提交未保存
  947. * @param \think\Request $request
  948. * @param type $talent_info
  949. * @param type json
  950. */
  951. private function reCheck(\think\Request $request, $talent_info) {
  952. $params = $request->param();
  953. if ($params["checkState"] == 3) {
  954. //审核成功
  955. $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
  956. } else if ($params["checkState"] == 2) {
  957. //审核驳回并记录需要修改的字段和上传文件
  958. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  959. $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
  960. } else {
  961. $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
  962. }
  963. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  964. if (!$log)
  965. return json(["msg" => "日志数据异常,保存失败"]);
  966. if ($log["active"] == 0) {
  967. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  968. } else {
  969. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  970. }
  971. $data["id"] = $talent_info["id"];
  972. $data["modify_files"] = $params["files"];
  973. $data["modify_fields"] = $params["fields"];
  974. TalentModel::update($data);
  975. return json(["code" => 200, "msg" => "保存成功"]);
  976. }
  977. /**
  978. * 复审-提交审核
  979. * @param type $talent_info
  980. * @return type json
  981. */
  982. private function reSubmitCheck($talent_info) {
  983. return $this->commonSubmitCheck($talent_info, 5);
  984. }
  985. private function commonSubmitCheck($talent_info, $nowProcess) {
  986. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  987. if (!$log || $log["active"] == 1)
  988. return json(["msg" => "请先保存审核状态,再提交审核"]);
  989. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  990. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  991. }
  992. $data["id"] = $talent_info["id"];
  993. $data["checkState"] = $log["new_state"];
  994. TalentModel::update($data);
  995. TalentLogApi::setActive($log["id"], 1);
  996. $userIds = [];
  997. if (in_array($data["checkState"], [TalentState::REVERIFY_PASS, TalentState::REVERIFY_REJECT])) {
  998. //复核成功需要发送短信给征信部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
  999. //从征信审核权限,逆推征信部门
  1000. if ($data["checkState"] == TalentState::REVERIFY_PASS) {
  1001. $privs = ["/admin/talent/hczxReject", "/admin/talent/hczxPass"];
  1002. } else {
  1003. $privs = ["admin/talent/fst_check"];
  1004. }
  1005. $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
  1006. $where = [];
  1007. $where[] = ["menuid", "in", $menuIds];
  1008. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
  1009. $where = [];
  1010. $where[] = ["status", "=", 1];
  1011. $where[] = ["roleid", "in", $roleIds];
  1012. $where[] = ["roleid", "<>", 1];
  1013. $userIds = User::where($where)->column("id");
  1014. }
  1015. $this->sendMsgByState($talent_info, $data["checkState"], $userIds);
  1016. return json(["code" => 200, "msg" => "审核成功"]);
  1017. }
  1018. private function sendMsgByState($talent_info, $state, $userIds = []) {
  1019. $phones = [];
  1020. $template = "";
  1021. $type = 0;
  1022. $processName = "";
  1023. $userId = 0;
  1024. $name = null;
  1025. switch ($state) {
  1026. case TalentState::BASE_VERIFY_PASS://基础信息审核通过发送短信通知用户
  1027. $type = 2;
  1028. $processName = "基础信息审核";
  1029. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核通过,请及时登录申报系统并进行人才认定的信息申报填写。";
  1030. break;
  1031. case TalentState::BASE_REJECT://基础信息审核驳回发送短信通知用户
  1032. $type = 2;
  1033. $processName = "基础信息审核";
  1034. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
  1035. break;
  1036. case TalentState::BASE_VERIFY_FAIL://基础信息审核不通过发送短信通知用户
  1037. $type = 2;
  1038. $processName = "基础信息审核";
  1039. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核不通过,原因是:{$log['description']}。";
  1040. break;
  1041. case TalentState::FST_VERIFY_PASS://初审通过发送短信通知并审部门
  1042. $type = 1;
  1043. $processName = "初级审核";
  1044. $template = "【晋江市人才服务平台】您的部门有新的人才认定申报需要审批,请及时登录审批系统处理。";
  1045. break;
  1046. case TalentState::FST_VERIFY_REJECT; //初审驳回发送短信通知用户
  1047. $type = 2;
  1048. $processName = "初级审核";
  1049. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
  1050. break;
  1051. case TalentState::FST_VERIFY_FAIL://初审不通过发送短信通知用户
  1052. $type = 2;
  1053. $processName = "初级审核";
  1054. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核不通过,原因是:{$log['description']}。";
  1055. break;
  1056. case TalentState::DEPT_VERIFY_REJECT://并审驳回发送短信通知初审部门
  1057. $type = 1;
  1058. $processName = "部门并审";
  1059. $template = "【晋江市人才服务平台】有人才认定申报在并审阶段被驳回,原因是:{$log['description']},请及时登录审批系统处理。";
  1060. break;
  1061. case TalentState::REVERIFY_PASS://复核通过发短信通知征信部门
  1062. $type = 1;
  1063. $processName = "复审";
  1064. $template = "【晋江市人才服务平台】有新的人才认定申报通过复审进入征信阶段,请及时登录审批系统处理。";
  1065. break;
  1066. case TalentState::REVERIFY_REJECT://复核驳回发短信通知初审部门
  1067. $type = 1;
  1068. $processName = "复审";
  1069. $template = "【晋江市人才服务平台】有人才认定申报在复审阶段被驳回,原因是:{$log['description']},请及时登录审批系统处理。";
  1070. break;
  1071. }
  1072. if ($type == 1) {
  1073. $where = [];
  1074. $where[] = ["id", "in", $userIds];
  1075. $phones = User::where($where)->column("phone");
  1076. $phones = array_unique(array_filter($phones));
  1077. }
  1078. if ($type == 2) {
  1079. $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
  1080. $phones[] = $ep->agentPhone;
  1081. $userId = $ep->id;
  1082. $name = $ep->name;
  1083. }
  1084. if ($phones && $template) {
  1085. while ($phone = array_shift($phones)) {
  1086. $smsapi = new ChuanglanSmsApi();
  1087. $result = $smsapi->sendSMS($phone, $template);
  1088. $result = json_decode($result, true);
  1089. $id = getStringId();
  1090. $record_data = [
  1091. 'id' => $id,
  1092. 'userId' => $userId,
  1093. 'bizId' => $id,
  1094. 'type' => $type,
  1095. 'smsType' => 2,
  1096. 'name' => $name,
  1097. 'phone' => $phone,
  1098. 'params' => $processName,
  1099. 'templateCode' => $template,
  1100. 'state' => $result['code'] == 0 ? 2 : 3,
  1101. 'sendingDate' => date("Y-m-d H:i:s", time()),
  1102. 'createTime' => date("Y-m-d H:i:s", time()),
  1103. 'msg' => $result['errorMsg']
  1104. ];
  1105. MessageRecord::create($record_data);
  1106. }
  1107. }
  1108. }
  1109. public function check() {
  1110. //公共调度方法
  1111. $request = $this->request;
  1112. $params = $request->param();
  1113. $check = $params["checkState"];
  1114. $check_msg = trim($params["checkMsg"]);
  1115. $files = $params["files"];
  1116. $fields = $params["fields"];
  1117. $id = $params["id"];
  1118. $talent_info = VerifyApi::getOne($id);
  1119. $checkState = $talent_info["checkState"];
  1120. if (!$talent_info) {
  1121. return json(["msg" => "数据错误"]);
  1122. }
  1123. if (!$check) {
  1124. return json(["msg" => "请选择审核状态"]);
  1125. }
  1126. if (!$check_msg) {
  1127. return json(["msg" => "请填写审核说明"]);
  1128. }
  1129. if ($checkState == TalentState::FST_SUBMIT) {
  1130. return $this->baseCheck($request, $talent_info);
  1131. } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
  1132. return $this->baseReCheck($request, $talent_info);
  1133. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1134. return $this->fstCheck($request, $talent_info);
  1135. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  1136. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1137. $companys = array_filter(explode(",", $condition["companyIds"]));
  1138. if ($companys && $talent_info["pass_dept_check"] != 1) {
  1139. if (!in_array($this->user["companyId"], $companys))
  1140. return json(["msg" => "你的部门不在并审部门列表"]);
  1141. return $this->deptCheck($request, $talent_info, $companys);
  1142. } else {
  1143. return $this->reCheck($request, $talent_info);
  1144. }
  1145. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  1146. return $this->reCheck($request, $talent_info);
  1147. } else {
  1148. return json(["msg" => "不在审核范围内,保存失败"]);
  1149. }
  1150. }
  1151. public function submitCheck() {
  1152. //公共调度方法
  1153. $id = $this->request->param("id");
  1154. $talent_info = VerifyApi::getOne($id);
  1155. $checkState = $talent_info["checkState"];
  1156. if (!$talent_info) {
  1157. return json(["msg" => "数据错误"]);
  1158. }
  1159. if ($checkState == TalentState::FST_SUBMIT) {
  1160. return $this->baseSubmitCheck($talent_info);
  1161. } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
  1162. return $this->baseReSubmitCheck($talent_info);
  1163. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1164. return $this->fstSubmitCheck($talent_info);
  1165. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  1166. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1167. $companys = array_filter(explode(",", $condition["companyIds"]));
  1168. if ($companys && $talent_info["pass_dept_check"] != 1) {
  1169. if (!in_array($this->user["companyId"], $companys))
  1170. return json(["msg" => "你的部门不在并审部门列表"]);
  1171. return $this->deptSubmitCheck($talent_info, $companys);
  1172. } else {
  1173. return $this->reSubmitCheck($talent_info);
  1174. }
  1175. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  1176. return $this->reSubmitCheck($talent_info);
  1177. } else {
  1178. return json(["msg" => "不在审核范围内,审核失败"]);
  1179. }
  1180. }
  1181. public function validateIsCheck() {
  1182. $params = $this->request->param();
  1183. $id = $params["id"];
  1184. $talent_info = VerifyApi::getOne($id);
  1185. $fstLog = TalentLogApi::getFstLog($id, 1);
  1186. $isMix = false;
  1187. if (in_array($fstLog["state"], [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT])) {
  1188. //初次提交是待初审状态,则为新的混合基础信息和人才认证信息的申报
  1189. $isMix = true;
  1190. }
  1191. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  1192. if ($talent_info) {
  1193. $checkState = $talent_info["checkState"];
  1194. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5基审复核通过 6基审复核驳回 7基审复核失败 8保存补充材料未提交 9提交补充材料进入初审 10初审通过 11初审驳回 12部门审核通过 13部门审核驳回 14复核通过 15复核驳回 16复核失败
  1195. $process = 0;
  1196. if (in_array($checkState, [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS])) {
  1197. switch ($checkState) {
  1198. case TalentState::FST_SUBMIT:
  1199. $fields = DictApi::getTalentFields(1);
  1200. $field_tmp = [];
  1201. foreach ($fields as $key => $field) {
  1202. $field_tmp[] = ["key" => $key, "value" => $field];
  1203. }
  1204. $where[] = ["project", "=", 1];
  1205. $where[] = ["step", "=", 1];
  1206. $where[] = ["active", "=", 1];
  1207. $where[] = ["type", "=", $enterprise["type"]];
  1208. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1209. /* foreach ($files as $key => $file) {
  1210. $options = array_filter(explode(",", $file["option"]));
  1211. if ($options) {
  1212. switch ($file["rel"]) {
  1213. case "talent_type":
  1214. $allow_tags = array_filter(explode(",", $file["enterprise_tag"]));
  1215. if ($allow_tags && !in_array($enterprise["enterpriseTag"], $allow_tags)) {
  1216. unset($files[$key]);
  1217. break;
  1218. }
  1219. if (!in_array($talent_info["talent_type"], $options)) {
  1220. unset($files[$key]);
  1221. break;
  1222. }
  1223. break;
  1224. case "birthday":
  1225. $birthYear = substr($talent_info["birthday"], 0, 4);
  1226. $currentYear = date("Y");
  1227. $age = $currentYear - $birthYear;
  1228. if ($age < $options[0]) {
  1229. unset($files[$key]);
  1230. break;
  1231. }
  1232. break;
  1233. }
  1234. }
  1235. } */
  1236. $process = 1;
  1237. break;
  1238. case TalentState::BASE_VERIFY_PASS:
  1239. $fields = DictApi::getTalentFields(1);
  1240. $field_tmp = [];
  1241. foreach ($fields as $key => $field) {
  1242. $field_tmp[] = ["key" => $key, "value" => $field];
  1243. }
  1244. $where[] = ["project", "=", 1];
  1245. $where[] = ["step", "=", 1];
  1246. $where[] = ["active", "=", 1];
  1247. $where[] = ["type", "=", $enterprise["type"]];
  1248. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1249. $process = 2;
  1250. break;
  1251. case TalentState::SCND_SUBMIT:
  1252. $fields = DictApi::getTalentFields(2);
  1253. $process = 3;
  1254. break;
  1255. case TalentState::FST_VERIFY_PASS:
  1256. $tc = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1257. if ($tc["companyIds"] && $talent_info["pass_dept_check"] != 1) {
  1258. $process = 4;
  1259. $fields = DictApi::getTalentFields(3);
  1260. } else {
  1261. $process = 5;
  1262. $fields = DictApi::getTalentFields(2);
  1263. }
  1264. break;
  1265. case TalentState::DEPT_VERIFY_PASS:
  1266. $process = 5;
  1267. $fields = DictApi::getTalentFields(2);
  1268. break;
  1269. }
  1270. if ($isMix) {
  1271. if ($enterprise["type"] == 2) {
  1272. $fields = DictApi::getTalentFields_IC();
  1273. } else {
  1274. $fields = DictApi::getTalentFields(4);
  1275. }
  1276. }
  1277. if ($checkState != TalentState::FST_SUBMIT) {
  1278. //$fields = DictApi::getTalentFields(2);
  1279. $field_tmp = [];
  1280. if ($fields) {
  1281. foreach ($fields as $key => $field) {
  1282. $field_tmp[] = ["key" => $key, "value" => $field];
  1283. }
  1284. }
  1285. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1286. $companys = array_filter(explode(",", $condition["companyIds"]));
  1287. $_companys = [];
  1288. foreach ($companys as $companyId) {
  1289. $company = CompanyApi::getOne($companyId);
  1290. $_companys[] = $company;
  1291. }
  1292. if ($process == 4 && $enterprise["type"] == 1) {
  1293. $where = [];
  1294. $where[] = ["delete", "=", 0];
  1295. $cwfts = explode(";", $condition["companyWithFileType"]);
  1296. foreach ($cwfts as $cwft) {
  1297. $_company_setting = explode(":", $cwft);
  1298. if ($_company_setting[0] == $this->user["companyId"]) {
  1299. $where[] = ["id", "in", explode(",", $_company_setting[1])];
  1300. break;
  1301. }
  1302. }
  1303. if ($where) {
  1304. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1305. } else {
  1306. $files = [];
  1307. }
  1308. } else {
  1309. $where = [];
  1310. $whr = [];
  1311. if (!$isMix) {
  1312. $where[] = ["step", "=", 2];
  1313. }
  1314. $where[] = ["project", "=", 1];
  1315. $where[] = ["active", "=", 1];
  1316. $where[] = ["type", "=", $enterprise["type"]];
  1317. $where[] = ["isConditionFile", "<>", 1];
  1318. $where[] = ["delete", "=", 0];
  1319. if ($condition && $condition["bindFileTypes"]) {
  1320. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  1321. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->select();
  1322. } else {
  1323. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1324. }
  1325. }
  1326. }
  1327. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  1328. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  1329. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files, "companys" => $_companys]]);
  1330. } else {
  1331. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  1332. }
  1333. }
  1334. }
  1335. public function findFieldsAndFiles() {
  1336. }
  1337. public function baseVerifyListExport() {
  1338. $this->commonExport(1);
  1339. }
  1340. public function baseReverifyListExport() {
  1341. $this->commonExport(2);
  1342. }
  1343. public function fstVerifyListExport() {
  1344. $this->commonExport(3);
  1345. }
  1346. public function deptVerifyListExport() {
  1347. $this->commonExport(4);
  1348. }
  1349. public function reVerifyListExport() {
  1350. $this->commonExport(5);
  1351. }
  1352. public function preListExport() {
  1353. $this->commonExport(6);
  1354. }
  1355. private function commonExport($process) {
  1356. $params = $this->request->param();
  1357. $fields = $params["export"];
  1358. if (!$fields)
  1359. return json(["msg" => "请选择要导出的数据"]);
  1360. $names = DictApi::getTalentFields(4);
  1361. $names["industryFieldNew"] = "产业领域";
  1362. $names["enterpriseName"] = "单位名称";
  1363. $names["enterpriseTag"] = "单位标签";
  1364. $names["street"] = "所属镇街";
  1365. $names["checkState"] = "审核状态";
  1366. $names["checkMsg"] = "审核意见";
  1367. $list = VerifyApi::getExportDatas($process, $fields);
  1368. foreach ($fields as $field) {
  1369. $columns[] = $names[$field];
  1370. }
  1371. $datas = [];
  1372. for ($i = 0; $i < count($list); $i++) {
  1373. $data = [];
  1374. for ($n = 0; $n < count($fields); $n++) {
  1375. $data[] = $list[$i][$fields[$n]];
  1376. }
  1377. $datas[] = $data;
  1378. }
  1379. if ($datas) {
  1380. export($columns, $datas);
  1381. exit();
  1382. }
  1383. echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
  1384. }
  1385. public function getPhones() {
  1386. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1387. $result = [];
  1388. if ($list) {
  1389. foreach ($list as $item) {
  1390. if ($item["phone"] && $item["name"]) {
  1391. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  1392. }
  1393. }
  1394. }
  1395. return json(["code" => 200, "obj" => implode(";", $result)]);
  1396. }
  1397. public function getEnterprisePhones() {
  1398. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1399. $result = [];
  1400. if ($list) {
  1401. foreach ($list as $item) {
  1402. if ($item["agentName"] && $item["agentPhone"]) {
  1403. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  1404. }
  1405. }
  1406. }
  1407. return json(["code" => 200, "obj" => implode(";", $result)]);
  1408. }
  1409. }