Talent.php 82 KB

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