Talent.php 95 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030
  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\controller\Api;
  9. use app\common\model\MessageRecord;
  10. use app\enterprise\model\Talent as TalentModel;
  11. use app\common\api\TalentConditionApi;
  12. use app\common\api\DictApi;
  13. use app\common\api\EnterpriseApi;
  14. use think\facade\Db;
  15. use app\admin\model\User;
  16. use app\common\api\MenuApi;
  17. use app\admin\model\Menu;
  18. use app\admin\model\SysRelation;
  19. use app\common\api\CompanyApi;
  20. use app\common\state\ProjectState;
  21. use app\admin\api\RsApi;
  22. use app\admin\model\ApiData;
  23. use app\common\state\CommonConst;
  24. /**
  25. * Description of Talent
  26. *
  27. * @author sgq
  28. */
  29. class Talent extends AdminController {
  30. public function common_check() {
  31. $request = $this->request;
  32. $params = $request->param();
  33. $id = $params["id"];
  34. $process = $params["process"];
  35. $info = VerifyApi::getTalentInfoById($id, true);
  36. $force = intval($this->request['force'], 0);
  37. $api_data = ApiData::where('uid', '=', $info['card_number'])->where('action', '=', 'rending')->where('status', '=', 1)->find(); //
  38. if ($force || !$api_data || !$api_data['status']) {
  39. ApiData::where('uid', '=', $info['card_number'])->where('action', '=', 'rending')->where('status', '=', 1)->update(['status' => 0, 'updateTime' => time()]);
  40. $rsapi = new RsApi();
  41. if ($info['card_type'] == 1) {
  42. $content = [];
  43. $info['rs']['I010902'] = $content['I010902'] = $rsapi->I010902($info['card_number']);
  44. $info['rs']['I030101'] = $content['I030101'] = $rsapi->I030101($info['card_number']);
  45. /* * ***********************处理养老缴费判断开始*************** */
  46. if (!empty($info['tax_insurance_month'])) {
  47. $tmp_time = explode(' - ', $info['tax_insurance_month']);
  48. $content['YL00018'] = $rsapi->YL00018($info['card_number'], str_replace('-', '', $tmp_time[0]), str_replace('-', '', $tmp_time[1]));
  49. $formatDate = formatDateByMonth($tmp_time[0], $tmp_time[1], $content['YL00018']['data']['list']);
  50. $str = '';
  51. foreach ($formatDate as $tmp_item) {
  52. $str .= $tmp_item . "<br />";
  53. }
  54. if (count($formatDate) == $content['YL00018']['data']['totalCount']) {
  55. $content['YL00018']['status'] = 'success';
  56. } else {
  57. $content['YL00018']['status'] = 'warning';
  58. }
  59. $content['YL00018']['content'] = "该人员社保填写日期为{$tmp_time[0]}至{$tmp_time[1]},共" . count($formatDate) . "个月,接口返回{$content['YL00018']['data']['totalCount']}个月数据,分别为:<br />$str";
  60. $info['rs']['YL00018'] = $content['YL00018'];
  61. unset($tmp_time);
  62. unset($tmp_item);
  63. }
  64. /* * ***********************处理养老缴费判断结束*************** */
  65. /* * ***********************处理职业资格证书开始*************** */
  66. if (!empty($info['pro_qua'])) {
  67. $content['SBJ0007'] = $rsapi->SBJ0007($info['name'], $info['card_number']);
  68. if ($content['SBJ0007']['data']['totalCount'] > 0) {
  69. $tmp_str = '';
  70. foreach ($content['SBJ0007']['data']['list'] as $tmp_item) {
  71. $tmp_str .= "职业资格名称:{$tmp_item['ksmc']};级别名称:{$tmp_item['jbmc']};专业名称:{$tmp_item['zymc']}<br />";
  72. }
  73. $content['SBJ0007']['content'] = "该人员共有{$content['SBJ0007']['data']['totalCount']}条职业资格证书记录,分别为:<br />{$tmp_str}";
  74. } else {
  75. $content['SBJ0007']['content'] = "该人员查不到职业资格证书记录";
  76. }
  77. $info['rs']['SBJ0007'] = $content['SBJ0007'];
  78. }
  79. /* * ***********************处理职业资格证书结束*************** */
  80. /* * ***********************处理高校教育信息开始*************** */
  81. if (!empty($info['highest_degree'])) {
  82. $content['SBJ0004'] = $rsapi->SBJ0004($info['name'], $info['card_number']);
  83. if ($content['SBJ0004']['data']['totalCount'] > 0) {
  84. $tmp_str = '';
  85. foreach ($content['SBJ0004']['data']['list'] as $tmp_item) {
  86. $tmp_str .= "层次:{$tmp_item['cc']};毕业学校名称:{$tmp_item['yxmc']}({$tmp_item['rxrq']}-{$tmp_item['byrq']});专业名称:{$tmp_item['zymc']};学习形式:{$tmp_item['xxxs']};编号:{$tmp_item['zsbh']}<br />";
  87. }
  88. $content['SBJ0004']['content'] = "该人员共有{$content['SBJ0004']['data']['totalCount']}条高校教育,分别为:<br />{$tmp_str}";
  89. } else {
  90. $content['SBJ0004']['content'] = "该人员查不到高校教育信息";
  91. }
  92. $info['rs']['SBJ0004'] = $content['SBJ0004'];
  93. }
  94. /* * ***********************处理高校教育信息结束*************** */
  95. $api_model_data = [
  96. 'uid' => $info['card_number'],
  97. 'action' => 'rending',
  98. 'content' => serialize($content),
  99. 'createTime' => time()
  100. ];
  101. ApiData::create($api_model_data);
  102. }
  103. } else {
  104. $content = unserialize($api_data['content']);
  105. if (array_key_exists('YL00018', $content)) {
  106. $tmp_time = explode(' - ', $info['tax_insurance_month']);
  107. $formatDate = formatDateByMonth($tmp_time[0], $tmp_time[1], $content['YL00018']['data']['list']);
  108. $str = '';
  109. foreach ($formatDate as $tmp_item) {
  110. $str .= $tmp_item . "<br />";
  111. }
  112. if (count($formatDate) == $content['YL00018']['data']['totalCount']) {
  113. $content['YL00018']['status'] = 'success';
  114. } else {
  115. $content['YL00018']['status'] = 'warning';
  116. }
  117. $content['YL00018']['content'] = "该人员社保填写日期为{$tmp_time[0]}至{$tmp_time[1]},共" . count($formatDate) . "个月,接口返回{$content['YL00018']['data']['totalCount']}个月数据,分别为:<br />$str";
  118. unset($tmp_time);
  119. unset($tmp_item);
  120. } else {
  121. $content['YL00018'] = [];
  122. }
  123. $info['rs'] = $content;
  124. }
  125. $info["process"] = $process;
  126. if ($process == 7) {
  127. //如果有变更记录,这此处获取最初一条记录的旧值并覆盖$info中的新值
  128. }
  129. if (in_array($info["checkState"], [TalentState::BASE_VERIFY_FAIL, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_REJECT, TalentState::BASE_REVERIFY_FAIL])) {
  130. return view("talentInfo_base_check", ["info" => $info]);
  131. } else {
  132. switch ($info["enterpriseType"]) {
  133. case CommonConst::ENTERPRISE_NORMAL:
  134. $tpl = "talentInfo_common_check"; //$info["isImport"] ? "nofile_talentInfo_common_check" : "talentInfo_common_check";
  135. return view($tpl, ["info" => $info]);
  136. case CommonConst::ENTERPRISE_JC:
  137. return view("talentInfo_common_checkIC", ["info" => $info]);
  138. case CommonConst::ENTERPRISE_WJ:
  139. return view("/talent/hospital/talentInfo_common_check", ["info" => $info]);
  140. case CommonConst::ENTERPRISE_GJ:
  141. return view("/talent/school/talentInfo_common_check", ["info" => $info]);
  142. }
  143. }
  144. }
  145. public function getTalentInfoByIdCard() {
  146. $card_number = $this->request->param("idCard");
  147. $card_type = $this->request->param("cardType");
  148. $where = [];
  149. $where[] = ["ti.card_type", "=", $card_type];
  150. $where[] = ["ti.card_number", "=", $card_number];
  151. $where[] = ["ti.delete", "=", 0];
  152. $list = TalentModel::alias("ti")
  153. ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
  154. ->leftJoin("(select mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=1 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ti.id")
  155. ->where($where)->order("ti.createTime desc")->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterpriseName")->select()->toArray();
  156. foreach ($list as $key => $item) {
  157. $list[$key]["checkStateName"] = TalentState::getStateName($item["realState"]);
  158. }
  159. return json(["rows" => $list]);
  160. }
  161. public function cancel_verify() {
  162. $params = $this->request->param();
  163. $ids = $params["ids"];
  164. $msg = $params["msg"];
  165. if ($msg == "") {
  166. return json(["msg" => "请填写审核不通过的原因"]);
  167. }
  168. $ids_arr = array_filter(explode(",", $ids));
  169. $counts = 0;
  170. foreach ($ids_arr as $id) {
  171. $ti = VerifyApi::getOne($id);
  172. $data["id"] = $id;
  173. if ($ti["checkState"] == TalentState::FST_SUBMIT) {
  174. $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
  175. TalentLogApi::write(1, $id, TalentState::BASE_VERIFY_FAIL, $msg, 1);
  176. TalentModel::update($data);
  177. $counts++;
  178. } else if ($ti["checkState"] == TalentState::SCND_SUBMIT) {
  179. $data["checkState"] = TalentState::FST_VERIFY_FAIL;
  180. TalentLogApi::write(1, $id, TalentState::FST_VERIFY_FAIL, $msg, 1);
  181. TalentModel::update($data);
  182. $counts++;
  183. } else {
  184. return json(["msg" => "不在审核范围"]);
  185. }
  186. }
  187. return json(["code" => 200, "msg" => sprintf("%d个申请已审核不通过", $counts)]);
  188. }
  189. public function base_verify() {
  190. $enterprises = EnterpriseApi::getSimpleList();
  191. return view("", ["enterprises" => $enterprises]);
  192. }
  193. public function base_verify_list() {
  194. $params = $this->request->param();
  195. return json(VerifyApi::getList($params));
  196. }
  197. public function base_reverify() {
  198. $enterprises = EnterpriseApi::getSimpleList();
  199. return view("", ["enterprises" => $enterprises]);
  200. }
  201. public function base_reverify_list() {
  202. $params = $this->request->param();
  203. return json(VerifyApi::getList($params));
  204. }
  205. /**
  206. * 部门初审
  207. * @auth {{/talentInfo/gotoIndex/-1}}
  208. */
  209. public function dept_fst_verify() {
  210. return view();
  211. }
  212. /**
  213. * 初审
  214. * @auth {{/talentInfo/gotoIndex/1}}
  215. */
  216. public function fst_verify() {
  217. $tpl = "";
  218. $assigns = $this->getCommonAssigns();
  219. switch ($this->user["type"]) {
  220. case CommonConst::ENTERPRISE_WJ:
  221. $tpl = "/talent/hospital/fst_verify";
  222. $medicalCommunities = \app\common\api\Nhc::getMedicalCommunityList();
  223. $_assigns = ["medicalCommunities" => $medicalCommunities];
  224. $assigns = array_merge($assigns, $_assigns);
  225. break;
  226. }
  227. return view($tpl, $assigns);
  228. }
  229. /**
  230. * 初审-审核
  231. * @auth {{/talentInfo/firstCheck}}
  232. */
  233. public function fst_check() {
  234. }
  235. /**
  236. * 初审-审核不通过
  237. * @auth {{/talentInfo/setNotPass}}
  238. */
  239. public function dis_pass() {
  240. }
  241. /**
  242. * 部门审核
  243. * @auth {{/talentInfo/gotoIndex/2}}
  244. */
  245. public function dept_verify() {
  246. $tpl = "";
  247. $companys = CompanyApi::getAll();
  248. $superpriv = VerifyApi::chkUserInSuperDeptUsers();
  249. $commonAssigns = $this->getCommonAssigns();
  250. $assigns = ["companys" => $companys, "superpriv" => $superpriv];
  251. $newAssigns = array_merge($assigns, $commonAssigns);
  252. switch ($this->user["type"]) {
  253. case CommonConst::ENTERPRISE_WJ:
  254. $tpl = "/talent/hospital/dept_verify";
  255. $medicalCommunities = \app\common\api\Nhc::getMedicalCommunityList();
  256. $newAssigns["medicalCommunities"] = $medicalCommunities;
  257. break;
  258. }
  259. return view($tpl, $newAssigns);
  260. }
  261. /**
  262. * 复审
  263. * @auth {{/talentInfo/gotoIndex/3}}
  264. */
  265. public function re_verify() {
  266. $tpl = "";
  267. $assigns = $this->getCommonAssigns();
  268. switch ($this->user["type"]) {
  269. case CommonConst::ENTERPRISE_WJ:
  270. $tpl = "/talent/hospital/re_verify";
  271. $medicalCommunities = \app\common\api\Nhc::getMedicalCommunityList();
  272. $_assigns = ["medicalCommunities" => $medicalCommunities];
  273. $assigns = array_merge($assigns, $_assigns);
  274. break;
  275. }
  276. return view($tpl, $assigns);
  277. }
  278. /**
  279. * 复审-撤销复核
  280. * @auth {{/talentInfo/cancleThirdCheck}}
  281. */
  282. public function cancel_check() {
  283. }
  284. /**
  285. * 预备人才库
  286. * @auth {{/talentInfo/gotoIndex/4}}
  287. */
  288. public function pre_list() {
  289. if ($this->user["type"] == 1) {
  290. $message = [
  291. "typeName" => "晋江市现代产业体系人才认定", "address" => "聚才网/人才晋江微信公众号", "dep" => "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心",
  292. "phone" => "0595-85633128", "email" => "jjrc85661234@163.com"
  293. ];
  294. } else {
  295. $message = [
  296. "typeName" => "晋江市集成电路产业优秀人才认定", "address" => "福建(晋江)集成电路产业园官方网站及微信公众号", "dep" => "集成电路产业园区",
  297. "phone" => "0595-82250007、0595-82250001", "email" => "jjjcdr@163.com"
  298. ];
  299. }
  300. $commonAssigns = $this->getCommonAssigns();
  301. $assigns = ["message" => $message];
  302. $newAssigns = array_merge($assigns, $commonAssigns);
  303. return view("", $newAssigns);
  304. }
  305. private function getCommonAssigns() {
  306. $type = $this->user["type"];
  307. $enterprises = EnterpriseApi::getSimpleList();
  308. $conditions = TalentConditionApi::getList([1, 2, 3, 4, 5, 6, 7], $type);
  309. $industry_field_new = array_column(DictApi::findChildDictByCode("industry_field"), "code");
  310. foreach ($industry_field_new as &$field) {
  311. $field .= "_field";
  312. }
  313. $parent_industry_fields = implode(",", $industry_field_new);
  314. $where[] = ["d2.code", "in", $parent_industry_fields];
  315. $industry_field_old = \app\common\model\Dict::alias("d1")->field("d1.*,d2.`name` as pname")->leftJoin("new_talent_dict d2", "d1.pid=d2.id")->order("name asc")->where($where)->select();
  316. return ["type" => $type, "enterprises" => $enterprises, "talent_conditions" => $conditions, "industry_field_old" => $industry_field_old];
  317. }
  318. /**
  319. * 优秀人才库
  320. * @auth {{/talentInfo/gotoIndex/5}}
  321. */
  322. public function library() {
  323. return view("", $this->getCommonAssigns());
  324. }
  325. public function selectNeedCheckData() {
  326. $params = $this->request->param();
  327. return json(["rows" => VerifyApi::getPublicList($params)]);
  328. }
  329. /**
  330. * 预备人才库-核查征信
  331. * @auth {{/talentInfo/prepareHczx}}
  332. */
  333. public function prepareHczx() {
  334. $ids = $this->request->param("ids");
  335. $ids_arr = array_filter(explode(",", $ids));
  336. if (!$ids_arr) {
  337. $res = ["code" => 500, "msg" => "没有选择导出的名单"];
  338. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  339. }
  340. $where[] = ["ti.id", "in", $ids_arr];
  341. $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();
  342. if (!$list) {
  343. $res = ["code" => 500, "msg" => "没有可以导出的内容"];
  344. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  345. }
  346. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  347. $rows = [];
  348. $i = 1;
  349. $card_types = DictApi::selectByParentCode("card_type");
  350. foreach ($list as $item) {
  351. $row = [
  352. $i, $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], $item["description"]
  353. ];
  354. $rows[] = $row;
  355. $i++;
  356. }
  357. $filename = "现代产业体系人才核查征信名单导出";
  358. if ($rows) {
  359. export($columns, $rows, $filename);
  360. exit();
  361. }
  362. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  363. }
  364. /**
  365. * 预备人才库-征信通过
  366. * @auth {{/talentInfo/hczxPass}}
  367. */
  368. public function hczxPass() {
  369. $params = $this->request->param();
  370. $ids = $params["ids"];
  371. $ids = array_filter(explode(",", $ids));
  372. $msg = "征信通过";
  373. $state = TalentState::ZX_PASS; //征信通过
  374. $total = count($ids);
  375. $error = 0;
  376. $success = 0;
  377. foreach ($ids as $id) {
  378. $talent_info = VerifyApi::getOne($id);
  379. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  380. $error++;
  381. continue;
  382. }
  383. if (VerifyApi::setPublic($id, $state, $msg)) {
  384. $success++;
  385. } else {
  386. $error++;
  387. }
  388. }
  389. return json(["code" => 200, "msg" => sprintf("核查征信完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  390. }
  391. /**
  392. * 预备人才库-征信失信
  393. * @auth {{/talentInfo/hczxReject}}
  394. */
  395. public function hczxReject() {
  396. $params = $this->request->param();
  397. $id = $params["id"];
  398. $msg = $params["outMsg"];
  399. if (!$msg)
  400. return json(["msg" => "请填写审核意见"]);
  401. $msg = "征信失信:" . $msg;
  402. $state = TalentState::ZX_FAIL; //征信不通过
  403. $talent_info = VerifyApi::getOne($id);
  404. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  405. return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
  406. }
  407. if (VerifyApi::setPublic($id, $state, $msg)) {
  408. return json(["code" => 200, "msg" => "已设置征信失信"]);
  409. }
  410. return json(["msg" => "设置征信失信失败"]);
  411. }
  412. /**
  413. * 预备人才库-公示预览
  414. * @auth {{/talentInfo/publicExportBefore}}
  415. */
  416. public function publicExportBefore() {
  417. $params = $this->request->param();
  418. $ids_arr = array_filter(explode(",", $params["ids"]));
  419. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  420. if ($ids_arr) {
  421. $where[] = ["id", "in", $ids_arr];
  422. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  423. $rows = [];
  424. $i = 1;
  425. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  426. foreach ($list as $item) {
  427. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  428. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  429. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  430. $row = [
  431. $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"]
  432. ];
  433. $rows[] = $row;
  434. $i++;
  435. }
  436. }
  437. if ($rows) {
  438. $filename = "现代产业体系人才公示预览导出";
  439. export($columns, $rows, $filename);
  440. exit();
  441. }
  442. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  443. }
  444. /**
  445. * 预备人才库-公示导出
  446. * @auth {{/talentInfo/publicExport}}
  447. */
  448. public function publicExport() {
  449. $params = $this->request->param();
  450. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  451. $startTime = $params["startTime"];
  452. $endTime = $params["endTime"];
  453. if (!strtotime($startTime) || !strtotime($endTime))
  454. return json(["msg" => "时间格式错误"]);
  455. $where[] = ["checkState", "=", TalentState::ANNOUNCED];
  456. $where[] = ["publicBatch", "between", [$startTime, $endTime]];
  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 ? "审核通过" : "审核不通过", $checkLog["description"]
  467. ];
  468. $rows[] = $row;
  469. $i++;
  470. }
  471. if ($rows) {
  472. $filename = "现代产业体系人才公示导出";
  473. export($columns, $rows, $filename);
  474. exit();
  475. }
  476. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  477. }
  478. /**
  479. * 预备人才库-公示
  480. * @auth {{/talentInfo/preparePublic}}
  481. */
  482. public function preparePublic() {
  483. $params = $this->request->param();
  484. $ids = $params["ids"];
  485. $publicBatch = $params["batch"];
  486. if (!$publicBatch || strlen($publicBatch) != 6 || !is_numeric($publicBatch))
  487. return json(["msg" => "公示批次错误"]);
  488. $isMessage = $params["isMessage"] == 1 ? true : false;
  489. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  490. return json(["msg" => "短信参数不能为空"]);
  491. }
  492. $ids = array_filter(explode(",", $ids));
  493. $msg = "已公示";
  494. $state = TalentState::ANNOUNCED; //公示
  495. $total = count($ids);
  496. $error = 0;
  497. $success = 0;
  498. $phones = [];
  499. foreach ($ids as $id) {
  500. $talent_info = VerifyApi::getOne($id);
  501. if ($talent_info["checkState"] != TalentState::ZX_PASS) {
  502. $error++;
  503. continue;
  504. }
  505. if (VerifyApi::setPublic($id, $state, $msg, $publicBatch)) {
  506. $success++;
  507. $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
  508. $phones[] = $ep->agentPhone;
  509. } else {
  510. $error++;
  511. }
  512. }
  513. $phones = array_unique(array_filter($phones));
  514. if ($isMessage && $phones) {
  515. $sms = new \app\common\api\ChuanglanSmsApi();
  516. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  517. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  518. while ($phone = array_shift($phones)) {
  519. $result = $sms->sendSMS($phone, $tpl_content);
  520. $result = json_decode($result, true);
  521. $recordId = getStringId();
  522. $record_data = [
  523. 'id' => $recordId,
  524. 'bizId' => $result["msgId"],
  525. 'type' => 2,
  526. 'smsType' => 1,
  527. 'phone' => $phone,
  528. 'params' => '公示',
  529. 'templateCode' => $tpl_content,
  530. 'state' => $result['code'] == 0 ? 2 : 3,
  531. 'sendingDate' => date("Y-m-d H:i:s", time()),
  532. 'createTime' => date("Y-m-d H:i:s", time()),
  533. 'msg' => $result['errorMsg']
  534. ];
  535. MessageRecord::create($record_data);
  536. }
  537. }
  538. return json(["code" => 200, "msg" => sprintf("公示完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  539. }
  540. /**
  541. * 预备人才库-公示再审核
  542. * @auth {{/talentInfo/prepareCheck}}
  543. */
  544. public function prepareCheck() {
  545. $params = $this->request->param();
  546. $id = $params["id"];
  547. $checkState = $params["checkState"];
  548. $msg = $params["checkMsg"];
  549. if (!$msg)
  550. return json(["msg" => "请填写审核意见"]);
  551. if ($checkState == 1) {
  552. $msg = "公示再审核通过:" . $msg;
  553. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  554. } else {
  555. $msg = "公示再审核不通过:" . $msg;
  556. $state = TalentState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
  557. }
  558. $talent_info = VerifyApi::getOne($id);
  559. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  560. return json(["msg" => "当前记录不是公示状态,无法审核"]);
  561. }
  562. if (VerifyApi::setPublic($id, $state, $msg)) {
  563. return json(["code" => 200, "msg" => "公示再审核完成"]);
  564. }
  565. return json(["msg" => "公示再审核失败"]);
  566. }
  567. /**
  568. * 预备人才库-公示通过(批量)
  569. * @auth {{/talentInfo/publicPass}}
  570. */
  571. public function publicPass() {
  572. $params = $this->request->param();
  573. $ids = $params["ids"];
  574. $ids = array_filter(explode(",", $ids));
  575. $msg = "公示再审核批量通过";
  576. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  577. $total = count($ids);
  578. $error = 0;
  579. $success = 0;
  580. foreach ($ids as $id) {
  581. $talent_info = VerifyApi::getOne($id);
  582. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  583. $error++;
  584. continue;
  585. }
  586. if (VerifyApi::setPublic($id, $state, $msg)) {
  587. $success++;
  588. } else {
  589. $error++;
  590. }
  591. }
  592. return json(["code" => 200, "msg" => sprintf("公示再审核完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  593. }
  594. /**
  595. * 预备人才库-公布预览
  596. * @auth {{/talentInfo/publishExportBefore}}
  597. */
  598. public function publishExportBefore() {
  599. $params = $this->request->param();
  600. $ids = $params["ids"];
  601. $ids = array_filter(explode(",", $ids));
  602. if ($ids) {
  603. $where[] = ["id", "in", $ids];
  604. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  605. $rows = [];
  606. $i = 1;
  607. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  608. foreach ($list as $item) {
  609. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  610. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  611. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  612. $row = [
  613. $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"]
  614. ];
  615. $rows[] = $row;
  616. $i++;
  617. }
  618. }
  619. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  620. $filename = "现代产业体系人才" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  621. if ($rows) {
  622. export($columns, $rows, $filename);
  623. exit();
  624. }
  625. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  626. }
  627. /**
  628. * 预备人才库-公布导出
  629. * @auth {{/talentInfo/publishExport}}
  630. */
  631. public function publishExport() {
  632. $params = $this->request->param();
  633. $startTime = $params["startTime"];
  634. $endTime = $params["endTime"];
  635. if (!strtotime($startTime) || !strtotime($endTime))
  636. return json(["msg" => "时间格式错误"]);
  637. $where[] = ["checkState", "=", TalentState::PUBLISH_PASS];
  638. $where[] = ["certificateGetTime", "between", [$startTime, $endTime]];
  639. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  640. $rows = [];
  641. $i = 1;
  642. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  643. foreach ($list as $item) {
  644. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  645. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  646. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  647. $row = [
  648. $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"]
  649. ];
  650. $rows[] = $row;
  651. $i++;
  652. }
  653. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  654. $filename = "现代产业体系人才" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  655. if ($rows) {
  656. export($columns, $rows, $filename);
  657. exit();
  658. }
  659. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  660. }
  661. /**
  662. * 预备人才库-公布
  663. * @auth {{/talentInfo/publish}}
  664. */
  665. public function publish() {
  666. $params = $this->request->param();
  667. $id = $params["id"];
  668. $msg = $params["checkMsg"];
  669. $checkState = $params["checkState"];
  670. $batch = $params["batch"];
  671. if ($checkState == 1) {
  672. $state = TalentState::PUBLISH_PASS;
  673. $msg = "公布审核通过:" . $msg;
  674. } else {
  675. $state = TalentState::PUBLISH_FAIL;
  676. $msg = "公布审核不通过:" . $msg;
  677. }
  678. if (!$batch || !strtotime($batch))
  679. return json(["msg" => "公布批次时间错误"]);
  680. if (!$msg)
  681. return json(["msg" => "请填写审核意见"]);
  682. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  683. $batch = $params["batch"];
  684. if (!strtotime($batch))
  685. return json(["msg" => "公布批次时间错误"]);
  686. $talent_info = VerifyApi::getOne($id);
  687. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  688. return json(["msg" => "当前记录不是公示再审核通过状态,无法审核"]);
  689. }
  690. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  691. return json(["code" => 200, "msg" => "公布审核完成"]);
  692. }
  693. return json(["msg" => "公布审核失败"]);
  694. }
  695. /**
  696. * 预备人才库-批量公布通过
  697. * @auth {{/talentInfo/preparePublish}}
  698. */
  699. public function preparePublish() {
  700. $params = $this->request->param();
  701. $ids = $params["ids"];
  702. $ids = array_filter(explode(",", $ids));
  703. $msg = "批量公布";
  704. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  705. $batch = $params["batch"];
  706. if (!strtotime($batch))
  707. return json(["msg" => "公布批次时间错误"]);
  708. $total = count($ids);
  709. $error = 0;
  710. $success = 0;
  711. foreach ($ids as $id) {
  712. $talent_info = VerifyApi::getOne($id);
  713. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  714. $error++;
  715. continue;
  716. }
  717. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  718. $success++;
  719. } else {
  720. $error++;
  721. }
  722. }
  723. return json(["code" => 200, "msg" => sprintf("公布完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  724. }
  725. /**
  726. * 预备人才库-批量发放人才码
  727. * @auth {{/talentInfo/prepareCertification}}
  728. */
  729. public function prepareCertification() {
  730. $lockFile = fopen("send_certificate.lock", "a");
  731. if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
  732. //查询所有待发放人才码的数据
  733. $params = $this->request->param();
  734. $ids = array_filter(explode(",", $params["ids"]));
  735. //晋江市优秀人才证书:当前年份+层次+四位递增数字
  736. //集成电路优秀人才证书:IC+当前年份+递增四位数,如IC20190001
  737. Db::startTrans();
  738. $talent_max_no = [];
  739. $user = $this->user;
  740. $_prefix_type = "";
  741. $subindex = 5;
  742. switch ($user["type"]) {
  743. case CommonConst::ENTERPRISE_JC:
  744. $_prefix_type = "IC";
  745. $subindex += strlen($_prefix_type);
  746. break;
  747. }
  748. try {
  749. $talent_list = VerifyApi::getListByIds($ids);
  750. $year = date("Y");
  751. foreach ($talent_list as $talent_info) {
  752. if ($talent_info["checkState"] != TalentState::PUBLISH_PASS) {
  753. Db::rollback();
  754. return json(["msg" => "只能对公布通过的对象发放人才码,请核查待发放人才码名单后再重新发放人才码"]);
  755. }
  756. /* 检查是否有存在人才码,保持同一个人唯一 */
  757. $where = [];
  758. $where[] = ["card_type", "=", $talent_info["card_type"]];
  759. $where[] = ["card_number", "=", $talent_info["card_number"]];
  760. $where[] = ["checkState", "=", TalentState::CERTIFICATED];
  761. $fstTalentInfo = Db::table("new_talent_info")->where($where)->order("createTime asc")->find(); //取第一条全通记录
  762. if ($fstTalentInfo) {
  763. $max_no = $fstTalentInfo["certificateNo"];
  764. } else {
  765. $no_prefix = $_prefix_type . $year . $talent_info["talent_arrange"];
  766. $where = [];
  767. $where[] = ["certificateNo", "like", $no_prefix . "%"];
  768. $max_no = $talent_max_no[$talent_info["talent_arrange"]] ?: Db::table("new_talent_info")->where($where)->max("certificateNo", false);
  769. if (!$max_no) {
  770. $max_no = $no_prefix . "0001";
  771. } else {
  772. $new_no = intval(substr($max_no, $subindex)) + 1;
  773. $max_no = $no_prefix . str_pad($new_no, 4, "0", STR_PAD_LEFT);
  774. }
  775. }
  776. //更新证书编号
  777. $data["id"] = $talent_info["id"];
  778. $data["certificateNo"] = $max_no;
  779. $data["checkState"] = TalentState::CERTIFICATED;
  780. $data["isEffect"] = 1;
  781. $data["isPublic"] = 5;
  782. Db::table("new_talent_info")->update($data);
  783. //写入日志
  784. $log["last_state"] = TalentState::PUBLISH_PASS;
  785. $log["id"] = getStringId();
  786. $log["state"] = $log["new_state"] = TalentState::CERTIFICATED;
  787. $log["type"] = 1;
  788. $log["mainId"] = $talent_info["id"];
  789. $log["companyId"] = $user["companyId"];
  790. $log["active"] = 1;
  791. $log["description"] = "人才码为:" . $max_no;
  792. $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);
  793. $log["createTime"] = date("Y-m-d H:i:s");
  794. Db::table("new_talent_checklog")->insert($log);
  795. $talent_max_no[$talent_info["talent_arrange"]] = $max_no;
  796. }
  797. Db::commit();
  798. if ($user["type"] == 2) {
  799. //办法上只写电路人才,所以暂时只给电路增加基础分
  800. $_ids = array_column($talent_list, "id");
  801. for ($i = 0; $i < count($_ids); $i++) {
  802. queue("app\job\Talent", ["type" => 4, "id" => $_ids[$i]]);
  803. }
  804. }
  805. return json(["code" => 200, "msg" => "发放人才码成功"]);
  806. } catch (\Exception $e) {
  807. Db::rollback();
  808. return json(["msg" => "发放人才码失败:" . $e->getMessage()]);
  809. }
  810. flock($lockFile, LOCK_UN);
  811. } else {
  812. return json(["msg" => "同一时间只能有一个管理员进行发放人才码操作"]);
  813. }
  814. }
  815. /**
  816. * 预备人才库-撤销公布
  817. * @auth {{/talentInfo/prepareCanclePublish}}
  818. */
  819. public function pre_cancel_publish() {
  820. }
  821. /**
  822. * 基本条件审核-提交未保存
  823. * @param \think\Request $request
  824. * @param type $talent_info
  825. * @return type json
  826. */
  827. private function baseCheck(\think\Request $request, $talent_info) {
  828. $params = $request->param();
  829. if ($params["checkState"] == 3) {
  830. //审核成功
  831. $log_checkState = $checkState = TalentState::BASE_VERIFY_PASS; //基础信息审核成功
  832. } else {
  833. //审核驳回并记录需要修改的字段和上传文件
  834. $checkState = TalentState::FST_SAVE; //退回提交材料阶段
  835. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  836. }
  837. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  838. if (!$log)
  839. return json(["msg" => "日志数据异常,保存失败"]);
  840. if ($log["active"] == 0) {
  841. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  842. } else {
  843. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  844. }
  845. $data["id"] = $talent_info["id"];
  846. $data["modify_files"] = $params["files"];
  847. $data["modify_fields"] = $params["fields"];
  848. TalentModel::update($data);
  849. return json(["code" => 200, "msg" => "保存成功"]);
  850. }
  851. /**
  852. * 基本条件审核-提交审核
  853. * @param type $talent_info
  854. * @return type json
  855. */
  856. private function baseSubmitCheck($talent_info) {
  857. return $this->commonSubmitCheck($talent_info, 1);
  858. }
  859. /**
  860. * 基本条件复审-提交未保存
  861. * @param \think\Request $request
  862. * @param type $talent_info
  863. * @return type json
  864. */
  865. private function baseReCheck(\think\Request $request, $talent_info) {
  866. $params = $request->param();
  867. if ($params["checkState"] == 3) {
  868. //审核成功
  869. $log_checkState = $checkState = TalentState::BASE_REVERIFY_PASS; //基础信息复审成功
  870. } else if ($params["checkState"] == 2) {
  871. //审核驳回并记录需要修改的字段和上传文件
  872. $checkState = TalentState::FST_SUBMIT; //退回待基础审核状态
  873. $log_checkState = TalentState::BASE_REVERIFY_REJECT; //日志记录拒绝状态
  874. } else {
  875. $log_checkState = $checkState = TalentState::BASE_REVERIFY_FAIL; //审核失败
  876. }
  877. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  878. if (!$log)
  879. return json(["msg" => "日志数据异常,保存失败"]);
  880. if ($log["active"] == 0) {
  881. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  882. } else {
  883. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  884. }
  885. $data["id"] = $talent_info["id"];
  886. $data["modify_files"] = $params["files"];
  887. $data["modify_fields"] = $params["fields"];
  888. TalentModel::update($data);
  889. return json(["code" => 200, "msg" => "保存成功"]);
  890. }
  891. /**
  892. * 基本条件复审-提交审核
  893. * @param type $talent_info
  894. * @return type json
  895. */
  896. private function baseReSubmitCheck($talent_info) {
  897. return $this->commonSubmitCheck($talent_info, 2);
  898. }
  899. /**
  900. * 初审-提交未保存
  901. * @param \think\Request $request
  902. * @param type $talent_info
  903. * @return type json
  904. */
  905. private function fstCheck(\think\Request $request, $talent_info, $ep) {
  906. $params = $request->param();
  907. $data["pass_dept_check"] = 0;
  908. if ($params["checkState"] == 3) {
  909. //审核成功,并取消设置越过部门并审
  910. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  911. if ($talent_info["isImport"] && $talent_info["isMatchZhiren"]) {
  912. $data["pass_dept_check"] = 1;
  913. }
  914. } else if ($params["checkState"] == 4) {
  915. if ($talent_info["highProcess"] < 3)
  916. return json(["msg" => "只有曾经达到过部门并审,初审时才可以选择直接跳过部门并审阶段"]);
  917. //审核成功,并设置越过部门并审。附加条件:最高进度曾经通过初审3,上级驳回后重新初审的
  918. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  919. if ($talent_info["highProcess"] >= 3) {
  920. $data["pass_dept_check"] = 1;
  921. }
  922. } else if ($params["checkState"] == 5) {
  923. //选择重审部门
  924. if ($talent_info["highProcess"] < 3)
  925. return json(["msg" => "只有曾经达到过部门并审,初审时才可以选择再次审核的部门"]);
  926. if (!$params["companys"])
  927. return json(["msg" => "请选择需要再次审核的部门"]);
  928. //以下注释12部分为重审部门的限制,未通过并未选择的部门需要选择才能保存审核,注释备用
  929. //1$pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  930. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  931. $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
  932. $re_check_companys = array_filter(explode(",", $params["companys"]));
  933. /* 2$unpass_companyIds = array_diff($companyIds, $pass_companyIds);
  934. $unselect_companyIds = [];
  935. foreach ($unpass_companyIds as $unpass_companyId) {
  936. if (!in_array($unpass_companyId, $re_check_companys))
  937. $unselect_companyIds[] = $unpass_companyId;
  938. }
  939. if ($unselect_companyIds) {
  940. $unselect_companyName = [];
  941. foreach ($unselect_companyIds as $unselect_companyId) {
  942. $unselect_companyName[] = getCacheById("Company", $unselect_companyId)["name"];
  943. }
  944. return json(["msg" => "以下部门未通过,需要勾选重新审核:<br>" . implode("<br>", $unselect_companyName)]);
  945. } */
  946. foreach ($re_check_companys as $reCompanyId) {
  947. if (!in_array($reCompanyId, $companyIds)) {
  948. return json(["msg" => "错误的部门"]);
  949. }
  950. }
  951. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  952. } else {
  953. //审核驳回并记录需要修改的字段和上传文件
  954. if ($ep["type"] == CommonConst::ENTERPRISE_WJ) {
  955. if ($params["checkState"] == 6) {
  956. //驳回到分院
  957. if ($ep["isGeneral"] == 1) {
  958. return json(["msg" => "总院不能驳回到分院"]);
  959. } else {
  960. $checkState = TalentState::FST_SAVE;
  961. }
  962. } else {
  963. if ($ep["isGeneral"] == 1) {
  964. $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
  965. } else {
  966. $checkState = TalentState::FST_SUBMIT;
  967. }
  968. }
  969. } else {
  970. $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
  971. }
  972. $log_checkState = TalentState::FST_VERIFY_REJECT; //日志记录拒绝状态
  973. }
  974. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  975. if (!$log && !$talent_info["oldId"])
  976. return json(["msg" => "日志数据异常,保存失败"]);
  977. if ($log["active"] === 0) {
  978. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  979. } else {
  980. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  981. }
  982. $data["id"] = $talent_info["id"];
  983. $data["modify_files"] = $params["files"];
  984. $data["modify_fields"] = $params["fields"];
  985. $data["re_check_companys"] = $params["companys"];
  986. TalentModel::update($data);
  987. return json(["code" => 200, "msg" => "保存成功"]);
  988. }
  989. /**
  990. * 初审-提交审核
  991. * @param type $talent_info
  992. * @return type json
  993. */
  994. private function fstSubmitCheck($talent_info, $ep) {
  995. $nowProcess = 3;
  996. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  997. if (!$log || $log["active"] == 1)
  998. return json(["msg" => "请先保存审核状态,再提交审核"]);
  999. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  1000. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  1001. }
  1002. $userIds = [];
  1003. if ($log["state"] == TalentState::FST_VERIFY_PASS && $talent_info["pass_dept_check"] == 0) {
  1004. $data["first_dept_check_time"] = date("Y-m-d H:i:s");
  1005. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1006. $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
  1007. if ($talent_info["re_check_companys"]) {
  1008. $unpass_companyIds = array_filter(explode(",", $talent_info["re_check_companys"]));
  1009. } else {
  1010. //这边去除已经审核通过的单位,主要通过日志是否存在记录。
  1011. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  1012. $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
  1013. if (!$unpass_companyIds) {
  1014. $data["pass_dept_check"] = 1; //部门已经全部审核过了,跳过部门审核
  1015. }
  1016. }
  1017. if ($unpass_companyIds) {
  1018. sort($unpass_companyIds);
  1019. $delay = 9 * 24 * 3600; //9天的秒数
  1020. queue("app\job\Talent", ["type" => 1, "id" => $talent_info["id"]], $delay); //加入部门审核超期处理队列,延迟7天执行
  1021. TalentLogApi::writeDeptLogs($talent_info["id"], $unpass_companyIds, TalentState::FST_VERIFY_PASS);
  1022. //初审通过发送短信通知并审部门
  1023. $codes = ["talentInfo_depCheck"];
  1024. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  1025. $where = [];
  1026. $where[] = ["menuid", "in", $menuIds];
  1027. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  1028. $where = [];
  1029. $where[] = ["status", "=", 1];
  1030. $where[] = ["type", "=", $this->user["type"]];
  1031. $where[] = ["companyId", "in", $unpass_companyIds];
  1032. $where[] = ["roleid", "<>", 1];
  1033. $regstr = ",(" . implode("|", $roleIds) . "),";
  1034. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  1035. $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
  1036. /* $privs = ["/admin/talent/dept_check"];
  1037. $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
  1038. $where[] = ["menuid", "in", $menuIds];
  1039. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
  1040. $where = [];
  1041. $where[] = ["status", "=", 1];
  1042. $where[] = ["companyId", "in", $unpass_companyIds];
  1043. $where[] = ["roleid", "in", $roleIds];
  1044. $where[] = ["roleid", "<>", 1];
  1045. $userIds = User::where($where)->column("id"); */
  1046. }
  1047. }
  1048. $data["id"] = $talent_info["id"];
  1049. $data["checkState"] = $log["new_state"];
  1050. TalentModel::update($data);
  1051. TalentLogApi::setActive($log["id"], 1);
  1052. $this->sendMsgByState($talent_info, $log["state"], $userIds, $log["description"]);
  1053. return json(["code" => 200, "msg" => "审核成功"]);
  1054. }
  1055. /**
  1056. * 部门审核-提交未保存
  1057. * @param \think\Request $request
  1058. * @param type $talent_info
  1059. * @return type json
  1060. */
  1061. private function deptCheck(\think\Request $request, $talent_info, $companys) {
  1062. if ($talent_info["pass_dept_check"] == 1)
  1063. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  1064. if (!in_array($this->user["companyId"], $companys))
  1065. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  1066. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  1067. $un_check_companyIds = TalentLogApi::getUnCheckDepts($talent_info["id"]); //未审核提交的单位
  1068. if (!in_array($this->user["companyId"], $un_check_companyIds) && in_array($this->user["companyId"], $pass_companyIds)) {
  1069. //判断不在未审核列表的同时判断已经在审核列表,是为了排除意外情况:缺失的待审核部门(通常是认证条件新增审核部门导致新增的部门未在审核列表中)
  1070. //缺失的待审核部门,作为未审状态,将在函数末尾根据当前审核情况补充一条保存未提交的记录
  1071. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  1072. }
  1073. $params = $request->param();
  1074. if ($params["checkState"] == 3) {
  1075. //审核成功
  1076. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  1077. $checkState = TalentState::DEPT_VERIFY_PASS; //审核成功
  1078. } else {
  1079. //审核驳回并记录需要修改的字段和上传文件
  1080. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  1081. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  1082. $talent_condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1083. if (!$talent_condition["companyWithFileType"])
  1084. return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
  1085. $cwfts = explode(";", $talent_condition["companyWithFileType"]);
  1086. $company_setting = [];
  1087. foreach ($cwfts as $cwft) {
  1088. $_company_setting = explode(":", $cwft);
  1089. if ($_company_setting[0] == $this->user["companyId"]) {
  1090. $company_setting = explode(",", $_company_setting[1]);
  1091. break;
  1092. }
  1093. }
  1094. if (!$company_setting)
  1095. return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
  1096. //$data["modify_fields"] = $params["fields"];
  1097. $original_modify_files = explode(",", $talent_info["modify_files"]);
  1098. $_current_modify_files = explode(",", $params["files"]);
  1099. $unselect_files = array_diff($company_setting, $_current_modify_files); //比较设置和当前提交的,取差值集,既是可选而未选的附件集合
  1100. $new_modify_files = array_unique(array_merge($original_modify_files, $_current_modify_files)); //合并当前提交及库中原来保存的值
  1101. foreach ($new_modify_files as $key => $item) {
  1102. if (in_array($item, $unselect_files))
  1103. unset($new_modify_files[$key]);
  1104. }
  1105. $data["modify_files"] = implode(",", array_unique($new_modify_files));
  1106. }
  1107. $fst_dept_check_time = $talent_info["first_dept_check_time"];
  1108. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $fst_dept_check_time);
  1109. if ($dept_log["active"] == 1)
  1110. return json(["msg" => "您的部门已经审核过了"]);
  1111. $data["id"] = $talent_info["id"];
  1112. TalentModel::update($data);
  1113. //修改日志
  1114. if (!$dept_log) {
  1115. TalentLogApi::write(ProjectState::TALENT, $talent_info["id"], [$log_checkState, $checkState, 3], $params["checkMsg"]); //补一条记录
  1116. //return json(["msg" => "未匹配日志,审核失败"]);
  1117. } else {
  1118. TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1119. }
  1120. return json(["code" => 200, "msg" => "保存成功"]);
  1121. }
  1122. /**
  1123. * 部门审核-提交审核
  1124. * @param type $talent_info
  1125. * @return type json
  1126. */
  1127. private function deptSubmitCheck($talent_info, $companys) {
  1128. if ($talent_info["pass_dept_check"] == 1)
  1129. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  1130. if (!in_array($this->user["companyId"], $companys))
  1131. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  1132. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  1133. if (in_array($this->user["companyId"], $pass_companyIds))
  1134. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  1135. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $talent_info["first_dept_check_time"]);
  1136. //if (!$dept_log)
  1137. //return json(["msg" => "未匹配日志,审核失败"]);
  1138. if ($dept_log["state"] == $dept_log["new_state"] || !$dept_log)
  1139. return json(["msg" => "请先保存审核状态,再提交审核"]);
  1140. if ($dept_log["active"] == 1)
  1141. return json(["msg" => "您的部门已经审核过了"]);
  1142. if ($talent_info["re_check_companys"]) {
  1143. $re_check_companys = array_filter(explode(",", $talent_info["re_check_companys"]));
  1144. $companys = VerifyApi::getNewReCheckCompanyIds($re_check_companys, $companys, $pass_companyIds);
  1145. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"], $talent_info["first_dept_check_time"]); //重审单位中已经通过的单位
  1146. }
  1147. $no_valid_companyIds = array_diff($pass_companyIds, $companys);
  1148. $pass_companyIds = array_diff($pass_companyIds, $no_valid_companyIds);
  1149. $over = $pass_companyIds ? count($pass_companyIds) : 0; //完成度,如果重审之前已有通过审核的部门,不用再审,直接按通过算
  1150. $error = 0; //失败数
  1151. $nowProcess = 4;
  1152. $over++;
  1153. if ($dept_log["new_state"] == TalentState::SCND_SUBMIT) {
  1154. $error++;
  1155. }
  1156. $logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
  1157. for ($i = 0; $i < count($logs); $i++) {
  1158. if (!in_array($logs[$i]["companyId"], $pass_companyIds) && in_array($logs[$i]["companyId"], $companys)) {
  1159. $over += $logs[$i]["active"] == 1 ? 1 : 0;
  1160. if ($logs[$i]["new_state"] == TalentState::SCND_SUBMIT) {
  1161. $error++;
  1162. }
  1163. }
  1164. }
  1165. if ($over == count($companys)) {
  1166. //全部已审核
  1167. $checkState = TalentState::SCND_SUBMIT;
  1168. $log_checkState = TalentState::DEPT_VERIFY_REJECT;
  1169. if ($error == 0) {
  1170. $log_checkState = $checkState = TalentState::DEPT_VERIFY_PASS;
  1171. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  1172. $data["modify_files"] = null;
  1173. }
  1174. if ($log_checkState == TalentState::DEPT_VERIFY_REJECT) {
  1175. $talent_condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1176. $cwfts = explode(";", $talent_condition["companyWithFileType"]);
  1177. $fileTypes = [];
  1178. foreach ($cwfts as $cwft) {
  1179. $_company_setting = explode(":", $cwft);
  1180. $_fileTypes = explode(",", $_company_setting[1]);
  1181. $fileTypes = array_merge($fileTypes, $_fileTypes);
  1182. }
  1183. $modify_files = explode(",", $talent_info["modify_files"]);
  1184. $removeFileTypes = array_diff($modify_files, $fileTypes);
  1185. $newModifyFiles = array_diff($modify_files, $removeFileTypes);
  1186. $data["modify_files"] = implode(",", $newModifyFiles);
  1187. }
  1188. $data["id"] = $talent_info["id"];
  1189. $data["checkState"] = $checkState;
  1190. $data["first_dept_check_time"] = null;
  1191. $data["re_check_companys"] = null;
  1192. TalentModel::update($data);
  1193. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "部门审核结束", 1);
  1194. if ($log_checkState == TalentState::DEPT_VERIFY_REJECT) {
  1195. //部门驳回发送短信通知
  1196. $codes = ["talentInfo_firstCheck"];
  1197. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  1198. $where = [];
  1199. $where[] = ["menuid", "in", $menuIds];
  1200. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  1201. $where = [];
  1202. $where[] = ["status", "=", 1];
  1203. $where[] = ["type", "=", $this->user["type"]];
  1204. $where[] = ["roleid", "<>", 1];
  1205. $regstr = ",(" . implode("|", $roleIds) . "),";
  1206. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  1207. $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
  1208. /* $privs = ["admin/talent/fst_check"];
  1209. $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
  1210. $where[] = ["menuid", "in", $menuIds];
  1211. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
  1212. $where = [];
  1213. $where[] = ["status", "=", 1];
  1214. $where[] = ["roleid", "in", $roleIds];
  1215. $where[] = ["roleid", "<>", 1];
  1216. $userIds = User::where($where)->column("id"); */
  1217. $this->sendMsgByState($talent_info, $log_checkState, $userIds, $dept_log["description"]);
  1218. }
  1219. }
  1220. TalentLogApi::setActive($dept_log["id"], 1);
  1221. return json(["code" => 200, "msg" => "审核成功"]);
  1222. }
  1223. /**
  1224. * 复审-提交未保存
  1225. * @param \think\Request $request
  1226. * @param type $talent_info
  1227. * @param type json
  1228. */
  1229. private function reCheck(\think\Request $request, $talent_info) {
  1230. $params = $request->param();
  1231. if ($params["checkState"] == 3) {
  1232. //审核成功
  1233. $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
  1234. } else if ($params["checkState"] == 2) {
  1235. //审核驳回并记录需要修改的字段和上传文件
  1236. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  1237. $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
  1238. } else {
  1239. $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
  1240. }
  1241. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  1242. if (!$log && !$talent_info["oldId"])
  1243. return json(["msg" => "日志数据异常,保存失败"]);
  1244. if ($log["active"] === 0) {
  1245. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1246. } else {
  1247. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  1248. }
  1249. $data["id"] = $talent_info["id"];
  1250. $data["modify_files"] = $params["files"];
  1251. $data["modify_fields"] = $params["fields"];
  1252. TalentModel::update($data);
  1253. return json(["code" => 200, "msg" => "保存成功"]);
  1254. }
  1255. /**
  1256. * 复审-提交审核
  1257. * @param type $talent_info
  1258. * @return type json
  1259. */
  1260. private function reSubmitCheck($talent_info) {
  1261. return $this->commonSubmitCheck($talent_info, 5);
  1262. }
  1263. private function commonSubmitCheck($talent_info, $nowProcess) {
  1264. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  1265. if (!$log || $log["active"] == 1)
  1266. return json(["msg" => "请先保存审核状态,再提交审核"]);
  1267. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  1268. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  1269. }
  1270. $data["id"] = $talent_info["id"];
  1271. $data["checkState"] = $log["new_state"];
  1272. TalentModel::update($data);
  1273. TalentLogApi::setActive($log["id"], 1);
  1274. $userIds = [];
  1275. if (in_array($log["state"], [TalentState::REVERIFY_PASS, TalentState::REVERIFY_REJECT])) {
  1276. //复核成功需要发送短信给征信部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
  1277. //从征信审核权限,逆推征信部门
  1278. if ($data["checkState"] == TalentState::REVERIFY_PASS) {
  1279. $codes = ["talentInfohczxReject", "talentInfohczxPass"];
  1280. } else {
  1281. $codes = ["talentInfo_firstCheck"];
  1282. }
  1283. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  1284. $where = [];
  1285. $where[] = ["menuid", "in", $menuIds];
  1286. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  1287. $where = [];
  1288. $where[] = ["status", "=", 1];
  1289. $where[] = ["type", "=", $this->user["type"]];
  1290. $where[] = ["roleid", "<>", 1];
  1291. $regstr = ",(" . implode("|", $roleIds) . "),";
  1292. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  1293. $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
  1294. /* if ($data["checkState"] == TalentState::REVERIFY_PASS) {
  1295. $privs = ["/admin/talent/hczxReject", "/admin/talent/hczxPass"];
  1296. } else {
  1297. $privs = ["admin/talent/fst_check"];
  1298. }
  1299. $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
  1300. $where = [];
  1301. $where[] = ["menuid", "in", $menuIds];
  1302. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
  1303. $where = [];
  1304. $where[] = ["status", "=", 1];
  1305. $where[] = ["roleid", "in", $roleIds];
  1306. $where[] = ["roleid", "<>", 1];
  1307. $userIds = User::where($where)->column("id"); */
  1308. }
  1309. $this->sendMsgByState($talent_info, $log["state"], $userIds, $log["description"]);
  1310. return json(["code" => 200, "msg" => "审核成功"]);
  1311. }
  1312. private function sendMsgByState($talent_info, $state, $userIds = [], $description = "") {
  1313. $phones = [];
  1314. $template = "";
  1315. $type = 0;
  1316. $processName = "";
  1317. $userId = 0;
  1318. $name = null;
  1319. switch ($state) {
  1320. case TalentState::BASE_VERIFY_PASS://基础信息审核通过发送短信通知用户
  1321. $type = 2;
  1322. $processName = "基础信息审核";
  1323. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核通过,请及时登录申报系统并进行人才认定的信息申报填写。";
  1324. break;
  1325. case TalentState::BASE_REJECT://基础信息审核驳回发送短信通知用户
  1326. $type = 2;
  1327. $processName = "基础信息审核";
  1328. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核驳回,原因是:{$description},请及时登录申报系统修改并重新提交。";
  1329. break;
  1330. case TalentState::BASE_VERIFY_FAIL://基础信息审核不通过发送短信通知用户
  1331. $type = 2;
  1332. $processName = "基础信息审核";
  1333. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核不通过,原因是:{$description}。";
  1334. break;
  1335. case TalentState::FST_VERIFY_PASS://初审通过发送短信通知并审部门
  1336. $type = 1;
  1337. $processName = "初级审核";
  1338. $template = "【晋江市人才服务平台】您的部门有新的人才认定申报需要审批,请及时登录审批系统处理。";
  1339. break;
  1340. case TalentState::FST_VERIFY_REJECT; //初审驳回发送短信通知用户
  1341. $type = 2;
  1342. $processName = "初级审核";
  1343. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$description},请及时登录申报系统修改并重新提交。";
  1344. break;
  1345. case TalentState::FST_VERIFY_FAIL://初审不通过发送短信通知用户
  1346. $type = 2;
  1347. $processName = "初级审核";
  1348. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核不通过,原因是:{$description}。";
  1349. break;
  1350. case TalentState::DEPT_VERIFY_REJECT://并审驳回发送短信通知初审部门
  1351. $type = 1;
  1352. $processName = "部门并审";
  1353. $template = "【晋江市人才服务平台】有人才认定申报在并审阶段被驳回,原因是:{$description},请及时登录审批系统处理。";
  1354. break;
  1355. case TalentState::REVERIFY_PASS://复核通过发短信通知征信部门
  1356. $type = 1;
  1357. $processName = "复审";
  1358. $template = "【晋江市人才服务平台】有新的人才认定申报通过复审进入征信阶段,请及时登录审批系统处理。";
  1359. break;
  1360. case TalentState::REVERIFY_REJECT://复核驳回发短信通知初审部门
  1361. $type = 1;
  1362. $processName = "复审";
  1363. $template = "【晋江市人才服务平台】有人才认定申报在复审阶段被驳回,原因是:{$description},请及时登录审批系统处理。";
  1364. break;
  1365. }
  1366. if ($type == 1) {
  1367. $where = [];
  1368. $where[] = ["id", "in", $userIds];
  1369. $phones = User::where($where)->column("phone");
  1370. $phones = array_unique(array_filter($phones));
  1371. }
  1372. if ($type == 2) {
  1373. $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
  1374. $phones[] = $ep->agentPhone;
  1375. $userId = $ep->id;
  1376. $name = $ep->name;
  1377. }
  1378. if ($phones && $template) {
  1379. while ($phone = array_shift($phones)) {
  1380. $smsapi = new ChuanglanSmsApi();
  1381. $result = $smsapi->sendSMS($phone, $template);
  1382. $result = json_decode($result, true);
  1383. $id = getStringId();
  1384. $record_data = [
  1385. 'id' => $id,
  1386. 'userId' => $userId,
  1387. 'bizId' => $result["msgId"],
  1388. 'type' => $type,
  1389. 'smsType' => 2,
  1390. 'name' => $name,
  1391. 'phone' => $phone,
  1392. 'params' => $processName,
  1393. 'templateCode' => $template,
  1394. 'state' => $result['code'] == 0 ? 2 : 3,
  1395. 'sendingDate' => date("Y-m-d H:i:s", time()),
  1396. 'createTime' => date("Y-m-d H:i:s", time()),
  1397. 'msg' => $result['errorMsg']
  1398. ];
  1399. MessageRecord::create($record_data);
  1400. }
  1401. }
  1402. }
  1403. public function check() {
  1404. //公共调度方法
  1405. $request = $this->request;
  1406. $params = $request->param();
  1407. $check = $params["checkState"];
  1408. $check_msg = trim($params["checkMsg"]);
  1409. $files = $params["files"];
  1410. $fields = $params["fields"];
  1411. $id = $params["id"];
  1412. $talent_info = VerifyApi::getOne($id);
  1413. $ep = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1414. $checkState = $talent_info["checkState"];
  1415. if (!$talent_info || !$ep) {
  1416. return json(["msg" => "数据错误"]);
  1417. }
  1418. if ($ep["type"] != $this->user["type"]) {
  1419. return json(["msg" => "不能审核的人才类型"]);
  1420. }
  1421. if (!$check) {
  1422. return json(["msg" => "请选择审核状态"]);
  1423. }
  1424. if (!$check_msg) {
  1425. return json(["msg" => "请填写审核说明"]);
  1426. }
  1427. if ($checkState == TalentState::FST_SUBMIT) {
  1428. return $this->baseCheck($request, $talent_info);
  1429. } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
  1430. return $this->baseReCheck($request, $talent_info);
  1431. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1432. return $this->fstCheck($request, $talent_info, $ep);
  1433. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  1434. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1435. $companys = array_filter(explode(",", $condition["companyIds"]));
  1436. if ($companys && $talent_info["pass_dept_check"] != 1) {
  1437. if (!in_array($this->user["companyId"], $companys))
  1438. return json(["msg" => "你的部门不在并审部门列表"]);
  1439. return $this->deptCheck($request, $talent_info, $companys);
  1440. } else {
  1441. return $this->reCheck($request, $talent_info);
  1442. }
  1443. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  1444. return $this->reCheck($request, $talent_info);
  1445. } else {
  1446. return json(["msg" => "不在审核范围内,保存失败"]);
  1447. }
  1448. }
  1449. public function submitCheck() {
  1450. //公共调度方法
  1451. $id = $this->request->param("id");
  1452. $talent_info = VerifyApi::getOne($id);
  1453. $ep = EnterpriseApi::getOne($talent_info["enterprise_id"]);
  1454. $checkState = $talent_info["checkState"];
  1455. if (!$talent_info || !$ep) {
  1456. return json(["msg" => "数据错误"]);
  1457. }
  1458. if ($ep["type"] != $this->user["type"]) {
  1459. return json(["msg" => "不能审核的人才类型"]);
  1460. }
  1461. if ($checkState == TalentState::FST_SUBMIT) {
  1462. return $this->baseSubmitCheck($talent_info);
  1463. } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
  1464. return $this->baseReSubmitCheck($talent_info);
  1465. } else if ($checkState == TalentState::SCND_SUBMIT) {
  1466. return $this->fstSubmitCheck($talent_info, $ep);
  1467. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  1468. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1469. $companys = array_filter(explode(",", $condition["companyIds"]));
  1470. if ($companys && $talent_info["pass_dept_check"] != 1) {
  1471. if (!in_array($this->user["companyId"], $companys))
  1472. return json(["msg" => "你的部门不在并审部门列表"]);
  1473. return $this->deptSubmitCheck($talent_info, $companys);
  1474. } else {
  1475. return $this->reSubmitCheck($talent_info);
  1476. }
  1477. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  1478. return $this->reSubmitCheck($talent_info);
  1479. } else {
  1480. return json(["msg" => "不在审核范围内,审核失败"]);
  1481. }
  1482. }
  1483. /**
  1484. * 撤销复核
  1485. * @auth {{/talentInfo/cancleThirdCheck}}
  1486. */
  1487. public function cancleThirdCheck() {
  1488. $returnObj = new \stdClass();
  1489. $returnObj->code = 500;
  1490. $id = \StrUtil::getRequestDecodeParam($this->request, "id");
  1491. $msg = \StrUtil::getRequestDecodeParam($this->request, "checkMsg");
  1492. $old = VerifyApi::getOne($id);
  1493. if (!$old) {
  1494. $returnObj->msg = "请选择需要撤销的对象";
  1495. return json($returnObj);
  1496. }
  1497. if ($old["checkState"] != TalentState::REVERIFY_PASS && $old["checkState"] != TalentState::REVERIFY_FAIL) {
  1498. $returnObj->msg = "当前对象不是\"复核通过\"或者\"复核不通过\"状态,无法撤销";
  1499. return json($returnObj);
  1500. }
  1501. $where = [];
  1502. $where[] = ["last_state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
  1503. $where[] = ["state", "in", [TalentState::REVERIFY_PASS, TalentState::REVERIFY_FAIL]];
  1504. $where[] = ["active", "=", 1];
  1505. $lastLog = TalentLogApi::getLastLogEx($id, ProjectState::TALENT, 0, $where);
  1506. if (($lastLog["state"] != TalentState::REVERIFY_PASS && $lastLog["state"] != TalentState::REVERIFY_FAIL) || $lastLog["active"] != 1) {
  1507. $returnObj->msg = "当前对象不是\"复核通过\"或者\"复核不通过\"状态,无法撤销";
  1508. return json($returnObj);
  1509. }
  1510. if ($old["isPublic"] != 1) {
  1511. $returnObj->msg = "当前对象已核查征信,无法撤销";
  1512. return json($returnObj);
  1513. }
  1514. try {
  1515. $upd["id"] = $id;
  1516. $upd["checkState"] = $lastLog["last_state"];
  1517. if (TalentModel::update($upd)) {
  1518. TalentLogApi::write(ProjectState::TALENT, $id, [TalentState::REVERIFY_CANCEL, $lastLog["last_state"]], "撤销原因:" . $msg, 1);
  1519. }
  1520. $returnObj->msg = "撤销成功";
  1521. $returnObj->code = 200;
  1522. return json($returnObj);
  1523. } catch (\think\db\exception\DbException $e) {
  1524. $responseObj->msg = $e->getMessage();
  1525. return json($responseObj);
  1526. }
  1527. }
  1528. public function validateIsCheck() {
  1529. $params = $this->request->param();
  1530. $id = $params["id"];
  1531. $process = $params["process"];
  1532. $talent_info = VerifyApi::getOne($id);
  1533. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  1534. if ($talent_info) {
  1535. $checkState = $talent_info["checkState"];
  1536. if (!$process || ($process == 3 && $checkState != TalentState::SCND_SUBMIT) || ($process == 4 && ($checkState != TalentState::FST_VERIFY_PASS || $talent_info["pass_dept_check"] == 1)) || ($process == 5 && !in_array($checkState, [TalentState::DEPT_VERIFY_PASS, TalentState::FST_VERIFY_PASS]))) {
  1537. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  1538. }
  1539. if ($process != 4) {
  1540. switch ($enterprise["type"]) {
  1541. case CommonConst::ENTERPRISE_NORMAL:
  1542. $fields = DictApi::getTalentFields(4, $talent_info["isImport"]);
  1543. break;
  1544. case CommonConst::ENTERPRISE_JC:
  1545. $fields = DictApi::getTalentFields_IC();
  1546. break;
  1547. case CommonConst::ENTERPRISE_WJ:
  1548. $fields = DictApi::getTalentFields_WJ();
  1549. break;
  1550. case CommonConst::ENTERPRISE_GJ:
  1551. $fields = DictApi::getTalentFields_GJ();
  1552. break;
  1553. }
  1554. } else {
  1555. $fields = null; //部门审核不需要审核字段
  1556. }
  1557. if ($fields["fst_work_time"] && in_array($enterprise['enterpriseTag'], ['mtdw', 'gyqyh', 'mbfqy', 'jrjg']) && $enterprise["type"] == 1) {
  1558. $fields["fst_work_time"] = $talent_info['talent_type'] == 1 ? "近三年来晋工作时间" : "近三年(首次)来晋工作时间";
  1559. }
  1560. if ($checkState != TalentState::FST_SUBMIT) {
  1561. //$fields = DictApi::getTalentFields(2);
  1562. $field_tmp = [];
  1563. if ($fields) {
  1564. foreach ($fields as $key => $field) {
  1565. $field_tmp[] = ["key" => $key, "value" => $field];
  1566. }
  1567. }
  1568. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1569. $companys = array_filter(explode(",", $condition["companyIds"]));
  1570. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  1571. $unpass_companyIds = array_diff($companys, $pass_companyIds);
  1572. $_companys = [];
  1573. foreach ($companys as $companyId) {
  1574. $company = CompanyApi::getOne($companyId);
  1575. if (in_array($companyId, $unpass_companyIds)) {
  1576. $company["uncheck"] = true;
  1577. }
  1578. $_companys[] = $company;
  1579. }
  1580. if ($process == 4 && in_array($enterprise["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_WJ])) {
  1581. $where = [];
  1582. $cwfts = explode(";", $condition["companyWithFileType"]);
  1583. foreach ($cwfts as $cwft) {
  1584. $_company_setting = explode(":", $cwft);
  1585. if ($_company_setting[0] == $this->user["companyId"]) {
  1586. $where[] = ["id", "in", explode(",", $_company_setting[1])];
  1587. break;
  1588. }
  1589. }
  1590. if ($where) {
  1591. $where[] = ["delete", "=", 0];
  1592. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  1593. } else {
  1594. $files = [];
  1595. }
  1596. } else {
  1597. $where = [];
  1598. $whr = [];
  1599. $where[] = ["project", "=", 1];
  1600. $where[] = ["active", "=", 1];
  1601. $where[] = ["type", "=", $enterprise["type"]];
  1602. $where[] = ["isConditionFile", "<>", 1];
  1603. $where[] = ["delete", "=", 0];
  1604. if ($condition && $condition["bindFileTypes"]) {
  1605. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  1606. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
  1607. } else {
  1608. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  1609. }
  1610. }
  1611. }
  1612. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  1613. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  1614. /* 保存的审核内容start */
  1615. $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, 0, ["active", "=", 0]);
  1616. if ($last_log["step"] == 3 && $last_log["companyId"] != $this->user["companyId"]) {
  1617. $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, $this->user["companyId"], ["active", "=", 0]);
  1618. }
  1619. $check = ["msg" => $last_log["description"]];
  1620. if ($last_log["state"] == TalentState::FST_VERIFY_PASS && $last_log["new_state"] == TalentState::FST_VERIFY_PASS) {
  1621. if ($talent_info["pass_dept_check"] == 1) {
  1622. if ($talent_info["isImport"] && $talent_info["isMatchZhiren"]) {
  1623. $check["checkState"] = 3; //初审通过
  1624. } else {
  1625. $check["checkState"] = 4; //初审通过(跳过部门并审)
  1626. }
  1627. } else {
  1628. if ($talent_info["re_check_companys"] && $talent_info["highProcess"] >= 4) {
  1629. $talent_info["re_check_companys"] = array_filter(explode(",", $talent_info["re_check_companys"]));
  1630. $check["checkState"] = 5; //初审通过(需要再次部门并审)
  1631. } else {
  1632. if ($process == 4) {
  1633. $check["checkState"] = ""; //部门待审核(系统自动生成的记录,应该算未保存状态,所以设成空,未选择状态)
  1634. } else {
  1635. $check["checkState"] = 3; //初审通过
  1636. }
  1637. }
  1638. }
  1639. }
  1640. if ($last_log["state"] == TalentState::FST_VERIFY_REJECT && $last_log["new_state"] == TalentState::SCND_SAVE) {
  1641. $check["checkState"] = 2; //初审驳回
  1642. }
  1643. if ($last_log["state"] == TalentState::FST_VERIFY_PASS && $last_log["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  1644. $check["checkState"] = 3; //部门通过
  1645. }
  1646. if ($last_log["state"] == TalentState::FST_VERIFY_PASS && $last_log["new_state"] == TalentState::SCND_SUBMIT) {
  1647. $check["checkState"] = 2; //部门驳回
  1648. }
  1649. if ($last_log["state"] == TalentState::REVERIFY_PASS && $last_log["new_state"] == TalentState::REVERIFY_PASS) {
  1650. $check["checkState"] = 3; //复审通过
  1651. }
  1652. if ($last_log["state"] == TalentState::REVERIFY_REJECT && $last_log["new_state"] == TalentState::SCND_SUBMIT) {
  1653. $check["checkState"] = 2; //复审驳回
  1654. }
  1655. if ($last_log["state"] == TalentState::REVERIFY_FAIL && $last_log["new_state"] == TalentState::REVERIFY_FAIL) {
  1656. $check["checkState"] = -1; //复审失败
  1657. }
  1658. /* 保存的审核内容end */
  1659. return json(["code" => 200, "obj" => ["process" => $process, "type" => $enterprise["type"], "talentInfo" => $talent_info, "check" => $check, "fieldList" => $field_tmp, "fileList" => $files, "companys" => $_companys]]);
  1660. }
  1661. }
  1662. public function findFieldsAndFiles() {
  1663. $id = $this->request["id"];
  1664. $talentInfo = VerifyApi::getOne($id);
  1665. $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
  1666. $responseObj = new \stdClass();
  1667. if ($talentInfo["checkState"] == TalentState::SCND_SAVE && $lastLog["state"] == TalentState::FST_VERIFY_REJECT) {
  1668. if ($this->user["type"] == CommonConst::ENTERPRISE_JC) {
  1669. $fields = DictApi::getTalentFields_IC();
  1670. } else if ($this->user["type"] == CommonConst::ENTERPRISE_WJ) {
  1671. $fields = DictApi::getTalentFields_WJ();
  1672. } else if ($this->user["type"] == CommonConst::ENTERPRISE_GJ) {
  1673. $fields = DictApi::getTalentFields_GJ();
  1674. } else {
  1675. $fields = DictApi::getTalentFields(4, $talentInfo["isImport"]);
  1676. }
  1677. $enterprise = \app\common\model\Enterprise::findOrEmpty($talentInfo["enterprise_id"]);
  1678. if ($fields["fst_work_time"] && in_array($enterprise['enterpriseTag'], ['mtdw', 'gyqyh', 'mbfqy', 'jrjg']) && $enterprise["type"] == 1) {
  1679. $fields["fst_work_time"] = $talentInfo['talent_type'] == 1 ? "近三年来晋工作时间" : "近三年(首次)来晋工作时间";
  1680. }
  1681. $field_tmp = [];
  1682. if ($fields) {
  1683. foreach ($fields as $key => $field) {
  1684. $field_tmp[] = ["key" => $key, "value" => $field];
  1685. }
  1686. }
  1687. $condition = TalentConditionApi::getOne($talentInfo["talent_condition"]);
  1688. $where = [];
  1689. $whr = [];
  1690. $where[] = ["project", "=", 1];
  1691. $where[] = ["active", "=", 1];
  1692. $where[] = ["type", "=", $enterprise["type"]];
  1693. $where[] = ["isConditionFile", "<>", 1];
  1694. $where[] = ["delete", "=", 0];
  1695. if ($condition && $condition["bindFileTypes"]) {
  1696. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  1697. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
  1698. } else {
  1699. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  1700. }
  1701. $responseObj->code = 200;
  1702. $responseObj->id = $id;
  1703. $responseObj->fileList = $files;
  1704. $responseObj->fieldList = $field_tmp;
  1705. $responseObj->select = [
  1706. "files" => array_filter(explode(",", $talentInfo["modify_files"])),
  1707. "fields" => array_filter(explode(",", $talentInfo["modify_fields"]))
  1708. ];
  1709. } else {
  1710. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  1711. }
  1712. return json($responseObj);
  1713. }
  1714. /**
  1715. * 初审-修改驳回字段
  1716. * @auth {{/talentInfo/updateFieldsAndFiles}}
  1717. */
  1718. public function updateFieldsAndFiles() {
  1719. $id = $this->request["id"];
  1720. $fields = array_filter(explode(",", $this->request["fields"]));
  1721. $files = array_filter(explode(",", $this->request["files"]));
  1722. $talentInfo = VerifyApi::getOne($id);
  1723. $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
  1724. $responseObj = new \stdClass();
  1725. if ($talentInfo["checkState"] == TalentState::SCND_SAVE && $lastLog["state"] == TalentState::FST_VERIFY_REJECT) {
  1726. if (!$fields && !$files) {
  1727. $responseObj->msg = "请选择可修改的字段或附件!";
  1728. return json($responseObj);
  1729. }
  1730. try {
  1731. $data["id"] = $id;
  1732. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  1733. $data["modify_files"] = $files ? implode(",", $files) : null;
  1734. TalentModel::update($data);
  1735. $responseObj->code = 200;
  1736. $responseObj->msg = "驳回字段修改成功";
  1737. return json($responseObj);
  1738. } catch (\think\db\exception\DbException $e) {
  1739. $responseObj->msg = $e->getMessage();
  1740. return json($responseObj);
  1741. }
  1742. } else {
  1743. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  1744. return json($responseObj);
  1745. }
  1746. }
  1747. /**
  1748. * 人才库-取消人才
  1749. * @auth {{/talentInfo/libraryCancle}}
  1750. */
  1751. public function removeFromLibrary() {
  1752. $responseObj = new \stdClass();
  1753. $params = $this->request->param();
  1754. $info = VerifyApi::getOne($params["id"]);
  1755. if (!$params["id"] || !$info) {
  1756. $responseObj->msg = "系统错误,请联系管理员";
  1757. return json($responseObj);
  1758. }
  1759. if ($info["active"] != 2) {
  1760. $responseObj->msg = "该人才未处于离职状态,无法取消";
  1761. return json($responseObj);
  1762. }
  1763. if ($info["isEffect"] == 4) {
  1764. $responseObj->msg = "无法重复取消";
  1765. return json($responseObj);
  1766. }
  1767. if (VerifyApi::setEffect($info["id"], 4, ["description" => "取消优秀人才", "stateChange" => "有效->无效", "active" => 1])) {
  1768. $responseObj->code = 200;
  1769. $responseObj->msg = "取消优秀人才成功";
  1770. return json($responseObj);
  1771. }
  1772. $responseObj->msg = "系统错误,请联系管理员";
  1773. return json($responseObj);
  1774. }
  1775. /**
  1776. * 人才库-恢复人才
  1777. * @auth {{/talentInfo/libraryRecovery}}
  1778. */
  1779. public function recovery() {
  1780. $responseObj = new \stdClass();
  1781. $params = $this->request->param();
  1782. $info = VerifyApi::getOne($params["id"]);
  1783. if (!$params["id"] || !$info) {
  1784. $responseObj->msg = "系统错误,请联系管理员";
  1785. return json($responseObj);
  1786. }
  1787. if ($info["isEffect"] != 4) {
  1788. $responseObj->msg = "无法恢复有效数据";
  1789. return json($responseObj);
  1790. }
  1791. if (VerifyApi::setEffect($info["id"], 1, ["description" => "恢复优秀人才", "stateChange" => "无效->有效", "active" => 1])) {
  1792. $responseObj->code = 200;
  1793. $responseObj->msg = "恢复优秀人才成功";
  1794. return json($responseObj);
  1795. }
  1796. $responseObj->msg = "系统错误,请联系管理员";
  1797. return json($responseObj);
  1798. }
  1799. public function baseVerifyListExport() {
  1800. $this->commonExport(1);
  1801. }
  1802. public function baseReverifyListExport() {
  1803. $this->commonExport(2);
  1804. }
  1805. public function fstVerifyListExport() {
  1806. $this->commonExport(3);
  1807. }
  1808. public function deptVerifyListExport() {
  1809. $this->commonExport(4);
  1810. }
  1811. public function reVerifyListExport() {
  1812. $this->commonExport(5);
  1813. }
  1814. public function preListExport() {
  1815. $this->commonExport(6);
  1816. }
  1817. public function libraryListExport() {
  1818. $this->commonExport(7);
  1819. }
  1820. private function commonExport($process) {
  1821. $companyId = $this->user['companyId'];
  1822. $company = getCacheById("Company", $companyId);
  1823. $setting = [];
  1824. $params = $this->request->param();
  1825. $fields = $params["export"];
  1826. if (!$fields)
  1827. return json(["msg" => "请选择要导出的数据"]);
  1828. $names = DictApi::getTalentFields(4, in_array("isMatchZhiren", $fields));
  1829. $names["industryFieldNew"] = "产业领域";
  1830. $names["enterpriseName"] = "单位名称";
  1831. $names["enterpriseTag"] = "单位标签";
  1832. $names["street"] = "所属镇街";
  1833. $names["checkState"] = "审核状态";
  1834. $names["checkMsg"] = "审核意见";
  1835. $names["first_dept_check_time"] = "进入并审时间";
  1836. $names["verifyDepts"] = "审核部门";
  1837. $names["deptDescription"] = "审核部门意见";
  1838. $names["deptPass"] = "部门通过";
  1839. $names["deptReject"] = "部门驳回";
  1840. $names["deptWait"] = "部门待审";
  1841. $names["breakFaithName"] = "曾被相关主管部门列为失信个人";
  1842. $names["identifyMonth"] = "公布入选月份";
  1843. $names["certificateNo"] = "人才编号";
  1844. $names["activeName"] = "离职状态";
  1845. $names["cur_quit_time"] = "离职时间";
  1846. $names["first_submit_time"] = "首次确认提交时间";
  1847. $names["new_submit_time"] = "最新确认提交时间";
  1848. $list = VerifyApi::getExportDatas($process, $params);
  1849. if ($process == 4 && VerifyApi::chkUserInSuperDeptUsers()) {
  1850. $fields[] = "first_dept_check_time";
  1851. $fields[] = "verifyDepts";
  1852. $fields[] = "deptDescription";
  1853. $fields[] = "deptPass";
  1854. $fields[] = "deptReject";
  1855. $fields[] = "deptWait";
  1856. $verifyDescriptionColumn = getExcelColumnByIndex(count($fields) - 4);
  1857. $setting["font"][] = [sprintf("%s%d:%s%d", $verifyDescriptionColumn, 2, $verifyDescriptionColumn, count($list) + 1), 8, "宋体"];
  1858. $setting["width"][] = [$verifyDescriptionColumn, 45];
  1859. $verifyDeptsColumn = getExcelColumnByIndex(count($fields) - 5);
  1860. $setting["font"][] = [sprintf("%s%d:%s%d", $verifyDeptsColumn, 2, $verifyDeptsColumn, count($list) + 1), 8, "宋体"];
  1861. $setting["width"][] = [$verifyDeptsColumn, 30];
  1862. }
  1863. foreach ($fields as $field) {
  1864. $columns[] = $names[$field];
  1865. }
  1866. $datas = [];
  1867. for ($i = 0; $i < count($list); $i++) {
  1868. $data = [];
  1869. for ($n = 0; $n < count($fields); $n++) {
  1870. $cellValue = $list[$i][$fields[$n]];
  1871. $data[] = $cellValue;
  1872. if ($fields[$n] == "deptPass" && $cellValue > 0) {
  1873. $setting["color"][] = [sprintf("%s%d", getExcelColumnByIndex($n), $i + 2), "15dd0f"];
  1874. }
  1875. if ($fields[$n] == "deptReject" && $cellValue > 0) {
  1876. $setting["color"][] = [sprintf("%s%d", getExcelColumnByIndex($n), $i + 2), "ff0000"];
  1877. }
  1878. if ($fields[$n] == "deptWait" && $cellValue > 0) {
  1879. $setting["color"][] = [sprintf("%s%d", getExcelColumnByIndex($n), $i + 2), "fdcb54"];
  1880. }
  1881. }
  1882. $datas[] = $data;
  1883. }
  1884. $setting["freeze"] = "A2";
  1885. $setting["filter"] = sprintf("A1:%s1", getExcelColumnByIndex(count($columns) - 1));
  1886. if ($datas) {
  1887. export($columns, $datas, "人才审核列表导出", $setting);
  1888. exit();
  1889. }
  1890. echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
  1891. }
  1892. public function getPhones() {
  1893. $list = VerifyApi::getListByProcess($this->request->param());
  1894. $result = [];
  1895. if ($list) {
  1896. foreach ($list as $item) {
  1897. if ($item["phone"] && $item["name"]) {
  1898. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  1899. }
  1900. }
  1901. }
  1902. return json(["code" => 200, "obj" => implode(";", $result)]);
  1903. }
  1904. public function getEnterprisePhones() {
  1905. $list = VerifyApi::getListByProcess($this->request->param());
  1906. $result = [];
  1907. if ($list) {
  1908. foreach ($list as $item) {
  1909. if ($item["agentName"] && $item["agentPhone"]) {
  1910. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  1911. }
  1912. }
  1913. }
  1914. return json(["code" => 200, "obj" => implode(";", $result)]);
  1915. }
  1916. }