package com.tofly.watermeter.custom.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.api.CertificationOrderClient;
import com.tofly.api.GdglinfoClient;
import com.tofly.api.order.OrderClient;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.core.util.Date8Util;
import com.tofly.common.core.util.DateUtil;
import com.tofly.common.core.util.StringUtil;
import com.tofly.common.oauth.exception.ToflyDeniedException;
import com.tofly.pojo.ReportOrderInfoVo;
import com.tofly.pojo.maintain.vo.datail.RepairOrderDetailVo;
import com.tofly.watermeter.custom.entity.meterRead.ReadSearch;
import com.tofly.watermeter.custom.entity.meterRead.readstatic.AccuracyCollect;
import com.tofly.watermeter.custom.entity.meterRead.readstatic.AuditMap;
import com.tofly.watermeter.custom.entity.quality.*;
import com.tofly.watermeter.custom.service.QualityStatisService;
import com.tofly.watermeter.em.Constant;
import com.tofly.watermeter.em.ExcelExportFileTypeEnum;
import com.tofly.watermeter.entity.*;
import com.tofly.watermeter.mapper.*;
import com.tofly.watermeter.service.QfcbqfmxService;
import com.tofly.watermeter.service.QfcbqfmxlsService;
import com.tofly.watermeter.util.JxlsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author FlashWJL
 * @date 2021/12/9 9:45
 */
@Service
public class QualityStatisServiceImpl implements QualityStatisService {

    @Autowired
    private ReadmeterMapper readmeterMapper;
    @Autowired
    private ReadmeterhisMapper readmeterhisMapper;
    @Autowired
    private CbqydwaterMapper cbqydwaterMapper;
    @Autowired
    private QfcbqfmxlsService qfcbqfmxlsService;
    @Autowired
    private QfcbqfmxService qfcbqfmxService;
    @Autowired
    private GdglinfoClient gdglinfoClient;
    @Autowired
    private OrderClient orderClient;
    @Autowired
    private CertificationOrderClient certificationOrderClient;
    @Autowired
    private QfkhjbxxMapper qfkhjbxxMapper;
    @Autowired
    private ReadmetereashisMapper readmetereashisMapper;

    @Override
    public List<Map<String, Object>> inspectCollect(QualityStatis qualityStatis, HttpServletResponse response) {
        //读取抽查比例配置
        Integer ratio = qualityStatis.getRatio();
        String template = qualityStatis.getTemplateFlag();
        String isGeneral = "1".equals(qualityStatis.getIsGeneral()) ? "1" : "0";
        qualityStatis.setIsGeneral(isGeneral);
        List<QualityResult> qualityResultList = readmeterMapper.inspectCollect(qualityStatis, ratio);
        //分组
        Map<String, List<QualityResult>> groupByQy = qualityResultList.stream().collect(Collectors.groupingBy(v -> v.getQybm() + "-" + v.getQymc()));
        List<Map<String, Object>> mapList = new ArrayList<>();
        final int[] i = {0};
        groupByQy.forEach((k, v) -> {
            i[0] = i[0] + 1;
            Map<String, Object> map = new HashMap<>();
            String[] qy = k.split("-");
            map.put("qybm", qy[0]);
            map.put("qymc", qy[1]);
            map.put("qydList", v);
            map.put("xh", i[0]);
            mapList.add(map);
        });
        //导出
        if ("1".equals(template)) {
            // 根据templateServiceType,templateFlag获取对应模板数据
            ExcelExportFileTypeEnum excelExportFileTypeEnum = ExcelExportFileTypeEnum.getExcelExportFileTypeEnum("qualityInspect", template);
            if (null == excelExportFileTypeEnum) {
                return null;
            }
            Map<String, Object> model = new HashMap<>(10);
            model.put("dataMap", mapList);
            // 从模型类型枚举根据templateServiceType获取策略对应模板数据
            JxlsUtils.exportExcel(excelExportFileTypeEnum, model, response, Constant.FILE_PATH_TEST_EXPORT_EXCEL);
            return null;
        }
        return mapList;
    }

    @Override
    public IPage<Readmeterhis> inspectCollectDeatils(Page page, QualityStatis qualityStatis, HttpServletResponse response) {
        String queryType = qualityStatis.getQueryType();
        String template = qualityStatis.getTemplateFlag();
        String qybm = qualityStatis.getCbqy();
        String cbqydbm = qualityStatis.getCbqyd();
        Date startTime = qualityStatis.getStartTime();
        Date endTime = qualityStatis.getEndTime();
        String cbqyd = qualityStatis.getCbqyd();
        String abnormal = qualityStatis.getAbnormal();
        String isGeneral = "1".equals(qualityStatis.getIsGeneral()) ? "1" : "0";
        qualityStatis.setIsGeneral(isGeneral);
        //区域、区段
        List<String> qybmList = null;
        List<String> qydbmList = null;
        if (StringUtil.isNotEmpty(qybm)) {
            qybmList = Arrays.asList(qybm.split(","));
        }
        if (StringUtil.isNotEmpty(cbqydbm)) {
            qydbmList = Arrays.asList(cbqydbm.split(","));
        }
        //异常类型ID集合
        List<String> abnormalList = null;
        if (StringUtil.isNotEmpty(abnormal)) {
            abnormalList = Arrays.asList(abnormal.split(","));
        }
        Integer queryCount = qualityStatis.getQueryCount();
        if ("1".equals(template)) {
            List<Readmeterhis> readmeterhisList = null;
            readmeterhisList = readmeterhisMapper.inspectCollectDeatilsList(qualityStatis, abnormalList, qybmList, qydbmList);
            ExcelExportFileTypeEnum excelExportFileTypeEnum = ExcelExportFileTypeEnum.getExcelExportFileTypeEnum("inspectCollectDeatils", template);
            if (null == excelExportFileTypeEnum) {
                return null;
            }
            Map<String, Object> model = new HashMap<>(10);
            model.put("dataMap", readmeterhisList);
            //设置excel表头名称，在excel中的直接用name即可将值取出来
            model.put("name", "抄表抽查详情列表");
            // 从模型类型枚举根据templateServiceType获取策略对应模板数据
            JxlsUtils.exportExcel(excelExportFileTypeEnum, model, response, Constant.FILE_PATH_TEST_EXPORT_EXCEL);
            return null;
        } else {
            IPage<Readmeterhis> iPage = null;
            iPage = readmeterhisMapper.inspectCollectDeatils(page, qualityStatis, abnormalList, qybmList, qydbmList);
            return iPage;
        }


    }

