Talent.php 76 KB

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