Talent.php 92 KB

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