package com.hzs.report.member.controller.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.hzs.common.core.annotation.Log;
import com.hzs.common.core.constant.CountryConstants;
import com.hzs.common.core.constant.EnumsPrefixConstants;
import com.hzs.common.core.constant.TableNameConstants;
import com.hzs.common.core.constant.msg.ConfigMsgConstants;
import com.hzs.common.core.constant.msg.NoticeMsgConstants;
import com.hzs.common.core.domain.R;
import com.hzs.common.core.enums.*;
import com.hzs.common.core.utils.DateUtils;
import com.hzs.common.core.utils.StringUtils;
import com.hzs.common.core.utils.poi.ExcelUtil;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.domain.AjaxResult;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.domain.member.ext.CuMemberExt;
import com.hzs.common.domain.system.config.BdAwards;
import com.hzs.common.security.service.UserTokenService;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.common.service.ITransactionCommonService;
import com.hzs.common.util.TransactionUtils;
import com.hzs.member.achieve.ICuMemberSettlePeriodServiceApi;
import com.hzs.member.base.IMemberServiceApi;
import com.hzs.report.member.service.ICuMemberAwardsStatService;
import com.hzs.report.member.vo.*;
import com.hzs.system.base.IAreaServiceApi;
import com.hzs.system.base.ICurrencyServiceApi;
import com.hzs.system.base.dto.CurrencyDTO;
import com.hzs.system.config.IAwardsServiceApi;
import com.hzs.system.config.IVertexServiceApi;
import com.hzs.system.config.dto.VertexDTO;
import com.hzs.system.sys.dto.LoginUser;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 会员奖衔升级记录表 前端控制器
 */
@RestController
@RequestMapping("/manager/member-awards")
public class CuMemberAwardsStatController extends BaseController {

    @Autowired
    private ICuMemberAwardsStatService iCuMemberAwardsStatService;
    @Autowired
    private ITransactionCommonService iTransactionCommonService;
    @Autowired
    private UserTokenService userTokenService;

    @DubboReference
    IMemberServiceApi iMemberServiceApi;
    @DubboReference
    ICurrencyServiceApi iCurrencyServiceApi;
    @DubboReference
    IAreaServiceApi iAreaServiceApi;
    @DubboReference
    IAwardsServiceApi iAwardsServiceApi;
    @DubboReference
    IVertexServiceApi iVertexServiceApi;
    @DubboReference
    ICuMemberSettlePeriodServiceApi iCuMemberSettlePeriodServiceApi;

