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