Talent.php 101 KB

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