    @Override
    public List<QualityResult> analyzeCollect(QualityStatis qualityStatis, HttpServletResponse response) {
        if (StringUtils.isEmpty(qualityStatis.getIsGeneral())){
            throw new ToflyDeniedException("查询类型不能为空");
        }
        String template = qualityStatis.getTemplateFlag();
        String qybm = qualityStatis.getCbqy();
        List<String> qybmList = null;
        qualityStatis.setIsGeneral(qualityStatis.getIsGeneral());
        if (StringUtil.isNotEmpty(qybm)) {
            qybmList = Arrays.asList(qybm.split(","));
        }
        List<QualityResult> qualityResultList = readmeterMapper.analyzeCollect(qualityStatis, qybmList);
        return qualityResultList;
    }

    @Override
    public List<QualityResult> analyzeAbnromal(QualityStatis qualityStatis, HttpServletResponse response) {
        String qybm = qualityStatis.getCbqy();
        List<String> qybmList = null;
        qualityStatis.setIsGeneral(qualityStatis.getIsGeneral());
        if (StringUtil.isNotEmpty(qybm)) {
            qybmList = Arrays.asList(qybm.split(","));
        }
        return readmeterMapper.analyzeAbnromal(qualityStatis, qybmList);
    }

    @Override
    public IPage<Readmeterhis> analyzeCollectDetails(Page page, QualityStatis qualityStatis, HttpServletResponse response) {
        String queryType = qualityStatis.getQueryType();
        String template = qualityStatis.getTemplateFlag();
        String qybm = qualityStatis.getCbqy();
        String cbqydbm = qualityStatis.getCbqyd();
        String abnormal = qualityStatis.getAbnormal();
        qualityStatis.setIsGeneral(qualityStatis.getIsGeneral());
        //异常类型ID集合
        List<String> abnormalList = null;
        if (StringUtil.isNotEmpty(abnormal)) {
            abnormalList = Arrays.asList(abnormal.split(","));
        }
        //区域、区段
        List<String> qybmList = null;
        List<String> qydbmList = null;
        if (StringUtil.isNotEmpty(qybm)) {
            qybmList = Arrays.asList(qybm.split(","));
        }
        if (StringUtil.isNotEmpty(cbqydbm)) {
            qydbmList = Arrays.asList(cbqydbm.split(","));
        }
        if ("1".equals(template)) {
            List<Readmeterhis> readmeterhisList = null;
            readmeterhisList = readmeterhisMapper.inspectCollectDeatilsList(qualityStatis, abnormalList, qybmList, qydbmList);
            ExcelExportFileTypeEnum excelExportFileTypeEnum = ExcelExportFileTypeEnum.getExcelExportFileTypeEnum("inspectCollectDeatils", template);
            if (null == excelExportFileTypeEnum) {
                return null;
            }
            Map<String, Object> model = new HashMap<>(10);
            model.put("dataMap", readmeterhisList);
            //设置excel表头名称，在excel中的直接用name即可将值取出来
            model.put("name", "水量分析详情数据");
            // 从模型类型枚举根据templateServiceType获取策略对应模板数据
            JxlsUtils.exportExcel(excelExportFileTypeEnum, model, response, Constant.FILE_PATH_TEST_EXPORT_EXCEL);
            return null;
        } else {
            return readmeterhisMapper.inspectCollectDeatils(page, qualityStatis, abnormalList, qybmList, qydbmList);
        }

    }

    @Override
    public List<Cbqydwater> trendCollectOne(QualityStatis qualityStatis, HttpServletResponse response) {
        String qybm = qualityStatis.getCbqy();
        String startDate = qualityStatis.getStartDate();
        String endDate = qualityStatis.getEndDate();
        List<String> qybmList = null;
        String yearMonth = Date8Util.getYearMonth();
        Long end = Long.parseLong(endDate);
        Long current = Long.parseLong(yearMonth);
//        String isGeneral = "1".equals(qualityStatis.getIsGeneral()) ? "1" : "0";
        String isGeneral = qualityStatis.getIsGeneral();
        qualityStatis.setIsGeneral(isGeneral);
        List<Cbqydwater> cbqydwaterList = new ArrayList<>();
        if (StringUtil.isNotEmpty(qybm)) {
            qybmList = Arrays.asList(qybm.split(","));
        }
        if ("0".equals(isGeneral)) {
            //如果选择的时间比当前月份大，则需要当月本系统的抄表信息，历史水量信息由森鑫炬提供（王海提出的）；两个数据源都不一样，查来查去的，麻烦。。。。
            if (end.compareTo(current) != -1) {
                //如果开始时间都比当前月大，则直接返回null
                Long start = Long.parseLong(startDate);
                if (start.compareTo(current) == 1) {
                    return null;
                }
                //森鑫炬提供的历史水量
                cbqydwaterList = cbqydwaterMapper.getTrendCollectOneHistory(startDate, endDate, yearMonth, qybmList, "1");
                //当月水量
                cbqydwaterList.addAll(cbqydwaterMapper.getTrendCollectOne(null, null, isGeneral, yearMonth, qybmList));
                return cbqydwaterList;
            } else {
                //查询历史所有数据，不包括当月的
                cbqydwaterList = cbqydwaterMapper.getTrendCollectOneHistory(startDate, endDate, yearMonth, qybmList, null);
                return cbqydwaterList;
            }
        } else if ("1".equals(isGeneral)) {
            //卡表都走本系统
            return cbqydwaterMapper.getTrendCollectOne(startDate, endDate, isGeneral, null, qybmList);

        } else {
//            查询远程表
            return cbqydwaterMapper.trendCollectOne(startDate, endDate, isGeneral, null, qybmList);
        }

    }

