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

import lombok.extern.slf4j.Slf4j;

/** 线程太多，合并线程
 * 格力品牌 需求类别 - 需求类别基础资料下载（需求大类、需求小类）
 */
@Slf4j
// @Component
public class GLPPXuQiuLeiBiebak {
    /*
    @Value("${baseurl}")
    private String baseurl = "";
    @Value("${xqdlc}")
    private String xqdlc = "";
    @Value("${xqxlc}")
    private String xqxlc = "";

    @Resource
    TokenCenter tokenCenter;
    @Resource
    BrandService brandService;
    @Resource
    GLPPXuQiuLeiBieService glppXuQiuLeiBieService;



    // 格力品牌需求大类基础资料信息同步
    @Scheduled(fixedDelayString = "${xqdl}")
    public void processXQDLTask() throws Exception {


        if (xqdlc.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()));

        // 提取品牌信息
        Brand brandRec = brandService.lambdaQuery().eq(Brand::getBrand,"格力").one();
        if (brandRec == null){
            log.info("格力品牌信息不存在【brand】");
            return;
        }

        Token token = tokenCenter.getCurrentToken();
        String url = baseurl + InterFaceTypeEnum.GELI_XQDL.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());

            glppXuQiuLeiBieService.extractedXQDL(brandRec,jsonArray);

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

    // 格力品牌需求小类基础资料信息同步
    @Scheduled(fixedDelayString = "${xqxl}")
    public void processXQXLTask() throws Exception {


        if (xqxlc.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()));

        // 提取品牌信息
        Brand brandRec = brandService.lambdaQuery().eq(Brand::getBrand,"格力").one();
        if (brandRec == null){
            log.info("格力品牌信息不存在【brand】");
            return;
        }

        Token token = tokenCenter.getCurrentToken();
        String url = baseurl + InterFaceTypeEnum.GELI_XQXL.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());

            glppXuQiuLeiBieService.extractedXQXL(brandRec,jsonArray);


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