Talent.php 83 KB

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