package com.miaxis.test;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.miaxis.JpcjApplication;
import com.miaxis.common.utils.http.HttpUtils;
import com.miaxis.icon.domain.IconCategory;
import com.miaxis.icon.domain.IconCategoryImage;
import com.miaxis.icon.domain.IconInfo;
import com.miaxis.icon.domain.IconQuestion;
import com.miaxis.icon.service.IIconCategoryImageService;
import com.miaxis.icon.service.IIconCategoryService;
import com.miaxis.icon.service.IIconInfoService;
import com.miaxis.icon.service.IIconQuestionService;
import com.miaxis.web.domain.WebNote;
import com.miaxis.web.service.IWebNoteService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@ActiveProfiles("dev")
@SpringBootTest(classes = JpcjApplication.class)
@RunWith(SpringRunner.class)
public class Script1 {

//
//    @Resource
//    ITQuestionService questionService;

    @Resource
    IWebNoteService webNoteService;


    @Resource
    IIconInfoService iIconInfoService;

    @Resource
    IIconQuestionService iIconQuestionService;

    @Resource
    IIconCategoryService iIconCategoryService;

    @Resource
    IIconCategoryImageService iIconCategoryImageService;
    @Test
    public void Scrip1() throws Exception {

        //插入图标分类以及分类图标对应关系
       // setCategoryData();
        //插入图标信息以及图标题目对应关系
        setIconData();
        //根据题目匹配
        //matchByAnwser();
    }

    private void setCategoryData() {
        String url ="https://sirius.kakamobi.cn/api/open/traffic-icon/group-list.htm";
        String param = "_appName=jiakaozhushou&_clv=1024&_launch=12&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=f276d9e9cb131b8208b72f9f09e6a8fd&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PPU4CURRG3ZJhCTYuwMbSDRiX8BrtiZJpLBjFbsKQGQiIie7C%2Br37W9zJe9eGkNBIIY3V13wnJ2dmL7PX3p%2BMhOggcJC0kzJwGQgdTbXsSRUjKKUoQL60r4fP902%2Fi%2FeejFFUxD9MmcGjUdwLY9JS4DiRi8Pp0xoKtq1GCXXdQmikpoBVwdBWTaowU6VU%2BdrO765HN5ej2yt%2FtMV6%2B9b71MaTZ2fLufRl0RF2BLLK2qUldcSLsloLrJC9nGQbSyi%2BNfL6XxnowOJj08wcM81DzI2EhqANQDgNkuK8IMgxoPbJH5wOFHeSBz3CfHbx%2FfMLCV%2BJzjcBAAA%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&patternCode=101&sceneCode=101&score12=0&sign=731a6fcb825f5490e321e7f05a18fca2";
        String s = HttpUtils.sendGet(url, param);
        JSONObject wholeData = JSONObject.parseObject(s);
        JSONObject data = wholeData.getJSONObject("data");
        JSONArray itemList =  data.getJSONArray("itemList");
        if (itemList == null) return ;
        for (int i=0 ;i <itemList.size();i++){
            JSONObject item = itemList.getJSONObject(i);
            IconCategory iconCategory =  new IconCategory();
            String name = unicodeToCN(item.getString("name"));
            iconCategory.setCategory(name);

            iIconCategoryService.save(iconCategory);
            JSONArray imageList = item.getJSONArray("imageList");
            if (imageList != null){
                for (int j=0 ;j <imageList.size();j++){
                    String imageStr =  imageList.getString(j);
                    IconCategoryImage iconCategoryImage= new IconCategoryImage();
                    iconCategoryImage.setImageurl(imageStr);
                    iconCategoryImage.setCategory(name );
                    iIconCategoryImageService.save(iconCategoryImage);
                }
            }

        }

    }

