package cn.gtmap.estateplat.config.utils;/*
 * @author <a href="mailto:huangzijian@gtmap.cn">huangzijian</a>
 * @version 1.0, 2017/12/23
 * @description  多线程初始化不动产证书或过度证书
 */

import cn.gtmap.estateplat.config.service.ztxx.BdcCxBdcdyZtService;
import cn.gtmap.estateplat.config.service.ztxx.BdcCxZszmZtService;
import cn.gtmap.estateplat.model.server.core.BdcCxZszmZt;
import cn.gtmap.estateplat.model.server.core.BdcZs;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;

public class RuleThread implements Runnable {

    private BdcCxZszmZtService bdcCxZszmZtService;
    private String name;
    private List<Map> gdZsList;
    private List<BdcZs> bdcZsList;
    private List<String> bdcdyhList;
    private String bdclx;
    private BdcCxBdcdyZtService bdcCxBdcdyZtService;
    private List<BdcCxZszmZt> bdcCxZszmZts;

    public List<BdcCxZszmZt> getBdcCxZszmZts() {
        return bdcCxZszmZts;
    }

    public void setBdcCxZszmZts(List<BdcCxZszmZt> bdcCxZszmZts) {
        this.bdcCxZszmZts = bdcCxZszmZts;
    }

    public BdcCxZszmZtService getBdcCxZszmZtService() {
        return bdcCxZszmZtService;
    }

    public void setBdcCxZszmZtService(BdcCxZszmZtService bdcCxZszmZtService) {
        this.bdcCxZszmZtService = bdcCxZszmZtService;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Map> getGdZsList() {
        return gdZsList;
    }

    public void setGdZsList(List<Map> gdZsList) {
        this.gdZsList = gdZsList;
    }

    public List<BdcZs> getBdcZsList() {
        return bdcZsList;
    }

    public void setBdcZsList(List<BdcZs> bdcZsList) {
        this.bdcZsList = bdcZsList;
    }

    public List<String> getBdcdyhList() {
        return bdcdyhList;
    }

    public void setBdcdyhList(List<String> bdcdyhList) {
        this.bdcdyhList = bdcdyhList;
    }

    public BdcCxBdcdyZtService getBdcCxBdcdyZtService() {
        return bdcCxBdcdyZtService;
    }

    public void setBdcCxBdcdyZtService(BdcCxBdcdyZtService bdcCxBdcdyZtService) {
        this.bdcCxBdcdyZtService = bdcCxBdcdyZtService;
    }

    public String getBdclx() {
        return bdclx;
    }

    public void setBdclx(String bdclx) {
        this.bdclx = bdclx;
    }

    @Override
    public void run() {
        System.out.println("进入线程======" + name);
        excute();
        System.out.println("结束线程====" + name);
    }

    private void excute() {
        if (null != bdcZsList && CollectionUtils.isNotEmpty(bdcZsList)) {
            bdcCxZszmZtService.initBdcZs(bdcZsList);
        } else if (null != gdZsList && CollectionUtils.isNotEmpty(gdZsList)) {
            bdcCxZszmZtService.initGdZs(gdZsList);
        }else  if(null != bdcCxZszmZts && CollectionUtils.isNotEmpty(bdcCxZszmZts)){
            if (CollectionUtils.isNotEmpty(bdcCxZszmZts)) {
                for (BdcCxZszmZt bdcCxZszmZt : bdcCxZszmZts) {
                    if (StringUtils.isNotBlank(bdcCxZszmZt.getCqzh()) && StringUtils.isNotBlank(bdcCxZszmZt.getSjly())) {
                        bdcCxZszmZtService.updateZszmZtByCqzh(bdcCxZszmZt);
                    }
                }
            }
        }
        else if(null !=bdcdyhList && CollectionUtils.isNotEmpty(bdcdyhList)){
            bdcCxBdcdyZtService.updateBdcdyZtByBdcdyh(bdcdyhList,bdclx);
        }

    }
}
