package com.dxhy.base.service.sqdktj;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dxhy.base.dao.BaseTDxDkCountDetailDao;
import com.dxhy.base.entity.BaseTDxDkCountDetail;
import com.dxhy.base.model.BaseTDxDkCountDetailRespVO;
import com.dxhy.common.constant.DbConstant;
import com.dxhy.common.datasource.config.DynamicContextHolder;
import com.dxhy.common.enums.DktjmxzjEnum;
import com.dxhy.common.enums.FplxEnum;
import com.dxhy.common.service.impl.MpBaseServiceImpl;
import com.dxhy.common.util.AmountFormatUtil;
import com.dxhy.common.util.MathUtil;
import com.dxhy.common.util.StringHelper;
import com.dxhy.common.vo.Tax;

/**
 * 抵扣统计明细service实现类
 *
 * @author kangzq
 * @date 2019年5月11日
 * @version 1.0
 */

@SuppressWarnings({"AlibabaLowerCamelCaseVariableNaming", "AlibabaUndefineMagicConstant", "AlibabaMethodTooLong",
    "AlibabaClassNamingShouldBeCamel"})
@Service("baseDktjService")
public class BaseDKtjServiceImpl extends MpBaseServiceImpl<BaseTDxDkCountDetailDao, BaseTDxDkCountDetail>
    implements BaseDktjService {

    @Override
    public String selectByGfsbhAndSkssq(Map<String, Object> pramsMap) {
        JSONObject json;
        DynamicContextHolder.push(pramsMap.get("dbName") + DbConstant.BUSINESS_READ);

        try {

            String[] titlelist =
                {"序号", "购方税号", "所属月份", "发票类型", "抵扣发票份数", "抵扣总金额", "抵扣总有效税额", "不抵扣发票份数", "不抵扣总金额", "不抵扣总有效税额"};
            String[] titleprop = {"xh", "taxno", "skssq", "invoiceType", "dkInvoiceCount", "dkAmountCount",
                "dkTaxAmountCount", "bdkInvoiceCount", "bdkAmountCount", "bdkTaxAmountCount"};

            // 需要设置返回列表标题时调用
            json = super.setTitleList(titlelist, titleprop);
            List<Tax> taxList = (List<Tax>)pramsMap.get("taxList");
            String gfsh = (String)pramsMap.get("gfsh");
            QueryWrapper<BaseTDxDkCountDetail> queryWrapper = new QueryWrapper<>();
            if (pramsMap.containsKey("gfsh") && !StringHelper.isBlank(String.valueOf(pramsMap.get("gfsh")))) {
                queryWrapper.eq("taxno", pramsMap.get("gfsh"));
            }
            if (pramsMap.containsKey("skssq") && !StringHelper.isBlank(String.valueOf(pramsMap.get("skssq")))) {
                queryWrapper.eq("tj_month", pramsMap.get("skssq"));
            }
            queryWrapper.orderByAsc("invoice_type");
            String skssq = pramsMap.get("skssq").toString().substring(0, 4) + "年"
                + pramsMap.get("skssq").toString().substring(4, 6) + "月";
            json.put("skssq", skssq);

            List<BaseTDxDkCountDetail> dkList = list(queryWrapper);
            // 页面展示对象
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
            SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒");
            StringBuilder sb = new StringBuilder();
            String tjdate = "";
            String tjmonth = "";
            String taxName = "";
            for (BaseTDxDkCountDetail baseTDxDkCountDetail : dkList) {
                sb.append(baseTDxDkCountDetail.getInvoiceType());
                String tjDate = baseTDxDkCountDetail.getTjDate();
                Date date = sdf.parse(tjDate);
                tjdate = sdf1.format(date);
                tjmonth = baseTDxDkCountDetail.getTjMonth();
                for (Tax t : taxList) {
                    String taxno = t.getTaxno();
                    if (gfsh.equals(taxno)) {
                        taxName = t.getTaxname();
                    }
                }
            }
            List<BaseTDxDkCountDetailRespVO> list = new ArrayList<>();
            if (sb.indexOf("01") < 0) {
                BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                td.setBdkAmountCount("0.00");
                td.setBdkInvoiceCount("0");
                td.setBdkTaxAmountCount("0.00");
                td.setDkAmountCount("0.00");
                td.setDkInvoiceCount("0");
                td.setDkTaxAmountCount("0.00");
                td.setTaxno((String)pramsMap.get("gfsh"));
                td.setTjDate(tjdate);
                td.setTjMonth(tjmonth);
                td.setTaxName(taxName);
                td.setInvoiceType("增值税专用发票");
                list.add(td);
            } else {
                for (BaseTDxDkCountDetail baseTDxDkCountDetail : dkList) {
                    if ("01".equals(baseTDxDkCountDetail.getInvoiceType())) {
                        BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                        sb.append(baseTDxDkCountDetail.getInvoiceType());
                        String bdkAmountCount;
                        try {
                            bdkAmountCount = baseTDxDkCountDetail.getBdkAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkAmountCount);
                            bdkAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkAmountCount = "-";
                        }
                        td.setBdkAmountCount(bdkAmountCount);
                        String bdkInvoiceCount;
                        try {
                            bdkInvoiceCount = baseTDxDkCountDetail.getBdkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(bdkInvoiceCount);
                            bdkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            bdkInvoiceCount = "-";
                        }
                        td.setBdkInvoiceCount(bdkInvoiceCount);
                        String bdkTaxAmountCount;
                        try {
                            bdkTaxAmountCount = baseTDxDkCountDetail.getBdkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkTaxAmountCount);
                            bdkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkTaxAmountCount = "-";
                        }
                        td.setBdkTaxAmountCount(bdkTaxAmountCount);
                        String dkAmountCount;
                        try {
                            dkAmountCount = baseTDxDkCountDetail.getDkAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkAmountCount);
                            dkAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkAmountCount = "-";
                        }
                        td.setDkAmountCount(dkAmountCount);
                        String dkInvoiceCount;
                        try {
                            dkInvoiceCount = baseTDxDkCountDetail.getDkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(dkInvoiceCount);
                            dkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            dkInvoiceCount = "-";
                        }
                        td.setDkInvoiceCount(dkInvoiceCount);
                        String dkTaxAmountCount;
                        try {
                            dkTaxAmountCount = baseTDxDkCountDetail.getDkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkTaxAmountCount);
                            dkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkTaxAmountCount = "-";
                        }
                        td.setDkTaxAmountCount(dkTaxAmountCount);
                        td.setTaxno(baseTDxDkCountDetail.getTaxno());
                        String tjDate = baseTDxDkCountDetail.getTjDate();
                        Date date = sdf.parse(tjDate);
                        td.setTjDate(sdf1.format(date));
                        tjdate = sdf1.format(date);
                        td.setTjMonth(baseTDxDkCountDetail.getTjMonth());
                        tjmonth = baseTDxDkCountDetail.getTjMonth();
                        for (Tax t : taxList) {
                            String taxno = t.getTaxno();
                            if (td.getTaxno().equals(taxno)) {
                                td.setTaxName(t.getTaxname());
                                taxName = t.getTaxname();
                            }
                        }
                        if (baseTDxDkCountDetail.getInvoiceType().equals(DktjmxzjEnum.ZJ.getDktjmxzjDm())) {
                            td.setInvoiceType(DktjmxzjEnum.ZJ.getDktjmxzjMc(DktjmxzjEnum.ZJ.getIndex()));
                        } else {
                            for (FplxEnum e : FplxEnum.values()) {
                                if (e.getFplxDm().equals(baseTDxDkCountDetail.getInvoiceType())) {
                                    td.setInvoiceType(e.getFplxMc(e.getIndex()));
                                }
                            }
                        }
                        list.add(td);
                    }
                }
            }
            if (sb.indexOf("03") < 0) {
                BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                td.setBdkAmountCount("0.00");
                td.setBdkInvoiceCount("0");
                td.setBdkTaxAmountCount("0.00");
                td.setDkAmountCount("0.00");
                td.setDkInvoiceCount("0");
                td.setDkTaxAmountCount("0.00");
                td.setTaxno((String)pramsMap.get("gfsh"));
                td.setTjDate(tjdate);
                td.setTjMonth(tjmonth);
                td.setTaxName(taxName);
                td.setInvoiceType("机动车销售统一发票");
                list.add(td);
            } else {
                for (BaseTDxDkCountDetail baseTDxDkCountDetail : dkList) {
                    if ("03".equals(baseTDxDkCountDetail.getInvoiceType())) {
                        BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                        sb.append(baseTDxDkCountDetail.getInvoiceType());
                        String bdkAmountCount;
                        try {
                            bdkAmountCount = baseTDxDkCountDetail.getBdkAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkAmountCount);
                            bdkAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkAmountCount = "-";
                        }
                        td.setBdkAmountCount(bdkAmountCount);
                        String bdkInvoiceCount;
                        try {
                            bdkInvoiceCount = baseTDxDkCountDetail.getBdkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(bdkInvoiceCount);
                            bdkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            bdkInvoiceCount = "-";
                        }
                        td.setBdkInvoiceCount(bdkInvoiceCount);
                        String bdkTaxAmountCount;
                        try {
                            bdkTaxAmountCount = baseTDxDkCountDetail.getBdkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkTaxAmountCount);
                            bdkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkTaxAmountCount = "-";
                        }
                        td.setBdkTaxAmountCount(bdkTaxAmountCount);
                        String dkAmountCount;
                        try {
                            dkAmountCount = baseTDxDkCountDetail.getDkAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkAmountCount);
                            dkAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkAmountCount = "-";
                        }
                        td.setDkAmountCount(dkAmountCount);
                        String dkInvoiceCount;
                        try {
                            dkInvoiceCount = baseTDxDkCountDetail.getDkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(dkInvoiceCount);
                            dkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            dkInvoiceCount = "-";
                        }
                        td.setDkInvoiceCount(dkInvoiceCount);
                        String dkTaxAmountCount;
                        try {
                            dkTaxAmountCount = baseTDxDkCountDetail.getDkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkTaxAmountCount);
                            dkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkTaxAmountCount = "-";
                        }
                        td.setDkTaxAmountCount(dkTaxAmountCount);
                        td.setTaxno(baseTDxDkCountDetail.getTaxno());
                        String tjDate = baseTDxDkCountDetail.getTjDate();
                        Date date = sdf.parse(tjDate);
                        td.setTjDate(sdf1.format(date));
                        tjdate = sdf1.format(date);
                        td.setTjMonth(baseTDxDkCountDetail.getTjMonth());
                        tjmonth = baseTDxDkCountDetail.getTjMonth();
                        for (Tax t : taxList) {
                            String taxno = t.getTaxno();
                            if (td.getTaxno().equals(taxno)) {
                                td.setTaxName(t.getTaxname());
                                taxName = t.getTaxname();
                            }
                        }
                        if (baseTDxDkCountDetail.getInvoiceType().equals(DktjmxzjEnum.ZJ.getDktjmxzjDm())) {
                            td.setInvoiceType(DktjmxzjEnum.ZJ.getDktjmxzjMc(DktjmxzjEnum.ZJ.getIndex()));
                        } else {
                            for (FplxEnum e : FplxEnum.values()) {
                                if (e.getFplxDm().equals(baseTDxDkCountDetail.getInvoiceType())) {
                                    td.setInvoiceType(e.getFplxMc(e.getIndex()));
                                }
                            }
                        }
                        list.add(td);
                    }
                }
            }

            if (sb.indexOf("08") < 0) {
                BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                td.setBdkAmountCount("0.00");
                td.setBdkInvoiceCount("0");
                td.setBdkTaxAmountCount("0.00");
                td.setDkAmountCount("0.00");
                td.setDkInvoiceCount("0");
                td.setDkTaxAmountCount("0.00");
                td.setTaxno((String)pramsMap.get("gfsh"));
                td.setTjDate(tjdate);
                td.setTjMonth(tjmonth);
                td.setTaxName(taxName);
                td.setInvoiceType("增值税电子专用发票");
                list.add(td);
            } else {
                for (BaseTDxDkCountDetail baseTDxDkCountDetail : dkList) {
                    if ("08".equals(baseTDxDkCountDetail.getInvoiceType())) {
                        BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                        sb.append(baseTDxDkCountDetail.getInvoiceType());
                        String bdkAmountCount;
                        try {
                            bdkAmountCount = baseTDxDkCountDetail.getBdkAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkAmountCount);
                            bdkAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkAmountCount = "-";
                        }
                        td.setBdkAmountCount(bdkAmountCount);
                        String bdkInvoiceCount;
                        try {
                            bdkInvoiceCount = baseTDxDkCountDetail.getBdkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(bdkInvoiceCount);
                            bdkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            bdkInvoiceCount = "-";
                        }
                        td.setBdkInvoiceCount(bdkInvoiceCount);
                        String bdkTaxAmountCount;
                        try {
                            bdkTaxAmountCount = baseTDxDkCountDetail.getBdkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkTaxAmountCount);
                            bdkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkTaxAmountCount = "-";
                        }
                        td.setBdkTaxAmountCount(bdkTaxAmountCount);
                        String dkAmountCount;
                        try {
                            dkAmountCount = baseTDxDkCountDetail.getDkAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkAmountCount);
                            dkAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkAmountCount = "-";
                        }
                        td.setDkAmountCount(dkAmountCount);
                        String dkInvoiceCount;
                        try {
                            dkInvoiceCount = baseTDxDkCountDetail.getDkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(dkInvoiceCount);
                            dkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            dkInvoiceCount = "-";
                        }
                        td.setDkInvoiceCount(dkInvoiceCount);
                        String dkTaxAmountCount;
                        try {
                            dkTaxAmountCount = baseTDxDkCountDetail.getDkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkTaxAmountCount);
                            dkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkTaxAmountCount = "-";
                        }
                        td.setDkTaxAmountCount(dkTaxAmountCount);
                        td.setTaxno(baseTDxDkCountDetail.getTaxno());
                        String tjDate = baseTDxDkCountDetail.getTjDate();
                        Date date = sdf.parse(tjDate);
                        td.setTjDate(sdf1.format(date));
                        tjdate = sdf1.format(date);
                        td.setTjMonth(baseTDxDkCountDetail.getTjMonth());
                        tjmonth = baseTDxDkCountDetail.getTjMonth();
                        for (Tax t : taxList) {
                            String taxno = t.getTaxno();
                            if (td.getTaxno().equals(taxno)) {
                                td.setTaxName(t.getTaxname());
                                taxName = t.getTaxname();
                            }
                        }
                        if (baseTDxDkCountDetail.getInvoiceType().equals(DktjmxzjEnum.ZJ.getDktjmxzjDm())) {
                            td.setInvoiceType(DktjmxzjEnum.ZJ.getDktjmxzjMc(DktjmxzjEnum.ZJ.getIndex()));
                        } else {
                            td.setInvoiceType("增值税电子专用发票");

                        }
                        list.add(td);
                    }
                }
            }
