package com.pqs9000.controller.report;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.njcn.pojo.commons.RedisDB;
import com.njcn.shiro.token.TokenManager;
import com.njcn.utils.ClearPathUtil;
import com.njcn.utils.redis.JedisManager;
import net.sf.json.JSONObject;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.njcn.enums.LogTypeEnum;
import com.njcn.mapper.configuration.ReportMapper;
import com.njcn.mapper.configuration.ReportModelMapper;
import com.njcn.mapper.data.EventDetailMapper;
import com.njcn.mapper.user.UserMapper;
import com.njcn.pojo.commons.HttpResult;
import com.njcn.pojo.commons.device.LineInfo;
import com.njcn.pojo.configuration.Report;
import com.njcn.pojo.configuration.ReportModel;
import com.njcn.pojo.data.EventDetail;
import com.njcn.service.configuration.DeviceService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.sso.pojo.user.User;
import com.njcn.utils.AppConfig;
import com.njcn.utils.PubUtils;
import com.pqs9000.controller.business.OverviewController;
import com.pqs9000.mapper.report.GetICurrentMapper;
import com.pqs9000.pojo.report.Condition;
import com.pqs9000.pojo.report.OverLimitInfo;
import com.pqs9000.pojo.report.Pass;
import com.pqs9000.pojo.report.ReportTarget;
import com.pqs9000.pojo.report.ReportValue;
import com.pqs9000.pojo.report.enumReport.EnumPass;
import com.pqs9000.service.report.DeviceReportService;
import com.pqs9000.service.report.GetDistortionDataService;
import com.pqs9000.service.report.GetFlickerDataService;
import com.pqs9000.service.report.GetFrequencyDataService;
import com.pqs9000.service.report.GetICurrentService;
import com.pqs9000.service.report.GetInICurrentService;
import com.pqs9000.service.report.GetInVoltageRateService;
import com.pqs9000.service.report.GetOverLimitDataService;
import com.pqs9000.service.report.GetPowerDataService;
import com.pqs9000.service.report.GetThreephaseDataService;
import com.pqs9000.service.report.GetVdeviationDataService;
import com.pqs9000.service.report.GetVirtualDataService;
import com.pqs9000.service.report.GetVoltageRateService;
import com.pqs9000.util.CustomXWPFDocument;
import com.pqs9000.util.SvgPngConverter;
import com.pqs9000.util.TransformTime;
import com.pqs9000.util.WordUtil;

import tk.mybatis.mapper.util.StringUtil;

@Controller
@RequestMapping("devicereport")
public class DeviceReportController {
    @Autowired
    private AppConfig appConfig;
    private static final Logger logger = LoggerFactory.getLogger(OverviewController.class);
    ObjectMapper objectMapper = new ObjectMapper();

    @Autowired
    private GetVirtualDataService getVirtualDataService;
    @Autowired
    private GetPowerDataService getPowerDataService;
    @Autowired
    private GetOverLimitDataService getOverLimitDataService;
    @Autowired
    private GetFlickerDataService getFlickerDataService;
    @Autowired
    private GetDistortionDataService getDistortionDataService;
    @Autowired
    private GetVdeviationDataService getVdeviationDataService;
    @Autowired
    private GetFrequencyDataService getFrequencyDataService;
    @Autowired
    private GetThreephaseDataService getThreephaseDataService;
    @Autowired
    private GetICurrentService getICurrentService;
    @Autowired
    private GetInICurrentService getInICurrentService;
    @Autowired
    private GetVoltageRateService getVoltageRateService;
    @Autowired
    private GetInVoltageRateService getInVoltageRateService;
    @Resource
    private DeviceService getDeviceInfo;
    @Autowired
    private UserLogDetailService userLog;
    @Autowired
    private JedisManager jedisManager;
    // 非谐波数据
    List<ReportTarget> listVirtual;
    List<ReportTarget> listPower;
    List<ReportTarget> listFlicker;
    List<ReportTarget> listDistortion;
    List<ReportTarget> listVdeviation;
    List<ReportTarget> listFrequency;
    List<ReportTarget> listThreephase;
    // 谐波电压数据
    List<ReportTarget> listVoltageRate;
    // 谐波电流数据
    List<ReportTarget> listICurrent;
    // 间谐波电压数据
    List<ReportTarget> listInVoltageRate;
    // 间谐波电流数据
    List<ReportTarget> listInICurrent;
    // 限值
    private OverLimitInfo overLimitInfo;

    @Autowired
    DeviceReportService deviceReportService;

    @Autowired
    ReportModelMapper reportModelMapper;

    @Autowired
    ReportMapper reportMapper;

    @Autowired
    UserMapper userMapper;

    @Autowired
    GetICurrentMapper getICurrentMapper;

    @Autowired
    EventDetailMapper eventDetailMapper;


    //获取离线报告模板
    @ResponseBody
    @RequestMapping(value = "loadOffPloy", method = RequestMethod.POST)
    public HttpResult loadOffPloy() {
        HttpResult result;
        List<ReportModel> model ;
        try {
            model = reportModelMapper.selectAll();
            if (model.size() == 0) {
                result = PubUtils.assignmentResult(null, 500, "暂无模板");
            } else {
                result = PubUtils.assignmentResult(model, 200, "获取离线报告模板成功");
            }
        } catch (Exception e) {
            logger.error("获取终端运行数据失败,方法名：steady");
            result = PubUtils.assignmentResult(null, 500, "获取离线报告模板失败");
        }

        return result;
    }

    @RequestMapping(value = "loadPloyInfo", method = RequestMethod.POST)
    @ResponseBody
    public String loadPloyInfo(HttpSession session) throws JsonProcessingException {
        List<ReportModel> result ;
        List<List> s = new ArrayList<List>();

        int j = 0;

        result = reportModelMapper.selectAll();

        for (int i = 0; i < result.size(); i++) {
            List<String> a = new ArrayList<String>();
            a.add(result.get(i).getModelIndex());
            a.add(result.get(i).getModelName());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            a.add(sdf.format(result.get(i).getUpdatetime()));
            if (result.get(i).getState() == 0) {
                a.add("删除");
            } else {
                a.add("正常");
            }
            s.add(a);
        }

        return objectMapper.writeValueAsString(s);
    }

    @RequestMapping(value = "delPloyInfo", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult delPloyInfo( String modelIndex, String modelName) {
        HttpResult result = new HttpResult();
        try {
            Properties pros = PubUtils.readProperties(getClass().getClassLoader(),"java.properties");
            String tmpPath = pros.get("TMP_PATH").toString()+ File.separator+ "offlinereoprtmodel" + File.separator + File.separator + modelName;
            tmpPath= ClearPathUtil.cleanString(tmpPath);
            File file = new File(tmpPath);
            if (file.exists()) {
                file.delete();
            }
            result.setCode(200);
            result.setMessage("删除成功!");
        } catch (Exception e) {
            result.setCode(500);
            result.setMessage("删除失败!");
        }
        return result;
    }

    @RequestMapping(value = "uploadOffPloy", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult uploadOffPloy(@RequestParam(value = "file", required = false) MultipartFile file) {
        HttpResult result;
        /**
         * ---------------------------------------------------------------------------------------------
         * xuyang 2020.08.26
         * 修改：对上传文件做判断
         * 1.文件类型 2.文件大小
         */
        //文件名
        String fileName = file.getOriginalFilename();
        //文件大小(此大小为kb)
        Long fileSize  = file.getSize()/1024;
        //获取文件后缀,判断上传文件格式
        String subffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
        //判断文件大小
        if (fileSize > 3072){
            result = PubUtils.assignmentResult(null, 500, "上传失败，上传文件超过3M，文件过大！");
            return result;
        }

        // 判断文件类型
        if (!"docx".equals(subffix)){
            result = PubUtils.assignmentResult(null, 500, "上传失败，文件类型错误，只能上传Docx文件！");
            return result;
        }
        /**
         * over
         * ---------------------------------------------------------------------------------------------
         */

        InputStream is;
        String tmppath;
        tmppath = appConfig.getTmppath() + File.separator+"offlinereoprtmodel";
        tmppath= ClearPathUtil.cleanString(tmppath);
        File tmpfile = new File(tmppath);
        if (!tmpfile.exists()) {
            tmpfile.mkdir();
        }

        try {
            is = file.getInputStream();
            CustomXWPFDocument doc = new CustomXWPFDocument(is);
            tmppath = tmppath + File.separator + File.separator + file.getOriginalFilename();
            PubUtils.createFile(tmppath);
            OutputStream os = new FileOutputStream(tmppath);
            doc.write(os);
            this.close(os);
            this.close(is);
            String save = deviceReportService.saveModel(file.getOriginalFilename());
            if (save == "success") {
                result = PubUtils.assignmentResult(null, 200, "上传成功");
            } else {
                result = PubUtils.assignmentResult(null, 500, "上传失败");
            }
        } catch (Exception e) {
            result = PubUtils.assignmentResult(null, 500, "上传失败");
        }
        return result;
    }

    /**
     * 关闭输入流
     *
     * @param is
     */
    private void close(InputStream is) {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                logger.error("关闭输入流异常，异常是"+e.getMessage());
            }
        }
    }

    /**
     * 关闭输出流
     *
     * @param os
     */
    private void close(OutputStream os) {
        if (os != null) {
            try {
                os.close();
            } catch (IOException e) {
                logger.error("关闭输出流异常，异常是"+e.getMessage());
            }
        }
    }

