Talent.php 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  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. /**
  15. * Description of Talent
  16. *
  17. * @author sgq
  18. */
  19. class Talent extends AdminController {
  20. public function common_check() {
  21. $request = $this->request;
  22. $params = $request->param();
  23. $id = $params["id"];
  24. $info = VerifyApi::getTalentInfoById($id);
  25. if (in_array($info["checkState"], [-1, 2])) {
  26. return view("talentInfo_base_check", ["info" => $info]);
  27. } else {
  28. return view("talentInfo_common_check", ["info" => $info]);
  29. }
  30. }
  31. public function cancel_verify() {
  32. $params = $this->request->param();
  33. $ids = $params["ids"];
  34. $msg = $params["msg"];
  35. if ($msg == "") {
  36. return json(["msg" => "请填写审核不通过的原因"]);
  37. }
  38. $ids_arr = array_filter(explode(",", $ids));
  39. $counts = 0;
  40. foreach ($ids_arr as $id) {
  41. $ti = VerifyApi::getOne($id);
  42. $data["id"] = $id;
  43. if ($ti["checkState"] == TalentState::FST_SUBMIT) {
  44. $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
  45. TalentLogApi::write(1, $id, TalentState::BASE_VERIFY_FAIL, $msg, 1);
  46. TalentModel::update($data);
  47. $counts++;
  48. } else if ($ti["checkState"] == TalentState::SCND_SAVE) {
  49. $data["checkState"] = TalentState::FST_VERIFY_FAIL;
  50. TalentLogApi::write(1, $id, TalentState::FST_VERIFY_FAIL, $msg, 1);
  51. TalentModel::update($data);
  52. $counts++;
  53. } else {
  54. return json(["msg" => "不在审核范围"]);
  55. }
  56. }
  57. return json(["code" => 200, sprintf("%d个申请已审核失败", $counts)]);
  58. }
  59. public function base_verify() {
  60. return view();
  61. }
  62. public function base_verify_list() {
  63. $request = $this->request;
  64. return json(VerifyApi::getList($request));
  65. }
  66. /**
  67. * 部门初审
  68. * @auth {{/talentInfo/gotoIndex/-1}}
  69. */
  70. public function dept_fst_verify() {
  71. return view();
  72. }
  73. /**
  74. * 初审
  75. * @auth {{/talentInfo/gotoIndex/1}}
  76. */
  77. public function fst_verify() {
  78. return view();
  79. }
  80. /**
  81. * 初审-审核
  82. * @auth {{/talentInfo/firstCheck}}
  83. */
  84. public function fst_check() {
  85. }
  86. /**
  87. * 初审-修改驳回字段
  88. * @auth {{/talentInfo/updateFieldsAndFiles}}
  89. */
  90. public function updateFieldsAndFiles() {
  91. }
  92. /**
  93. * 初审-审核不通过
  94. * @auth {{/talentInfo/setNotPass}}
  95. */
  96. public function dis_pass() {
  97. }
  98. /**
  99. * 部门审核
  100. * @auth {{/talentInfo/gotoIndex/2}}
  101. */
  102. public function dept_verify() {
  103. return view();
  104. }
  105. /**
  106. * 复审
  107. * @auth {{/talentInfo/gotoIndex/3}}
  108. */
  109. public function re_verify() {
  110. return view();
  111. }
  112. /**
  113. * 复审-撤销复核
  114. * @auth {{/talentInfo/cancleThirdCheck}}
  115. */
  116. public function cancel_check() {
  117. }
  118. /**
  119. * 预备人才库
  120. * @auth {{/talentInfo/gotoIndex/4}}
  121. */
  122. public function pre_list() {
  123. if (session("user")["type"] == 1) {
  124. $message = [
  125. "typeName" => "晋江市优秀人才认定", "address" => "聚才网/人才晋江微信公众号", "dep" => "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心",
  126. "phone" => "0595-85633128", "email" => "jjrc85661234@163.com"
  127. ];
  128. } else {
  129. $message = [
  130. "typeName" => "晋江市集成电路产业优秀人才认定", "address" => "福建(晋江)集成电路产业园官方网站及微信公众号", "dep" => "集成电路产业园区",
  131. "phone" => "0595-82250007、0595-82250001", "email" => "jjjcdr@163.com"
  132. ];
  133. }
  134. return view("", ["message" => $message]);
  135. }
  136. public function selectNeedCheckData() {
  137. $params = $this->request->param();
  138. return json(["code" => 200, "obj" => VerifyApi::getPublicList($params)]);
  139. }
  140. /**
  141. * 预备人才库-核查征信
  142. * @auth {{/talentInfo/prepareHczx}}
  143. */
  144. public function prepareHczx() {
  145. $ids = $this->request->param("ids");
  146. $ids_arr = array_filter(explode(",", $ids));
  147. if (!$ids_arr) {
  148. $res = ["code" => 500, "msg" => "没有选择导出的名单"];
  149. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  150. }
  151. $where[] = ["ti.id", "in", $ids_arr];
  152. $list = TalentModel::alias("ti")->leftJoin("new_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();
  153. if (!$list) {
  154. $res = ["code" => 500, "msg" => "没有可以导出的内容"];
  155. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  156. }
  157. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  158. $rows = [];
  159. $i = 1;
  160. $card_types = DictApi::selectByParentCode("card_type");
  161. foreach ($list as $item) {
  162. $row = [
  163. $i, $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], $item["description"]
  164. ];
  165. $rows[] = $row;
  166. $i++;
  167. }
  168. $filename = "优秀人才核查征信名单导出";
  169. if ($rows) {
  170. export($columns, $rows, $filename);
  171. exit();
  172. }
  173. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  174. }
  175. /**
  176. * 预备人才库-征信通过
  177. * @auth {{/talentInfo/hczxPass}}
  178. */
  179. public function hczxPass() {
  180. $params = $this->request->param();
  181. $ids = $params["ids"];
  182. $ids = array_filter(explode(",", $ids));
  183. $msg = "征信通过";
  184. $state = TalentState::ZX_PASS; //征信通过
  185. $total = count($ids);
  186. $error = 0;
  187. $success = 0;
  188. foreach ($ids as $id) {
  189. $talent_info = VerifyApi::getOne($id);
  190. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  191. $error++;
  192. continue;
  193. }
  194. if (VerifyApi::setPublic($id, $state, $msg)) {
  195. $success++;
  196. } else {
  197. $error++;
  198. }
  199. }
  200. return json(["code" => 200, "msg" => sprintf("核查征信完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  201. }
  202. /**
  203. * 预备人才库-征信失信
  204. * @auth {{/talentInfo/hczxReject}}
  205. */
  206. public function hczxReject() {
  207. $params = $this->request->param();
  208. $id = $params["id"];
  209. $msg = $params["outMsg"];
  210. if (!$msg)
  211. return json(["msg" => "请填写审核意见"]);
  212. $msg = "征信失信:" . $msg;
  213. $state = TalentState::ZX_FAIL; //征信不通过
  214. $talent_info = VerifyApi::getOne($id);
  215. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  216. return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
  217. }
  218. if (VerifyApi::setPublic($id, $state, $msg)) {
  219. return json(["code" => 200, "msg" => "已设置征信失信"]);
  220. }
  221. return json(["msg" => "设置征信失信失败"]);
  222. }
  223. /**
  224. * 预备人才库-公示预览
  225. * @auth {{/talentInfo/publicExportBefore}}
  226. */
  227. public function publicExportBefore() {
  228. $params = $this->request->param();
  229. $ids_arr = array_filter(explode(",", $params["ids"]));
  230. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  231. if ($ids_arr) {
  232. $where[] = ["id", "in", $ids_arr];
  233. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  234. $rows = [];
  235. $i = 1;
  236. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  237. foreach ($list as $item) {
  238. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  239. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  240. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  241. $row = [
  242. $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"]
  243. ];
  244. $rows[] = $row;
  245. $i++;
  246. }
  247. }
  248. if ($rows) {
  249. $filename = "优秀人才公示预览导出";
  250. export($columns, $rows, $filename);
  251. exit();
  252. }
  253. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  254. }
  255. /**
  256. * 预备人才库-公示导出
  257. * @auth {{/talentInfo/publicExport}}
  258. */
  259. public function publicExport() {
  260. $params = $this->request->param();
  261. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  262. $startTime = $params["startTime"];
  263. $endTime = $params["endTime"];
  264. if (!strtotime($startTime) || !strtotime($endTime))
  265. return json(["msg" => "时间格式错误"]);
  266. $where[] = ["checkState", "=", TalentState::ANNOUNCED];
  267. $where[] = ["publicBatch", "between", [$startTime, $endTime]];
  268. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  269. $rows = [];
  270. $i = 1;
  271. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  272. foreach ($list as $item) {
  273. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  274. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  275. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  276. $row = [
  277. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED ? "审核通过" : "审核不通过", $checkLog["description"]
  278. ];
  279. $rows[] = $row;
  280. $i++;
  281. }
  282. if ($rows) {
  283. $filename = "优秀人才公示导出";
  284. export($columns, $rows, $filename);
  285. exit();
  286. }
  287. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  288. }
  289. /**
  290. * 预备人才库-公示
  291. * @auth {{/talentInfo/preparePublic}}
  292. */
  293. public function preparePublic() {
  294. $params = $this->request->param();
  295. $ids = $params["ids"];
  296. $publicBatch = $params["batch"];
  297. if (!$publicBatch || strlen($publicBatch) != 6 || !is_numeric($publicBatch))
  298. return json(["msg" => "公示批次错误"]);
  299. $isMessage = $params["isMessage"] == 1 ? true : false;
  300. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  301. return json(["msg" => "短信参数不能为空"]);
  302. }
  303. $ids = array_filter(explode(",", $ids));
  304. $msg = "已公示";
  305. $state = TalentState::ANNOUNCED; //公示
  306. $total = count($ids);
  307. $error = 0;
  308. $success = 0;
  309. $phones = [];
  310. foreach ($ids as $id) {
  311. $talent_info = VerifyApi::getOne($id);
  312. if ($talent_info["checkState"] != TalentState::ZX_PASS) {
  313. $error++;
  314. continue;
  315. }
  316. if (VerifyApi::setPublic($id, $state, $msg, $publicBatch)) {
  317. $success++;
  318. $phones[] = $talent_info["phone"];
  319. } else {
  320. $error++;
  321. }
  322. }
  323. $phones = array_unique(array_filter($phones));
  324. if ($isMessage && $phones) {
  325. $sms = new \app\common\api\ChuanglanSmsApi();
  326. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  327. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  328. while ($phone = array_shift($phones)) {
  329. $sms->sendSMS($phone, $tpl_content);
  330. }
  331. }
  332. return json(["code" => 200, "msg" => sprintf("公示完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  333. }
  334. /**
  335. * 预备人才库-公示再审核
  336. * @auth {{/talentInfo/prepareCheck}}
  337. */
  338. public function prepareCheck() {
  339. $params = $this->request->param();
  340. $id = $params["id"];
  341. $checkState = $params["checkState"];
  342. $msg = $params["checkMsg"];
  343. if (!$msg)
  344. return json(["msg" => "请填写审核意见"]);
  345. if ($checkState == 1) {
  346. $msg = "公示再审核通过:" . $msg;
  347. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  348. } else {
  349. $msg = "公示再审核不通过:" . $msg;
  350. $state = TalentState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
  351. }
  352. $talent_info = VerifyApi::getOne($id);
  353. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  354. return json(["msg" => "当前记录不是公示状态,无法审核"]);
  355. }
  356. if (VerifyApi::setPublic($id, $state, $msg)) {
  357. return json(["code" => 200, "msg" => "公示再审核完成"]);
  358. }
  359. return json(["msg" => "公示再审核失败"]);
  360. }
  361. /**
  362. * 预备人才库-公示通过(批量)
  363. * @auth {{/talentInfo/publicPass}}
  364. */
  365. public function publicPass() {
  366. $params = $this->request->param();
  367. $ids = $params["ids"];
  368. $ids = array_filter(explode(",", $ids));
  369. $msg = "公示再审核批量通过";
  370. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  371. $total = count($ids);
  372. $error = 0;
  373. $success = 0;
  374. foreach ($ids as $id) {
  375. $talent_info = VerifyApi::getOne($id);
  376. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  377. $error++;
  378. continue;
  379. }
  380. if (VerifyApi::setPublic($id, $state, $msg)) {
  381. $success++;
  382. } else {
  383. $error++;
  384. }
  385. }
  386. return json(["code" => 200, "msg" => sprintf("公示再审核完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  387. }
  388. /**
  389. * 预备人才库-公布预览
  390. * @auth {{/talentInfo/publishExportBefore}}
  391. */
  392. public function publishExportBefore() {
  393. $params = $this->request->param();
  394. $ids = $params["ids"];
  395. $ids = array_filter(explode(",", $ids));
  396. if ($ids) {
  397. $where[] = ["id", "in", $ids];
  398. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  399. $rows = [];
  400. $i = 1;
  401. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  402. foreach ($list as $item) {
  403. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  404. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  405. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  406. $row = [
  407. $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"]
  408. ];
  409. $rows[] = $row;
  410. $i++;
  411. }
  412. }
  413. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  414. $filename = "优秀人才" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  415. if ($rows) {
  416. export($columns, $rows, $filename);
  417. exit();
  418. }
  419. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  420. }
  421. /**
  422. * 预备人才库-公布导出
  423. * @auth {{/talentInfo/publishExport}}
  424. */
  425. public function publishExport() {
  426. $params = $this->request->param();
  427. $startTime = $params["startTime"];
  428. $endTime = $params["endTime"];
  429. if (!strtotime($startTime) || !strtotime($endTime))
  430. return json(["msg" => "时间格式错误"]);
  431. $where[] = ["checkState", "=", TalentState::PUBLISH_PASS];
  432. $where[] = ["certificateGetTime", "between", [$startTime, $endTime]];
  433. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  434. $rows = [];
  435. $i = 1;
  436. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  437. foreach ($list as $item) {
  438. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  439. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  440. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  441. $row = [
  442. $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"]
  443. ];
  444. $rows[] = $row;
  445. $i++;
  446. }
  447. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  448. $filename = "优秀人才" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  449. if ($rows) {
  450. export($columns, $rows, $filename);
  451. exit();
  452. }
  453. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  454. }
  455. /**
  456. * 预备人才库-公布
  457. * @auth {{/talentInfo/publish}}
  458. */
  459. public function publish() {
  460. $params = $this->request->param();
  461. $id = $params["id"];
  462. $msg = $params["checkMsg"];
  463. $checkState = $params["checkState"];
  464. $batch = $params["batch"];
  465. if ($checkState == 1) {
  466. $state = TalentState::PUBLISH_PASS;
  467. $msg = "公布审核通过:" . $msg;
  468. } else {
  469. $state = TalentState::PUBLISH_FAIL;
  470. $msg = "公布审核不通过:" . $msg;
  471. }
  472. if (!$batch || !strtotime($batch))
  473. return json(["msg" => "公布批次时间错误"]);
  474. if (!$msg)
  475. return json(["msg" => "请填写审核意见"]);
  476. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  477. $batch = $params["batch"];
  478. if (!strtotime($batch))
  479. return json(["msg" => "公布批次时间错误"]);
  480. $talent_info = VerifyApi::getOne($id);
  481. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  482. return json(["msg" => "当前记录不是公示再审核通过状态,无法审核"]);
  483. }
  484. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  485. return json(["code" => 200, "msg" => "公布审核完成"]);
  486. }
  487. return json(["msg" => "公布审核失败"]);
  488. }
  489. /**
  490. * 预备人才库-批量公布通过
  491. * @auth {{/talentInfo/preparePublish}}
  492. */
  493. public function preparePublish() {
  494. $params = $this->request->param();
  495. $ids = $params["ids"];
  496. $ids = array_filter(explode(",", $ids));
  497. $msg = "批量公布";
  498. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  499. $batch = $params["batch"];
  500. if (!strtotime($batch))
  501. return json(["msg" => "公布批次时间错误"]);
  502. $total = count($ids);
  503. $error = 0;
  504. $success = 0;
  505. foreach ($ids as $id) {
  506. $talent_info = VerifyApi::getOne($id);
  507. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  508. $error++;
  509. continue;
  510. }
  511. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  512. $success++;
  513. } else {
  514. $error++;
  515. }
  516. }
  517. return json(["code" => 200, "msg" => sprintf("公布完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  518. }
  519. /**
  520. * 预备人才库-批量发证
  521. * @auth {{/talentInfo/prepareCertification}}
  522. */
  523. public function prepareCertification() {
  524. $lockFile = fopen("send_certificate.lock", "a");
  525. if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
  526. //查询所有待发证的数据
  527. $params = $this->request->param();
  528. $ids = array_filter(explode(",", $params["ids"]));
  529. //晋江市优秀人才证书:当前年份+层次+四位递增数字
  530. //集成电路优秀人才证书:IC+当前年份+递增四位数,如IC20190001
  531. Db::startTrans();
  532. $talent_max_no = [];
  533. $user = session("user");
  534. try {
  535. $talent_list = VerifyApi::getListByIds($ids);
  536. $year = date("Y");
  537. foreach ($talent_list as $talent_info) {
  538. if ($talent_info["checkState"] != TalentState::PUBLISH_PASS) {
  539. Db::rollback();
  540. return json(["msg" => "只能对公布通过的对象进行发证,请核查待发证名单后再重新发证"]);
  541. }
  542. $no_prefix = $year . $talent_info["talent_arrange"];
  543. $where[] = ["certificateNo", "like", $no_prefix . "%"];
  544. $max_no = $talent_max_no[$talent_info["talent_arrange"]] ?: Db::table("new_talent_info")->where($where)->max("certificateNo");
  545. if (!$max_no) {
  546. $max_no = $no_prefix . "0001";
  547. } else {
  548. $new_no = intval(substr($max_no, 5)) + 1;
  549. $max_no = $no_prefix . str_pad($new_no, 4, "0", STR_PAD_LEFT);
  550. }
  551. //更新证书编号
  552. $data["id"] = $talent_info["id"];
  553. $data["certificateNo"] = $max_no;
  554. $data["checkState"] = TalentState::CERTIFICATED;
  555. $data["isPublic"] = 5;
  556. Db::table("new_talent_info")->update($data);
  557. //写入日志
  558. $log["last_state"] = TalentState::PUBLISH_PASS;
  559. $log["id"] = getStringId();
  560. $log["state"] = $log["new_state"] = TalentState::CERTIFICATED;
  561. $log["type"] = 1;
  562. $log["mainId"] = $talent_info["id"];
  563. $log["companyId"] = $user["companyId"];
  564. $log["active"] = 1;
  565. $log["description"] = "人才编号为:" . $max_no;
  566. $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);
  567. $log["createTime"] = date("Y-m-d H:i:s");
  568. Db::table("new_talent_checklog")->insert($log);
  569. $talent_max_no[$talent_info["talent_arrange"]] = $max_no;
  570. }
  571. Db::commit();
  572. return json(["code" => 200, "msg" => "发证成功"]);
  573. } catch (\Exception $e) {
  574. Db::rollback();
  575. return json(["msg" => "发证失败:" . $e->getMessage()]);
  576. }
  577. flock($lockFile, LOCK_UN);
  578. } else {
  579. return json(["msg" => "同一时间只能有一个管理员进行发证操作"]);
  580. }
  581. }
  582. /**
  583. * 预备人才库-撤销公布
  584. * @auth {{/talentInfo/prepareCanclePublish}}
  585. */
  586. public function pre_cancel_publish() {
  587. }
  588. /**
  589. * 基本条件审核-提交未保存
  590. * @param \think\Request $request
  591. * @param type $talent_info
  592. * @return type json
  593. */
  594. private function baseCheck(\think\Request $request, $talent_info) {
  595. $params = $request->param();
  596. if ($params["checkState"] == 3) {
  597. //审核成功
  598. $log_checkState = $checkState = TalentState::BASE_VERIFY_PASS; //初审成功
  599. } else {
  600. //审核驳回并记录需要修改的字段和上传文件
  601. $checkState = TalentState::FST_SAVE; //退回提交材料阶段
  602. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  603. }
  604. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  605. if (!$log)
  606. return json(["msg" => "日志数据异常,保存失败"]);
  607. if ($log["active"] == 0) {
  608. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  609. } else {
  610. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  611. }
  612. $data["id"] = $talent_info["id"];
  613. $data["modify_files"] = $params["files"];
  614. $data["modify_fields"] = $params["fields"];
  615. TalentModel::update($data);
  616. return json(["code" => 200, "msg" => "保存成功"]);
  617. }
  618. /**
  619. * 基本条件审核-提交审核
  620. * @param type $talent_info
  621. * @return type json
  622. */
  623. private function baseSubmitCheck($talent_info) {
  624. return $this->commonSubmitCheck($talent_info, 1);
  625. }
  626. /**
  627. * 初审-提交未保存
  628. * @param \think\Request $request
  629. * @param type $talent_info
  630. * @return type json
  631. */
  632. private function fstCheck(\think\Request $request, $talent_info) {
  633. $params = $request->param();
  634. if ($params["checkState"] == 3) {
  635. //审核成功,并取消设置越过部门并审
  636. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  637. $data["pass_dept_check"] = 0;
  638. } else if ($params["checkState"] == 4) {
  639. if ($talent_info["highProcess"] < 3)
  640. return json(["msg" => "只有曾经通过部门并审,初审时才可以选择直接跳过部门并审阶段"]);
  641. //审核成功,并设置越过部门并审。附加条件:最高进度曾经通过部门并审3(包含部门并审)
  642. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  643. $data["pass_dept_check"] = $talent_info["highProcess"] >= 3 ? 1 : 0;
  644. } else {
  645. //审核驳回并记录需要修改的字段和上传文件
  646. $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
  647. $log_checkState = TalentState::FST_VERIFY_REJECT; //日志记录拒绝状态
  648. }
  649. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  650. if (!$log)
  651. return json(["msg" => "日志数据异常,保存失败"]);
  652. if ($log["active"] == 0) {
  653. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  654. } else {
  655. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  656. }
  657. $data["id"] = $talent_info["id"];
  658. $data["modify_files"] = $params["files"];
  659. $data["modify_fields"] = $params["fields"];
  660. TalentModel::update($data);
  661. return json(["code" => 200, "msg" => "保存成功"]);
  662. }
  663. /**
  664. * 初审-提交审核
  665. * @param type $talent_info
  666. * @return type json
  667. */
  668. private function fstSubmitCheck($talent_info) {
  669. $nowProcess = 2;
  670. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  671. if (!$log || $log["active"] == 1)
  672. return json(["msg" => "请先保存审核状态,再提交审核"]);
  673. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  674. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  675. }
  676. if ($log["new_state"] == TalentState::FST_VERIFY_PASS && $talent_info["pass_dept_check"] == 0) {
  677. $data["first_dept_check_time"] = date("Y-m-d H:i:s");
  678. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  679. $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
  680. //这边去除已经审核通过的单位,主要通过日志是否存在记录。
  681. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  682. $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
  683. if (!$unpass_companyIds) {
  684. $data["pass_dept_check"] = 1; //部门已经全部审核过了,跳过部门审核
  685. } else {
  686. sort($unpass_companyIds);
  687. TalentLogApi::writeDeptLogs($talent_info["id"], $unpass_companyIds, TalentState::FST_VERIFY_PASS);
  688. }
  689. }
  690. $data["id"] = $talent_info["id"];
  691. $data["checkState"] = $log["new_state"];
  692. TalentModel::update($data);
  693. TalentLogApi::setActive($log["id"], 1);
  694. return json(["code" => 200, "msg" => "审核成功"]);
  695. }
  696. /**
  697. * 部门审核-提交未保存
  698. * @param \think\Request $request
  699. * @param type $talent_info
  700. * @return type json
  701. */
  702. private function deptCheck(\think\Request $request, $talent_info, $companys) {
  703. if ($talent_info["pass_dept_check"] == 1)
  704. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  705. if (!in_array($this->user["companyId"], $companys))
  706. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  707. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  708. if (in_array($this->user["companyId"], $pass_companyIds))
  709. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  710. $params = $request->param();
  711. if ($params["checkState"] == 3) {
  712. //审核成功
  713. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  714. $checkState = TalentState::DEPT_VERIFY_PASS; //审核成功
  715. } else {
  716. //审核驳回并记录需要修改的字段和上传文件
  717. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  718. $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
  719. $talent_condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  720. if (!$talent_condition["companyWithFileType"])
  721. return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
  722. $cwfts = explode(";", $talent_condition["companyWithFileType"]);
  723. $company_setting = [];
  724. foreach ($cwfts as $cwft) {
  725. $_company_setting = explode(":", $cwft);
  726. if ($_company_setting[0] == $this->user["companyId"]) {
  727. $company_setting = explode(",", $_company_setting[1]);
  728. break;
  729. }
  730. }
  731. if (!$company_setting)
  732. return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
  733. //$data["modify_fields"] = $params["fields"];
  734. $original_modify_files = explode(",", $talent_info["modify_files"]);
  735. $_current_modify_files = explode(",", $params["files"]);
  736. $unselect_files = array_diff($company_setting, $_current_modify_files); //比较设置和当前提交的,取差值集,既是可选而未选的附件集合
  737. $new_modify_files = array_unique(array_merge($original_modify_files, $_current_modify_files)); //合并当前提交及库中原来保存的值
  738. foreach ($new_modify_files as $key => $item) {
  739. if (in_array($item, $unselect_files))
  740. unset($new_modify_files[$key]);
  741. }
  742. $data["modify_files"] = implode(",", array_unique($new_modify_files));
  743. }
  744. $fst_dept_check_time = $talent_info["first_dept_check_time"];
  745. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $fst_dept_check_time);
  746. if (!$dept_log)
  747. return json(["msg" => "未匹配日志,审核失败"]);
  748. if ($dept_log["active"] == 1)
  749. return json(["msg" => "您的部门已经审核过了"]);
  750. $data["id"] = $talent_info["id"];
  751. TalentModel::update($data);
  752. //修改日志
  753. TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  754. return json(["code" => 200, "msg" => "保存成功"]);
  755. }
  756. /**
  757. * 部门审核-提交审核
  758. * @param type $talent_info
  759. * @return type json
  760. */
  761. private function deptSubmitCheck($talent_info, $companys) {
  762. if ($talent_info["pass_dept_check"] == 1)
  763. return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
  764. if (!in_array($this->user["companyId"], $companys))
  765. return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
  766. $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
  767. if (in_array($this->user["companyId"], $pass_companyIds))
  768. return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
  769. $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $talent_info["first_dept_check_time"]);
  770. $over = $pass_companyIds ? count($pass_companyIds) : 0; //完成度,如果重审之前已有通过审核的部门,不用再审,直接按通过算
  771. $error = 0; //失败数
  772. $nowProcess = 3;
  773. if (!$dept_log)
  774. return json(["msg" => "未匹配日志,审核失败"]);
  775. if ($dept_log["state"] == $dept_log["new_state"])
  776. return json(["msg" => "请先保存审核状态,再提交审核"]);
  777. if ($dept_log["active"] == 1)
  778. return json(["msg" => "您的部门已经审核过了"]);
  779. $over++;
  780. if ($dept_log["new_state"] == TalentState::SCND_SUBMIT) {
  781. $error++;
  782. }
  783. $logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
  784. for ($i = 0; $i < count($logs); $i++) {
  785. if (!in_array($logs[$i]["companyId"], $pass_companyIds)) {
  786. $over += $logs[$i]["active"] == 1 ? 1 : 0;
  787. if ($logs[$i]["new_state"] == TalentState::SCND_SUBMIT) {
  788. $error++;
  789. }
  790. }
  791. }
  792. if ($over == count($companys)) {
  793. //全部已审核
  794. $checkState = TalentState::SCND_SUBMIT;
  795. $log_checkState = TalentState::DEPT_VERIFY_REJECT;
  796. if ($error == 0) {
  797. $log_checkState = $checkState = TalentState::DEPT_VERIFY_PASS;
  798. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  799. }
  800. $data["id"] = $talent_info["id"];
  801. $data["checkState"] = $checkState;
  802. $data["first_dept_check_time"] = null;
  803. TalentModel::update($data);
  804. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "部门审核结束", 1);
  805. }
  806. TalentLogApi::setActive($dept_log["id"], 1);
  807. return json(["code" => 200, "msg" => "审核成功"]);
  808. }
  809. /**
  810. * 复审-提交未保存
  811. * @param \think\Request $request
  812. * @param type $talent_info
  813. * @param type json
  814. */
  815. private function reCheck(\think\Request $request, $talent_info) {
  816. $params = $request->param();
  817. if ($params["checkState"] == 3) {
  818. //审核成功
  819. $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
  820. } else if ($params["checkState"] == 2) {
  821. //审核驳回并记录需要修改的字段和上传文件
  822. $checkState = TalentState::SCND_SUBMIT; //退回待初审
  823. $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
  824. } else {
  825. $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
  826. }
  827. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  828. if (!$log)
  829. return json(["msg" => "日志数据异常,保存失败"]);
  830. if ($log["active"] == 0) {
  831. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  832. } else {
  833. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  834. }
  835. $data["id"] = $talent_info["id"];
  836. $data["modify_files"] = $params["files"];
  837. $data["modify_fields"] = $params["fields"];
  838. TalentModel::update($data);
  839. return json(["code" => 200, "msg" => "保存成功"]);
  840. }
  841. /**
  842. * 复审-提交审核
  843. * @param type $talent_info
  844. * @return type json
  845. */
  846. private function reSubmitCheck($talent_info) {
  847. return $this->commonSubmitCheck($talent_info, 4);
  848. }
  849. private function commonSubmitCheck($talent_info, $nowProcess) {
  850. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  851. if (!$log || $log["active"] == 1)
  852. return json(["msg" => "请先保存审核状态,再提交审核"]);
  853. if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  854. $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
  855. }
  856. $smsapi = new ChuanglanSmsApi();
  857. if($log['last_state'] == 1){
  858. //基础信息审核通过,发送短信
  859. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核通过,请及时登录申报系统并进行人才认定的信息申报填写。";
  860. }else{
  861. $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
  862. }
  863. $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
  864. $result = $smsapi->sendSMS($ep->agentPhone,$template);
  865. $result = json_decode($result,true);
  866. $id = getStringId();
  867. $record_data = [
  868. 'id' => $id,
  869. 'bizId' => $id,
  870. 'type' => 2,
  871. 'smsType' => 1,
  872. 'phone' => $ep->agentPhone,
  873. 'params' => '基础信息审核',
  874. 'templateCode' => $template,
  875. 'state' => $result['code'] == 0 ? 2 : 3,
  876. 'sendingDate' => date("Y-m-d H:i:s",time()),
  877. 'createTime' => date("Y-m-d H:i:s",time()),
  878. 'msg' => $result['errorMsg']
  879. ];
  880. MessageRecord::create($record_data);
  881. $data["id"] = $talent_info["id"];
  882. $data["checkState"] = $log["new_state"];
  883. TalentModel::update($data);
  884. TalentLogApi::setActive($log["id"], 1);
  885. return json(["code" => 200, "msg" => "审核成功"]);
  886. }
  887. public function check() {
  888. //公共调度方法
  889. $request = $this->request;
  890. $params = $request->param();
  891. $check = $params["checkState"];
  892. $check_msg = trim($params["checkMsg"]);
  893. $files = $params["files"];
  894. $fields = $params["fields"];
  895. $id = $params["id"];
  896. $talent_info = VerifyApi::getOne($id);
  897. $checkState = $talent_info["checkState"];
  898. if (!$talent_info) {
  899. return json(["msg" => "数据错误"]);
  900. }
  901. if (!$check) {
  902. return json(["msg" => "请选择审核状态"]);
  903. }
  904. if (!$check_msg) {
  905. return json(["msg" => "请填写审核说明"]);
  906. }
  907. if ($checkState == TalentState::FST_SUBMIT) {
  908. return $this->baseCheck($request, $talent_info);
  909. } else if ($checkState == TalentState::SCND_SUBMIT) {
  910. return $this->fstCheck($request, $talent_info);
  911. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  912. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  913. $companys = array_filter(explode(",", $condition["companyIds"]));
  914. if ($companys && $talent_info["pass_dept_check"] != 1) {
  915. if (!in_array($this->user["companyId"], $companys))
  916. return json(["msg" => "你的部门不在并审部门列表"]);
  917. return $this->deptCheck($request, $talent_info, $companys);
  918. } else {
  919. return $this->reCheck($request, $talent_info);
  920. }
  921. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  922. return $this->reCheck($request, $talent_info);
  923. } else {
  924. return json(["msg" => "不在审核范围内,保存失败"]);
  925. }
  926. }
  927. public function submitCheck() {
  928. //公共调度方法
  929. $id = $this->request->param("id");
  930. $talent_info = VerifyApi::getOne($id);
  931. $checkState = $talent_info["checkState"];
  932. if (!$talent_info) {
  933. return json(["msg" => "数据错误"]);
  934. }
  935. if ($checkState == TalentState::FST_SUBMIT) {
  936. return $this->baseSubmitCheck($talent_info);
  937. } else if ($checkState == TalentState::SCND_SUBMIT) {
  938. return $this->fstSubmitCheck($talent_info);
  939. } else if ($checkState == TalentState::FST_VERIFY_PASS) {
  940. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  941. $companys = array_filter(explode(",", $condition["companyIds"]));
  942. if ($companys && $talent_info["pass_dept_check"] != 1) {
  943. if (!in_array($this->user["companyId"], $companys))
  944. return json(["msg" => "你的部门不在并审部门列表"]);
  945. return $this->deptSubmitCheck($talent_info, $companys);
  946. } else {
  947. return $this->reSubmitCheck($talent_info);
  948. }
  949. } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
  950. return $this->reSubmitCheck($talent_info);
  951. } else {
  952. return json(["msg" => "不在审核范围内,审核失败"]);
  953. }
  954. }
  955. public function validateIsCheck() {
  956. $params = $this->request->param();
  957. $id = $params["id"];
  958. $talent_info = VerifyApi::getOne($id);
  959. if ($talent_info) {
  960. $checkState = $talent_info["checkState"];
  961. // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
  962. $process = 0;
  963. if (in_array($checkState, [2, 6, 7, 9])) {
  964. switch ($checkState) {
  965. case 2:
  966. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  967. $fields = DictApi::getTalentFields(1);
  968. $field_tmp = [];
  969. foreach ($fields as $key => $field) {
  970. $field_tmp[] = ["key" => $key, "value" => $field];
  971. }
  972. $where[] = ["project", "=", 1];
  973. $where[] = ["step", "=", 1];
  974. $where[] = ["active", "=", 1];
  975. $where[] = ["type", "=", $enterprise["type"]];
  976. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  977. $process = 1;
  978. break;
  979. case 6:
  980. $fields = DictApi::getTalentFields(2);
  981. $process = 2;
  982. break;
  983. case 7:
  984. $tc = TalentConditionApi::getOne($talent_info["talent_condition"]);
  985. if ($tc["companyIds"] && $talent_info["pass_dept_check"] != 1) {
  986. $process = 3;
  987. $fields = DictApi::getTalentFields(3);
  988. } else {
  989. $process = 4;
  990. $fields = DictApi::getTalentFields(2);
  991. }
  992. break;
  993. case 9:
  994. $process = 4;
  995. $fields = DictApi::getTalentFields(2);
  996. break;
  997. }
  998. if ($checkState != 2) {
  999. $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  1000. //$fields = DictApi::getTalentFields(2);
  1001. $field_tmp = [];
  1002. if ($fields) {
  1003. foreach ($fields as $key => $field) {
  1004. $field_tmp[] = ["key" => $key, "value" => $field];
  1005. }
  1006. }
  1007. $where = [];
  1008. $whr = [];
  1009. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  1010. $where[] = ["project", "=", 1];
  1011. $where[] = ["step", "=", 2];
  1012. $where[] = ["active", "=", 1];
  1013. $where[] = ["type", "=", $enterprise["type"]];
  1014. $where[] = ["isConditionFile", "<>", 1];
  1015. if ($process == 3) {
  1016. $where = [];
  1017. $cwfts = explode(";", $condition["companyWithFileType"]);
  1018. foreach ($cwfts as $cwft) {
  1019. $_company_setting = explode(":", $cwft);
  1020. if ($_company_setting[0] == $this->user["companyId"]) {
  1021. $where[] = ["id", "in", explode(",", $_company_setting[1])];
  1022. break;
  1023. }
  1024. }
  1025. if ($where) {
  1026. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1027. } else {
  1028. $files = [];
  1029. }
  1030. } else {
  1031. if ($condition && $condition["bindFileTypes"]) {
  1032. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  1033. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->select();
  1034. } else {
  1035. $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
  1036. }
  1037. }
  1038. }
  1039. $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
  1040. $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
  1041. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files]]);
  1042. } else {
  1043. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  1044. }
  1045. }
  1046. }
  1047. public function findFieldsAndFiles() {
  1048. }
  1049. public function commonExport() {
  1050. $params = $this->request->param();
  1051. $fields = $params["export"];
  1052. if (!$fields)
  1053. return json(["msg" => "请选择要导出的数据"]);
  1054. $names = DictApi::getTalentFields(4);
  1055. $names["industryFieldNew"] = "产业领域";
  1056. $names["enterpriseName"] = "单位名称";
  1057. $names["enterpriseTag"] = "单位标签";
  1058. $names["street"] = "所属镇街";
  1059. $names["checkState"] = "审核状态";
  1060. $list = VerifyApi::getExportDatas($fields);
  1061. foreach ($fields as $field) {
  1062. $columns[] = $names[$field];
  1063. }
  1064. $datas = [];
  1065. for ($i = 0; $i < count($list); $i++) {
  1066. $data = [];
  1067. for ($n = 0; $n < count($fields); $n++) {
  1068. $data[] = $list[$i][$fields[$n]];
  1069. }
  1070. $datas[] = $data;
  1071. }
  1072. if ($datas) {
  1073. export($columns, $datas);
  1074. exit();
  1075. }
  1076. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  1077. }
  1078. public function getPhones() {
  1079. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1080. $result = [];
  1081. if ($list) {
  1082. foreach ($list as $item) {
  1083. if ($item["phone"] && $item["name"]) {
  1084. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  1085. }
  1086. }
  1087. }
  1088. return json(["code" => 200, "obj" => implode(";", $result)]);
  1089. }
  1090. public function getEnterprisePhones() {
  1091. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1092. $result = [];
  1093. if ($list) {
  1094. foreach ($list as $item) {
  1095. if ($item["agentName"] && $item["agentPhone"]) {
  1096. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  1097. }
  1098. }
  1099. }
  1100. return json(["code" => 200, "obj" => implode(";", $result)]);
  1101. }
  1102. }