Talent.php 103 KB

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