Talent.php 81 KB

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