Talent.php 88 KB

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