Talent.php 106 KB

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