Talent.php 98 KB

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