Talent.php 95 KB

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