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

import lombok.extern.slf4j.Slf4j;

/** 线程太多，合并线程
 * 格力品牌类别系列基础资料下载（大类、小类、系列、机型）
 */
@Slf4j
// @Component
public class GLPPLeiBiebak {
    /*
    @Value("${baseurl}")
    private String baseurl = "";
    @Value("${lbdlc}")
    private String lbdlc = "";
    @Value("${lbxlc}")
    private String lbxlc = "";
    @Value("${lbxltc}")
    private String lbxltc = "";
    @Value("${lbjxc}")
    private String lbjxc = "";

    @Resource
    TokenCenter tokenCenter;
    @Resource
    GLPPLeiBieService glppLeiBieService;


    //格力品牌大类基础资料信息同步
    @Scheduled(fixedDelayString = "${lbdl}")
    public void processDLTask() throws Exception {
        if (lbdlc.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.GELI_DL.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());

            glppLeiBieService.extractedDL(jsonArray);

            log.info("格力大类基础资料信息处理完成: \uF0B7{}",sdf.format(new Date()));
        }else {
            log.info("["+url+"]无数据");
        }
    }

    //格力品牌小类基础资料信息同步
    @Scheduled(fixedDelayString = "${lbxl}")
    public void processXLTask() throws Exception {
        if (lbxlc.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.GELI_XL.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());

            glppLeiBieService.extractedXL(jsonArray);

            log.info("格力小类基础资料信息处理完成: \uF0B7{}",sdf.format(new Date()));
        }else {
            log.info("["+url+"]无数据");
        }
    }

    //格力品牌系列基础资料信息同步
    @Scheduled(fixedDelayString = "${lbxlt}")
    public void processPPXLTask() throws Exception {
        if (lbxltc.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.GELI_PPXL.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());

            glppLeiBieService.extractedXiLie(jsonArray);

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

    //格力品牌机型基础资料信息同步
    @Scheduled(fixedDelayString = "${lbjx}")
    public void processPPJXTask() throws Exception {
        if (lbjxc.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.GELI_PPJX.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());

            glppLeiBieService.extractedJX(jsonArray);

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