Talent.php 74 KB

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