package com.dgtly.sync.service;

import com.dgtly.system.service.IAssRelcustomerinfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.ParseException;

/**
 * @description: 关联经销商上线
 * @author: qxm
 * @date: 2021/10/13 16:03
 */
@Component
public class RelationCustomerOnlineComponent {

    private static final Logger log = LoggerFactory.getLogger(RelationCustomerOnlineComponent.class);

    @Autowired
    private IAssRelcustomerinfoService assRelcustomerinfoService;

    /**关联经销商上线*/
    public void relationCustomerOnlineSync() throws ParseException {
        Long startTime = System.currentTimeMillis();
        assRelcustomerinfoService.relationCustomerOnlineSync();
        Long endTime = System.currentTimeMillis();
        log.info("关联经销商上线用时：" + (endTime - startTime)+"毫秒");
    }

    /*SELECT s.mainkunnr,s.mainname1 from (SELECT
        ar.*
    FROM
        customers_start cs
    LEFT JOIN ass_relcustomerinfo ar ON (cs.customers_code=ar.kunnr or cs.customers_code=ar.mainkunnr)
    WHERE  ar.glfs != '开票方关联'
    GROUP BY kunnr) s LEFT JOIN customers_start c ON s.mainkunnr = c.customers_code
    WHERE c.customers_code is null

    union all

    SELECT s.kunnr,s.name1 from (SELECT
        ar.*
    FROM
        customers_start cs
    LEFT JOIN ass_relcustomerinfo ar ON (cs.customers_code=ar.kunnr or cs.customers_code=ar.mainkunnr)
    WHERE  ar.glfs != '开票方关联'
    GROUP BY kunnr) s LEFT JOIN customers_start c ON s.kunnr = c.customers_code
    WHERE c.customers_code is null

*/

}
