Talent.php 103 KB

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