Talent.php 79 KB

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