    @PostMapping("saveReport")
    @ResponseBody
    public String saveReport(HttpServletRequest request, HttpSession session, HttpServletResponse response, String startTime, String endTime, String lineIndex, String name, String filename) throws ParseException, IOException {
        try {
            Thread.sleep(1000 * 50);
        } catch (InterruptedException e1) {
            logger.error("线程启动失败，原因是"+ e1.getMessage());
        }

        LineInfo lineDto = getDeviceInfo.getDeviceInfo(Long.valueOf(lineIndex));
        String bdname = lineDto.getSubName();
        String gdname = lineDto.getGdName();

        TransformTime TransformTime = new TransformTime(startTime, endTime);
        try {
            TransformTime.string2Date();
        } catch (Exception e2) {
            logger.error("获取时间发生异常，异常是"+e2.getMessage());
        }
        Condition condition=new Condition();
        condition.setStart(TransformTime.getStart());
        condition.setEnd(TransformTime.getEnd());
        condition.setPointIndex(Integer.valueOf(lineIndex));
        List<TransformTime> exc = new ArrayList<>();
        condition.setExceptTime(exc);
        int day = appConfig.getReportday();
        int days = (int) ((TransformTime.getEnd().getTime() - TransformTime.getStart().getTime()) / (1000 * 3600 * 24))+1;
        Boolean b = (days > day) ? new Boolean(false) : new Boolean(true);
        condition.setB(b);
        saveConditionData(condition);
        condition=getConditionData();
        getOverLimitData();
        condition.setCount(this.overLimitInfo.getCount());
        condition.setPltCount(this.overLimitInfo.getPltCount());
        condition.setPstCount(this.overLimitInfo.getPstCount());
        saveConditionData(condition);
        Condition tempCondition=getConditionData();

        if (0 == this.overLimitInfo.getOverLimitRate().size()) {
            return "datafail";
        }
        String rtfPath ;
        boolean flagPath = false;
        rtfPath = appConfig.getTmppath() + File.separator+"offlinereoprtmodel" + File.separator + filename;
        rtfPath= ClearPathUtil.cleanString(rtfPath);
        InputStream ins = null;
        try {
            ins = new FileInputStream(rtfPath);
            if (null != ins) {
                flagPath = true;
            }
        } catch (FileNotFoundException e) {
            flagPath = false;
        } finally {
            if (ins != null) {
                ins.close();
            }
        }
        if (!flagPath) {
            return "pathfail";
        }
        Map<String, Object> reportmap = new HashMap<>();// 报告Map
        //电压有效值趋势图
        Map<String, Object> header = new HashMap<>();
        byte[] image = (byte[]) session.getAttribute("Chart_VrmsX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_VrmsX$", header);
        session.removeAttribute("Chart_VrmsX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_VrmsN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_VrmsN$", header);
        session.removeAttribute("Chart_VrmsN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_VrmsE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_VrmsE$", header);
        session.removeAttribute("Chart_VrmsE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_Vrms%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_Vrms%$", header);
        session.removeAttribute("Chart_Vrms%");

        //电流有效值趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_IrmsX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_IrmsX$", header);
        session.removeAttribute("Chart_IrmsX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_IrmsN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_IrmsN$", header);
        session.removeAttribute("Chart_IrmsN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_IrmsE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_IrmsE$", header);
        session.removeAttribute("Chart_IrmsE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_Irms%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_Irms%$", header);
        session.removeAttribute("Chart_Irms%");

        //有功功率趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_PsumX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_PsumX$", header);
        session.removeAttribute("Chart_PsumX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_PsumN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_PsumN$", header);
        session.removeAttribute("Chart_PsumN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_PsumE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_PsumE$", header);
        session.removeAttribute("Chart_PsumE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_Psum%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_Psum%$", header);
        session.removeAttribute("Chart_Psum%");

        //无功功率趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_QsumX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_QsumX$", header);
        session.removeAttribute("Chart_QsumX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_QsumN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_QsumN$", header);
        session.removeAttribute("Chart_QsumN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_QsumE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_QsumE$", header);
        session.removeAttribute("Chart_QsumE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_Qsum%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_Qsum%$", header);
        session.removeAttribute("Chart_Qsum%");

        //视在功率趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_SsumX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_SsumX$", header);
        session.removeAttribute("Chart_SsumX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_SsumN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_SsumN$", header);
        session.removeAttribute("Chart_SsumN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_SsumE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_SsumE$", header);
        session.removeAttribute("Chart_SsumE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_Ssum%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_Ssum%$", header);
        session.removeAttribute("Chart_Ssum%");

        //电压不平衡趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_VunbalX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_VunbalX$", header);
        session.removeAttribute("Chart_VunbalX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_VunbalN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_VunbalN$", header);
        session.removeAttribute("Chart_VunbalN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_VunbalE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_VunbalE$", header);
        session.removeAttribute("Chart_VunbalE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_Vunbal%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_Vunbal%$", header);
        session.removeAttribute("Chart_Vunbal%");

        //频率趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_FreDevX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_FreDevX$", header);
        session.removeAttribute("Chart_FreDevX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_FreDevN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_FreDevN$", header);
        session.removeAttribute("Chart_FreDevN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_FreDevE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_FreDevE$", header);
        session.removeAttribute("Chart_FreDevE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_FreDev%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_FreDev%$", header);
        session.removeAttribute("Chart_FreDev%");

        //长时闪变趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_PltX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_PltX$", header);
        session.removeAttribute("Chart_PltX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_PltN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_PltN$", header);
        session.removeAttribute("Chart_PltN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_PltE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_PltE$", header);
        session.removeAttribute("Chart_PltE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_Plt%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_Plt%$", header);
        session.removeAttribute("Chart_Plt%");

        //短时闪变趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_PstX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_PstX$", header);
        session.removeAttribute("Chart_PstX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_PstN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_PstN$", header);
        session.removeAttribute("Chart_PstN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_PstE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_PstE$", header);
        session.removeAttribute("Chart_PstE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_Pst%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_Pst%$", header);
        session.removeAttribute("Chart_Pst%");

        //电压畸变率趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_ThdVX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_ThdVX$", header);
        session.removeAttribute("Chart_ThdVX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_ThdVN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_ThdVN$", header);
        session.removeAttribute("Chart_ThdVN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_ThdVE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_ThdVE$", header);
        session.removeAttribute("Chart_ThdVE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_ThdV%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_ThdV%$", header);
        session.removeAttribute("Chart_ThdV%");

        //电流畸变率趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_ThdIX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_ThdIX$", header);
        session.removeAttribute("Chart_ThdIX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_ThdIN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_ThdIN$", header);
        session.removeAttribute("Chart_ThdIN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_ThdIE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_ThdIE$", header);
        session.removeAttribute("Chart_ThdIE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Chart_ThdI%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Chart_ThdI%$", header);
        session.removeAttribute("Chart_ThdI%");

        //谐波电压趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("SpecMap_HVX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$SpecMap_HVX$", header);
        session.removeAttribute("SpecMap_HVX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("SpecMap_HVN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$SpecMap_HVN$", header);
        session.removeAttribute("SpecMap_HVN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("SpecMap_HVE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$SpecMap_HVE$", header);
        session.removeAttribute("SpecMap_HVE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("SpecMap_HV%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$SpecMap_HV%$", header);
        session.removeAttribute("SpecMap_HV%");

        //谐波电流趋势图
        header = new HashMap<>();
        image = (byte[]) session.getAttribute("SpecMap_HIX");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$SpecMap_HIX$", header);
        session.removeAttribute("SpecMap_HIX");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("SpecMap_HIN");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$SpecMap_HIN$", header);
        session.removeAttribute("SpecMap_HIN");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("SpecMap_HIE");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$SpecMap_HIE$", header);
        session.removeAttribute("SpecMap_HIE");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("SpecMap_HI%");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$SpecMap_HI%$", header);
        session.removeAttribute("SpecMap_HI%");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Basic_Vrms");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Basic_Vrms$", header);
        session.removeAttribute("Basic_Vrms");

        header = new HashMap<>();
        image = (byte[]) session.getAttribute("Basic_Irms");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$Basic_Irms$", header);
        session.removeAttribute("Basic_Irms");

        for (int num = 1; num < 26; num++) {
            header = new HashMap<>();
            image = (byte[]) session.getAttribute("SpecMap_HV" + String.valueOf(num));
            header.put("width", 500);
            header.put("height", 250);
            header.put("type", "image/png");
            header.put("content", image);
            reportmap.put("$SpecMap_HV" + String.valueOf(num) + "$", header);
            session.removeAttribute("SpecMap_HV" + String.valueOf(num));
        }

        for (int num = 1; num < 26; num++) {
            header = new HashMap<String, Object>();
            image = (byte[]) session.getAttribute("SpecMap_HI" + String.valueOf(num));
            header.put("width", 500);
            header.put("height", 250);
            header.put("type", "image/png");
            header.put("content", image);
            reportmap.put("$SpecMap_HI" + String.valueOf(num) + "$", header);
            session.removeAttribute("SpecMap_HI" + String.valueOf(num));
        }

        header = new HashMap<String, Object>();
        image = (byte[]) session.getAttribute("HarmI");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$HarmI$", header);
        session.removeAttribute("HarmI");

        header = new HashMap<String, Object>();
        image = (byte[]) session.getAttribute("HarmV");
        header.put("width", 500);
        header.put("height", 250);
        header.put("type", "image/png");
        header.put("content", image);
        reportmap.put("$HarmV$", header);
        session.removeAttribute("HarmV");

        getVirtualData();
        ReportValue voltage1 = (ReportValue) this.listVirtual.get(0).getList().get(0);// 电压幅值
        ReportValue voltage2 = (ReportValue) this.listVirtual.get(0).getList().get(1);// 电压幅值
        ReportValue voltage3 = (ReportValue) this.listVirtual.get(0).getList().get(2);// 电压幅值
        ReportValue current1 = (ReportValue) this.listVirtual.get(1).getList().get(0);// 电流幅值
        ReportValue current2 = (ReportValue) this.listVirtual.get(1).getList().get(1);// 电流幅值
        ReportValue current3 = (ReportValue) this.listVirtual.get(1).getList().get(2);// 电流幅值
        String strLineBaseName = String.format("%s%s", new String[]{bdname, name});
        String strAnalysis = "";// 分析建议
        String strError = "";// 报表错误

        /**************************************************************
         **** 基波电压/电流有效值表格
         **************************************
         **************************************
         * 一、用基波电压和基波电流做是否有值的判断， 判断策略为所有的基波电压和基波电流都为空
         * *************************************
         * ************************************* 二、基本数据判断
         * ①、(最大值>=最小值、平均值、95%概率值) ②、(平均值>=最小值) ③、(95%概率值>=最小值)
         ***************************************************************/
        String strBaseVIResult = "";
        // 基波电压最大值
        reportmap.put("$VrmsX_A$", judgeNull(voltage1.getFmaxValue()));
        reportmap.put("$VrmsX_B$", judgeNull(voltage2.getFmaxValue()));
        reportmap.put("$VrmsX_C$", judgeNull(voltage3.getFmaxValue()));

        // 基波电流最大值
        reportmap.put("$IrmsX_A$", judgeNull(current1.getFmaxValue()));
        reportmap.put("$IrmsX_B$", judgeNull(current2.getFmaxValue()));
        reportmap.put("$IrmsX_C$", judgeNull(current3.getFmaxValue()));

        // 基波电压最小值
        reportmap.put("$VrmsN_A$", judgeNull(voltage1.getMinValue()));
        reportmap.put("$VrmsN_B$", judgeNull(voltage2.getMinValue()));
        reportmap.put("$VrmsN_C$", judgeNull(voltage3.getMinValue()));

        // 基波电流最小值
        reportmap.put("$IrmsN_A$", judgeNull(current1.getMinValue()));
        reportmap.put("$IrmsN_B$", judgeNull(current2.getMinValue()));
        reportmap.put("$IrmsN_C$", judgeNull(current3.getMinValue()));

        // 基波电压平均值
        reportmap.put("$VrmsE_A$", judgeNull(voltage1.getMeanValue()));
        reportmap.put("$VrmsE_B$", judgeNull(voltage2.getMeanValue()));
        reportmap.put("$VrmsE_C$", judgeNull(voltage3.getMeanValue()));

        // 基波电流平均值
        reportmap.put("$IrmsE_A$", judgeNull(current1.getMeanValue()));
        reportmap.put("$IrmsE_B$", judgeNull(current2.getMeanValue()));
        reportmap.put("$IrmsE_C$", judgeNull(current3.getMeanValue()));

        // 基波电压cp95值
        reportmap.put("$Vrms%_A$", judgeNull(voltage1.getCp95Value()));
        reportmap.put("$Vrms%_B$", judgeNull(voltage2.getCp95Value()));
        reportmap.put("$Vrms%_C$", judgeNull(voltage3.getCp95Value()));

        // 基波电流cp95值
        reportmap.put("$Irms%_A$", judgeNull(current1.getCp95Value()));
        reportmap.put("$Irms%_B$", judgeNull(current2.getCp95Value()));
        reportmap.put("$Irms%_C$", judgeNull(current3.getCp95Value()));

        /**************************************************************
         **** 三张大表基础数据幅值
         ***************************************************************/
//		// 基波电压最大值
//		reportmap.put("$HV1X_A$", judgeNull(voltage1.getFmaxValue()));
//		reportmap.put("$HV1X_B$", judgeNull(voltage2.getFmaxValue()));
//		reportmap.put("$HV1X_C$", judgeNull(voltage3.getFmaxValue()));
//
//		// 基波电流最大值
//		reportmap.put("$HI1X_A$", judgeNull(current1.getFmaxValue()));
//		reportmap.put("$HI1X_B$", judgeNull(current2.getFmaxValue()));
//		reportmap.put("$HI1X_C$", judgeNull(current3.getFmaxValue()));
//
//		// 基波电压最小值
//		reportmap.put("$HV1N_A$", judgeNull(voltage1.getMinValue()));
//		reportmap.put("$HV1N_B$", judgeNull(voltage2.getMinValue()));
//		reportmap.put("$HV1N_C$", judgeNull(voltage3.getMinValue()));
//
//		// 基波电流最小值
//		reportmap.put("$HI1N_A$", judgeNull(current1.getMinValue()));
//		reportmap.put("$HI1N_B$", judgeNull(current2.getMinValue()));
//		reportmap.put("$HI1N_C$", judgeNull(current3.getMinValue()));
//
//		// 基波电压平均值
//		reportmap.put("$HV1E_A$", judgeNull(voltage1.getMeanValue()));
//		reportmap.put("$HV1E_B$", judgeNull(voltage2.getMeanValue()));
//		reportmap.put("$HV1E_C$", judgeNull(voltage3.getMeanValue()));
//
//		// 基波电流平均值
//		reportmap.put("$HI1E_A$", judgeNull(current1.getMeanValue()));
//		reportmap.put("$HI1E_B$", judgeNull(current2.getMeanValue()));
//		reportmap.put("$HI1E_C$", judgeNull(current3.getMeanValue()));
//
//		// 基波电压cp95值
//		reportmap.put("$HV1%_A$", judgeNull(voltage1.getCp95Value()));
//		reportmap.put("$HV1%_B$", judgeNull(voltage2.getCp95Value()));
//		reportmap.put("$HV1%_C$", judgeNull(voltage3.getCp95Value()));
//
//		// 基波电流cp95值
//		reportmap.put("$HI1%_A$", judgeNull(current1.getCp95Value()));
//		reportmap.put("$HI1%_B$", judgeNull(current2.getCp95Value()));
//		reportmap.put("$HI1%_C$", judgeNull(current3.getCp95Value()));

        // 遍历map中的值
        int iCount = 0;
        // 判断所取的基波电压、基波电流值是否为null
        for (Object value : reportmap.values()) {
            if (value == null)
                iCount++;
        }
        // 假如所有的数据都为null,则返回（所选的时间段内未找到数据）
        if (iCount == reportmap.size())
            return "exportworld";// 未找到数据

        // 基本数据判断
        for (int i = 0; i < 3; i++) {
            String tmpstrMap = "A";
            switch (i) {
                case 0:
                    tmpstrMap = "A";
                    break;
                case 1:
                    tmpstrMap = "B";
                    break;
                case 2:
                    tmpstrMap = "C";
                    break;
            }
            try {
                // 基波电压
                Double vmaxValue = Double.parseDouble(reportmap.get("$BV0X_" + tmpstrMap + "$").toString());
                Double vminValue = Double.parseDouble(reportmap.get("$BV0N_" + tmpstrMap + "$").toString());
                Double vaveValue = Double.parseDouble(reportmap.get("$BV0E_" + tmpstrMap + "$").toString());
                Double vcp95Value = Double.parseDouble(reportmap.get("$BV0%_" + tmpstrMap + "$").toString());
                // 基波电流
                Double imaxValue = Double.parseDouble(reportmap.get("$BI0X_" + tmpstrMap + "$").toString());
                Double iminValue = Double.parseDouble(reportmap.get("$BI0N_" + tmpstrMap + "$").toString());
                Double iaveValue = Double.parseDouble(reportmap.get("$BI0E_" + tmpstrMap + "$").toString());
                Double icp95Value = Double.parseDouble(reportmap.get("$BI0%_" + tmpstrMap + "$").toString());

                if (!(vmaxValue >= vminValue && vmaxValue >= vaveValue && vmaxValue >= vcp95Value)) {
                    strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
                            + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值；2、平均值>=最小值；3、95%概率值>=最小值)。";
                    break;
                } else if (vaveValue < vminValue) {
                    strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
                            + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值；2、平均值>=最小值；3、95%概率值>=最小值)。";
                    break;
                } else if (vcp95Value < vminValue) {
                    strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
                            + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值；2、平均值>=最小值；3、95%概率值>=最小值)。";
                    break;
                } else if (!(imaxValue >= iminValue && imaxValue >= iaveValue && imaxValue >= icp95Value)) {
                    strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
                            + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值；2、平均值>=最小值；3、95%概率值>=最小值)。";
                    break;
                } else if (iaveValue < iminValue) {
                    strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
                            + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值；2、平均值>=最小值；3、95%概率值>=最小值)。";
                    break;
                } else if (icp95Value < iminValue) {
                    strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
                            + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值；2、平均值>=最小值；3、95%概率值>=最小值)。";
                    break;
                }
            } catch (Exception e) {
                strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName + "基波电压/电流数据存在异常(不是数值类型)。";
                break;
            }
        }
