Talent.php 99 KB

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