package com.ruoyi.spider.ie;

import cn.hutool.core.lang.Dict;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.db.Entity;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static java.util.regex.Pattern.*;

/**
 * 掌上高考：院校库、专业、分数线、计划
 * @author mo
 *
 */
@Service
public class ZhangSGKService extends AbstraceService {
    private String domainUrl = "https://api.eol.cn/";
    private String domainUrl2 = "https://static-data.gaokao.cn/";

    private static Logger log = LoggerFactory.getLogger(ZhangSGKService.class);
    int seconds = 1;
//    List<Integer> finishedCollegeList = Arrays.asList(873,1520,1050,1547,890,2638,2638,1156,1924);
            /**
            Arrays.asList(
            873,1520,1050,1547,890,2638,1156,1924,1921,902,1334,2671,1933,1939,1410,1554,2445,1936,1301,1937
            ,1187,1927,3068,2931,2672,1940,2444,1172,1932,3114,1926,1925,1930,1926,1925,1930,3040
            ,1938,2912,3067,2446,2907,3361,1931,2969,3214,1934,1928,2447,2674,3363,1935,3513,2913,3368,3098,3512
            ,3367,3369,3364,3371,3629,3579
    ,3372,3366,3511,3510,3514,3515,3581,3370,1148,1941,1125,1512,1532,2451,2452,1307,2448,3423,2842,1150,1942,2454
            ,2455,3079,2677,1944,2676,2453,3036,2906,1943,3047,2673,2670,2914,3519,3091,2675
            ,3365,3518,3583,3517,3582,3516,1992,2294,3318,3533,3455,3501);**/
    /**
     * 一、掌上高考：
     * 院校列表：https://api.eol.cn/web/api?page=1&size=20&uri=apidata/api/gkv3/single/school& local_province_id=41&keyword=&school_type=&nature=&type=&colleges_level=&doublehigh=&single=75001
     * 学校概况：school_id->1156
     *  https://static-data.gaokao.cn/www/2.0/school/1156/info.json
     *  https://static-data.gaokao.cn/www/2.0/school/image/1156.json
     *
     * 开设专业：school_id->1156
     *  https://static-data.gaokao.cn/www/2.0/single/school/1156/special/single_type_list.json
     *  专业详情：school_id->1156、special_id->57286
     *    https://static-data.gaokao.cn/www/2.0/single/school/1156/special/57286.json
     * 招生快迅列表：school_id->1156
     *  https://static-data.gaokao.cn/www/2.0/single/news/single_school/1156.json
     *  招生快迅详情：school_id->1156
     *   https://static-data.gaokao.cn/www/2.0/school/1156/news/68001/208758.json
     *
     * 招生计划：school_id->1156
     *      https://static-data.gaokao.cn/www/2.0/single/school/1156/dic/specialplan.json
     *      https://api.zjzw.cn/web/api/?local_province_id=41&local_single_id=75001&local_type_id=94&page=1&school_id=1156&size=5&student_type=66&uri=apidata/api/gkv3/single/plan&year=2024&signsafe=068f8a1088ceed7a8d71973d838eb55a
     * 专业分：
     *      https://static-data.gaokao.cn/www/2.0/single/school/1156/dic/specialscore.json
     *      https://api.zjzw.cn/web/api/?local_province_id=41&local_single_id=75001&local_type_id=195&page=2&school_id=1156&size=5&student_type=62&uri=apidata/api/gkv3/single/special_score&year=2023&signsafe=9eadd24d412956abb7c6160fa11b238d
     *
     *
     */
    /**
     * 院校列表
     */
    public void getColleges(String location,Integer pageIndex,Integer pageSize,List<Integer> finishedCollegeList,String collegeNames) {
        int count = 0, total = 5000;
        if (null==pageIndex ) pageIndex = 1;
        if (null==pageSize ) pageSize = 20;
        Boolean isFinished = false;
        Set<Integer> collegeList = new HashSet<>();
        do {
            String path = domainUrl+"web/api?page=%s&size=%s&uri=apidata/api/gkv3/single/school&local_province_id=41&keyword=%s&school_type=&nature=&type=&colleges_level=&doublehigh=&single=75001";
            if (StringUtils.isNotBlank(collegeNames)){
                try {
                    collegeNames = URLEncoder.encode(collegeNames, "UTF-8");
                } catch (UnsupportedEncodingException e) {
                    log.error(e.toString());
                    return;
                }
            }
            path = String.format(path,pageIndex,pageSize,collegeNames);

            Dict params = Dict.create();
            JSONObject res = getZsgkJson(path, params,false);
            JSONArray arr = res.getJSONObject("data").getJSONArray("item");
            if(null!=arr&&arr.size()<pageSize){
                isFinished = true;
            }
            for (int i = 0; i < arr.size(); i++) {
                Entity record = Entity.create("zsgk_college").parseBean(arr.getJSONObject(i));
                Date now = new Date();
                record.set("location", location);
//                record.set("createTime", now);
                record.set("updateTime", now);
                Integer school_id= record.getInt("school_id");
                String schoolName= record.getStr("name");
                if (finishedCollegeList.contains(school_id)){
                    log.info("包含学校 {} - {}，跳过",school_id,schoolName);
                    continue;
                }
                log.info("开始第【{}】页 - 第{}个学校： {} - {}",pageIndex,(i+1),school_id, schoolName);
                ThreadUtil.safeSleep(1*1000);

                /**
                //院校详情
                path = domainUrl2+"www/2.0/school/%s/info.json";
                path = String.format(path,school_id);
                res = getZsgkJson(path, params,false);
                JSONObject info = res.getJSONObject("data");
                record.putAll(info);
                ThreadUtil.safeSleep(2*1000);

                //院校住宿条件
                path = domainUrl2+"www/2.0/school/image/%s.json";
                path = String.format(path,school_id);
                res = getZsgkJson(path, params,false);
                JSONObject imageInfo = res.getJSONObject("data");
                record.putAll(imageInfo);

                log.info(JSONObject.toJSONString(record));
                record.put("feature",record.getStr("feature"));
                record.put("xueke_rank",record.getStr("xueke_rank"));
                record.put("province_single",record.getStr("province_single"));
                record.put("remark",record.getStr("remark"));
                record.put("urllinks",record.getStr("urllinks"));
                record.put("video",record.getStr("video"));
                record.put("video_pc",record.getStr("video_pc"));
                record.put("dualclass",record.getStr("dualclass"));
                record.put("special",record.getStr("special"));
                record.put("province_score_min",record.getStr("province_score_min"));
                record.put("pro_type_min",record.getStr("pro_type_min"));
                record.put("pro_type",record.getStr("pro_type"));
                record.put("rank",record.getStr("rank"));
                record.put("fenxiao",record.getStr("fenxiao"));
                record.put("yk_feature",record.getStr("yk_feature"));
                record.put("yk_type",record.getStr("yk_type"));
                record.put("canteenDormitory",record.getStr("canteenDormitory"));
                record.put("canteenDormitoryImg",record.getStr("canteenDormitoryImg"));
                record.put("schoolImg",record.getStr("schoolImg"));
                insertOrUpdate(record, "school_id");
                //处理json数据
                log.info("完成第【{}】页 - 第{}个学校：【{}】- {} - {}",pageIndex,(i+1),school_id, name);
                ThreadUtil.safeSleep(2*1000);
                 **/

                //开设专业
//                path = domainUrl2+"www/2.0/single/school/%s/special/single_type_list.json";
//                path = String.format(path,school_id);
//                res = getZsgkJson(path, params,false);
//                ThreadUtil.safeSleep(1*1000);
//
//                JSONObject specialObj = res.getJSONObject("data");

//                for (String k : specialObj.keySet()) {
//                    Entity specialRecordTable = Entity.create("zsgk_college_major");
//                    String key = k;
//                    JSONArray array = (JSONArray)specialObj.get(key);
//                    array.stream().forEach(ll->{
//                        JSONObject specialRecord = (JSONObject) ll;
//                        specialRecord.put("single_type", specialRecord.getString("single_type"));
//                        specialRecord.put("key", k);
//                        now = new Date();
//                        //specialRecord.put("createTime", now);
//                        specialRecord.put("updateTime", now);
//                        specialRecord.put("school_name",schoolName );
//                        String specialId = specialRecord.getString("id");
//                        //专业详情：www/2.0/single/school/1156/special/57286.json
//                        String detailPath = domainUrl2 + "www/2.0/single/school/%s/special/%s.json";
//                        detailPath = String.format(detailPath, school_id,specialId);
//                        JSONObject specialDetail = getZsgkJson(detailPath, params, false);
//                        if(null!=specialDetail&&specialDetail.containsKey("data")){
//                            JSONObject detailDataObj = specialDetail.getJSONObject("data");
//                            if(null!=detailDataObj&&detailDataObj.containsKey("content")){
//                                specialRecord.put("detail", detailDataObj.getString("content"));
//                            }
//                        }
//
//                        specialRecordTable.putAll(specialRecord);
//                        insertOrUpdate(specialRecordTable, "id");
//                        ThreadUtil.safeSleep(seconds*1000);
//                    });
//                }
//                log.info("完成第【{}】页 - 第{}个学校的开设专业：【{}】- {} - {}",pageIndex,(i+1),school_id, schoolName);

                //招生快迅列表
//                path = domainUrl2+"www/2.0/single/news/single_school/%s.json";
//                path = String.format(path,school_id);
//                res = getZsgkJson(path, params,false);
//                if(null!=res&&res.containsKey("data")){
//                    JSONObject newsObj = res.getJSONObject("data");
//                    for (String k : newsObj.keySet()) {
//                        Entity newsRecordTable = Entity.create("zsgk_college_news");
//                        String key = k;
//                        JSONArray array = (JSONArray)newsObj.get(key);
//
//                        array.stream().forEach(ll->{
//                            JSONObject newsRecord = (JSONObject) ll;
//                            newsRecord.put("single_type", newsRecord.getString("single_type"));
//                            newsRecord.put("key", k);
//                            now = new Date();
//                            //newsRecord.put("createTime", now);
//                            newsRecord.put("updateTime", now);
//                            String type_id = newsRecord.getString("type_id");
//                            String newsId = newsRecord.getString("id");
//                            //快讯详情：www/2.0/school/1156/news/68001/208758.json
//                            String detailPath = domainUrl2 + "www/2.0/school/%s/news/%s/%s.json";
//                            detailPath = String.format(detailPath,school_id, type_id,newsId);
//                            JSONObject resDetail = getZsgkJson(detailPath, params, false);
//                            JSONObject detailDataObj = resDetail.getJSONObject("data");
//                            if(detailDataObj.containsKey("content")){
//                                newsRecord.put("detail", detailDataObj.getString("content"));
//                                newsRecord.put("type_name", detailDataObj.getString("type_name"));
//                            }
//
//                            newsRecordTable.putAll(newsRecord);
//                            insertOrUpdate(newsRecordTable, "id");
//                            ThreadUtil.safeSleep(seconds*1000);
//                        });
//
//                    }
//                    log.info("完成第【{}】页 - 第{}个学校的招生快迅：【{}】- {} - {}",pageIndex,(i+1),school_id, schoolName);
//                    collegeList.add(school_id);
//                    log.info("总共完成学校：{}",JSONObject.toJSONString(collegeList));
//                }else {
//                    log.info("学校无招生快迅：【{}】- {} ",school_id, schoolName);
//                }
                List<Integer> includeSingleIdList= Arrays.asList(75006,75008,75015);


                //招生计划
                //{ "code": "0000", "message": "成功", "data": { "province": [ 41 ], "year": { "41": [ 2024, 2023, 2022, 2021, 2020 ] }, "single": { "41_2024": [ { "id": 75001, "name": "高职单招", "rank": "20" } ], "41_2023": [ { "id": 75001, "name": "高职单招", "rank": "20" } ], "41_2022": [ { "id": 75001, "name": "高职单招", "rank": "20" } ], "41_2021": [ { "id": 75001, "name": "高职单招", "rank": "20" } ], "41_2020": [ { "id": 75001, "name": "高职单招", "rank": "20" } ] }, "student": { "41_2024_75001": [ { "id": 66, "name": "其他考生", "rank": "0" } ], "41_2023_75001": [ { "id": 66, "name": "其他考生", "rank": "0" } ], "41_2022_75001": [ { "id": 62, "name": "高中毕业生", "rank": "70" } ], "41_2021_75001": [ { "id": 62, "name": "高中毕业生", "rank": "70" } ], "41_2020_75001": [ { "id": 62, "name": "高中毕业生", "rank": "70" } ] }, "type": { "41_2024_75001_66": [ { "id": 94, "name": "文理兼收", "rank": "0" } ], "41_2023_75001_66": [ { "id": 195, "name": "其他", "rank": "0" } ], "41_2022_75001_62": [ { "id": 195, "name": "其他", "rank": "0" } ], "41_2021_75001_62": [ { "id": 195, "name": "其他", "rank": "0" } ], "41_2020_75001_62": [ { "id": 195, "name": "其他", "rank": "0" } ] } }, "md5": "89f9ec08a9f972b48391b732003732fb", "time": "2024-04-11 07:01:16" }
                path = domainUrl2+"www/2.0/single/school/%s/dic/specialplan.json";
                path = String.format(path,school_id);
                res = getZsgkJson(path, params,false);
                if(null!=res&&res.containsKey("data")){
                    JSONObject dataObj = res.getJSONObject("data");

                    JSONObject signlePlanObj = dataObj.getJSONObject("single");
                    Map<String,String> signleMap = new HashMap<>();
                    signlePlanObj.keySet().stream().forEach(kkk->{
                        JSONArray jsonArray = (JSONArray)signlePlanObj.get(kkk);
                        jsonArray.stream().forEach(llObj->{
                            JSONObject oobject = (JSONObject)llObj;
                            signleMap.put(oobject.getString("id"),oobject.getString("name"));
                        });
                    });

                    JSONObject studentPlanObj = dataObj.getJSONObject("student");
                    Map<String,String> studentTypeMap = new HashMap<>();
                    studentPlanObj.keySet().stream().forEach(kkk->{
                        JSONArray jsonArray = (JSONArray)studentPlanObj.get(kkk);
                        jsonArray.stream().forEach(llObj->{
                            JSONObject oobject = (JSONObject)llObj;
                            studentTypeMap.put(oobject.getString("id"),oobject.getString("name"));
                        });
                    });
                    JSONObject typePlanObj = dataObj.getJSONObject("type");
                    for (String k : typePlanObj.keySet()) {
                        Entity planRecordTable = Entity.create("zsgk_college_submit_plan");
                        String key = k;//41_2024_75001_66
                        String[] keyArray = key.split("_");
                        String local_province_id = keyArray[0];
                        String year = keyArray[1];
                        String local_single_id = keyArray[2];
                        if (!includeSingleIdList.contains(Integer.parseInt(local_single_id))){
                            continue;
                        }
                        String student_type = keyArray[3];
                        JSONArray LocalTypeArray = (JSONArray)typePlanObj.get(key);
                        for (Object ll : LocalTypeArray) {//local_type_id
                            JSONObject localTypeObj = (JSONObject) ll;
                            String local_type_id = localTypeObj.getString("id");
                            String type_name = localTypeObj.getString("name");
                            Integer page = 1, size = 30;
                            int totalAll=100;
                            //计划 https://api.zjzw.cn/web/api/?local_province_id=41&local_single_id=75001&local_type_id=94&page=1&school_id=1156&size=5&student_type=66&uri=apidata/api/gkv3/single/plan&year=2024&signsafe=068f8a1088ceed7a8d71973d838eb55a
                            do {
                                String detailPath = domainUrl + "web/api/?local_province_id=%s&local_single_id=%s&local_type_id=%s&page=%s&school_id=%s&size=%s&student_type=%s&uri=apidata/api/gkv3/single/plan&year=%s";
                                detailPath = String.format(detailPath, local_province_id, local_single_id, local_type_id, page, school_id, size, student_type, year);
                                log.info("{}-{} ,请求url= {}", school_id, schoolName,detailPath);
                                JSONObject resDetail = getZsgkJson(detailPath, params, true);
                                JSONObject dataObject = resDetail.getJSONObject("data");
                                Integer numFound = dataObject.getInteger("numFound");
                                totalAll = numFound;
                                JSONArray itemArray = dataObject.getJSONArray("item");
                                if (numFound != itemArray.size()) {
//                                    log.error("{}-{} 计划数据量异常，停止程序，停止程序,请求url= {}", school_id, schoolName,detailPath);
//                                    return;
                                }
                                for (Object ll0 : itemArray) {
                                    JSONObject insertRecord = (JSONObject) ll0;
                                    String spname = insertRecord.getString("spname");
                                    insertRecord.put("udid", k + "_" + local_type_id + "_" + school_id + "_" + numFound + "_" + spname);
                                    insertRecord.put("key", k);
                                    insertRecord.put("year", year);
                                    insertRecord.put("single_id", local_single_id);
                                    insertRecord.put("single_name", signleMap.get(local_single_id));
                                    insertRecord.put("school_id", school_id);
                                    insertRecord.put("school_name", schoolName);
                                    insertRecord.put("province_id", local_province_id);
                                    insertRecord.put("type_id", local_type_id);
                                    insertRecord.put("type_name", type_name);
                                    insertRecord.put("student_type", student_type);
                                    insertRecord.put("student_type_name", studentTypeMap.get(student_type));
                                    insertRecord.put("numFound", year + "_" + numFound);
                                    now = new Date();
//                                    insertRecord.put("createTime", now);
                                    insertRecord.put("updateTime", now);

                                    planRecordTable.putAll(insertRecord);
                                    insertOrUpdate(planRecordTable, "udid");
                                    ThreadUtil.safeSleep(seconds * 1000);
                                }
                                count = page * size;//20
                                page += 1;//2
                            }while (count <= totalAll);
                        }
                    }
                    log.info("完成第【{}】页 - 第{}个学校的招生计划：【{}】- {} - {}",pageIndex,(i+1),school_id, schoolName);
                    collegeList.add(school_id);
                    log.info("总共完成学校：{}",JSONObject.toJSONString(collegeList));
                }else {
                    log.info("学校无招生计划：【{}】- {} ",school_id, schoolName);
                }


                //专业分
                //{ "code": "0000", "message": "成功", "data": { "province": [ 41 ], "year": { "41": [ 2023 ] }, "single": { "41_2023": [ { "id": 75001, "name": "高职单招", "rank": "2" } ] }, "student": { "41_2023_75001": [ { "id": 62, "name": "高中毕业生", "rank": "70" }, { "id": 63, "name": "中职毕业生", "rank": "69" } ] }, "type": { "41_2023_75001_63": [ { "id": 195, "name": "其他", "rank": "0" } ], "41_2023_75001_62": [ { "id": 195, "name": "其他", "rank": "0" } ] } }, "md5": "741bcf4aa6fe4bc803a6fe5561318e19", "time": "2023-11-06 18:30:20" }
                path = domainUrl2+"www/2.0/single/school/%s/dic/specialscore.json";
                path = String.format(path,school_id);
                res = getZsgkJson(path, params,false);
                if(null!=res&&res.containsKey("data")){
                    JSONObject dataObj = res.getJSONObject("data");

                    JSONObject signlePlanObj = dataObj.getJSONObject("single");
                    Map<String,String> signleMap = new HashMap<>();
                    signlePlanObj.keySet().stream().forEach(kkk->{
                        JSONArray jsonArray = (JSONArray)signlePlanObj.get(kkk);
                        jsonArray.stream().forEach(llObj->{
                            JSONObject oobject = (JSONObject)llObj;
                            signleMap.put(oobject.getString("id"),oobject.getString("name"));
                        });
                    });

                    JSONObject studentPlanObj = dataObj.getJSONObject("student");
                    Map<String,String> studentTypeMap = new HashMap<>();
                    studentPlanObj.keySet().stream().forEach(kkk->{
                        JSONArray jsonArray = (JSONArray)studentPlanObj.get(kkk);
                        jsonArray.stream().forEach(llObj->{
                            JSONObject oobject = (JSONObject)llObj;
                            studentTypeMap.put(oobject.getString("id"),oobject.getString("name"));
                        });
                    });

                    JSONObject typePlanObj = dataObj.getJSONObject("type");
                    for (String k : typePlanObj.keySet()) {
                        Entity planRecordTable = Entity.create("zsgk_college_submit_major");
                        String key = k;//41_2024_75001_66
                        String[] keyArray = key.split("_");
                        String local_province_id = keyArray[0];
                        String year = keyArray[1];
                        String local_single_id = keyArray[2];
                        if (!includeSingleIdList.contains(Integer.parseInt(local_single_id))){
                            continue;
                        }
                        String student_type = keyArray[3];
                        JSONArray LocalTypeArray = (JSONArray)typePlanObj.get(key);
                        for (Object ll : LocalTypeArray) {//local_type_id
                            JSONObject localTypeObj = (JSONObject) ll;
                            String local_type_id = localTypeObj.getString("id");
                            String type_name = localTypeObj.getString("name");
                            Integer page = 1, size = 30;
                            int totalAll=100;

                            //分数 https://api.zjzw.cn/web/api/?local_province_id=41&local_single_id=75001&local_type_id=94&page=1&school_id=1156&size=5&student_type=66&uri=apidata/api/gkv3/single/plan&year=2024&signsafe=068f8a1088ceed7a8d71973d838eb55a
                            do {
                                String detailPath = domainUrl + "web/api/?local_province_id=%s&local_single_id=%s&local_type_id=%s&page=%s&school_id=%s&size=%s&student_type=%s&uri=apidata/api/gkv3/single/special_score&year=%s";
                                detailPath = String.format(detailPath, local_province_id, local_single_id, local_type_id, page, school_id, size, student_type, year);
                                log.info("{}-{} ,请求url= {}", school_id, schoolName,detailPath);
                                JSONObject resDetail = getZsgkJson(detailPath, params, true);
                                JSONObject dataObject = resDetail.getJSONObject("data");
                                Integer numFound = dataObject.getInteger("numFound");
                                JSONArray itemArray = dataObject.getJSONArray("item");
                                if (numFound != itemArray.size()) {
//                                    log.error("{}-{} 专业分数据量异常，停止程序,请求url= {}", school_id, schoolName,detailPath);
//                                    return;
                                }
                                for (Object ll0 : itemArray) {
                                    JSONObject insertRecord = (JSONObject) ll0;
                                    String spname = insertRecord.getString("spname");
                                    insertRecord.put("udid", k + "_" + local_type_id + "_" + school_id + "_" + numFound + "_" + spname);
                                    insertRecord.put("key", k);
                                    insertRecord.put("year", year);
                                    insertRecord.put("single_id", local_single_id);
                                    insertRecord.put("single_name", signleMap.get(local_single_id));
                                    insertRecord.put("school_id", school_id);
                                    insertRecord.put("school_name", schoolName);
                                    insertRecord.put("province_id", local_province_id);
                                    insertRecord.put("type_id", local_type_id);
                                    insertRecord.put("type_name", type_name);
                                    insertRecord.put("student_type", student_type);
                                    insertRecord.put("student_type_name", studentTypeMap.get(student_type));
                                    insertRecord.put("numFound", year + "_" + numFound);
                                    now = new Date();
//                                    insertRecord.put("createTime", now);
                                    insertRecord.put("updateTime", now);
                                    String logo = "https://static-data.gaokao.cn/upload/logo/%s.jpg";
                                    logo = String.format(logo,school_id);
                                    insertRecord.put("logo", logo);

                                    planRecordTable.putAll(insertRecord);
                                    insertOrUpdate(planRecordTable, "udid");
                                    ThreadUtil.safeSleep(seconds * 1000);
                                }

                                count = page * size;//20
                                page += 1;//2
                            }while (count <= totalAll);
                        }
                    }
                    log.info("完成第【{}】页 - 第{}个学校的专业分：【{}】- {} - {}",pageIndex,(i+1),school_id, schoolName);
                    collegeList.add(school_id);
                    log.info("总共完成学校：{}",JSONObject.toJSONString(collegeList));
                }else {
                    log.info("学校无专业分：【{}】- {} ",school_id, schoolName);
                }


            }

            log.info("已完成page={}, 开始第{}页", pageIndex, (pageIndex + 1));
            count = pageIndex * pageSize;//20
            pageIndex += 1;//2
            if (isFinished){
                break;
            }
        }while (count <= total);
    }

    public static String unicodeToChinese(String unicodeStr) {
        Pattern pattern = compile("(\\\\u(\\p{XDigit}{4}))");
        Matcher matcher = pattern.matcher(unicodeStr);
        StringBuffer sb = new StringBuffer();
        while (matcher.find()) {
            char ch = (char) Integer.parseInt(matcher.group(2), 16);
            matcher.appendReplacement(sb, String.valueOf(ch));
        }
        matcher.appendTail(sb);
        return sb.toString();
    }

    public static String unicodeToChinese(Entity object){
        return unicodeToChinese(JSONObject.toJSONString(object));
    }

    public static Entity unicodeToChineseObj(Entity object){
        return Entity.parse(unicodeToChinese(object));
    }

    public static void main(String[] args) {
        ZhangSGKService service = new ZhangSGKService();
//        String collegeNames = "民政职业大学";
        List<String> collegeNameList=Arrays.asList("新疆生产建设兵团兴新职业技术学院","塔里木职业技术学院");
        for (String s : collegeNameList) {
            service.getColleges("河南",1,20,Arrays.asList(),s);
        }
//        service.getColleges("河南",1,20,Arrays.asList(),collegeNames);
    }
}
