Talent.php 100 KB

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