Talent.php 78 KB

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