package com.pqs9000.controller.business;

import com.njcn.enums.LogTypeEnum;
import com.njcn.pojo.commons.*;
import com.njcn.pojo.commons.device.*;
import com.njcn.pojo.configuration.PlateResult;
import com.njcn.pojo.configuration.PlateResultDetail;
import com.njcn.pojo.plate.PlateReportDetail;
import com.njcn.service.configuration.PlateResultService;
import com.njcn.service.configuration.TreeService;
import com.njcn.service.log.UserLogDetailService;
import com.njcn.shiro.token.TokenManager;
import com.njcn.sso.pojo.user.User;
import com.njcn.utils.*;
import com.njcn.utils.redis.JedisManager;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import tk.mybatis.mapper.util.StringUtil;

import javax.annotation.Resource;
import javax.security.auth.login.AccountException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.ParseException;
import java.util.*;
import java.util.regex.Pattern;

/***
 * 电镀controller
 * @author denghuajun
 * @time 2021-06-12 10:13
 */
@Controller
@RequestMapping(value = "plate")
public class PlateController {

    private static final Logger logger = LoggerFactory.getLogger(PlateController.class);

    @Resource
    private TreeService getDeviceTree;

    @Autowired
    COverlimit cOverlimit;


    @Autowired
    UserLogDetailService userLog;

    @Autowired
    JedisManager jedisManager;

    @Resource
    PlateResultService plateResultService;