    @Override
    public List<Cbqydwater> trendCollectTwo(QualityStatis qualityStatis, HttpServletResponse response) {
        String qybm = qualityStatis.getCbqy();
//        String isGeneral = "1".equals(qualityStatis.getIsGeneral()) ? "1" : "0";
        String isGeneral = qualityStatis.getIsGeneral();
        qualityStatis.setIsGeneral(isGeneral);
        String qydbm = qualityStatis.getCbqyd();
        List<String> qydbmList = null;
        String startDate = qualityStatis.getStartDate();
        String endDate = qualityStatis.getEndDate();
        String yearMonth = Date8Util.getYearMonth();
        Long end = Long.parseLong(endDate);
        Long current = Long.parseLong(yearMonth);
        List<Cbqydwater> cbqydwaterList = new ArrayList<>();
        if (StringUtil.isNotEmpty(qydbm)) {
            qydbmList = Arrays.asList(qydbm.split(","));
        }
        if ("0".equals(isGeneral)) {
            //如果选择的时间比当前月份大，则需要当月本系统的抄表信息，历史水量信息由森鑫炬提供
            if (end.compareTo(current) != -1) {
                //如果开始时间都比当前月大，则直接返回null
                Long start = Long.parseLong(startDate);
                if (start.compareTo(current) == 1) {
                    return null;
                }
                //森鑫炬提供的历史水量
                cbqydwaterList = cbqydwaterMapper.getTrendCollectTwoHistory(startDate, endDate, yearMonth, qydbmList, "1", qybm);
                //当月水量
                cbqydwaterList.addAll(cbqydwaterMapper.getTrendCollectTwo(null, null, isGeneral, qybm, yearMonth, qydbmList));
                return cbqydwaterList;
            } else {
                cbqydwaterList = cbqydwaterMapper.getTrendCollectTwoHistory(startDate, endDate, yearMonth, qydbmList, null, qybm);
                return cbqydwaterList;
            }
        } else if ("1".equals(isGeneral)) {
            return cbqydwaterMapper.getTrendCollectTwo(startDate, endDate, isGeneral, qybm, null, qydbmList);
        } else {
            return cbqydwaterMapper.trendCollectTwo(startDate, endDate, isGeneral, qybm, null, qydbmList);
        }

    }

    @Override
    public Object trendCollectThree(QualityStatis qualityStatis, HttpServletResponse response) {
        String qybm = qualityStatis.getCbqy();
        String qydbm = qualityStatis.getCbqyd();
        String startDate = qualityStatis.getStartDate();
        String endDate = qualityStatis.getEndDate();
        String currentMonth = Date8Util.getYearMonth();
        Long end = Long.parseLong(endDate);
        Long current = Long.parseLong(currentMonth);
//        String isGeneral = "1".equals(qualityStatis.getIsGeneral()) ? "1" : "0";
        String isGeneral = qualityStatis.getIsGeneral();
        qualityStatis.setIsGeneral(isGeneral);
        List<String> qybmList = null;
        List<String> qydbmList = null;
        List<Cbqydwater> cbqydwaterList;
        if (StringUtil.isNotEmpty(qybm)) {
            qybmList = Arrays.asList(qybm.split(","));
        }
        if (StringUtil.isNotEmpty(qydbm)) {
            qydbmList = Arrays.asList(qydbm.split(","));
        }
        if ("0".equals(isGeneral)) {
            //如果选择的时间比当前月份大，则需要当月本系统的抄表信息，历史水量信息由森鑫炬提供
            if (end.compareTo(current) != -1) {
                //如果开始时间都比当前月大，则直接返回null
                Long start = Long.parseLong(startDate);
                if (start.compareTo(current) == 1) {
                    return null;
                }
                //森鑫炬提供的历史水量
                cbqydwaterList = cbqydwaterMapper.getTrendCollectThreeHistory(startDate, endDate, currentMonth, qybmList, qydbmList, "1");
                //当月水量
                cbqydwaterList.addAll(cbqydwaterMapper.getTrendCollectThree(null, null, isGeneral, currentMonth, qybmList, qydbmList));
            } else {
                cbqydwaterList = cbqydwaterMapper.getTrendCollectThreeHistory(startDate, endDate, currentMonth, qybmList, qydbmList, null);
            }
        } else if ("1".equals(isGeneral)) {
            cbqydwaterList = cbqydwaterMapper.getTrendCollectThree(startDate, endDate, isGeneral, null, qybmList, qydbmList);
        } else {
            cbqydwaterList = cbqydwaterMapper.trendCollectThree(startDate, endDate, qybmList, qydbmList);
        }
        Map<String, List<Cbqydwater>> groupByCbqy = cbqydwaterList.stream().collect(Collectors.groupingBy(v -> v.getCbqyBm() + "-" + v.getCbqyMc()));
        List<Map<String, Object>> mapList = new ArrayList<>();
        groupByCbqy.forEach((k, v) -> {
            String[] cbqy = k.split("-");
            Map<String, Object> map = new HashMap(10);
            map.put("qybm", cbqy[0]);
            map.put("qymc", cbqy[1]);
            map.put("list", v);
            mapList.add(map);
        });
        return mapList;
    }

    @Override
    public IPage<Object> trendCollectFour(Page page, QualityStatis qualityStatis, HttpServletResponse response) {
        String isGeneral = "1".equals(qualityStatis.getIsGeneral()) ? "1" : "0";
        qualityStatis.setIsGeneral(isGeneral);
        String qybm = qualityStatis.getCbqy();
        String qydbm = qualityStatis.getCbqyd();
        String yearMonth = qualityStatis.getYearMonth();
        List<String> qybmList = null;
        List<String> qydbmList = null;
        if (StringUtil.isNotEmpty(qybm)) {
            qybmList = Arrays.asList(qybm.split(","));
        }
        if (StringUtil.isNotEmpty(qydbm)) {
            qydbmList = Arrays.asList(qydbm.split(","));
        }
        //机械表
        if ("0".equals(isGeneral)) {
            //获取当前年月；如果选择的时间是当前年月的，则查询当前月本系统抄表数据，否则查询森鑫炬抄表历史数据
            String currentMonth = Date8Util.getYearMonth();
            if (currentMonth.equals(yearMonth)) {
                return cbqydwaterMapper.getTrendCollectFour(page, qybmList, qydbmList, yearMonth, isGeneral);
            } else {
                return cbqydwaterMapper.getTrendCollectFourHistory(page, qybmList, qydbmList, yearMonth);
            }
        }
        //卡表
        else {
            return cbqydwaterMapper.getTrendCollectFour(page, qybmList, qydbmList, yearMonth, isGeneral);
        }


    }

