Talent.php 83 KB

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