package com.dxhy.core.job.thread;

import java.util.List;

import com.dxhy.common.constant.DbConstant;
import com.dxhy.common.datasource.config.DynamicContextHolder;
import com.dxhy.common.utils.SpringContextUtils;
import com.dxhy.core.job.entity.TDxHttpLogDataPlatform;
import com.dxhy.core.job.service.DataPlatformCollectService;

/**
 * @author user
 */
@SuppressWarnings("FieldCanBeLocal")
public class DataPlatformInvoiceParseHandle extends Thread {
    private DataPlatformCollectService dataPlatformCollectService;

    private String responseJson;
    private String linkName;
    private TDxHttpLogDataPlatform tDxHttpLog = new TDxHttpLogDataPlatform();
    private final String db;
    private String taxno;

    /**
     * 入参，执行接口方法
     *
     * @param taxno
     *            类型
     * @param db
     *            数据库名
     */
    public DataPlatformInvoiceParseHandle(String taxno, String db) {

        this.taxno = taxno;
        this.db = db;
    }

    @Override
    public void run() {
        dataPlatformCollectService =
            (DataPlatformCollectService)SpringContextUtils.getBean("dataPlatformCollectService");
        DynamicContextHolder.push(db + DbConstant.BUSINESS_READ);
        List<TDxHttpLogDataPlatform> logs = dataPlatformCollectService.getHttpLogsByTaxno(taxno);
        for (TDxHttpLogDataPlatform tDxHttpLog : logs) {
            dataPlatformCollectService.subscribe(tDxHttpLog, db);
        }
    }
}