    /**
     * 电镀相关终端树
     */
    /**
     * 终端树
     *
     * @return
     */
    @RequestMapping(value = "platetree", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getPlateTree(String startTime, String endTime) {
        HttpResult result;
        DatePojo datePojo;
        datePojo = PubUtils.validateDate(startTime, endTime, "tree");
        if (!StringUtils.isEmpty(datePojo.getMsg())) {
            result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
            return result;
        }

        User user = TokenManager.getToken();
        List<Tree> data;
        try {
            data = getDeviceTree.getNodePlateTreedata(user.getLoginName(), datePojo.getStartTime(), datePojo.getEndTime());
            result = PubUtils.assignmentResult(data, 200, "获取设备树信息成功");
        } catch (Exception e) {
            result = PubUtils.assignmentResult(null, 200, "获取设备树信息失败");
        }
        return result;
    }

    /**
     * 终端树
     *
     * @return
     */
    @RequestMapping(value = "nodeplatetree", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult getNodePlatetree(String startTime, String endTime) {
        HttpResult result;
        DatePojo datePojo;
        datePojo = PubUtils.validateDate(startTime, endTime, "tree");
        if (!StringUtils.isEmpty(datePojo.getMsg())) {
            result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
            return result;
        }

        User user = TokenManager.getToken();
        List<Tree> data;
        try {
            data = getDeviceTree.getNodePlateTreedata(user.getLoginName(), datePojo.getStartTime(), datePojo.getEndTime());
            result = PubUtils.assignmentResult(data, 200, "获取设备树信息成功");
        } catch (Exception e) {
            result = PubUtils.assignmentResult(null, 200, "获取设备树信息失败");
        }
        return result;
    }

    /**
     * 电压等级终端树
     *
     * @return
     */
    @RequestMapping(value = "scalePlateTree", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult devTypePlateTree(String startTime, String endTime) {
        HttpResult result;
        DatePojo datePojo;
        datePojo = PubUtils.validateDate(startTime, endTime, "tree");
        if (!StringUtils.isEmpty(datePojo.getMsg())) {
            result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
            return result;
        }

        User user = TokenManager.getToken();
        List<Tree> data;
        try {
            data = getDeviceTree.getScalePlateTree(user.getLoginName(), datePojo.getStartTime(), datePojo.getEndTime());
            result = PubUtils.assignmentResult(data, 200, "获取设备树信息成功");
        } catch (Exception e) {
            result = PubUtils.assignmentResult(null, 200, "获取设备树信息失败");
        }
        return result;
    }

    /**
     * 厂家终端树
     *
     * @return
     */
    @RequestMapping(value = "mancPlateTree", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult mancPlateTree(String startTime, String endTime) {
        HttpResult result;
        DatePojo datePojo;
        datePojo = PubUtils.validateDate(startTime, endTime, "tree");
        if (!StringUtils.isEmpty(datePojo.getMsg())) {
            result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
            return result;
        }

        User user = TokenManager.getToken();
        List<Tree> data;
        try {
            data = getDeviceTree.getMancPlateTree(user.getLoginName(), datePojo.getStartTime(), datePojo.getEndTime());
            result = PubUtils.assignmentResult(data, 200, "获取设备树信息成功");
        } catch (Exception e) {
            result = PubUtils.assignmentResult(null, 200, "获取设备树信息失败");
        }
        return result;
    }

    /**
     * 干扰源类型终终端树
     *
     * @return
     */
    @RequestMapping(value = "loadTypePlateTree", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult loadTypePlateTree(String startTime, String endTime) {
        HttpResult result;
        DatePojo datePojo;
        datePojo = PubUtils.validateDate(startTime, endTime, "tree");
        if (!StringUtils.isEmpty(datePojo.getMsg())) {
            result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
            return result;
        }

        User user = TokenManager.getToken();
        List<Tree> data;
        try {
            data = getDeviceTree.getLoadTypePlateTree(user.getLoginName(), datePojo.getStartTime(), datePojo.getEndTime());
            result = PubUtils.assignmentResult(data, 200, "获取设备树信息成功");
        } catch (Exception e) {
            result = PubUtils.assignmentResult(null, 200, "获取设备树信息失败");
        }
        return result;
    }

    /**
     * 国网上报终端树
     *
     * @return
     */
    @RequestMapping(value = "monitorTree", method = RequestMethod.POST)
    @ResponseBody
    public HttpResult monitorTree(String startTime, String endTime) {
        HttpResult result;
        DatePojo datePojo;
        datePojo = PubUtils.validateDate(startTime, endTime, "tree");
        if (!StringUtils.isEmpty(datePojo.getMsg())) {
            result = PubUtils.assignmentResult(null, 500, datePojo.getMsg());
            return result;
        }

        User user = TokenManager.getToken();
        List<Tree> data;
        try {
            data = getDeviceTree.getMonitorPlateTree(user.getLoginName(), datePojo.getStartTime(), datePojo.getEndTime());
            result = PubUtils.assignmentResult(data, 200, "获取设备树信息成功");
        } catch (Exception e) {
            result = PubUtils.assignmentResult(null, 200, "获取设备树信息失败");
        }
        return result;
    }


    /**
     * @return com.njcn.pojo.configuration.HistoryResult
     * @Author denghuajun
     * @Description //TODO 获取电度数据
     * @Date 2021/6/13 10:13
     * @Param [request, startTime, endTime, lineIndex, type, number]
     **/
    @RequestMapping(value = "getPlateResult", method = RequestMethod.POST)
    @ResponseBody
    public PlateResult getHistoryResult(HttpServletRequest request, String obj, String type,
                                        String number) throws AccountException {
        int num = 0;
        PlateResult result = new PlateResult();
        JSONArray json = JSONArray.fromObject(obj); //使用net.sf.json.JSONObject对象来解析json
        String condition = (String) json.getJSONObject(0).get("condition");//指标
        String startTime = (String) json.getJSONObject(0).get("startTime");//起始时间
        String endTime = (String) json.getJSONObject(0).get("endTime");//结束时间
        String point = (String) json.getJSONObject(0).get("point");//监测点
        //String dataTail = (String) json.getJSONObject(0).get("dataTail");//数据展示方式
        String valueType = (String) json.getJSONObject(0).get("valueType");//指标详细
        Long lineIndex;
        //进行时间判断
        String beginQuery = (String) json.getJSONObject(0).get("startAllTime");
        String endQuery = (String) json.getJSONObject(0).get("endAllTime");

        try {
            lineIndex = Long.valueOf(point);
            PlateResult resultTemp = new PlateResult();
            number = String.valueOf(1);
            if (Integer.parseInt(condition) == 21 || Integer.parseInt(condition) == 22) {
                number = String.valueOf(json.getJSONObject(0).get("harmonic"));
            }
            switch (Integer.parseInt(condition)) {
                case 11:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getZYGDNValue";       //正向有功电能
                            break;
                        case 2:
                            type = "getFYGDNValue";      //反向有功电能
                            break;
                        case 3:
                            type = "getZHYGDNValue";     //组合有功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 111:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getSXZYGDNValue";       //三相总正向有功电能
                            break;
                        case 2:
                            type = "getSXFYGDNValue";      //三相总反向有功电能
                            break;
                        case 3:
                            type = "getSXZHYGDNValue";     //三相总组合有功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 12:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getXOneWGValue";       //象限1无功电能
                            break;
                        case 2:
                            type = "getXTwoWGValue";      //象限2无功电能
                            break;
                        case 3:
                            type = "getXThreeWGValue";     //象限3无功电能
                            break;
                        case 4:
                            type = "getXFourWGValue";     //象限4无功电能
                            break;
                        case 5:
                            type = "getZHOneValue";      //组合1无功电能
                            break;
                        case 6:
                            type = "getZHTwoValue";      //组合2无功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 121:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getSXXOneWGValue";       //三相总象限1无功电能
                            break;
                        case 2:
                            type = "getSXXTwoWGValue";      //三相总象限2无功电能
                            break;
                        case 3:
                            type = "getSXXThreeWGValue";     //三相总象限3无功电能
                            break;
                        case 4:
                            type = "getSXXFourWGValue";     //三相总象限4无功电能
                            break;
                        case 5:
                            type = "getSXZHOneValue";      //三相总组合1无功电能
                            break;
                        case 6:
                            type = "getSXZHTwoValue";      //三相总组合2无功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 13:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getZSZDNValue";       //正向视在电能
                            break;
                        case 2:
                            type = "getFSZDNValue";      //反向视在电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 131:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getSXZSZDNValue";       //三相总正向视在电能
                            break;
                        case 2:
                            type = "getSXFSZDNValue";      //三相总反向视在电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 14:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getZJBYGValue";       //正向基波有功电能
                            break;
                        case 2:
                            type = "getFJBYGValue";      //反向基波有功电能
                            break;
                        case 3:
                            type = "getZHJBYGValue";     //组合基波有功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 141:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getSXZJBYGValue";       //三相总正向基波有功电能
                            break;
                        case 2:
                            type = "getSXFJBYGValue";      //三相总反向基波有功电能
                            break;
                        case 3:
                            type = "getSXZHJBYGValue";     //三相总组合基波有功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 15:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getXOneJBWGValue";       //象限1基波无功电能
                            break;
                        case 2:
                            type = "getXTwoJBWGValue";      //象限2基波无功电能
                            break;
                        case 3:
                            type = "getXThreeJBWGValue";     //象限3基波无功电能
                            break;
                        case 4:
                            type = "getXFourJBWGValue";     //象限4基波无功电能
                            break;
                        case 5:
                            type = "getZHOneJBValue";      //组合1基波无功电能
                            break;
                        case 6:
                            type = "getZHTwoJBValue";      //组合2无功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 151:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getSXXOneJBWGValue";       //三相总象限1基波无功电能
                            break;
                        case 2:
                            type = "getSXXTwoJBWGValue";      //三相总象限2基波无功电能
                            break;
                        case 3:
                            type = "getSXXThreeJBWGValue";     //三相总象限3基波无功电能
                            break;
                        case 4:
                            type = "getSXXFourJBWGValue";     //三相总象限4基波无功电能
                            break;
                        case 5:
                            type = "getSXZHOneJBValue";      //三相总组合1基波无功电能
                            break;
                        case 6:
                            type = "getSXZHTwoJBValue";      //三相总组合2无功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 16:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getZZXBYGValue";       //正向总谐波有功电能
                            break;
                        case 2:
                            type = "getFZXBYGValue";      //反向总谐波有功电能
                            break;
                        case 3:
                            type = "getZHZXBYGValue";     //组合总谐波有功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 161:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getSXZZXBYGValue";       //三相总正向总谐波有功电能
                            break;
                        case 2:
                            type = "getSXFZXBYGValue";      //三相总反向总谐波有功电能
                            break;
                        case 3:
                            type = "getSXZHZXBYGValue";     //三相总组合总谐波有功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 17:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getXOneZXBWGValue";       //象限1总谐波无功电能
                            break;
                        case 2:
                            type = "getXTwoZXBWGValue";      //象限2总谐波无功电能
                            break;
                        case 3:
                            type = "getXThreeZXBWGValue";     //象限3总谐波无功电能
                            break;
                        case 4:
                            type = "getXFourZXBWGValue";     //象限4总谐波无功电能
                            break;
                        case 5:
                            type = "getZHOneZXBWGValue";      //组合1总谐波无功电能
                            break;
                        case 6:
                            type = "getZHTwoZXBWGValue";      //组合2总谐波无功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 171:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getSXXOneZXBWGValue";       //三相总象限1总谐波无功电能
                            break;
                        case 2:
                            type = "getSXXTwoZXBWGValue";      //三相总象限2总谐波无功电能
                            break;
                        case 3:
                            type = "getSXXThreeZXBWGValue";     //三相总象限3总谐波无功电能
                            break;
                        case 4:
                            type = "getSXXFourZXBWGValue";     //三相总象限4总谐波无功电能
                            break;
                        case 5:
                            type = "getSXZHOneZXBWGValue";      //三相总组合1总谐波无功电能
                            break;
                        case 6:
                            type = "getSXZHTwoZXBWGValue";      //三相总组合2总谐波无功电能
                            break;
                        default:
                            break;
                    }
                    break;
                case 21:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getZXBYGValue";       //1-50次正向谐波有功电能
                            break;
                        case 2:
                            type = "getFXBYGValue";      //1-50次反向谐波有功电能
                            break;
                    }
                    break;
                case 22:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getXOneXBWGValue";       //1-50次I象限谐波无功电能
                            break;
                        case 2:
                            type = "getXTwoXBWGValue";      //1-50次I象限谐波无功电能
                            break;
                        case 3:
                            type = "getXThreeXBWGValue";       //1-50次III象限谐波无功电能
                            break;
                        case 4:
                            type = "getXFourXBWGValue";      //1-50次IV象限谐波无功电能
                            break;
                    }
                    break;
                case 31:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getZYGXLValue";       //正向有功需量
                            break;
                        case 2:
                            type = "getFYGXLValue";      //反向有功需量
                            break;
                        case 3:
                            type = "getZHYGXLValue";     //组合有功需量
                            break;
                    }
                    break;
                case 32:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            type = "getXOneWGXLValue";       //象限1总谐波无功需量
                            break;
                        case 2:
                            type = "getXTwoWGXLValue";      //象限2总谐波无功需量
                            break;
                        case 3:
                            type = "getXThreeWGXLValue";     //象限3总谐波无功需量
                            break;
                        case 4:
                            type = "getXFourWGXLValue";     //象限4总谐波无功需量
                            break;
                        case 5:
                            type = "getZHOneWGXLValue";      //组合1总谐波无功需量
                            break;
                        case 6:
                            type = "getZHTwoWGXLValue";      //组合2总谐波无功需量
                            break;
                    }
                    break;
                default:
                    break;
            }

            //xuyang_add number增加正则判断，只能读取非0的正整数
            String pattern = "^\\+?[1-9][0-9]*$";
            if (!StringUtil.isEmpty(number) && Pattern.matches(pattern, number)) {
                resultTemp = plateResultService.getPlateResult(startTime, endTime, lineIndex, type, number, Integer.parseInt(condition));
                result.setData(resultTemp.getData());
            }
            userLog.getLog("查询电度数据", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
        } catch (Exception e) {
            userLog.getLog("查询电度数据", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
            logger.error("获取电度数据，异常是" + e.toString());
        }
        return result;
    }


    /**
     * @return com.njcn.pojo.configuration.HistoryResult
     * @Author denghuajun
     * @Description //TODO 获取电度数据
     * @Date 2021/6/13 10:13
     * @Param [request, startTime, endTime, lineIndex, type, number]
     **/
    @RequestMapping(value = "getPlateReportResult", method = RequestMethod.POST)
    @ResponseBody
    public PlateReportDetail getPlateReportResult(HttpServletRequest request, String obj, String type) throws AccountException {
        PlateReportDetail result = new PlateReportDetail();
        JSONArray json = JSONArray.fromObject(obj); //使用net.sf.json.JSONObject对象来解析json
        String condition = (String) json.getJSONObject(0).get("condition");//指标
        String startTime = (String) json.getJSONObject(0).get("startTime");//起始时间
        String endTime = (String) json.getJSONObject(0).get("endTime");//结束时间
        String point = (String) json.getJSONObject(0).get("point");//监测点
        String timeType = String.valueOf(json.getJSONObject(0).get("timeType"));//指标详细
        String valueType = (String) json.getJSONObject(0).get("valueType");//指标详细
        Long lineIndex;
        String syllableName = "";
        //进行时间判断
        String beginQuery = (String) json.getJSONObject(0).get("startAllTime");
        String endQuery = (String) json.getJSONObject(0).get("endAllTime");

        try {
            lineIndex = Long.valueOf(point);
            switch (Integer.parseInt(condition)) {
                case 111:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            syllableName = "P_Pros";       //三相总正向有功电能
                            break;
                        case 2:
                            syllableName = "P_Cons";      //三相总反向有功电能
                            break;
                        case 3:
                            syllableName = "P_Unit";     //三相总组合有功电能
                            break;
                    }
                    break;
                case 121:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            syllableName = "Q_Sector1";       //三相总象限1无功电能
                            break;
                        case 2:
                            syllableName = "Q_Sector2";      //三相总象限2无功电能
                            break;
                        case 3:
                            syllableName = "Q_Sector3";     //三相总象限3无功电能
                            break;
                        case 4:
                            syllableName = "Q_Sector4";     //三相总象限4无功电能
                            break;
                        case 5:
                            syllableName = "Q_Unit1";      //三相总组合1无功电能
                            break;
                        case 6:
                            syllableName = "Q_Unit2";      //三相总组合2无功电能
                            break;
                    }
                    break;
                case 131:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            syllableName = "S_Pros";       //三相总正向视在电能
                            break;
                        case 2:
                            syllableName = "S_Cons";      //三相总反向视在电能
                            break;
                    }
                    break;
                case 141:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            syllableName = "Basic_P_Pros";       //三相总正向基波有功电能
                            break;
                        case 2:
                            syllableName = "Basic_P_Cons";      //三相总反向基波有功电能
                            break;
                        case 3:
                            syllableName = "Basic_P_Unit";     //三相总组合基波有功电能
                            break;
                    }
                    break;
                case 151:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            syllableName = "Basic_Q_Sector1";       //三相总象限1基波无功电能
                            break;
                        case 2:
                            syllableName = "Basic_Q_Sector2";      //三相总象限2基波无功电能
                            break;
                        case 3:
                            syllableName = "Basic_Q_Sector3";     //三相总象限3基波无功电能
                            break;
                        case 4:
                            syllableName = "Basic_Q_Sector4";     //三相总象限4基波无功电能
                            break;
                        case 5:
                            syllableName = "Basic_Q_Unit_1";      //三相总组合1基波无功电能
                            break;
                        case 6:
                            syllableName = "Basic_Q_Unit_2";      //三相总组合2无功电能
                            break;
                    }
                    break;
                case 161:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            syllableName = "Thd_P_Pros";       //三相总正向总谐波有功电能
                            break;
                        case 2:
                            syllableName = "Thd_P_Cons";      //三相总反向总谐波有功电能
                            break;
                        case 3:
                            syllableName = "Thd_P_Unit";     //三相总组合总谐波有功电能
                            break;
                    }
                    break;
                case 171:
                    switch (Integer.parseInt(valueType)) {
                        case 1:
                            syllableName = "Thd_Q_Sector1";       //三相总象限1总谐波无功电能
                            break;
                        case 2:
                            syllableName = "Thd_Q_Sector2";      //三相总象限2总谐波无功电能
                            break;
                        case 3:
                            syllableName = "Thd_Q_Sector3";     //三相总象限3总谐波无功电能
                            break;
                        case 4:
                            syllableName = "Thd_Q_Sector4";     //三相总象限4总谐波无功电能
                            break;
                        case 5:
                            syllableName = "Thd_Q_Unit1";      //三相总组合1总谐波无功电能
                            break;
                        case 6:
                            syllableName = "Thd_Q_Unit2";      //三相总组合2总谐波无功电能
                            break;
                    }
                    break;
                default:
                    break;
            }
            result = plateResultService.getPlateReportResult(startTime, endTime, lineIndex, syllableName, Integer.parseInt(condition), Integer.parseInt(timeType));
            userLog.getLog("查询电度数据", "成功", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
        } catch (Exception e) {
            userLog.getLog("查询电度数据", "失败", PubUtils.getIpAddr(request), LogTypeEnum.BUSSINESS.toString(), 0);
            logger.error("获取电度数据，异常是" + e.toString());
        }
        return result;
    }

    @RequestMapping(value = "/getCreaExcelResult")
    @ResponseBody
    public void getCreaExcelResult(HttpServletRequest request, HttpServletResponse httpServletResponse, @RequestParam(value = "userList") String userList) throws AccountException {
        JSONObject jsonObject = JSONObject.fromObject(userList);
        String startTime = jsonObject.getString("startTime");//起始时间
        String endTime = jsonObject.getString("endTime");//结束时间

        int intervalNum = jsonObject.getInt("intervalNum");//用于区分选择的是年月
        String lineIndex = jsonObject.getString("lineIndex");//获取监测点id;
        JSONArray jsonArrayCondition = jsonObject.getJSONArray("condition");
        // 创建HSSFWorkbook对象(excel的文档对象)
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFCellStyle hssfCellStyle = wb.createCellStyle();
        hssfCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        hssfCellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
        String yearMontDay = "";
        if (intervalNum == 1) {
            yearMontDay = "月度报告";
        } else if (intervalNum == 2) {
            yearMontDay = "季度报告";
        } else {
            yearMontDay = "年度报告";
        }
        //获取数据
        for (int i = 0; i < jsonArrayCondition.size(); i++) {
            String conditionId = (String) jsonArrayCondition.getJSONObject(i).get("id");
            String jsonValueTypeNum = jsonArrayCondition.getJSONObject(i).getString("valueTypeNum");
            String jsonValue = StringUtils.strip(jsonValueTypeNum.toString(), "[]");
            String[] jsonValueType = jsonValue.split(",");
            //用于获取新建的sheet名
            String sheetName = getSheetName(conditionId);

            PlateReportDetail result = new PlateReportDetail();

            // 建立新的sheet对象（excel的表单）
            HSSFSheet sheet = wb.createSheet(sheetName);
            sheet.setDefaultColumnWidth(10);//列宽
            HSSFFont font = wb.createFont();
            font.setFontName("黑体");
            font.setFontHeightInPoints((short) 16);//设置字体大小
            List<HSSFRow> rowTime = new ArrayList<>();
            HSSFCell cellOneTime = null;
            //创建工作薄
            getCreatSheetCell(startTime, endTime, Long.valueOf(lineIndex), intervalNum, conditionId, sheet, result, rowTime, jsonValueType, cellOneTime);
            //jsonObject jsonValueTypeNum =;
            //JSONArray jsonValueTypeNum = jsonArrayCondition.getJSONArray(i);
//            for (int j = 0;j<jsonValueTypeNum.size();j++){
//
//            }
        }
        //导出execl
        getExportExcel(yearMontDay, httpServletResponse, request, wb);

    }

    /***
     * 获取指标
     */
    public String getSheetName(String conditionId) {
        String sheetName = "";
        switch (Integer.parseInt(conditionId)) {
            case 111:
                sheetName = "三相总有功电能";
                break;
            case 121:
                sheetName = "三相总无功电能";
                break;
            case 131:
                sheetName = "三相总视在电能";
                break;
            case 141:
                sheetName = "三相总基波有功电能";
                break;
            case 151:
                sheetName = "三相总基波无功电能";
                break;
            case 161:
                sheetName = "三相总谐波有功电能";
                break;
            case 171:
                sheetName = "三相总谐波无功电能";
                break;
            default:
                break;
        }
        return sheetName;
    }

    /**
     * 获取查询的指标名称
     */
    public String getSyllableName(String conditionId, Integer jsonValueType) {
        String syllableName = "";
        switch (Integer.parseInt(conditionId)) {
            case 111:
                switch (jsonValueType) {
                    case 1:
                        syllableName = "P_Pros";       //三相总正向有功电能
                        break;
                    case 2:
                        syllableName = "P_Cons";      //三相总反向有功电能
                        break;
                    case 3:
                        syllableName = "P_Unit";     //三相总组合有功电能
                        break;
                }
                break;
            case 121:
                switch (jsonValueType) {
                    case 1:
                        syllableName = "Q_Sector1";       //三相总象限1无功电能
                        break;
                    case 2:
                        syllableName = "Q_Sector2";      //三相总象限2无功电能
                        break;
                    case 3:
                        syllableName = "Q_Sector3";     //三相总象限3无功电能
                        break;
                    case 4:
                        syllableName = "Q_Sector4";     //三相总象限4无功电能
                        break;
                    case 5:
                        syllableName = "Q_Unit1";      //三相总组合1无功电能
                        break;
                    case 6:
                        syllableName = "Q_Unit2";      //三相总组合2无功电能
                        break;
                }
                break;
            case 131:
                switch (jsonValueType) {
                    case 1:
                        syllableName = "S_Pros";       //三相总正向视在电能
                        break;
                    case 2:
                        syllableName = "S_Cons";      //三相总反向视在电能
                        break;
                }
                break;
            case 141:
                switch (jsonValueType) {
                    case 1:
                        syllableName = "Basic_P_Pros";       //三相总正向基波有功电能
                        break;
                    case 2:
                        syllableName = "Basic_P_Cons";      //三相总反向基波有功电能
                        break;
                    case 3:
                        syllableName = "Basic_P_Unit";     //三相总组合基波有功电能
                        break;
                }
                break;
            case 151:
                switch (jsonValueType) {
                    case 1:
                        syllableName = "Basic_Q_Sector1";       //三相总象限1基波无功电能
                        break;
                    case 2:
                        syllableName = "Basic_Q_Sector2";      //三相总象限2基波无功电能
                        break;
                    case 3:
                        syllableName = "Basic_Q_Sector3";     //三相总象限3基波无功电能
                        break;
                    case 4:
                        syllableName = "Basic_Q_Sector4";     //三相总象限4基波无功电能
                        break;
                    case 5:
                        syllableName = "Basic_Q_Unit_1";      //三相总组合1基波无功电能
                        break;
                    case 6:
                        syllableName = "Basic_Q_Unit_2";      //三相总组合2无功电能
                        break;
                }
                break;
            case 161:
                switch (jsonValueType) {
                    case 1:
                        syllableName = "Thd_P_Pros";       //三相总正向总谐波有功电能
                        break;
                    case 2:
                        syllableName = "Thd_P_Cons";      //三相总反向总谐波有功电能
                        break;
                    case 3:
                        syllableName = "Thd_P_Unit";     //三相总组合总谐波有功电能
                        break;
                }
                break;
            case 171:
                switch (jsonValueType) {
                    case 1:
                        syllableName = "Thd_Q_Sector1";       //三相总象限1总谐波无功电能
                        break;
                    case 2:
                        syllableName = "Thd_Q_Sector2";      //三相总象限2总谐波无功电能
                        break;
                    case 3:
                        syllableName = "Thd_Q_Sector3";     //三相总象限3总谐波无功电能
                        break;
                    case 4:
                        syllableName = "Thd_Q_Sector4";     //三相总象限4总谐波无功电能
                        break;
                    case 5:
                        syllableName = "Thd_Q_Unit1";      //三相总组合1总谐波无功电能
                        break;
                    case 6:
                        syllableName = "Thd_Q_Unit2";      //三相总组合2总谐波无功电能
                        break;
                }
                break;
            default:
                break;
        }
        return syllableName;
    }


    /***
     * 循环创建工作簿
     */
    public void getCreatSheetCell(String startTime, String endTime, Long lineIndex, int intervalNum, String conditionId, HSSFSheet sheet, PlateReportDetail result, List<HSSFRow> rowTime, String[] jsonValueType, HSSFCell cellOneTime) {
        switch (Integer.parseInt(conditionId)) {
            case 111:
                HSSFRow row1 = sheet.createRow(0);
                row1.createCell(0).getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平居中
                row1.createCell(0).getCellStyle().setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
                HSSFCell cellValueOne = row1.createCell(0);
                cellValueOne.setCellValue("时间");
                sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));

                HSSFRow row2 = sheet.createRow(1);
                // 创建单元格（excel的单元格，参数为列索引，可以是0～255之间的任何一个
                for (int j = 0; j < jsonValueType.length; j++) {
                    String syllableName = getSyllableName(conditionId, Integer.valueOf(jsonValueType[j]));
                    try {
                        result = plateResultService.getPlateReportResult(startTime, endTime, lineIndex, syllableName, Integer.parseInt(conditionId), intervalNum);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    if (result.getMonthYear() != null) {
                        List<String> timeId = result.getTimeId();
                        String monYear = result.getMonthYear();
                        List<PlateResultDetail> plateResultDetailList = result.getPlateResultDetail();
                        switch (Integer.parseInt(jsonValueType[j])) {
                            case 1:
                                if (j == 0) {
                                    HSSFCell cellOne = row1.createCell(1);
                                    cellOne.setCellValue("正向总有功电能");
                                    HSSFCell cellValueOneJ = row2.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = row1.createCell(4 * j + 1);
                                    cellOne.setCellValue("正向总有功电能");
                                    HSSFCell cellValueOneJ = row2.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 2:
                                if (j == 0) {
                                    HSSFCell cellOne = row1.createCell(1);
                                    cellOne.setCellValue("反向总有功电能");
                                    HSSFCell cellValueOneJ = row2.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = row1.createCell(4 * j + 1);
                                    cellOne.setCellValue("反向总有功电能");
                                    HSSFCell cellValueOneJ = row2.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 3:
                                if (j == 0) {
                                    HSSFCell cellOne = row1.createCell(1);
                                    cellOne.setCellValue("组合总有功电能");
                                    HSSFCell cellValueOneJ = row2.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = row1.createCell(4 * j + 1);
                                    cellOne.setCellValue("组合总有功电能");
                                    HSSFCell cellValueOneJ = row2.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    sheet.addMergedRegion(new CellRangeAddress(0, 0, 4 * j + 1, 4 * (1 + j)));
                }
                break;
            case 121:
                HSSFRow rowWg = sheet.createRow(0);
                rowWg.createCell(0).getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平居中
                rowWg.createCell(0).getCellStyle().setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
                HSSFCell cellValueOneWg = rowWg.createCell(0);
                cellValueOneWg.setCellValue("时间");
                sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
                HSSFRow row2Wg = sheet.createRow(1);
                // 创建单元格（excel的单元格，参数为列索引，可以是0～255之间的任何一个
                for (int j = 0; j < jsonValueType.length; j++) {
                    String syllableName = getSyllableName(conditionId, Integer.valueOf(jsonValueType[j]));
                    try {
                        result = plateResultService.getPlateReportResult(startTime, endTime, lineIndex, syllableName, Integer.parseInt(conditionId), intervalNum);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    if (result.getMonthYear() != null) {
                        List<String> timeId = result.getTimeId();
                        String monYear = result.getMonthYear();
                        List<PlateResultDetail> plateResultDetailList = result.getPlateResultDetail();
                        switch (Integer.parseInt(jsonValueType[j])) {
                            case 1:
                                if (j == 0) {
                                    HSSFCell cellOne = rowWg.createCell(1);
                                    cellOne.setCellValue("象限I总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("象限I总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 2:
                                if (j == 0) {
                                    HSSFCell cellOne = rowWg.createCell(1);
                                    cellOne.setCellValue("象限II总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("象限II总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 3:
                                if (j == 0) {
                                    HSSFCell cellOne = rowWg.createCell(1);
                                    cellOne.setCellValue("象限III总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("象限III总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 4:
                                if (j == 0) {
                                    HSSFCell cellOne = rowWg.createCell(1);
                                    cellOne.setCellValue("象限IV总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("象限IV总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 5:
                                if (j == 0) {
                                    HSSFCell cellOne = rowWg.createCell(1);
                                    cellOne.setCellValue("组合1总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("组合1总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 6:
                                if (j == 0) {
                                    HSSFCell cellOne = rowWg.createCell(1);
                                    cellOne.setCellValue("组合2总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("组合2总无功电能");
                                    HSSFCell cellValueOneJ = row2Wg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2Wg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2Wg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2Wg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    sheet.addMergedRegion(new CellRangeAddress(0, 0, 4 * j + 1, 4 * (1 + j)));
                }
                break;
            case 131:
                HSSFRow rowSZ = sheet.createRow(0);
                rowSZ.createCell(0).getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平居中
                rowSZ.createCell(0).getCellStyle().setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
                HSSFCell cellValueOnesz = rowSZ.createCell(0);
                cellValueOnesz.setCellValue("时间");
                sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
                HSSFRow row2SZ = sheet.createRow(1);
                // 创建单元格（excel的单元格，参数为列索引，可以是0～255之间的任何一个
                for (int j = 0; j < jsonValueType.length; j++) {
                    String syllableName = getSyllableName(conditionId, Integer.valueOf(jsonValueType[j]));
                    try {
                        result = plateResultService.getPlateReportResult(startTime, endTime, lineIndex, syllableName, Integer.parseInt(conditionId), intervalNum);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    if (result.getMonthYear() != null) {
                        List<String> timeId = result.getTimeId();
                        String monYear = result.getMonthYear();
                        List<PlateResultDetail> plateResultDetailList = result.getPlateResultDetail();
                        switch (Integer.parseInt(jsonValueType[j])) {
                            case 1:
                                if (j == 0) {
                                    HSSFCell cellOne = rowSZ.createCell(1);
                                    cellOne.setCellValue("正向总视在电能");
                                    HSSFCell cellValueOneJ = row2SZ.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2SZ.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2SZ.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2SZ.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowSZ.createCell(4 * j + 1);
                                    cellOne.setCellValue("正向总视在电能");
                                    HSSFCell cellValueOneJ = row2SZ.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2SZ.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2SZ.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2SZ.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 2:
                                if (j == 0) {
                                    HSSFCell cellOne = rowSZ.createCell(1);
                                    cellOne.setCellValue("反向总视在电能");
                                    HSSFCell cellValueOneJ = row2SZ.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2SZ.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2SZ.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2SZ.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowSZ.createCell(4 * j + 1);
                                    cellOne.setCellValue("反向总视在电能");
                                    HSSFCell cellValueOneJ = row2SZ.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2SZ.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2SZ.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2SZ.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    sheet.addMergedRegion(new CellRangeAddress(0, 0, 4 * j + 1, 4 * (1 + j)));
                }
                break;
            case 141:
                HSSFRow rowjb = sheet.createRow(0);
                rowjb.createCell(0).getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平居中
                rowjb.createCell(0).getCellStyle().setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
                HSSFCell cellValueOnejb = rowjb.createCell(0);
                cellValueOnejb.setCellValue("时间");
                sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
                HSSFRow row2jb = sheet.createRow(1);

                // 创建单元格（excel的单元格，参数为列索引，可以是0～255之间的任何一个
                for (int j = 0; j < jsonValueType.length; j++) {
                    String syllableName = getSyllableName(conditionId, Integer.valueOf(jsonValueType[j]));
                    try {
                        result = plateResultService.getPlateReportResult(startTime, endTime, lineIndex, syllableName, Integer.parseInt(conditionId), intervalNum);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    if (result.getMonthYear() != null) {
                        List<String> timeId = result.getTimeId();
                        String monYear = result.getMonthYear();
                        List<PlateResultDetail> plateResultDetailList = result.getPlateResultDetail();
                        switch (Integer.parseInt(jsonValueType[j])) {
                            case 1:
                                if (j == 0) {
                                    HSSFCell cellOne = rowjb.createCell(1);
                                    cellOne.setCellValue("正向总基波有功电能");
                                    HSSFCell cellValueOneJ = row2jb.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2jb.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2jb.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2jb.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowjb.createCell(4 * j + 1);
                                    cellOne.setCellValue("正向总基波有功电能");
                                    HSSFCell cellValueOneJ = row2jb.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2jb.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2jb.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2jb.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 2:
                                if (j == 0) {
                                    HSSFCell cellOne = rowjb.createCell(1);
                                    cellOne.setCellValue("反向总基波有功电能");
                                    HSSFCell cellValueOneJ = row2jb.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2jb.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2jb.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2jb.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowjb.createCell(4 * j + 1);
                                    cellOne.setCellValue("反向总基波有功电能");
                                    HSSFCell cellValueOneJ = row2jb.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2jb.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2jb.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2jb.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 3:
                                if (j == 0) {
                                    HSSFCell cellOne = rowjb.createCell(1);
                                    cellOne.setCellValue("组合总基波有功电能");
                                    HSSFCell cellValueOneJ = row2jb.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2jb.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2jb.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2jb.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowjb.createCell(4 * j + 1);
                                    cellOne.setCellValue("组合总基波有功电能");
                                    HSSFCell cellValueOneJ = row2jb.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2jb.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2jb.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2jb.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    sheet.addMergedRegion(new CellRangeAddress(0, 0, 4 * j + 1, 4 * (1 + j)));
                }
                break;
            case 151:
                HSSFRow rowJBWg = sheet.createRow(0);
                rowJBWg.createCell(0).getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平居中
                rowJBWg.createCell(0).getCellStyle().setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
                HSSFCell cellValueOneJBWg = rowJBWg.createCell(0);
                cellValueOneJBWg.setCellValue("时间");
                sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
                HSSFRow row2JBWg = sheet.createRow(1);
                // 创建单元格（excel的单元格，参数为列索引，可以是0～255之间的任何一个
                for (int j = 0; j < jsonValueType.length; j++) {
                    String syllableName = getSyllableName(conditionId, Integer.valueOf(jsonValueType[j]));
                    try {
                        result = plateResultService.getPlateReportResult(startTime, endTime, lineIndex, syllableName, Integer.parseInt(conditionId), intervalNum);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    if (result.getMonthYear() != null) {
                        List<String> timeId = result.getTimeId();
                        String monYear = result.getMonthYear();
                        List<PlateResultDetail> plateResultDetailList = result.getPlateResultDetail();
                        switch (Integer.parseInt(jsonValueType[j])) {
                            case 1:
                                if (j == 0) {
                                    HSSFCell cellOne = rowJBWg.createCell(1);
                                    cellOne.setCellValue("I象限总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowJBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("I象限总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 2:
                                if (j == 0) {
                                    HSSFCell cellOne = rowJBWg.createCell(0);
                                    cellOne.setCellValue("II象限总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowJBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("II象限总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 3:
                                if (j == 0) {
                                    HSSFCell cellOne = rowJBWg.createCell(0);
                                    cellOne.setCellValue("III象限总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowJBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("III象限总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 4:
                                if (j == 0) {
                                    HSSFCell cellOne = rowJBWg.createCell(0);
                                    cellOne.setCellValue("IV象限总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowJBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("IV象限总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 5:
                                if (j == 0) {
                                    HSSFCell cellOne = rowJBWg.createCell(0);
                                    cellOne.setCellValue("组合1总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowJBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("组合1总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 6:
                                if (j == 0) {
                                    HSSFCell cellOne = rowJBWg.createCell(0);
                                    cellOne.setCellValue("组合2总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowJBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("组合2总基波无功电能");
                                    HSSFCell cellValueOneJ = row2JBWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2JBWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2JBWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2JBWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    sheet.addMergedRegion(new CellRangeAddress(0, 0, 4 * j + 1, 4 * (1 + j)));
                }
                break;
            case 161:
                HSSFRow rowzxb = sheet.createRow(0);
                rowzxb.createCell(0).getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平居中
                rowzxb.createCell(0).getCellStyle().setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
                HSSFCell cellValueOnezjb = rowzxb.createCell(0);
                cellValueOnezjb.setCellValue("时间");
                sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
                HSSFRow row2zxb = sheet.createRow(1);
                // 创建单元格（excel的单元格，参数为列索引，可以是0～255之间的任何一个
                for (int j = 0; j < jsonValueType.length; j++) {
                    String syllableName = getSyllableName(conditionId, Integer.valueOf(jsonValueType[j]));
                    try {
                        result = plateResultService.getPlateReportResult(startTime, endTime, lineIndex, syllableName, Integer.parseInt(conditionId), intervalNum);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    if (result.getMonthYear() != null) {
                        List<String> timeId = result.getTimeId();
                        String monYear = result.getMonthYear();
                        List<PlateResultDetail> plateResultDetailList = result.getPlateResultDetail();
                        switch (Integer.parseInt(jsonValueType[j])) {
                            case 1:
                                if (j == 0) {
                                    HSSFCell cellOne = rowzxb.createCell(1);
                                    cellOne.setCellValue("正向总谐波有功电能");
                                    HSSFCell cellValueOneJ = row2zxb.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2zxb.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2zxb.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2zxb.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowzxb.createCell(4 * j + 1);
                                    cellOne.setCellValue("正向总谐波有功电能");
                                    HSSFCell cellValueOneJ = row2zxb.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2zxb.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2zxb.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2zxb.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 2:
                                if (j == 0) {
                                    HSSFCell cellOne = rowzxb.createCell(0);
                                    cellOne.setCellValue("反向总谐波有功电能");
                                    HSSFCell cellValueOneJ = row2zxb.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2zxb.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2zxb.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2zxb.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowzxb.createCell(4 * j + 1);
                                    cellOne.setCellValue("反向总谐波有功电能");
                                    HSSFCell cellValueOneJ = row2zxb.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2zxb.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2zxb.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2zxb.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 3:
                                if (j == 0) {
                                    HSSFCell cellOne = rowzxb.createCell(0);
                                    cellOne.setCellValue("组合总谐波有功电能");
                                    HSSFCell cellValueOneJ = row2zxb.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2zxb.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2zxb.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2zxb.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowzxb.createCell(4 * j + 1);
                                    cellOne.setCellValue("组合总谐波有功电能");
                                    HSSFCell cellValueOneJ = row2zxb.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2zxb.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2zxb.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2zxb.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    sheet.addMergedRegion(new CellRangeAddress(0, 0, 4 * j + 1, 4 * (1 + j)));
                }
                break;
            case 171:
                HSSFRow rowZXBWg = sheet.createRow(0);
                rowZXBWg.createCell(0).getCellStyle().setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平居中
                rowZXBWg.createCell(0).getCellStyle().setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
                HSSFCell cellValueOneZXbWg = rowZXBWg.createCell(0);
                cellValueOneZXbWg.setCellValue("时间");
                sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
                HSSFRow row2ZXbWg = sheet.createRow(1);
                // 创建单元格（excel的单元格，参数为列索引，可以是0～255之间的任何一个
                for (int j = 0; j < jsonValueType.length; j++) {
                    String syllableName = getSyllableName(conditionId, Integer.valueOf(jsonValueType[j]));
                    try {
                        result = plateResultService.getPlateReportResult(startTime, endTime, lineIndex, syllableName, Integer.parseInt(conditionId), intervalNum);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    if (result.getMonthYear() != null) {
                        List<String> timeId = result.getTimeId();
                        String monYear = result.getMonthYear();
                        List<PlateResultDetail> plateResultDetailList = result.getPlateResultDetail();
                        switch (Integer.parseInt(jsonValueType[j])) {
                            case 1:
                                if (j == 0) {
                                    HSSFCell cellOne = rowZXBWg.createCell(1);
                                    cellOne.setCellValue("象限I总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowZXBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("象限I总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 2:
                                if (j == 0) {
                                    HSSFCell cellOne = rowZXBWg.createCell(0);
                                    cellOne.setCellValue("象限II总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowZXBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("象限II总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 3:
                                if (j == 0) {
                                    HSSFCell cellOne = rowZXBWg.createCell(0);
                                    cellOne.setCellValue("象限III总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowZXBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("象限III总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 4:
                                if (j == 0) {
                                    HSSFCell cellOne = rowZXBWg.createCell(0);
                                    cellOne.setCellValue("象限IV总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowZXBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("象限IV总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 5:
                                if (j == 0) {
                                    HSSFCell cellOne = rowZXBWg.createCell(0);
                                    cellOne.setCellValue("组合1总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowZXBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("组合1总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            case 6:
                                if (j == 0) {
                                    HSSFCell cellOne = rowZXBWg.createCell(0);
                                    cellOne.setCellValue("组合2总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(j + 4);
                                    cellValueOneG.setCellValue("谷");
                                } else {
                                    HSSFCell cellOne = rowZXBWg.createCell(4 * j + 1);
                                    cellOne.setCellValue("组合2总谐波无功电能");
                                    HSSFCell cellValueOneJ = row2ZXbWg.createCell(4 * j + 1);
                                    cellValueOneJ.setCellValue("尖");
                                    HSSFCell cellValueOnef = row2ZXbWg.createCell(4 * j + 2);
                                    cellValueOnef.setCellValue("峰");
                                    HSSFCell cellValueOneP = row2ZXbWg.createCell(4 * j + 3);
                                    cellValueOneP.setCellValue("平");
                                    HSSFCell cellValueOneG = row2ZXbWg.createCell(4 * j + 4);
                                    cellValueOneG.setCellValue("谷");
                                }
                                for (int t = 0; t < timeId.size(); t++) {
                                    if (j == 0) {
                                        rowTime.add(sheet.createRow(2 + t));
                                    }
                                    cellOneTime = rowTime.get(t).createCell(0);
                                    // 设置单元格内容
                                    cellOneTime.setCellValue(monYear + "-" + timeId.get(t));
                                    if (j == 0) {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    } else {
                                        //尖
                                        HSSFCell cellOneJ = rowTime.get(t).createCell(4 * j + 1);
                                        cellOneJ.setCellValue(String.valueOf(plateResultDetailList.get(0).getData().get(t)));
                                        //峰
                                        HSSFCell cellOneF = rowTime.get(t).createCell(4 * j + 2);
                                        cellOneF.setCellValue(String.valueOf(plateResultDetailList.get(1).getData().get(t)));
                                        //平
                                        HSSFCell cellOneP = rowTime.get(t).createCell(4 * j + 3);
                                        cellOneP.setCellValue(String.valueOf(plateResultDetailList.get(2).getData().get(t)));
                                        //谷
                                        HSSFCell cellOneG = rowTime.get(t).createCell(4 * j + 4);
                                        cellOneG.setCellValue(String.valueOf(plateResultDetailList.get(3).getData().get(t)));
                                    }
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    sheet.addMergedRegion(new CellRangeAddress(0, 0, 4 * j + 1, 4 * (1 + j)));
                }
                break;
            default:
                break;
        }
    }

    /***
     * 导出excel报表
     */
    public void getExportExcel(String yearMontDay, HttpServletResponse httpServletResponse, HttpServletRequest request, HSSFWorkbook wb) {
        String tableName = "电度" + yearMontDay;
        try {
            OutputStream outputStream = httpServletResponse.getOutputStream();
            String fileName = tableName + ".xls";
            // 请求浏览器打开下载窗口
            httpServletResponse.reset();
            httpServletResponse.setCharacterEncoding("UTF-8");
            // Content-disposition 告诉浏览器以下载的形式打开
            String header = request.getHeader("User-Agent").toUpperCase();
            if (header.contains("MSIE") || header.contains("TRIDENT") || header.contains("EDGE")) {
                fileName = URLEncoder.encode(fileName, "utf-8");
                fileName = fileName.replace("+", "%20"); // IE下载文件名空格变+号问题
            } else {
                fileName = new String(fileName.getBytes(), "ISO8859-1");
            }
            httpServletResponse.setHeader("Content-Disposition", "attachment; filename=" + fileName);// 要保存的文件名
            httpServletResponse.setContentType("application/vnd.ms-excel");
            // 直接用数组缓冲输出流输出
            wb.write(outputStream);
        } catch (
                Exception e) {
            e.printStackTrace();
            String str1 = "导出失败！";
            System.out.println(str1);
        }
    }
}