//		reportmap.put("$BaseVIResult$", strBaseVIResult);
        if (!"".equals(strBaseVIResult))
            strError += strBaseVIResult;

        /**************************************************************
         **** 所选的时间段内有数据存在则进行其他加载
         ***************************************************************/
        // 获取报告生成时间
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日");// 报告时分秒格式
        String strTime = String.format("%s——%s。",
                new String[]{(String) formatter.format(tempCondition.getStart()), (String) formatter.format(tempCondition.getEnd())});

        reportmap.put("$TitleTime$", formatter.format(currentTime)); // 报告生成时间
        reportmap.put("$titlePoint$", strLineBaseName);
        reportmap.put("$GD_Name$", gdname);// 监测点名称2
        reportmap.put("$SUBName$", bdname);// 监测点名称2
//		reportmap.put("$ReportTitle$",
//				String.format("对该地区%s电能质量在线监测数据进行分析， 以判断电能质量指标是否满足国标。", new String[] { strLineBaseName }));// 报告标题
        reportmap.put("$ReportTime$", strTime);// 报告分析时间段
//		reportmap.put("$RunBaseName$", String.format("以下将对%s电能质量统计数据进行分析，数据包括基波电压/电流、谐波电压/电流、电压偏差、三相电压不平衡度、电压闪变、频率偏差。",
//				new String[] { strLineBaseName }));// 运行数据分析
//		reportmap.put("$BaseVITable$", String.format("报告分析时间段内%s的基波电压/电流分钟统计数据见下表。", new String[] { strLineBaseName }));// 基波电压和电流
//		reportmap.put("$VDTable$", String.format("报告分析时间段内%s的电压偏差统计数据见下表。", new String[] { strLineBaseName }));// 供电电压偏差
//		reportmap.put("$FRETable$", String.format("报告分析时间段内%s的频率偏差统计数据见下表。", new String[] { strLineBaseName }));// 频率偏差
//		reportmap.put("$THETable$", String.format("报告分析时间段内%s的三相电压不平衡度统计数据见下表。", new String[] { strLineBaseName }));// 三相电压不平衡度
//		reportmap.put("$PltTable$", String.format("报告分析时间段内%s的闪变统计数据见下表。", new String[] { strLineBaseName }));// 闪变
//		reportmap.put("$RVTable$",
//				String.format("报告分析时间段内%s的2-25次谐波电压含有率CP95概率值统计数据见下表。", new String[] { strLineBaseName }));// 谐波电压
//		reportmap.put("$RITable$",
//				String.format("报告分析时间段内%s的2-25次谐波电流幅值CP95概率值统计数据见下表。", new String[] { strLineBaseName }));// 谐波电流
//
//		reportmap.put("$LineName1$", name);// 监测点名称1
//		reportmap.put("$LineName2$", name);// 监测点名称2
//		reportmap.put("$LineName3$", name);// 监测点名称3
//		reportmap.put("$LineName4$", name);// 监测点名称4
//		reportmap.put("$LineName5$", name);// 监测点名称5

        /**********************
         **** 数据获取
         ***********************/
        getPowerData();
        getFlicker();
        getVdeviation();
        getDistortion();
        getFre();
        getThreePhase();
        getVoltageRate();
        getCurrentRate();
        getInVoltageRate();
        getInCurrentRate();

        ReportValue pst1 = (ReportValue) this.listFlicker.get(0).getList().get(0);// 短闪
        ReportValue pst2 = (ReportValue) this.listFlicker.get(0).getList().get(1);// 短闪
        ReportValue pst3 = (ReportValue) this.listFlicker.get(0).getList().get(2);// 短闪
        ReportValue plt1 = (ReportValue) this.listFlicker.get(1).getList().get(0);// 长闪
        ReportValue plt2 = (ReportValue) this.listFlicker.get(1).getList().get(1);// 长闪
        ReportValue plt3 = (ReportValue) this.listFlicker.get(1).getList().get(2);// 长闪

        reportmap.put("$LineBase$", String.format("%s%s，CT变比为：%s，PT变比为：%s。",
                new String[]{bdname, name, lineDto.getCT(), lineDto.getPT()}));// 监测点基本信息

        /**************************************************************
         **** 三张大表基础数据幅值
         ***************************************************************/
        reportmap.put("$JC_Loc$", bdname);
        reportmap.put("$JC_Time$", strTime);
        reportmap.put("$JC_Line$", name);
        reportmap.put("$JC_PT$", lineDto.getPT());
        reportmap.put("$JC_VolGra$", lineDto.getScale());
        reportmap.put("$JC_CT$", lineDto.getCT());
        reportmap.put("$RefeCap$", String.valueOf(lineDto.getJZCMP()));
        reportmap.put("$MinCap$", String.valueOf(lineDto.getDLCMP()));
        reportmap.put("$UserCap$", String.valueOf(lineDto.getXYCMP()));
        reportmap.put("$SupCap$", String.valueOf(lineDto.getDEVCMP()));

        Double maxValue = 0.00;
        Double minValue = 0.00;
        Double aveValue = 0.00;
        Double cp95Value = 0.00;
        Double maxValue1 = 0.00;
        Double minValue1 = 0.00;
        Double aveValue1 = 0.00;
        Double cp95Value1 = 0.00;
        Double maxValue2 = 0.00;
        Double minValue2 = 0.00;
        Double aveValue2 = 0.00;
        Double cp95Value2 = 0.00;
        Double cp95ValueA = 0.00;
        Double cp95ValueB = 0.00;
        Double cp95ValueC = 0.00;
        Double limit = 0.00;
        Double lmaxValue = 0.00;
        Double lminValue = 0.00;
        Double laveValue = 0.00;
        Double lcp95Value = 0.00;
        Double lmaxValue1 = 0.00;
        Double lminValue1 = 0.00;
        Double laveValue1 = 0.00;
        Double lcp95Value1 = 0.00;
        Double lmaxValue2 = 0.00;
        Double lminValue2 = 0.00;
        Double laveValue2 = 0.00;
        Double lcp95Value2 = 0.00;
        Double lcp95ValueA = 0.00;
        Double lcp95ValueB = 0.00;
        Double lcp95ValueC = 0.00;
        Double llimit = 0.00;
        /**************************************************************
         **** 电压偏差（上偏差和下偏差）
         ***************************************************************/
        ReportValue vdeviation1 = (ReportValue) this.listVdeviation.get(0).getList().get(0);
        ReportValue vdeviation2 = (ReportValue) this.listVdeviation.get(0).getList().get(1);
        ReportValue vdeviation3 = (ReportValue) this.listVdeviation.get(0).getList().get(2);
        String vdeviationLimit = judgeNull(this.listVdeviation.get(0).getOverLimit());// 获取电压上下偏差的国标限值


        ReportValue ldeviation1 = (ReportValue) this.listVdeviation.get(1).getList().get(0);
        ReportValue ldeviation2 = (ReportValue) this.listVdeviation.get(1).getList().get(1);
        ReportValue ldeviation3 = (ReportValue) this.listVdeviation.get(1).getList().get(2);
        String ldeviationLimit = judgeNull(this.listVdeviation.get(1).getOverLimit());// 获取电压上下偏差的国标限值

        reportmap.put("$PVDL$", vdeviationLimit);
        String strResultVdeviationdata = "";
        String tmpstrResultVdeviationdata = "";
        String strResultVdeviationdataValue = "";
        // 获取电压偏差
        String tmpstrMap = "";
        reportmap.put("$PVDX_A$", judgeNull(vdeviation1.getFmaxValue()));
        reportmap.put("$PVDN_A$", judgeNull(vdeviation1.getMinValue()));
        reportmap.put("$PVDE_A$", judgeNull(vdeviation1.getMeanValue()));
        reportmap.put("$PVD%_A$", judgeNull(vdeviation1.getCp95Value()));
        reportmap.put("$PVDX_B$", judgeNull(vdeviation2.getFmaxValue()));
        reportmap.put("$PVDN_B$", judgeNull(vdeviation2.getMinValue()));
        reportmap.put("$PVDE_B$", judgeNull(vdeviation2.getMeanValue()));
        reportmap.put("$PVD%_B$", judgeNull(vdeviation2.getCp95Value()));
        reportmap.put("$PVDX_C$", judgeNull(vdeviation3.getFmaxValue()));
        reportmap.put("$PVDN_C$", judgeNull(vdeviation3.getMinValue()));
        reportmap.put("$PVDE_C$", judgeNull(vdeviation3.getMeanValue()));
        reportmap.put("$PVD%_C$", judgeNull(vdeviation3.getCp95Value()));

        reportmap.put("$LVDL$", vdeviationLimit);
        reportmap.put("$LVDX_A$", judgeNull(ldeviation1.getFmaxValue()));
        reportmap.put("$LVDN_A$", judgeNull(ldeviation1.getMinValue()));
        reportmap.put("$LVDE_A$", judgeNull(ldeviation1.getMeanValue()));
        reportmap.put("$LVD%_A$", judgeNull(ldeviation1.getCp95Value()));
        reportmap.put("$LVDX_B$", judgeNull(ldeviation2.getFmaxValue()));
        reportmap.put("$LVDN_B$", judgeNull(ldeviation2.getMinValue()));
        reportmap.put("$LVDE_B$", judgeNull(ldeviation2.getMeanValue()));
        reportmap.put("$LVD%_B$", judgeNull(ldeviation2.getCp95Value()));
        reportmap.put("$LVDX_C$", judgeNull(ldeviation3.getFmaxValue()));
        reportmap.put("$LVDN_C$", judgeNull(ldeviation3.getMinValue()));
        reportmap.put("$LVDE_C$", judgeNull(ldeviation3.getMeanValue()));
        reportmap.put("$LVD%_C$", judgeNull(ldeviation3.getCp95Value()));

        // 值错误判断
        try {
            maxValue = Math.abs(Double.parseDouble(vdeviation1.getFmaxValue().toString()));
            minValue = Math.abs(Double.parseDouble(vdeviation1.getMinValue().toString()));
            aveValue = Math.abs(Double.parseDouble(vdeviation1.getMeanValue().toString()));
            cp95Value = Math.abs(Double.parseDouble(vdeviation1.getCp95Value().toString()));

            maxValue1 = Math.abs(Double.parseDouble(vdeviation2.getFmaxValue().toString()));
            minValue1 = Math.abs(Double.parseDouble(vdeviation2.getMinValue().toString()));
            aveValue1 = Math.abs(Double.parseDouble(vdeviation2.getMeanValue().toString()));
            cp95Value1 = Math.abs(Double.parseDouble(vdeviation2.getCp95Value().toString()));

            maxValue2 = Math.abs(Double.parseDouble(vdeviation3.getFmaxValue().toString()));
            minValue2 = Math.abs(Double.parseDouble(vdeviation3.getMinValue().toString()));
            aveValue2 = Math.abs(Double.parseDouble(vdeviation3.getMeanValue().toString()));
            cp95Value2 = Math.abs(Double.parseDouble(vdeviation3.getCp95Value().toString()));
            limit = Math.abs(Double.parseDouble(vdeviationLimit));

            lmaxValue = Math.abs(Double.parseDouble(ldeviation1.getFmaxValue().toString()));
            lminValue = Math.abs(Double.parseDouble(ldeviation1.getMinValue().toString()));
            laveValue = Math.abs(Double.parseDouble(ldeviation1.getMeanValue().toString()));
            lcp95Value = Math.abs(Double.parseDouble(ldeviation1.getCp95Value().toString()));

            lmaxValue1 = Math.abs(Double.parseDouble(ldeviation2.getFmaxValue().toString()));
            lminValue1 = Math.abs(Double.parseDouble(ldeviation2.getMinValue().toString()));
            laveValue1 = Math.abs(Double.parseDouble(ldeviation2.getMeanValue().toString()));
            lcp95Value1 = Math.abs(Double.parseDouble(ldeviation2.getCp95Value().toString()));

            lmaxValue2 = Math.abs(Double.parseDouble(ldeviation3.getFmaxValue().toString()));
            lminValue2 = Math.abs(Double.parseDouble(ldeviation3.getMinValue().toString()));
            laveValue2 = Math.abs(Double.parseDouble(ldeviation3.getMeanValue().toString()));
            lcp95Value2 = Math.abs(Double.parseDouble(ldeviation3.getCp95Value().toString()));
            llimit = Math.abs(Double.parseDouble(ldeviationLimit));
        } catch (Exception e) {
            strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName + "电压偏差数据存在异常(不是数值类型)。";
        }

        // 限值判断
        if (maxValue > limit) {
            if (!"".equals(tmpstrResultVdeviationdata))
                tmpstrResultVdeviationdata += "、";
            tmpstrResultVdeviationdata += tmpstrMap + "相";
        }

        // 假如为空则所有的都满足
        if ("".equals(tmpstrResultVdeviationdata)) {
            strResultVdeviationdata += "从上表中可以看出" + strLineBaseName + "A、B、C三相电压偏差满足国标限值（10%）的要求。";
        } else {
            strAnalysis += tmpstrResultVdeviationdata + "电压偏差不满足国标限值（10%）的要求。";
            strResultVdeviationdata += "从上表中可以看出" + strLineBaseName + tmpstrResultVdeviationdata
                    + "电压偏差不满足国标限值（10%）的要求。";
        }

        if (judgeNull(vdeviation1.getFmaxValue()) == "/") {
            reportmap.put("$PVDR_A$", "/");
        } else if (maxValue < limit) {
            reportmap.put("$PVDR_A$", "合格");
        } else {
            reportmap.put("$PVDR_A$", "不合格");
        }

        if (judgeNull(vdeviation2.getFmaxValue()) == "/") {
            reportmap.put("$PVDR_B$", "/");
        } else if (maxValue1 < limit) {
            reportmap.put("$PVDR_B$", "合格");
        } else {
            reportmap.put("$PVDR_B$", "不合格");
        }

        if (judgeNull(vdeviation3.getFmaxValue()) == "/") {
            reportmap.put("$PVDR_C$", "/");
        } else if (maxValue2 < limit) {
            reportmap.put("$PVDR_C$", "合格");
        } else {
            reportmap.put("$PVDR_C$", "不合格");
        }

        if (judgeNull(ldeviation1.getFmaxValue()) == "/") {
            reportmap.put("$PVDR_A$", "/");
        } else if (lmaxValue < llimit) {
            reportmap.put("$LVDR_A$", "合格");
        } else {
            reportmap.put("$LVDR_A$", "不合格");
        }

        if (judgeNull(ldeviation2.getFmaxValue()) == "/") {
            reportmap.put("$PVDR_A$", "/");
        } else if (lmaxValue1 < llimit) {
            reportmap.put("$LVDR_B$", "合格");
        } else {
            reportmap.put("$LVDR_B$", "不合格");
        }

        if (judgeNull(ldeviation3.getFmaxValue()) == "/") {
            reportmap.put("$PVDR_A$", "/");
        } else if (lmaxValue2 < llimit) {
            reportmap.put("$LVDR_C$", "合格");
        } else {
            reportmap.put("$LVDR_C$", "不合格");
        }

        /**************************************************************
         **** 频率偏差
         ***************************************************************/
        ReportValue valueOfFreValue = (ReportValue) this.listFrequency.get(1).getList().get(0);
        String valueOfFreLimit = judgeNull(this.listFrequency.get(1).getOverLimit());// 获取频率偏差国标限值
        reportmap.put("$FreDevL$", valueOfFreLimit);
        String strResultFre = "";
        String tmpstrResultFre = "";
        String strResultFreValue = "";

        reportmap.put("$FreDevX$", judgeNull(valueOfFreValue.getFmaxValue()));
        reportmap.put("$FreDevN$", judgeNull(valueOfFreValue.getMinValue()));
        reportmap.put("$FreDevE$", judgeNull(valueOfFreValue.getMeanValue()));
        reportmap.put("$FreDev%$", judgeNull(valueOfFreValue.getCp95Value()));

        try {
            maxValue = Math.abs(Double.parseDouble(valueOfFreValue.getFmaxValue().toString()));
            minValue = Math.abs(Double.parseDouble(valueOfFreValue.getMinValue().toString()));
            aveValue = Math.abs(Double.parseDouble(valueOfFreValue.getMeanValue().toString()));
            cp95Value = Math.abs(Double.parseDouble(valueOfFreValue.getCp95Value().toString()));
            limit = Math.abs(Double.parseDouble(valueOfFreLimit));
        } catch (Exception e) {
            strResultFreValue += "注意:从上表中可以看出" + strLineBaseName + "频率偏差数据存在异常(不是数值类型)。";
        }

        if (maxValue > limit) {
            tmpstrResultFre += "最大值为：" + valueOfFreValue.getFmaxValue().toString() + "Hz";
        }
        if (minValue > limit) {
            tmpstrResultFre += "最小值为：" + valueOfFreValue.getMinValue().toString() + "Hz";
        }
        if (aveValue > limit) {
            tmpstrResultFre += "平均值为：" + valueOfFreValue.getMeanValue().toString() + "Hz";
        }
        if (cp95Value > limit) {
            tmpstrResultFre += "95%概率值为：" + valueOfFreValue.getCp95Value().toString() + "Hz";
        }

        if (judgeNull(vdeviation1.getFmaxValue()) == "/") {
            reportmap.put("$FreDevR$", "/");
        } else if ("".equals(tmpstrResultFre)) {
            reportmap.put("$FreDevR$", "合格");// 三张大表取值
            strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差均满足国标限值（±" + valueOfFreLimit + "Hz）的要求。";
        } else {
            reportmap.put("$FreDevR$", "不合格");// 三张大表取值
            strAnalysis += tmpstrResultFre + ",均不满足国标限值（±" + valueOfFreLimit + "Hz）的要求。";
            strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差" + tmpstrResultFre + ",均不满足国标限值（±" + valueOfFreLimit
                    + "Hz）的要求。";
        }

        /**************************************************************
         **** 三项电压不平衡度
         ***************************************************************/
        ReportValue valueOfThree = (ReportValue) this.listThreephase.get(0).getList().get(0);
        String valueOfThreeLimit = judgeNull(this.listThreephase.get(0).getOverLimit());// 获取三相电压不平衡度国标限值
        String strResultThree = "";
        String tmpstrResultThree = "";
        String strResultThreeValue = "";

        /************************************
         **** 三张大表取值
         **************************************/
        reportmap.put("$VunbalL$", valueOfThreeLimit);
        reportmap.put("$VunbalX$", judgeNull(valueOfThree.getFmaxValue()));
        reportmap.put("$VunbalN$", judgeNull(valueOfThree.getMinValue()));
        reportmap.put("$VunbalE$", judgeNull(valueOfThree.getMeanValue()));
        reportmap.put("$Vunbal%$", judgeNull(valueOfThree.getCp95Value()));

        try {
            maxValue = Double.parseDouble(valueOfThree.getFmaxValue().toString());
            minValue = Double.parseDouble(valueOfThree.getMinValue().toString());
            aveValue = Double.parseDouble(valueOfThree.getMeanValue().toString());
            cp95Value = Double.parseDouble(valueOfThree.getCp95Value().toString());
            limit = Double.parseDouble(valueOfThreeLimit);
        } catch (Exception e) {
            strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName + "三相电压不平衡度数据存在异常(不是数值类型)。";
        }

        if (judgeNull(valueOfThree.getFmaxValue()) == "/") {
            reportmap.put("$VunbalR$", "/");
        } else if (cp95Value > limit) {
            reportmap.put("$VunbalR$", "不合格");// 三张大表取值
            tmpstrResultThree += "三相电压不平衡度95%概率值为：" + valueOfThree.getCp95Value().toString();
        } else {
            reportmap.put("$VunbalR$", "合格");// 三张大表取值
        }

        if ("".equals(tmpstrResultThree)) {
            strResultThree += "三相电压不平衡度根据国标标准测量结果以95%概率值作为判断是否合格的依据，从上表中可以看出" + strLineBaseName + tmpstrResultThree
                    + "，满足国标限值（" + valueOfThreeLimit + "%）的要求。";
        } else {
            strAnalysis += tmpstrResultThree + "，不满足国标限值（" + valueOfThreeLimit + "%）的要求。";
            strResultThree += "三相电压不平衡度根据国标标准测量结果以95%概率值作为判断是否合格的依据，从上表中可以看出" + strLineBaseName + tmpstrResultThree
                    + "，不满足国标限值（" + valueOfThreeLimit + "%）的要求。";
        }

        strError += strResultThreeValue;

        /**************************************************************
         **** 电压闪变
         ***************************************************************/
        String valueOfFlickerLimit = judgeNull(this.listFlicker.get(1).getOverLimit());// 获取电压长时闪变的限值
        String strResultFlicker = "";
        String tmpstrResultFlicker = "";
        String strResultFlickerValue = "";
        String strPhase = "";// 相别，A、B、C
        String strType = "";// 长闪还是短闪；S:短闪；L：长闪
        String strValueType = "";// 值类型，最大，最小，平均，95%概率值
        try {
            if (judgeNull(plt1.getFmaxValue()) == "/") {
                reportmap.put("$" + "PltR_" + "A" + "$", "/");
            } else if (Double.parseDouble(plt1.getFmaxValue().toString()) > Double.parseDouble(valueOfFlickerLimit)) {
                if (!"".equals(tmpstrResultFlicker))
                    tmpstrResultFlicker += ",";
                tmpstrResultFlicker += "A相最大值为：" + plt1.getFmaxValue().toString();
                reportmap.put("$" + "PltR_" + "A" + "$", "不合格");
            } else {
                reportmap.put("$" + "PltR_" + "A" + "$", "合格");
            }

            if (judgeNull(plt2.getFmaxValue()) == "/") {
                reportmap.put("$" + "PltR_" + "B" + "$", "/");
            } else if (Double.parseDouble(plt2.getFmaxValue().toString()) > Double.parseDouble(valueOfFlickerLimit)) {
                if (!"".equals(tmpstrResultFlicker))
                    tmpstrResultFlicker += ",";
                tmpstrResultFlicker += "B相最大值为：" + plt2.getFmaxValue().toString();
                reportmap.put("$" + "PltR_" + "B" + "$", "不合格");
            } else {
                reportmap.put("$" + "PltR_" + "B" + "$", "合格");
            }

            if (judgeNull(plt3.getFmaxValue()) == "/") {
                reportmap.put("$" + "PltR_" + "C" + "$", "/");
            } else if (Double.parseDouble(plt3.getFmaxValue().toString()) > Double.parseDouble(valueOfFlickerLimit)) {
                if (!"".equals(tmpstrResultFlicker))
                    tmpstrResultFlicker += ",";
                tmpstrResultFlicker += "C相最大值为：" + plt3.getFmaxValue().toString();
                reportmap.put("$" + "PltR_" + "C" + "$", "不合格");
            } else {
                reportmap.put("$" + "PltR_" + "C" + "$", "合格");
            }
        } catch (Exception e) {
            if ("".equals(strResultFlickerValue))
                strResultFlickerValue += "注意:从上表中可以看出" + strLineBaseName + "长时闪变数据存在异常(不是数值类型)。";
        }

        /************************************
         **** 三张大表取值
         **************************************/
        reportmap.put("$" + "Plt" + "X" + "_" + "A" + "$", judgeNull(plt1.getFmaxValue()));
        reportmap.put("$" + "Plt" + "E" + "_" + "A" + "$", judgeNull(plt1.getMeanValue()));
        reportmap.put("$" + "Plt" + "N" + "_" + "A" + "$", judgeNull(plt1.getMinValue()));
        reportmap.put("$" + "Plt" + "%" + "_" + "A" + "$", judgeNull(plt1.getCp95Value()));
        reportmap.put("$" + "Plt" + "X" + "_" + "B" + "$", judgeNull(plt2.getFmaxValue()));
        reportmap.put("$" + "Plt" + "E" + "_" + "B" + "$", judgeNull(plt2.getMeanValue()));
        reportmap.put("$" + "Plt" + "N" + "_" + "B" + "$", judgeNull(plt2.getMinValue()));
        reportmap.put("$" + "Plt" + "%" + "_" + "B" + "$", judgeNull(plt2.getCp95Value()));
        reportmap.put("$" + "Plt" + "X" + "_" + "C" + "$", judgeNull(plt3.getFmaxValue()));
        reportmap.put("$" + "Plt" + "E" + "_" + "C" + "$", judgeNull(plt3.getMeanValue()));
        reportmap.put("$" + "Plt" + "N" + "_" + "C" + "$", judgeNull(plt3.getMinValue()));
        reportmap.put("$" + "Plt" + "%" + "_" + "C" + "$", judgeNull(plt3.getCp95Value()));
        reportmap.put("$PltL_A$", valueOfFlickerLimit);
        reportmap.put("$PltL_B$", valueOfFlickerLimit);
        reportmap.put("$PltL_C$", valueOfFlickerLimit);

        reportmap.put("$" + "Pst" + "X" + "_" + "A" + "$", judgeNull(pst1.getFmaxValue()));
        reportmap.put("$" + "Pst" + "E" + "_" + "A" + "$", judgeNull(pst1.getMeanValue()));
        reportmap.put("$" + "Pst" + "N" + "_" + "A" + "$", judgeNull(pst1.getMinValue()));
        reportmap.put("$" + "Pst" + "%" + "_" + "A" + "$", judgeNull(pst1.getCp95Value()));
        reportmap.put("$" + "Pst" + "X" + "_" + "B" + "$", judgeNull(pst2.getFmaxValue()));
        reportmap.put("$" + "Pst" + "E" + "_" + "B" + "$", judgeNull(pst2.getMeanValue()));
        reportmap.put("$" + "Pst" + "N" + "_" + "B" + "$", judgeNull(pst2.getMinValue()));
        reportmap.put("$" + "Pst" + "%" + "_" + "B" + "$", judgeNull(pst2.getCp95Value()));
        reportmap.put("$" + "Pst" + "X" + "_" + "C" + "$", judgeNull(pst3.getFmaxValue()));
        reportmap.put("$" + "Pst" + "E" + "_" + "C" + "$", judgeNull(pst3.getMeanValue()));
        reportmap.put("$" + "Pst" + "N" + "_" + "C" + "$", judgeNull(pst3.getMinValue()));
        reportmap.put("$" + "Pst" + "%" + "_" + "C" + "$", judgeNull(pst3.getCp95Value()));
        reportmap.put("$PstL_A$", "-");
        reportmap.put("$PstL_B$", "-");
        reportmap.put("$PstL_C$", "-");
        reportmap.put("$PstR_A$", "-");
        reportmap.put("$PstR_B$", "-");
        reportmap.put("$PstR_C$", "-");

        if ("".equals(tmpstrResultFlicker)) {
            strResultFlicker += "电压长时闪变根据国标标准测量结果以最大值、最小值、95%概率值作为判断是否合格的依据，从上表中可以看出" + strLineBaseName + "长时闪变"
                    + tmpstrResultFlicker + "，其满足国标限值（" + valueOfFlickerLimit + "）的要求。";
        } else {
            strAnalysis += "长时闪变" + tmpstrResultFlicker + "，其不满足国标限值（" + valueOfFlickerLimit + "）的要求。";
            strResultFlicker += "电压长时闪变根据国标标准测量结果以最大值、最小值、95%概率值作为判断是否合格的依据，从上表中可以看出" + strLineBaseName + "长时闪变"
                    + tmpstrResultFlicker + "，其不满足国标限值（" + valueOfFlickerLimit + "）的要求。";
        }

        strError += strResultFlickerValue;

        /**************************************************************
         **** 电压含有率
         ***************************************************************/
        String strResultVoltageRate = "";
        String tmpstrResultVoltageRate = "";
        String strResultVoltageRateValue = "";
        String strCurrentA, strCurrentB, strCurrentC, strLimit;
        // 获取25次谐波
        for (int i = 0; i < 50; i++) {
            // 基波电压含有率
            strCurrentA = judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(0)).getCp95Value());
            strCurrentB = judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(1)).getCp95Value());
            strCurrentC = judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(2)).getCp95Value());
            strLimit = judgeNull(this.listVoltageRate.get(i).getOverLimit());

            /************************************
             **** 三张大表取值
             **************************************/
            reportmap.put("$HV" + (i + 1) + "X_A$",
                    judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(0)).getFmaxValue()));
            reportmap.put("$HV" + (i + 1) + "X_B$",
                    judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(1)).getFmaxValue()));
            reportmap.put("$HV" + (i + 1) + "X_C$",
                    judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(2)).getFmaxValue()));

            reportmap.put("$HV" + (i + 1) + "N_A$",
                    judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(0)).getMinValue()));
            reportmap.put("$HV" + (i + 1) + "N_B$",
                    judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(1)).getMinValue()));
            reportmap.put("$HV" + (i + 1) + "N_C$",
                    judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(2)).getMinValue()));

            reportmap.put("$HV" + (i + 1) + "E_A$",
                    judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(0)).getMeanValue()));
            reportmap.put("$HV" + (i + 1) + "E_B$",
                    judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(1)).getMeanValue()));
            reportmap.put("$HV" + (i + 1) + "E_C$",
                    judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(2)).getMeanValue()));

            reportmap.put("$HV" + (i + 1) + "%_A$", strCurrentA);
            reportmap.put("$HV" + (i + 1) + "%_B$", strCurrentB);
            reportmap.put("$HV" + (i + 1) + "%_C$", strCurrentC);
            reportmap.put("$HV" + (i + 1) + "L$", strLimit);

            try {
                maxValue = Double.parseDouble(strCurrentA);
                minValue = Double.parseDouble(strCurrentB);
                aveValue = Double.parseDouble(strCurrentC);
                limit = Double.parseDouble(strLimit);
            } catch (Exception e) {
                strResultVoltageRateValue += "注意:从上表中可以看出" + strLineBaseName + "谐波电压含有率95%概率值数据存在异常(不是数值类型)。";
            }

            if (i == 0) {
                continue;
            }
            String tmpstrResult = "";
            if (judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(0)).getFmaxValue()) == "/") {
                reportmap.put("$HV" + (i + 1) + "R_A$", "/");
            } else if (maxValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "A";
                reportmap.put("$HV" + (i + 1) + "R_A$", "不合格");// 三张大表取值
            } else
                reportmap.put("$HV" + (i + 1) + "R_A$", "合格");// 三张大表取值
            if (judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(1)).getFmaxValue()) == "/") {
                reportmap.put("$HV" + (i + 1) + "R_B$", "/");
            } else if (minValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "B";
                reportmap.put("$HV" + (i + 1) + "R_B$", "不合格");// 三张大表取值
            } else
                reportmap.put("$HV" + (i + 1) + "R_B$", "合格");// 三张大表取值
            if (judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(2)).getFmaxValue()) == "/") {
                reportmap.put("$HV" + (i + 1) + "R_C$", "/");
            } else if (aveValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "C";
                reportmap.put("$HV" + (i + 1) + "R_C$", "不合格");// 三张大表取值
            } else
                reportmap.put("$HV" + (i + 1) + "R_C$", "合格");// 三张大表取值
            // 判断单个结论是否存在
            if (!"".equals(tmpstrResult)) {
                tmpstrResultVoltageRate += (i + 1) + "次谐波电压含有率95%概率值" + tmpstrResult + ";";
            }
        }

        // 假如为空则所有的都满足
        if ("".equals(tmpstrResultVoltageRate)) {
            strResultVoltageRate += "从上表中可以看出" + strLineBaseName + "2-25次谐波电压含有率95%概率值均满足国标限值要求。";
        } else {
            strAnalysis += tmpstrResultVoltageRate + "2-25次谐波电压含有率95%概率值均不满足国标限值要求。";
            strResultVoltageRate += "从上表中可以看出" + strLineBaseName + tmpstrResultVoltageRate + "均不满足国标限值要求。";
        }

        /**************************************************************
         **** 间谐波电压含有率
         ***************************************************************/
        String strResultInVoltageRate = "";
        String tmpstrResultInVoltageRate = "";
        String strResultInVoltageRateValue = "";
        String strInCurrentA, strInCurrentB, strInCurrentC, strInLimit;
        // 获取25次谐波
        for (int i = 1; i < 50; i++) {
            // 间谐波电压含有率
            strInCurrentA = judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(0)).getCp95Value());
            strInCurrentB = judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(1)).getCp95Value());
            strInCurrentC = judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(2)).getCp95Value());
            strInLimit = judgeNull(this.listInVoltageRate.get(i).getOverLimit());

            /************************************
             **** 三张大表取值
             **************************************/
            reportmap.put("$InHV" + (i + 0.5) + "X_A$",
                    judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(0)).getFmaxValue()));
            reportmap.put("$InHV" + (i + 0.5) + "X_B$",
                    judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(1)).getFmaxValue()));
            reportmap.put("$InHV" + (i + 0.5) + "X_C$",
                    judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(2)).getFmaxValue()));

            reportmap.put("$InHV" + (i + 0.5) + "N_A$",
                    judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(0)).getMinValue()));
            reportmap.put("$InHV" + (i + 0.5) + "N_B$",
                    judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(1)).getMinValue()));
            reportmap.put("$InHV" + (i + 0.5) + "N_C$",
                    judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(2)).getMinValue()));

            reportmap.put("$InHV" + (i + 0.5) + "E_A$",
                    judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(0)).getMeanValue()));
            reportmap.put("$InHV" + (i + 0.5) + "E_B$",
                    judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(1)).getMeanValue()));
            reportmap.put("$InHV" + (i + 0.5) + "E_C$",
                    judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(2)).getMeanValue()));

            reportmap.put("$InHV" + (i + 0.5) + "%_A$", strInCurrentA);
            reportmap.put("$InHV" + (i + 0.5) + "%_B$", strInCurrentB);
            reportmap.put("$InHV" + (i + 0.5) + "%_C$", strInCurrentC);
            reportmap.put("$InHV" + (i + 0.5) + "L$", strInLimit);

            try {
                maxValue = Double.parseDouble(strInCurrentA);
                minValue = Double.parseDouble(strInCurrentB);
                aveValue = Double.parseDouble(strInCurrentC);
                limit = Double.parseDouble(strInLimit);
            } catch (Exception e) {
                strResultInVoltageRateValue += "注意:从上表中可以看出" + strLineBaseName + "间谐波电压含有率95%概率值数据存在异常(不是数值类型)。";
            }

            String tmpstrResult = "";
            if (judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(0)).getFmaxValue()) == "/") {
                reportmap.put("$InHV" + (i + 0.5) + "R_A$", "/");
            } else if (maxValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "A";
                reportmap.put("$InHV" + (i + 0.5) + "R_A$", "不合格");// 三张大表取值
            } else {
                reportmap.put("$InHV" + (i + 0.5) + "R_A$", "合格");// 三张大表取值
            }
            if (judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(1)).getFmaxValue()) == "/") {
                reportmap.put("$InHV" + (i + 0.5) + "R_B$", "/");
            } else if (minValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "B";
                reportmap.put("$InHV" + (i + 0.5) + "R_B$", "不合格");// 三张大表取值
            } else {
                reportmap.put("$InHV" + (i + 0.5) + "R_B$", "合格");// 三张大表取值
            }
            if (judgeNull(((ReportValue) this.listInVoltageRate.get(i).getList().get(2)).getFmaxValue()) == "/") {
                reportmap.put("$InHV" + (i + 0.5) + "R_C$", "/");
            } else if (aveValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "C";
                reportmap.put("$InHV" + (i + 0.5) + "R_C$", "不合格");// 三张大表取值
            } else {
                reportmap.put("$InHV" + (i + 0.5) + "R_C$", "合格");// 三张大表取值
            }
            // 判断单个结论是否存在
            if (!"".equals(tmpstrResult)) {
                tmpstrResultInVoltageRate += (i + 0.5) + "次谐波电压含有率95%概率值" + tmpstrResult + ";";
            }
        }

        // 假如为空则所有的都满足
        if ("".equals(tmpstrResultInVoltageRate)) {
            strResultInVoltageRate += "从上表中可以看出" + strLineBaseName + "2-25次谐波电压含有率95%概率值均满足国标限值要求。";
        } else {
            strAnalysis += tmpstrResultVoltageRate + "2-25次谐波电压含有率95%概率值均不满足国标限值要求。";
            strResultInVoltageRate += "从上表中可以看出" + strLineBaseName + tmpstrResultInVoltageRate + "均不满足国标限值要求。";
        }

        /**************************************************************
         **** 间谐波电流幅值
         ***************************************************************/
        String strResultInCurrent = "";
        String tmpstrResultInCurrent = "";
        String strResultInCurrentValue = "";
        // 获取25次谐波
        for (int i = 1; i < 50; i++) {
            // 基波电压含有率
            strCurrentA = judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(0)).getCp95Value());
            strCurrentB = judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(1)).getCp95Value());
            strCurrentC = judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(2)).getCp95Value());
            strLimit = judgeNull(this.listInICurrent.get(i).getOverLimit());

            /************************************
             **** 三张大表取值
             **************************************/
            reportmap.put("$InHI" + (i + 0.5) + "X_A$", judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(0)).getFmaxValue()));
            reportmap.put("$InHI" + (i + 0.5) + "X_B$", judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(1)).getFmaxValue()));
            reportmap.put("$InHI" + (i + 0.5) + "X_C$", judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(2)).getFmaxValue()));

            reportmap.put("$InHI" + (i + 0.5) + "N_A$", judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(0)).getMinValue()));
            reportmap.put("$InHI" + (i + 0.5) + "N_B$", judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(1)).getMinValue()));
            reportmap.put("$InHI" + (i + 0.5) + "N_C$", judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(2)).getMinValue()));

            reportmap.put("$InHI" + (i + 0.5) + "E_A$", judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(0)).getMeanValue()));
            reportmap.put("$InHI" + (i + 0.5) + "E_B$", judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(1)).getMeanValue()));
            reportmap.put("$InHI" + (i + 0.5) + "E_C$", judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(2)).getMeanValue()));

            reportmap.put("$InHI" + (i + 0.5) + "%_A$", strCurrentA);
            reportmap.put("$InHI" + (i + 0.5) + "%_B$", strCurrentB);
            reportmap.put("$InHI" + (i + 0.5) + "%_C$", strCurrentC);
            reportmap.put("$InHI" + (i + 0.5) + "L$", strLimit);

            try {
                maxValue = Double.parseDouble(strCurrentA);
                minValue = Double.parseDouble(strCurrentB);
                aveValue = Double.parseDouble(strCurrentC);
                limit = Double.parseDouble(strLimit);
            } catch (Exception e) {
                strResultInCurrentValue += "注意:从上表中可以看出" + strLineBaseName + "谐波电流幅值95%概率值数据存在异常(不是数值类型)。";
            }

            String tmpstrResult = "";
            if (judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(0)).getFmaxValue()) == "/") {
                reportmap.put("$InHI" + (i + 0.5) + "R_A$", "/");
            } else if (maxValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "A";
                reportmap.put("$InHI" + (i + 0.5) + "R_A$", "不合格");// 三张大表取值
            } else {
                reportmap.put("$InHI" + (i + 0.5) + "R_A$", "合格");// 三张大表取值
            }
            if (judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(1)).getFmaxValue()) == "/") {
                reportmap.put("$InHI" + (i + 0.5) + "R_B$", "/");
            } else if (minValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "B";
                reportmap.put("$InHI" + (i + 0.5) + "R_B$", "不合格");// 三张大表取值
            } else {
                reportmap.put("$InHI" + (i + 0.5) + "R_B$", "合格");// 三张大表取值
            }
            if (judgeNull(((ReportValue) this.listInICurrent.get(i).getList().get(2)).getFmaxValue()) == "/") {
                reportmap.put("$InHI" + (i + 0.5) + "R_C$", "/");
            } else if (aveValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "C";
                reportmap.put("$InHI" + (i + 0.5) + "R_C$", "不合格");// 三张大表取值
            } else {
                reportmap.put("$InHI" + (i + 0.5) + "R_C$", "合格");// 三张大表取值
            }
            // 判断单个结论是否存在
            if (!"".equals(tmpstrResult)) {
                tmpstrResultInCurrent += (i + 0.5) + "次谐波电流幅值95%概率值" + tmpstrResult + ";";
            }
        }

        /**************************************************************
         **** 电压总谐波畸变率(THD)
         ***************************************************************/
        ReportValue distortion1 = (ReportValue) this.listDistortion.get(0).getList().get(0);
        ReportValue distortion2 = (ReportValue) this.listDistortion.get(0).getList().get(1);
        ReportValue distortion3 = (ReportValue) this.listDistortion.get(0).getList().get(2);
        String distortionLimit = judgeNull(this.listDistortion.get(0).getOverLimit());
        reportmap.put("$ThdVR_L$", distortionLimit);

        String strResultDistortion = "";
        String tmpstrResultDistortion = "";
        String strResultDistortionValue = "";

        reportmap.put("$ThdV%_A$", judgeNull(distortion1.getCp95Value()));
        reportmap.put("$ThdV%_B$", judgeNull(distortion2.getCp95Value()));
        reportmap.put("$ThdV%_C$", judgeNull(distortion3.getCp95Value()));

        /************************************
         **** 三张大表取值
         **************************************/
        reportmap.put("$ThdVX_A$", judgeNull(distortion1.getFmaxValue()));
        reportmap.put("$ThdVE_A$", judgeNull(distortion1.getMeanValue()));
        reportmap.put("$ThdVN_A$", judgeNull(distortion1.getMinValue()));

        reportmap.put("$ThdVX_B$", judgeNull(distortion2.getFmaxValue()));
        reportmap.put("$ThdVE_B$", judgeNull(distortion2.getMeanValue()));
        reportmap.put("$ThdVN_B$", judgeNull(distortion2.getMinValue()));

        reportmap.put("$ThdVX_C$", judgeNull(distortion3.getFmaxValue()));
        reportmap.put("$ThdVE_C$", judgeNull(distortion3.getMeanValue()));
        reportmap.put("$ThdVN_C$", judgeNull(distortion3.getMinValue()));

        // 值错误判断
        try {
            cp95ValueA = Math.abs(Double.parseDouble(distortion1.getCp95Value().toString()));
            cp95ValueB = Math.abs(Double.parseDouble(distortion2.getCp95Value().toString()));
            cp95ValueC = Math.abs(Double.parseDouble(distortion3.getCp95Value().toString()));
            limit = Math.abs(Double.parseDouble(distortionLimit));
        } catch (Exception e) {
            strResultDistortionValue += "注意:从上表中可以看出" + strLineBaseName + "电压总谐波畸变率(THD)数据存在异常(不是数值类型)。";
        }
        // 限值判断
        if (judgeNull(distortion1.getFmaxValue()) == "/") {
            reportmap.put("$ThdVR_A$", "/");
        } else if (cp95ValueA > limit) {
            if (!"".equals(tmpstrResultDistortion))
                tmpstrResultDistortion += "、";
            tmpstrResultDistortion += "A相";
            reportmap.put("$ThdVR_A$", "不合格");// 三张大表取值
        } else {
            reportmap.put("$ThdVR_A$", "合格");// 三张大表取值
        }
        if (judgeNull(distortion2.getFmaxValue()) == "/") {
            reportmap.put("$ThdVR_B$", "/");
        } else if (cp95ValueB > limit) {
            if (!"".equals(tmpstrResultDistortion))
                tmpstrResultDistortion += "、";
            tmpstrResultDistortion += "B相";
            reportmap.put("$ThdVR_B$", "不合格");// 三张大表取值
        } else {
            reportmap.put("$ThdVR_B$", "合格");// 三张大表取值
        }
        if (judgeNull(distortion3.getFmaxValue()) == "/") {
            reportmap.put("$ThdVR_C$", "/");
        } else if (cp95ValueC > limit) {
            if (!"".equals(tmpstrResultDistortion))
                tmpstrResultDistortion += "、";
            tmpstrResultDistortion += "C相";
            reportmap.put("$ThdVR_C$", "不合格");// 三张大表取值
        } else {
            reportmap.put("$ThdVR_C$", "合格");// 三张大表取值
        }

        // 假如为空则所有的都满足
        if ("".equals(tmpstrResultDistortion)) {
            strResultDistortion += "电压总谐波畸变率(THD)95%概率值均满足国标限值要求。";
        } else {
            strAnalysis += "电压总谐波畸变率(THD)95%概率值" + tmpstrResultDistortion + "均不满足国标限值要求。";
            strResultDistortion += "电压总谐波畸变率(THD)95%概率值" + tmpstrResultDistortion + "均不满足国标限值要求。";
        }
        strError += strResultVoltageRateValue + strResultDistortionValue;

        /**************************************************************
         **** 谐波电流幅值
         ***************************************************************/
        String strResultCurrent = "";
        String tmpstrResultCurrent = "";
        String strResultCurrentValue = "";
        // 获取50次谐波
        for (int i = 0; i < 50; i++) {
            // 基波电压含有率
            strCurrentA = judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(0)).getCp95Value());
            strCurrentB = judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(1)).getCp95Value());
            strCurrentC = judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(2)).getCp95Value());
            strLimit = judgeNull(this.listICurrent.get(i).getOverLimit());

            /************************************
             **** 三张大表取值
             **************************************/
            reportmap.put("$HI" + (i + 1) + "X_A$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(0)).getFmaxValue()));
            reportmap.put("$HI" + (i + 1) + "X_B$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(1)).getFmaxValue()));
            reportmap.put("$HI" + (i + 1) + "X_C$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(2)).getFmaxValue()));

            reportmap.put("$HI" + (i + 1) + "N_A$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(0)).getMinValue()));
            reportmap.put("$HI" + (i + 1) + "N_B$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(1)).getMinValue()));
            reportmap.put("$HI" + (i + 1) + "N_C$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(2)).getMinValue()));

            reportmap.put("$HI" + (i + 1) + "E_A$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(0)).getMeanValue()));
            reportmap.put("$HI" + (i + 1) + "E_B$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(1)).getMeanValue()));
            reportmap.put("$HI" + (i + 1) + "E_C$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(2)).getMeanValue()));

            reportmap.put("$HI" + (i + 1) + "%_A$", strCurrentA);
            reportmap.put("$HI" + (i + 1) + "%_B$", strCurrentB);
            reportmap.put("$HI" + (i + 1) + "%_C$", strCurrentC);
            reportmap.put("$HI" + (i + 1) + "L$", strLimit);

            try {
                maxValue = Double.parseDouble(strCurrentA);
                minValue = Double.parseDouble(strCurrentB);
                aveValue = Double.parseDouble(strCurrentC);
                limit = Double.parseDouble(strLimit);
            } catch (Exception e) {
                strResultCurrentValue += "注意:从上表中可以看出" + strLineBaseName + "谐波电流幅值95%概率值数据存在异常(不是数值类型)。";
            }

            if (i == 0) {
                continue;
            }
            String tmpstrResult = "";
            if (judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(0)).getFmaxValue()) == "/") {
                reportmap.put("$HI" + (i + 1) + "R_A$", "/");
            } else if (maxValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "A";
                reportmap.put("$HI" + (i + 1) + "R_A$", "不合格");// 三张大表取值
            } else {
                reportmap.put("$HI" + (i + 1) + "R_A$", "合格");// 三张大表取值
            }
            if (judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(1)).getFmaxValue()) == "/") {
                reportmap.put("$HI" + (i + 1) + "R_B$", "/");
            } else if (minValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "B";
                reportmap.put("$HI" + (i + 1) + "R_B$", "不合格");// 三张大表取值
            } else {
                reportmap.put("$HI" + (i + 1) + "R_B$", "合格");// 三张大表取值
            }
            if (judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(2)).getFmaxValue()) == "/") {
                reportmap.put("$HI" + (i + 1) + "R_C$", "/");
            } else if (aveValue > limit) {
                if (!"".equals(tmpstrResult))
                    tmpstrResult += "、";
                tmpstrResult += "C";
                reportmap.put("$HI" + (i + 1) + "R_C$", "不合格");// 三张大表取值
            } else {
                reportmap.put("$HI" + (i + 1) + "R_C$", "合格");// 三张大表取值
            }
            // 判断单个结论是否存在
            if (!"".equals(tmpstrResult)) {
                tmpstrResultCurrent += (i + 1) + "次谐波电流幅值95%概率值" + tmpstrResult + ";";
            }
        }

        // 假如为空则所有的都满足
        if ("".equals(tmpstrResultCurrent)) {
            strResultCurrent += "从上表中可以看出" + strLineBaseName + "2-25次谐波电流幅值95%概率值均满足国标限值要求。";
        } else {
            strAnalysis += tmpstrResultCurrent + "均不满足国标限值要求。";
            strResultCurrent += "从上表中可以看出" + strLineBaseName + tmpstrResultCurrent + "均不满足国标限值要求。";
        }

        strError += strResultCurrentValue;

        // 测试结果填写
        reportmap.put("$ResultTitle$", String.format("通过对（%s——%s）时间段内%s电能质量统计数据分析后得出以下结论：",
                new String[]{(String) formatter.format(tempCondition.getStart()), (String) formatter.format(tempCondition.getEnd()), strLineBaseName}));// 结论标题
        reportmap.put("$Result_VD$", String.format("（1）电压偏差：%s", new String[]{strResultVdeviationdata}));// 电压偏差
        reportmap.put("$Result_FRE$", String.format("（2）频率偏差：%s", new String[]{strResultFre}));// 频率偏差
        reportmap.put("$Result_THE$", String.format("（3）三相电压不平衡度：%s", new String[]{strResultThree}));// 三相电压不平衡度
        reportmap.put("$Result_FIC$", String.format("（4）电压长时闪变：%s", new String[]{strResultFlicker}));// 电压长时闪变
        reportmap.put("$Result_VOL$", String.format("（5）谐波电压：%s", new String[]{strResultVoltageRate}));// 谐波电压
        reportmap.put("$Result_CUR$", String.format("（6）谐波电流：%s", new String[]{strResultCurrent}));// 谐波电流

        /************************************
         **** 三张大表取值 有功:0-11 无功:12-23 视在:24-31 基波有功汇总:32-35 基波无功汇总:36-39
         * 基波视在汇总:40-43 功率因数:44-46
         **************************************/
        ReportValue powerDto1 = (ReportValue) this.listPower.get(0).getList().get(0);
        ReportValue powerDto2 = (ReportValue) this.listPower.get(0).getList().get(1);
        ReportValue powerDto3 = (ReportValue) this.listPower.get(0).getList().get(2);
        reportmap.put("$PsumX$", judgeNull(powerDto1.getFmaxValue()));
        reportmap.put("$PsumN$", judgeNull(powerDto1.getMinValue()));
        reportmap.put("$PsumE$", judgeNull(powerDto1.getMeanValue()));

        reportmap.put("$QsumX$", judgeNull(powerDto2.getFmaxValue()));
        reportmap.put("$QsumN$", judgeNull(powerDto2.getMinValue()));
        reportmap.put("$QsumE$", judgeNull(powerDto2.getMeanValue()));

        reportmap.put("$SsumX$", judgeNull(powerDto3.getFmaxValue()));
        reportmap.put("$SsumN$", judgeNull(powerDto3.getMinValue()));
        reportmap.put("$SsumE$", judgeNull(powerDto3.getMeanValue()));

        /**
         * 结论边界值
         */
        ReportValue vside = getICurrentMapper.VsideValue(tempCondition);
        ReportValue inside = getICurrentMapper.InsideValue(tempCondition);
        ReportValue pside = getICurrentMapper.PsideValue(tempCondition);
        ReportValue qside = getICurrentMapper.QsideValue(tempCondition);

        reportmap.put("$VSideMax$", vside.getFmaxValue() + "%");
        reportmap.put("$InSideMax$", inside.getFmaxValue() + "A");
        reportmap.put("$InSideMin$", inside.getMinValue() + "A");
        reportmap.put("$PSideMax$", pside.getFmaxValue() + "KW");
        reportmap.put("$PSideMin$", pside.getMinValue() + "KW");
        reportmap.put("$QSideMax$", qside.getFmaxValue() + "Kvar");
        reportmap.put("$QSideMin$", qside.getMinValue() + "Kvar");

        /**
         * 暂降事件
         */
        List<Integer> lines = new ArrayList<>();
        lines.add(Integer.valueOf(lineIndex));
        List<EventDetail> events = eventDetailMapper.queryVoltageList(tempCondition.getStart(), tempCondition.getEnd(), lines,null,null,null,null,null,null,null,null,null,null,null);
        String eventlists = "";
        if (events.size() == 0) {
            eventlists = "无";
        } else {
            for (int i = 0; i < events.size(); i++) {
                eventlists += String.valueOf(i + 1) + "、" + events.get(i).getTime() + "发生暂降事件，持续时间" + String.valueOf(events.get(i).getPersistTime())
                        + "s，暂降幅值" + String.valueOf(events.get(i).getEventValue()) + "%;" + "\n";
            }
        }
        reportmap.put("$EventList$", eventlists);

//		reportmap.put("$YF0X$", powerDto.getPower()[44]);
//		reportmap.put("$YF0N$", powerDto.getPower()[45]);
//		reportmap.put("$YF0E$", powerDto.getPower()[46]);
        formatter = new SimpleDateFormat("yyyyMMddHHmm");// 报告时分秒格式
        WordUtil oRTF = new WordUtil();
//		oRTF.rgModel(reportmap, rtfPath, name + formatter.format(currentTime), session);
        try {
            oRTF.getWord(rtfPath, reportmap, bdname + name + "_" + formatter.format(TransformTime.getStart()) + "_" +
                    formatter.format(TransformTime.getEnd()) + "_报告" + ".docx", response, session);
            userLog.getLog("导出word报告", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
        } catch (Exception e) {
            userLog.getLog("导出word报告", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
        }

        String saveresult = deviceReportService.saveReport(bdname + name + "_" + formatter.format(TransformTime.getStart()) + "_" +
                formatter.format(TransformTime.getEnd()) + "_报告" + ".docx");
        return saveresult;
    }

    private void transformData(List<ReportTarget> list, List<ReportValue> listValue, List<Pass> listOverlimit,boolean... b) {
        int offset = b[0] ? 3 : 1;
        offset = (b.length == 2 && !b[1]) ? 4 : offset;
        int i = 0;

        for (int index = 0; index < listValue.size(); index += offset) {
            if (i == listOverlimit.size()) {
                break;
            }
            ReportTarget reportTarget = new ReportTarget();
            reportTarget.setList(listValue.subList(index, index + offset));
            Float overLimit = listOverlimit.get(i).getOverLimit();
            reportTarget.setOverLimit(overLimit);

            switch (listOverlimit.get(i).getCode()) {
                case 1:
                    for (int k = 0; k < reportTarget.getList().size(); k++) {
                        if (null == reportTarget.getList().get(k).getFmaxValue()) {
                            break;
                        } else if (reportTarget.getList().get(k).getFmaxValue().floatValue() > overLimit.floatValue()) {
                            reportTarget.setPass(EnumPass.NOPASS.getCode());
                            break;
                        } else {
                            reportTarget.setPass(EnumPass.PASS.getCode());
                        }
                    }
                    break;
                case 2:
                    for (int k = 0; k < reportTarget.getList().size(); k++) {
                        if (null == reportTarget.getList().get(k).getMinValue()) {
                            break;
                        } else if (reportTarget.getList().get(k).getMinValue().floatValue() > overLimit.floatValue()) {
                            reportTarget.setPass(EnumPass.NOPASS.getCode());
                            break;
                        } else {
                            reportTarget.setPass(EnumPass.PASS.getCode());
                        }
                    }
                    break;
                case 3:
                    for (int k = 0; k < reportTarget.getList().size(); k++) {
                        if (null == reportTarget.getList().get(k).getMeanValue()) {
                            break;
                        } else if (reportTarget.getList().get(k).getMeanValue().floatValue() > overLimit.floatValue()) {
                            reportTarget.setPass(EnumPass.NOPASS.getCode());
                            break;
                        } else {
                            reportTarget.setPass(EnumPass.PASS.getCode());
                        }
                    }
                    break;
                case 4:
                    for (int k = 0; k < reportTarget.getList().size(); k++) {
                        if (null == reportTarget.getList().get(k).getCp95Value()) {
                            break;
                        } else if (reportTarget.getList().get(k).getCp95Value().floatValue() > overLimit.floatValue()) {
                            reportTarget.setPass(EnumPass.NOPASS.getCode());
                            break;
                        } else {
                            reportTarget.setPass(EnumPass.PASS.getCode());
                        }
                    }
                    break;
                default:
                    break;
            }

            i++;
            list.add(reportTarget);
        }
    }

    public void getOverLimitData() {
        Condition condition=getConditionData();
        this.overLimitInfo = getOverLimitDataService.getOverLimitData(condition);
        condition.setCount(this.overLimitInfo.getCount());
        saveConditionData(condition);

    }

    // 基波幅值
    public void getVirtualData() {
        Condition condition=getConditionData();
        List<ReportValue> listVirtual = getVirtualDataService.getVirtualData(condition);

        List<Pass> list = new ArrayList<>();

        for (int i = 0; i < 3; i++) {
            Pass pass = new Pass(null);
            list.add(pass);
        }

        this.listVirtual = new ArrayList<>();
        transformData(this.listVirtual, listVirtual, list, true);
    }

    // 功率
    public void getPowerData() {
        Condition condition=getConditionData();
        List<ReportValue> listPower = getPowerDataService.getPowerData(condition);

        List<Pass> list = new ArrayList<>();

        for (int i = 0; i < 4; i++) {
            Pass pass = new Pass(null);
            list.add(pass);
        }

        this.listPower = new ArrayList<>();
        transformData(this.listPower, listPower, list, true, false);
    }

    // 闪变
    public void getFlicker() {
        Condition condition=getConditionData();
        List<ReportValue> listFlicker = getFlickerDataService.getFlickerData(condition);

        List<Pass> list = new ArrayList<>();

        for (int i = 0; i < 2; i++) {
            Pass pass;

            if (i == 1) {
                pass = new Pass(overLimitInfo.getOverLimitRate().get(0).getFlicker(), EnumPass.MAX.getCode());
            } else {
                pass = new Pass(null);
            }

            list.add(pass);
        }

        this.listFlicker = new ArrayList<>();
        transformData(this.listFlicker, listFlicker, list, true);
    }

    // 电压偏差
    public void getVdeviation() {
        Condition condition=getConditionData();
        List<ReportValue> listVdeviation = getVdeviationDataService.getVdeviation(condition);

        List<Pass> list = new ArrayList<>();

        for (int i = 0; i < 2; i++) {
            Pass pass;
            pass = new Pass(overLimitInfo.getOverLimitRate().get(0).getVoltageDev(), EnumPass.MAX.getCode());
            list.add(pass);
        }

        this.listVdeviation = new ArrayList<>();
        transformData(this.listVdeviation, listVdeviation, list, true);
    }

    // 畸变率
    public void getDistortion() {
        Condition condition=getConditionData();
        List<ReportValue> listDistortion = getDistortionDataService.getDistortionData(condition);

        List<Pass> list = new ArrayList<>();

        for (int i = 0; i < 2; i++) {
            Pass pass;

            if (i == 0) {
                pass = new Pass(overLimitInfo.getOverLimitRate().get(0).getUaberrance(), EnumPass.MAX.getCode());
            } else {
                pass = new Pass(null);
            }

            list.add(pass);
        }

        this.listDistortion = new ArrayList<>();
        transformData(this.listDistortion, listDistortion, list, true);
    }

    // 频率
    public void getFre() {
        Condition condition=getConditionData();
        List<ReportValue> listFrequency = getFrequencyDataService.getFrequencyData(condition);

        List<Pass> list = new ArrayList<>();

        for (int i = 0; i < 2; i++) {
            Pass pass;

            if (i == 1) {
                pass = new Pass(overLimitInfo.getOverLimitRate().get(0).getFreqDev(), EnumPass.MAX.getCode());
            } else {
                pass = new Pass(null);
            }

            list.add(pass);
        }

        this.listFrequency = new ArrayList<>();
        transformData(this.listFrequency, listFrequency, list, false);
    }

    // 三相不平衡
    public void getThreePhase() {
        Condition condition=getConditionData();
        List<ReportValue> listThreephase = getThreephaseDataService.getThreephase(condition);

        List<Pass> list = new ArrayList<>();

        for (int i = 0; i < 8; i++) {
            Pass pass;

            if (i == 0) {
                pass = new Pass(overLimitInfo.getOverLimitRate().get(0).getUbalance(), EnumPass.CP95.getCode());
            } else {
                pass = new Pass(null);
            }

            list.add(pass);
        }

        this.listThreephase = new ArrayList<>();
        transformData(this.listThreephase, listThreephase, list, false);
    }

    // 谐波电流
    public void getCurrentRate() {
        Condition condition=getConditionData();
        List<ReportValue> listICurrent = getICurrentService.getICurrent(condition);

        List<Pass> list = new ArrayList<>();

        for (int i = 0; i < 50; i++) {
            Pass pass;

            if (i < overLimitInfo.getOverLimitRate().get(0).getIHarmList().size() + 1 && i > 0) {
                pass = new Pass(overLimitInfo.getOverLimitRate().get(0).getIHarmList().get(i - 1),
                        EnumPass.CP95.getCode());
            } else {
                pass = new Pass(null);
            }

            list.add(pass);
        }

        this.listICurrent = new ArrayList<>();
        transformData(this.listICurrent, listICurrent, list, true);
    }

    // 谐波电压
    public void getVoltageRate() {
        Condition condition=getConditionData();
        List<ReportValue> listVoltageRate = getVoltageRateService.getVoltageRate(condition);

        List<Pass> list = new ArrayList<>();

        for (int i = 0; i < 51; i++) {
            Pass pass;

            if (i == 0) {
                pass = new Pass(null);
            } else if (i == 50) {
                pass = new Pass(overLimitInfo.getOverLimitRate().get(0).getUaberrance(), EnumPass.MAX.getCode());
            } else if (i < overLimitInfo.getOverLimitRate().get(0).getVHarmList().size() + 1) {
                pass = new Pass(overLimitInfo.getOverLimitRate().get(0).getVHarmList().get(i - 1),
                        EnumPass.CP95.getCode());
            } else {
                pass = new Pass(null);
            }

            list.add(pass);
        }

        this.listVoltageRate = new ArrayList<>();
        transformData(this.listVoltageRate, listVoltageRate, list, true);
    }

    // 间谐波电流
    public void getInCurrentRate() {
        Condition condition=getConditionData();
        List<ReportValue> listInICurrent = getInICurrentService.getInICurrent(condition);

        List<Pass> list = new ArrayList<>();

        for (int i = 0; i < 50; i++) {
            Pass pass;

            if (i < overLimitInfo.getOverLimitRate().get(0).getIHarmList().size() + 1 && i > 0) {
                pass = new Pass(overLimitInfo.getOverLimitRate().get(0).getIHarmList().get(i - 1),
                        EnumPass.CP95.getCode());
            } else {
                pass = new Pass(null);
            }

            list.add(pass);
        }

        this.listInICurrent = new ArrayList<>();
        transformData(this.listInICurrent, listInICurrent, list, true);
    }

    // 间谐波电压
    public void getInVoltageRate() {
        Condition condition=getConditionData();
        List<ReportValue> listInVoltageRate = getInVoltageRateService.getInVoltageRate(condition);

        List<Pass> list = new ArrayList<>();

        for (int i = 0; i < 51; i++) {
            Pass pass;

            if (i == 0) {
                pass = new Pass(null);
            } else if (i == 50) {
                pass = new Pass(overLimitInfo.getOverLimitRate().get(0).getUaberrance(), EnumPass.MAX.getCode());
            } else if (i < overLimitInfo.getOverLimitRate().get(0).getVHarmList().size() + 1) {
                pass = new Pass(overLimitInfo.getOverLimitRate().get(0).getVHarmList().get(i - 1),
                        EnumPass.CP95.getCode());
            } else {
                pass = new Pass(null);
            }

            list.add(pass);
        }

        this.listInVoltageRate = new ArrayList<>();
        transformData(this.listInVoltageRate, listInVoltageRate, list, true);
    }

    public String judgeNull(Float result) {
        return (result == null) ? "/" : result.toString();
    }

    @GetMapping("downloadModel")
    public void downloadExport(HttpServletResponse response, HttpSession session) throws UnsupportedEncodingException {
        String tmpPath = (String) session.getAttribute("tmpPath");
        String filename = (String) session.getAttribute("fileName");
        
        // 设置输出的格式
        response.reset();
        response.setContentType("application/docx");
        response.addHeader("Content-Disposition",
                "attachment; filename=" + new String(filename.getBytes("gb2312"), "ISO8859-1"));
        // 循环取出流中的数据
        byte[] b = new byte[100];
        int len;
        if (StringUtils.isBlank(tmpPath)) {

        } else {
	        if (!StringUtils.isBlank(tmpPath)) {
	            tmpPath= ClearPathUtil.cleanString(tmpPath);
	            // 读到流中
	            InputStream inStream = null;
	            try {
	                inStream = new FileInputStream(tmpPath);
	
	                if(null!=inStream){
	                    while ((len = inStream.read(b)) > 0)
	                        response.getOutputStream().write(b, 0, len);
	                }
	            } catch (IOException e) {
	                // TODO Auto-generated catch block
	                logger.error("读取报表信息失败：" + e.getMessage());
	            }
	            finally {
	                if (inStream != null) {
	                    try{
                            inStream.close();
                        }catch (Exception e){
                            logger.error("关闭输入流异常，异常为："+e.toString());
                        }
	                }
	            }
	
	        }
	        // 清除session中的数据
	        session.removeAttribute("fileName");
	        session.removeAttribute("tmpPath");
        }

    }

    @RequestMapping(value = "loadReportInfo", method = RequestMethod.POST)
    @ResponseBody
    public String loadReportInfo(HttpSession session) throws JsonProcessingException {
        List<Report> result = new ArrayList<Report>();
        List<List> s = new ArrayList<List>();

        int j = 0;

        result = reportMapper.getAll();

        for (int i = 0; i < result.size(); i++) {
            List<String> a = new ArrayList<String>();
            a.add(result.get(i).getReportIndex());
            a.add(result.get(i).getReportName());
            User user = userMapper.selectId(result.get(i).getUserIndex());
            a.add(user.getName());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            a.add(sdf.format(result.get(i).getSavetime()));
            if (StringUtil.isEmpty(result.get(i).getUpuserIndex())) {
                a.add("无");
                a.add("无");
            } else {
                User user1 = userMapper.selectId(result.get(i).getUpuserIndex());
                a.add(user1.getName());
                a.add(sdf.format(result.get(i).getUpdatetime()));
            }
            s.add(a);
        }

        return objectMapper.writeValueAsString(s);
    }

    @RequestMapping(value = "delReportInfo", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult delReportInfo(HttpServletRequest request, String reportIndex, String reportName) {
        HttpResult result = new HttpResult();

        try {
            int falg = reportMapper.deleteByPrimaryKey(reportIndex);
            Properties pros = PubUtils.readProperties(getClass().getClassLoader(),"java.properties");
            String tmpPath = pros.get("TMP_PATH").toString() +File.separator+ "offlinereoprt" + File.separator+ reportName;
            File file = new File(tmpPath);
            if (file.exists()) {
                file.delete();
            }
            String tmpfile = pros.get("TMP_PATH").toString() + File.separator+"offlinereoprtupdate" + File.separator+ reportName;
            File upd = new File(tmpfile);
            if (upd.exists()) {
                upd.delete();
            }
            result.setCode(200);
            result.setMessage("删除成功!");
        } catch (Exception e) {
            result.setCode(500);
            result.setMessage("删除失败!");
        }
        return result;
    }

    @RequestMapping(value = "checkReport", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult checkReport(HttpServletResponse response, HttpSession session, String reportName) throws UnsupportedEncodingException {
        HttpResult result = new HttpResult();
        String tmppath = "";
        tmppath = appConfig.getTmppath() + File.separator+"offlinereoprt" + File.separator + reportName;
        File file = new File(tmppath);
        if (!file.exists()) {
            result.setCode(500);
            result.setMessage("下载失败,文件不存在!");
        } else {
            result.setCode(200);
            result.setMessage("");
            session.setAttribute("reportName", reportName);
        }
        return result;
    }

    @RequestMapping(value = "checkUpReport", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult checkUpReport(HttpServletResponse response, HttpSession session, String reportName) throws UnsupportedEncodingException {
        HttpResult result = new HttpResult();
        String tmppath = "";
        tmppath = appConfig.getTmppath() + File.separator+"offlinereoprtupdate" + File.separator+reportName;
        File file = new File(tmppath);
        if (!file.exists()) {
            result.setCode(500);
            result.setMessage("下载失败,未找到文件!");
        } else {
            result.setCode(200);
            result.setMessage("");
            session.setAttribute("reportName", reportName);
        }
        return result;
    }

    @GetMapping("downReport")
    public void downReport(HttpServletResponse response, HttpSession session) throws UnsupportedEncodingException {
        HttpResult result = new HttpResult();
        // 读到流中
        InputStream inStream = null;
        String reportName = (String) session.getAttribute("reportName");
        session.removeAttribute("reportName");
        try {
            String tmppath =appConfig.getTmppath() + File.separator+"offlinereoprt" + File.separator+ reportName;
            tmppath= ClearPathUtil.cleanString(tmppath);
            inStream = new FileInputStream(tmppath);
        } catch (FileNotFoundException e) {
            logger.error("读取报表信息失败：" + e.getMessage());
        } finally {
            if (inStream != null) {
                try {
                    inStream.close();
                } catch (IOException e) {
                    logger.error("关闭输入流异常，异常为："+e.toString());
                }
            }
        }
        // 设置输出的格式
        response.reset();
        response.setContentType("application/docx");
        response.addHeader("Content-Disposition",
                "attachment; filename=" + new String(reportName.getBytes("gb2312"), "ISO8859-1"));
        // 循环取出流中的数据
        byte[] b = new byte[100];
        int len;
        try {
            if(null!=inStream){
                while ((len = inStream.read(b)) > 0)
                    response.getOutputStream().write(b, 0, len);
                inStream.close();
            }
        } catch (IOException e) {
            logger.error("读取流中的数据发生异常，异常是"+e.getMessage());
        }
    }

    @GetMapping("downUpReport")
    public void downUpReport(HttpServletResponse response, HttpSession session) throws UnsupportedEncodingException {
        HttpResult result = new HttpResult();
        // 读到流中
        InputStream inStream = null;
        String reportName = (String) session.getAttribute("reportName");
        session.removeAttribute("reportName");
        try {
            String tmppath = appConfig.getTmppath() + File.separator+"offlinereoprtupdate" +File.separator+ reportName;
            tmppath= ClearPathUtil.cleanString(tmppath);
            inStream = new FileInputStream(tmppath);
        } catch (FileNotFoundException e) {
            logger.error("读取报表信息失败：" + e.getMessage());
        } finally {
            if (inStream != null) {
                try {
                    inStream.close();
                } catch (IOException e) {
                    logger.error("关闭输入流异常，异常为："+e.toString());
                }
            }
        }
        // 设置输出的格式
        response.reset();
        response.setContentType("application/docx");
        response.addHeader("Content-Disposition",
                "attachment; filename=" + new String(reportName.getBytes("gb2312"), "ISO8859-1"));
        // 循环取出流中的数据
        byte[] b = new byte[100];
        int len;
        try {
            if(null!=inStream){
                while ((len = inStream.read(b)) > 0)
                    response.getOutputStream().write(b, 0, len);
                inStream.close();
            }
        } catch (IOException e) {
            logger.error("读取流中的数据发生异常，异常是"+e.getMessage());
        }
    }

    @RequestMapping(value = "updatereport", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult updatereport(@RequestParam(value = "file", required = false) MultipartFile file, @Param(value = "reportIndex")
            String reportIndex, @Param(value = "reportName") String reportName, HttpServletResponse response) {
        HttpResult result;
        /**
         * -------------------------------------------------------------------------------------------------------------
         * xuyang 2020.08.27
         * 修改：对上传文件做判断
         * 1.文件类型 2.文件大小
         */
        //文件名
        String fileName = file.getOriginalFilename();
        //文件大小(此大小为kb)
        Long fileSize  = file.getSize()/1024;
        //获取文件后缀,判断上传文件格式
        String subffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
        //判断文件大小
        if (fileSize > 3072){
            result = PubUtils.assignmentResult(null, 500, "上传失败，上传文件超过3M，文件过大！");
            return result;
        }

        // 判断文件类型
        if (!"doc".equals(subffix)){
            result = PubUtils.assignmentResult(null, 500, "上传失败，文件类型错误，只能上传Doc文件！");
            return result;
        }
        /**
         * over
         * -------------------------------------------------------------------------------------------------------------
         */

        InputStream is = null;

        String tmppath = "";
        tmppath = appConfig.getTmppath() + File.separator+"offlinereoprtupdate";
        String tmpPath = tmppath + File.separator+file.getOriginalFilename();
        File tmpdir = new File(tmppath);
        if (!tmpdir.exists()) {
            tmpdir.mkdir();
        }
        File tmpfile = new File(tmpPath);
        if (tmpfile.exists()) {
            tmpfile.delete();
        }

        try {
            is = file.getInputStream();
            CustomXWPFDocument doc = new CustomXWPFDocument(is);
            PubUtils.createFile(tmpPath);
            OutputStream os = new FileOutputStream(tmpPath);
            doc.write(os);
            this.close(os);
            this.close(is);

            String save = deviceReportService.updateReport(reportIndex, file.getOriginalFilename());
            if (save == "success") {
                result = PubUtils.assignmentResult(null, 200, "上传成功");
            } else {
                result = PubUtils.assignmentResult(null, 500, "上传失败");
            }
        } catch (Exception e) {
            result = PubUtils.assignmentResult(null, 500, "上传失败");
        }
        return result;
    }

    @RequestMapping(value = "changesvg", method = RequestMethod.POST)
    @ResponseBody
    public void changesvg(HttpSession session, String charData, String targetName, String Typename) {
        try {
            String tmppath = appConfig.getTmppath() + "reportImg";
            File tmpdir = new File(tmppath);
            if (!tmpdir.exists()) {
                tmpdir.mkdir();
            }
            SvgPngConverter.convertToPng(charData, tmppath + File.separator+ targetName + Typename + ".png");
            session.setAttribute("pngpath", tmppath + File.separator+ targetName + Typename + ".png");
            session.setAttribute("targetName", targetName);
            session.setAttribute("Typename", Typename);
        } catch (IOException|TranscoderException e) {
            logger.error("更改图标发生异常，异常是"+e.getMessage());
        }
    }

    @RequestMapping(value = "readpng", method = RequestMethod.POST)
    @ResponseBody
    public void readpng(HttpServletResponse response, HttpSession session) throws UnsupportedEncodingException {
        String pngpath = (String) session.getAttribute("pngpath");
        String targetName = (String) session.getAttribute("targetName");
        String Typename = (String) session.getAttribute("Typename");
        session.removeAttribute("pngpath");
        session.removeAttribute("targetName");
        session.removeAttribute("Typename");

        String result = SvgPngConverter.getImageBASE64Encoder(session, pngpath, targetName, Typename);
    }


    /**
     * 保存condition数据
     * @param condition 数据
     */
    private void saveConditionData(Condition condition) {
        String userId = TokenManager.getUserId();
        String key = userId+"DeviceReportController";
        JSONObject conditionJson=JSONObject.fromObject(condition);
        jedisManager.saveValueByKey(RedisDB.LONG_TIME_QUERY,key,conditionJson.toString(),-1);
    }

    /**
     * 获取condition数据
     */
    private Condition getConditionData() {
        String userId = TokenManager.getUserId();
        String key = userId+"DeviceReportController";
        String valueJson = jedisManager.getValueByKey(RedisDB.LONG_TIME_QUERY, key);
        JSONObject conditionJSONObject=JSONObject.fromObject(valueJson);
        return (Condition) JSONObject.toBean(conditionJSONObject,Condition.class);
    }
}

