Talent.php 79 KB

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