Talent.php 89 KB

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