    @Override
    public IPage<Map> queryCollect(Page page, QualityStatis qualityStatis, HttpServletResponse response) {
//        String isGeneral = "1".equals(qualityStatis.getIsGeneral()) ? "1" : "0";
        String isGeneral = qualityStatis.getIsGeneral();
        qualityStatis.setIsGeneral(isGeneral);
        String qydbm = qualityStatis.getCbqyd();
        List<String> qydbmList = null;
        Date startTime = qualityStatis.getStartTime();
        Date endTime = qualityStatis.getEndTime();
        if (StringUtil.isNotEmpty(qydbm)) {
            qydbmList = Arrays.asList(qydbm.split(","));
        }
        if (StringUtil.isNotNull(startTime) && StringUtil.isNotNull(endTime)) {
            //拼接年月
            qualityStatis.setStartDate(DateUtil.parseDateToStr("yyyy", startTime) + "01");
            qualityStatis.setEndDate(DateUtil.parseDateToStr("yyyy", endTime) + "12");
            String endDate = qualityStatis.getEndDate();
            String currentMonth = Date8Util.getYearMonth();
            Long end = Long.parseLong(endDate);
            Long current = Long.parseLong(currentMonth);
            if ("0".equals(isGeneral)) {
                //如果选择的时间比当前月份大，则需要当月本系统的抄表信息，历史水量信息由森鑫炬提供
                if (end.compareTo(current) != -1) {
                    //用 TF_YWPN_YHBINGQY_W 表为主表，然后关联查询森鑫炬历史水量表和本系统的当月抄表水量表
                    return readmeterMapper.queryCollectHistory(page, qualityStatis, qydbmList, currentMonth, isGeneral);
                }
                return readmeterMapper.queryCollect(page, qualityStatis, qydbmList);
            } else if ("1".equals(isGeneral)) {
                return readmeterMapper.queryCollectHistoryCard(page, qualityStatis, qydbmList, currentMonth, isGeneral);
            } else {
                return readmeterMapper.queryCollectHistoryCardTwo(page, qualityStatis, qydbmList, currentMonth, isGeneral);
            }
        }
        return null;
    }

    @Override
    public Object queryCollectDeatil(QualityStatis qualityStatis, HttpServletResponse response) {
//        String isGeneral = "1".equals(qualityStatis.getIsGeneral()) ? "1" : "0";
        String isGeneral = qualityStatis.getIsGeneral();
        qualityStatis.setIsGeneral(isGeneral);
        Date startTime = qualityStatis.getStartTime();
        Date endTime = qualityStatis.getEndTime();
        String yhbh = qualityStatis.getYhbh();
        String startDate;
        String endDate;
        if (StringUtil.isNotNull(startTime) && StringUtil.isNotNull(endTime)) {
            //拼接年月
            startDate = DateUtil.parseDateToStr("yyyy", startTime) + "01";
            endDate = DateUtil.parseDateToStr("yyyy", endTime) + "12";
            String currentMonth = Date8Util.getYearMonth();
            Long end = Long.parseLong(endDate);
            Long current = Long.parseLong(currentMonth);
            if ("0".equals(isGeneral)) {
                List<Qfcbqfmxls> qfcbqfmxlsList;
                //如果选择的时间比当前月份大，则需要当月本系统的抄表信息，历史水量信息由森鑫炬提供
                if (end.compareTo(current) > -1) {
                    qfcbqfmxlsList = qfcbqfmxlsService.list(Wrappers.<Qfcbqfmxls>lambdaQuery().eq(StringUtil.isNotEmpty(yhbh), Qfcbqfmxls::getYhbh, yhbh)
                            .between(StringUtil.isNotEmpty(startDate) && StringUtil.isNotEmpty(endDate), Qfcbqfmxls::getCbyf, startDate, endDate)
                            .select(Qfcbqfmxls::getYhbh, Qfcbqfmxls::getYhxm, Qfcbqfmxls::getCbsl, Qfcbqfmxls::getCbyf).orderByAsc(Qfcbqfmxls::getCbyf));

                    String collect = qfcbqfmxlsList.stream().filter(Objects::nonNull).map(Qfcbqfmxls::getCbyf).collect(Collectors.joining(","));
                    //不包含当前月份查询本地抄表记录
                    if (!collect.contains(current.toString())) {
                        Readmeterhis readmeterhis = readmeterhisMapper.selectOne(Wrappers.<Readmeterhis>lambdaQuery().eq(Readmeterhis::getMonthPlan, current)
                                .eq(Readmeterhis::getCbbz, "1").eq(Readmeterhis::getYhbh, yhbh)
                                .select(Readmeterhis::getYhbh, Readmeterhis::getCbsl, Readmeterhis::getCbyf, Readmeterhis::getMonthPlan));
                        if (StringUtil.isNotNull(readmeterhis)) {
                            Qfcbqfmxls qfcbqfmxls = new Qfcbqfmxls();
                            qfcbqfmxls.setYhbh(readmeterhis.getYhbh());
                            qfcbqfmxls.setCbsl(readmeterhis.getCbsl());
                            qfcbqfmxls.setCbyf(readmeterhis.getMonthPlan());
                            qfcbqfmxlsList.add(qfcbqfmxls);
                            qfcbqfmxlsList.sort(Comparator.comparing(Qfcbqfmxls::getCbyf));
                        }
                    }
                } else {
                    qfcbqfmxlsList = qfcbqfmxlsService.list(Wrappers.<Qfcbqfmxls>lambdaQuery().eq(StringUtil.isNotEmpty(yhbh), Qfcbqfmxls::getYhbh, yhbh)
                            .between(StringUtil.isNotEmpty(startDate) && StringUtil.isNotEmpty(endDate), Qfcbqfmxls::getCbyf, startDate, endDate)
                            .select(Qfcbqfmxls::getYhbh, Qfcbqfmxls::getYhxm, Qfcbqfmxls::getCbsl, Qfcbqfmxls::getCbyf).orderByAsc(Qfcbqfmxls::getCbyf));
                }
                if (qfcbqfmxlsList.size() > 0) {
                    //处理数据
                    Map<String, List<Qfcbqfmxls>> groupByCbyf = qfcbqfmxlsList.stream().collect(Collectors.groupingBy(v -> v.getCbyf().substring(0, 4)));
                    List<WaterQuery> mapList = new ArrayList<>();
                    groupByCbyf.forEach((k, v) -> {
                        WaterQuery map = new WaterQuery();
                        map.setYear(k + "年水量");
                        map.setList(v);
                        mapList.add(map);
                    });
                    mapList.sort(Comparator.comparing(WaterQuery::getYear));
                    return mapList;
                }

            } else if ("1".equals(isGeneral)) {
                List<Readmeterhis> readmeterhisList;
                readmeterhisList = readmeterhisMapper.selectList(Wrappers.<Readmeterhis>lambdaQuery().eq(StringUtil.isNotEmpty(yhbh), Readmeterhis::getYhbh, yhbh)
                        .between(StringUtil.isNotEmpty(startDate) && StringUtil.isNotEmpty(endDate), Readmeterhis::getCbyf, startDate, endDate)
                        .eq(Readmeterhis::getCbbz, "1")
                        .select(Readmeterhis::getYhbh, Readmeterhis::getYhxm, Readmeterhis::getCbsl, Readmeterhis::getCbyf).orderByAsc(Readmeterhis::getCbyf));
                if (readmeterhisList.size() > 0) {
                    //处理数据
                    Map<String, List<Readmeterhis>> groupByCbyf = readmeterhisList.stream().collect(Collectors.groupingBy(v -> v.getCbyf().substring(0, 4)));
                    List<WaterQuery> mapList = new ArrayList<>();
                    groupByCbyf.forEach((k, v) -> {
                        WaterQuery map = new WaterQuery();
                        map.setYear(k + "年水量");
                        map.setList(v);
                        mapList.add(map);
                    });
                    mapList.sort(Comparator.comparing(WaterQuery::getYear));
                    return mapList;
                }
                return null;
            } else {
                List<Readmetereashis> readmeterhisLis = readmetereashisMapper.getHisInfo(startDate, endDate, yhbh);

                if (readmeterhisLis.size() > 0) {
                    //处理数据
                    Map<String, List<Readmetereashis>> groupByCbyf = readmeterhisLis.stream().collect(Collectors.groupingBy(v -> v.getCbyf().substring(0, 4)));
                    List<WaterQuery> mapList = new ArrayList<>();
                    groupByCbyf.forEach((k, v) -> {
                        WaterQuery map = new WaterQuery();
                        map.setYear(k + "年水量");
                        map.setList(v);
                        mapList.add(map);
                    });
                    mapList.sort(Comparator.comparing(WaterQuery::getYear));
                    return mapList;
                }
                return null;
            }
        }
        return null;
    }