    private void setIconData() throws Exception {
        String url ="https://sirius.kakamobi.cn/api/open/traffic-icon/icon-list.htm";
        String param = "_appName=jiakaozhushou&_clv=1024&_launch=8&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=6edd66e6ce8fa26c21b8e9509f70ddf8&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12QO04CYRSF7%2FN%2FZG5DdRsIa3ALosOQaQjMBE1Eos0fuwkaGnsTV%2BAyLOxdBXE9UkhjdZpz8uU7M7ueXXX%2BbIzMY9QxhhGmilLF4mIAacoAEhU4RFT2td083N7vulF89GAkCIh%2BZ0CkHo3jFEkCpKSniJRcz53GBKVpIGKp60ZLizUXGZKUZmjDIJkH4MGX9vPxfXz7PL5%2F%2BYttltvLzud22L86Wc6pS5uepWfFVYY%2BrLln2qTVEnUl5OkM21kQ9K2x1%2F%2FMFCpCPxhkoph5UWJusbSsTVGWecEQF0kUTwK17%2F%2FGYcwywlyRVKdHJhdPv8lP2EY3AQAA&_vendor=appstore&_version=8.13.2&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.13.2&carType=car&groupId=1&patternCode=101&sceneCode=101&score12=0&sign=90620500420099af09ae692c81d3ed21";
        String category = "停车让行";
        saveDataByCategory(url,param,category);

        param="_appName=jiakaozhushou&_clv=1024&_launch=12&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=d84a0f0e954177d480052f28d4e76eb9&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12Pu04CURRF%2BQV7axP%2FwN6vMvyLzZncx3mS0JyK%2BjZa2RAl04wMo5ggJkpmIEghjdVu9srKWsPb%2Bn3wF2BlnipONc80VhIrJicwixM2o4TGOSmy7%2BHn8ftzM8zSg2cQUlP1LzAR9AScJiqULUY8TZLoeP60QEpta0lL17VYGu24UB2ptHWTawpcG9d%2BhLubi%2FH1aHx16c%2BwO24%2FBl%2FBfPHkAiHEIe56pp5RD8H6vOeeZRcPR8UDicezbAOZ1LfA3v0rQ6tEfQ4WRFLgZUmh0dIwtgWZVkVzWkZCPQV0vviD85TTTENlJ1hGt%2Fevv3A7cow3AQAA&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=2&patternCode=101&sceneCode=101&score12=0&sign=0d297639ffac5e96017659d4d394b346";
        category = "警告标志";
        saveDataByCategory(url,param,category);

        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=245e01e9f78e99afc20a3f8e6ae36733&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PO04CYRRGXQxxI%2FRuwdIdmNhN0NBYafO3BGaCJiKJ4DBkKpdCdRsS7vN%2FZG4hhTRWX%2FOdnJyNf2%2B2NTy6kMiR7EjxQHngPIiCOmI%2BCaImQ4mJTGDhby%2Fvn%2Bv6kF4hOishEXw4Mhskl3Qi1og523kSZ7DLp3Ml7TpMFNq2s9BTK0GrrKGr%2BlhpkQqlgplf392M7m9HD2N48uVs9VXDzqeTZ2AvJdd52Yg2YjQv2MSFNMLLPJ%2BRzZUhX2Rrj0qwcoH2X5nhwARTx8KciuxDKj2FXqwLJroLFNM%2Bq9E5oIXJHxyPkg5UBjzDfDX%2BWfwCRvMztDcBAAA%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=3&patternCode=101&sceneCode=101&score12=0&sign=54de2c13f0c19b1c65a232a77e66c652";
        category = "指示标志";
        saveDataByCategory(url,param,category);


        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=04e3278c5603be353d6e178c7b37a5cd&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PMU7DQBBFN3JHwAGJECuxlRqaLWisgKJdeYqZnZndJlLkam6BxF0i7sIFuAIlN6ChwQVpqH7zn57eHK7ml609ARPzgfRAeaQwpDCwmABiODKiFEXOhZRtA9f3N3erdiwPliEJIZHdAqakVoDLkZJkDEGnKSmYnj8OhMQ5LOTr2qmvqGYvfRDv%2Bir3ErlH7q2Bt8%2Fv08fX6f3HnmHbLC9aW8B%2B92gJYgxt2HYsHSutI3Z5wx2nbVg3pGtJFs6yFWQhWwJb%2Fa9McUhke8CYUok88yVW5CtW55Vl4SmXWRClKaC23R%2BcD1xGigNOcHLD68svoSiy0TcBAAA%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=4&patternCode=101&sceneCode=101&score12=0&sign=f97403ecc2f8ed22b7887784603e94a1";
        category = "指路标志";
        saveDataByCategory(url,param,category);


        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=1ea37c194894b773c4da54636d7b737a&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PvUoDURBGRY35geyym8bARrGLSxDsBLmVJE2YYu%2BFYX7unXkAX0XyZla2ljY%2BgL0pTGP1Nd%2FhcJZ4u7yp4B5ZmXfqO817jQPFgQ0MReKWRay4cC7qDFM8f764HFX78gQZyVRU4QqFyKEgl62SZYnRj1Mogp8%2BLZpa20rR0HWth0Y7DtZHC23f5N4S98I9zPDt%2Fevw%2BXP4%2BIYHnM%2FG1xWscLO%2BA8KUYhXnNVvNrpMkdZ5yzTSPk5n6xAjiSTbCbApjZOj%2BlbkMpLBBSUQl8SKU1Gho2NvgbKuguSyiuR4DOlj%2FwXnHZa9pkCNMZy%2Bvj7%2BTkAIvNwEAAA%3D%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=5&patternCode=101&sceneCode=101&score12=0&sign=eda769364f752677375c35d708d92208";
        category = "交警手势信号";
        saveDataByCategory(url,param,category);



        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=1072d1a4ebf8a6294b9e662e097f74b2&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PPUoDURRGxQ1YuAxrG1s3E9yLewikvARu8R5z73v3p1TCkCzgoRijMENC0kwYnYAxhWmsvuY7HM4Rv49fDSzQ1X2sPNY01VBZqJyAUCRMXIQyi6es7LDDj5fP91Uzza%2BQ0EhFFd5QzBgyep6oUZIQ%2BDTZAvD50yEpdZ1kLcPQcel18EJ1oNLVfaopei1ewwYfbi5Hd9ej2yt4xvVm%2BdPAAWfzJzCMMTRh3Tq1zrqN0qadt27rsN0ob8kgnGUrTKSwRIfhXxlLZQozlGiWo%2B9Ljr2W3rkr7HQomvI%2BEOspYID5H5zGnqcaKznBdnH%2F6L%2BgIeVLNwEAAA%3D%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=6&patternCode=101&sceneCode=101&score12=0&sign=9f16fda22d7461a759cac36ce9fe2252";
        category = "旅游区标志";
        saveDataByCategory(url,param,category);




        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=980f0a8444dd6661705622512a74ee6d&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PPUoDURRG3YadZCsiuAVLd%2BAODBKns3ggWGcmCcaATtSUMyldx61CUr13f%2BHCvGcK01h9zXc4nI1%2FbT5reHQxkYPRweLO8sB5EAR01bwXVUykEpORwNzfXz5el%2FUuPUN0RlMzeHNlJkguaW%2BMUXOm4yTOQKdP72jY95ostG1PobNWAlYZQ191scIilUoFC7%2B4vR7d3Yzur%2BDBp4vVdw1rH0%2BegL2UXOdpI9gI2axoE%2BfSCE%2FzbGE0Q4Z8ki09osHKBdp%2FZaQDG4xdC3Mqsg2pdBY6oT6Q4DpYTNuMZMeAFiZ%2FcDxI2lkZ9Ajz2eXP%2BS8PCzKYNwEAAA%3D%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=7&patternCode=101&sceneCode=101&score12=0&sign=5503b516040b4c4aa28b555983dbc0c3";
        category = "道路施工安全标志";
        saveDataByCategory(url,param,category);


        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=8ff02d1e2f12cbfef0d702467b3504e8&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PvUoDURBGhTBlwvzcO8PeC9P4Ikkku6DGGNgou2niEgQ7Qe4j%2BAZ2Vva%2Bgp3kscQUprH6mu9wOGu%2FX9%2FV8OAkRBOxiYSRpApTRQrqzGlMzBqNKUQxgplfvlxdL%2BtRfIbgqMIicOOMaBCd4lhQA6dkx4mYwE6f3lW07zlKadveSictFR2Sln7owqCZBqYB5v79%2Bnl4%2Bzq8f8CjL%2Bar2xo2vt89AXrOqU6LhrQhk2nmJsyoIVyk6VxsqgjpJFt6UIGVE7T%2FyowrFNg7Z8SYaVti7qR0ZH0x0k2RELdJTY4BLez%2B4DChOJJc8RHGs4vzn1%2B2%2F%2Fh8NwEAAA%3D%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=8&patternCode=101&sceneCode=101&score12=0&sign=f88dd3c12f0d7e0a09bd8d0c751c2f3a";
        category = "辅助标志";
        saveDataByCategory(url,param,category);



        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=abc820db8679d5b3eaf72f57b2a182c0&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PvUoDQRRGLXwFwdreN7DzuSTvYbXMIPdv5t4mEAj3BZQpLA1LcMk2EbIKGmNCwq4pTGP1Nd%2FhcJbwvvwY%2FAWQESesE85TjhXFCs0NROIYRSypYE6s6Fv4evr8Xg%2FT9OgZyFiY%2FQeESD0BpjGTZYlRj5Moup4%2BLRhb20ri0nWtloY7LFZHK23d5NoC1oK17%2BHu5mJ0fT66uvRXOOw3b4OvYD57doIQ4hAPPVqPyrsgfd5ij3SIuz3rzsjjSbaGbOwbQO%2F%2BlalUxD4HCUQp4KKk0HBpUNuiaKvCOS2iKR8DOp%2F9wXmCacqhkiNMZ7f3D79NRFhJNwEAAA%3D%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=9&patternCode=101&sceneCode=101&score12=0&sign=dee6ab87308a4481555f90665e69c417";
        category = "禁止标线";
        saveDataByCategory(url,param,category);

        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=ce888de508d485618740080083d2f339&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PPUoDURRGXYG4A0vBBbgB6%2BCqElJd3hu4cH%2Ffa12GQowkmQmZKSyiZsBuDJJWEB6mMI3V13yHw9ni2%2Fa9gU8UEhmTjSlPKVYaK3FwZI4TYfZkLDmRCSzx8fvhed5M0w9kVCcmgidkVYOEkiaknjlGO07SCHb6tOjkbcuJSt%2B3VjrqpfgQvbRDlwcPMrAMsMC786vR5c3o4hq%2BcL2YvTaww8P%2BAxRDiE1c1%2BK1GK0C13kpteg6rhZkK1eIJ9kcsxPMUKD%2FV2ZcKcEBOaimIJuSQkelE2uLie8K5bSJbnQM6GH%2FB%2BexpCmFio%2Bwnt3ev%2FwCZe66CTcBAAA%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=10&patternCode=101&sceneCode=101&score12=0&sign=d9f6d2182020c2367258689bdff9e4a8";
        category = "警告标线";
        saveDataByCategory(url,param,category);


        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=e96be788c36b2c5dadcaf1513d7e6b8d&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12Pu00DQRRFZ943eKuZF1mW3AexF5ts5bV2bfmDBJNAboG1CQkNIMqgABLKQK6CLnCAE6Kb3KOjM7fr%2Baz3ZyMhmghMJI4kV5wrQkdTzWNSxQBKMQiQr%2Bz%2B8W637UfhwaMxior4rSkzeDAKY2GMmjOcJ3B2uHxaQ8G21SClrlsojdRUcMhY2qGJAyYalAbf2Pf71%2Bn14%2FT26U%2B23Oxvep%2Fa4fjibCnlPi87wo5A1km7uKKOeJnXG4E1sueLbGsRxfdGXv8rA61Y%2FGCamEOiRQmpkdIQtAUIp0ViWGQEOQfUfvyD44TCSFKlZ5jD7OrnF5B6t7Q3AQAA&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=11&patternCode=101&sceneCode=101&score12=0&sign=ac98b1af0beaa03bec673eb0e93ffccd";
        category = "指示标线";
        saveDataByCategory(url,param,category);


        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=81732bba50ccd40cf81d5f1ae0eee319&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PO0oDYRRGXYLLkKxCsLZwGa5ANyAEidP%2FIGgMKJlJ0s1komYNriHpbhW4MP%2FjPk1hGquv%2BQ6Hs8Wv7WcNT6iuunfeez54HCQOSkBoFndqRoVNc3FWWOL7y8frtD6UZ8go5OYOb2giDAW17FwoW4x8nCIR%2BPTpkJy6zoqHvu84tN5roCpS6Ko2V5S0Mq1ghRe3l6P7m9HdNTzifDX7rmGD48kDCKYU6zhvlBplXyRr8lIblXlcrJwXJBBPsilmcpihQv%2BvjG0QhzFaEilJ16Gk1kOr3AVW2gTPZR2J%2FRjQw%2BQPznstB0%2BDHWE5u%2Fo5%2FwWwyHNdNwEAAA%3D%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=12&patternCode=101&sceneCode=101&score12=0&sign=2b229552ceb5285838b1c4bce5e3d417";
        category = "交通事故图解";
        saveDataByCategory(url,param,category);



        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=a62a5ce6d52f0a579c94c6f5118d888f&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PvU4CQRRGfRDiuxh7X8HSN7CxWbKd6KKJCIHdUGszhc0GDZnJ3uL%2BzliQEKr7HHZSSGP1Nd%2FJyZnA4%2BSh9U8QEtmR7SgfKA4cB1FXQIx7QdRiKLmQia%2Fg6e35dd4eyrtnYCUk8hdAZvMCUvbEmjFGO07h6Hb6VKCkVYWFQtNUFmpqJGgfNVR9nXtN0qP0voDz69vR1c3o4s6%2FYL2Y3bc%2Bhe3mwxlSim1cd6KdGC0TdnklnfA6LhdkS2WPJ9kcspLPQLz5V2Y4MPkWMDGXJONQUk2hFquCiU4D5TKOanQMaHzzB%2BedlAOlAY8wn13%2BfP8CA74P%2FDcBAAA%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=13&patternCode=101&sceneCode=101&score12=0&sign=c2603f106da0ffce1ee7a4ba6ea75705";
        category = "汽车仪表盘指示灯";
        saveDataByCategory(url,param,category);



        param="_appName=jiakaozhushou&_clv=1024&_launch=13&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=a98979b1e0a3353c486549bca886c646&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12Pu0oDURRFrfwFrcXeP7CR4G%2BlOl3Ced7HwAF%2FJclMUIgRomYy041BAlaCcGtTmMZqN3uxWBt%2F27w38OGMzBPUCcYx5kpyxQbmRHnKRBaUOAZUhrk%2FfT%2B%2BrJtx%2BIHoYkiI8OwkohCcwxTFIuWsxwmSQU%2Bfzg2t6yhgadtOS48tFxuylW7o42CJB%2BIBZn5%2FfjO6uB1dXsGnL2er1wa2fth%2FgXhKucnLmq1mxUWiOs65ZlnmxQx1YQL5JFt7NISVM7T%2FypQqQTg4JZGQeFdC6rH0rF1Rtm3BGHbZFI8BLez%2F4DjhMMZU0RGWs7uH619OBpTmNwEAAA%3D%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=14&patternCode=101&sceneCode=101&score12=0&sign=de5db22bdf8ccb0a7422e6068499bc0a";
        category = "车内功能按键";
        saveDataByCategory(url,param,category);



        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=97be2efaf18d5240c0497d0835f28f32&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PvUoDURBGRY35geyym8bARrGLS7AW5FaSNGGKvReG%2Bbl35gHyKpI3s7K1tPEB7E1hGquv%2BQ6Hs8T75V0Fj8jKvFPfad5rHCgObGAoErcsYsWFc1FnmOLly9X1qNqXZ8hIpqIKNyhEDgW5bJUsS4x%2BmkIR%2FPxp0dTaVoqGrms9NNpxsD5aaPsm95a4F%2B5hhm%2FvX8fPn%2BPHNzzhfDa%2BrWCFm%2FUDEKYUqziv2Wp2nSSp85RrpnmczNQnRhDPshFmUxgjQ%2FevzGUghQ1KIiqJF6GkRkPD3gZnWwXNZRHN9RTQwfoPzjsue02DnGC6eD0cfgF5KLykNwEAAA%3D%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=15&patternCode=101&sceneCode=101&score12=0&sign=821aa02650a1a1753090809ef6afa9ae";
        category = "色盲色弱检测";
        saveDataByCategory(url,param,category);



        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=d25392905642ef671e05ef0cfa4fa88a&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PPU4CURRGbe1cBAmhuu9lbnF%2F3ytoJmjotXmaiBCYCUOmEx06GxfgMowbcEXENUghjdXXfCcnZ4%2Bv%2B5cGrlFZdcQ%2B4jThUEmo1MCQKIyVyLKTpsyusMH724enZTPJd5BQjIkZHpFEHDJqHrNYohD8NFkC%2BPnTobF1HWUuw9B56XnQYnWw0tV9qi1qTVrDCn8%2B347fH8evd7jB7Wrx3MAB57MpCMYYmrBt1Vp1Xkdq00ZblW1Yr9jXJhDOsiUmY1igwvCvzKkShjlSFMlRdyXHnkuv3hVXOxROeRfM%2BRQwwOwPTiPNE44VnWC5mF5e%2FQILMXKsNwEAAA%3D%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=16&patternCode=101&sceneCode=101&score12=0&sign=729d4378b124d3361b9606a4e526ea79";
        category = "道路施工安全设施设置示例";
        saveDataByCategory(url,param,category);


        param="_appName=jiakaozhushou&_clv=1024&_launch=11&_manufacturer=Apple&_network=wifi&_operator=T&_pkgName=cn.mucang.ios.jiakaobaodianhuoche&_platform=iphone&_product=%E9%A9%BE%E8%80%83%E5%AE%9D%E5%85%B8%E5%8A%A9%E6%89%8B&_productCategory=jiakaobaodian&_r=d89eb56c197ae4e37f0d6c1499939e68&_renyuan=mucang&_system=iOS&_systemVersion=13.5&_v=H4sIAAAAAAAAE12PvUoDQRRGI8RIkt2Q3TJqFuzWIGkFYRAkIdVlZuHC%2FZ1pfZngm4lvYCn4ANamMI3V13yHw1nhzeq2hnsUEtmR7agcKA2aBnFwZE57YfZsLCWTCczw4nF0NakP%2BQkKqhMTwSWyqkFGyXtSL5ySnSZrAjt%2FGnTypuFMoesaCy11ErxPHpq%2BLb1H6Vl6mOLb%2B9fx8%2Bf48Q0PuJiOr2tY43ZzB4oxpjotKvFKjOaRqzKTSnSR5lOyuSuks2yCxQnGKND9KzMelGCLHFVzlGXIsaXQijXBxNeBSl4mNzoFdLD5g8tO8oHiwCdYRy%2Bvz790g2LmNwEAAA%3D%3D&_vendor=appstore&_version=8.14.0&_webviewVersion=4.7&authToken=d84aa6f07ef5cda9a555e7c44af0f5a9d2328773&bizCode=8.14.0&carType=car&groupId=17&patternCode=101&sceneCode=101&score12=0&sign=d9827c272c5916346a3feb5bc6443b41";
        category = "其他标线";
        saveDataByCategory(url,param,category);

    }

//    @Test
//    public void matchByAnwser() {
//        List<IconQuestion> iconQuestionlist = iIconQuestionService.list(new QueryWrapper<IconQuestion>().isNull("ydt_id"));
//        for (IconQuestion iconQuestion : iconQuestionlist){
//            TQuestion tQuestion = questionService.getOne(new QueryWrapper<TQuestion>().eq("question_id", iconQuestion.getQuestionId()));
//            if (tQuestion == null) continue;
//            List<WebNote> list = webNoteService.list(new QueryWrapper<WebNote>().eq("An1", tQuestion.getOptionA())
//                    .eq("An2", tQuestion.getOptionB()).eq("An3", tQuestion.getOptionC()).eq("An4", tQuestion.getOptionD()));
//            if (!CollectionUtils.isEmpty(list)){
//                if (list.size() ==1){
//                    WebNote webNote = list.get(0);
//                    iconQuestion.setYdtId(webNote.getId());
//                    iconQuestion.setYdtImageUrl(webNote.getMediaUrl());
//                    iIconQuestionService.updateById(iconQuestion);
//                }
//
//            }
//
//        }
//
//
//    }


