Talent.php 94 KB

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