    @Override
    public Map<String, List<QualityFluctuate>> fluctuateCollect(QualityStatis qualityStatis, HttpServletResponse
            response) {
        String template = qualityStatis.getTemplateFlag();
        String qydbm = qualityStatis.getCbqyd();
        List<String> qydbmList = null;
        String qybm = qualityStatis.getCbqy();
        String yearMonth = qualityStatis.getYearMonth();
        Integer queryCount = qualityStatis.getQueryCount();
        String isGeneral = "1".equals(qualityStatis.getIsGeneral()) ? "1" : "0";
        qualityStatis.setIsGeneral(isGeneral);
        if (StringUtil.isNull(queryCount)) {
            throw new ToflyDeniedException("波动数必传");
        }
        String type = qualityStatis.getType();
        if (StringUtil.isNotEmpty(qydbm)) {
            qydbmList = Arrays.asList(qydbm.split(","));
        }
        //水表口径
        if ("1".equals(type)) {
            List<QualityFluctuate> qualityFluctuateUpList = readmeterhisMapper.getFluctuateBySbkjUp(qybm, isGeneral, yearMonth, queryCount, qydbmList);
            List<QualityFluctuate> qualityFluctuateDownList = readmeterhisMapper.getFluctuateBySbkjDown(qybm, isGeneral, yearMonth, queryCount, qydbmList);
            Map<String, List<QualityFluctuate>> map = new HashMap<>();
            map.put("uplist", qualityFluctuateUpList);
            map.put("downlist", qualityFluctuateDownList);
            return map;
        } else if ("2".equals(type)) {
            //用水性质
            List<QualityFluctuate> qualityFluctuateUpList = readmeterhisMapper.getFluctuateByYsxzUp(qybm, isGeneral, yearMonth, queryCount, qydbmList);
            List<QualityFluctuate> qualityFluctuateDownList = readmeterhisMapper.getFluctuateByYsxzDown(qybm, isGeneral, yearMonth, queryCount, qydbmList);
            Map<String, List<QualityFluctuate>> map = new HashMap<>();
            map.put("uplist", qualityFluctuateUpList);
            map.put("downlist", qualityFluctuateDownList);
            return map;
        } else if ("3".equals(type)) {
            //异常原因
            List<QualityFluctuate> qualityFluctuateUpList = readmeterhisMapper.getFluctuateByAbnomalUp(qybm, isGeneral, yearMonth, queryCount, qydbmList);
            List<QualityFluctuate> qualityFluctuateDownList = readmeterhisMapper.getFluctuateByAbnomalDown(qybm, isGeneral, yearMonth, queryCount, qydbmList);
            Map<String, List<QualityFluctuate>> map = new HashMap<>();
            map.put("uplist", qualityFluctuateUpList);
            map.put("downlist", qualityFluctuateDownList);
            return map;
        } else {
            throw new ToflyDeniedException("请正确查询汇总信息");
        }
    }

