Talent.php 97 KB

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