package com.dxhy.base.service.sqdktj;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.dxhy.base.dao.BaseTDxDkCountLogDao;
import com.dxhy.base.entity.BaseTDxDkCountLog;
import com.dxhy.common.constant.DbConstant;
import com.dxhy.common.datasource.config.DynamicContextHolder;
import com.dxhy.common.service.impl.MpBaseServiceImpl;
import com.dxhy.common.utils.DateUtils;

/**
 * 撤销抵扣统计service实现类
 *
 * @author kangzq
 * @date 2019年5月11日
 * @version 1.0
 */
@SuppressWarnings("AlibabaClassNamingShouldBeCamel")
@Service("baseTDxDkCountLogService")
public class BaseTDxDkCountLogServiceImpl extends MpBaseServiceImpl<BaseTDxDkCountLogDao, BaseTDxDkCountLog>
    implements BaseTDxDkCountLogService {

    @Override
    public void insertBatch(Map<String, Object> pramsMap) {
        DynamicContextHolder.push(pramsMap.get("dbName") + DbConstant.BUSINESS_WRITE);
        try {

            String[] gfshs = pramsMap.get("gfshs").toString().split(",");
            String[] skssqs = pramsMap.get("skssqs").toString().split(",");
            String czr = pramsMap.get("czr").toString();
            String czlx = pramsMap.get("czlx").toString();
            List<BaseTDxDkCountLog> tDxDkCountLogList = new ArrayList<>();

            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

            for (int i = 0; i < gfshs.length; i++) {
                BaseTDxDkCountLog vo = new BaseTDxDkCountLog();
                vo.setCreateDate(sdf.format(DateUtils.getSqlDateLong()));
                vo.setOperaName(czr);
                vo.setOperaType(czlx);
                vo.setSkssq(skssqs[i]);
                vo.setTaxno(gfshs[i]);
                tDxDkCountLogList.add(vo);
            }

            int batchSize = 1000;
            super.saveBatch(tDxDkCountLogList, batchSize);
            // 统一设置操作成功标识
        } catch (Exception e) {
            // 统一设置操作异常标识
        }
    }

}
