Talent.php 74 KB

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