    @Override
    public IPage<Readmeterhis> fluctuateCollectDeatil(Page page, QualityStatis qualityStatis, HttpServletResponse
            response) {
        String isGeneral = "1".equals(qualityStatis.getIsGeneral()) ? "1" : "0";
        String template = qualityStatis.getTemplateFlag();
        String qydbm = qualityStatis.getCbqyd();
        List<String> qydbmList = null;
        String sbkj = qualityStatis.getSbkj();
        List<String> sbkjList = null;
        String abnormal = qualityStatis.getAbnormal();
        List<String> abnormalList = null;
        String ysxz = qualityStatis.getYsxz();
        List<String> ysxzList = null;
        String qybm = qualityStatis.getCbqy();
        String yearMonth = qualityStatis.getYearMonth();
        Integer queryCount = qualityStatis.getQueryCount();
        if (StringUtil.isNull(queryCount)) {
            throw new ToflyDeniedException("波动数必传");
        }
        String type = qualityStatis.getType();
        String queryType = qualityStatis.getQueryType();
        if (StringUtil.isNotEmpty(qydbm)) {
            qydbmList = Arrays.asList(qydbm.split(","));
        }
        if (StringUtil.isNotEmpty(sbkj)) {
            sbkjList = Arrays.asList(sbkj.split(","));
        }
        if (StringUtil.isNotEmpty(abnormal)) {
            abnormalList = Arrays.asList(abnormal.split(","));
        }
        if (StringUtil.isNotEmpty(ysxz)) {
            ysxzList = Arrays.asList(ysxz.split(","));
        }

        return readmeterhisMapper.fluctuateCollectDeatil(page, queryType, type, qybm, qydbmList, yearMonth, queryCount, sbkjList, abnormalList, ysxzList, isGeneral);
//        if (StringUtil.isNotNull(sbkjList) || StringUtil.isNotNull(abnormalList) || StringUtil.isNotNull(ysxzList)) {
//            return readmeterhisMapper.selectPage(page, Wrappers.<Readmeterhis>lambdaQuery()
//                    .eq(Readmeterhis::getCbbz, "1")
//                    .isNotNull(Readmeterhis::getShbz)
//                    .gt("5".equals(queryType), Readmeterhis::getContinuityUp, 0)
//                    .gt("6".equals(queryType), Readmeterhis::getContinuityDown, 0)
//                    .in("1".equals(type) && StringUtil.isNotNull(sbkjList), Readmeterhis::getSbkj, sbkjList)
//                    .in("2".equals(type) && StringUtil.isNotNull(abnormalList), Readmeterhis::getAbnomalId, abnormalList)
//                    .in("3".equals(type) && StringUtil.isNotNull(ysxzList), Readmeterhis::getYsxz, ysxzList)
//                    .eq(StringUtil.isNotEmpty(qybm), Readmeterhis::getCbqyBm, qybm)
//                    .in(StringUtil.isNotNull(qydbmList), Readmeterhis::getCbqydBm, qydbmList)
//                    .eq(StringUtil.isNotEmpty(yearMonth), Readmeterhis::getMonthPlan, yearMonth)
//                    .apply("ROWNUM <= " + queryCount)
//                    .orderByDesc(Readmeterhis::getSoleSign, Readmeterhis::getCbqyMc, Readmeterhis::getQydmc)
//                    .select(Readmeterhis::getYhbh, Readmeterhis::getYhxm, Readmeterhis::getCbqyMc, Readmeterhis::getQydmc,
//                            Readmeterhis::getYsxz, Readmeterhis::getSbkj, Readmeterhis::getAbnomalId, Readmeterhis::getAuditReason,
//                            Readmeterhis::getMonth1, Readmeterhis::getCbrq1, Readmeterhis::getCbyf, Readmeterhis::getCbsl, Readmeterhis::getSjsl));
//        }
//        //查看全部的情况
//        else {
//            return readmeterhisMapper.fluctuateCollectDeatil(page, queryType, type, qybm, qydbmList, yearMonth, queryCount , sbkjList , abnormalList , ysxzList);
//        }
    }

    @Override
    public ResultRespone<List<AccuracyCollect>> accuracyCollect(QualityStatis qualityStatis, HttpServletResponse
            response) {
        String cbry = qualityStatis.getCbryName();
        List<String> cbryList = null;
        String yearMonth = qualityStatis.getYearMonth();
        String isGeneral = "1".equals(qualityStatis.getIsGeneral()) ? "1" : "0";
        if (StringUtil.isNotEmpty(cbry)) {
            cbryList = Arrays.asList(cbry.split(","));
        }
        List<AccuracyCollect> accuracyCollectList = readmeterhisMapper.accuracyCollect(cbryList, yearMonth, isGeneral);
//        //处理数据
//        Map<String , List<AccuracyCollect>> groupCbryMap = accuracyCollectList.stream()
//                .collect(Collectors.groupingBy(v -> v.getCbry() + "-" + v.getCbryName()));
//        List<AccuracyCollect> result = new ArrayList<>();
//        groupCbryMap.forEach((k , v) -> {
//            AccuracyCollect collect = new AccuracyCollect();
//            Integer allNum = 0;
//            Integer accuracyAllNum = 0;
//            String[] cbryInfo = k.split("-");
//            collect.setCbry(Long.valueOf(cbryInfo[0]));
//            collect.setCbryName(cbryInfo[1]);
//            for (AccuracyCollect vv : v) {
//                allNum = allNum + vv.getAllNum();
//                accuracyAllNum = accuracyAllNum + vv.getAccuracyNum();
//            }
//            BigDecimal allBig = new BigDecimal(allNum);
//            BigDecimal accuracyBig = new BigDecimal(accuracyAllNum);
//            Float ratio = accuracyBig.divide(allBig , 3 , BigDecimal.ROUND_UP).multiply(ReadData.CALCULATE_HUNDRED.getYield()).floatValue();
//            collect.setAllAccuracyRatio(ratio);
//            collect.setList(v);
//            result.add(collect);
//        });
//        return ResultRespone.success(result);
        return ResultRespone.success(accuracyCollectList);
    }

    @Override
    public ResultRespone<IPage<AuditMap>> accuracyCollectDeatil(Page page, ReadSearch search, HttpServletResponse
            response) {
        String sspq = search.getSspq();
        String cbb = search.getCbb();
        String cbry = search.getCbryName();
        String cwyf = search.getCwyf();
        String isDis = search.getIsDis();
        String isGeneral = search.getIsGeneral();
        String template = search.getTemplateFlag();
        String state = search.getState();
        String issyn = search.getIssyn();
        String cbfs = search.getCbfs();
        String isEstimate = search.getIsEstimate();
        if (StringUtil.isEmpty(cwyf)) {
            throw new ToflyDeniedException("选择时间月份");
        } else if (StringUtil.isEmpty(isGeneral)) {
            throw new ToflyDeniedException("请选择计划类型");
        }
        List<String> qybmList = null;
        List<String> qydbmList = null;
        List<String> cbryList = null;
        List<String> cbfsList = null;
        if (StringUtil.isNotEmpty(sspq)) {
            qybmList = Arrays.asList(sspq.split(","));
        }
        if (StringUtil.isNotEmpty(cbb)) {
            qydbmList = Arrays.asList(cbb.split(","));
        }
        if (StringUtil.isNotEmpty(cbry)) {
            cbryList = Arrays.asList(cbry.split(","));
        }
        if (StringUtil.isNotEmpty(cbfs)) {
            cbfsList = Arrays.asList(cbfs.split(","));
        }
        if ("1".equals(template)) {
            List<AuditMap> list = qfcbqfmxService.getOfflineInfoList2(cwyf, qybmList, qydbmList, cbryList, isDis, isGeneral, state, isEstimate, issyn, cbfsList);
            // 根据templateServiceType,templateFlag获取对应模板数据，找到枚举中相应的Excel文件名、路径等信息
            ExcelExportFileTypeEnum excelExportFileTypeEnum =
                    ExcelExportFileTypeEnum.getExcelExportFileTypeEnum("offlineInfo", template);
            if (null == excelExportFileTypeEnum) {
                return null;
            }
            Map<String, Object> model = new HashMap<>(10);
            model.put("dataMap", list);
            JxlsUtils.exportExcel(excelExportFileTypeEnum, model, response, Constant.FILE_PATH_TEST_EXPORT_EXCEL);
            return null;
        } else {
            IPage<AuditMap> iPage = qfcbqfmxService.getOfflineInfo2(page, cwyf, qybmList, qydbmList, cbryList, isDis, isGeneral, state, isEstimate, issyn, cbfsList);
            return ResultRespone.success(iPage);
        }

    }


