Talent.php 95 KB

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