package com.zfire.jiasm.syncdata.download.basedata;

import lombok.extern.slf4j.Slf4j;

/** 线程太多，合并线程
 * 格力品牌用户属性、信息渠道 基础资料下载（用户属性、用户等级、信息渠道、信息来源）
 */
@Slf4j
// @Component
public class GLPPYHSXXXQDbak {
    /*
    @Value("${baseurl}")
    private String baseurl = "";
    @Value("${yhsxc}")
    private String yhsxc = "";
    @Value("${yhdjc}")
    private String yhdjc = "";
    @Value("${xxqdc}")
    private String xxqdc = "";
    @Value("${xxlyc}")
    private String xxlyc = "";


    @Resource
    TokenCenter tokenCenter;
    @Resource
    GLPPYHSXXXQDService glppyhsxxxqdService;


    // 格力品牌用户属性信息同步
    @Scheduled(fixedDelayString = "${yhsx}")
    public void processYHSXTask() throws Exception {


        if (yhsxc.equals(TaskConfigEnum.FALSE.getCode())){
            return;
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Map<String, String> paramMap = new HashMap<String, String>();

        log.info("开始下载格力品牌用户属性信息: \uF0B7{}",sdf.format(new Date()));

        Token token = tokenCenter.getCurrentToken();
        String url = baseurl + InterFaceTypeEnum.GLPP_YHSX.getCode() + "/querylist";
        String paramJson= JSON.toJSONString(paramMap);

        JSONResult jsonResult = HttpUtil.httpRequestWithToken(url, "POST", paramJson, token);
        if (jsonResult.getStatus() == null || !jsonResult.getStatus().toString().equals("200")) {
            log.info("下载格力品牌用户属性信息失败！: {}",jsonResult.getMessage());
            return;
        }

        JSONArray jsonArray = (JSONArray) jsonResult.getData();
        if (jsonArray != null) {
            log.info("下载了{}条数据",jsonArray.size());

            glppyhsxxxqdService.extractedYHSX(jsonArray);

            log.info("格力品牌用户属性信息处理完成: \uF0B7{}",sdf.format(new Date()));
        }else {
            log.info("["+url+"]无数据");
        }
    }

    // 格力品牌用户等级信息同步
    @Scheduled(fixedDelayString = "${yhdj}")
    public void processYHDJTask() throws Exception {


        if (yhdjc.equals(TaskConfigEnum.FALSE.getCode())){
            return;
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Map<String, String> paramMap = new HashMap<String, String>();

        log.info("开始下载格力品牌用户等级信息: \uF0B7{}",sdf.format(new Date()));

        Token token = tokenCenter.getCurrentToken();
        String url = baseurl + InterFaceTypeEnum.GLPP_YHDJ.getCode() + "/querylist";
        String paramJson= JSON.toJSONString(paramMap);

        JSONResult jsonResult = HttpUtil.httpRequestWithToken(url, "POST", paramJson, token);
        if (jsonResult.getStatus() == null || !jsonResult.getStatus().toString().equals("200")) {
            log.info("下载格力品牌用户等级信息失败！: {}",jsonResult.getMessage());
            return;
        }

        JSONArray jsonArray = (JSONArray) jsonResult.getData();
        if (jsonArray != null) {
            log.info("下载了{}条数据",jsonArray.size());

            glppyhsxxxqdService.extractedYHDJ(jsonArray);

            log.info("格力品牌用户等级信息处理完成: \uF0B7{}",sdf.format(new Date()));
        }else {
            log.info("["+url+"]无数据");
        }
    }

    // 格力品牌信息渠道信息同步
    @Scheduled(fixedDelayString = "${xxqd}")
    public void processXXQDTask() throws Exception {


        if (xxqdc.equals(TaskConfigEnum.FALSE.getCode())){
            return;
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Map<String, String> paramMap = new HashMap<String, String>();

        log.info("开始下载格力品牌信息渠道信息: \uF0B7{}",sdf.format(new Date()));

        Token token = tokenCenter.getCurrentToken();
        String url = baseurl + InterFaceTypeEnum.GLPP_XXQD.getCode() + "/querylist";
        String paramJson= JSON.toJSONString(paramMap);

        JSONResult jsonResult = HttpUtil.httpRequestWithToken(url, "POST", paramJson, token);
        if (jsonResult.getStatus() == null || !jsonResult.getStatus().toString().equals("200")) {
            log.info("下载格力品牌信息渠道信息失败！: {}",jsonResult.getMessage());
            return;
        }

        JSONArray jsonArray = (JSONArray) jsonResult.getData();
        if (jsonArray != null) {
            log.info("下载了{}条数据",jsonArray.size());

            glppyhsxxxqdService.extractedXXQD(jsonArray);

            log.info("格力品牌信息渠道信息处理完成: \uF0B7{}",sdf.format(new Date()));
        }else {
            log.info("["+url+"]无数据");
        }
    }

    // 格力品牌信息来源信息同步
    @Scheduled(fixedDelayString = "${xxly}")
    public void processXXLYTask() throws Exception {


        if (xxlyc.equals(TaskConfigEnum.FALSE.getCode())){
            return;
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Map<String, String> paramMap = new HashMap<String, String>();

        log.info("开始下载格力品牌信息来源信息: \uF0B7{}",sdf.format(new Date()));

        Token token = tokenCenter.getCurrentToken();
        String url = baseurl + InterFaceTypeEnum.GLPP_XXLY.getCode() + "/querylist";
        String paramJson= JSON.toJSONString(paramMap);

        JSONResult jsonResult = HttpUtil.httpRequestWithToken(url, "POST", paramJson, token);
        if (jsonResult.getStatus() == null || !jsonResult.getStatus().toString().equals("200")) {
            log.info("下载格力品牌信息来源信息失败！: {}",jsonResult.getMessage());
            return;
        }

        JSONArray jsonArray = (JSONArray) jsonResult.getData();
        if (jsonArray != null) {
            log.info("下载了{}条数据",jsonArray.size());

            glppyhsxxxqdService.extractedXXLY(jsonArray);

            log.info("格力品牌信息来源信息处理完成: \uF0B7{}",sdf.format(new Date()));
        }else {
            log.info("["+url+"]无数据");
        }
    }
*/
}
