1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107 |
- <?php
- namespace app\admin\controller;
- use app\admin\common\AdminController;
- use app\common\api\ChuanglanSmsApi;
- use app\common\api\VerifyApi;
- use app\common\api\TalentLogApi;
- use app\common\api\TalentState;
- use app\common\controller\Api;
- use app\common\model\MessageRecord;
- use app\enterprise\model\Talent as TalentModel;
- use app\common\api\TalentConditionApi;
- use app\common\api\DictApi;
- use app\common\api\EnterpriseApi;
- use think\facade\Db;
- use app\admin\model\User;
- use app\common\api\MenuApi;
- use app\admin\model\Menu;
- use app\admin\model\SysRelation;
- use app\common\api\CompanyApi;
- use app\common\state\ProjectState;
- use app\admin\api\RsApi;
- use app\admin\model\ApiData;
- use app\common\state\CommonConst;
- /**
- * Description of Talent
- *
- * @author sgq
- */
- class Talent extends AdminController {
- public function common_check() {
- $request = $this->request;
- $params = $request->param();
- $id = $params["id"];
- $process = $params["process"];
- $info = VerifyApi::getTalentInfoById($id, true);
- $force = intval($this->request['force'], 0);
- $api_data = ApiData::where('uid', '=', $info['card_number'])->where('action', '=', 'rending')->where('status', '=', 1)->find(); //
- if ($force || !$api_data || !$api_data['status']) {
- ApiData::where('uid', '=', $info['card_number'])->where('action', '=', 'rending')->where('status', '=', 1)->update(['status' => 0, 'updateTime' => time()]);
- $rsapi = new RsApi();
- if ($info['card_type'] == 1) {
- $content = [];
- $info['rs']['I010902'] = $content['I010902'] = $rsapi->I010902($info['card_number']);
- $info['rs']['I030101'] = $content['I030101'] = $rsapi->I030101($info['card_number']);
- /* * ***********************处理养老缴费判断开始*************** */
- if (!empty($info['tax_insurance_month'])) {
- $tmp_time = explode(' - ', $info['tax_insurance_month']);
- $content['YL00018'] = $rsapi->YL00018($info['card_number'], str_replace('-', '', $tmp_time[0]), str_replace('-', '', $tmp_time[1]));
- $formatDate = formatDateByMonth($tmp_time[0], $tmp_time[1], $content['YL00018']['data']['list']);
- $str = '';
- foreach ($formatDate as $tmp_item) {
- $str .= $tmp_item . "<br />";
- }
- if (count($formatDate) == $content['YL00018']['data']['totalCount']) {
- $content['YL00018']['status'] = 'success';
- } else {
- $content['YL00018']['status'] = 'warning';
- }
- $content['YL00018']['content'] = "该人员社保填写日期为{$tmp_time[0]}至{$tmp_time[1]},共" . count($formatDate) . "个月,接口返回{$content['YL00018']['data']['totalCount']}个月数据,分别为:<br />$str";
- $info['rs']['YL00018'] = $content['YL00018'];
- unset($tmp_time);
- unset($tmp_item);
- }
- /* * ***********************处理养老缴费判断结束*************** */
- /* * ***********************处理职业资格证书开始*************** */
- if (!empty($info['pro_qua'])) {
- $content['SBJ0007'] = $rsapi->SBJ0007($info['name'], $info['card_number']);
- if ($content['SBJ0007']['data']['totalCount'] > 0) {
- $tmp_str = '';
- foreach ($content['SBJ0007']['data']['list'] as $tmp_item) {
- $tmp_str .= "职业资格名称:{$tmp_item['ksmc']};级别名称:{$tmp_item['jbmc']};专业名称:{$tmp_item['zymc']}<br />";
- }
- $content['SBJ0007']['content'] = "该人员共有{$content['SBJ0007']['data']['totalCount']}条职业资格证书记录,分别为:<br />{$tmp_str}";
- } else {
- $content['SBJ0007']['content'] = "该人员查不到职业资格证书记录";
- }
- $info['rs']['SBJ0007'] = $content['SBJ0007'];
- }
- /* * ***********************处理职业资格证书结束*************** */
- /* * ***********************处理高校教育信息开始*************** */
- if (!empty($info['highest_degree'])) {
- $content['SBJ0004'] = $rsapi->SBJ0004($info['name'], $info['card_number']);
- if ($content['SBJ0004']['data']['totalCount'] > 0) {
- $tmp_str = '';
- foreach ($content['SBJ0004']['data']['list'] as $tmp_item) {
- $tmp_str .= "层次:{$tmp_item['cc']};毕业学校名称:{$tmp_item['yxmc']}({$tmp_item['rxrq']}-{$tmp_item['byrq']});专业名称:{$tmp_item['zymc']};学习形式:{$tmp_item['xxxs']};编号:{$tmp_item['zsbh']}<br />";
- }
- $content['SBJ0004']['content'] = "该人员共有{$content['SBJ0004']['data']['totalCount']}条高校教育,分别为:<br />{$tmp_str}";
- } else {
- $content['SBJ0004']['content'] = "该人员查不到高校教育信息";
- }
- $info['rs']['SBJ0004'] = $content['SBJ0004'];
- }
- /* * ***********************处理高校教育信息结束*************** */
- $api_model_data = [
- 'uid' => $info['card_number'],
- 'action' => 'rending',
- 'content' => serialize($content),
- 'createTime' => time()
- ];
- ApiData::create($api_model_data);
- }
- } else {
- $content = unserialize($api_data['content']);
- if (array_key_exists('YL00018', $content)) {
- $tmp_time = explode(' - ', $info['tax_insurance_month']);
- $formatDate = formatDateByMonth($tmp_time[0], $tmp_time[1], $content['YL00018']['data']['list']);
- $str = '';
- foreach ($formatDate as $tmp_item) {
- $str .= $tmp_item . "<br />";
- }
- if (count($formatDate) == $content['YL00018']['data']['totalCount']) {
- $content['YL00018']['status'] = 'success';
- } else {
- $content['YL00018']['status'] = 'warning';
- }
- $content['YL00018']['content'] = "该人员社保填写日期为{$tmp_time[0]}至{$tmp_time[1]},共" . count($formatDate) . "个月,接口返回{$content['YL00018']['data']['totalCount']}个月数据,分别为:<br />$str";
- unset($tmp_time);
- unset($tmp_item);
- } else {
- $content['YL00018'] = [];
- }
- $info['rs'] = $content;
- }
- $info["process"] = $process;
- if ($process == 7) {
- //如果有变更记录,这此处获取最初一条记录的旧值并覆盖$info中的新值
- }
- if (in_array($info["checkState"], [TalentState::BASE_VERIFY_FAIL, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_REJECT, TalentState::BASE_REVERIFY_FAIL])) {
- return view("talentInfo_base_check", ["info" => $info]);
- } else {
- switch ($info["enterpriseType"]) {
- case CommonConst::ENTERPRISE_NORMAL:
- $tpl = "talentInfo_common_check"; //$info["isImport"] ? "nofile_talentInfo_common_check" : "talentInfo_common_check";
- return view($tpl, ["info" => $info]);
- case CommonConst::ENTERPRISE_JC:
- return view("talentInfo_common_checkIC", ["info" => $info]);
- case CommonConst::ENTERPRISE_WJ:
- return view("/talent/hospital/new_talentInfo_common_check", ["info" => $info]);
- case CommonConst::ENTERPRISE_GJ:
- $config = getJsonConfig("../sys_config.json", "gj_special_person");
- if(array_key_exists($info['card_number'],$config)){
- $allow_other_place = 1;
- }else{
- $allow_other_place = 0;
- }
- return view("/talent/school/talentInfo_common_check", ["info" => $info,'allow_other_place' => $allow_other_place]);
- }
- }
- }
- public function getTalentInfoByIdCard() {
- $card_number = $this->request->param("idCard");
- $card_type = $this->request->param("cardType");
- $where = [];
- $where[] = ["ti.card_type", "=", $card_type];
- $where[] = ["ti.card_number", "=", $card_number];
- $where[] = ["ti.delete", "=", 0];
- $list = TalentModel::alias("ti")
- ->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")
- ->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")
- ->where($where)->order("ti.createTime desc")->field("ti.*,tl.last_state as 'lastState',tl.state as 'realState',e.name as enterpriseName")->select()->toArray();
- foreach ($list as $key => $item) {
- $list[$key]["checkStateName"] = TalentState::getStateName($item["realState"]);
- }
- return json(["rows" => $list]);
- }
- public function cancel_verify() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $msg = $params["msg"];
- if ($msg == "") {
- return json(["msg" => "请填写审核不通过的原因"]);
- }
- $ids_arr = array_filter(explode(",", $ids));
- $counts = 0;
- foreach ($ids_arr as $id) {
- $ti = VerifyApi::getOne($id);
- $data["id"] = $id;
- if ($ti["checkState"] == TalentState::FST_SUBMIT) {
- $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
- TalentLogApi::write(1, $id, TalentState::BASE_VERIFY_FAIL, $msg, 1);
- TalentModel::update($data);
- $counts++;
- } else if ($ti["checkState"] == TalentState::SCND_SUBMIT) {
- $data["checkState"] = TalentState::FST_VERIFY_FAIL;
- TalentLogApi::write(1, $id, TalentState::FST_VERIFY_FAIL, $msg, 1);
- TalentModel::update($data);
- $counts++;
- } else {
- return json(["msg" => "不在审核范围"]);
- }
- }
- return json(["code" => 200, "msg" => sprintf("%d个申请已审核不通过", $counts)]);
- }
- public function base_verify() {
- $enterprises = EnterpriseApi::getSimpleList();
- return view("", ["enterprises" => $enterprises]);
- }
- public function base_verify_list() {
- $params = $this->request->param();
- return json(VerifyApi::getList($params));
- }
- public function base_reverify() {
- $enterprises = EnterpriseApi::getSimpleList();
- return view("", ["enterprises" => $enterprises]);
- }
- public function base_reverify_list() {
- $params = $this->request->param();
- return json(VerifyApi::getList($params));
- }
- /**
- * 部门初审
- * @auth {{/talentInfo/gotoIndex/-1}}
- */
- public function dept_fst_verify() {
- return view();
- }
- /**
- * 初审
- * @auth {{/talentInfo/gotoIndex/1}}
- */
- public function fst_verify() {
- $tpl = "";
- $assigns = $this->getCommonAssigns();
- switch ($this->user["type"]) {
- case CommonConst::ENTERPRISE_WJ:
- $tpl = "/talent/hospital/fst_verify";
- $medicalCommunities = \app\common\api\Nhc::getMedicalCommunityList();
- $_assigns = ["medicalCommunities" => $medicalCommunities];
- $assigns = array_merge($assigns, $_assigns);
- break;
- }
- return view($tpl, $assigns);
- }
- /**
- * 初审-审核
- * @auth {{/talentInfo/firstCheck}}
- */
- public function fst_check() {
-
- }
- /**
- * 初审-审核不通过
- * @auth {{/talentInfo/setNotPass}}
- */
- public function dis_pass() {
-
- }
- /**
- * 部门审核
- * @auth {{/talentInfo/gotoIndex/2}}
- */
- public function dept_verify() {
- $tpl = "";
- $companys = CompanyApi::getAll();
- $superpriv = VerifyApi::chkUserInSuperDeptUsers();
- $commonAssigns = $this->getCommonAssigns();
- $assigns = ["companys" => $companys, "superpriv" => $superpriv];
- $newAssigns = array_merge($assigns, $commonAssigns);
- switch ($this->user["type"]) {
- case CommonConst::ENTERPRISE_WJ:
- $tpl = "/talent/hospital/dept_verify";
- $medicalCommunities = \app\common\api\Nhc::getMedicalCommunityList();
- $newAssigns["medicalCommunities"] = $medicalCommunities;
- break;
- }
- return view($tpl, $newAssigns);
- }
- /**
- * 复审
- * @auth {{/talentInfo/gotoIndex/3}}
- */
- public function re_verify() {
- $tpl = "";
- $assigns = $this->getCommonAssigns();
- switch ($this->user["type"]) {
- case CommonConst::ENTERPRISE_WJ:
- $tpl = "/talent/hospital/re_verify";
- $medicalCommunities = \app\common\api\Nhc::getMedicalCommunityList();
- $_assigns = ["medicalCommunities" => $medicalCommunities];
- $assigns = array_merge($assigns, $_assigns);
- break;
- }
- return view($tpl, $assigns);
- }
- /**
- * 预备人才库
- * @auth {{/talentInfo/gotoIndex/4}}
- */
- public function pre_list() {
- if ($this->user["type"] == 1) {
- $message = [
- "typeName" => "晋江市现代产业体系人才认定", "address" => "聚才网/人才晋江微信公众号", "dep" => "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心",
- "phone" => "0595-85633128", "email" => "jjrc85661234@163.com"
- ];
- } else {
- $message = [
- "typeName" => "晋江市集成电路产业优秀人才认定", "address" => "福建(晋江)集成电路产业园官方网站及微信公众号", "dep" => "集成电路产业园区",
- "phone" => "0595-82250007、0595-82250001", "email" => "jjjcdr@163.com"
- ];
- }
- $commonAssigns = $this->getCommonAssigns();
- $assigns = ["message" => $message];
- $newAssigns = array_merge($assigns, $commonAssigns);
- return view("", $newAssigns);
- }
- private function getCommonAssigns() {
- $type = $this->user["type"];
- $enterprises = EnterpriseApi::getSimpleList();
- $conditions = TalentConditionApi::getList([1, 2, 3, 4, 5, 6, 7], $type);
- $industry_field_new = array_column(DictApi::findChildDictByCode("industry_field"), "code");
- foreach ($industry_field_new as &$field) {
- $field .= "_field";
- }
- $parent_industry_fields = implode(",", $industry_field_new);
- $where[] = ["d2.code", "in", $parent_industry_fields];
- $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();
- return ["type" => $type, "enterprises" => $enterprises, "talent_conditions" => $conditions, "industry_field_old" => $industry_field_old];
- }
- /**
- * 优秀人才库
- * @auth {{/talentInfo/gotoIndex/5}}
- */
- public function library() {
- return view("", $this->getCommonAssigns());
- }
- public function selectNeedCheckData() {
- $params = $this->request->param();
- return json(["rows" => VerifyApi::getPublicList($params)]);
- }
- /**
- * 预备人才库-核查征信
- * @auth {{/talentInfo/prepareHczx}}
- */
- public function prepareHczx() {
- $ids = $this->request->param("ids");
- $ids_arr = array_filter(explode(",", $ids));
- if (!$ids_arr) {
- $res = ["code" => 500, "msg" => "没有选择导出的名单"];
- echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
- }
- $where[] = ["ti.id", "in", $ids_arr];
- $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();
- if (!$list) {
- $res = ["code" => 500, "msg" => "没有可以导出的内容"];
- echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
- }
- $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
- $rows = [];
- $i = 1;
- $card_types = DictApi::selectByParentCode("card_type");
- foreach ($list as $item) {
- $row = [
- $i, $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], $item["description"]
- ];
- $rows[] = $row;
- $i++;
- }
- $filename = "现代产业体系人才核查征信名单导出";
- if ($rows) {
- export($columns, $rows, $filename);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
- }
- /**
- * 预备人才库-征信通过
- * @auth {{/talentInfo/hczxPass}}
- */
- public function hczxPass() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $ids = array_filter(explode(",", $ids));
- $msg = "征信通过";
- $state = TalentState::ZX_PASS; //征信通过
- $total = count($ids);
- $error = 0;
- $success = 0;
- foreach ($ids as $id) {
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
- $error++;
- continue;
- }
- if (VerifyApi::setPublic($id, $state, $msg)) {
- $success++;
- } else {
- $error++;
- }
- }
- return json(["code" => 200, "msg" => sprintf("核查征信完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
- }
- /**
- * 预备人才库-征信失信
- * @auth {{/talentInfo/hczxReject}}
- */
- public function hczxReject() {
- $params = $this->request->param();
- $id = $params["id"];
- $msg = $params["outMsg"];
- if (!$msg)
- return json(["msg" => "请填写审核意见"]);
- $msg = "征信失信:" . $msg;
- $state = TalentState::ZX_FAIL; //征信不通过
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
- return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
- }
- if (VerifyApi::setPublic($id, $state, $msg)) {
- return json(["code" => 200, "msg" => "已设置征信失信"]);
- }
- return json(["msg" => "设置征信失信失败"]);
- }
- /**
- * 预备人才库-公示预览
- * @auth {{/talentInfo/publicExportBefore}}
- */
- public function publicExportBefore() {
- $params = $this->request->param();
- $ids_arr = array_filter(explode(",", $params["ids"]));
- $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
- if ($ids_arr) {
- $where[] = ["id", "in", $ids_arr];
- $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
- $rows = [];
- $i = 1;
- $talentArranges = DictApi::selectByParentCode("talent_arrange");
- foreach ($list as $item) {
- $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
- $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
- $checkLog = TalentLogApi::getLastLog($item["id"], 1);
- $row = [
- $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"]
- ];
- $rows[] = $row;
- $i++;
- }
- }
- if ($rows) {
- $filename = "现代产业体系人才公示预览导出";
- export($columns, $rows, $filename);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
- }
- /**
- * 预备人才库-公示导出
- * @auth {{/talentInfo/publicExport}}
- */
- public function publicExport() {
- $params = $this->request->param();
- $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
- $startTime = $params["startTime"];
- $endTime = $params["endTime"];
- if (!strtotime($startTime) || !strtotime($endTime))
- return json(["msg" => "时间格式错误"]);
- $where[] = ["checkState", "=", TalentState::ANNOUNCED];
- $where[] = ["publicBatch", "between", [$startTime, $endTime]];
- $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
- $rows = [];
- $i = 1;
- $talentArranges = DictApi::selectByParentCode("talent_arrange");
- foreach ($list as $item) {
- $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
- $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
- $checkLog = TalentLogApi::getLastLog($item["id"], 1);
- $row = [
- $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED ? "审核通过" : "审核不通过", $checkLog["description"]
- ];
- $rows[] = $row;
- $i++;
- }
- if ($rows) {
- $filename = "现代产业体系人才公示导出";
- export($columns, $rows, $filename);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
- }
- /**
- * 预备人才库-公示
- * @auth {{/talentInfo/preparePublic}}
- */
- public function preparePublic() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $publicBatch = $params["batch"];
- if (!$publicBatch || strlen($publicBatch) != 6 || !is_numeric($publicBatch))
- return json(["msg" => "公示批次错误"]);
- $isMessage = $params["isMessage"] == 1 ? true : false;
- if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
- return json(["msg" => "短信参数不能为空"]);
- }
- $ids = array_filter(explode(",", $ids));
- $msg = "已公示";
- $state = TalentState::ANNOUNCED; //公示
- $total = count($ids);
- $error = 0;
- $success = 0;
- $phones = [];
- foreach ($ids as $id) {
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::ZX_PASS) {
- $error++;
- continue;
- }
- if (VerifyApi::setPublic($id, $state, $msg, $publicBatch)) {
- $success++;
- $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
- $phones[] = $ep->agentPhone;
- } else {
- $error++;
- }
- }
- $phones = array_unique(array_filter($phones));
- if ($isMessage && $phones) {
- $sms = new \app\common\api\ChuanglanSmsApi();
- $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
- $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
- while ($phone = array_shift($phones)) {
- $result = $sms->sendSMS($phone, $tpl_content);
- $result = json_decode($result, true);
- $recordId = getStringId();
- $record_data = [
- 'id' => $recordId,
- 'bizId' => $result["msgId"],
- 'type' => 2,
- 'smsType' => 1,
- 'phone' => $phone,
- 'params' => '公示',
- 'templateCode' => $tpl_content,
- 'state' => $result['code'] == 0 ? 2 : 3,
- 'sendingDate' => date("Y-m-d H:i:s", time()),
- 'createTime' => date("Y-m-d H:i:s", time()),
- 'msg' => $result['errorMsg']
- ];
- MessageRecord::create($record_data);
- }
- }
- return json(["code" => 200, "msg" => sprintf("公示完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
- }
- /**
- * 预备人才库-公示再审核
- * @auth {{/talentInfo/prepareCheck}}
- */
- public function prepareCheck() {
- $params = $this->request->param();
- $id = $params["id"];
- $checkState = $params["checkState"];
- $msg = $params["checkMsg"];
- if (!$msg)
- return json(["msg" => "请填写审核意见"]);
- if ($checkState == 1) {
- $msg = "公示再审核通过:" . $msg;
- $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
- } else {
- $msg = "公示再审核不通过:" . $msg;
- $state = TalentState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
- }
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
- return json(["msg" => "当前记录不是公示状态,无法审核"]);
- }
- if (VerifyApi::setPublic($id, $state, $msg)) {
- return json(["code" => 200, "msg" => "公示再审核完成"]);
- }
- return json(["msg" => "公示再审核失败"]);
- }
- /**
- * 预备人才库-公示通过(批量)
- * @auth {{/talentInfo/publicPass}}
- */
- public function publicPass() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $ids = array_filter(explode(",", $ids));
- $msg = "公示再审核批量通过";
- $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
- $total = count($ids);
- $error = 0;
- $success = 0;
- foreach ($ids as $id) {
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
- $error++;
- continue;
- }
- if (VerifyApi::setPublic($id, $state, $msg)) {
- $success++;
- } else {
- $error++;
- }
- }
- return json(["code" => 200, "msg" => sprintf("公示再审核完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
- }
- /**
- * 预备人才库-公布预览
- * @auth {{/talentInfo/publishExportBefore}}
- */
- public function publishExportBefore() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $ids = array_filter(explode(",", $ids));
- if ($ids) {
- $where[] = ["id", "in", $ids];
- $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
- $rows = [];
- $i = 1;
- $talentArranges = DictApi::selectByParentCode("talent_arrange");
- foreach ($list as $item) {
- $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
- $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
- $checkLog = TalentLogApi::getLastLog($item["id"], 1);
- $row = [
- $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"]
- ];
- $rows[] = $row;
- $i++;
- }
- }
- $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
- $filename = "现代产业体系人才" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
- if ($rows) {
- export($columns, $rows, $filename);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
- }
- /**
- * 预备人才库-公布导出
- * @auth {{/talentInfo/publishExport}}
- */
- public function publishExport() {
- $params = $this->request->param();
- $startTime = $params["startTime"];
- $endTime = $params["endTime"];
- if (!strtotime($startTime) || !strtotime($endTime))
- return json(["msg" => "时间格式错误"]);
- $where[] = ["checkState", "=", TalentState::PUBLISH_PASS];
- $where[] = ["certificateGetTime", "between", [$startTime, $endTime]];
- $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
- $rows = [];
- $i = 1;
- $talentArranges = DictApi::selectByParentCode("talent_arrange");
- foreach ($list as $item) {
- $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
- $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
- $checkLog = TalentLogApi::getLastLog($item["id"], 1);
- $row = [
- $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"]
- ];
- $rows[] = $row;
- $i++;
- }
- $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
- $filename = "现代产业体系人才" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
- if ($rows) {
- export($columns, $rows, $filename);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
- }
- /**
- * 预备人才库-公布
- * @auth {{/talentInfo/publish}}
- */
- public function publish() {
- $params = $this->request->param();
- $id = $params["id"];
- $msg = $params["checkMsg"];
- $checkState = $params["checkState"];
- $batch = $params["batch"];
- if ($checkState == 1) {
- $state = TalentState::PUBLISH_PASS;
- $msg = "公布审核通过:" . $msg;
- } else {
- $state = TalentState::PUBLISH_FAIL;
- $msg = "公布审核不通过:" . $msg;
- }
- if (!$batch || !strtotime($batch))
- return json(["msg" => "公布批次时间错误"]);
- if (!$msg)
- return json(["msg" => "请填写审核意见"]);
- $state = TalentState::PUBLISH_PASS; //公示再审核通过
- $batch = $params["batch"];
- if (!strtotime($batch))
- return json(["msg" => "公布批次时间错误"]);
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
- return json(["msg" => "当前记录不是公示再审核通过状态,无法审核"]);
- }
- if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
- return json(["code" => 200, "msg" => "公布审核完成"]);
- }
- return json(["msg" => "公布审核失败"]);
- }
- /**
- * 预备人才库-批量公布通过
- * @auth {{/talentInfo/preparePublish}}
- */
- public function preparePublish() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $ids = array_filter(explode(",", $ids));
- $msg = "批量公布";
- $state = TalentState::PUBLISH_PASS; //公示再审核通过
- $batch = $params["batch"];
- if (!strtotime($batch))
- return json(["msg" => "公布批次时间错误"]);
- $total = count($ids);
- $error = 0;
- $success = 0;
- foreach ($ids as $id) {
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
- $error++;
- continue;
- }
- if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
- $success++;
- } else {
- $error++;
- }
- }
- return json(["code" => 200, "msg" => sprintf("公布完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
- }
- /**
- * 预备人才库-批量发放人才码
- * @auth {{/talentInfo/prepareCertification}}
- */
- public function prepareCertification() {
- $lockFile = fopen("send_certificate.lock", "a");
- if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
- //查询所有待发放人才码的数据
- $params = $this->request->param();
- $ids = array_filter(explode(",", $params["ids"]));
- //晋江市优秀人才证书:当前年份+层次+四位递增数字
- //集成电路优秀人才证书:IC+当前年份+递增四位数,如IC20190001
- Db::startTrans();
- $talent_max_no = [];
- $user = $this->user;
- $_prefix_type = "";
- $subindex = 5;
- switch ($user["type"]) {
- case CommonConst::ENTERPRISE_JC:
- $_prefix_type = "IC";
- $subindex += strlen($_prefix_type);
- break;
- }
- try {
- $talent_list = VerifyApi::getListByIds($ids);
- $year = date("Y");
- foreach ($talent_list as $talent_info) {
- if ($talent_info["checkState"] != TalentState::PUBLISH_PASS) {
- Db::rollback();
- return json(["msg" => "只能对公布通过的对象发放人才码,请核查待发放人才码名单后再重新发放人才码"]);
- }
- /* 检查是否有存在人才码,保持同一个人唯一 */
- $where = [];
- $where[] = ["card_type", "=", $talent_info["card_type"]];
- $where[] = ["card_number", "=", $talent_info["card_number"]];
- $where[] = ["checkState", "=", TalentState::CERTIFICATED];
- $fstTalentInfo = Db::table("new_talent_info")->where($where)->order("createTime asc")->find(); //取第一条全通记录
- if ($fstTalentInfo) {
- $max_no = $fstTalentInfo["certificateNo"];
- } else {
- $no_prefix = $_prefix_type . $year . $talent_info["talent_arrange"];
- $where = [];
- $where[] = ["certificateNo", "like", $no_prefix . "%"];
- $max_no = $talent_max_no[$talent_info["talent_arrange"]] ?: Db::table("new_talent_info")->where($where)->max("certificateNo", false);
- if (!$max_no) {
- $max_no = $no_prefix . "0001";
- } else {
- $new_no = intval(substr($max_no, $subindex)) + 1;
- $max_no = $no_prefix . str_pad($new_no, 4, "0", STR_PAD_LEFT);
- }
- }
- //更新证书编号
- $data["id"] = $talent_info["id"];
- $data["certificateNo"] = $max_no;
- $data["checkState"] = TalentState::CERTIFICATED;
- $data["isEffect"] = 1;
- $data["isPublic"] = 5;
- Db::table("new_talent_info")->update($data);
- //写入日志
- $log["last_state"] = TalentState::PUBLISH_PASS;
- $log["id"] = getStringId();
- $log["state"] = $log["new_state"] = TalentState::CERTIFICATED;
- $log["type"] = 1;
- $log["mainId"] = $talent_info["id"];
- $log["companyId"] = $user["companyId"];
- $log["active"] = 1;
- $log["description"] = "人才码为:" . $max_no;
- $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);
- $log["createTime"] = date("Y-m-d H:i:s");
- Db::table("new_talent_checklog")->insert($log);
- $talent_max_no[$talent_info["talent_arrange"]] = $max_no;
- }
- Db::commit();
- if ($user["type"] == 2) {
- //办法上只写电路人才,所以暂时只给电路增加基础分
- $_ids = array_column($talent_list, "id");
- for ($i = 0; $i < count($_ids); $i++) {
- queue("app\job\Talent", ["type" => 4, "id" => $_ids[$i]]);
- }
- }
- return json(["code" => 200, "msg" => "发放人才码成功"]);
- } catch (\Exception $e) {
- Db::rollback();
- return json(["msg" => "发放人才码失败:" . $e->getMessage()]);
- }
- flock($lockFile, LOCK_UN);
- } else {
- return json(["msg" => "同一时间只能有一个管理员进行发放人才码操作"]);
- }
- }
- /**
- * 预备人才库-撤销公布
- * @auth {{/talentInfo/prepareCanclePublish}}
- */
- public function pre_cancel_publish() {
-
- }
- /**
- * 基本条件审核-提交未保存
- * @param \think\Request $request
- * @param type $talent_info
- * @return type json
- */
- private function baseCheck(\think\Request $request, $talent_info) {
- $params = $request->param();
- if ($params["checkState"] == 3) {
- //审核成功
- $log_checkState = $checkState = TalentState::BASE_VERIFY_PASS; //基础信息审核成功
- } else {
- //审核驳回并记录需要修改的字段和上传文件
- $checkState = TalentState::FST_SAVE; //退回提交材料阶段
- $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
- }
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log)
- return json(["msg" => "日志数据异常,保存失败"]);
- if ($log["active"] == 0) {
- TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- } else {
- TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- }
- $data["id"] = $talent_info["id"];
- $data["modify_files"] = $params["files"];
- $data["modify_fields"] = $params["fields"];
- TalentModel::update($data);
- return json(["code" => 200, "msg" => "保存成功"]);
- }
- /**
- * 基本条件审核-提交审核
- * @param type $talent_info
- * @return type json
- */
- private function baseSubmitCheck($talent_info) {
- return $this->commonSubmitCheck($talent_info, 1);
- }
- /**
- * 基本条件复审-提交未保存
- * @param \think\Request $request
- * @param type $talent_info
- * @return type json
- */
- private function baseReCheck(\think\Request $request, $talent_info) {
- $params = $request->param();
- if ($params["checkState"] == 3) {
- //审核成功
- $log_checkState = $checkState = TalentState::BASE_REVERIFY_PASS; //基础信息复审成功
- } else if ($params["checkState"] == 2) {
- //审核驳回并记录需要修改的字段和上传文件
- $checkState = TalentState::FST_SUBMIT; //退回待基础审核状态
- $log_checkState = TalentState::BASE_REVERIFY_REJECT; //日志记录拒绝状态
- } else {
- $log_checkState = $checkState = TalentState::BASE_REVERIFY_FAIL; //审核失败
- }
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log)
- return json(["msg" => "日志数据异常,保存失败"]);
- if ($log["active"] == 0) {
- TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- } else {
- TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- }
- $data["id"] = $talent_info["id"];
- $data["modify_files"] = $params["files"];
- $data["modify_fields"] = $params["fields"];
- TalentModel::update($data);
- return json(["code" => 200, "msg" => "保存成功"]);
- }
- /**
- * 基本条件复审-提交审核
- * @param type $talent_info
- * @return type json
- */
- private function baseReSubmitCheck($talent_info) {
- return $this->commonSubmitCheck($talent_info, 2);
- }
- /**
- * 初审-提交未保存
- * @param \think\Request $request
- * @param type $talent_info
- * @return type json
- */
- private function fstCheck(\think\Request $request, $talent_info, $ep) {
- $params = $request->param();
- $data["pass_dept_check"] = 0;
- if ($params["checkState"] == 3) {
- //审核成功,并取消设置越过部门并审
- $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
- if ($talent_info["isImport"] && $talent_info["isMatchZhiren"]) {
- $data["pass_dept_check"] = 1;
- }
- if (in_array($ep["type"], [CommonConst::ENTERPRISE_GJ, CommonConst::ENTERPRISE_WJ]) && $talent_info["is_fujian_talent"] == 1 && $talent_info["is_jinjiang_talent"] == 1) {
- $data["pass_dept_check"] = 1;
- }
- } else if ($params["checkState"] == 4) {
- if ($talent_info["highProcess"] < 3)
- return json(["msg" => "只有曾经达到过部门并审,初审时才可以选择直接跳过部门并审阶段"]);
- //审核成功,并设置越过部门并审。附加条件:最高进度曾经通过初审3,上级驳回后重新初审的
- $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
- if ($talent_info["highProcess"] >= 3) {
- $data["pass_dept_check"] = 1;
- }
- } else if ($params["checkState"] == 5) {
- //选择重审部门
- if ($talent_info["highProcess"] < 3)
- return json(["msg" => "只有曾经达到过部门并审,初审时才可以选择再次审核的部门"]);
- if (!$params["companys"])
- return json(["msg" => "请选择需要再次审核的部门"]);
- //以下注释12部分为重审部门的限制,未通过并未选择的部门需要选择才能保存审核,注释备用
- //1$pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
- $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
- $re_check_companys = array_filter(explode(",", $params["companys"]));
- /* 2$unpass_companyIds = array_diff($companyIds, $pass_companyIds);
- $unselect_companyIds = [];
- foreach ($unpass_companyIds as $unpass_companyId) {
- if (!in_array($unpass_companyId, $re_check_companys))
- $unselect_companyIds[] = $unpass_companyId;
- }
- if ($unselect_companyIds) {
- $unselect_companyName = [];
- foreach ($unselect_companyIds as $unselect_companyId) {
- $unselect_companyName[] = getCacheById("Company", $unselect_companyId)["name"];
- }
- return json(["msg" => "以下部门未通过,需要勾选重新审核:<br>" . implode("<br>", $unselect_companyName)]);
- } */
- foreach ($re_check_companys as $reCompanyId) {
- if (!in_array($reCompanyId, $companyIds)) {
- return json(["msg" => "错误的部门"]);
- }
- }
- $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
- } else {
- //审核驳回并记录需要修改的字段和上传文件
- if ($ep["type"] == CommonConst::ENTERPRISE_WJ) {
- if ($params["checkState"] == 6) {
- //驳回到分院
- if ($ep["isGeneral"] == 1) {
- return json(["msg" => "总院不能驳回到分院"]);
- } else {
- $checkState = TalentState::FST_SAVE;
- }
- } else {
- if ($ep["isGeneral"] == 1) {
- $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
- } else {
- if (\app\common\api\Nhc::hasGeneralHospital($talent_info["medicalCommunityId"])) {
- $checkState = TalentState::FST_SUBMIT;
- } else {
- $checkState = TalentState::FST_SAVE;
- }
- }
- }
- } else {
- $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
- }
- $log_checkState = TalentState::FST_VERIFY_REJECT; //日志记录拒绝状态
- }
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log && !$talent_info["oldId"])
- return json(["msg" => "日志数据异常,保存失败"]);
- if ($log["active"] === 0) {
- TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- } else {
- TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- }
- $data["id"] = $talent_info["id"];
- $data["modify_files"] = $params["files"];
- $data["modify_fields"] = $params["fields"];
- $data["re_check_companys"] = $params["companys"];
- TalentModel::update($data);
- return json(["code" => 200, "msg" => "保存成功"]);
- }
- /**
- * 初审-提交审核
- * @param type $talent_info
- * @return type json
- */
- private function fstSubmitCheck($talent_info, $ep) {
- $nowProcess = 3;
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log || $log["active"] == 1)
- return json(["msg" => "请先保存审核状态,再提交审核"]);
- if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
- $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
- }
- $userIds = [];
- if ($log["state"] == TalentState::FST_VERIFY_PASS && $talent_info["pass_dept_check"] == 0) {
- $data["first_dept_check_time"] = date("Y-m-d H:i:s");
- $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
- if ($talent_info["re_check_companys"]) {
- $unpass_companyIds = array_filter(explode(",", $talent_info["re_check_companys"]));
- } else {
- //这边去除已经审核通过的单位,主要通过日志是否存在记录。
- $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
- $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
- if (!$unpass_companyIds) {
- $data["pass_dept_check"] = 1; //部门已经全部审核过了,跳过部门审核
- }
- }
- if ($unpass_companyIds) {
- sort($unpass_companyIds);
- $delay = 9 * 24 * 3600; //9天的秒数
- queue("app\job\Talent", ["type" => 1, "id" => $talent_info["id"]], $delay); //加入部门审核超期处理队列,延迟7天执行
- TalentLogApi::writeDeptLogs($talent_info["id"], $unpass_companyIds, TalentState::FST_VERIFY_PASS);
- //初审通过发送短信通知并审部门
- $codes = ["talentInfo_depCheck"];
- $menuIds = MenuApi::getMenuIdsByCodes($codes);
- $where = [];
- $where[] = ["menuid", "in", $menuIds];
- $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
- $where = [];
- $where[] = ["status", "=", 1];
- $where[] = ["type", "=", $this->user["type"]];
- $where[] = ["companyId", "in", $unpass_companyIds];
- $where[] = ["roleid", "<>", 1];
- $regstr = ",(" . implode("|", $roleIds) . "),";
- $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
- $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
- /* $privs = ["/admin/talent/dept_check"];
- $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
- $where[] = ["menuid", "in", $menuIds];
- $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
- $where = [];
- $where[] = ["status", "=", 1];
- $where[] = ["companyId", "in", $unpass_companyIds];
- $where[] = ["roleid", "in", $roleIds];
- $where[] = ["roleid", "<>", 1];
- $userIds = User::where($where)->column("id"); */
- }
- }
- $data["id"] = $talent_info["id"];
- $data["checkState"] = $log["new_state"];
- TalentModel::update($data);
- TalentLogApi::setActive($log["id"], 1);
- $this->sendMsgByState($talent_info, $log["state"], $userIds, $log["description"]);
- return json(["code" => 200, "msg" => "审核成功"]);
- }
- /**
- * 部门审核-提交未保存
- * @param \think\Request $request
- * @param type $talent_info
- * @return type json
- */
- private function deptCheck(\think\Request $request, $talent_info, $companys) {
- if ($talent_info["pass_dept_check"] == 1)
- return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
- if (!in_array($this->user["companyId"], $companys))
- return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
- $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
- $un_check_companyIds = TalentLogApi::getUnCheckDepts($talent_info["id"]); //未审核提交的单位
- if (!in_array($this->user["companyId"], $un_check_companyIds) && in_array($this->user["companyId"], $pass_companyIds)) {
- //判断不在未审核列表的同时判断已经在审核列表,是为了排除意外情况:缺失的待审核部门(通常是认证条件新增审核部门导致新增的部门未在审核列表中)
- //缺失的待审核部门,作为未审状态,将在函数末尾根据当前审核情况补充一条保存未提交的记录
- return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
- }
- $params = $request->param();
- if ($params["checkState"] == 3) {
- //审核成功
- $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
- $checkState = TalentState::DEPT_VERIFY_PASS; //审核成功
- } else {
- //审核驳回并记录需要修改的字段和上传文件
- $checkState = TalentState::SCND_SUBMIT; //退回待初审
- $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
- $talent_condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- if (!$talent_condition["companyWithFileType"])
- return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
- $cwfts = explode(";", $talent_condition["companyWithFileType"]);
- $company_setting = [];
- foreach ($cwfts as $cwft) {
- $_company_setting = explode(":", $cwft);
- if ($_company_setting[0] == $this->user["companyId"]) {
- $company_setting = explode(",", $_company_setting[1]);
- break;
- }
- }
- if (!$company_setting)
- return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
- //$data["modify_fields"] = $params["fields"];
- $original_modify_files = explode(",", $talent_info["modify_files"]);
- $_current_modify_files = explode(",", $params["files"]);
- $unselect_files = array_diff($company_setting, $_current_modify_files); //比较设置和当前提交的,取差值集,既是可选而未选的附件集合
- $new_modify_files = array_unique(array_merge($original_modify_files, $_current_modify_files)); //合并当前提交及库中原来保存的值
- foreach ($new_modify_files as $key => $item) {
- if (in_array($item, $unselect_files))
- unset($new_modify_files[$key]);
- }
- $data["modify_files"] = implode(",", array_unique($new_modify_files));
- }
- $fst_dept_check_time = $talent_info["first_dept_check_time"];
- $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $fst_dept_check_time);
- if ($dept_log["active"] == 1)
- return json(["msg" => "您的部门已经审核过了"]);
- $data["id"] = $talent_info["id"];
- TalentModel::update($data);
- //修改日志
- if (!$dept_log) {
- TalentLogApi::write(ProjectState::TALENT, $talent_info["id"], [$log_checkState, $checkState, 3], $params["checkMsg"]); //补一条记录
- //return json(["msg" => "未匹配日志,审核失败"]);
- } else {
- TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- }
- return json(["code" => 200, "msg" => "保存成功"]);
- }
- /**
- * 部门审核-提交审核
- * @param type $talent_info
- * @return type json
- */
- private function deptSubmitCheck($talent_info, $companys) {
- if ($talent_info["pass_dept_check"] == 1)
- return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
- if (!in_array($this->user["companyId"], $companys))
- return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
- $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
- if (in_array($this->user["companyId"], $pass_companyIds))
- return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
- $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $talent_info["first_dept_check_time"]);
- //if (!$dept_log)
- //return json(["msg" => "未匹配日志,审核失败"]);
- if ($dept_log["state"] == $dept_log["new_state"] || !$dept_log)
- return json(["msg" => "请先保存审核状态,再提交审核"]);
- if ($dept_log["active"] == 1)
- return json(["msg" => "您的部门已经审核过了"]);
- if ($talent_info["re_check_companys"]) {
- $re_check_companys = array_filter(explode(",", $talent_info["re_check_companys"]));
- $companys = VerifyApi::getNewReCheckCompanyIds($re_check_companys, $companys, $pass_companyIds);
- $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"], $talent_info["first_dept_check_time"]); //重审单位中已经通过的单位
- }
- $no_valid_companyIds = array_diff($pass_companyIds, $companys);
- $pass_companyIds = array_diff($pass_companyIds, $no_valid_companyIds);
- $over = $pass_companyIds ? count($pass_companyIds) : 0; //完成度,如果重审之前已有通过审核的部门,不用再审,直接按通过算
- $error = 0; //失败数
- $nowProcess = 4;
- $over++;
- if ($dept_log["new_state"] == TalentState::SCND_SUBMIT) {
- $error++;
- }
- $logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
- for ($i = 0; $i < count($logs); $i++) {
- if (!in_array($logs[$i]["companyId"], $pass_companyIds) && in_array($logs[$i]["companyId"], $companys)) {
- $over += $logs[$i]["active"] == 1 ? 1 : 0;
- if ($logs[$i]["new_state"] == TalentState::SCND_SUBMIT) {
- $error++;
- }
- }
- }
- if ($over == count($companys)) {
- //全部已审核
- $checkState = TalentState::SCND_SUBMIT;
- $log_checkState = TalentState::DEPT_VERIFY_REJECT;
- if ($error == 0) {
- $log_checkState = $checkState = TalentState::DEPT_VERIFY_PASS;
- $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
- $data["modify_files"] = null;
- }
- if ($log_checkState == TalentState::DEPT_VERIFY_REJECT) {
- $talent_condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- $cwfts = explode(";", $talent_condition["companyWithFileType"]);
- $fileTypes = [];
- foreach ($cwfts as $cwft) {
- $_company_setting = explode(":", $cwft);
- $_fileTypes = explode(",", $_company_setting[1]);
- $fileTypes = array_merge($fileTypes, $_fileTypes);
- }
- $modify_files = explode(",", $talent_info["modify_files"]);
- $removeFileTypes = array_diff($modify_files, $fileTypes);
- $newModifyFiles = array_diff($modify_files, $removeFileTypes);
- $data["modify_files"] = implode(",", $newModifyFiles);
- }
- $data["id"] = $talent_info["id"];
- $data["checkState"] = $checkState;
- $data["first_dept_check_time"] = null;
- $data["re_check_companys"] = null;
- TalentModel::update($data);
- TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "部门审核结束", 1);
- if ($log_checkState == TalentState::DEPT_VERIFY_REJECT) {
- //部门驳回发送短信通知
- $codes = ["talentInfo_firstCheck"];
- $menuIds = MenuApi::getMenuIdsByCodes($codes);
- $where = [];
- $where[] = ["menuid", "in", $menuIds];
- $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
- $where = [];
- $where[] = ["status", "=", 1];
- $where[] = ["type", "=", $this->user["type"]];
- $where[] = ["roleid", "<>", 1];
- $regstr = ",(" . implode("|", $roleIds) . "),";
- $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
- $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
- /* $privs = ["admin/talent/fst_check"];
- $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
- $where[] = ["menuid", "in", $menuIds];
- $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
- $where = [];
- $where[] = ["status", "=", 1];
- $where[] = ["roleid", "in", $roleIds];
- $where[] = ["roleid", "<>", 1];
- $userIds = User::where($where)->column("id"); */
- $this->sendMsgByState($talent_info, $log_checkState, $userIds, $dept_log["description"]);
- }
- }
- TalentLogApi::setActive($dept_log["id"], 1);
- return json(["code" => 200, "msg" => "审核成功"]);
- }
- /**
- * 复审-提交未保存
- * @param \think\Request $request
- * @param type $talent_info
- * @param type json
- */
- private function reCheck(\think\Request $request, $talent_info) {
- $params = $request->param();
- if ($params["checkState"] == 3) {
- //审核成功
- $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
- } else if ($params["checkState"] == 2) {
- //审核驳回并记录需要修改的字段和上传文件
- $checkState = TalentState::SCND_SUBMIT; //退回待初审
- $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
- } else {
- $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
- }
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log && !$talent_info["oldId"])
- return json(["msg" => "日志数据异常,保存失败"]);
- if ($log["active"] === 0) {
- TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- } else {
- TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- }
- $data["id"] = $talent_info["id"];
- $data["modify_files"] = $params["files"];
- $data["modify_fields"] = $params["fields"];
- TalentModel::update($data);
- return json(["code" => 200, "msg" => "保存成功"]);
- }
- /**
- * 复审-提交审核
- * @param type $talent_info
- * @return type json
- */
- private function reSubmitCheck($talent_info) {
- return $this->commonSubmitCheck($talent_info, 5);
- }
- private function commonSubmitCheck($talent_info, $nowProcess) {
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log || $log["active"] == 1)
- return json(["msg" => "请先保存审核状态,再提交审核"]);
- if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
- $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
- }
- $data["id"] = $talent_info["id"];
- $data["checkState"] = $log["new_state"];
- TalentModel::update($data);
- TalentLogApi::setActive($log["id"], 1);
- $userIds = [];
- if (in_array($log["state"], [TalentState::REVERIFY_PASS, TalentState::REVERIFY_REJECT])) {
- //复核成功需要发送短信给征信部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
- //从征信审核权限,逆推征信部门
- if ($data["checkState"] == TalentState::REVERIFY_PASS) {
- $codes = ["talentInfohczxReject", "talentInfohczxPass"];
- } else {
- $codes = ["talentInfo_firstCheck"];
- }
- $menuIds = MenuApi::getMenuIdsByCodes($codes);
- $where = [];
- $where[] = ["menuid", "in", $menuIds];
- $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
- $where = [];
- $where[] = ["status", "=", 1];
- $where[] = ["type", "=", $this->user["type"]];
- $where[] = ["roleid", "<>", 1];
- $regstr = ",(" . implode("|", $roleIds) . "),";
- $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
- $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
- /* if ($data["checkState"] == TalentState::REVERIFY_PASS) {
- $privs = ["/admin/talent/hczxReject", "/admin/talent/hczxPass"];
- } else {
- $privs = ["admin/talent/fst_check"];
- }
- $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
- $where = [];
- $where[] = ["menuid", "in", $menuIds];
- $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
- $where = [];
- $where[] = ["status", "=", 1];
- $where[] = ["roleid", "in", $roleIds];
- $where[] = ["roleid", "<>", 1];
- $userIds = User::where($where)->column("id"); */
- }
- $this->sendMsgByState($talent_info, $log["state"], $userIds, $log["description"]);
- return json(["code" => 200, "msg" => "审核成功"]);
- }
- private function sendMsgByState($talent_info, $state, $userIds = [], $description = "") {
- $phones = [];
- $template = "";
- $type = 0;
- $processName = "";
- $userId = 0;
- $name = null;
- switch ($state) {
- case TalentState::BASE_VERIFY_PASS://基础信息审核通过发送短信通知用户
- $type = 2;
- $processName = "基础信息审核";
- $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核通过,请及时登录申报系统并进行人才认定的信息申报填写。";
- break;
- case TalentState::BASE_REJECT://基础信息审核驳回发送短信通知用户
- $type = 2;
- $processName = "基础信息审核";
- $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核驳回,原因是:{$description},请及时登录申报系统修改并重新提交。";
- break;
- case TalentState::BASE_VERIFY_FAIL://基础信息审核不通过发送短信通知用户
- $type = 2;
- $processName = "基础信息审核";
- $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核不通过,原因是:{$description}。";
- break;
- case TalentState::FST_VERIFY_PASS://初审通过发送短信通知并审部门
- $type = 1;
- $processName = "初级审核";
- $template = "【晋江市人才服务平台】您的部门有新的人才认定申报需要审批,请及时登录审批系统处理。";
- break;
- case TalentState::FST_VERIFY_REJECT; //初审驳回发送短信通知用户
- $type = 2;
- $processName = "初级审核";
- $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$description},请及时登录申报系统修改并重新提交。";
- break;
- case TalentState::FST_VERIFY_FAIL://初审不通过发送短信通知用户
- $type = 2;
- $processName = "初级审核";
- $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核不通过,原因是:{$description}。";
- break;
- case TalentState::DEPT_VERIFY_REJECT://并审驳回发送短信通知初审部门
- $type = 1;
- $processName = "部门并审";
- $template = "【晋江市人才服务平台】有人才认定申报在并审阶段被驳回,原因是:{$description},请及时登录审批系统处理。";
- break;
- case TalentState::REVERIFY_PASS://复核通过发短信通知征信部门
- $type = 1;
- $processName = "复审";
- $template = "【晋江市人才服务平台】有新的人才认定申报通过复审进入征信阶段,请及时登录审批系统处理。";
- break;
- case TalentState::REVERIFY_REJECT://复核驳回发短信通知初审部门
- $type = 1;
- $processName = "复审";
- $template = "【晋江市人才服务平台】有人才认定申报在复审阶段被驳回,原因是:{$description},请及时登录审批系统处理。";
- break;
- }
- if ($type == 1) {
- $where = [];
- $where[] = ["id", "in", $userIds];
- $where[] = ["type", "<>", CommonConst::ENTERPRISE_JC]; //集成电路审核端停短信
- $phones = User::where($where)->column("phone");
- $phones = array_unique(array_filter($phones));
- }
- if ($type == 2) {
- $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
- $phones[] = $ep->agentPhone;
- $userId = $ep->id;
- $name = $ep->name;
- }
- if ($phones && $template) {
- while ($phone = array_shift($phones)) {
- $smsapi = new ChuanglanSmsApi();
- $result = $smsapi->sendSMS($phone, $template);
- $result = json_decode($result, true);
- $id = getStringId();
- $record_data = [
- 'id' => $id,
- 'userId' => $userId,
- 'bizId' => $result["msgId"],
- 'type' => $type,
- 'smsType' => 2,
- 'name' => $name,
- 'phone' => $phone,
- 'params' => $processName,
- 'templateCode' => $template,
- 'state' => $result['code'] == 0 ? 2 : 3,
- 'sendingDate' => date("Y-m-d H:i:s", time()),
- 'createTime' => date("Y-m-d H:i:s", time()),
- 'msg' => $result['errorMsg']
- ];
- MessageRecord::create($record_data);
- }
- }
- }
- public function check() {
- //公共调度方法
- $request = $this->request;
- $params = $request->param();
- $check = $params["checkState"];
- $check_msg = trim($params["checkMsg"]);
- $files = $params["files"];
- $fields = $params["fields"];
- $id = $params["id"];
- $talent_info = VerifyApi::getOne($id);
- $ep = EnterpriseApi::getOne($talent_info["enterprise_id"]);
- $checkState = $talent_info["checkState"];
- if (!$talent_info || !$ep) {
- return json(["msg" => "数据错误"]);
- }
- if ($ep["type"] != $this->user["type"]) {
- return json(["msg" => "不能审核的人才类型"]);
- }
- if (!$check) {
- return json(["msg" => "请选择审核状态"]);
- }
- if (!$check_msg) {
- return json(["msg" => "请填写审核说明"]);
- }
- if ($checkState == TalentState::FST_SUBMIT) {
- return $this->baseCheck($request, $talent_info);
- } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
- return $this->baseReCheck($request, $talent_info);
- } else if ($checkState == TalentState::SCND_SUBMIT) {
- return $this->fstCheck($request, $talent_info, $ep);
- } else if ($checkState == TalentState::FST_VERIFY_PASS) {
- $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- $companys = array_filter(explode(",", $condition["companyIds"]));
- if ($companys && $talent_info["pass_dept_check"] != 1) {
- if (!in_array($this->user["companyId"], $companys))
- return json(["msg" => "你的部门不在并审部门列表"]);
- return $this->deptCheck($request, $talent_info, $companys);
- } else {
- return $this->reCheck($request, $talent_info);
- }
- } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
- return $this->reCheck($request, $talent_info);
- } else {
- return json(["msg" => "不在审核范围内,保存失败"]);
- }
- }
- public function submitCheck() {
- //公共调度方法
- $id = $this->request->param("id");
- $talent_info = VerifyApi::getOne($id);
- $ep = EnterpriseApi::getOne($talent_info["enterprise_id"]);
- $checkState = $talent_info["checkState"];
- if (!$talent_info || !$ep) {
- return json(["msg" => "数据错误"]);
- }
- if ($ep["type"] != $this->user["type"]) {
- return json(["msg" => "不能审核的人才类型"]);
- }
- if ($checkState == TalentState::FST_SUBMIT) {
- return $this->baseSubmitCheck($talent_info);
- } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
- return $this->baseReSubmitCheck($talent_info);
- } else if ($checkState == TalentState::SCND_SUBMIT) {
- return $this->fstSubmitCheck($talent_info, $ep);
- } else if ($checkState == TalentState::FST_VERIFY_PASS) {
- $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- $companys = array_filter(explode(",", $condition["companyIds"]));
- if ($companys && $talent_info["pass_dept_check"] != 1) {
- if (!in_array($this->user["companyId"], $companys))
- return json(["msg" => "你的部门不在并审部门列表"]);
- return $this->deptSubmitCheck($talent_info, $companys);
- } else {
- return $this->reSubmitCheck($talent_info);
- }
- } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
- return $this->reSubmitCheck($talent_info);
- } else {
- return json(["msg" => "不在审核范围内,审核失败"]);
- }
- }
- /**
- * 撤销初审失败
- * @auth {{/talentInfo/cancleFirstCheck}}
- */
- public function cancleFirstCheck() {
- $returnObj = new \stdClass();
- $returnObj->code = 500;
- $id = \StrUtil::getRequestDecodeParam($this->request, "id");
- $msg = \StrUtil::getRequestDecodeParam($this->request, "checkMsg");
- $old = VerifyApi::getOne($id);
- if (!$old) {
- $returnObj->msg = "请选择需要撤销的对象";
- return json($returnObj);
- }
- if ($old["checkState"] != TalentState::FST_VERIFY_FAIL) {
- $returnObj->msg = "当前对象不是\"初审不通过\"状态,无法撤销";
- return json($returnObj);
- }
- $where = [];
- $lastLog = TalentLogApi::getLastLogEx($id, ProjectState::TALENT);
- if ($lastLog["state"] != TalentState::FST_VERIFY_FAIL || $lastLog["active"] != 1) {
- $returnObj->msg = "当前对象不是\"初审不通过\"状态,无法撤销";
- return json($returnObj);
- }
- if ($old["isPublic"] != 1) {
- $returnObj->msg = "当前对象已核查征信,无法撤销";
- return json($returnObj);
- }
- try {
- if (in_array($lastLog["last_state"], [TalentState::SCND_SUBMIT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT])) {
- $checkState = TalentState::SCND_SUBMIT;
- } else if (in_array($lastLog["last_state"], [TalentState::SCND_SAVE, TalentState::FST_VERIFY_REJECT])) {
- $checkState = TalentState::SCND_SAVE;
- } else {
- $returnObj->msg = "当前对象日志异常,无法撤销";
- return json($returnObj);
- }
- $upd["id"] = $id;
- $upd["checkState"] = $checkState;
- if (TalentModel::update($upd)) {
- TalentLogApi::write(ProjectState::TALENT, $id, [$lastLog["last_state"], $checkState], "撤销原因:" . $msg, 1);
- }
- $returnObj->msg = "撤销成功";
- $returnObj->code = 200;
- return json($returnObj);
- } catch (\think\db\exception\DbException $e) {
- $returnObj->msg = $e->getMessage();
- return json($returnObj);
- }
- }
- /**
- * 撤销复核
- * @auth {{/talentInfo/cancleThirdCheck}}
- */
- public function cancleThirdCheck() {
- $returnObj = new \stdClass();
- $returnObj->code = 500;
- $id = \StrUtil::getRequestDecodeParam($this->request, "id");
- $msg = \StrUtil::getRequestDecodeParam($this->request, "checkMsg");
- $old = VerifyApi::getOne($id);
- if (!$old) {
- $returnObj->msg = "请选择需要撤销的对象";
- return json($returnObj);
- }
- if ($old["checkState"] != TalentState::REVERIFY_PASS && $old["checkState"] != TalentState::REVERIFY_FAIL) {
- $returnObj->msg = "当前对象不是\"复核通过\"或者\"复核不通过\"状态,无法撤销";
- return json($returnObj);
- }
- $where = [];
- $where[] = ["last_state", "in", [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS]];
- $where[] = ["state", "in", [TalentState::REVERIFY_PASS, TalentState::REVERIFY_FAIL]];
- $where[] = ["active", "=", 1];
- $lastLog = TalentLogApi::getLastLogEx($id, ProjectState::TALENT, 0, $where);
- if (($lastLog["state"] != TalentState::REVERIFY_PASS && $lastLog["state"] != TalentState::REVERIFY_FAIL) || $lastLog["active"] != 1) {
- $returnObj->msg = "当前对象不是\"复核通过\"或者\"复核不通过\"状态,无法撤销";
- return json($returnObj);
- }
- if ($old["isPublic"] != 1) {
- $returnObj->msg = "当前对象已核查征信,无法撤销";
- return json($returnObj);
- }
- try {
- $upd["id"] = $id;
- $upd["checkState"] = $lastLog["last_state"];
- if (TalentModel::update($upd)) {
- TalentLogApi::write(ProjectState::TALENT, $id, [TalentState::REVERIFY_CANCEL, $lastLog["last_state"]], "撤销原因:" . $msg, 1);
- }
- $returnObj->msg = "撤销成功";
- $returnObj->code = 200;
- return json($returnObj);
- } catch (\think\db\exception\DbException $e) {
- $returnObj->msg = $e->getMessage();
- return json($returnObj);
- }
- }
- public function validateIsCheck() {
- $params = $this->request->param();
- $id = $params["id"];
- $process = $params["process"];
- $talent_info = VerifyApi::getOne($id);
- $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
- if ($talent_info) {
- $checkState = $talent_info["checkState"];
- 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]))) {
- return json(["msg" => "该申报不在审核范围内,无法审核"]);
- }
- if ($process != 4) {
- switch ($enterprise["type"]) {
- case CommonConst::ENTERPRISE_NORMAL:
- $fields = DictApi::getTalentFields(4, $talent_info["isImport"]);
- break;
- case CommonConst::ENTERPRISE_JC:
- $fields = DictApi::getTalentFields_IC();
- break;
- case CommonConst::ENTERPRISE_WJ:
- $fields = DictApi::getTalentFields_WJ();
- break;
- case CommonConst::ENTERPRISE_GJ:
- $fields = DictApi::getTalentFields_GJ();
- break;
- }
- } else {
- $fields = null; //部门审核不需要审核字段
- }
- if ($fields["fst_work_time"] && in_array($enterprise['enterpriseTag'], ['mtdw', 'gyqyh', 'mbfqy', 'jrjg']) && $enterprise["type"] == 1) {
- $fields["fst_work_time"] = $talent_info['talent_type'] == 1 ? "近三年来晋工作时间" : "近三年(首次)来晋工作时间";
- }
- if ($checkState != TalentState::FST_SUBMIT) {
- //$fields = DictApi::getTalentFields(2);
- $field_tmp = [];
- if ($fields) {
- foreach ($fields as $key => $field) {
- $field_tmp[] = ["key" => $key, "value" => $field];
- }
- }
- $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- $companys = array_filter(explode(",", $condition["companyIds"]));
- $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
- $unpass_companyIds = array_diff($companys, $pass_companyIds);
- $_companys = [];
- foreach ($companys as $companyId) {
- $company = CompanyApi::getOne($companyId);
- if (in_array($companyId, $unpass_companyIds)) {
- $company["uncheck"] = true;
- }
- $_companys[] = $company;
- }
- if ($process == 4 && in_array($enterprise["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_WJ])) {
- $where = [];
- $cwfts = explode(";", $condition["companyWithFileType"]);
- foreach ($cwfts as $cwft) {
- $_company_setting = explode(":", $cwft);
- if ($_company_setting[0] == $this->user["companyId"]) {
- $where[] = ["id", "in", explode(",", $_company_setting[1])];
- break;
- }
- }
- if ($where) {
- $where[] = ["delete", "=", 0];
- $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
- } else {
- $files = [];
- }
- } else {
- $where = [];
- $whr = [];
- $where[] = ["project", "=", 1];
- $where[] = ["active", "=", 1];
- $where[] = ["type", "=", $enterprise["type"]];
- $where[] = ["isConditionFile", "<>", 1];
- $where[] = ["delete", "=", 0];
- if ($condition && $condition["bindFileTypes"]) {
- $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
- $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
- } else {
- $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
- }
- }
- }
- $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
- $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
- /* 保存的审核内容start */
- $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, 0, ["active", "=", 0]);
- if ($last_log["step"] == 3 && $last_log["companyId"] != $this->user["companyId"]) {
- $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, $this->user["companyId"], ["active", "=", 0]);
- }
- $check = ["msg" => $last_log["description"]];
- if ($last_log["state"] == TalentState::FST_VERIFY_PASS && $last_log["new_state"] == TalentState::FST_VERIFY_PASS) {
- if ($talent_info["pass_dept_check"] == 1) {
- if ($talent_info["isImport"] && $talent_info["isMatchZhiren"]) {
- $check["checkState"] = 3; //初审通过
- } else {
- $check["checkState"] = 4; //初审通过(跳过部门并审)
- }
- } else {
- if ($talent_info["re_check_companys"] && $talent_info["highProcess"] >= 4) {
- $talent_info["re_check_companys"] = array_filter(explode(",", $talent_info["re_check_companys"]));
- $check["checkState"] = 5; //初审通过(需要再次部门并审)
- } else {
- if ($process == 4) {
- $check["checkState"] = ""; //部门待审核(系统自动生成的记录,应该算未保存状态,所以设成空,未选择状态)
- } else {
- $check["checkState"] = 3; //初审通过
- }
- }
- }
- }
- if ($last_log["state"] == TalentState::FST_VERIFY_REJECT && $last_log["new_state"] == TalentState::SCND_SAVE) {
- $check["checkState"] = 2; //初审驳回
- }
- if ($last_log["state"] == TalentState::FST_VERIFY_PASS && $last_log["new_state"] == TalentState::DEPT_VERIFY_PASS) {
- $check["checkState"] = 3; //部门通过
- }
- if ($last_log["state"] == TalentState::FST_VERIFY_PASS && $last_log["new_state"] == TalentState::SCND_SUBMIT) {
- $check["checkState"] = 2; //部门驳回
- }
- if ($last_log["state"] == TalentState::REVERIFY_PASS && $last_log["new_state"] == TalentState::REVERIFY_PASS) {
- $check["checkState"] = 3; //复审通过
- }
- if ($last_log["state"] == TalentState::REVERIFY_REJECT && $last_log["new_state"] == TalentState::SCND_SUBMIT) {
- $check["checkState"] = 2; //复审驳回
- }
- if ($last_log["state"] == TalentState::REVERIFY_FAIL && $last_log["new_state"] == TalentState::REVERIFY_FAIL) {
- $check["checkState"] = -1; //复审失败
- }
- /* 保存的审核内容end */
- return json(["code" => 200, "obj" => ["process" => $process, "type" => $enterprise["type"], "talentInfo" => $talent_info, "check" => $check, "fieldList" => $field_tmp, "fileList" => $files, "companys" => $_companys]]);
- }
- }
- public function findFieldsAndFiles() {
- $id = $this->request["id"];
- $talentInfo = VerifyApi::getOne($id);
- $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
- $responseObj = new \stdClass();
- if (($talentInfo["checkState"] == TalentState::SCND_SAVE || $talentInfo["checkState"] == TalentState::FST_SAVE || $talentInfo["checkState"] == TalentState::FST_SUBMIT) && $lastLog["state"] == TalentState::FST_VERIFY_REJECT) {
- if ($this->user["type"] == CommonConst::ENTERPRISE_JC) {
- $fields = DictApi::getTalentFields_IC();
- } else if ($this->user["type"] == CommonConst::ENTERPRISE_WJ) {
- $fields = DictApi::getTalentFields_WJ();
- } else if ($this->user["type"] == CommonConst::ENTERPRISE_GJ) {
- $fields = DictApi::getTalentFields_GJ();
- } else {
- $fields = DictApi::getTalentFields(4, $talentInfo["isImport"]);
- }
- $enterprise = \app\common\model\Enterprise::findOrEmpty($talentInfo["enterprise_id"]);
- if ($fields["fst_work_time"] && in_array($enterprise['enterpriseTag'], ['mtdw', 'gyqyh', 'mbfqy', 'jrjg']) && $enterprise["type"] == 1) {
- $fields["fst_work_time"] = $talentInfo['talent_type'] == 1 ? "近三年来晋工作时间" : "近三年(首次)来晋工作时间";
- }
- $field_tmp = [];
- if ($fields) {
- foreach ($fields as $key => $field) {
- $field_tmp[] = ["key" => $key, "value" => $field];
- }
- }
- $condition = TalentConditionApi::getOne($talentInfo["talent_condition"]);
- $where = [];
- $whr = [];
- $where[] = ["project", "=", 1];
- $where[] = ["active", "=", 1];
- $where[] = ["type", "=", $enterprise["type"]];
- $where[] = ["isConditionFile", "<>", 1];
- $where[] = ["delete", "=", 0];
- if ($condition && $condition["bindFileTypes"]) {
- $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
- $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
- } else {
- $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
- }
- $responseObj->code = 200;
- $responseObj->id = $id;
- $responseObj->fileList = $files;
- $responseObj->fieldList = $field_tmp;
- $responseObj->checkMsg = $lastLog["description"];
- $responseObj->select = [
- "files" => array_filter(explode(",", $talentInfo["modify_files"])),
- "fields" => array_filter(explode(",", $talentInfo["modify_fields"]))
- ];
- } else {
- $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
- }
- return json($responseObj);
- }
- /**
- * 初审-修改驳回字段
- * @auth {{/talentInfo/updateFieldsAndFiles}}
- */
- public function updateFieldsAndFiles() {
- $id = $this->request["id"];
- $fields = array_filter(explode(",", $this->request["fields"]));
- $files = array_filter(explode(",", $this->request["files"]));
- $checkMsg = \StrUtil::getRequestDecodeParam($this->request, "checkMsg");
- $talentInfo = VerifyApi::getOne($id);
- $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
- $responseObj = new \stdClass();
- Db::startTrans();
- if (($talentInfo["checkState"] == TalentState::SCND_SAVE || $talentInfo["checkState"] == TalentState::FST_SAVE || $talentInfo["checkState"] == TalentState::FST_SUBMIT) && $lastLog["state"] == TalentState::FST_VERIFY_REJECT) {
- if (!$fields && !$files) {
- $responseObj->msg = "请选择可修改的字段或附件!";
- return json($responseObj);
- }
- try {
- $data["id"] = $id;
- $data["modify_fields"] = $fields ? implode(",", $fields) : null;
- $data["modify_files"] = $files ? implode(",", $files) : null;
- $res1 = Db::table("new_talent_info")->update($data);
- if (in_array($this->user["type"], [CommonConst::ENTERPRISE_WJ])) {
- if (\StrUtil::isEmpOrNull($checkMsg)) {
- $responseObj->msg = "请填写审核意见!";
- return json($responseObj);
- }
- $updLog["id"] = $lastLog["id"];
- $updLog["description"] = $checkMsg;
- $res2 = Db::table("new_talent_checklog")->update($updLog);
- }
- if ($res1 || $res2) {
- Db::commit();
- $responseObj->code = 200;
- $responseObj->msg = "驳回字段修改成功";
- } else {
- Db::rollback();
- $responseObj->msg = "没有任何修改,提交失败";
- }
- return json($responseObj);
- } catch (\think\db\exception\DbException $e) {
- Db::rollback();
- $responseObj->msg = $e->getMessage();
- return json($responseObj);
- }
- } else {
- $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
- return json($responseObj);
- }
- }
- /**
- * 人才库-取消人才
- * @auth {{/talentInfo/libraryCancle}}
- */
- public function removeFromLibrary() {
- $responseObj = new \stdClass();
- $params = $this->request->param();
- $info = VerifyApi::getOne($params["id"]);
- if (!$params["id"] || !$info) {
- $responseObj->msg = "系统错误,请联系管理员";
- return json($responseObj);
- }
- if ($info["active"] != 2) {
- $responseObj->msg = "该人才未处于离职状态,无法取消";
- return json($responseObj);
- }
- if ($info["isEffect"] == 4) {
- $responseObj->msg = "无法重复取消";
- return json($responseObj);
- }
- if (VerifyApi::setEffect($info["id"], 4, ["description" => "取消优秀人才", "stateChange" => "有效->无效", "active" => 1])) {
- $responseObj->code = 200;
- $responseObj->msg = "取消优秀人才成功";
- return json($responseObj);
- }
- $responseObj->msg = "系统错误,请联系管理员";
- return json($responseObj);
- }
- /**
- * 人才库-恢复人才
- * @auth {{/talentInfo/libraryRecovery}}
- */
- public function recovery() {
- $responseObj = new \stdClass();
- $params = $this->request->param();
- $info = VerifyApi::getOne($params["id"]);
- if (!$params["id"] || !$info) {
- $responseObj->msg = "系统错误,请联系管理员";
- return json($responseObj);
- }
- if ($info["isEffect"] != 4) {
- $responseObj->msg = "无法恢复有效数据";
- return json($responseObj);
- }
- if (VerifyApi::setEffect($info["id"], 1, ["description" => "恢复优秀人才", "stateChange" => "无效->有效", "active" => 1])) {
- $responseObj->code = 200;
- $responseObj->msg = "恢复优秀人才成功";
- return json($responseObj);
- }
- $responseObj->msg = "系统错误,请联系管理员";
- return json($responseObj);
- }
- public function baseVerifyListExport() {
- $this->commonExport(1);
- }
- public function baseReverifyListExport() {
- $this->commonExport(2);
- }
- public function fstVerifyListExport() {
- $this->commonExport(3);
- }
- public function deptVerifyListExport() {
- $this->commonExport(4);
- }
- public function reVerifyListExport() {
- $this->commonExport(5);
- }
- public function preListExport() {
- $this->commonExport(6);
- }
- public function libraryListExport() {
- $this->commonExport(7);
- }
- private function commonExport($process) {
- $companyId = $this->user['companyId'];
- $company = getCacheById("Company", $companyId);
- $setting = [];
- $params = $this->request->param();
- $fields = $params["export"];
- if (!$fields)
- return json(["msg" => "请选择要导出的数据"]);
- $names = DictApi::getTalentFields(4, in_array("isMatchZhiren", $fields));
- $names["industryFieldNew"] = "产业领域";
- $names["enterpriseName"] = "单位名称";
- $names["enterpriseTag"] = "单位标签";
- $names["street"] = "所属镇街";
- $names["checkState"] = "审核状态";
- $names["checkMsg"] = "审核意见";
- $names["first_dept_check_time"] = "进入并审时间";
- $names["verifyDepts"] = "审核部门";
- $names["deptDescription"] = "审核部门意见";
- $names["deptPass"] = "部门通过";
- $names["deptReject"] = "部门驳回";
- $names["deptWait"] = "部门待审";
- $names["breakFaithName"] = "曾被相关主管部门列为失信个人";
- $names["identifyMonth"] = "公布入选月份";
- $names["certificateNo"] = "人才编号";
- $names["activeName"] = "离职状态";
- $names["cur_quit_time"] = "离职时间";
- $names["first_submit_time"] = "首次确认提交时间";
- $names["new_submit_time"] = "最新确认提交时间";
- $list = VerifyApi::getExportDatas($process, $params);
- if ($process == 4 && VerifyApi::chkUserInSuperDeptUsers()) {
- $fields[] = "first_dept_check_time";
- $fields[] = "verifyDepts";
- $fields[] = "deptDescription";
- $fields[] = "deptPass";
- $fields[] = "deptReject";
- $fields[] = "deptWait";
- $verifyDescriptionColumn = getExcelColumnByIndex(count($fields) - 4);
- $setting["font"][] = [sprintf("%s%d:%s%d", $verifyDescriptionColumn, 2, $verifyDescriptionColumn, count($list) + 1), 8, "宋体"];
- $setting["width"][] = [$verifyDescriptionColumn, 45];
- $verifyDeptsColumn = getExcelColumnByIndex(count($fields) - 5);
- $setting["font"][] = [sprintf("%s%d:%s%d", $verifyDeptsColumn, 2, $verifyDeptsColumn, count($list) + 1), 8, "宋体"];
- $setting["width"][] = [$verifyDeptsColumn, 30];
- }
- foreach ($fields as $field) {
- $columns[] = $names[$field];
- }
- $datas = [];
- for ($i = 0; $i < count($list); $i++) {
- $data = [];
- for ($n = 0; $n < count($fields); $n++) {
- $cellValue = $list[$i][$fields[$n]];
- $data[] = $cellValue;
- if ($fields[$n] == "deptPass" && $cellValue > 0) {
- $setting["color"][] = [sprintf("%s%d", getExcelColumnByIndex($n), $i + 2), "15dd0f"];
- }
- if ($fields[$n] == "deptReject" && $cellValue > 0) {
- $setting["color"][] = [sprintf("%s%d", getExcelColumnByIndex($n), $i + 2), "ff0000"];
- }
- if ($fields[$n] == "deptWait" && $cellValue > 0) {
- $setting["color"][] = [sprintf("%s%d", getExcelColumnByIndex($n), $i + 2), "fdcb54"];
- }
- }
- $datas[] = $data;
- }
- $setting["freeze"] = "A2";
- $setting["filter"] = sprintf("A1:%s1", getExcelColumnByIndex(count($columns) - 1));
- if ($datas) {
- export($columns, $datas, "人才审核列表导出", $setting);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
- }
- public function getPhones() {
- $list = VerifyApi::getListByProcess($this->request->param());
- $result = [];
- if ($list) {
- foreach ($list as $item) {
- if ($item["phone"] && $item["name"]) {
- $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
- }
- }
- }
- return json(["code" => 200, "obj" => implode(";", $result)]);
- }
- public function getEnterprisePhones() {
- $list = VerifyApi::getListByProcess($this->request->param());
- $result = [];
- if ($list) {
- foreach ($list as $item) {
- if ($item["agentName"] && $item["agentPhone"]) {
- $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
- }
- }
- }
- return json(["code" => 200, "obj" => implode(";", $result)]);
- }
- }
|