Talent.php 103 KB

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