//            if (sb.indexOf("31") < 0) {
//                BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
//                td.setBdkAmountCount("0.00");
//                td.setBdkInvoiceCount("0");
//                td.setBdkTaxAmountCount("0.00");
//                td.setDkAmountCount("0.00");
//                td.setDkInvoiceCount("0");
//                td.setDkTaxAmountCount("0.00");
//                td.setTaxno((String)pramsMap.get("gfsh"));
//                td.setTjDate(tjdate);
//                td.setTjMonth(tjmonth);
//                td.setTaxName(taxName);
//                td.setInvoiceType("电子发票（增值税专用发票）");
//                list.add(td);
//            } else {
//                for (BaseTDxDkCountDetail baseTDxDkCountDetail : dkList) {
//                    if ("31".equals(baseTDxDkCountDetail.getInvoiceType())) {
//                        BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
//                        sb.append(baseTDxDkCountDetail.getInvoiceType());
//                        String bdkAmountCount;
//                        try {
//                            bdkAmountCount = baseTDxDkCountDetail.getBdkAmountCount();
//                            BigDecimal amountCount = new BigDecimal(bdkAmountCount);
//                            bdkAmountCount =
//                                    AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
//                        } catch (Exception e) {
//                            bdkAmountCount = "-";
//                        }
//                        td.setBdkAmountCount(bdkAmountCount);
//                        String bdkInvoiceCount;
//                        try {
//                            bdkInvoiceCount = baseTDxDkCountDetail.getBdkInvoiceCount();
//                            BigDecimal amountCount = new BigDecimal(bdkInvoiceCount);
//                            bdkInvoiceCount =
//                                    AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
//                        } catch (Exception e) {
//                            bdkInvoiceCount = "-";
//                        }
//                        td.setBdkInvoiceCount(bdkInvoiceCount);
//                        String bdkTaxAmountCount;
//                        try {
//                            bdkTaxAmountCount = baseTDxDkCountDetail.getBdkTaxAmountCount();
//                            BigDecimal amountCount = new BigDecimal(bdkTaxAmountCount);
//                            bdkTaxAmountCount =
//                                    AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
//                        } catch (Exception e) {
//                            bdkTaxAmountCount = "-";
//                        }
//                        td.setBdkTaxAmountCount(bdkTaxAmountCount);
//                        String dkAmountCount;
//                        try {
//                            dkAmountCount = baseTDxDkCountDetail.getDkAmountCount();
//                            BigDecimal amountCount = new BigDecimal(dkAmountCount);
//                            dkAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
//                        } catch (Exception e) {
//                            dkAmountCount = "-";
//                        }
//                        td.setDkAmountCount(dkAmountCount);
//                        String dkInvoiceCount;
//                        try {
//                            dkInvoiceCount = baseTDxDkCountDetail.getDkInvoiceCount();
//                            BigDecimal amountCount = new BigDecimal(dkInvoiceCount);
//                            dkInvoiceCount =
//                                    AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
//                        } catch (Exception e) {
//                            dkInvoiceCount = "-";
//                        }
//                        td.setDkInvoiceCount(dkInvoiceCount);
//                        String dkTaxAmountCount;
//                        try {
//                            dkTaxAmountCount = baseTDxDkCountDetail.getDkTaxAmountCount();
//                            BigDecimal amountCount = new BigDecimal(dkTaxAmountCount);
//                            dkTaxAmountCount =
//                                    AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
//                        } catch (Exception e) {
//                            dkTaxAmountCount = "-";
//                        }
//                        td.setDkTaxAmountCount(dkTaxAmountCount);
//                        td.setTaxno(baseTDxDkCountDetail.getTaxno());
//                        String tjDate = baseTDxDkCountDetail.getTjDate();
//                        Date date = sdf.parse(tjDate);
//                        td.setTjDate(sdf1.format(date));
//                        tjdate = sdf1.format(date);
//                        td.setTjMonth(baseTDxDkCountDetail.getTjMonth());
//                        tjmonth = baseTDxDkCountDetail.getTjMonth();
//                        for (Tax t : taxList) {
//                            String taxno = t.getTaxno();
//                            if (td.getTaxno().equals(taxno)) {
//                                td.setTaxName(t.getTaxname());
//                                taxName = t.getTaxname();
//                            }
//                        }
//                        if (baseTDxDkCountDetail.getInvoiceType().equals(DktjmxzjEnum.ZJ.getDktjmxzjDm())) {
//                            td.setInvoiceType(DktjmxzjEnum.ZJ.getDktjmxzjMc(DktjmxzjEnum.ZJ.getIndex()));
//                        } else {
//                            td.setInvoiceType("电子发票（增值税专用发票）");
//
//                        }
//                        list.add(td);
//                    }
//                }
//            }
            if (sb.indexOf("14") < 0) {
                BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                td.setBdkAmountCount("0.00");
                td.setBdkInvoiceCount("0");
                td.setBdkTaxAmountCount("0.00");
                td.setDkAmountCount("0.00");
                td.setDkInvoiceCount("0");
                td.setDkTaxAmountCount("0.00");
                td.setTaxno((String)pramsMap.get("gfsh"));
                td.setTjDate(tjdate);
                td.setTjMonth(tjmonth);
                td.setTaxName(taxName);
                td.setInvoiceType("通行费电子发票");
                list.add(td);
            } else {
                for (BaseTDxDkCountDetail baseTDxDkCountDetail : dkList) {
                    if ("14".equals(baseTDxDkCountDetail.getInvoiceType())) {
                        BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                        sb.append(baseTDxDkCountDetail.getInvoiceType());
                        String bdkAmountCount;
                        try {
                            bdkAmountCount = baseTDxDkCountDetail.getBdkAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkAmountCount);
                            bdkAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkAmountCount = "-";
                        }
                        td.setBdkAmountCount(bdkAmountCount);
                        String bdkInvoiceCount;
                        try {
                            bdkInvoiceCount = baseTDxDkCountDetail.getBdkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(bdkInvoiceCount);
                            bdkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            bdkInvoiceCount = "-";
                        }
                        td.setBdkInvoiceCount(bdkInvoiceCount);
                        String bdkTaxAmountCount;
                        try {
                            bdkTaxAmountCount = baseTDxDkCountDetail.getBdkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkTaxAmountCount);
                            bdkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkTaxAmountCount = "-";
                        }
                        td.setBdkTaxAmountCount(bdkTaxAmountCount);
                        String dkAmountCount;
                        try {
                            dkAmountCount = baseTDxDkCountDetail.getDkAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkAmountCount);
                            dkAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkAmountCount = "-";
                        }
                        td.setDkAmountCount(dkAmountCount);
                        String dkInvoiceCount;
                        try {
                            dkInvoiceCount = baseTDxDkCountDetail.getDkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(dkInvoiceCount);
                            dkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            dkInvoiceCount = "-";
                        }
                        td.setDkInvoiceCount(dkInvoiceCount);
                        String dkTaxAmountCount;
                        try {
                            dkTaxAmountCount = baseTDxDkCountDetail.getDkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkTaxAmountCount);
                            dkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkTaxAmountCount = "-";
                        }
                        td.setDkTaxAmountCount(dkTaxAmountCount);
                        td.setTaxno(baseTDxDkCountDetail.getTaxno());
                        String tjDate = baseTDxDkCountDetail.getTjDate();
                        Date date = sdf.parse(tjDate);
                        td.setTjDate(sdf1.format(date));
                        tjdate = sdf1.format(date);
                        td.setTjMonth(baseTDxDkCountDetail.getTjMonth());
                        tjmonth = baseTDxDkCountDetail.getTjMonth();
                        for (Tax t : taxList) {
                            String taxno = t.getTaxno();
                            if (td.getTaxno().equals(taxno)) {
                                td.setTaxName(t.getTaxname());
                                taxName = t.getTaxname();
                            }
                        }
                        if (baseTDxDkCountDetail.getInvoiceType().equals(DktjmxzjEnum.ZJ.getDktjmxzjDm())) {
                            td.setInvoiceType(DktjmxzjEnum.ZJ.getDktjmxzjMc(DktjmxzjEnum.ZJ.getIndex()));
                        } else {
                            td.setInvoiceType("通行费电子发票");

                        }
                        list.add(td);
                    }
                }
            }
            if (sb.indexOf("17") < 0) {
                BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                td.setBdkAmountCount("-");
                td.setBdkInvoiceCount("0");
                td.setBdkTaxAmountCount("0.00");
                td.setDkAmountCount("-");
                td.setDkInvoiceCount("0");
                td.setDkTaxAmountCount("0.00");
                td.setTaxno((String)pramsMap.get("gfsh"));
                td.setTjDate(tjdate);
                td.setTjMonth(tjmonth);
                td.setTaxName(taxName);
                td.setInvoiceType("海关缴款书");
                list.add(td);
            } else {
                for (BaseTDxDkCountDetail baseTDxDkCountDetail : dkList) {
                    if ("17".equals(baseTDxDkCountDetail.getInvoiceType())) {
                        BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                        sb.append(baseTDxDkCountDetail.getInvoiceType());
                        String bdkAmountCount;
                        try {
                            bdkAmountCount = baseTDxDkCountDetail.getBdkAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkAmountCount);
                            bdkAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkAmountCount = "-";
                        }
                        td.setBdkAmountCount(bdkAmountCount);
                        String bdkInvoiceCount;
                        try {
                            bdkInvoiceCount = baseTDxDkCountDetail.getBdkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(bdkInvoiceCount);
                            bdkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            bdkInvoiceCount = "-";
                        }
                        td.setBdkInvoiceCount(bdkInvoiceCount);
                        String bdkTaxAmountCount;
                        try {
                            bdkTaxAmountCount = baseTDxDkCountDetail.getBdkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkTaxAmountCount);
                            bdkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkTaxAmountCount = "-";
                        }
                        td.setBdkTaxAmountCount(bdkTaxAmountCount);
                        String dkAmountCount;
                        try {
                            dkAmountCount = baseTDxDkCountDetail.getDkAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkAmountCount);
                            dkAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkAmountCount = "-";
                        }
                        td.setDkAmountCount(dkAmountCount);
                        String dkInvoiceCount;
                        try {
                            dkInvoiceCount = baseTDxDkCountDetail.getDkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(dkInvoiceCount);
                            dkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            dkInvoiceCount = "-";
                        }
                        td.setDkInvoiceCount(dkInvoiceCount);
                        String dkTaxAmountCount;
                        try {
                            dkTaxAmountCount = baseTDxDkCountDetail.getDkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkTaxAmountCount);
                            dkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkTaxAmountCount = "-";
                        }
                        td.setDkTaxAmountCount(dkTaxAmountCount);
                        td.setTaxno(baseTDxDkCountDetail.getTaxno());
                        String tjDate = baseTDxDkCountDetail.getTjDate();
                        Date date = sdf.parse(tjDate);
                        td.setTjDate(sdf1.format(date));
                        tjdate = sdf1.format(date);
                        td.setTjMonth(baseTDxDkCountDetail.getTjMonth());
                        tjmonth = baseTDxDkCountDetail.getTjMonth();
                        for (Tax t : taxList) {
                            String taxno = t.getTaxno();
                            if (td.getTaxno().equals(taxno)) {
                                td.setTaxName(t.getTaxname());
                                taxName = t.getTaxname();
                            }
                        }
                        td.setInvoiceType("海关缴款书");
                        list.add(td);
                    }
                }
            }
            if (sb.indexOf("24") < 0) {
                BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                td.setBdkAmountCount("0.00");
                td.setBdkInvoiceCount("0");
                td.setBdkTaxAmountCount("0.00");
                td.setDkAmountCount("0.00");
                td.setDkInvoiceCount("0");
                td.setDkTaxAmountCount("0.00");
                td.setTaxno((String)pramsMap.get("gfsh"));
                td.setTjDate(tjdate);
                td.setTjMonth(tjmonth);
                td.setTaxName(taxName);
                td.setInvoiceType("出口转内销发票");
                list.add(td);
            } else {
                for (BaseTDxDkCountDetail baseTDxDkCountDetail : dkList) {
                    if ("24".equals(baseTDxDkCountDetail.getInvoiceType())) {
                        BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                        sb.append(baseTDxDkCountDetail.getInvoiceType());
                        String bdkAmountCount;
                        try {
                            bdkAmountCount = baseTDxDkCountDetail.getBdkAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkAmountCount);
                            bdkAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkAmountCount = "-";
                        }
                        td.setBdkAmountCount(bdkAmountCount);
                        String bdkInvoiceCount;
                        try {
                            bdkInvoiceCount = baseTDxDkCountDetail.getBdkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(bdkInvoiceCount);
                            bdkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            bdkInvoiceCount = "-";
                        }
                        td.setBdkInvoiceCount(bdkInvoiceCount);
                        String bdkTaxAmountCount;
                        try {
                            bdkTaxAmountCount = baseTDxDkCountDetail.getBdkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkTaxAmountCount);
                            bdkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkTaxAmountCount = "-";
                        }
                        td.setBdkTaxAmountCount(bdkTaxAmountCount);
                        String dkAmountCount;
                        try {
                            dkAmountCount = baseTDxDkCountDetail.getDkAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkAmountCount);
                            dkAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkAmountCount = "-";
                        }
                        td.setDkAmountCount(dkAmountCount);
                        String dkInvoiceCount;
                        try {
                            dkInvoiceCount = baseTDxDkCountDetail.getDkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(dkInvoiceCount);
                            dkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            dkInvoiceCount = "-";
                        }
                        td.setDkInvoiceCount(dkInvoiceCount);
                        String dkTaxAmountCount;
                        try {
                            dkTaxAmountCount = baseTDxDkCountDetail.getDkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkTaxAmountCount);
                            dkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkTaxAmountCount = "-";
                        }
                        td.setDkTaxAmountCount(dkTaxAmountCount);
                        td.setTaxno(baseTDxDkCountDetail.getTaxno());
                        String tjDate = baseTDxDkCountDetail.getTjDate();
                        Date date = sdf.parse(tjDate);
                        td.setTjDate(sdf1.format(date));
                        tjdate = sdf1.format(date);
                        td.setTjMonth(baseTDxDkCountDetail.getTjMonth());
                        tjmonth = baseTDxDkCountDetail.getTjMonth();
                        for (Tax t : taxList) {
                            String taxno = t.getTaxno();
                            if (td.getTaxno().equals(taxno)) {
                                td.setTaxName(t.getTaxname());
                                taxName = t.getTaxname();
                            }
                        }
                        td.setInvoiceType("出口转内销发票");
                        list.add(td);
                    }
                }
            }
            if (sb.indexOf("30") < 0) {
                BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                td.setBdkAmountCount("-");
                td.setBdkInvoiceCount("0");
                td.setBdkTaxAmountCount("0.00");
                td.setDkAmountCount("-");
                td.setDkInvoiceCount("0");
                td.setDkTaxAmountCount("0.00");
                td.setTaxno((String)pramsMap.get("gfsh"));
                td.setTjDate(tjdate);
                td.setTjMonth(tjmonth);
                td.setTaxName(taxName);
                td.setInvoiceType("出口转内销海关缴款书");
                list.add(td);
            } else {
                for (BaseTDxDkCountDetail baseTDxDkCountDetail : dkList) {
                    if ("30".equals(baseTDxDkCountDetail.getInvoiceType())) {
                        BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                        sb.append(baseTDxDkCountDetail.getInvoiceType());
                        String bdkAmountCount;
                        try {
                            bdkAmountCount = baseTDxDkCountDetail.getBdkAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkAmountCount);
                            bdkAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkAmountCount = "-";
                        }
                        td.setBdkAmountCount(bdkAmountCount);
                        String bdkInvoiceCount;
                        try {
                            bdkInvoiceCount = baseTDxDkCountDetail.getBdkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(bdkInvoiceCount);
                            bdkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            bdkInvoiceCount = "-";
                        }
                        td.setBdkInvoiceCount(bdkInvoiceCount);
                        String bdkTaxAmountCount;
                        try {
                            bdkTaxAmountCount = baseTDxDkCountDetail.getBdkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkTaxAmountCount);
                            bdkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkTaxAmountCount = "-";
                        }
                        td.setBdkTaxAmountCount(bdkTaxAmountCount);
                        String dkAmountCount;
                        try {
                            dkAmountCount = baseTDxDkCountDetail.getDkAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkAmountCount);
                            dkAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkAmountCount = "-";
                        }
                        td.setDkAmountCount(dkAmountCount);
                        String dkInvoiceCount;
                        try {
                            dkInvoiceCount = baseTDxDkCountDetail.getDkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(dkInvoiceCount);
                            dkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            dkInvoiceCount = "-";
                        }
                        td.setDkInvoiceCount(dkInvoiceCount);
                        String dkTaxAmountCount;
                        try {
                            dkTaxAmountCount = baseTDxDkCountDetail.getDkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkTaxAmountCount);
                            dkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkTaxAmountCount = "-";
                        }
                        td.setDkTaxAmountCount(dkTaxAmountCount);
                        td.setTaxno(baseTDxDkCountDetail.getTaxno());
                        String tjDate = baseTDxDkCountDetail.getTjDate();
                        Date date = sdf.parse(tjDate);
                        td.setTjDate(sdf1.format(date));
                        tjdate = sdf1.format(date);
                        td.setTjMonth(baseTDxDkCountDetail.getTjMonth());
                        tjmonth = baseTDxDkCountDetail.getTjMonth();
                        for (Tax t : taxList) {
                            String taxno = t.getTaxno();
                            if (td.getTaxno().equals(taxno)) {
                                td.setTaxName(t.getTaxname());
                                taxName = t.getTaxname();
                            }
                        }
                        td.setInvoiceType("出口转内销海关缴款书");
                        list.add(td);
                    }
                }
            }

            if (sb.indexOf("80") < 0) {
                BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                td.setBdkAmountCount("0.00");
                td.setBdkInvoiceCount("0");
                td.setBdkTaxAmountCount("0.00");
                td.setDkAmountCount("0.00");
                td.setDkInvoiceCount("0");
                td.setDkTaxAmountCount("0.00");
                td.setTaxno((String)pramsMap.get("gfsh"));
                td.setTjDate(tjdate);
                td.setTjMonth(tjmonth);
                td.setTaxName(taxName);
                td.setInvoiceType("出口转内销专用电子发票");
                list.add(td);
            } else {
                for (BaseTDxDkCountDetail baseTDxDkCountDetail : dkList) {
                    if ("80".equals(baseTDxDkCountDetail.getInvoiceType())) {
                        BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                        sb.append(baseTDxDkCountDetail.getInvoiceType());
                        String bdkAmountCount;
                        try {
                            bdkAmountCount = baseTDxDkCountDetail.getBdkAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkAmountCount);
                            bdkAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkAmountCount = "-";
                        }
                        td.setBdkAmountCount(bdkAmountCount);
                        String bdkInvoiceCount;
                        try {
                            bdkInvoiceCount = baseTDxDkCountDetail.getBdkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(bdkInvoiceCount);
                            bdkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            bdkInvoiceCount = "-";
                        }
                        td.setBdkInvoiceCount(bdkInvoiceCount);
                        String bdkTaxAmountCount;
                        try {
                            bdkTaxAmountCount = baseTDxDkCountDetail.getBdkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(bdkTaxAmountCount);
                            bdkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            bdkTaxAmountCount = "-";
                        }
                        td.setBdkTaxAmountCount(bdkTaxAmountCount);
                        String dkAmountCount;
                        try {
                            dkAmountCount = baseTDxDkCountDetail.getDkAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkAmountCount);
                            dkAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkAmountCount = "-";
                        }
                        td.setDkAmountCount(dkAmountCount);
                        String dkInvoiceCount;
                        try {
                            dkInvoiceCount = baseTDxDkCountDetail.getDkInvoiceCount();
                            BigDecimal amountCount = new BigDecimal(dkInvoiceCount);
                            dkInvoiceCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                        } catch (Exception e) {
                            dkInvoiceCount = "-";
                        }
                        td.setDkInvoiceCount(dkInvoiceCount);
                        String dkTaxAmountCount;
                        try {
                            dkTaxAmountCount = baseTDxDkCountDetail.getDkTaxAmountCount();
                            BigDecimal amountCount = new BigDecimal(dkTaxAmountCount);
                            dkTaxAmountCount =
                                AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                        } catch (Exception e) {
                            dkTaxAmountCount = "-";
                        }
                        td.setDkTaxAmountCount(dkTaxAmountCount);
                        td.setTaxno(baseTDxDkCountDetail.getTaxno());
                        String tjDate = baseTDxDkCountDetail.getTjDate();
                        Date date = sdf.parse(tjDate);
                        td.setTjDate(sdf1.format(date));
                        td.setTjMonth(baseTDxDkCountDetail.getTjMonth());
                        for (Tax t : taxList) {
                            String taxno = t.getTaxno();
                            if (td.getTaxno().equals(taxno)) {
                                td.setTaxName(t.getTaxname());
                            }
                        }
                        td.setInvoiceType("出口转内销专用电子发票");
                        list.add(td);
                    }
                }
            }
            for (BaseTDxDkCountDetail baseTDxDkCountDetail : dkList) {
                if ("99".equals(baseTDxDkCountDetail.getInvoiceType())) {
                    BaseTDxDkCountDetailRespVO td = new BaseTDxDkCountDetailRespVO();
                    sb.append(baseTDxDkCountDetail.getInvoiceType());
                    String bdkAmountCount;
                    try {
                        bdkAmountCount = baseTDxDkCountDetail.getBdkAmountCount();
                        BigDecimal amountCount = new BigDecimal(bdkAmountCount);
                        bdkAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                    } catch (Exception e) {
                        bdkAmountCount = "-";
                    }
                    td.setBdkAmountCount(bdkAmountCount);
                    String bdkInvoiceCount;
                    try {
                        bdkInvoiceCount = baseTDxDkCountDetail.getBdkInvoiceCount();
                        BigDecimal amountCount = new BigDecimal(bdkInvoiceCount);
                        bdkInvoiceCount =
                            AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                    } catch (Exception e) {
                        bdkInvoiceCount = "-";
                    }
                    td.setBdkInvoiceCount(bdkInvoiceCount);
                    String bdkTaxAmountCount;
                    try {
                        bdkTaxAmountCount = baseTDxDkCountDetail.getBdkTaxAmountCount();
                        BigDecimal amountCount = new BigDecimal(bdkTaxAmountCount);
                        bdkTaxAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                    } catch (Exception e) {
                        bdkTaxAmountCount = "-";
                    }
                    td.setBdkTaxAmountCount(bdkTaxAmountCount);
                    String dkAmountCount;
                    try {
                        dkAmountCount = baseTDxDkCountDetail.getDkAmountCount();
                        BigDecimal amountCount = new BigDecimal(dkAmountCount);
                        dkAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                    } catch (Exception e) {
                        dkAmountCount = "-";
                    }
                    td.setDkAmountCount(dkAmountCount);
                    String dkInvoiceCount;
                    try {
                        dkInvoiceCount = baseTDxDkCountDetail.getDkInvoiceCount();
                        BigDecimal amountCount = new BigDecimal(dkInvoiceCount);
                        dkInvoiceCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString(), 0));
                    } catch (Exception e) {
                        dkInvoiceCount = "-";
                    }
                    td.setDkInvoiceCount(dkInvoiceCount);
                    String dkTaxAmountCount;
                    try {
                        dkTaxAmountCount = baseTDxDkCountDetail.getDkTaxAmountCount();
                        BigDecimal amountCount = new BigDecimal(dkTaxAmountCount);
                        dkTaxAmountCount = AmountFormatUtil.fmtMicrometer(MathUtil.round(amountCount.toPlainString()));
                    } catch (Exception e) {
                        dkTaxAmountCount = "-";
                    }
                    td.setDkTaxAmountCount(dkTaxAmountCount);
                    td.setTaxno(baseTDxDkCountDetail.getTaxno());
                    String tjDate = baseTDxDkCountDetail.getTjDate();
                    Date date = sdf.parse(tjDate);
                    td.setTjDate(sdf1.format(date));
                    td.setTjMonth(baseTDxDkCountDetail.getTjMonth());
                    for (Tax t : taxList) {
                        String taxno = t.getTaxno();
                        if (td.getTaxno().equals(taxno)) {
                            td.setTaxName(t.getTaxname());
                        }
                    }
                    if (baseTDxDkCountDetail.getInvoiceType().equals(DktjmxzjEnum.ZJ.getDktjmxzjDm())) {
                        td.setInvoiceType(DktjmxzjEnum.ZJ.getDktjmxzjMc(DktjmxzjEnum.ZJ.getIndex()));
                    } else {
                        for (FplxEnum e : FplxEnum.values()) {
                            if (e.getFplxDm().equals(baseTDxDkCountDetail.getInvoiceType())) {
                                td.setInvoiceType(e.getFplxMc(e.getIndex()));
                            }
                        }
                    }
                    list.add(td);
                }
            }
            json.put("datalist", list);
        } catch (Exception e) {
            // 统一设置操作异常标识
            json = super.errorResult(e);
        }

        return super.responseResult(json);
    }

    @Override
    public JSONObject selectCxtjHjxx(Map<String, Object> pramsMap) {

        JSONObject json = new JSONObject();

        String[] gfshs = pramsMap.get("gfshs").toString().split(",");
        String[] skssqs = pramsMap.get("skssqs").toString().split(",");

        String hjsl = "0";
        String hjje = "0";
        String hjse = "0";
        String sl = "0";
        String je = "0";
        String se = "0";

        for (int i = 0; i < gfshs.length; i++) {

            Map<String, Object> pramMap = new HashMap<>(16);
            pramMap.put("gfsh", gfshs[i]);
            pramMap.put("skssq", skssqs[i]);

            QueryWrapper<BaseTDxDkCountDetail> queryWrapper = new QueryWrapper<>();
            if (pramMap.containsKey("gfsh") && !StringHelper.isBlank(String.valueOf(pramMap.get("gfsh")))) {
                queryWrapper.eq("taxno", pramMap.get("gfsh"));
            }
            if (pramMap.containsKey("skssq") && !StringHelper.isBlank(String.valueOf(pramMap.get("skssq")))) {
                queryWrapper.eq("tj_month", pramMap.get("skssq"));
            }
            queryWrapper.eq("invoice_type", DktjmxzjEnum.ZJ.getDktjmxzjDm());
            List<BaseTDxDkCountDetail> dkList = list(queryWrapper);
            if (dkList != null && dkList.size() > 0) {
                String bdkAmount;
                String dkAmount;
                try {
                    bdkAmount = new BigDecimal(dkList.get(0).getBdkAmountCount()).toPlainString();
                } catch (Exception e) {
                    bdkAmount = "0";
                }
                try {
                    dkAmount = new BigDecimal(dkList.get(0).getDkAmountCount()).toPlainString();
                } catch (Exception e) {
                    dkAmount = "0";
                }
                sl = MathUtil.add(bdkAmount, dkAmount);
                String bdkInvoiceCount;
                String dkInvoiceCount;
                try {
                    bdkInvoiceCount = new BigDecimal(dkList.get(0).getBdkInvoiceCount()).toPlainString();
                } catch (Exception e) {
                    bdkInvoiceCount = "0";
                }
                try {
                    dkInvoiceCount = new BigDecimal(dkList.get(0).getDkInvoiceCount()).toPlainString();
                } catch (Exception e) {
                    dkInvoiceCount = "0";
                }
                je = MathUtil.add(bdkInvoiceCount, dkInvoiceCount);
                String bdkTaxAmount;
                String dkTaxAmount;
                try {
                    bdkTaxAmount = new BigDecimal(dkList.get(0).getBdkTaxAmountCount()).toPlainString();
                } catch (Exception e) {
                    bdkTaxAmount = "0";
                }
                try {
                    dkTaxAmount = new BigDecimal(dkList.get(0).getDkTaxAmountCount()).toPlainString();
                } catch (Exception e) {
                    dkTaxAmount = "0";
                }
                se = MathUtil.add(bdkTaxAmount, dkTaxAmount);
            }

        }
        hjsl = MathUtil.add(hjsl, sl).substring(0, 1);
        hjje = AmountFormatUtil.fmtMicrometer(MathUtil.round(MathUtil.add(hjje, je)));
        hjse = AmountFormatUtil.fmtMicrometer(MathUtil.round(MathUtil.add(hjse, se)));

        json.put("hjsl", hjsl);
        json.put("hjje", hjje);
        json.put("hjse", hjse);

        return json;
    }

}
