Talent.php 79 KB

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