Talent.php 74 KB

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