    @Override
    public IPage<AuditMap> cardUpdateTwo(Page page, ReadSearch search, HttpServletResponse response) {
        String sspq = search.getSspq();
        String cbb = search.getCbb();
        String cbry = search.getCbryName();
        String cwyf = search.getCwyf();
        String isGeneral = search.getIsGeneral();
        String state = search.getState();
        String inputContent = search.getInputContent();
        String isUpdate = search.getIsUpdate();
        if (StringUtil.isEmpty(cwyf)) {
            throw new ToflyDeniedException("选择时间月份");
        } else if (StringUtil.isEmpty(isGeneral)) {
            throw new ToflyDeniedException("请选择计划类型");
        }
        List<String> qybmList = null;
        List<String> qydbmList = null;
        List<String> cbryList = null;
        if (StringUtil.isNotEmpty(sspq)) {
            qybmList = Arrays.asList(sspq.split(","));
        }
        if (StringUtil.isNotEmpty(cbb)) {
            qydbmList = Arrays.asList(cbb.split(","));
        }
        if (StringUtil.isNotEmpty(cbry)) {
            cbryList = Arrays.asList(cbry.split(","));
        }
//        if ("1".equals(template)) {
//            List<AuditMap> list = qfcbqfmxService.getOfflineInfoList2(cwyf, qybmList, qydbmList, cbryList, isDis, isGeneral, state, isEstimate, issyn, cbfsList);
//            // 根据templateServiceType,templateFlag获取对应模板数据，找到枚举中相应的Excel文件名、路径等信息
//            ExcelExportFileTypeEnum excelExportFileTypeEnum =
//                    ExcelExportFileTypeEnum.getExcelExportFileTypeEnum("offlineInfo", template);
//            if (null == excelExportFileTypeEnum) {
//                return null;
//            }
//            Map<String, Object> model = new HashMap<>(10);
//            model.put("dataMap", list);
//            JxlsUtils.exportExcel(excelExportFileTypeEnum, model, response, Constant.FILE_PATH_TEST_EXPORT_EXCEL);
//            return null;
//        } else {
        IPage<AuditMap> iPage = qfcbqfmxService.cardUpdateTwo(page, cwyf, qybmList, qydbmList, cbryList, isGeneral, state, inputContent, isUpdate);
        return iPage;
//        }
    }

    @Override
    public ResultRespone<IPage<QualityEvent>> eventCollect(Page page, ReadSearch search, HttpServletResponse
            response) {
        String inputcontent = search.getInputContent();
        String startTime = search.getStartTime();
        String endTime = search.getEndTime();
        Date startDate = null;
        Date endDate = null;
        if (StringUtil.isNotEmpty(startTime)) {
            startDate = cn.hutool.core.date.DateUtil.beginOfMonth(DateUtil.formatDate(startTime, "yyyyMM"));
            //没传递结束时间，默认今天
            if (StringUtil.isEmpty(endTime)) {
                endDate = cn.hutool.core.date.DateUtil.endOfMonth(new Date());
            } else {
                endDate = cn.hutool.core.date.DateUtil.endOfMonth(DateUtil.formatDate(endTime, "yyyyMM"));
            }
        }
//        else {
//            throw new ToflyDeniedException("请选择时间段");
//        }

        return ResultRespone.success(readmeterhisMapper.eventCollect(page, inputcontent, startDate, endDate));
    }

    @Override
    public ResultRespone<List<QualityEventInfo>> eventCollectInfo(ReadSearch search, HttpServletResponse response) {
        String yhbh = search.getYhbh();
        String startTime = search.getStartTime();
        String endTime = search.getEndTime();
        Date startDate = null;
        Date endDate = null;
        if (StringUtil.isNotEmpty(startTime)) {
            startDate = cn.hutool.core.date.DateUtil.beginOfMonth(DateUtil.formatDate(startTime, "yyyyMM"));
            //没传递结束时间，默认今天
            if (StringUtil.isEmpty(endTime)) {
                endDate = cn.hutool.core.date.DateUtil.endOfMonth(new Date());
            } else {
                endDate = cn.hutool.core.date.DateUtil.endOfMonth(DateUtil.formatDate(endTime, "yyyyMM"));
            }
        } else {
            throw new ToflyDeniedException("请选择时间段");
        }
        //抄表事件
        List<QualityEventInfo> cbEventInfo = readmeterhisMapper.getCbEventInfo(yhbh, startDate, endDate);
        List<QualityEventInfo> eventInfoList = new ArrayList<>();
        if (StringUtil.isNotNull(cbEventInfo)) {
            eventInfoList.addAll(cbEventInfo);
        }
        //业务工单事件
        List<QualityEventInfo> GdEventInfo = readmeterhisMapper.getGdEventInfo(yhbh, startDate, endDate);
        if (StringUtil.isNotNull(GdEventInfo)) {
            eventInfoList.addAll(GdEventInfo);
        }
        //质检事件
        List<QualityEventInfo> ZjEventInfo = readmeterhisMapper.getZjEventInfo(yhbh, startDate, endDate);
        if (StringUtil.isNotNull(ZjEventInfo)) {
            eventInfoList.addAll(ZjEventInfo);
        }
        //根据时间降序排序
        eventInfoList.sort(Comparator.comparing(QualityEventInfo::getEventtime, Comparator.reverseOrder()));
        return ResultRespone.success(eventInfoList);
    }

