Talent.php 84 KB

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