Talent.php 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702
  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. switch ($info["enterpriseType"]) {
  35. case 1:
  36. $tpl = "talentInfo_common_check"; //$info["isImport"] ? "nofile_talentInfo_common_check" : "talentInfo_common_check";
  37. return view($tpl, ["info" => $info]);
  38. case 2:
  39. return view("talentInfo_common_checkIC", ["info" => $info]);
  40. }
  41. }
  42. }
  43. public function cancel_verify() {
  44. $params = $this->request->param();
  45. $ids = $params["ids"];
  46. $msg = $params["msg"];
  47. if ($msg == "") {
  48. return json(["msg" => "请填写审核不通过的原因"]);
  49. }
  50. $ids_arr = array_filter(explode(",", $ids));
  51. $counts = 0;
  52. foreach ($ids_arr as $id) {
  53. $ti = VerifyApi::getOne($id);
  54. $data["id"] = $id;
  55. if ($ti["checkState"] == TalentState::FST_SUBMIT) {
  56. $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
  57. TalentLogApi::write(1, $id, TalentState::BASE_VERIFY_FAIL, $msg, 1);
  58. TalentModel::update($data);
  59. $counts++;
  60. } else if ($ti["checkState"] == TalentState::SCND_SUBMIT) {
  61. $data["checkState"] = TalentState::FST_VERIFY_FAIL;
  62. TalentLogApi::write(1, $id, TalentState::FST_VERIFY_FAIL, $msg, 1);
  63. TalentModel::update($data);
  64. $counts++;
  65. } else {
  66. return json(["msg" => "不在审核范围"]);
  67. }
  68. }
  69. return json(["code" => 200, "msg" => sprintf("%d个申请已审核不通过", $counts)]);
  70. }
  71. public function base_verify() {
  72. $enterprises = EnterpriseApi::getSimpleList();
  73. return view("", ["enterprises" => $enterprises]);
  74. }
  75. public function base_verify_list() {
  76. $params = $this->request->param();
  77. return json(VerifyApi::getList($params));
  78. }
  79. public function base_reverify() {
  80. $enterprises = EnterpriseApi::getSimpleList();
  81. return view("", ["enterprises" => $enterprises]);
  82. }
  83. public function base_reverify_list() {
  84. $params = $this->request->param();
  85. return json(VerifyApi::getList($params));
  86. }
  87. /**
  88. * 部门初审
  89. * @auth {{/talentInfo/gotoIndex/-1}}
  90. */
  91. public function dept_fst_verify() {
  92. return view();
  93. }
  94. /**
  95. * 初审
  96. * @auth {{/talentInfo/gotoIndex/1}}
  97. */
  98. public function fst_verify() {
  99. $enterprises = EnterpriseApi::getSimpleList();
  100. $conditions = TalentConditionApi::getList([1, 2, 3, 4, 5, 6, 7], $this->user["type"]);
  101. $industry_field_new = array_column(DictApi::findChildDictByCode("industry_field"), "code");
  102. foreach ($industry_field_new as &$field) {
  103. $field .= "_field";
  104. }
  105. $parent_industry_fields = implode(",", $industry_field_new);
  106. $where[] = ["d2.code", "in", $parent_industry_fields];
  107. $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();
  108. return view("", ["enterprises" => $enterprises, "talent_conditions" => $conditions, "industry_field_old" => $industry_field_old]);
  109. }
  110. /**
  111. * 初审-审核
  112. * @auth {{/talentInfo/firstCheck}}
  113. */
  114. public function fst_check() {
  115. }
  116. /**
  117. * 初审-审核不通过
  118. * @auth {{/talentInfo/setNotPass}}
  119. */
  120. public function dis_pass() {
  121. }
  122. /**
  123. * 部门审核
  124. * @auth {{/talentInfo/gotoIndex/2}}
  125. */
  126. public function dept_verify() {
  127. $enterprises = EnterpriseApi::getSimpleList();
  128. return view("", ["enterprises" => $enterprises]);
  129. }
  130. /**
  131. * 复审
  132. * @auth {{/talentInfo/gotoIndex/3}}
  133. */
  134. public function re_verify() {
  135. $enterprises = EnterpriseApi::getSimpleList();
  136. return view("", ["enterprises" => $enterprises]);
  137. }
  138. /**
  139. * 复审-撤销复核
  140. * @auth {{/talentInfo/cancleThirdCheck}}
  141. */
  142. public function cancel_check() {
  143. }
  144. /**
  145. * 预备人才库
  146. * @auth {{/talentInfo/gotoIndex/4}}
  147. */
  148. public function pre_list() {
  149. if ($this->user["type"] == 1) {
  150. $message = [
  151. "typeName" => "晋江市现代产业体系人才认定", "address" => "聚才网/人才晋江微信公众号", "dep" => "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心",
  152. "phone" => "0595-85633128", "email" => "jjrc85661234@163.com"
  153. ];
  154. } else {
  155. $message = [
  156. "typeName" => "晋江市集成电路产业优秀人才认定", "address" => "福建(晋江)集成电路产业园官方网站及微信公众号", "dep" => "集成电路产业园区",
  157. "phone" => "0595-82250007、0595-82250001", "email" => "jjjcdr@163.com"
  158. ];
  159. }
  160. $enterprises = EnterpriseApi::getSimpleList();
  161. return view("", ["message" => $message, "enterprises" => $enterprises]);
  162. }
  163. /**
  164. * 优秀人才库
  165. * @auth {{/talentInfo/gotoIndex/5}}
  166. */
  167. public function library() {
  168. $enterprises = EnterpriseApi::getSimpleList();
  169. $conditions = TalentConditionApi::getList([1, 2, 3, 4, 5, 6, 7], $this->user["type"]);
  170. $industry_field_new = array_column(DictApi::findChildDictByCode("industry_field"), "code");
  171. foreach ($industry_field_new as &$field) {
  172. $field .= "_field";
  173. }
  174. $parent_industry_fields = implode(",", $industry_field_new);
  175. $where[] = ["d2.code", "in", $parent_industry_fields];
  176. $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();
  177. return view("", ["enterprises" => $enterprises, "talent_conditions" => $conditions, "industry_field_old" => $industry_field_old]);
  178. }
  179. public function selectNeedCheckData() {
  180. $params = $this->request->param();
  181. return json(["code" => 200, "obj" => VerifyApi::getPublicList($params)]);
  182. }
  183. /**
  184. * 预备人才库-核查征信
  185. * @auth {{/talentInfo/prepareHczx}}
  186. */
  187. public function prepareHczx() {
  188. $ids = $this->request->param("ids");
  189. $ids_arr = array_filter(explode(",", $ids));
  190. if (!$ids_arr) {
  191. $res = ["code" => 500, "msg" => "没有选择导出的名单"];
  192. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  193. }
  194. $where[] = ["ti.id", "in", $ids_arr];
  195. $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();
  196. if (!$list) {
  197. $res = ["code" => 500, "msg" => "没有可以导出的内容"];
  198. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  199. }
  200. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  201. $rows = [];
  202. $i = 1;
  203. $card_types = DictApi::selectByParentCode("card_type");
  204. foreach ($list as $item) {
  205. $row = [
  206. $i, $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], $item["description"]
  207. ];
  208. $rows[] = $row;
  209. $i++;
  210. }
  211. $filename = "现代产业体系人才核查征信名单导出";
  212. if ($rows) {
  213. export($columns, $rows, $filename);
  214. exit();
  215. }
  216. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  217. }
  218. /**
  219. * 预备人才库-征信通过
  220. * @auth {{/talentInfo/hczxPass}}
  221. */
  222. public function hczxPass() {
  223. $params = $this->request->param();
  224. $ids = $params["ids"];
  225. $ids = array_filter(explode(",", $ids));
  226. $msg = "征信通过";
  227. $state = TalentState::ZX_PASS; //征信通过
  228. $total = count($ids);
  229. $error = 0;
  230. $success = 0;
  231. foreach ($ids as $id) {
  232. $talent_info = VerifyApi::getOne($id);
  233. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  234. $error++;
  235. continue;
  236. }
  237. if (VerifyApi::setPublic($id, $state, $msg)) {
  238. $success++;
  239. } else {
  240. $error++;
  241. }
  242. }
  243. return json(["code" => 200, "msg" => sprintf("核查征信完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  244. }
  245. /**
  246. * 预备人才库-征信失信
  247. * @auth {{/talentInfo/hczxReject}}
  248. */
  249. public function hczxReject() {
  250. $params = $this->request->param();
  251. $id = $params["id"];
  252. $msg = $params["outMsg"];
  253. if (!$msg)
  254. return json(["msg" => "请填写审核意见"]);
  255. $msg = "征信失信:" . $msg;
  256. $state = TalentState::ZX_FAIL; //征信不通过
  257. $talent_info = VerifyApi::getOne($id);
  258. if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
  259. return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
  260. }
  261. if (VerifyApi::setPublic($id, $state, $msg)) {
  262. return json(["code" => 200, "msg" => "已设置征信失信"]);
  263. }
  264. return json(["msg" => "设置征信失信失败"]);
  265. }
  266. /**
  267. * 预备人才库-公示预览
  268. * @auth {{/talentInfo/publicExportBefore}}
  269. */
  270. public function publicExportBefore() {
  271. $params = $this->request->param();
  272. $ids_arr = array_filter(explode(",", $params["ids"]));
  273. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  274. if ($ids_arr) {
  275. $where[] = ["id", "in", $ids_arr];
  276. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  277. $rows = [];
  278. $i = 1;
  279. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  280. foreach ($list as $item) {
  281. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  282. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  283. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  284. $row = [
  285. $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"]
  286. ];
  287. $rows[] = $row;
  288. $i++;
  289. }
  290. }
  291. if ($rows) {
  292. $filename = "现代产业体系人才公示预览导出";
  293. export($columns, $rows, $filename);
  294. exit();
  295. }
  296. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  297. }
  298. /**
  299. * 预备人才库-公示导出
  300. * @auth {{/talentInfo/publicExport}}
  301. */
  302. public function publicExport() {
  303. $params = $this->request->param();
  304. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
  305. $startTime = $params["startTime"];
  306. $endTime = $params["endTime"];
  307. if (!strtotime($startTime) || !strtotime($endTime))
  308. return json(["msg" => "时间格式错误"]);
  309. $where[] = ["checkState", "=", TalentState::ANNOUNCED];
  310. $where[] = ["publicBatch", "between", [$startTime, $endTime]];
  311. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  312. $rows = [];
  313. $i = 1;
  314. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  315. foreach ($list as $item) {
  316. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  317. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  318. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  319. $row = [
  320. $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED ? "审核通过" : "审核不通过", $checkLog["description"]
  321. ];
  322. $rows[] = $row;
  323. $i++;
  324. }
  325. if ($rows) {
  326. $filename = "现代产业体系人才公示导出";
  327. export($columns, $rows, $filename);
  328. exit();
  329. }
  330. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  331. }
  332. /**
  333. * 预备人才库-公示
  334. * @auth {{/talentInfo/preparePublic}}
  335. */
  336. public function preparePublic() {
  337. $params = $this->request->param();
  338. $ids = $params["ids"];
  339. $publicBatch = $params["batch"];
  340. if (!$publicBatch || strlen($publicBatch) != 6 || !is_numeric($publicBatch))
  341. return json(["msg" => "公示批次错误"]);
  342. $isMessage = $params["isMessage"] == 1 ? true : false;
  343. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  344. return json(["msg" => "短信参数不能为空"]);
  345. }
  346. $ids = array_filter(explode(",", $ids));
  347. $msg = "已公示";
  348. $state = TalentState::ANNOUNCED; //公示
  349. $total = count($ids);
  350. $error = 0;
  351. $success = 0;
  352. $phones = [];
  353. foreach ($ids as $id) {
  354. $talent_info = VerifyApi::getOne($id);
  355. if ($talent_info["checkState"] != TalentState::ZX_PASS) {
  356. $error++;
  357. continue;
  358. }
  359. if (VerifyApi::setPublic($id, $state, $msg, $publicBatch)) {
  360. $success++;
  361. $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
  362. $phones[] = $ep->agentPhone;
  363. } else {
  364. $error++;
  365. }
  366. }
  367. $phones = array_unique(array_filter($phones));
  368. if ($isMessage && $phones) {
  369. $sms = new \app\common\api\ChuanglanSmsApi();
  370. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  371. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  372. while ($phone = array_shift($phones)) {
  373. $result = $sms->sendSMS($phone, $tpl_content);
  374. $result = json_decode($result, true);
  375. $recordId = getStringId();
  376. $record_data = [
  377. 'id' => $recordId,
  378. 'bizId' => $result["msgId"],
  379. 'type' => 2,
  380. 'smsType' => 1,
  381. 'phone' => $phone,
  382. 'params' => '公示',
  383. 'templateCode' => $tpl_content,
  384. 'state' => $result['code'] == 0 ? 2 : 3,
  385. 'sendingDate' => date("Y-m-d H:i:s", time()),
  386. 'createTime' => date("Y-m-d H:i:s", time()),
  387. 'msg' => $result['errorMsg']
  388. ];
  389. MessageRecord::create($record_data);
  390. }
  391. }
  392. return json(["code" => 200, "msg" => sprintf("公示完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  393. }
  394. /**
  395. * 预备人才库-公示再审核
  396. * @auth {{/talentInfo/prepareCheck}}
  397. */
  398. public function prepareCheck() {
  399. $params = $this->request->param();
  400. $id = $params["id"];
  401. $checkState = $params["checkState"];
  402. $msg = $params["checkMsg"];
  403. if (!$msg)
  404. return json(["msg" => "请填写审核意见"]);
  405. if ($checkState == 1) {
  406. $msg = "公示再审核通过:" . $msg;
  407. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  408. } else {
  409. $msg = "公示再审核不通过:" . $msg;
  410. $state = TalentState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
  411. }
  412. $talent_info = VerifyApi::getOne($id);
  413. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  414. return json(["msg" => "当前记录不是公示状态,无法审核"]);
  415. }
  416. if (VerifyApi::setPublic($id, $state, $msg)) {
  417. return json(["code" => 200, "msg" => "公示再审核完成"]);
  418. }
  419. return json(["msg" => "公示再审核失败"]);
  420. }
  421. /**
  422. * 预备人才库-公示通过(批量)
  423. * @auth {{/talentInfo/publicPass}}
  424. */
  425. public function publicPass() {
  426. $params = $this->request->param();
  427. $ids = $params["ids"];
  428. $ids = array_filter(explode(",", $ids));
  429. $msg = "公示再审核批量通过";
  430. $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  431. $total = count($ids);
  432. $error = 0;
  433. $success = 0;
  434. foreach ($ids as $id) {
  435. $talent_info = VerifyApi::getOne($id);
  436. if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
  437. $error++;
  438. continue;
  439. }
  440. if (VerifyApi::setPublic($id, $state, $msg)) {
  441. $success++;
  442. } else {
  443. $error++;
  444. }
  445. }
  446. return json(["code" => 200, "msg" => sprintf("公示再审核完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  447. }
  448. /**
  449. * 预备人才库-公布预览
  450. * @auth {{/talentInfo/publishExportBefore}}
  451. */
  452. public function publishExportBefore() {
  453. $params = $this->request->param();
  454. $ids = $params["ids"];
  455. $ids = array_filter(explode(",", $ids));
  456. if ($ids) {
  457. $where[] = ["id", "in", $ids];
  458. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  459. $rows = [];
  460. $i = 1;
  461. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  462. foreach ($list as $item) {
  463. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  464. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  465. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  466. $row = [
  467. $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"]
  468. ];
  469. $rows[] = $row;
  470. $i++;
  471. }
  472. }
  473. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  474. $filename = "现代产业体系人才" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  475. if ($rows) {
  476. export($columns, $rows, $filename);
  477. exit();
  478. }
  479. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  480. }
  481. /**
  482. * 预备人才库-公布导出
  483. * @auth {{/talentInfo/publishExport}}
  484. */
  485. public function publishExport() {
  486. $params = $this->request->param();
  487. $startTime = $params["startTime"];
  488. $endTime = $params["endTime"];
  489. if (!strtotime($startTime) || !strtotime($endTime))
  490. return json(["msg" => "时间格式错误"]);
  491. $where[] = ["checkState", "=", TalentState::PUBLISH_PASS];
  492. $where[] = ["certificateGetTime", "between", [$startTime, $endTime]];
  493. $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
  494. $rows = [];
  495. $i = 1;
  496. $talentArranges = DictApi::selectByParentCode("talent_arrange");
  497. foreach ($list as $item) {
  498. $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
  499. $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
  500. $checkLog = TalentLogApi::getLastLog($item["id"], 1);
  501. $row = [
  502. $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"]
  503. ];
  504. $rows[] = $row;
  505. $i++;
  506. }
  507. $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
  508. $filename = "现代产业体系人才" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  509. if ($rows) {
  510. export($columns, $rows, $filename);
  511. exit();
  512. }
  513. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  514. }
  515. /**
  516. * 预备人才库-公布
  517. * @auth {{/talentInfo/publish}}
  518. */
  519. public function publish() {
  520. $params = $this->request->param();
  521. $id = $params["id"];
  522. $msg = $params["checkMsg"];
  523. $checkState = $params["checkState"];
  524. $batch = $params["batch"];
  525. if ($checkState == 1) {
  526. $state = TalentState::PUBLISH_PASS;
  527. $msg = "公布审核通过:" . $msg;
  528. } else {
  529. $state = TalentState::PUBLISH_FAIL;
  530. $msg = "公布审核不通过:" . $msg;
  531. }
  532. if (!$batch || !strtotime($batch))
  533. return json(["msg" => "公布批次时间错误"]);
  534. if (!$msg)
  535. return json(["msg" => "请填写审核意见"]);
  536. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  537. $batch = $params["batch"];
  538. if (!strtotime($batch))
  539. return json(["msg" => "公布批次时间错误"]);
  540. $talent_info = VerifyApi::getOne($id);
  541. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  542. return json(["msg" => "当前记录不是公示再审核通过状态,无法审核"]);
  543. }
  544. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  545. return json(["code" => 200, "msg" => "公布审核完成"]);
  546. }
  547. return json(["msg" => "公布审核失败"]);
  548. }
  549. /**
  550. * 预备人才库-批量公布通过
  551. * @auth {{/talentInfo/preparePublish}}
  552. */
  553. public function preparePublish() {
  554. $params = $this->request->param();
  555. $ids = $params["ids"];
  556. $ids = array_filter(explode(",", $ids));
  557. $msg = "批量公布";
  558. $state = TalentState::PUBLISH_PASS; //公示再审核通过
  559. $batch = $params["batch"];
  560. if (!strtotime($batch))
  561. return json(["msg" => "公布批次时间错误"]);
  562. $total = count($ids);
  563. $error = 0;
  564. $success = 0;
  565. foreach ($ids as $id) {
  566. $talent_info = VerifyApi::getOne($id);
  567. if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
  568. $error++;
  569. continue;
  570. }
  571. if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
  572. $success++;
  573. } else {
  574. $error++;
  575. }
  576. }
  577. return json(["code" => 200, "msg" => sprintf("公布完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  578. }
  579. /**
  580. * 预备人才库-批量发放人才码
  581. * @auth {{/talentInfo/prepareCertification}}
  582. */
  583. public function prepareCertification() {
  584. $lockFile = fopen("send_certificate.lock", "a");
  585. if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
  586. //查询所有待发放人才码的数据
  587. $params = $this->request->param();
  588. $ids = array_filter(explode(",", $params["ids"]));
  589. //晋江市优秀人才证书:当前年份+层次+四位递增数字
  590. //集成电路优秀人才证书:IC+当前年份+递增四位数,如IC20190001
  591. Db::startTrans();
  592. $talent_max_no = [];
  593. $user = $this->user;
  594. try {
  595. $talent_list = VerifyApi::getListByIds($ids);
  596. $year = date("Y");
  597. foreach ($talent_list as $talent_info) {
  598. if ($talent_info["checkState"] != TalentState::PUBLISH_PASS) {
  599. Db::rollback();
  600. return json(["msg" => "只能对公布通过的对象发放人才码,请核查待发放人才码名单后再重新发放人才码"]);
  601. }
  602. $no_prefix = $year . $talent_info["talent_arrange"];
  603. $where[] = ["certificateNo", "like", $no_prefix . "%"];
  604. $max_no = $talent_max_no[$talent_info["talent_arrange"]] ?: Db::table("new_talent_info")->where($where)->max("certificateNo");
  605. if (!$max_no) {
  606. $max_no = $no_prefix . "0001";
  607. } else {
  608. $new_no = intval(substr($max_no, 5)) + 1;
  609. $max_no = $no_prefix . str_pad($new_no, 4, "0", STR_PAD_LEFT);
  610. }
  611. //更新证书编号
  612. $data["id"] = $talent_info["id"];
  613. $data["certificateNo"] = $max_no;
  614. $data["checkState"] = TalentState::CERTIFICATED;
  615. $data["isEffect"] = 1;
  616. $data["isPublic"] = 5;
  617. Db::table("new_talent_info")->update($data);
  618. //写入日志
  619. $log["last_state"] = TalentState::PUBLISH_PASS;
  620. $log["id"] = getStringId();
  621. $log["state"] = $log["new_state"] = TalentState::CERTIFICATED;
  622. $log["type"] = 1;
  623. $log["mainId"] = $talent_info["id"];
  624. $log["companyId"] = $user["companyId"];
  625. $log["active"] = 1;
  626. $log["description"] = "人才码为:" . $max_no;
  627. $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);
  628. $log["createTime"] = date("Y-m-d H:i:s");
  629. Db::table("new_talent_checklog")->insert($log);
  630. $talent_max_no[$talent_info["talent_arrange"]] = $max_no;
  631. }
  632. Db::commit();
  633. return json(["code" => 200, "msg" => "发放人才码成功"]);
  634. } catch (\Exception $e) {
  635. Db::rollback();
  636. return json(["msg" => "发放人才码失败:" . $e->getMessage()]);
  637. }
  638. flock($lockFile, LOCK_UN);
  639. } else {
  640. return json(["msg" => "同一时间只能有一个管理员进行发放人才码操作"]);
  641. }
  642. }
  643. /**
  644. * 预备人才库-撤销公布
  645. * @auth {{/talentInfo/prepareCanclePublish}}
  646. */
  647. public function pre_cancel_publish() {
  648. }
  649. /**
  650. * 基本条件审核-提交未保存
  651. * @param \think\Request $request
  652. * @param type $talent_info
  653. * @return type json
  654. */
  655. private function baseCheck(\think\Request $request, $talent_info) {
  656. $params = $request->param();
  657. if ($params["checkState"] == 3) {
  658. //审核成功
  659. $log_checkState = $checkState = TalentState::BASE_VERIFY_PASS; //基础信息审核成功
  660. } else {
  661. //审核驳回并记录需要修改的字段和上传文件
  662. $checkState = TalentState::FST_SAVE; //退回提交材料阶段
  663. $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
  664. }
  665. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  666. if (!$log)
  667. return json(["msg" => "日志数据异常,保存失败"]);
  668. if ($log["active"] == 0) {
  669. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  670. } else {
  671. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  672. }
  673. $data["id"] = $talent_info["id"];
  674. $data["modify_files"] = $params["files"];
  675. $data["modify_fields"] = $params["fields"];
  676. TalentModel::update($data);
  677. return json(["code" => 200, "msg" => "保存成功"]);
  678. }
  679. /**
  680. * 基本条件审核-提交审核
  681. * @param type $talent_info
  682. * @return type json
  683. */
  684. private function baseSubmitCheck($talent_info) {
  685. return $this->commonSubmitCheck($talent_info, 1);
  686. }
  687. /**
  688. * 基本条件复审-提交未保存
  689. * @param \think\Request $request
  690. * @param type $talent_info
  691. * @return type json
  692. */
  693. private function baseReCheck(\think\Request $request, $talent_info) {
  694. $params = $request->param();
  695. if ($params["checkState"] == 3) {
  696. //审核成功
  697. $log_checkState = $checkState = TalentState::BASE_REVERIFY_PASS; //基础信息复审成功
  698. } else if ($params["checkState"] == 2) {
  699. //审核驳回并记录需要修改的字段和上传文件
  700. $checkState = TalentState::FST_SUBMIT; //退回待基础审核状态
  701. $log_checkState = TalentState::BASE_REVERIFY_REJECT; //日志记录拒绝状态
  702. } else {
  703. $log_checkState = $checkState = TalentState::BASE_REVERIFY_FAIL; //审核失败
  704. }
  705. $log = TalentLogApi::getLastLog($talent_info["id"], 1);
  706. if (!$log)
  707. return json(["msg" => "日志数据异常,保存失败"]);
  708. if ($log["active"] == 0) {
  709. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  710. } else {
  711. TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  712. }
  713. $data["id"] = $talent_info["id"];
  714. $data["modify_files"] = $params["files"];
  715. $data["modify_fields"] = $params["fields"];
  716. TalentModel::update($data);
  717. return json(["code" => 200, "msg" => "保存成功"]);
  718. }
  719. /**
  720. * 基本条件复审-提交审核
  721. * @param type $talent_info
  722. * @return type json
  723. */
  724. private function baseReSubmitCheck($talent_info) {
  725. return $this->commonSubmitCheck($talent_info, 2);
  726. }
  727. /**
  728. * 初审-提交未保存
  729. * @param \think\Request $request
  730. * @param type $talent_info
  731. * @return type json
  732. */
  733. private function fstCheck(\think\Request $request, $talent_info) {
  734. $params = $request->param();
  735. $data["pass_dept_check"] = 0;
  736. if ($params["checkState"] == 3) {
  737. //审核成功,并取消设置越过部门并审
  738. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  739. if ($talent_info["isImport"] && $talent_info["isMatchZhiren"]) {
  740. $data["pass_dept_check"] = 1;
  741. }
  742. } else if ($params["checkState"] == 4) {
  743. if ($talent_info["highProcess"] < 4)
  744. return json(["msg" => "只有曾经通过部门并审,初审时才可以选择直接跳过部门并审阶段"]);
  745. //审核成功,并设置越过部门并审。附加条件:最高进度曾经通过部门并审4(包含部门并审)
  746. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  747. if ($talent_info["highProcess"] >= 4) {
  748. $data["pass_dept_check"] = 1;
  749. }
  750. } else if ($params["checkState"] == 5) {
  751. //选择重审部门
  752. if ($talent_info["highProcess"] < 4)
  753. return json(["msg" => "只有曾经通过部门并审,初审时才可以选择再次审核的部门"]);
  754. if (!$params["companys"])
  755. return json(["msg" => "请选择需要再次审核的部门"]);
  756. $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
  757. $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
  758. $re_check_companys = array_filter(explode(",", $talent_info["re_check_companys"]));
  759. foreach ($re_check_companys as $reCompanyId) {
  760. if (!in_array($reCompanyId, $companyIds)) {
  761. return json(["msg" => "错误的部门"]);
  762. }
  763. }
  764. $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
  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. /* 保存的审核内容start */
  1396. $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, 0, ["active", "=", 0]);
  1397. if ($last_log["step"] == 3 && $last_log["companyId"] != $this->user["companyId"]) {
  1398. $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, $this->user["companyId"], ["active", "=", 0]);
  1399. }
  1400. $check = ["msg" => $last_log["description"]];
  1401. if ($last_log["state"] == TalentState::FST_VERIFY_PASS && $last_log["new_state"] == TalentState::FST_VERIFY_PASS) {
  1402. if ($talent_info["pass_dept_check"] == 1) {
  1403. if ($talent_info["isImport"] && $talent_info["isMatchZhiren"]) {
  1404. $check["checkState"] = 3; //初审通过
  1405. } else {
  1406. $check["checkState"] = 4; //初审通过(跳过部门并审)
  1407. }
  1408. } else {
  1409. if ($talent_info["re_check_companys"] && $talent_info["highProcess"] >= 4) {
  1410. $check["checkState"] = 5; //初审通过(需要再次部门并审)
  1411. } else {
  1412. $check["checkState"] = 3; //初审通过
  1413. }
  1414. }
  1415. }
  1416. if ($last_log["state"] == TalentState::FST_VERIFY_REJECT && $last_log["new_state"] == TalentState::SCND_SAVE) {
  1417. $check["checkState"] = 2; //初审驳回
  1418. }
  1419. if ($last_log["state"] == TalentState::FST_VERIFY_PASS && $last_log["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  1420. $check["checkState"] = 3; //部门通过
  1421. }
  1422. if ($last_log["state"] == TalentState::FST_VERIFY_PASS && $last_log["new_state"] == TalentState::SCND_SUBMIT) {
  1423. $check["checkState"] = 2; //部门驳回
  1424. }
  1425. if ($last_log["state"] == TalentState::REVERIFY_PASS && $last_log["new_state"] == TalentState::REVERIFY_PASS) {
  1426. $check["checkState"] = 3; //复审通过
  1427. }
  1428. if ($last_log["state"] == TalentState::REVERIFY_REJECT && $last_log["new_state"] == TalentState::SCND_SUBMIT) {
  1429. $check["checkState"] = 2; //复审驳回
  1430. }
  1431. if ($last_log["state"] == TalentState::REVERIFY_FAIL && $last_log["new_state"] == TalentState::REVERIFY_FAIL) {
  1432. $check["checkState"] = -1; //复审失败
  1433. }
  1434. /* 保存的审核内容end */
  1435. return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "check" => $check, "fieldList" => $field_tmp, "fileList" => $files, "companys" => $_companys]]);
  1436. } else {
  1437. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  1438. }
  1439. }
  1440. }
  1441. public function findFieldsAndFiles() {
  1442. $id = $this->request["id"];
  1443. $talentInfo = VerifyApi::getOne($id);
  1444. $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
  1445. $responseObj = new \stdClass();
  1446. if ($talentInfo["checkState"] == TalentState::SCND_SAVE && $lastLog["state"] == TalentState::FST_VERIFY_REJECT) {
  1447. if ($this->user["type"] == 2) {
  1448. $fields = DictApi::getTalentFields_IC();
  1449. } else {
  1450. $fields = DictApi::getTalentFields(4, $talentInfo["isImport"]);
  1451. }
  1452. $field_tmp = [];
  1453. if ($fields) {
  1454. foreach ($fields as $key => $field) {
  1455. $field_tmp[] = ["key" => $key, "value" => $field];
  1456. }
  1457. }
  1458. $enterprise = \app\common\model\Enterprise::findOrEmpty($talentInfo["enterprise_id"]);
  1459. $condition = TalentConditionApi::getOne($talentInfo["talent_condition"]);
  1460. $where = [];
  1461. $whr = [];
  1462. $where[] = ["project", "=", 1];
  1463. $where[] = ["active", "=", 1];
  1464. $where[] = ["type", "=", $enterprise["type"]];
  1465. $where[] = ["isConditionFile", "<>", 1];
  1466. $where[] = ["delete", "=", 0];
  1467. if ($condition && $condition["bindFileTypes"]) {
  1468. $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
  1469. $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->order("sn asc")->select();
  1470. } else {
  1471. $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
  1472. }
  1473. $responseObj->code = 200;
  1474. $responseObj->id = $id;
  1475. $responseObj->fileList = $files;
  1476. $responseObj->fieldList = $field_tmp;
  1477. $responseObj->select = [
  1478. "files" => array_filter(explode(",", $talentInfo["modify_files"])),
  1479. "fields" => array_filter(explode(",", $talentInfo["modify_fields"]))
  1480. ];
  1481. } else {
  1482. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  1483. }
  1484. return json($responseObj);
  1485. }
  1486. /**
  1487. * 初审-修改驳回字段
  1488. * @auth {{/talentInfo/updateFieldsAndFiles}}
  1489. */
  1490. public function updateFieldsAndFiles() {
  1491. $id = $this->request["id"];
  1492. $fields = array_filter(explode(",", $this->request["fields"]));
  1493. $files = array_filter(explode(",", $this->request["files"]));
  1494. $talentInfo = VerifyApi::getOne($id);
  1495. $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
  1496. $responseObj = new \stdClass();
  1497. if ($talentInfo["checkState"] == TalentState::SCND_SAVE && $lastLog["state"] == TalentState::FST_VERIFY_REJECT) {
  1498. if (!$fields && !$files) {
  1499. $responseObj->msg = "请选择可修改的字段或附件!";
  1500. return json($responseObj);
  1501. }
  1502. try {
  1503. $data["id"] = $id;
  1504. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  1505. $data["modify_files"] = $files ? implode(",", $files) : null;
  1506. TalentModel::update($data);
  1507. $responseObj->code = 200;
  1508. $responseObj->msg = "驳回字段修改成功";
  1509. return json($responseObj);
  1510. } catch (\think\db\exception\DbException $e) {
  1511. $responseObj->msg = $e->getMessage();
  1512. return json($responseObj);
  1513. }
  1514. } else {
  1515. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  1516. return json($responseObj);
  1517. }
  1518. }
  1519. public function baseVerifyListExport() {
  1520. $this->commonExport(1);
  1521. }
  1522. public function baseReverifyListExport() {
  1523. $this->commonExport(2);
  1524. }
  1525. public function fstVerifyListExport() {
  1526. $this->commonExport(3);
  1527. }
  1528. public function deptVerifyListExport() {
  1529. $this->commonExport(4);
  1530. }
  1531. public function reVerifyListExport() {
  1532. $this->commonExport(5);
  1533. }
  1534. public function preListExport() {
  1535. $this->commonExport(6);
  1536. }
  1537. public function libraryListExport() {
  1538. $this->commonExport(7);
  1539. }
  1540. private function commonExport($process) {
  1541. $params = $this->request->param();
  1542. $fields = $params["export"];
  1543. if (!$fields)
  1544. return json(["msg" => "请选择要导出的数据"]);
  1545. $names = DictApi::getTalentFields(4);
  1546. $names["industryFieldNew"] = "产业领域";
  1547. $names["enterpriseName"] = "单位名称";
  1548. $names["enterpriseTag"] = "单位标签";
  1549. $names["street"] = "所属镇街";
  1550. $names["checkState"] = "审核状态";
  1551. $names["checkMsg"] = "审核意见";
  1552. $list = VerifyApi::getExportDatas($process, $fields);
  1553. foreach ($fields as $field) {
  1554. $columns[] = $names[$field];
  1555. }
  1556. $datas = [];
  1557. for ($i = 0; $i < count($list); $i++) {
  1558. $data = [];
  1559. for ($n = 0; $n < count($fields); $n++) {
  1560. $data[] = $list[$i][$fields[$n]];
  1561. }
  1562. $datas[] = $data;
  1563. }
  1564. if ($datas) {
  1565. export($columns, $datas);
  1566. exit();
  1567. }
  1568. echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
  1569. }
  1570. public function getPhones() {
  1571. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1572. $result = [];
  1573. if ($list) {
  1574. foreach ($list as $item) {
  1575. if ($item["phone"] && $item["name"]) {
  1576. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  1577. }
  1578. }
  1579. }
  1580. return json(["code" => 200, "obj" => implode(";", $result)]);
  1581. }
  1582. public function getEnterprisePhones() {
  1583. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1584. $result = [];
  1585. if ($list) {
  1586. foreach ($list as $item) {
  1587. if ($item["agentName"] && $item["agentPhone"]) {
  1588. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  1589. }
  1590. }
  1591. }
  1592. return json(["code" => 200, "obj" => implode(";", $result)]);
  1593. }
  1594. }