    /**
     * 真实业绩新增奖衔查询列表
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.REAL_PERFORMANCE_ADDED_AWARDS, method = EOperationMethod.SELECT)
    @GetMapping("/list")
    public TableDataInfo list(CuMemberAwardsStatVO cuMemberAwardsStatVO) {
        Date date = DateUtils.currentDate();
        cuMemberAwardsStatVO.setPkCountry(SecurityUtils.getPkCountry());
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        //当前日期前一天
        String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date));
        //查询最新期数
        int endperiod = iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                DateUtils.parseDateToStr(dateStr)).getData().getPkId();
        cuMemberAwardsStatVO.setPeriod(endperiod);
        String achieveTableName = TableNameConstants.CU_MEMBER_SETTLE + endperiod;
        cuMemberAwardsStatVO.setAchieveTableName(achieveTableName);
        startPage();
        List<CuMemberAwardsStatVO> list = iCuMemberAwardsStatService.selectCuMemberAwardsList(cuMemberAwardsStatVO);
        //业绩转为当前国家的汇率
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                if (null != currency.getData().getInExchangeRate()) {
                    itm.setANewPv(itm.getANewPv().multiply(currency.getData().getInExchangeRate()));
                    itm.setBNewPv(itm.getBNewPv().multiply(currency.getData().getInExchangeRate()));
                }
            });
        }

        return getDataTable(list);
    }

    /**
     * 导出 真实业绩新增奖衔查询列表
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.REAL_PERFORMANCE_ADDED_AWARDS, method = EOperationMethod.EXPORT)
    @PostMapping("/export")
    public void exportUmbrella(HttpServletResponse response, CuMemberAwardsStatVO cuMemberAwardsStatVO) {
        cuMemberAwardsStatVO.setPkCountry(SecurityUtils.getPkCountry());
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());

        Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(
                EnumsPrefixConstants.KEY_AWARD);
        Date date = DateUtils.currentDate();
        //当前日期前一天
        String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date));
        //查询最新期数
        int endperiod = iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                DateUtils.parseDateToStr(dateStr)).getData().getPkId();
        cuMemberAwardsStatVO.setPeriod(endperiod);
        String achieveTableName = TableNameConstants.CU_MEMBER_SETTLE + endperiod;
        cuMemberAwardsStatVO.setAchieveTableName(achieveTableName);
        List<CuMemberAwardsStatVO> list = iCuMemberAwardsStatService.selectCuMemberAwardsList(cuMemberAwardsStatVO);
        //业绩转为当前国家的汇率
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                itm.setPkAwardsVal(transactionMap1.get(itm.getPkAwards()));
                if (null != currency.getData().getInExchangeRate()) {
                    itm.setANewPv(itm.getANewPv().multiply(currency.getData().getInExchangeRate()));
                    itm.setBNewPv(itm.getBNewPv().multiply(currency.getData().getInExchangeRate()));
                }
            });
        }

        ExcelUtil<CuMemberAwardsStatVO> util = new ExcelUtil<>(CuMemberAwardsStatVO.class);
        util.exportExcel(response, list, "真实业绩新增奖衔");
    }


    /**
     * 奖衔晋升查询
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AWARD_PROMOTION, method = EOperationMethod.SELECT)
    @GetMapping("/promotion-list")
    public TableDataInfo awardPromotionList(AwardPromotionVO awardPromotionVO) {
        if (StringUtils.isEmpty(awardPromotionVO.getMemberCode()) &&
                StringUtils.isNull(awardPromotionVO.getOldPkAwards()) &&
                StringUtils.isNull(awardPromotionVO.getPkAwards()) &&
                StringUtils.isEmpty(awardPromotionVO.getStartDate()) &&
                StringUtils.isEmpty(awardPromotionVO.getEndDate())
        ) {
            return getDataTable(new ArrayList<>());
        }
        awardPromotionVO.setPkCountry(SecurityUtils.getPkCountry());
        startPage();
        List<AwardPromotionVO> list = iCuMemberAwardsStatService.awardPromotionList(awardPromotionVO);
        return getDataTable(list);
    }

    /**
     * 导出奖衔晋升查询
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AWARD_PROMOTION, method = EOperationMethod.EXPORT)
    @PostMapping("/promotion-export")
    public void exportPromotion(HttpServletResponse response, AwardPromotionVO awardPromotionVO) {
        if (StringUtils.isEmpty(awardPromotionVO.getMemberCode()) &&
                StringUtils.isNull(awardPromotionVO.getOldPkAwards()) &&
                StringUtils.isNull(awardPromotionVO.getPkAwards()) &&
                StringUtils.isEmpty(awardPromotionVO.getStartDate()) &&
                StringUtils.isEmpty(awardPromotionVO.getEndDate())
        ) {
            return;
        }
        awardPromotionVO.setPkCountry(SecurityUtils.getPkCountry());
        Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(
                EnumsPrefixConstants.KEY_AWARD);
        List<AwardPromotionVO> list = iCuMemberAwardsStatService.awardPromotionList(awardPromotionVO);
        //业绩转为当前国家的汇率
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                itm.setPkAwardsVal(transactionMap1.get(itm.getPkAwards()));
                itm.setOldPkAwardsVal(transactionMap1.get(itm.getOldPkAwards()));

            });
        }
        ExcelUtil<AwardPromotionVO> util = new ExcelUtil<>(AwardPromotionVO.class);
        util.exportExcel(response, list, "奖衔晋升");
    }

    /**
     * 会员业绩数据查询
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.MEMBER_ACHIEVE, method = EOperationMethod.SELECT)
    @GetMapping("/member-achieve-list")
    public TableDataInfo memberAchieveList(MemberAchieveVO memberAchieveVO) {
        if (StringUtils.isEmpty(memberAchieveVO.getMemberCode()) ||
                StringUtils.isEmpty(memberAchieveVO.getStartDate()) ||
                StringUtils.isEmpty(memberAchieveVO.getEndDate())
        ) {
            return getDataTable(new ArrayList<>());
        }
        memberAchieveVO.setPkMember(iMemberServiceApi.getMemberByCode(memberAchieveVO.getMemberCode()).getData().getPkId());
        memberAchieveVO.setPkCountry(SecurityUtils.getPkCountry());
        startPage();
        List<MemberAchieveVO> list = iCuMemberAwardsStatService.memberAchieveList(memberAchieveVO);
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        //业绩转为当前国家的汇率
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                itm.setPushOrderAchieve(itm.getPushOrderAchieve().multiply(currency.getData().getInExchangeRate()));
                itm.setResettleAchieve((itm.getLeftResettleAchieve().add(itm.getRightResettleAchieve())).multiply(currency.getData().getInExchangeRate()));
                itm.setLeftResettleAchieve(itm.getLeftResettleAchieve().multiply(currency.getData().getInExchangeRate()));
                itm.setRightResettleAchieve(itm.getRightResettleAchieve().multiply(currency.getData().getInExchangeRate()));
                itm.setRegisterAchieve(itm.getRegisterAchieve().multiply(currency.getData().getInExchangeRate()));
                itm.setDirectAchieve(itm.getDirectAchieve().multiply(currency.getData().getInExchangeRate()));
                itm.setReplyAchieve(itm.getReplyAchieve().multiply(currency.getData().getInExchangeRate()));
                itm.setTradeAchieve(itm.getTradeAchieve().multiply(currency.getData().getInExchangeRate()));
                itm.setRealIncomeTotal(itm.getRealIncomeTotal().multiply(currency.getData().getInExchangeRate()));
            });
        }
        return getDataTable(list);
    }

    /**
     * 导出会员业绩数据查询
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.MEMBER_ACHIEVE, method = EOperationMethod.EXPORT)
    @PostMapping("/member-achieve-export")
    public void exportMemberAchieve(HttpServletResponse response, MemberAchieveVO memberAchieveVO) {
        if (StringUtils.isNotEmpty(memberAchieveVO.getMemberCode()) &&
                StringUtils.isNotEmpty(memberAchieveVO.getStartDate()) &&
                StringUtils.isNotEmpty(memberAchieveVO.getEndDate())
        ) {
            memberAchieveVO.setPkMember(iMemberServiceApi.getMemberByCode(memberAchieveVO.getMemberCode()).getData().getPkId());
            memberAchieveVO.setPkCountry(SecurityUtils.getPkCountry());
            List<MemberAchieveVO> list = iCuMemberAwardsStatService.memberAchieveList(memberAchieveVO);
            //查询当前国家的汇率
            R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
            //业绩转为当前国家的汇率
            if (CollectionUtil.isNotEmpty(list)) {
                list.forEach(itm -> {
                    itm.setPushOrderAchieve(itm.getPushOrderAchieve().multiply(currency.getData().getInExchangeRate()));
                    itm.setResettleAchieve((itm.getLeftResettleAchieve().add(itm.getRightResettleAchieve())).multiply(currency.getData().getInExchangeRate()));
                    itm.setLeftResettleAchieve(itm.getLeftResettleAchieve().multiply(currency.getData().getInExchangeRate()));
                    itm.setRightResettleAchieve(itm.getRightResettleAchieve().multiply(currency.getData().getInExchangeRate()));
                    itm.setRegisterAchieve(itm.getRegisterAchieve().multiply(currency.getData().getInExchangeRate()));
                    itm.setDirectAchieve(itm.getDirectAchieve().multiply(currency.getData().getInExchangeRate()));
                    itm.setReplyAchieve(itm.getReplyAchieve().multiply(currency.getData().getInExchangeRate()));
                    itm.setTradeAchieve(itm.getTradeAchieve().multiply(currency.getData().getInExchangeRate()));
                    itm.setRealIncomeTotal(itm.getRealIncomeTotal().multiply(currency.getData().getInExchangeRate()));
                });
            }
            ExcelUtil<MemberAchieveVO> util = new ExcelUtil<>(MemberAchieveVO.class);
            util.exportExcel(response, list, "会员业绩数据查询");
        }
    }

    /**
     * 真实奖衔分析
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AWARD_ANALYSIS, method = EOperationMethod.SELECT)
    @GetMapping("/analysis-list")
    public TableDataInfo analysisList(CuMemberAwardsAnalysisVO cuMemberAwardsAnalysisVO) {
        Date date = DateUtils.currentDate();
        cuMemberAwardsAnalysisVO.setPkCountry(SecurityUtils.getPkCountry());
        //当前日期前一天
        String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date));

        //查询最新期数
        int endperiod = iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                DateUtils.parseDateToStr(dateStr)).getData().getPkId();
        cuMemberAwardsAnalysisVO.setPeriod(endperiod);
        startPage();
        List<CuMemberAwardsAnalysisVO> list = iCuMemberAwardsStatService.selectCuMemberAwardsAnalysisList(cuMemberAwardsAnalysisVO);
        for (CuMemberAwardsAnalysisVO pe : list) {
            String dates = DateUtils.parseDateToStr(DateUtils.YYYY_MM, pe.getCreationTime());
            pe.setAchieveTableName(TableNameConstants.CU_MEMBER_ACHIEVE + DateUtils.getMonth(dates));
        }
        List<CuMemberAwardsAnalysisVO> realList = new ArrayList<>();
        if (CollectionUtil.isNotEmpty(list)) {
            realList = iCuMemberAwardsStatService.selectAwardsAnalysisList(list);
        }
        if (CollectionUtil.isNotEmpty(list) && CollectionUtil.isNotEmpty(realList)) {
            //查询当前国家的汇率
            R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());

            list.forEach(itm -> {
                //业绩转为当前国家的汇率
                list.forEach(itmm -> {
                    if (itm.getPkMember().equals(itmm.getPkMember()) &&
                            itm.getPeriod().equals(itmm.getPeriod())) {
                        if (null != currency.getData().getInExchangeRate()) {
                            itm.setASumRealPv(itmm.getASumRealPv().multiply(currency.getData().getInExchangeRate()));
                            itm.setBSumRealPv(itmm.getBSumRealPv().multiply(currency.getData().getInExchangeRate()));
                        } else {
                            itm.setASumRealPv(itmm.getASumRealPv());
                            itm.setBSumRealPv(itmm.getBSumRealPv());
                        }
                    }
                });
            });
        }
        return getDataTable(list);
    }

    /**
     * 真实奖衔分析-详情（穿透页面接口）
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.ANALYSIS_DETAILS, method = EOperationMethod.SELECT)
    @GetMapping("/analysis-details-list")
    public TableDataInfo analysisDetailsList(CuMemberAwardsAnalysisVO cuMemberAwardsAnalysisVO) {
        Date date = DateUtils.currentDate();
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        //当前日期前一天
        String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date));

        //查询最新期数
        if (cuMemberAwardsAnalysisVO.getPeriod() == null) {
            int endperiod = iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                    DateUtils.parseDateToStr(dateStr)).getData().getPkId();
            cuMemberAwardsAnalysisVO.setPeriod(endperiod);
        }
        String achieveTableName = TableNameConstants.CU_MEMBER_SETTLE + cuMemberAwardsAnalysisVO.getPeriod();
        cuMemberAwardsAnalysisVO.setAchieveTableName(achieveTableName);
        startPage();
        List<CuMemberAwardsAnalysisVO> list = iCuMemberAwardsStatService.selectCuMemberAwardsAnalysisDetailsList(cuMemberAwardsAnalysisVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                //业绩转为当前国家的汇率
                if (null != currency.getData().getInExchangeRate()) {
                    itm.setASumRealPv(itm.getASumRealPv().multiply(currency.getData().getInExchangeRate()));
                    itm.setBSumRealPv(itm.getBSumRealPv().multiply(currency.getData().getInExchangeRate()));
                }
            });
        }

        return getDataTable(list);
    }

    /**
     * 导出真实奖衔分析-详情（穿透页面接口）
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AWARD_ANALYSIS, method = EOperationMethod.EXPORT)
    @PostMapping("/export-analysis-details")
    public void exportAnalysisDetails(HttpServletResponse response, CuMemberAwardsAnalysisVO cuMemberAwardsAnalysisVO) {
        Date date = DateUtils.currentDate();
        Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(EnumsPrefixConstants.KEY_GRADE,
                EnumsPrefixConstants.KEY_AWARD);
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        //当前日期前一天
        String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date));
        //查询最新期数
        int endperiod = iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                DateUtils.parseDateToStr(dateStr)).getData().getPkId();
        cuMemberAwardsAnalysisVO.setPeriod(endperiod);
        String achieveTableName = TableNameConstants.CU_MEMBER_SETTLE + endperiod;
        cuMemberAwardsAnalysisVO.setAchieveTableName(achieveTableName);
        startPage();
        List<CuMemberAwardsAnalysisVO> list = iCuMemberAwardsStatService.selectCuMemberAwardsAnalysisDetailsList(cuMemberAwardsAnalysisVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                itm.setPkAwardsVal(transactionMap1.get(itm.getPkAwards()));
                itm.setPkRegisterGradeVal(transactionMap1.get(itm.getPkRegisterGrade()));
                //业绩转为当前国家的汇率
                if (null != currency.getData().getInExchangeRate()) {
                    itm.setASumRealPv(itm.getASumRealPv().multiply(currency.getData().getInExchangeRate()));
                    itm.setBSumRealPv(itm.getBSumRealPv().multiply(currency.getData().getInExchangeRate()));
                }
            });
        }
        ExcelUtil<CuMemberAwardsAnalysisVO> util = new ExcelUtil<>(CuMemberAwardsAnalysisVO.class);
        util.exportExcel(response, list, "真实奖衔分析");
    }

    /**
     * 收入明细
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.REVENUE_DETAI_LIST, method = EOperationMethod.SELECT)
    @GetMapping("/revenue-detai-list")
    public TableDataInfo revenueDetailsList(RevenueDetailsVO revenueDetailsVO) {
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        revenueDetailsVO.setPkCountry(SecurityUtils.getPkCountry());
        startPage();
        List<RevenueDetailsVO> list = iCuMemberAwardsStatService.selectRevenueDetailsList(revenueDetailsVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                //业绩转为当前国家的汇率
                if (null != currency.getData().getInExchangeRate()) {
                    itm.setPurRealSubtotal(itm.getPurRealSubtotal().multiply(currency.getData().getInExchangeRate()));
                    itm.setRepurRealSubtotal(itm.getRepurRealSubtotal().multiply(currency.getData().getInExchangeRate()));
                    itm.setRealIncomeTotal(itm.getRealIncomeTotal().multiply(currency.getData().getInExchangeRate()));
                }
            });
        }
        return getDataTable(list);
    }

    /**
     * 导出收入明细
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.REVENUE_DETAI_LIST, method = EOperationMethod.EXPORT)
    @PostMapping("/export-revenue-detai")
    public void exportRevenueDetai(HttpServletResponse response, RevenueDetailsVO revenueDetailsVO) {
        revenueDetailsVO.setPkCountry(SecurityUtils.getPkCountry());
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(EnumsPrefixConstants.KEY_GRADE,
                EnumsPrefixConstants.KEY_AWARD);
        List<RevenueDetailsVO> list = iCuMemberAwardsStatService.selectRevenueDetailsList(revenueDetailsVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                //业绩转为当前国家的汇率
                if (null != currency.getData().getInExchangeRate()) {
                    itm.setPkAwardsVal(transactionMap1.get(itm.getPkAwards()));
                    itm.setPkRegisterGradeVal(transactionMap1.get(itm.getPkRegisterGrade()));
                    itm.setPurRealSubtotal(itm.getPurRealSubtotal().multiply(currency.getData().getInExchangeRate()));
                    itm.setRepurRealSubtotal(itm.getRepurRealSubtotal().multiply(currency.getData().getInExchangeRate()));
                    itm.setRealIncomeTotal(itm.getRealIncomeTotal().multiply(currency.getData().getInExchangeRate()));
                }
            });
        }
        ExcelUtil<RevenueDetailsVO> util = new ExcelUtil<>(RevenueDetailsVO.class);
        util.exportExcel(response, list, "收入明细");
    }

    /**
     * 导出真实奖衔分析
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AWARD_ANALYSIS, method = EOperationMethod.EXPORT)
    @PostMapping("/export-analysis")
    public void exportAnalysis(HttpServletResponse response, CuMemberAwardsAnalysisVO cuMemberAwardsAnalysisVO) {

        Date date = DateUtils.currentDate();
        cuMemberAwardsAnalysisVO.setPkCountry(SecurityUtils.getPkCountry());
        //当前日期前一天
        String dateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date));
        //查询最新期数
        int endperiod = iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                DateUtils.parseDateToStr(dateStr)).getData().getPkId();
        cuMemberAwardsAnalysisVO.setPeriod(endperiod);
        String achieveTableName = TableNameConstants.CU_MEMBER_SETTLE + endperiod;
        cuMemberAwardsAnalysisVO.setAchieveTableName(achieveTableName);
        List<CuMemberAwardsAnalysisVO> list = iCuMemberAwardsStatService.selectCuMemberAwardsAnalysisList(cuMemberAwardsAnalysisVO);
        for (CuMemberAwardsAnalysisVO pe : list) {
            pe.setAchieveTableName(TableNameConstants.CU_MEMBER_SETTLE + pe.getPeriod());
        }
        List<CuMemberAwardsAnalysisVO> realList = iCuMemberAwardsStatService.selectAwardsAnalysisList(list);
        if (CollectionUtil.isNotEmpty(list) && CollectionUtil.isNotEmpty(realList)) {
            //查询当前国家的汇率
            R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
            Map<String, String> transactionMap = iTransactionCommonService.exportEnumTransaction(EUpgradeType.values());

            list.forEach(itm -> {
                itm.setUpTypeVal(transactionMap.get(EnumsPrefixConstants.UPGRADE_TYPE + itm.getUpType()));
                //业绩转为当前国家的汇率
                list.forEach(itmm -> {
                    if (itm.getPkMember().equals(itmm.getPkMember()) &&
                            itm.getPeriod().equals(itmm.getPeriod())) {
                        if (null != currency.getData().getInExchangeRate()) {
                            itm.setASumRealPv(itmm.getASumRealPv().multiply(currency.getData().getInExchangeRate()));
                            itm.setBSumRealPv(itmm.getBSumRealPv().multiply(currency.getData().getInExchangeRate()));
                        } else {
                            itm.setASumRealPv(itmm.getASumRealPv());
                            itm.setBSumRealPv(itmm.getBSumRealPv());
                        }
                    }
                });
            });
        }
        ExcelUtil<CuMemberAwardsAnalysisVO> util = new ExcelUtil<>(CuMemberAwardsAnalysisVO.class);
        util.exportExcel(response, list, "真实奖衔分析");
    }

    /**
     * 个人统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.PERSON_STAT, method = EOperationMethod.SELECT)
    @GetMapping("/personStatList")
    public TableDataInfo personStatList(PersonStatVO personStatVO) {
        Date date = DateUtils.currentDate();
        personStatVO.setPkCountry(SecurityUtils.getPkCountry());
        if (StringUtils.isNull(personStatVO.getStartDate()) ||
                StringUtils.isNull(personStatVO.getEndDate())) {
            if (DateUtils.compareDateBefore(date, DateUtils.currentMonthFirstDate()) ||
                    DateUtils.compareDateEqual(date, DateUtils.currentMonthFirstDate())) {
                //之前月的第一天
                personStatVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeMonthFirstDate()));
                personStatVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeMonthLastDate()));
            } else {
                //当前月第一天
                personStatVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
                personStatVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date)));
            }
        }
        if (DateUtils.compareDateBefore(date, DateUtils.parseStringToDate(personStatVO.getStartDate())) ||
                DateUtils.compareDateEqual(date, DateUtils.parseStringToDate(personStatVO.getStartDate()))) {
            //当前月第一天
            personStatVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
        }
        if (DateUtils.compareDateBefore(date, DateUtils.parseStringToDate(personStatVO.getEndDate())) ||
                DateUtils.compareDateEqual(date, DateUtils.parseStringToDate(personStatVO.getEndDate()))) {
            //当前日期的前一天
            personStatVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date)));
        }
        //查询业绩集合
        List<PersonStatVO> perList = new ArrayList<>();

        //会员集合
        List<Long> pkMemberList = new ArrayList<>();
        startPage();
        List<PersonStatVO> list = iCuMemberAwardsStatService.selectPersonStatList(personStatVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm ->
                    pkMemberList.add(itm.getPkMember())
            );
        }
        if (CollectionUtil.isNotEmpty(list)) {
            List<String> firstDaysOfMonth = getStrideMonth(personStatVO.getStartDate(), personStatVO.getEndDate());
            if (CollectionUtil.isNotEmpty(firstDaysOfMonth)) {
                for (String dateStr : firstDaysOfMonth) {
                    //查询最新期数
                    int staperiod = iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                            DateUtils.parseDateToStr(dateStr)).getData().getPkId();
                    PersonStatVO per = new PersonStatVO();
                    per.setPeriod(staperiod);
                    String achieveTableName = TableNameConstants.CU_MEMBER_ACHIEVE + DateUtils.getMonth(dateStr);
                    per.setAchieveTableName(achieveTableName);
                    per.setPkMemberList(pkMemberList);
                    perList.add(per);
                }
            }
            List<PersonStatVO> newPvlist = iCuMemberAwardsStatService.selectPersonPvList(perList);
            if (CollectionUtil.isNotEmpty(list) && CollectionUtil.isNotEmpty(newPvlist)) {
                list.forEach(itm -> {
                    newPvlist.forEach(itmm -> {
                        if (itm.getPkMember().equals(itmm.getPkMember())) {
                            itm.setRealityPv(itmm.getRealityPv());
                        }
                    });
                });
            }
        }
        return getDataTable(list);
    }

    /**
     * 导出 个人统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.PERSON_STAT, method = EOperationMethod.EXPORT)
    @PostMapping("/export-personStat")
    public void exportPersonStat(HttpServletResponse response, PersonStatVO personStatVO) {
        Date date = DateUtils.currentDate();
        personStatVO.setPkCountry(SecurityUtils.getPkCountry());
        if (StringUtils.isNull(personStatVO.getStartDate()) ||
                StringUtils.isNull(personStatVO.getEndDate())) {
            if (DateUtils.compareDateBefore(date, DateUtils.currentMonthFirstDate()) ||
                    DateUtils.compareDateEqual(date, DateUtils.currentMonthFirstDate())) {
                //之前月的第一天
                personStatVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeMonthFirstDate()));
                personStatVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeMonthLastDate()));
            } else {
                //当前月第一天
                personStatVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
                personStatVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date)));
            }
        }
        if (DateUtils.compareDateBefore(date, DateUtils.parseStringToDate(personStatVO.getStartDate())) ||
                DateUtils.compareDateEqual(date, DateUtils.parseStringToDate(personStatVO.getStartDate()))) {
            //当前月第一天
            personStatVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
        }
        if (DateUtils.compareDateBefore(date, DateUtils.parseStringToDate(personStatVO.getEndDate())) ||
                DateUtils.compareDateEqual(date, DateUtils.parseStringToDate(personStatVO.getEndDate()))) {
            //当前日期的前一天
            personStatVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date)));
        }
        //查询业绩集合
        List<PersonStatVO> perList = new ArrayList<>();

        //会员集合
        List<Long> pkMemberList = new ArrayList<>();
        startPage();
        List<PersonStatVO> list = iCuMemberAwardsStatService.selectPersonStatList(personStatVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm ->
                    pkMemberList.add(itm.getPkMember())
            );
        }
        if (CollectionUtil.isNotEmpty(list)) {
            List<String> firstDaysOfMonth = getStrideMonth(personStatVO.getStartDate(), personStatVO.getEndDate());
            if (CollectionUtil.isNotEmpty(firstDaysOfMonth)) {
                for (String dateStr : firstDaysOfMonth) {
                    //查询最新期数
                    int staperiod = iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                            DateUtils.parseDateToStr(dateStr)).getData().getPkId();
                    PersonStatVO per = new PersonStatVO();
                    per.setPeriod(staperiod);
                    String achieveTableName = TableNameConstants.CU_MEMBER_ACHIEVE + DateUtils.getMonth(dateStr);
                    per.setAchieveTableName(achieveTableName);
                    per.setPkMemberList(pkMemberList);
                    perList.add(per);
                }
            }
            List<PersonStatVO> newPvlist = iCuMemberAwardsStatService.selectPersonPvList(perList);
            if (CollectionUtil.isNotEmpty(list) && CollectionUtil.isNotEmpty(newPvlist)) {
                list.forEach(itm -> {
                    newPvlist.forEach(itmm -> {
                        if (itm.getPkMember().equals(itmm.getPkMember())) {
                            itm.setRealityPv(itmm.getRealityPv());
                        }
                    });
                });
            }
        }
        ExcelUtil<PersonStatVO> util = new ExcelUtil<>(PersonStatVO.class);
        util.exportExcel(response, list, "个人统计");
    }


    /**
     * 直推统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.DIRECT_PUSH_STAT, method = EOperationMethod.SELECT)
    @GetMapping("/directPushStatList")
    public TableDataInfo directPushStatList(DirectPushVO directPushVO) {
        Integer pkCountry = SecurityUtils.getPkCountry();
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();
        if (pkCountry.equals(CountryConstants.CHINA_COUNTRY)) {
            directPushVO.setRate(exchangeRate);
        } else {
            directPushVO.setRate(BigDecimal.ONE);
        }
        directPushVO.setPkCountry(pkCountry);
        List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(directPushVO.getOrderType());
        if (StringUtils.isNull(directPushVO.getStartDate()) ||
                StringUtils.isNull(directPushVO.getEndDate())) {
            return getDataTable(new ArrayList<>());
        }
        startPage();
        directPushVO.setOrderTypeList(orderTypeList);
        List<DirectPushVO> list = iCuMemberAwardsStatService.selectDirectPushStatList(directPushVO);
        return getDataTable(list);
    }

    /**
     * 导出直推统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.DIRECT_PUSH_STAT, method = EOperationMethod.EXPORT)
    @PostMapping("/export-directPush")
    public void exportDirectPush(HttpServletResponse response, DirectPushVO directPushVO) {
        Date date = DateUtils.currentDate();
        Integer pkCountry = SecurityUtils.getPkCountry();
        // 获取需要翻译的枚举翻译
        Map<String, String> transactionMap = iTransactionCommonService.exportEnumTransaction(EOrderBusiness.values());
        Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(EnumsPrefixConstants.KEY_GRADE,
                EnumsPrefixConstants.KEY_AWARD);
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();
        if (pkCountry.equals(CountryConstants.CHINA_COUNTRY)) {
            directPushVO.setRate(exchangeRate);
        } else {
            directPushVO.setRate(BigDecimal.ONE);
        }
        directPushVO.setPkCountry(pkCountry);
        List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(directPushVO.getOrderType());
        if (null == directPushVO.getOrderType()) {
            directPushVO.setOrderType(EOrderBusiness.WHOLE.getValue());
        }
        directPushVO.setOrderTypeList(orderTypeList);
        if (StringUtils.isNull(directPushVO.getStartDate()) ||
                StringUtils.isNull(directPushVO.getEndDate())) {
            return;
        }
        List<DirectPushVO> list = iCuMemberAwardsStatService.selectDirectPushStatList(directPushVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                itm.setPkAwardsVal(transactionMap1.get(itm.getPkAwards()));
                itm.setPkRegisterGradeVal(transactionMap1.get(itm.getPkRegisterGrade()));
                itm.setOrderTypeVal(transactionMap.get(EnumsPrefixConstants.ORDER_BUSINESS + itm.getOrderType().toString()));
            });
        }
        ExcelUtil<DirectPushVO> util = new ExcelUtil<>(DirectPushVO.class);
        util.exportExcel(response, list, "直推统计");
    }

    /**
     * 个人复购统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.PERSON_REPURCHASE, method = EOperationMethod.SELECT)
    @GetMapping("/personRepurchaseList")
    public TableDataInfo personRepurchaseList(PersonRepurchaseVO prVO) {
        if (StringUtils.isEmpty(prVO.getStartDate()) || StringUtils.isEmpty(prVO.getEndDate())) {
            return getDataTable(new ArrayList<>());
        }
        Integer pkCountry = SecurityUtils.getPkCountry();
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();
        prVO.setPkCountry(pkCountry);
        startPage();
        List<PersonRepurchaseVO> list = iCuMemberAwardsStatService.personRepurchaseList(prVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                if (itm.getRepurchaseAmount().compareTo(BigDecimal.ZERO) > 0) {
                    itm.setRepurchaseAmount(itm.getRepurchaseAmount().divide(exchangeRate, 2, BigDecimal.ROUND_HALF_UP));
                }
            });
        }
        return getDataTable(list);
    }

    /**
     * 导出个人复购统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.PERSON_REPURCHASE, method = EOperationMethod.EXPORT)
    @PostMapping("/export-personRepurchase")
    public void exportPersonRepurchase(HttpServletResponse response, PersonRepurchaseVO prVO) {
        if (StringUtils.isNotEmpty(prVO.getStartDate()) &&
                StringUtils.isNotEmpty(prVO.getEndDate())) {
            Integer pkCountry = SecurityUtils.getPkCountry();
            R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
            BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();
            prVO.setPkCountry(pkCountry);
            List<PersonRepurchaseVO> list = iCuMemberAwardsStatService.personRepurchaseList(prVO);
            if (CollectionUtil.isNotEmpty(list)) {
                Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(EnumsPrefixConstants.KEY_GRADE,
                        EnumsPrefixConstants.KEY_AWARD);
                list.forEach(itm -> {
                    if (itm.getRepurchaseAmount().compareTo(BigDecimal.ZERO) > 0) {
                        itm.setRepurchaseAmount(itm.getRepurchaseAmount().divide(exchangeRate, 2, BigDecimal.ROUND_HALF_UP));
                    }
                    itm.setPkAwardsVal(transactionMap1.get(itm.getPkAwards()));
                    itm.setPkSettleGradeVal(transactionMap1.get(itm.getPkSettleGrade()));
                });
            }
            ExcelUtil<PersonRepurchaseVO> util = new ExcelUtil<>(PersonRepurchaseVO.class);
            util.exportExcel(response, list, "个人复购统计");
        }
    }

    /**
     * 导出安置业绩统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.POSIT_STAT, method = EOperationMethod.EXPORT)
    @PostMapping("/export-positStat")
    public void exportPositStat(HttpServletResponse response, PositStatVO psVO) {
        if (StringUtils.isEmpty(psVO.getStartDate()) || StringUtils.isEmpty(psVO.getEndDate())) {
            return;
        }
        Integer pkCountry = SecurityUtils.getPkCountry();
        if (pkCountry.equals(CountryConstants.CHINA_COUNTRY)) {
            return;
        }
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.isSuccess() ? (currency.getData().getInExchangeRate() != null ? currency.getData().getInExchangeRate() : BigDecimal.ONE) : BigDecimal.ONE;

        psVO.setPkCountry(pkCountry);
        //查询国家全部会员
        List<PositStatVO> list = iCuMemberAwardsStatService.positStatList(psVO);
        List<PositStatVO> listNew = new ArrayList<>();

        if (CollectionUtil.isNotEmpty(list)) {
            List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(psVO.getOrderType());
            psVO.setOrderTypeList(orderTypeList);

            Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(EnumsPrefixConstants.KEY_GRADE, EnumsPrefixConstants.KEY_AWARD);

            for (PositStatVO ps : list) {
                psVO.setPkMember(ps.getPkMember());
                ps.setPkAwardsVal(transactionMap1.get(ps.getPkAwards()));
                ps.setPkSettleGradeVal(transactionMap1.get(ps.getPkSettleGrade()));
                //查询会员伞下安置业绩
                List<PositStatVO> achieveList = iCuMemberAwardsStatService.positStatAchieve(psVO);
                if (CollectionUtil.isNotEmpty(achieveList)) {
                    updateAchieveValues(achieveList, exchangeRate, ps);
                    listNew.add(ps);
                }
            }
        }

        ExcelUtil<PositStatVO> util = new ExcelUtil<>(PositStatVO.class);
        util.exportExcel(response, listNew, "安置业绩统计");
    }

    private void updateAchieveValues(List<PositStatVO> achieveList, BigDecimal exchangeRate, PositStatVO ps) {
        for (PositStatVO itmm : achieveList) {
            ps.setLeftAchieve(itmm.getLeftAchieve());
            ps.setLeftAmount(itmm.getLeftAmount().max(BigDecimal.ZERO).divide(exchangeRate, 2, BigDecimal.ROUND_HALF_UP));
            ps.setRightAchieve(itmm.getRightAchieve());
            ps.setRightAmount(itmm.getRightAmount().max(BigDecimal.ZERO).divide(exchangeRate, 2, BigDecimal.ROUND_HALF_UP));
        }
    }


    /**
     * 直推数据列表
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.DIRECT_PUSH_DATA, method = EOperationMethod.SELECT)
    @GetMapping("/directPushDataList")
    public TableDataInfo directPushDataList(DirectPushDataVO dpdVO) {
        if (StringUtils.isEmpty(dpdVO.getMemberName()) &&
                StringUtils.isEmpty(dpdVO.getMemberCode()) &&
                StringUtils.isNull(dpdVO.getDpNumber()) &&
                StringUtils.isNull(dpdVO.getOrderAchieve()) &&
                StringUtils.isEmpty(dpdVO.getPkRegisterGradeStr()) &&
                StringUtils.isNull(dpdVO.getPkVertex()) &&
                StringUtils.isNull(dpdVO.getStartDate()) &&
                StringUtils.isNull(dpdVO.getEndDate()) &&
                StringUtils.isNull(dpdVO.getYesNoAddress())) {
            return getDataTable(new ArrayList<>());
        }
        if (StringUtils.isNotEmpty(dpdVO.getPkRegisterGradeStr())) {
            List<Integer> pkIdList = Arrays.stream(dpdVO.getPkRegisterGradeStr().split(","))
                    .map(Integer::parseInt)
                    .collect(Collectors.toList());
            dpdVO.setPkRegisterGradeList(pkIdList);
        }

        Date date = DateUtils.currentDate();
        Integer pkCountry = SecurityUtils.getPkCountry();
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();
        if (pkCountry.equals(CountryConstants.CHINA_COUNTRY)) {
            dpdVO.setRate(exchangeRate);
            if (dpdVO.getOrderAchieve() != null) {
                dpdVO.setOrderAchieve(dpdVO.getOrderAchieve().divide(exchangeRate));
            }
        } else {
            dpdVO.setRate(BigDecimal.ONE);
        }
        dpdVO.setPkCountry(pkCountry);
        if (StringUtils.isEmpty(dpdVO.getStartDate()) ||
                StringUtils.isEmpty(dpdVO.getEndDate())) {
            //当前月第一天
            dpdVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
            dpdVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date)));
        }
        List<Integer> queryAwardsList = new ArrayList<>();
        // 查询总监级奖衔ID
        List<BdAwards> awardsList = iAwardsServiceApi.queryAwards(SecurityUtils.getPkCountry()).getData();
        if (CollectionUtil.isNotEmpty(awardsList)) {
            for (BdAwards bdAwards : awardsList) {
                if (bdAwards.getAwardsValue().equals(EAwards.CHIEF.getValue())
                        || bdAwards.getAwardsValue().equals(EAwards.HIGH_CHIEF.getValue())
                        || bdAwards.getAwardsValue().equals(EAwards.SENIOR_CHIEF.getValue())) {
                    queryAwardsList.add(bdAwards.getPkId());
                }
            }
        }
        dpdVO.setAwardsList(queryAwardsList);
        startPage();
        List<DirectPushDataVO> list = iCuMemberAwardsStatService.selectDirectPushDataList(dpdVO);
        if (CollectionUtil.isNotEmpty(list)) {
            // 获取行政区划map
            Map<Integer, String> areaMap = iAreaServiceApi.getAreaMap(SecurityUtils.getPkCountry()).getData();
            list.forEach(itm -> {
                if (StringUtils.isNotEmpty(itm.getParentChief())) {
                    // 处理所属总监
                    String tmpChief = itm.getParentChief().split(",")[0];
                    itm.setParentChief(tmpChief.split("-")[0]);
                    itm.setParentChiefName(tmpChief.split("-")[1]);
                    String address = "";
                    String recProvince = areaMap.get(itm.getPkProvince());
                    if (StringUtils.isNotEmpty(recProvince)) {
                        address += recProvince;
                    }
                    String recCity = areaMap.get(itm.getPkCity());
                    if (StringUtils.isNotEmpty(recCity)) {
                        address += recCity;
                    }
                    String recCounty = areaMap.get(itm.getPkCounty());
                    if (StringUtils.isNotEmpty(recCounty)) {
                        address += recCounty;
                    }
                    if (StringUtils.isNotEmpty(itm.getAddress())) {
                        address += itm.getAddress();
                    }
                    itm.setAddress(address);
                }
            });
        }
        return getDataTable(list);
    }


    /**
     * 导出直推数据
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.DIRECT_PUSH_DATA, method = EOperationMethod.EXPORT)
    @PostMapping("/export-directPushData")
    public void exportDirectPushData(HttpServletResponse response, DirectPushDataVO dpdVO) {
        if (StringUtils.isNotEmpty(dpdVO.getMemberName()) ||
                StringUtils.isNotEmpty(dpdVO.getMemberCode()) ||
                StringUtils.isNotNull(dpdVO.getDpNumber()) ||
                StringUtils.isNotNull(dpdVO.getOrderAchieve()) ||
                StringUtils.isEmpty(dpdVO.getPkRegisterGradeStr()) ||
                StringUtils.isNotNull(dpdVO.getPkVertex()) ||
                StringUtils.isNotNull(dpdVO.getStartDate()) ||
                StringUtils.isNotNull(dpdVO.getEndDate())) {
            if (StringUtils.isNotEmpty(dpdVO.getPkRegisterGradeStr())) {
                List<Integer> pkIdList = Arrays.stream(dpdVO.getPkRegisterGradeStr().split(","))
                        .map(Integer::parseInt)
                        .collect(Collectors.toList());
                dpdVO.setPkRegisterGradeList(pkIdList);
            }
            Date date = DateUtils.currentDate();
            Integer pkCountry = SecurityUtils.getPkCountry();
            R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
            BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();
            if (pkCountry.equals(CountryConstants.CHINA_COUNTRY)) {
                dpdVO.setRate(exchangeRate);
                if (dpdVO.getOrderAchieve() != null) {
                    dpdVO.setOrderAchieve(dpdVO.getOrderAchieve().divide(exchangeRate));
                }
            } else {
                dpdVO.setRate(BigDecimal.ONE);
            }
            dpdVO.setPkCountry(pkCountry);

            if (StringUtils.isEmpty(dpdVO.getStartDate()) ||
                    StringUtils.isEmpty(dpdVO.getEndDate())) {
                //当前月第一天
                dpdVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
                dpdVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date)));
            }
            List<Integer> queryAwardsList = new ArrayList<>();
            // 查询总监级奖衔ID
            List<BdAwards> awardsList = iAwardsServiceApi.queryAwards(SecurityUtils.getPkCountry()).getData();
            if (CollectionUtil.isNotEmpty(awardsList)) {
                for (BdAwards bdAwards : awardsList) {
                    if (bdAwards.getAwardsValue().equals(EAwards.CHIEF.getValue())
                            || bdAwards.getAwardsValue().equals(EAwards.HIGH_CHIEF.getValue())
                            || bdAwards.getAwardsValue().equals(EAwards.SENIOR_CHIEF.getValue())) {
                        queryAwardsList.add(bdAwards.getPkId());
                    }
                }
            }
            dpdVO.setAwardsList(queryAwardsList);
            List<DirectPushDataVO> list = iCuMemberAwardsStatService.selectDirectPushDataList(dpdVO);
            if (CollectionUtil.isNotEmpty(list)) {
                // 获取行政区划map
                Map<Integer, String> areaMap = iAreaServiceApi.getAreaMap(SecurityUtils.getPkCountry()).getData();
                list.forEach(itm -> {
                    if (StringUtils.isNotEmpty(itm.getParentChief())) {
                        // 处理所属总监
                        String tmpChief = itm.getParentChief().split(",")[0];
                        itm.setParentChief(tmpChief.split("-")[0]);
                        itm.setParentChiefName(tmpChief.split("-")[1]);
                        String address = "";
                        String recProvince = areaMap.get(itm.getPkProvince());
                        if (StringUtils.isNotEmpty(recProvince)) {
                            address += recProvince;
                        }
                        String recCity = areaMap.get(itm.getPkCity());
                        if (StringUtils.isNotEmpty(recCity)) {
                            address += recCity;
                        }
                        String recCounty = areaMap.get(itm.getPkCounty());
                        if (StringUtils.isNotEmpty(recCounty)) {
                            address += recCounty;
                        }
                        if (StringUtils.isNotEmpty(itm.getAddress())) {
                            address += itm.getAddress();
                        }
                        itm.setAddress(address);
                    }
                });
            }
            ExcelUtil<DirectPushDataVO> util = new ExcelUtil<>(DirectPushDataVO.class);
            util.exportExcel(response, list, "直推数据");
        }
    }

    /**
     * 直推数据详情
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.DIRECT_PUSH_DATA, method = EOperationMethod.SELECT)
    @GetMapping("/directPushDataDetails")
    public TableDataInfo directPushDataDetails(DirectPushDataVO dpdVO) {
        if (dpdVO.getPkMember() == null) {
            return getDataTable(new ArrayList<>());
        }
        Integer pkCountry = SecurityUtils.getPkCountry();
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();
        dpdVO.setRate(exchangeRate);
        dpdVO.setPkCountry(pkCountry);
        List<DirectPushDataVO> list = iCuMemberAwardsStatService.selectDirectPushDataDetails(dpdVO);
        return getDataTable(list);
    }


    /**
     * 直推数据-发送站内信展示
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.DIRECT_PUSH_DATA, method = EOperationMethod.CONFIRM)
    @GetMapping("/sendingMessages")
    public AjaxResult sendingMessages(DirectPushDataVO dpdVO) {
        List<Long> pkMemberList = new ArrayList<>();
        String pkMemberStr = dpdVO.getPkMemberStr();
        if (StringUtils.isNotEmpty(pkMemberStr)) {
            pkMemberList = Arrays.stream(pkMemberStr.split(","))
                    .map(Long::parseLong)
                    .collect(Collectors.toList());
        }
        //会员集合
        List<Long> pkMemberListMsg = new ArrayList<>();
        if (CollectionUtil.isEmpty(pkMemberList)) {
            if (StringUtils.isNotEmpty(dpdVO.getMemberName()) ||
                    StringUtils.isNotEmpty(dpdVO.getMemberCode()) ||
                    StringUtils.isNotNull(dpdVO.getDpNumber()) ||
                    StringUtils.isNotNull(dpdVO.getOrderAchieve()) ||
                    StringUtils.isNotEmpty(dpdVO.getPkRegisterGradeStr()) ||
                    StringUtils.isNotNull(dpdVO.getPkVertex()) ||
                    StringUtils.isNotNull(dpdVO.getStartDate()) ||
                    StringUtils.isNotNull(dpdVO.getEndDate())) {
                if (StringUtils.isNotEmpty(dpdVO.getPkRegisterGradeStr())) {
                    List<Integer> pkIdList = Arrays.stream(dpdVO.getPkRegisterGradeStr().split(","))
                            .map(Integer::parseInt)
                            .collect(Collectors.toList());
                    dpdVO.setPkRegisterGradeList(pkIdList);
                }
                //查询会员
                Date date = DateUtils.currentDate();
                Integer pkCountry = SecurityUtils.getPkCountry();
                R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
                BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();
                if (pkCountry.equals(CountryConstants.CHINA_COUNTRY)) {
                    dpdVO.setRate(exchangeRate);
                    if (dpdVO.getOrderAchieve() != null) {
                        dpdVO.setOrderAchieve(dpdVO.getOrderAchieve().divide(exchangeRate));
                    }
                } else {
                    dpdVO.setRate(BigDecimal.ONE);
                }
                dpdVO.setPkCountry(pkCountry);
                if (StringUtils.isEmpty(dpdVO.getStartDate()) ||
                        StringUtils.isEmpty(dpdVO.getEndDate())) {
                    //当前月第一天
                    dpdVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
                    dpdVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date)));
                }

                if (StringUtils.isNotEmpty(dpdVO.getMemberCode()) ||
                        StringUtils.isNotEmpty(dpdVO.getMemberName())) {
                    PersonStatVO personStatVO = new PersonStatVO();
                    personStatVO.setPkCountry(pkCountry);
                    personStatVO.setMemberCode(dpdVO.getMemberCode());
                    personStatVO.setMemberName(dpdVO.getMemberName());
                    List<PersonStatVO> memberlist = iCuMemberAwardsStatService.selectPersonStatList(personStatVO);
                    if (CollectionUtil.isNotEmpty(memberlist)) {
                        List<Long> finalPkMemberList = pkMemberList;
                        memberlist.forEach(itm ->
                                finalPkMemberList.add(itm.getPkMember())
                        );
                    }
                }

                dpdVO.setPkMemberList(pkMemberList);
                List<Integer> queryAwardsList = new ArrayList<>();
                // 查询总监级奖衔ID
                List<BdAwards> awardsList = iAwardsServiceApi.queryAwards(SecurityUtils.getPkCountry()).getData();
                if (CollectionUtil.isNotEmpty(awardsList)) {
                    for (BdAwards bdAwards : awardsList) {
                        if (bdAwards.getAwardsValue().equals(EAwards.CHIEF.getValue())
                                || bdAwards.getAwardsValue().equals(EAwards.HIGH_CHIEF.getValue())
                                || bdAwards.getAwardsValue().equals(EAwards.SENIOR_CHIEF.getValue())) {
                            queryAwardsList.add(bdAwards.getPkId());
                        }
                    }
                }
                dpdVO.setAwardsList(queryAwardsList);
                List<DirectPushDataVO> list = iCuMemberAwardsStatService.selectDirectPushDataList(dpdVO);
                if (CollectionUtil.isNotEmpty(list)) {
                    list.forEach(itm -> {
                        pkMemberListMsg.add(itm.getPkMember());
                    });
                }
            }
        }
        List<NoticeMemberVO> nmList = new ArrayList<>();
        if (CollectionUtil.isNotEmpty(pkMemberList)) {
            for (Long l : pkMemberList) {
                NoticeMemberVO nmvo = BeanUtil.copyProperties(dpdVO, NoticeMemberVO.class);
                nmvo.setPkMember(l);
                nmvo.setMemberCode(iMemberServiceApi.getMemberById(l).getData().getMemberCode());
                nmList.add(nmvo);
            }
        } else if (CollectionUtil.isNotEmpty(pkMemberListMsg)) {
            for (Long l : pkMemberListMsg) {
                NoticeMemberVO nmvo = BeanUtil.copyProperties(dpdVO, NoticeMemberVO.class);
                nmvo.setPkMember(l);
                nmvo.setMemberCode(iMemberServiceApi.getMemberById(l).getData().getMemberCode());
                nmList.add(nmvo);
            }
        }
        return AjaxResult.success(nmList);
    }


    /**
     * 直推数据-发送站内信-发起签呈
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.DIRECT_PUSH_DATA, method = EOperationMethod.SUBMIT)
    @PostMapping("/petition")
    public AjaxResult petition(@RequestBody NoticeMemberVO nmvo) {
        if (StringUtils.isNull(nmvo.getSignType())) {
            return AjaxResult.error(ConfigMsgConstants.SIGN_TYPE_NOT_NULL);
        }
        if (CollectionUtil.isEmpty(nmvo.getUserIdList())) {
            return AjaxResult.error(ConfigMsgConstants.EXAMINE_AND_APPROVE_NOT_NULL);
        }
        if (StringUtils.isEmpty(nmvo.getTitle())) {
            return AjaxResult.error(TransactionUtils.getContent(NoticeMsgConstants.TITLE_NOT_EMPTY));
        }
        if (StringUtils.isEmpty(nmvo.getContent())) {
            return AjaxResult.error(TransactionUtils.getContent(ConfigMsgConstants.HO_CONTENT_NOT_NULL));
        }
        Date date = new Date();
        Long userID = SecurityUtils.getUserId();
        Integer pkCountry = SecurityUtils.getPkCountry();
        LoginUser loginUser = userTokenService.getLoginUser();
        nmvo.setCreationTime(date);
        nmvo.setPkCountry(pkCountry);
        nmvo.setPkCreate(userID);
        nmvo.setApprovalBusiness(EApprovalBusiness.DIRECT_PUSH_DATA_MAIL.getValue());
        nmvo.setLoginUser(loginUser);
        return AjaxResult.success(iCuMemberAwardsStatService.petition(nmvo));
    }


    /**
     * 会员订单分布统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.ORDER_SCATTER, method = EOperationMethod.SELECT)
    @GetMapping("/memberOrderScatter")
    public TableDataInfo memberOrderScatter(OrderScatterVO orderScatterVO) {
        Date date = DateUtils.currentDate();
        Integer pkCountry = SecurityUtils.getPkCountry();
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();
        orderScatterVO.setRate(exchangeRate);
        orderScatterVO.setPkCountry(pkCountry);
        if (StringUtils.isNull(orderScatterVO.getStartDate()) ||
                StringUtils.isNull(orderScatterVO.getEndDate())) {
            //当前月第一天
            orderScatterVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
            orderScatterVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date)));
        }
        List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(orderScatterVO.getOrderType());

        orderScatterVO.setOrderTypeList(orderTypeList);
        startPage();
        List<OrderScatterVO> list = iCuMemberAwardsStatService.memberOrderScatter(orderScatterVO);
        return getDataTable(list);
    }

    /**
     * 导出会员订单分布统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.ORDER_SCATTER, method = EOperationMethod.EXPORT)
    @PostMapping("/export-OrderScatter")
    public void exportOrderScatter(HttpServletResponse response, OrderScatterVO orderScatterVO) {
        Date date = DateUtils.currentDate();
        Integer pkCountry = SecurityUtils.getPkCountry();
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();
        orderScatterVO.setRate(exchangeRate);
        orderScatterVO.setPkCountry(pkCountry);
        if (StringUtils.isNull(orderScatterVO.getStartDate()) ||
                StringUtils.isNull(orderScatterVO.getEndDate())) {
            //当前月第一天
            orderScatterVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
            orderScatterVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, date)));
        }
        List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(orderScatterVO.getOrderType());

        orderScatterVO.setOrderTypeList(orderTypeList);
        List<OrderScatterVO> list = iCuMemberAwardsStatService.memberOrderScatter(orderScatterVO);
        ExcelUtil<OrderScatterVO> util = new ExcelUtil<>(OrderScatterVO.class);
        util.exportExcel(response, list, "会员订单分布统计");
    }

    /**
     * 地区业绩统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AREA_ACHIEVE_STAT, method = EOperationMethod.SELECT)
    @GetMapping("/areaAchieveStat")
    public TableDataInfo areaAchieveStat(AreaAchieveStatVO areaAchieveStatVO) {
        Date date = DateUtils.currentDate();
        Integer pkCountry = SecurityUtils.getPkCountry();

        // 获取货币数据和汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();

        // 在输入对象中设置汇率和国家
        areaAchieveStatVO.setRate(exchangeRate);
        areaAchieveStatVO.setPkCountry(pkCountry);

        // 如果开始日期和结束日期为空，则设置开始日期和结束日期
        if (StringUtils.isNull(areaAchieveStatVO.getQueryTime())) {
            areaAchieveStatVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
            areaAchieveStatVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date));
        } else {
            Date sta = DateUtils.parseDate(areaAchieveStatVO.getQueryTime());
            areaAchieveStatVO.setStartDate(DateUtils.currentMonthFirstDateStr(sta));
            areaAchieveStatVO.setEndDate(DateUtils.currentMonthLastDateStr(sta));
        }

        // 获取行政区划map
        Map<Integer, String> areaMap = iAreaServiceApi.getAreaMap(pkCountry).getData();

        // 获取数据并按省份分组
        List<AreaAchieveStatVO> list = iCuMemberAwardsStatService.areaAchieveStat(areaAchieveStatVO);
        Map<Integer, List<AreaAchieveStatVO>> aasMap = list.stream().collect(Collectors.groupingBy(AreaAchieveStatVO::getReProvince));

        List<AreaAchieveStatVO> allList = new ArrayList<>();

        // 处理数据并更新订单金额和完成情况
        areaMap.forEach((key, value) -> {
            List<AreaAchieveStatVO> aasList = aasMap.get(key);
            AreaAchieveStatVO aasAll = new AreaAchieveStatVO();
            BigDecimal orderAmountSum = new BigDecimal(0);
            BigDecimal orderAchieveSum = new BigDecimal(0);
            if (CollectionUtil.isNotEmpty(aasList)) {
                for (AreaAchieveStatVO aas : aasList) {
                    orderAmountSum = orderAmountSum.add(aas.getOrderAmount());
                    orderAchieveSum = orderAchieveSum.add(aas.getOrderAchieve());
                    aasAll.setPrName(aas.getPrName());
                    aasAll.setOrderAmountSum(orderAmountSum.longValue());
                    aasAll.setOrderAchieveSum(orderAchieveSum.longValue());
                    switch (aas.getCreationTime()) {
                        case "01":
                            aasAll.setOrderAmount1(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve1(aas.getOrderAchieve().longValue());
                            break;
                        case "02":
                            aasAll.setOrderAmount2(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve2(aas.getOrderAchieve().longValue());
                            break;
                        case "03":
                            aasAll.setOrderAmount3(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve3(aas.getOrderAchieve().longValue());
                            break;
                        case "04":
                            aasAll.setOrderAmount4(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve4(aas.getOrderAchieve().longValue());
                            break;
                        case "05":
                            aasAll.setOrderAmount5(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve5(aas.getOrderAchieve().longValue());
                            break;
                        case "06":
                            aasAll.setOrderAmount6(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve6(aas.getOrderAchieve().longValue());
                            break;
                        case "07":
                            aasAll.setOrderAmount7(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve7(aas.getOrderAchieve().longValue());
                            break;
                        case "08":
                            aasAll.setOrderAmount8(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve8(aas.getOrderAchieve().longValue());
                            break;
                        case "09":
                            aasAll.setOrderAmount9(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve9(aas.getOrderAchieve().longValue());
                            break;
                        case "10":
                            aasAll.setOrderAmount10(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve10(aas.getOrderAchieve().longValue());
                            break;
                        case "11":
                            aasAll.setOrderAmount11(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve11(aas.getOrderAchieve().longValue());
                            break;
                        case "12":
                            aasAll.setOrderAmount12(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve12(aas.getOrderAchieve().longValue());
                            break;
                        case "13":
                            aasAll.setOrderAmount13(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve13(aas.getOrderAchieve().longValue());
                            break;
                        case "14":
                            aasAll.setOrderAmount14(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve14(aas.getOrderAchieve().longValue());
                            break;
                        case "15":
                            aasAll.setOrderAmount15(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve15(aas.getOrderAchieve().longValue());
                            break;
                        case "16":
                            aasAll.setOrderAmount16(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve16(aas.getOrderAchieve().longValue());
                            break;
                        case "17":
                            aasAll.setOrderAmount17(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve17(aas.getOrderAchieve().longValue());
                            break;
                        case "18":
                            aasAll.setOrderAmount18(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve18(aas.getOrderAchieve().longValue());
                            break;
                        case "19":
                            aasAll.setOrderAmount19(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve19(aas.getOrderAchieve().longValue());
                            break;
                        case "20":
                            aasAll.setOrderAmount20(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve20(aas.getOrderAchieve().longValue());
                            break;
                        case "21":
                            aasAll.setOrderAmount21(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve21(aas.getOrderAchieve().longValue());
                            break;
                        case "22":
                            aasAll.setOrderAmount22(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve22(aas.getOrderAchieve().longValue());
                            break;
                        case "23":
                            aasAll.setOrderAmount23(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve23(aas.getOrderAchieve().longValue());
                            break;
                        case "24":
                            aasAll.setOrderAmount24(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve24(aas.getOrderAchieve().longValue());
                            break;
                        case "25":
                            aasAll.setOrderAmount25(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve25(aas.getOrderAchieve().longValue());
                            break;
                        case "26":
                            aasAll.setOrderAmount26(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve26(aas.getOrderAchieve().longValue());
                            break;
                        case "27":
                            aasAll.setOrderAmount27(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve27(aas.getOrderAchieve().longValue());
                            break;
                        case "28":
                            aasAll.setOrderAmount28(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve28(aas.getOrderAchieve().longValue());
                            break;
                        case "29":
                            aasAll.setOrderAmount29(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve29(aas.getOrderAchieve().longValue());
                            break;
                        case "30":
                            aasAll.setOrderAmount30(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve30(aas.getOrderAchieve().longValue());
                            break;
                        case "31":
                            aasAll.setOrderAmount31(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve31(aas.getOrderAchieve().longValue());
                            break;
                        default:
                            break;
                    }
                }
                allList.add(aasAll);
            }
        });
        //统计全国
        AreaAchieveStatVO qg = new AreaAchieveStatVO();
        qg.setPrName("全国");
        for (int i = 1; i <= 31; i++) {
            int finalI = i;
            long orderAmountSum = allList.stream().mapToLong(data -> getPropertyValue(data, "getOrderAmount" + finalI)).sum();
            int finalI1 = i;
            long orderAchieveSum = allList.stream().mapToLong(data -> getPropertyValue(data, "getOrderAchieve" + finalI1)).sum();
            qg.setOrderAmount(i, orderAmountSum);
            qg.setOrderAchieve(i, orderAchieveSum);
        }
        qg.setOrderAmountSum(allList.stream().mapToLong(AreaAchieveStatVO::getOrderAmountSum).sum());
        qg.setOrderAchieveSum(allList.stream().mapToLong(AreaAchieveStatVO::getOrderAchieveSum).sum());
        allList.add(0, qg);
        return getDataTable(allList);
    }

    // 获取对象属性值的通用方法
    private long getPropertyValue(AreaAchieveStatVO data, String methodName) {
        long value = 0;
        try {
            Method method = AreaAchieveStatVO.class.getMethod(methodName);
            value = (long) method.invoke(data);
        } catch (Exception e) {
            // 异常处理
        }
        return value;
    }

    /**
     * 导出地区业绩统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AREA_ACHIEVE_STAT, method = EOperationMethod.EXPORT)
    @PostMapping("/export-areaAchieveStat")
    public void exportAreaAchieveStat(HttpServletResponse response, AreaAchieveStatVO areaAchieveStatVO) throws IOException {
        Date date = DateUtils.currentDate();
        Integer pkCountry = SecurityUtils.getPkCountry();
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();
        areaAchieveStatVO.setRate(exchangeRate);
        areaAchieveStatVO.setPkCountry(pkCountry);
        // 如果开始日期和结束日期为空，则设置开始日期和结束日期
        if (StringUtils.isNull(areaAchieveStatVO.getQueryTime())) {
            areaAchieveStatVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
            areaAchieveStatVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date));
        } else {
            Date sta = DateUtils.parseDate(areaAchieveStatVO.getQueryTime());
            areaAchieveStatVO.setStartDate(DateUtils.currentMonthFirstDateStr(sta));
            areaAchieveStatVO.setEndDate(DateUtils.currentMonthLastDateStr(sta));
        }
        // 获取行政区划map
        Map<Integer, String> areaMap = iAreaServiceApi.getAreaMap(pkCountry).getData();

        // 获取数据并按省份分组
        List<AreaAchieveStatVO> list = iCuMemberAwardsStatService.areaAchieveStat(areaAchieveStatVO);
        Map<Integer, List<AreaAchieveStatVO>> aasMap = list.stream().collect(Collectors.groupingBy(AreaAchieveStatVO::getReProvince));
        List<AreaAchieveStatVO> allList = new ArrayList<>();
        // 处理数据并更新订单金额和完成情况
        areaMap.forEach((key, value) -> {
            List<AreaAchieveStatVO> aasList = aasMap.get(key);
            AreaAchieveStatVO aasAll = new AreaAchieveStatVO();
            BigDecimal orderAmountSum = new BigDecimal(0);
            BigDecimal orderAchieveSum = new BigDecimal(0);
            if (CollectionUtil.isNotEmpty(aasList)) {
                for (AreaAchieveStatVO aas : aasList) {
                    orderAmountSum = orderAmountSum.add(aas.getOrderAmount());
                    orderAchieveSum = orderAchieveSum.add(aas.getOrderAchieve());
                    aasAll.setPrName(aas.getPrName());
                    aasAll.setOrderAmountSum(orderAmountSum.longValue());
                    aasAll.setOrderAchieveSum(orderAchieveSum.longValue());
                    switch (aas.getCreationTime()) {
                        case "01":
                            aasAll.setOrderAmount1(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve1(aas.getOrderAchieve().longValue());
                            break;
                        case "02":
                            aasAll.setOrderAmount2(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve2(aas.getOrderAchieve().longValue());
                            break;
                        case "03":
                            aasAll.setOrderAmount3(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve3(aas.getOrderAchieve().longValue());
                            break;
                        case "04":
                            aasAll.setOrderAmount4(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve4(aas.getOrderAchieve().longValue());
                            break;
                        case "05":
                            aasAll.setOrderAmount5(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve5(aas.getOrderAchieve().longValue());
                            break;
                        case "06":
                            aasAll.setOrderAmount6(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve6(aas.getOrderAchieve().longValue());
                            break;
                        case "07":
                            aasAll.setOrderAmount7(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve7(aas.getOrderAchieve().longValue());
                            break;
                        case "08":
                            aasAll.setOrderAmount8(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve8(aas.getOrderAchieve().longValue());
                            break;
                        case "09":
                            aasAll.setOrderAmount9(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve9(aas.getOrderAchieve().longValue());
                            break;
                        case "10":
                            aasAll.setOrderAmount10(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve10(aas.getOrderAchieve().longValue());
                            break;
                        case "11":
                            aasAll.setOrderAmount11(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve11(aas.getOrderAchieve().longValue());
                            break;
                        case "12":
                            aasAll.setOrderAmount12(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve12(aas.getOrderAchieve().longValue());
                            break;
                        case "13":
                            aasAll.setOrderAmount13(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve13(aas.getOrderAchieve().longValue());
                            break;
                        case "14":
                            aasAll.setOrderAmount14(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve14(aas.getOrderAchieve().longValue());
                            break;
                        case "15":
                            aasAll.setOrderAmount15(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve15(aas.getOrderAchieve().longValue());
                            break;
                        case "16":
                            aasAll.setOrderAmount16(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve16(aas.getOrderAchieve().longValue());
                            break;
                        case "17":
                            aasAll.setOrderAmount17(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve17(aas.getOrderAchieve().longValue());
                            break;
                        case "18":
                            aasAll.setOrderAmount18(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve18(aas.getOrderAchieve().longValue());
                            break;
                        case "19":
                            aasAll.setOrderAmount19(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve19(aas.getOrderAchieve().longValue());
                            break;
                        case "20":
                            aasAll.setOrderAmount20(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve20(aas.getOrderAchieve().longValue());
                            break;
                        case "21":
                            aasAll.setOrderAmount21(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve21(aas.getOrderAchieve().longValue());
                            break;
                        case "22":
                            aasAll.setOrderAmount22(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve22(aas.getOrderAchieve().longValue());
                            break;
                        case "23":
                            aasAll.setOrderAmount23(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve23(aas.getOrderAchieve().longValue());
                            break;
                        case "24":
                            aasAll.setOrderAmount24(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve24(aas.getOrderAchieve().longValue());
                            break;
                        case "25":
                            aasAll.setOrderAmount25(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve25(aas.getOrderAchieve().longValue());
                            break;
                        case "26":
                            aasAll.setOrderAmount26(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve26(aas.getOrderAchieve().longValue());
                            break;
                        case "27":
                            aasAll.setOrderAmount27(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve27(aas.getOrderAchieve().longValue());
                            break;
                        case "28":
                            aasAll.setOrderAmount28(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve28(aas.getOrderAchieve().longValue());
                            break;
                        case "29":
                            aasAll.setOrderAmount29(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve29(aas.getOrderAchieve().longValue());
                            break;
                        case "30":
                            aasAll.setOrderAmount30(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve30(aas.getOrderAchieve().longValue());
                            break;
                        case "31":
                            aasAll.setOrderAmount31(aas.getOrderAmount().longValue());
                            aasAll.setOrderAchieve31(aas.getOrderAchieve().longValue());
                            break;
                        default:
                            break;
                    }
                }
                allList.add(aasAll);
            }
        });
        //统计全国
        AreaAchieveStatVO qg = new AreaAchieveStatVO();
        qg.setPrName("全国");
        for (int i = 1; i <= 31; i++) {
            int finalI = i;
            long orderAmountSum = allList.stream().mapToLong(data -> getPropertyValue(data, "getOrderAmount" + finalI)).sum();
            int finalI1 = i;
            long orderAchieveSum = allList.stream().mapToLong(data -> getPropertyValue(data, "getOrderAchieve" + finalI1)).sum();
            qg.setOrderAmount(i, orderAmountSum);
            qg.setOrderAchieve(i, orderAchieveSum);
        }
        qg.setOrderAmountSum(allList.stream().mapToLong(AreaAchieveStatVO::getOrderAmountSum).sum());
        qg.setOrderAchieveSum(allList.stream().mapToLong(AreaAchieveStatVO::getOrderAchieveSum).sum());
        allList.add(0, qg);
        String fileName = DateUtils.parseDateToStr(DateUtils.YYYY_MM_CHINA, DateUtils.parseDate(areaAchieveStatVO.getStartDate())) + "订单统计表";
        iCuMemberAwardsStatService.exportExcelWithMergedCells(response, fileName, allList);
    }


    /**
     * 查询跨月时间
     **/
    public List<String> getStrideMonth(String startDate, String endDate) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDate start = LocalDate.parse(startDate, formatter);
        LocalDate end = LocalDate.parse(endDate, formatter);
        List<String> firstDaysOfMonth = new ArrayList<>();
        while (!start.isAfter(end)) {
            YearMonth yearMonth = YearMonth.from(start);
            LocalDate firstDayOfMonth = yearMonth.atDay(1);
            firstDaysOfMonth.add(firstDayOfMonth.format(formatter));
            start = start.plusMonths(1);
        }
        return firstDaysOfMonth;
    }

    /**
     * 伞下血缘去重
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AWARD_ANALYSIS, method = EOperationMethod.SELECT)
    @GetMapping("/blood-remove-same")
    public TableDataInfo bloodRemoveSameList(BloodRemoveSameVO bloodRemoveSameVO) {
        List<BloodRemoveSameVO> list = new ArrayList<>();
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        bloodRemoveSameVO.setPkCountry(SecurityUtils.getPkCountry());
        List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(bloodRemoveSameVO.getOrderType());
        bloodRemoveSameVO.setOrderTypeList(orderTypeList);
        List<Integer> pkAwardsList = new ArrayList<>();
        if (bloodRemoveSameVO.getPkAwardsLevel() != null) {
            if (bloodRemoveSameVO.getPkAwardsLevel() == EAwardsLevel.MANAGER_LEVEL.getValue()) {
                pkAwardsList.add(EAwards.MANAGER.getValue());
                pkAwardsList.add(EAwards.HIGH_MANAGER.getValue());
                pkAwardsList.add(EAwards.SENIOR_MANAGER.getValue());
            } else if (bloodRemoveSameVO.getPkAwardsLevel() == EAwardsLevel.CHIEF_LEVEL.getValue()) {
                pkAwardsList.add(EAwards.CHIEF.getValue());
                pkAwardsList.add(EAwards.HIGH_CHIEF.getValue());
                pkAwardsList.add(EAwards.SENIOR_CHIEF.getValue());
                pkAwardsList.add(EAwards.CHAIRMAN.getValue());
            } else if (bloodRemoveSameVO.getPkAwardsLevel() == EAwardsLevel.CHAIRMAN_LEVEL.getValue()) {
                pkAwardsList.add(EAwards.CHAIRMAN.getValue());
                pkAwardsList.add(EAwards.HONOR_CHAIRMAN.getValue());
                pkAwardsList.add(EAwards.GLOBAL_CHAIRMAN.getValue());
            }
            pkAwardsList = iCuMemberAwardsStatService.awardsLevellist(pkAwardsList, SecurityUtils.getPkCountry());
        }
        if (bloodRemoveSameVO.getPkAwards() != null) {
            pkAwardsList.add(bloodRemoveSameVO.getPkAwards());
        }
        if (CollectionUtil.isNotEmpty(pkAwardsList)) {
            bloodRemoveSameVO.setPkAwardsList(pkAwardsList);
        }
        if ((CollectionUtil.isEmpty(pkAwardsList) && null == bloodRemoveSameVO.getPkAwards())
                || StringUtils.isEmpty(bloodRemoveSameVO.getStartDate())
                || StringUtils.isEmpty(bloodRemoveSameVO.getEndDate())) {
            return getDataTable(list);
        }
        list = iCuMemberAwardsStatService.bloodRemoveSameList(bloodRemoveSameVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                itm.setOrderAchieve(itm.getOrderAchieve().multiply(currency.getData().getInExchangeRate()));
            });
        }
        return getDataTable(list);
    }

    /**
     * 伞下血缘去重历史数据
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AWARD_ANALYSIS, method = EOperationMethod.SELECT)
    @GetMapping("/blood-remove-same-history")
    public TableDataInfo bloodRemoveSameListHistory(BloodRemoveSameVO bloodRemoveSameVO) {
        List<BloodRemoveSameVO> list = new ArrayList<>();
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        bloodRemoveSameVO.setPkCountry(SecurityUtils.getPkCountry());
        List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(bloodRemoveSameVO.getOrderType());
        bloodRemoveSameVO.setOrderTypeList(orderTypeList);
        if (StringUtils.isNull(bloodRemoveSameVO.getOrderType())) {
            bloodRemoveSameVO.setOrderType(EOrderBusiness.WHOLE.getValue());
        }
        List<Integer> pkAwardsList = new ArrayList<>();
        if (bloodRemoveSameVO.getPkAwards() != null) {
            pkAwardsList.add(bloodRemoveSameVO.getPkAwards());
        }
        if (CollectionUtil.isNotEmpty(pkAwardsList)) {
            bloodRemoveSameVO.setPkAwardsList(pkAwardsList);
        }
        if ((CollectionUtil.isEmpty(pkAwardsList) && null == bloodRemoveSameVO.getPkAwards())
                || StringUtils.isEmpty(bloodRemoveSameVO.getStartDate())
                || StringUtils.isEmpty(bloodRemoveSameVO.getEndDate())) {
            return getDataTable(list);
        }
        //查询最新期数
        //开始时间减一天
        bloodRemoveSameVO.setStartDate(DateUtils.beforeDateStr(1, ChronoUnit.DAYS, DateUtils.YYYY_MM_DD, bloodRemoveSameVO.getStartDate()));
        bloodRemoveSameVO.setPeriodSta(iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                DateUtils.parseDateToStr(bloodRemoveSameVO.getStartDate())).getData().getPkId());
        bloodRemoveSameVO.setPeriodEnd(iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                DateUtils.parseDateToStr(bloodRemoveSameVO.getEndDate())).getData().getPkId());
        bloodRemoveSameVO.setAchieveTableNameSta(TableNameConstants.CU_MEMBER_ACHIEVE + DateUtils.getMonth(bloodRemoveSameVO.getStartDate()));
        bloodRemoveSameVO.setAchieveTableNameEnd(TableNameConstants.CU_MEMBER_ACHIEVE + DateUtils.getMonth(bloodRemoveSameVO.getEndDate()));
        bloodRemoveSameVO.setSettleTableNameSta(TableNameConstants.CU_MEMBER_TREE + DateUtils.getMonth(bloodRemoveSameVO.getStartDate()));
        bloodRemoveSameVO.setSettleTableNameEnd(TableNameConstants.CU_MEMBER_TREE + DateUtils.getMonth(bloodRemoveSameVO.getEndDate()));
        list = iCuMemberAwardsStatService.bloodRemoveSameListHistoryNew(bloodRemoveSameVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                itm.setOrderAchieve(itm.getOrderAchieve().multiply(currency.getData().getInExchangeRate()));
                itm.setOrderAmount(itm.getOrderAmount().multiply(currency.getData().getInExchangeRate()));
            });
        }
        return getDataTable(list);
    }


    /**
     * 导出伞下血缘去重
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AWARD_ANALYSIS, method = EOperationMethod.EXPORT)
    @PostMapping("/export-blood-remove-same")
    public void exportBloodRemoveSame(HttpServletResponse response, BloodRemoveSameVO bloodRemoveSameVO) {
        List<BloodRemoveSameVO> list = new ArrayList<>();
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(
                EnumsPrefixConstants.KEY_AWARD);
        bloodRemoveSameVO.setPkCountry(SecurityUtils.getPkCountry());
        List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(bloodRemoveSameVO.getOrderType());
        bloodRemoveSameVO.setOrderTypeList(orderTypeList);
        List<Integer> pkAwardsList = new ArrayList<>();
        if (bloodRemoveSameVO.getPkAwardsLevel() != null) {
            if (bloodRemoveSameVO.getPkAwardsLevel() == EAwardsLevel.MANAGER_LEVEL.getValue()) {
                pkAwardsList.add(EAwards.MANAGER.getValue());
                pkAwardsList.add(EAwards.HIGH_MANAGER.getValue());
                pkAwardsList.add(EAwards.SENIOR_MANAGER.getValue());
            } else if (bloodRemoveSameVO.getPkAwardsLevel() == EAwardsLevel.CHIEF_LEVEL.getValue()) {
                pkAwardsList.add(EAwards.CHIEF.getValue());
                pkAwardsList.add(EAwards.HIGH_CHIEF.getValue());
                pkAwardsList.add(EAwards.SENIOR_CHIEF.getValue());
                pkAwardsList.add(EAwards.CHAIRMAN.getValue());
            } else if (bloodRemoveSameVO.getPkAwardsLevel() == EAwardsLevel.CHAIRMAN_LEVEL.getValue()) {
                pkAwardsList.add(EAwards.CHAIRMAN.getValue());
                pkAwardsList.add(EAwards.HONOR_CHAIRMAN.getValue());
                pkAwardsList.add(EAwards.GLOBAL_CHAIRMAN.getValue());
            }
            pkAwardsList = iCuMemberAwardsStatService.awardsLevellist(pkAwardsList, SecurityUtils.getPkCountry());
        }
        if (bloodRemoveSameVO.getPkAwards() != null) {
            pkAwardsList.add(bloodRemoveSameVO.getPkAwards());
        }
        if (CollectionUtil.isNotEmpty(pkAwardsList)) {
            bloodRemoveSameVO.setPkAwardsList(pkAwardsList);
        }
        if ((CollectionUtil.isEmpty(pkAwardsList) && null == bloodRemoveSameVO.getPkAwards())
                || StringUtils.isEmpty(bloodRemoveSameVO.getStartDate())
                || StringUtils.isEmpty(bloodRemoveSameVO.getEndDate())) {
            ExcelUtil<BloodRemoveSameVO> util = new ExcelUtil<>(BloodRemoveSameVO.class);
            util.exportExcel(response, list, "伞下血缘去重");
        } else {
            list = iCuMemberAwardsStatService.bloodRemoveSameList(bloodRemoveSameVO);
            list.forEach(itm -> {
                itm.setOrderAchieve(itm.getOrderAchieve().multiply(currency.getData().getInExchangeRate()));
                itm.setPkAwardsVal(transactionMap1.get(itm.getPkAwards()));
            });
            ExcelUtil<BloodRemoveSameVO> util = new ExcelUtil<>(BloodRemoveSameVO.class);
            util.exportExcel(response, list, "伞下血缘去重");
        }
    }

    /**
     * 导出伞下血缘去重历史数据
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AWARD_ANALYSIS, method = EOperationMethod.EXPORT)
    @PostMapping("/export-blood-remove-same-history")
    public void exportBloodRemoveSameHistory(HttpServletResponse response, BloodRemoveSameVO bloodRemoveSameVO) {
        List<BloodRemoveSameVO> list = new ArrayList<>();
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(
                EnumsPrefixConstants.KEY_AWARD);
        bloodRemoveSameVO.setPkCountry(SecurityUtils.getPkCountry());
        List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(bloodRemoveSameVO.getOrderType());
        bloodRemoveSameVO.setOrderTypeList(orderTypeList);
        List<Integer> pkAwardsList = new ArrayList<>();
        if (StringUtils.isNull(bloodRemoveSameVO.getOrderType())) {
            bloodRemoveSameVO.setOrderType(EOrderBusiness.WHOLE.getValue());
        }
        if (bloodRemoveSameVO.getPkAwards() != null) {
            pkAwardsList.add(bloodRemoveSameVO.getPkAwards());
        }
        if (CollectionUtil.isNotEmpty(pkAwardsList)) {
            bloodRemoveSameVO.setPkAwardsList(pkAwardsList);
        }
        if ((CollectionUtil.isEmpty(pkAwardsList) && null == bloodRemoveSameVO.getPkAwards())
                || StringUtils.isEmpty(bloodRemoveSameVO.getStartDate())
                || StringUtils.isEmpty(bloodRemoveSameVO.getEndDate())) {
            ExcelUtil<BloodRemoveSameVO> util = new ExcelUtil<>(BloodRemoveSameVO.class);
            util.exportExcel(response, list, "伞下血缘去重");
        } else {
            //查询最新期数
            bloodRemoveSameVO.setStartDate(DateUtils.beforeDateStr(1, ChronoUnit.DAYS, DateUtils.YYYY_MM_DD, bloodRemoveSameVO.getStartDate()));
            bloodRemoveSameVO.setPeriodSta(iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                    DateUtils.parseDateToStr(bloodRemoveSameVO.getStartDate())).getData().getPkId());
            bloodRemoveSameVO.setPeriodEnd(iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                    DateUtils.parseDateToStr(bloodRemoveSameVO.getEndDate())).getData().getPkId());
            bloodRemoveSameVO.setAchieveTableNameSta(TableNameConstants.CU_MEMBER_ACHIEVE + DateUtils.getMonth(bloodRemoveSameVO.getStartDate()));
            bloodRemoveSameVO.setAchieveTableNameEnd(TableNameConstants.CU_MEMBER_ACHIEVE + DateUtils.getMonth(bloodRemoveSameVO.getEndDate()));
            bloodRemoveSameVO.setSettleTableNameSta(TableNameConstants.CU_MEMBER_TREE + DateUtils.getMonth(bloodRemoveSameVO.getStartDate()));
            bloodRemoveSameVO.setSettleTableNameEnd(TableNameConstants.CU_MEMBER_TREE + DateUtils.getMonth(bloodRemoveSameVO.getEndDate()));
            list = iCuMemberAwardsStatService.bloodRemoveSameListHistoryNew(bloodRemoveSameVO);
            list.forEach(itm -> {
                itm.setOrderAchieve(itm.getOrderAchieve().multiply(currency.getData().getInExchangeRate()));
                itm.setOrderAmount(itm.getOrderAmount().multiply(currency.getData().getInExchangeRate()));
                itm.setPkAwardsVal(transactionMap1.get(itm.getPkAwards()));
            });
            ExcelUtil<BloodRemoveSameVO> util = new ExcelUtil<>(BloodRemoveSameVO.class);
            util.exportExcel(response, list, "伞下血缘去重");
        }
    }

    /**
     * 安置血缘查询
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.RESETTLE_BLOOD, method = EOperationMethod.SELECT)
    @GetMapping("/resettle-blood-list")
    public TableDataInfo resettleBloodList(ResettleBloodVO resettleBloodVO) {
        resettleBloodVO.setPkCountry(SecurityUtils.getPkCountry());
        if (StringUtils.isNotEmpty(resettleBloodVO.getMemberCode())) {
            R<CuMemberExt> member = iMemberServiceApi.getMemberByCode(resettleBloodVO.getMemberCode());
            resettleBloodVO.setPkMember(member.getData().getPkId());
            resettleBloodVO.setMemberCode(member.getData().getMemberCode());
            resettleBloodVO.setMemberName(member.getData().getMemberName());
            resettleBloodVO.setCreationTime(member.getData().getCreationTime());
            List<ResettleBloodVO> list = iCuMemberAwardsStatService.resettleBloodList(resettleBloodVO);
            return getDataTable(list);
        } else {
            return getDataTable(new ArrayList<>());
        }
    }

    /**
     * 导出安置血缘查询
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.RESETTLE_BLOOD, method = EOperationMethod.EXPORT)
    @PostMapping("/resettle-blood-excel")
    public void resettleBloodExcel(HttpServletResponse response, ResettleBloodVO resettleBloodVO) {
        resettleBloodVO.setPkCountry(SecurityUtils.getPkCountry());
        if (StringUtils.isNotEmpty(resettleBloodVO.getMemberCode())) {
            R<CuMemberExt> member = iMemberServiceApi.getMemberByCode(resettleBloodVO.getMemberCode());
            resettleBloodVO.setPkMember(member.getData().getPkId());
            resettleBloodVO.setMemberCode(member.getData().getMemberCode());
            resettleBloodVO.setMemberName(member.getData().getMemberName());
            resettleBloodVO.setCreationTime(member.getData().getCreationTime());
            startPage();
            List<ResettleBloodVO> list = iCuMemberAwardsStatService.resettleBloodList(resettleBloodVO);
            List<ResettleBloodExcel> listExcel = new ArrayList<>();
            list.forEach(item -> listExcel.add(BeanUtil.copyProperties(item, ResettleBloodExcel.class)));
            ExcelUtil<ResettleBloodExcel> util = new ExcelUtil<>(ResettleBloodExcel.class);
            util.exportExcel(response, listExcel, "安置血缘查询");
        }
    }

    /**
     * 安置血缘查询-左右区人数详情列表
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.RESETTLE_DETAILS, method = EOperationMethod.SELECT)
    @GetMapping("/resettle-details-list")
    public TableDataInfo resettleDetailsList(ResettleBloodVO resettleBloodVO) {
        resettleBloodVO.setPkCountry(SecurityUtils.getPkCountry());
        startPage();
        List<ResettleBloodVO> list = iCuMemberAwardsStatService.lrMemberDetailsList(resettleBloodVO);
        return getDataTable(list);
    }

    /**
     * 安置血缘查询-左右区血缘人数详情列表
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.RESETTLE_BLOOD_DETAILS, method = EOperationMethod.SELECT)
    @GetMapping("/resettle-blood-details-list")
    public TableDataInfo resettleBloodDetailsList(ResettleBloodVO resettleBloodVO) {
        resettleBloodVO.setPkCountry(SecurityUtils.getPkCountry());
        startPage();
        List<ResettleBloodVO> list = iCuMemberAwardsStatService.lrbMemberDetailsList(resettleBloodVO);
        return getDataTable(list);
    }


    /**
     * 导出左右区血缘人数详情列表
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.RESETTLE_BLOOD_DETAILS, method = EOperationMethod.EXPORT)
    @PostMapping("/resettle-details-excel")
    public void resettleDetailsExcel(HttpServletResponse response, ResettleBloodVO resettleBloodVO) {
        resettleBloodVO.setPkCountry(SecurityUtils.getPkCountry());
        Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(
                EnumsPrefixConstants.KEY_AWARD, EnumsPrefixConstants.KEY_GRADE);
        List<ResettleBloodVO> list = iCuMemberAwardsStatService.lrMemberDetailsList(resettleBloodVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                itm.setPkAwardsVal(transactionMap1.get(itm.getPkAwards()));
                itm.setPkRegisterGradeVal(transactionMap1.get(itm.getPkRegisterGrade()));
            });
        }
        ExcelUtil<ResettleBloodVO> util = new ExcelUtil<>(ResettleBloodVO.class);
        util.exportExcel(response, list, "安置血缘查询");
    }

    /**
     * 导出左右区人数详情列表
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.RESETTLE_DETAILS, method = EOperationMethod.EXPORT)
    @PostMapping("/resettle-blood-details-excel")
    public void resettleBloodDetailsExcel(HttpServletResponse response, ResettleBloodVO resettleBloodVO) {
        resettleBloodVO.setPkCountry(SecurityUtils.getPkCountry());
        Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(
                EnumsPrefixConstants.KEY_AWARD, EnumsPrefixConstants.KEY_GRADE);
        List<ResettleBloodVO> list = iCuMemberAwardsStatService.lrbMemberDetailsList(resettleBloodVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                itm.setPkAwardsVal(transactionMap1.get(itm.getPkAwards()));
                itm.setPkRegisterGradeVal(transactionMap1.get(itm.getPkRegisterGrade()));
            });
        }
        ExcelUtil<ResettleBloodVO> util = new ExcelUtil<>(ResettleBloodVO.class);
        util.exportExcel(response, list, "安置血缘查询");
    }


    /**
     * 伞下直推产品查询
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.UMBRELLA_BELOW_PRODUCT, method = EOperationMethod.SELECT)
    @GetMapping("/umbrella-below-product")
    public TableDataInfo umbrellaBelowProduct(UmbrellaBelowProductVO ubpVO) {
        if (StringUtils.isEmpty(ubpVO.getMemberCode())) {
            return getDataTable(new ArrayList<>());
        }
        ubpVO.setPkCountry(SecurityUtils.getPkCountry());
        if (ubpVO.getOrderType() == null) {
            ubpVO.setOrderType(EOrderBusiness.WHOLE.getValue());
        }
        List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(ubpVO.getOrderType());
        ubpVO.setOrderTypeList(orderTypeList);
        R<CuMemberExt> member = iMemberServiceApi.getMemberByCode(ubpVO.getMemberCode());
        ubpVO.setPkMember(member.getData().getPkId());
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        startPage();
        List<UmbrellaBelowProductVO> list = iCuMemberAwardsStatService.umbrellaBelowProductList(ubpVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                //业绩转为当前国家的汇率
                if (SecurityUtils.getPkCountry().equals(CountryConstants.CHINA_COUNTRY) &&
                        null != currency.getData().getInExchangeRate()) {
                    itm.setOrderAchieve(itm.getOrderAchieve().multiply(currency.getData().getInExchangeRate()));
                    itm.setOrderType(ubpVO.getOrderType());
                }
            });
        }
        return getDataTable(list);
    }

    /**
     * 导出伞下直推产品查询
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.UMBRELLA_BELOW_PRODUCT, method = EOperationMethod.EXPORT)
    @PostMapping("/umbrella-below-product-excel")
    public void umbrellaBelowProductExcel(HttpServletResponse response, UmbrellaBelowProductVO ubpVO) {
        if (StringUtils.isNotEmpty(ubpVO.getMemberCode())) {
            ubpVO.setPkCountry(SecurityUtils.getPkCountry());
            if (ubpVO.getOrderType() == null) {
                ubpVO.setOrderType(EOrderBusiness.WHOLE.getValue());
            }
            List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(ubpVO.getOrderType());
            ubpVO.setOrderTypeList(orderTypeList);
            R<CuMemberExt> member = iMemberServiceApi.getMemberByCode(ubpVO.getMemberCode());
            ubpVO.setPkMember(member.getData().getPkId());
            //查询当前国家的汇率
            R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
            startPage();
            List<UmbrellaBelowProductVO> list = iCuMemberAwardsStatService.umbrellaBelowProductList(ubpVO);
            if (CollectionUtil.isNotEmpty(list)) {
                Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(EnumsPrefixConstants.KEY_GRADE,
                        EnumsPrefixConstants.KEY_AWARD);
                // 获取需要翻译的枚举翻译
                Map<String, String> transactionMap = iTransactionCommonService.exportEnumTransaction(EOrderBusiness.values());
                list.forEach(itm -> {
                    //业绩转为当前国家的汇率
                    if (SecurityUtils.getPkCountry().equals(CountryConstants.CHINA_COUNTRY) &&
                            null != currency.getData().getInExchangeRate()) {
                        itm.setOrderAchieve(itm.getOrderAchieve().multiply(currency.getData().getInExchangeRate()));
                        itm.setOrderTypeVal(transactionMap.get(EnumsPrefixConstants.ORDER_BUSINESS + ubpVO.getOrderType()));
                        itm.setPkRegisterGradeVal(transactionMap1.get(itm.getPkRegisterGrade()));
                        itm.setPkAwardsVal(transactionMap1.get(itm.getPkAwards()));
                    }
                });
            }
            ExcelUtil<UmbrellaBelowProductVO> util = new ExcelUtil<>(UmbrellaBelowProductVO.class);
            util.exportExcel(response, list, "伞下直推产品查询");
        }
    }

    /**
     * 伞下直推产品去重
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.UMBRELLA_BELOW_REPEAT, method = EOperationMethod.SELECT)
    @GetMapping("/umbrella-below-repeat")
    public TableDataInfo umbrellaBelowRepeat(UmbrellaBelowRepeatVO ubrVO) {
        if (StringUtils.isEmpty(ubrVO.getMemberCode())) {
            return getDataTable(new ArrayList<>());
        }
        if (ubrVO.getOrderType() == null) {
            ubrVO.setOrderType(EOrderBusiness.WHOLE.getValue());
        }
        ubrVO.setPkCountry(SecurityUtils.getPkCountry());
        List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(ubrVO.getOrderType());
        ubrVO.setOrderTypeList(orderTypeList);
        R<CuMemberExt> member = iMemberServiceApi.getMemberByCode(ubrVO.getMemberCode());
        ubrVO.setPkMember(member.getData().getPkId());
        List<Long> pkMemberList = new ArrayList<>();
        if (StringUtils.isNotEmpty(ubrVO.getPkMemberStr())) {
            pkMemberList = Arrays.stream(ubrVO.getPkMemberStr().split(","))
                    .map(Long::parseLong).collect(Collectors.toList());
        }
        ubrVO.setPkMemberList(pkMemberList);
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        startPage();
        List<UmbrellaBelowRepeatVO> list = iCuMemberAwardsStatService.umbrellaBelowRepeatList(ubrVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                //业绩转为当前国家的汇率
                if (SecurityUtils.getPkCountry().equals(CountryConstants.CHINA_COUNTRY) &&
                        null != currency.getData().getInExchangeRate()) {
                    itm.setAchievement(itm.getAchievement().multiply(currency.getData().getInExchangeRate()));
                    itm.setTotalAchievement(itm.getTotalAchievement().multiply(currency.getData().getInExchangeRate()));
                }
            });
        }
        return getDataTable(list);
    }

    /**
     * 导出伞下直推产品去重
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.UMBRELLA_BELOW_REPEAT, method = EOperationMethod.EXPORT)
    @PostMapping("/umbrella-below-repeat-excel")
    public void umbrellaBelowRepeatExcel(HttpServletResponse response, UmbrellaBelowRepeatVO ubrVO) {
        if (StringUtils.isNotEmpty(ubrVO.getMemberCode())) {
            if (ubrVO.getOrderType() == null) {
                ubrVO.setOrderType(EOrderBusiness.WHOLE.getValue());
            }
            ubrVO.setPkCountry(SecurityUtils.getPkCountry());
            List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(ubrVO.getOrderType());
            ubrVO.setOrderTypeList(orderTypeList);
            R<CuMemberExt> member = iMemberServiceApi.getMemberByCode(ubrVO.getMemberCode());
            ubrVO.setPkMember(member.getData().getPkId());
            List<Long> pkMemberList = new ArrayList<>();
            if (StringUtils.isNotEmpty(ubrVO.getPkMemberStr())) {
                pkMemberList = Arrays.stream(ubrVO.getPkMemberStr().split(","))
                        .map(Long::parseLong).collect(Collectors.toList());
            }
            ubrVO.setPkMemberList(pkMemberList);
            //查询当前国家的汇率
            R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
            List<UmbrellaBelowRepeatVO> list = iCuMemberAwardsStatService.umbrellaBelowRepeatList(ubrVO);
            if (CollectionUtil.isNotEmpty(list)) {
                Map<String, String> transactionMap = iTransactionCommonService.exportEnumTransaction(EOrderType.values());
                list.forEach(itm -> {
                    //业绩转为当前国家的汇率
                    if (SecurityUtils.getPkCountry().equals(CountryConstants.CHINA_COUNTRY) &&
                            null != currency.getData().getInExchangeRate()) {
                        itm.setAchievement(itm.getAchievement().multiply(currency.getData().getInExchangeRate()));
                        itm.setTotalAchievement(itm.getTotalAchievement().multiply(currency.getData().getInExchangeRate()));
                        itm.setOrderTypeVal(transactionMap.get(EnumsPrefixConstants.ORDER_TYPE + itm.getOrderType()));
                    }
                });
            }
            ExcelUtil<UmbrellaBelowRepeatVO> util = new ExcelUtil<>(UmbrellaBelowRepeatVO.class);
            util.exportExcel(response, list, "伞下直推产品去重");
        }
    }

    /**
     * 伞下直推产品统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.STAT_PRODUCT, method = EOperationMethod.SELECT)
    @GetMapping("/stat-product")
    public TableDataInfo statProduct(StatProductVO sptVO) {
        if (StringUtils.isEmpty(sptVO.getMemberCode())) {
            return getDataTable(new ArrayList<>());
        }
        sptVO.setPkCountry(SecurityUtils.getPkCountry());
        if (sptVO.getOrderType() == null) {
            sptVO.setOrderType(EOrderBusiness.WHOLE.getValue());
        }
        List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(sptVO.getOrderType());
        sptVO.setOrderTypeList(orderTypeList);
        R<CuMemberExt> member = iMemberServiceApi.getMemberByCode(sptVO.getMemberCode());
        sptVO.setPkMember(member.getData().getPkId());
        List<Long> pkMemberList = new ArrayList<>();
        if (StringUtils.isNotEmpty(sptVO.getPkMemberStr())) {
            pkMemberList = Arrays.stream(sptVO.getPkMemberStr().split(","))
                    .map(Long::parseLong).collect(Collectors.toList());
        }
        sptVO.setPkMemberList(pkMemberList);
        //查询当前国家的汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        startPage();
        List<StatProductVO> list = iCuMemberAwardsStatService.statProductList(sptVO);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(itm -> {
                //业绩转为当前国家的汇率
                if (SecurityUtils.getPkCountry().equals(CountryConstants.CHINA_COUNTRY) &&
                        null != currency.getData().getInExchangeRate()) {
                    itm.setAchievement(itm.getAchievement().multiply(currency.getData().getInExchangeRate()));
                    itm.setOrderType(sptVO.getOrderType());
                }
            });
        }
        return getDataTable(list);
    }

    /**
     * 导出伞下直推产品统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.STAT_PRODUCT, method = EOperationMethod.EXPORT)
    @PostMapping("/stat-product-excel")
    public void statProductExcel(HttpServletResponse response, StatProductVO sptVO) {
        if (StringUtils.isNotEmpty(sptVO.getMemberCode())) {
            sptVO.setPkCountry(SecurityUtils.getPkCountry());
            if (sptVO.getOrderType() == null) {
                sptVO.setOrderType(EOrderBusiness.WHOLE.getValue());
            }
            List<Integer> orderTypeList = EOrderBusiness.getOrderTypeList(sptVO.getOrderType());
            sptVO.setOrderTypeList(orderTypeList);
            R<CuMemberExt> member = iMemberServiceApi.getMemberByCode(sptVO.getMemberCode());
            sptVO.setPkMember(member.getData().getPkId());
            List<Long> pkMemberList = new ArrayList<>();
            if (StringUtils.isNotEmpty(sptVO.getPkMemberStr())) {
                pkMemberList = Arrays.stream(sptVO.getPkMemberStr().split(","))
                        .map(Long::parseLong).collect(Collectors.toList());
            }
            sptVO.setPkMemberList(pkMemberList);
            //查询当前国家的汇率
            R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
            List<StatProductVO> list = iCuMemberAwardsStatService.statProductList(sptVO);
            if (CollectionUtil.isNotEmpty(list)) {
                list.forEach(itm -> {
                    //业绩转为当前国家的汇率
                    if (SecurityUtils.getPkCountry().equals(CountryConstants.CHINA_COUNTRY) &&
                            null != currency.getData().getInExchangeRate()) {
                        itm.setAchievement(itm.getAchievement().multiply(currency.getData().getInExchangeRate()));
                        itm.setOrderType(sptVO.getOrderType());
                    }
                });
            }
            ExcelUtil<StatProductVO> util = new ExcelUtil<>(StatProductVO.class);
            util.exportExcel(response, list, "伞下直推产品统计");
        }
    }


    /**
     * 会员户籍数据查询
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.DOMICILE_DATA_LIST, method = EOperationMethod.SELECT)
    @GetMapping("/domicileDataList")
    public TableDataInfo domicileDataList(DomicileDataVO ddVO) {
        if (StringUtils.isEmpty(ddVO.getMemberCode())) {
            return getDataTable(new ArrayList<>());
        }
        Date date = new Date();
        String endDateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date);
        endDateStr = DateUtils.beforeDateStr(1, ChronoUnit.DAYS, DateUtils.YYYY_MM_DD, endDateStr);
        //查询最新期数
        int endPeriod = iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                DateUtils.parseDateToStr(endDateStr)).getData().getPkId();
        String endAchieveTableName = TableNameConstants.CU_MEMBER_ACHIEVE + DateUtils.getMonth(endDateStr);
        Integer pkCountry = SecurityUtils.getPkCountry();
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.isSuccess() ? (currency.getData().getInExchangeRate() != null ? currency.getData().getInExchangeRate() : BigDecimal.ONE) : BigDecimal.ONE;
        ddVO.setEndPeriod(endPeriod);
        ddVO.setEndAchieveTableName(endAchieveTableName);
        ddVO.setPkCountry(pkCountry);
        R<CuMemberExt> member = iMemberServiceApi.getMemberByCode(ddVO.getMemberCode());
        ddVO.setPkMember(member.getData().getPkId());
        ddVO.setPhone(member.getData().getPhone());
        //会员户籍数据查询
        List<DomicileDataVO> list = iCuMemberAwardsStatService.domicileDataList(ddVO);

        if (CollectionUtil.isNotEmpty(list)) {

            for (DomicileDataVO dcd : list) {
                dcd.setLeftAchieve(dcd.getLeftAchieve().multiply(exchangeRate));
                dcd.setRightAchieve(dcd.getRightAchieve().multiply(exchangeRate));
            }
        }
        return getDataTable(list);
    }


    /**
     * 导出会员户籍数据查询
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.DOMICILE_DATA_LIST, method = EOperationMethod.EXPORT)
    @PostMapping("/export-domicileDataList")
    public void exportDomicileDataList(HttpServletResponse response, DomicileDataVO ddVO) {
        if (StringUtils.isEmpty(ddVO.getMemberCode())) {
            return;
        }
        Date date = new Date();
        String endDateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date);
        endDateStr = DateUtils.beforeDateStr(1, ChronoUnit.DAYS, DateUtils.YYYY_MM_DD, endDateStr);
        //查询最新期数
        int endPeriod = iCuMemberSettlePeriodServiceApi.getCuMemberSettlePeriodByDate(
                DateUtils.parseDateToStr(endDateStr)).getData().getPkId();
        String endAchieveTableName = TableNameConstants.CU_MEMBER_ACHIEVE + DateUtils.getMonth(endDateStr);
        Integer pkCountry = SecurityUtils.getPkCountry();
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.isSuccess() ? (currency.getData().getInExchangeRate() != null ? currency.getData().getInExchangeRate() : BigDecimal.ONE) : BigDecimal.ONE;
        ddVO.setEndPeriod(endPeriod);
        ddVO.setEndAchieveTableName(endAchieveTableName);
        ddVO.setPkCountry(pkCountry);
        R<CuMemberExt> member = iMemberServiceApi.getMemberByCode(ddVO.getMemberCode());
        ddVO.setPkMember(member.getData().getPkId());
        ddVO.setPhone(member.getData().getPhone());
        //查询国家全部会员
        List<DomicileDataVO> list = iCuMemberAwardsStatService.domicileDataList(ddVO);

        if (CollectionUtil.isNotEmpty(list)) {
            Map<Integer, String> transactionMap1 = iTransactionCommonService.exportEnumTransactionByDB(EnumsPrefixConstants.KEY_GRADE, EnumsPrefixConstants.KEY_AWARD);

            for (DomicileDataVO dcd : list) {
                dcd.setPkAwardsVal(transactionMap1.get(dcd.getPkAwards()));
                dcd.setLeftAchieve(dcd.getLeftAchieve().multiply(exchangeRate));
                dcd.setRightAchieve(dcd.getRightAchieve().multiply(exchangeRate));
            }
        }

        ExcelUtil<DomicileDataVO> util = new ExcelUtil<>(DomicileDataVO.class);
        util.exportExcel(response, list, "会员户籍数据查询");
    }

    /**
     * 系统业绩统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AREA_ACHIEVE_STAT, method = EOperationMethod.SELECT)
    @GetMapping("/vertexAchieveStat")
    public TableDataInfo vertexAchieveStat(VertexAchieveStatVO vertexAchieveStatVO) {
        Date date = DateUtils.currentDate();
        Integer pkCountry = SecurityUtils.getPkCountry();

        // 获取货币数据和汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();

        // 在输入对象中设置汇率和国家
        vertexAchieveStatVO.setRate(exchangeRate);
        vertexAchieveStatVO.setPkCountry(pkCountry);

        // 如果开始日期和结束日期为空，则设置开始日期和结束日期
        if (StringUtils.isNull(vertexAchieveStatVO.getQueryTime())) {
            vertexAchieveStatVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
            vertexAchieveStatVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date));
        } else {
            Date sta = DateUtils.parseDate(vertexAchieveStatVO.getQueryTime());
            vertexAchieveStatVO.setStartDate(DateUtils.currentMonthFirstDateStr(sta));
            vertexAchieveStatVO.setEndDate(DateUtils.currentMonthLastDateStr(sta));
        }

        // 体系map
        R<List<VertexDTO>> vt = iVertexServiceApi.findAllByPkCountry(SecurityUtils.getPkCountry());

        // 获取数据并按体系分组
        List<VertexAchieveStatVO> list = iCuMemberAwardsStatService.vertexAchieveStat(vertexAchieveStatVO);
        Map<Long, List<VertexAchieveStatVO>> vvtMap = list.stream().collect(Collectors.groupingBy(VertexAchieveStatVO::getPkVertex));

        List<VertexAchieveStatVO> allList = new ArrayList<>();

        if (CollectionUtil.isNotEmpty(vt.getData())) {
            Map<Long, VertexDTO> vtMap = vt.getData().stream().collect(Collectors.toMap(VertexDTO::getPkId, Function.identity()));
            // 处理数据并更新订单金额和完成情况
            vtMap.forEach((key, value) -> {
                List<VertexAchieveStatVO> vvtList = vvtMap.get(key);
                VertexAchieveStatVO aasAll = new VertexAchieveStatVO();
                BigDecimal orderAmountSum = new BigDecimal(0);
                BigDecimal orderAchieveSum = new BigDecimal(0);
                if (CollectionUtil.isNotEmpty(vvtList)) {
                    for (VertexAchieveStatVO vvt : vvtList) {
                        orderAmountSum = orderAmountSum.add(vvt.getOrderAmount());
                        orderAchieveSum = orderAchieveSum.add(vvt.getOrderAchieve());
                        aasAll.setVertexName(vvt.getVertexName());
                        aasAll.setOrderAmountSum(orderAmountSum.longValue());
                        aasAll.setOrderAchieveSum(orderAchieveSum.longValue());
                        switch (vvt.getCreationTime()) {
                            case "01":
                                aasAll.setOrderAmount1(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve1(vvt.getOrderAchieve().longValue());
                                break;
                            case "02":
                                aasAll.setOrderAmount2(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve2(vvt.getOrderAchieve().longValue());
                                break;
                            case "03":
                                aasAll.setOrderAmount3(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve3(vvt.getOrderAchieve().longValue());
                                break;
                            case "04":
                                aasAll.setOrderAmount4(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve4(vvt.getOrderAchieve().longValue());
                                break;
                            case "05":
                                aasAll.setOrderAmount5(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve5(vvt.getOrderAchieve().longValue());
                                break;
                            case "06":
                                aasAll.setOrderAmount6(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve6(vvt.getOrderAchieve().longValue());
                                break;
                            case "07":
                                aasAll.setOrderAmount7(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve7(vvt.getOrderAchieve().longValue());
                                break;
                            case "08":
                                aasAll.setOrderAmount8(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve8(vvt.getOrderAchieve().longValue());
                                break;
                            case "09":
                                aasAll.setOrderAmount9(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve9(vvt.getOrderAchieve().longValue());
                                break;
                            case "10":
                                aasAll.setOrderAmount10(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve10(vvt.getOrderAchieve().longValue());
                                break;
                            case "11":
                                aasAll.setOrderAmount11(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve11(vvt.getOrderAchieve().longValue());
                                break;
                            case "12":
                                aasAll.setOrderAmount12(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve12(vvt.getOrderAchieve().longValue());
                                break;
                            case "13":
                                aasAll.setOrderAmount13(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve13(vvt.getOrderAchieve().longValue());
                                break;
                            case "14":
                                aasAll.setOrderAmount14(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve14(vvt.getOrderAchieve().longValue());
                                break;
                            case "15":
                                aasAll.setOrderAmount15(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve15(vvt.getOrderAchieve().longValue());
                                break;
                            case "16":
                                aasAll.setOrderAmount16(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve16(vvt.getOrderAchieve().longValue());
                                break;
                            case "17":
                                aasAll.setOrderAmount17(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve17(vvt.getOrderAchieve().longValue());
                                break;
                            case "18":
                                aasAll.setOrderAmount18(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve18(vvt.getOrderAchieve().longValue());
                                break;
                            case "19":
                                aasAll.setOrderAmount19(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve19(vvt.getOrderAchieve().longValue());
                                break;
                            case "20":
                                aasAll.setOrderAmount20(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve20(vvt.getOrderAchieve().longValue());
                                break;
                            case "21":
                                aasAll.setOrderAmount21(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve21(vvt.getOrderAchieve().longValue());
                                break;
                            case "22":
                                aasAll.setOrderAmount22(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve22(vvt.getOrderAchieve().longValue());
                                break;
                            case "23":
                                aasAll.setOrderAmount23(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve23(vvt.getOrderAchieve().longValue());
                                break;
                            case "24":
                                aasAll.setOrderAmount24(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve24(vvt.getOrderAchieve().longValue());
                                break;
                            case "25":
                                aasAll.setOrderAmount25(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve25(vvt.getOrderAchieve().longValue());
                                break;
                            case "26":
                                aasAll.setOrderAmount26(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve26(vvt.getOrderAchieve().longValue());
                                break;
                            case "27":
                                aasAll.setOrderAmount27(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve27(vvt.getOrderAchieve().longValue());
                                break;
                            case "28":
                                aasAll.setOrderAmount28(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve28(vvt.getOrderAchieve().longValue());
                                break;
                            case "29":
                                aasAll.setOrderAmount29(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve29(vvt.getOrderAchieve().longValue());
                                break;
                            case "30":
                                aasAll.setOrderAmount30(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve30(vvt.getOrderAchieve().longValue());
                                break;
                            case "31":
                                aasAll.setOrderAmount31(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve31(vvt.getOrderAchieve().longValue());
                                break;
                            default:
                                break;
                        }
                    }
                } else {
                    aasAll.setVertexName(value.getVertexName());
                }
                allList.add(aasAll);
            });
        }
        return getDataTable(allList);
    }

    /**
     * 导出系统业绩统计
     **/
    @Log(module = EOperationModule.STATISTIC_ANALYSIS, business = EOperationBusiness.AREA_ACHIEVE_STAT, method = EOperationMethod.EXPORT)
    @PostMapping("/export-vertexAchieveStat")
    public void exportvertexAchieveStat(HttpServletResponse response, VertexAchieveStatVO vertexAchieveStatVO) throws IOException {
        Date date = DateUtils.currentDate();
        Integer pkCountry = SecurityUtils.getPkCountry();

        // 获取货币数据和汇率
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(pkCountry);
        BigDecimal exchangeRate = currency.getData().getInExchangeRate() == null ? BigDecimal.ONE : currency.getData().getInExchangeRate();

        // 在输入对象中设置汇率和国家
        vertexAchieveStatVO.setRate(exchangeRate);
        vertexAchieveStatVO.setPkCountry(pkCountry);

        // 如果开始日期和结束日期为空，则设置开始日期和结束日期
        if (StringUtils.isNull(vertexAchieveStatVO.getQueryTime())) {
            vertexAchieveStatVO.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentMonthFirstDate()));
            vertexAchieveStatVO.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date));
        } else {
            Date sta = DateUtils.parseDate(vertexAchieveStatVO.getQueryTime());
            vertexAchieveStatVO.setStartDate(DateUtils.currentMonthFirstDateStr(sta));
            vertexAchieveStatVO.setEndDate(DateUtils.currentMonthLastDateStr(sta));
        }

        // 体系map
        R<List<VertexDTO>> vt = iVertexServiceApi.findAll();

        // 获取数据并按体系分组
        List<VertexAchieveStatVO> list = iCuMemberAwardsStatService.vertexAchieveStat(vertexAchieveStatVO);
        Map<Long, List<VertexAchieveStatVO>> vvtMap = list.stream().collect(Collectors.groupingBy(VertexAchieveStatVO::getPkVertex));

        List<VertexAchieveStatVO> allList = new ArrayList<>();

        if (CollectionUtil.isNotEmpty(vt.getData())) {
            Map<Long, VertexDTO> vtMap = vt.getData().stream().collect(Collectors.toMap(VertexDTO::getPkId, Function.identity()));
            // 处理数据并更新订单金额和完成情况
            vtMap.forEach((key, value) -> {
                List<VertexAchieveStatVO> vvtList = vvtMap.get(key);
                VertexAchieveStatVO aasAll = new VertexAchieveStatVO();
                BigDecimal orderAmountSum = new BigDecimal(0);
                BigDecimal orderAchieveSum = new BigDecimal(0);
                if (CollectionUtil.isNotEmpty(vvtList)) {
                    for (VertexAchieveStatVO vvt : vvtList) {
                        orderAmountSum = orderAmountSum.add(vvt.getOrderAmount());
                        orderAchieveSum = orderAchieveSum.add(vvt.getOrderAchieve());
                        aasAll.setVertexName(vvt.getVertexName());
                        aasAll.setOrderAmountSum(orderAmountSum.longValue());
                        aasAll.setOrderAchieveSum(orderAchieveSum.longValue());
                        switch (vvt.getCreationTime()) {
                            case "01":
                                aasAll.setOrderAmount1(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve1(vvt.getOrderAchieve().longValue());
                                break;
                            case "02":
                                aasAll.setOrderAmount2(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve2(vvt.getOrderAchieve().longValue());
                                break;
                            case "03":
                                aasAll.setOrderAmount3(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve3(vvt.getOrderAchieve().longValue());
                                break;
                            case "04":
                                aasAll.setOrderAmount4(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve4(vvt.getOrderAchieve().longValue());
                                break;
                            case "05":
                                aasAll.setOrderAmount5(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve5(vvt.getOrderAchieve().longValue());
                                break;
                            case "06":
                                aasAll.setOrderAmount6(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve6(vvt.getOrderAchieve().longValue());
                                break;
                            case "07":
                                aasAll.setOrderAmount7(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve7(vvt.getOrderAchieve().longValue());
                                break;
                            case "08":
                                aasAll.setOrderAmount8(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve8(vvt.getOrderAchieve().longValue());
                                break;
                            case "09":
                                aasAll.setOrderAmount9(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve9(vvt.getOrderAchieve().longValue());
                                break;
                            case "10":
                                aasAll.setOrderAmount10(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve10(vvt.getOrderAchieve().longValue());
                                break;
                            case "11":
                                aasAll.setOrderAmount11(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve11(vvt.getOrderAchieve().longValue());
                                break;
                            case "12":
                                aasAll.setOrderAmount12(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve12(vvt.getOrderAchieve().longValue());
                                break;
                            case "13":
                                aasAll.setOrderAmount13(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve13(vvt.getOrderAchieve().longValue());
                                break;
                            case "14":
                                aasAll.setOrderAmount14(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve14(vvt.getOrderAchieve().longValue());
                                break;
                            case "15":
                                aasAll.setOrderAmount15(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve15(vvt.getOrderAchieve().longValue());
                                break;
                            case "16":
                                aasAll.setOrderAmount16(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve16(vvt.getOrderAchieve().longValue());
                                break;
                            case "17":
                                aasAll.setOrderAmount17(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve17(vvt.getOrderAchieve().longValue());
                                break;
                            case "18":
                                aasAll.setOrderAmount18(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve18(vvt.getOrderAchieve().longValue());
                                break;
                            case "19":
                                aasAll.setOrderAmount19(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve19(vvt.getOrderAchieve().longValue());
                                break;
                            case "20":
                                aasAll.setOrderAmount20(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve20(vvt.getOrderAchieve().longValue());
                                break;
                            case "21":
                                aasAll.setOrderAmount21(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve21(vvt.getOrderAchieve().longValue());
                                break;
                            case "22":
                                aasAll.setOrderAmount22(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve22(vvt.getOrderAchieve().longValue());
                                break;
                            case "23":
                                aasAll.setOrderAmount23(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve23(vvt.getOrderAchieve().longValue());
                                break;
                            case "24":
                                aasAll.setOrderAmount24(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve24(vvt.getOrderAchieve().longValue());
                                break;
                            case "25":
                                aasAll.setOrderAmount25(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve25(vvt.getOrderAchieve().longValue());
                                break;
                            case "26":
                                aasAll.setOrderAmount26(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve26(vvt.getOrderAchieve().longValue());
                                break;
                            case "27":
                                aasAll.setOrderAmount27(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve27(vvt.getOrderAchieve().longValue());
                                break;
                            case "28":
                                aasAll.setOrderAmount28(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve28(vvt.getOrderAchieve().longValue());
                                break;
                            case "29":
                                aasAll.setOrderAmount29(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve29(vvt.getOrderAchieve().longValue());
                                break;
                            case "30":
                                aasAll.setOrderAmount30(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve30(vvt.getOrderAchieve().longValue());
                                break;
                            case "31":
                                aasAll.setOrderAmount31(vvt.getOrderAmount().longValue());
                                aasAll.setOrderAchieve31(vvt.getOrderAchieve().longValue());
                                break;
                            default:
                                break;
                        }
                    }
                } else {
                    aasAll.setVertexName(value.getVertexName());
                }
                allList.add(aasAll);
            });
        }
        String fileName = DateUtils.parseDateToStr(DateUtils.YYYY_MM_CHINA, DateUtils.parseDate(vertexAchieveStatVO.getStartDate())) + "系统统计表";
        iCuMemberAwardsStatService.exportExcelVertexWithMergedCells(response, fileName, allList);
    }

}
