Talent.php 92 KB

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