Talent.php 77 KB

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