Talent.php 94 KB

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