    public void saveDataByCategory(String url,String param,String category) throws Exception {
        String s = HttpUtils.sendGet(url, param);
        System.out.println(s);
        JSONObject wholeData = JSONObject.parseObject(s);
        JSONObject data = wholeData.getJSONObject("data");
        JSONArray itemList =  data.getJSONArray("itemList");
        if (itemList == null) return ;
        //List<IconInfo> iconInfos = new ArrayList<IconInfo>();
        for (int i=0 ;i <itemList.size();i++){
            JSONObject item = itemList.getJSONObject(i);
            IconInfo iconInfo =  new IconInfo();
            iconInfo.setCategory(category);
            String content = unicodeToCN(item.getString("content"));
            String title = unicodeToCN(item.getString("title"));
            iconInfo.setContent(content);
            iconInfo.setTitle(title);
            iconInfo.setImageurl(item.getString("imageUrl"));
            iIconInfoService.save(iconInfo);
            JSONArray ke1QuestionList = item.getJSONArray("ke1QuestionList");
            if (ke1QuestionList != null){
                for (int j=0 ;j <ke1QuestionList.size();j++){
                    long quetionId =  ke1QuestionList.getLong(j);
                    IconQuestion iconQuestion= new IconQuestion();
                    iconQuestion.setIconId(iconInfo.getId());
                    iconQuestion.setTitle(iconInfo.getTitle());
                    iconQuestion.setQuestionId(quetionId);
                    iconQuestion.setQuestionImageUrl(iIconQuestionService.getImageUrl(quetionId));
                    iIconQuestionService.save(iconQuestion);
                }
            }

        }
    }


    public static String unicodeToCN(String str) {
        Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
        Matcher matcher = pattern.matcher(str);
        char ch;
        while (matcher.find()) {
            ch = (char) Integer.parseInt(matcher.group(2), 16);
            str = str.replace(matcher.group(1), ch + "");
        }
        return str;
    }

























}