    @Override
    public ResultRespone<Object> eventById(String eventid, String eventtype, String qwxid, HttpServletResponse
            response) {
//        @ApiModelProperty(value = "事件类型；1：抄表事件，2：业务工单事件，3：质检事件，4：表务事件")
//        private String eventtype;
        if (StringUtil.isEmpty(eventid)) {
            throw new ToflyDeniedException("请传递事件唯一标识");
        }
        if (StringUtil.isEmpty(eventtype)) {
            throw new ToflyDeniedException("请传递事件类型");
        }
        //抄表事件
        if ("1".equals(eventtype)) {
            Readmeterhis readmeterhis = readmeterhisMapper.selectOne(Wrappers.<Readmeterhis>lambdaQuery().eq(Readmeterhis::getSoleSign, eventid));
            if (readmeterhis != null && !StringUtils.isEmpty(readmeterhis.getFileid())) {
                readmeterhis.setFileUrl(readmeterhisMapper.getFileInfoList(Arrays.asList(readmeterhis.getFileid().split(","))));
            }
            return ResultRespone.success(readmeterhis);
        }
        //业务工单事件
        else if ("2".equals(eventtype)) {
            ResultRespone resultRespone = gdglinfoClient.getById(Long.valueOf(eventid));
            Object gdInfo = resultRespone.getResult();
            if (StringUtil.isNotEmpty(qwxid)) {
                //抢维修事件
                ResultRespone<RepairOrderDetailVo> repairOrderDetail = orderClient.getPlanRepairOrderDetail(Long.valueOf(qwxid), null);
//                List<Object> objects = new ArrayList<>();
                Map<String, Object> map = new HashMap<>();
                map.put("gdInfo", gdInfo);
                map.put("qwxInfo", repairOrderDetail.getResult());
                return ResultRespone.success(map);
            }
            return ResultRespone.success(gdInfo);
        }
        //质检事件
        else if ("3".equals(eventtype)) {
            ResultRespone<List<ReportOrderInfoVo>> resultRespone = certificationOrderClient.getOrder(Long.valueOf(eventid), 1L);
            List<ReportOrderInfoVo> reportOrderInfoVoList = resultRespone.getResult();
            return ResultRespone.success(reportOrderInfoVoList);
        }

        return ResultRespone.failed(false, "无数据");
    }

    @Override
    public Boolean inspectRatio(String ratio) {
        return readmeterhisMapper.updateInspectRatio(ratio);
    }

    @Override
    public List<QualityHouse> householdsCollect(String jsonString) {
        if (StringUtil.isEmpty(jsonString)) {
            throw new ToflyDeniedException("请选择查询");
        }
        List<QualityHouse> qualityHouseList = JSONObject.parseArray(jsonString, QualityHouse.class);
        List<QualityHouse> reslut = new ArrayList<>();
        qualityHouseList.forEach(v -> {
            String cbqy = v.getCbqy();
            String sbkj = v.getSbkj();
            String cbqyd = v.getCbqyd();
            String ysxz = v.getYsxz();
            String sbcj = v.getSbcj();
            List<String> cbqyList = null;
            List<String> cbqydList = null;
            List<String> sbkjList = null;
            List<String> ysxzList = null;
            List<String> sbcjList = null;
            if (StringUtil.isNotEmpty(cbqy)) {
                cbqyList = Arrays.asList(cbqy.split(","));
            }
            if (StringUtil.isNotEmpty(cbqyd)) {
                cbqydList = Arrays.asList(cbqyd.split(","));
            }
            if (StringUtil.isNotEmpty(sbkj)) {
                sbkjList = Arrays.asList(sbkj.split(","));
            }
            if (StringUtil.isNotEmpty(ysxz)) {
                ysxzList = Arrays.asList(ysxz.split(","));
            }
            if (StringUtil.isNotEmpty(sbcj)) {
                sbcjList = Arrays.asList(sbcj.split(","));
            }
            //目前只有一条；因为没有批量勾选
            List<QualityHouse> qualityHouses = qfkhjbxxMapper.householdsCollect(cbqyList, cbqydList, sbkjList, ysxzList, sbcjList);
            //reslut.addAll(qualityHouses);
            if (qualityHouses.size() > 0) {
                v.setCollectNum(qualityHouses.get(0).getCollectNum());
                reslut.add(v);
            } else {
                v.setCollectNum(0);
                reslut.add(v);
            }
        });
        return reslut;
    }

    @Override
    public IPage<Qfkhjbxx> householdsCollectDeatil(Page page, String cbqy, String cbqyd, String sbkj, String
            ysxz, String sbcj, String inputcontent) {
        List<String> cbqyList = null;
        List<String> cbqydList = null;
        List<String> sbkjList = null;
        List<String> ysxzList = null;
        List<String> sbcjList = null;
        if (StringUtil.isNotEmpty(cbqy)) {
            cbqyList = Arrays.asList(cbqy.split(","));
        }
        if (StringUtil.isNotEmpty(cbqyd)) {
            cbqydList = Arrays.asList(cbqyd.split(","));
        }
        if (StringUtil.isNotEmpty(sbkj)) {
            sbkjList = Arrays.asList(sbkj.split(","));
        }
        if (StringUtil.isNotEmpty(ysxz)) {
            ysxzList = Arrays.asList(ysxz.split(","));
        }
        if (StringUtil.isNotEmpty(sbcj)) {
            sbcjList = Arrays.asList(sbcj.split(","));
        }
        return qfkhjbxxMapper.householdsCollectDeatil(page, cbqyList, cbqydList, sbkjList, ysxzList, sbcjList, inputcontent);

    }

    @Override
    public Map cardDataAnalyeCollect(ReadSearch search) {
        Date startDate = search.getStartDate();
        Date endDate = search.getEndDate();
        return readmeterhisMapper.cardDataAnalyeCollect(startDate, endDate);
    }

    @Override
    public List<AccuracyCollect> cardUpdateCollect(String isGeneral, String yearMonth, String cbry) {
        List<String> cbryList = null;
        isGeneral = "1".equals(isGeneral) ? "1" : "0";
        if (StringUtil.isNotEmpty(cbry)) {
            cbryList = Arrays.asList(cbry.split(","));
        }
        if (StringUtil.isEmpty(yearMonth)) {
            throw new ToflyDeniedException("请选择月份");
        }
        List<AccuracyCollect> accuracyCollectList = readmeterhisMapper.cardUpdateCollect(cbryList, yearMonth, isGeneral);
        return accuracyCollectList;
    }


}
