Talent.php 92 KB

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