whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
src/main/java/com/whyc/service/EchartPictureDowloadService.java
@@ -3,13 +3,16 @@
import com.google.gson.reflect.TypeToken;
import com.whyc.dto.BattMaintDealarm;
import com.whyc.dto.BattTestData;
import com.whyc.dto.DeviceTypeDTO;
import com.whyc.dto.Response;
import com.whyc.pojo.*;
import com.whyc.util.ActionUtil;
import com.whyc.util.ExcelUtil;
import com.whyc.util.MessageUtils;
import com.whyc.util.ServletUtils;
import org.apache.ibatis.annotations.Mapper;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.core.env.Environment;
@@ -23,7 +26,9 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Formatter;
import java.util.List;
import java.util.stream.Collectors;
@Service
@@ -50,7 +55,7 @@
    private Environment environment;
    //文件导出
    public void exportExcel( HttpServletRequest req, HttpServletResponse resp) {
    public void exportExcel( HttpServletRequest req, HttpServletResponse resp) throws Exception {
        String pageName = req.getParameter("pageName");
        if (ServletUtils.isNotNull(pageName)) {
            if ("charge-test".equalsIgnoreCase(pageName)) {
@@ -59,6 +64,8 @@
                controlExcelExprot(req,resp);            //实时监测导出图表
            }else if("exportTbal".equalsIgnoreCase(pageName)){
                ExprotReport(req,resp);                  //导出BTS常规报表
            }else if("exportTbalDZ".equalsIgnoreCase(pageName)){
                ExprotReportDZ(req,resp);                  //导出BTS常规报表
            }else if("charge-test-monData".equalsIgnoreCase(pageName)){
                //ExprotLD9MonTestData(req,resp);            //导出LD-9度历史数据
                ExprotLD9Group(req,resp);
@@ -68,9 +75,99 @@
                ExportElectricityPrice(req,resp);         //电价统计报表
            }else if("A059".equalsIgnoreCase(pageName)){
                ExportA059(req,resp);     //A059一体机导出报表
            }else if("eleAnalyse".equalsIgnoreCase(pageName)){
                Exportele_eleAnalyseTable(req,resp);     //电池组统计分析查询
            }
        }
    }
    //电池组统计分析查询
    private void Exportele_eleAnalyseTable( HttpServletRequest req,HttpServletResponse resp
                                          ) {
        String excelTitle="电池组统计查询";
        String pictureName="电池组统计分析图";
        String[] arr_Th=req.getParameter("arr_Th").split(",");
        String[] arr_Td=req.getParameter("arr_Td").split(",");
        String[] echart_url=req.getParameter("echart_url").split(",");
        int rowindex=4;
        //System.out.println(arr_Td.length+"##"+arr_Th.length);
        //定义一个工作簿
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet(excelTitle);
        // 产生表格标题行
        HSSFRow title = sheet.createRow(0);
        HSSFCell titlecell = title.createCell(0);
        HSSFRichTextString tname = new HSSFRichTextString(excelTitle);
        //System.out.print(text+"\t");
        titlecell.setCellValue(tname);
        if(arr_Th!=null && arr_Th.length>0){
            HSSFRow row0 = sheet.createRow(1);
            for(int i=0;i<arr_Th.length;i++){
                HSSFCell cell = row0.createCell(i);
                HSSFRichTextString text = new HSSFRichTextString(arr_Th[i]);
                //System.out.print(text+"\t");
                cell.setCellValue(text);
            }
            if(arr_Td!=null && arr_Td.length>0){
                int rowNum=(int)(Math.ceil((double)arr_Td.length/arr_Th.length));      //总行数
                int index=0;
                //System.out.println("总共有"+rowNum+"行");
                for(int i=1;i<=rowNum;i++){
                    HSSFRow row = sheet.createRow(i+1);
                    for(int j=0;j<arr_Th.length && index<arr_Td.length;j++){
                        HSSFCell cell = row.createCell(j);
                        HSSFRichTextString text = new HSSFRichTextString(arr_Td[index++]);
                        //System.out.print((i-1)*rowNum+j+"\t");
                        //System.out.print(text+"\t");
                        cell.setCellValue(text);
                    }
                }
                rowindex=rowNum+3;
            }
        }
        HSSFRow row = sheet.createRow(rowindex);
        HSSFCell cell = row.createCell(0);
        HSSFRichTextString text = new HSSFRichTextString(pictureName);
        //System.out.print((i-1)*rowNum+j+"\t");
        //System.out.print(text+"\t");
        cell.setCellValue(text);
        if(echart_url!=null && echart_url.length>0){
            List<byte[]> bytes=new ArrayList<byte[]>();
            try {
                bytes.add(new BASE64Decoder().decodeBuffer(echart_url[1]));
                HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
                for (int i = 0; i < bytes.size(); i++) {
                    HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,
                            (short) 0, rowindex+1, (short) 0, 1000 * (2 + 1));
                    anchor.setAnchorType(3);
                    // 插入图片
                    patriarch.createPicture(
                            anchor,
                            workbook.addPicture(bytes.get(i),
                                    HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        // 转码防止乱码
        try {
            resp.addHeader("Content-Disposition", "attachment;filename="
                    + new String(excelName.getBytes("UTF-8"), "ISO8859-1")
                    + ".xls");
            OutputStream out = resp.getOutputStream();
            workbook.write(out);
            out.close();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    //导出单个图表
    private void chargeExcelExprot(HttpServletRequest req,
                                   HttpServletResponse resp) {
@@ -115,44 +212,50 @@
     * @param resp
     */
    private void ExportA059(HttpServletRequest req, HttpServletResponse resp) {
        String ltop_echart = req.getParameter("ltop_echart");         //总电压折线图
        String rtop_echart = req.getParameter("rtop_echart");         //单体电压柱状图
        String lbottom_echart = req.getParameter("lbottom_echart");      //电池电流折线图
        String rbottom_echart = req.getParameter("rbottom_echart");      //单体电压折现图
        bytes=new ArrayList<byte[]>();
        String ltop_echart = req.getParameter("ltop_echart");            //总电压折线图
        String rtop_echart = req.getParameter("rtop_echart");            //单体电压柱状图
        String lbottom_echart = req.getParameter("lbottom_echart");        //电池电流折线图
        String rbottom_echart = req.getParameter("rbottom_echart");        //单体电压折现图
        bytes = new ArrayList<byte[]>();
        int battGroupId =Integer.valueOf(req.getParameter("battGroupId"));  //电池组编号
        int testRecordCount =Integer.valueOf(req.getParameter("testRecordCount"));  //测试编号
        int battGroupId = Integer.valueOf(req.getParameter("battGroupId"));  //电池组编号
        int testRecordCount = Integer.valueOf(req.getParameter("testRecordCount"));  //测试编号
        String stateFlag = req.getParameter("stateFlag");//时间+第几次放电
        //stateFlag = "2022-02-10-第1次放电";
        List<FBOTestData> list=fboservice.getList(battGroupId,testRecordCount);  //查询4059充放电数据
        List<FBOTestData> list = fboservice.getList(battGroupId, testRecordCount);  //查询4059充放电数据
        //取出电池组信息构建excel文件的名称
        String excelName =binfservice.serchExcelName(battGroupId);
        String excelName = binfservice.serchExcelNameA059(battGroupId, stateFlag);
        int monCount= fboservice.getMonCuntBytestRecordCount(battGroupId,testRecordCount); //查询具体一次充放电单体个数
        int monCount = fboservice.getMonCuntBytestRecordCount(battGroupId, testRecordCount); //查询具体一次充放电单体个数
        //处理图片
        try {
            if (ServletUtils.isNotNull(ltop_echart)) {
                String[] url = ltop_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }if (ServletUtils.isNotNull(rtop_echart)) {
            }
            if (ServletUtils.isNotNull(rtop_echart)) {
                String[] url = rtop_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }if (ServletUtils.isNotNull(lbottom_echart)) {
            }
            if (ServletUtils.isNotNull(lbottom_echart)) {
                String[] url = lbottom_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }if (ServletUtils.isNotNull(rbottom_echart)) {
            }
            if (ServletUtils.isNotNull(rbottom_echart)) {
                String[] url = rbottom_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("Sheet1");
        sheet.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet.setDefaultRowHeight((short) (1 * 256)); //设置默认行高,表示2个字符的高度
        //图片元素
        HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
@@ -197,33 +300,34 @@
                    sheet.getRow(rowNum).createCell(1).setCellValue(fbo.getSumVol());
                    sheet.getRow(rowNum).createCell(2).setCellValue(fbo.getTestCurr());
                    sheet.getRow(rowNum).createCell(3).setCellValue(fbo.getTestCap());
                    sheet.getRow(rowNum).createCell(4+j).setCellValue(fbo.getMonVol());
                    sheet.getRow(rowNum).createCell(4 + j).setCellValue(fbo.getMonVol());
                }
                i=i+monCount-1;
                i = i + monCount - 1;
                rowNum++;
            }
        }
        rowNum+=2;
        rowNum += 2;
        //excel文件名
        String testTime = new SimpleDateFormat("yyyy-MM-dd").format(test_starttime);
        excelName = excelName+"-"+testTime;
        String regEx="[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
        excelName = excelName.replace(regEx,"");
        /*String testTime = new SimpleDateFormat("yyyy-MM-dd").format(test_starttime);
        excelName = excelName+"-"+testTime;*/
        String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
        excelName = excelName.replaceAll(regEx, "");
        //插入图片
        int picNum = 0;
        String[] picName = new String[]{
                "总电压折线图","单体电压柱状图","电池电流折线图","单体电压折现图"
                "总电压折线图", "单体电压柱状图", "电池电流折线图", "单体电压折现图"
        };
        for(int i=0;i<picName.length;i++){
            sheet.createRow(rowNum-1);
            sheet.getRow(rowNum-1).createCell(0).setCellValue(picName[i]);
        for (int i = 0; i < picName.length; i++) {
            sheet.createRow(rowNum - 1);
            sheet.getRow(rowNum - 1).createCell(0).setCellValue(picName[i]);
            //rowNum++;
            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 0, rowNum, (short) 10, rowNum+rowNumAdd);
            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255, (short) 0, rowNum, (short) 10, rowNum + rowNumAdd);
            anchor.setAnchorType(3);
            patriarch.createPicture(anchor,wb.addPicture(bytes.get(picNum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
            picNum ++;rowNum+=rowNumAdd;
            patriarch.createPicture(anchor, wb.addPicture(bytes.get(picNum), HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
            picNum++;
            rowNum += rowNumAdd;
        }
        rowNum++;
@@ -248,7 +352,7 @@
     * @param req
     * @param resp
     */
    private void ExprotLD9Group(HttpServletRequest req,HttpServletResponse resp) {
    private void ExprotLD9Group(HttpServletRequest req,HttpServletResponse resp) throws Exception {
        String battinf = req.getParameter("battinf");               //电池组信息
        String testdatainfo = req.getParameter("testdatainfo");          //单体测试数据
        Title echarttitle = ActionUtil.getGson().fromJson(req.getParameter("obj-title"), Title.class);  //最大最小信息
@@ -264,7 +368,7 @@
            //ld9整组放电数据
            createLD9AllGroup(wb,linf);
            //查询存放ld9在testrecordcount下有哪些单体存在放电记录
            List<Ld9testdatastop> list=stopservice.searchlinftestdata(linf);
            List<Ld9testdatastop> list=stopservice.searchlinftestdata(linf,req);
            if(list!=null&&list.size()>0){
                for(int i=0;i<list.size();i++){
                    Ld9testdatastop ld9stop=list.get(i);
@@ -286,26 +390,29 @@
    //LD9放电整组信息
    private void createLd9GroupInfo(HSSFWorkbook wb, Title title, String[][] datas,Battinf binf) {
        HSSFSheet sheet1 = wb.createSheet("数据总览");
        sheet1.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet1.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        int rownum = 1;
        sheet1.createRow(rownum);
        sheet1.getRow(rownum).createCell(1).setCellValue("电池组名称");
        sheet1.getRow(rownum).createCell(2).setCellValue(binf.getStationName()+"-"+binf.getBattGroupName());
        sheet1.getRow(rownum).createCell(2).setCellValue(binf.getStationName() + "-" + binf.getBattGroupName());
        rownum++;
        sheet1.createRow(rownum);
        sheet1.getRow(rownum).createCell(1).setCellValue( "电池品牌:"+binf.getBattProducer());
        sheet1.getRow(rownum).createCell(2).setCellValue( "安装日期:"+formartDate(binf.getBattInUseDate(),"yyyy-MM-dd"));
        sheet1.getRow(rownum).createCell(3).setCellValue( "单体数量:"+binf.getMonCount());
        sheet1.getRow(rownum).createCell(4).setCellValue( "单体电压:"+binf.getMonVolStd()+"V");
        sheet1.getRow(rownum).createCell(5).setCellValue( "单体标称容量:"+formartDouble(binf.getMonCapStd(),0)+"AH");
        sheet1.getRow(rownum).createCell(6).setCellValue( "单体标称内阻:"+formartDouble(binf.getMonResStd(),3)+"mΩ");
        sheet1.getRow(rownum).createCell(7).setCellValue( "单体标称电导:"+formartDouble(binf.getMonSerStd(),0));
        sheet1.getRow(rownum).createCell(1).setCellValue("电池品牌:" + binf.getBattProducer());
        sheet1.getRow(rownum).createCell(2).setCellValue("安装日期:" + formartDate(binf.getBattInUseDate(), "yyyy-MM-dd"));
        sheet1.getRow(rownum).createCell(3).setCellValue("单体数量:" + binf.getMonCount());
        sheet1.getRow(rownum).createCell(4).setCellValue("单体电压:" + binf.getMonVolStd() + "V");
        sheet1.getRow(rownum).createCell(5).setCellValue("单体标称容量:" + formartDouble(binf.getMonCapStd(), 0) + "AH");
        sheet1.getRow(rownum).createCell(6).setCellValue("单体标称内阻:" + formartDouble(binf.getMonResStd(), 3) + "mΩ");
        sheet1.getRow(rownum).createCell(7).setCellValue("单体标称电导:" + formartDouble(binf.getMonSerStd(), 0));
        rownum++;
        sheet1.createRow(rownum);
        sheet1.getRow(rownum).createCell(1).setCellValue( "报告日期:");
        sheet1.getRow(rownum).createCell(2).setCellValue(formartDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
        rownum+=2;
        sheet1.getRow(rownum).createCell(1).setCellValue("报告日期:");
        sheet1.getRow(rownum).createCell(2).setCellValue(formartDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
        rownum += 2;
        rownum++;
        sheet1.createRow(rownum);
@@ -358,7 +465,7 @@
        }
    }
    //生成每个单体放电单体表
    private void createGroupSheet(HSSFWorkbook wb,Battinf binf,Ld9testdatastop ld9stop) {
    private void createGroupSheet(HSSFWorkbook wb, Battinf binf, Ld9testdatastop ld9stop){
        List<byte[]> listbyte=new ArrayList<byte[]>();//读取图片
        //-----------------------读取4张图:单体电压折线图,组端/在线电压折线图,测试电流折线图,单体实际容量柱状图
        String fileDirName = "";
@@ -372,7 +479,7 @@
            //打包版
            fileDirName = jarFile.toString();
        }
        String picroot=fileDirName+ File.separator+"ld9"+File.separator+ld9stop.getBattGroupId()+File.separator+ld9stop.getTestRecordCount()+File.separator+ld9stop.getMonNum()+File.separator;
        String picroot=fileDirName+ File.separator+"ld9"+File.separator+ ld9stop.getBattGroupId() +File.separator+ld9stop.getTestRecordCount()+File.separator+ld9stop.getMonNum()+File.separator;
        File f = new File(picroot);
        List<String> picName = new ArrayList();
        if(f.exists()){
@@ -383,60 +490,70 @@
                byte[] data = null;
                // 读取图片字节数组
                try {
                    in = new FileInputStream(picroot+files[i].getName());
                    in = new FileInputStream(picroot + files[i].getName());
                    data = new byte[in.available()];
                    in.read(data);
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }finally {
                    if(in!=null){
                        try {
                            in.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
                listbyte.add(data);
            }
        }
        HSSFSheet sheet1 = wb.createSheet(ld9stop.getMonNum()+"#历史"+BattTestData.getTestType_4019(ld9stop.getTestType())+"信息表");
        HSSFSheet sheet1 = wb.createSheet(ld9stop.getMonNum() + "#历史" + BattTestData.getTestType_4019(ld9stop.getTestType()) + "信息表");
        sheet1.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet1.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        HSSFPatriarch patriarch = sheet1.createDrawingPatriarch();
        int rownum = 1;
        sheet1.createRow(rownum);
        sheet1.getRow(rownum).createCell(1).setCellValue("电池组名称");
        sheet1.getRow(rownum).createCell(2).setCellValue(binf.getStationName()+"-"+binf.getBattGroupName());
        sheet1.getRow(rownum).createCell(2).setCellValue(binf.getStationName() + "-" + binf.getBattGroupName());
        rownum++;
        sheet1.createRow(rownum);
        sheet1.getRow(rownum).createCell(1).setCellValue( "电池品牌:"+binf.getBattProducer());
        sheet1.getRow(rownum).createCell(2).setCellValue( "安装日期:"+formartDate(binf.getBattInUseDate(),"yyyy-MM-dd"));
        sheet1.getRow(rownum).createCell(3).setCellValue( "单体数量:"+binf.getMonCount());
        sheet1.getRow(rownum).createCell(4).setCellValue( "单体电压:"+binf.getMonVolStd()+"V");
        sheet1.getRow(rownum).createCell(5).setCellValue( "单体标称容量:"+formartDouble(binf.getMonCapStd(),0)+"AH");
        sheet1.getRow(rownum).createCell(6).setCellValue( "单体标称内阻:"+formartDouble(binf.getMonResStd(),3)+"mΩ");
        sheet1.getRow(rownum).createCell(7).setCellValue( "单体标称电导:"+formartDouble(binf.getMonSerStd(),0));
        sheet1.getRow(rownum).createCell(1).setCellValue("电池品牌:" + binf.getBattProducer());
        sheet1.getRow(rownum).createCell(2).setCellValue("安装日期:" + formartDate(binf.getBattInUseDate(), "yyyy-MM-dd"));
        sheet1.getRow(rownum).createCell(3).setCellValue("单体数量:" + binf.getMonCount());
        sheet1.getRow(rownum).createCell(4).setCellValue("单体电压:" + binf.getMonVolStd() + "V");
        sheet1.getRow(rownum).createCell(5).setCellValue("单体标称容量:" + formartDouble(binf.getMonCapStd(), 0) + "AH");
        sheet1.getRow(rownum).createCell(6).setCellValue("单体标称内阻:" + formartDouble(binf.getMonResStd(), 3) + "mΩ");
        sheet1.getRow(rownum).createCell(7).setCellValue("单体标称电导:" + formartDouble(binf.getMonSerStd(), 0));
        rownum++;
        sheet1.createRow(rownum);
        sheet1.getRow(rownum).createCell(1).setCellValue( "被测单体编号:#"+ld9stop.getMonNum());
        sheet1.getRow(rownum).createCell(2).setCellValue( "测试类型:"+BattTestData.getTestType_4019(ld9stop.getTestType()));
        sheet1.getRow(rownum).createCell(3).setCellValue( "测试时间:"+formartDate(ld9stop.getTestStarttime(),"yyyy-MM-dd HH:mm:ss"));
        sheet1.getRow(rownum).createCell(4).setCellValue( "测试电流:"+ld9stop.getTestCurr()+"A");
        sheet1.getRow(rownum).createCell(5).setCellValue( "测试时长:"+formatTestLong(ld9stop.getTestTimelong()));
        sheet1.getRow(rownum).createCell(6).setCellValue( "测试容量:"+formartDouble(ld9stop.getTestCap(),0)+"AH");
        sheet1.getRow(rownum).createCell(7).setCellValue( "终止原因:"+BattTestData.getStopType_4019(ld9stop.getTestStopreason()));
        sheet1.getRow(rownum).createCell(1).setCellValue("被测单体编号:#" + ld9stop.getMonNum());
        sheet1.getRow(rownum).createCell(2).setCellValue("测试类型:" + BattTestData.getTestType_4019(ld9stop.getTestType()));
        sheet1.getRow(rownum).createCell(3).setCellValue("测试时间:" + formartDate(ld9stop.getTestStarttime(), "yyyy-MM-dd HH:mm:ss"));
        sheet1.getRow(rownum).createCell(4).setCellValue("测试电流:" + ld9stop.getTestCurr() + "A");
        sheet1.getRow(rownum).createCell(5).setCellValue("测试时长:" + formatTestLong(ld9stop.getTestTimelong()));
        sheet1.getRow(rownum).createCell(6).setCellValue("测试容量:" + formartDouble(ld9stop.getTestCap(), 0) + "AH");
        sheet1.getRow(rownum).createCell(7).setCellValue("终止原因:" + BattTestData.getStopType_4019(ld9stop.getTestStopreason()));
        rownum++;
        sheet1.createRow(rownum);
        sheet1.getRow(rownum).createCell(1).setCellValue( "报告日期:");
        sheet1.getRow(rownum).createCell(2).setCellValue(formartDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
        rownum+=2;
        sheet1.getRow(rownum).createCell(1).setCellValue("报告日期:");
        sheet1.getRow(rownum).createCell(2).setCellValue(formartDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
        rownum += 2;
        //画图
        if(listbyte!=null&&listbyte.size()>0){
            for(int i=0;i<listbyte.size();i++){
        if (listbyte != null && listbyte.size() > 0) {
            for (int i = 0; i < listbyte.size(); i++) {
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue(picName.get(i));
                sheet1.getRow(rownum).createCell(1).setCellValue(picName.get(i).equals("测试容量") ? "单体测试容量柱状图" : picName.get(i));
                rownum++;
                HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, rownum, (short) 10, 25 * (i + 1));
                HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255, (short) 1, rownum, (short) 10, 25 * (i + 1));
                anchor.setAnchorType(3);
                patriarch.createPicture(anchor,wb.addPicture(listbyte.get(i),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                rownum+=25;
                patriarch.createPicture(anchor, wb.addPicture(listbyte.get(i), HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                rownum += 25;
            }
        }
    }
@@ -445,28 +562,162 @@
     * @param req
     * @param resp
     */
    private void ExprotReport(HttpServletRequest req, HttpServletResponse resp) {
        String ltop_echart = req.getParameter("ltop_echart");         //组端电压折线图
        String rtop_echart = req.getParameter("rtop_echart");         //电池电流折线图
        String lbottom_echart = req.getParameter("lbottom_echart");      //单体电压折线图
        String rbottom_echart = req.getParameter("rbottom_echart");      //单体电压柱状图
        String actucap_echart = req.getParameter("actucap_echart");      //实际容量折线图
        String restcap_echart = req.getParameter("restcap_echart");      //剩余容量柱状图
        String capperc_echart = req.getParameter("capperc_echart");      //单体实际容量百分比图
        String montmp_echart = req.getParameter("tmp_echart");         //单体温度折线图
        String mon_res_echart = req.getParameter("mon_res");         //单体内阻折线图
        String mon_jhcurr_eachart = req.getParameter("JH_curr");      //单体均衡电流柱状图
        String last_vol_echart = req.getParameter("last_vol");         //单体终止电压折线图
        String last_tmp_echart = req.getParameter("last_tmp");         //单体终止电压折线图
    private void ExprotReportDZ(HttpServletRequest req, HttpServletResponse resp) {
        String ltop_echart = req.getParameter("ltop_echart");            //组端电压折线图
        String rtop_echart = req.getParameter("rtop_echart");            //电池电流折线图
        String lbottom_echart = req.getParameter("lbottom_echart");        //单体电压折线图
        String rbottom_echart = req.getParameter("rbottom_echart");        //单体电压柱状图
        String actucap_echart = req.getParameter("actucap_echart");        //实际容量折线图
        String restcap_echart = req.getParameter("restcap_echart");        //剩余容量柱状图
        String capperc_echart = req.getParameter("capperc_echart");        //单体实际容量百分比图
        String montmp_echart = req.getParameter("tmp_echart");            //单体温度折线图
        //String mon_res_echart = req.getParameter("mon_res");            //单体内阻折线图
        //String mon_jhcurr_eachart = req.getParameter("JH_curr");        //单体均衡电流柱状图
        String last_vol_echart = req.getParameter("last_vol");            //单体终止电压折线图
        String last_tmp_echart = req.getParameter("last_tmp");            //单体终止电压折线图
        String restcap_line_echart = req.getParameter("restcap_line_echart");  //剩余容量折线图
        String monVolComparePic =  req.getParameter("mon_vol_compare_pic");//追加的单体电压对比 图片
        String monTempComparePic =  req.getParameter("mon_temp_compare_pic");//追加的单体温度对比 图片
        String monVolComparePic = req.getParameter("mon_vol_compare_pic");//追加的单体电压对比 图片
        String monTempComparePic = req.getParameter("mon_temp_compare_pic");//追加的单体温度对比 图片
        Qth qth = ActionUtil.getGson().fromJson(req.getParameter("group_vol_qth"), Qth.class);
        bytes=new ArrayList<byte[]>();
        bytes = new ArrayList<byte[]>();
        BattMaintDealarm bmd = ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(req.getParameter("obj-bmd"), BattMaintDealarm.class);
        String stateFlag = req.getParameter("stateFlag");//时间+第几次放电
        bmd.getBinf().setStationName9(stateFlag);//StationName9放文本信息用于8059、8060设备加文件名信息
        Title echarttitle = ActionUtil.getGson().fromJson(req.getParameter("obj-title"), Title.class);
        String[][] datas = ActionUtil.getGson().fromJson(req.getParameter("arr-data"), String[][].class);
        //System.out.println(req.getParameter("ltop_echart")+"###################");
        String[][] mon_vol_list = ActionUtil.getGson().fromJson(req.getParameter("mon-vol-list"), String[][].class);
        String[][] mon_tmp_list = ActionUtil.getGson().fromJson(req.getParameter("mon-tmp-list"), String[][].class);
        //追加的单体电压/温度对比列表
        String splitTime = req.getParameter("splitTime");
        String[] timeCompareList = ActionUtil.getGson().fromJson(req.getParameter("time-compare-list"), String[].class);
        String[][] monVolCompareList = ActionUtil.getGson().fromJson(req.getParameter("mon-vol-compare-list"), String[][].class);
        String[][] monTempCompareList = ActionUtil.getGson().fromJson(req.getParameter("mon-tmp-compare-list"), String[][].class);
        List<BatttestdataId> groupinfo = ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(req.getParameter("mon-group-list"),  new TypeToken<List<BatttestdataId>>(){}.getType());
        //System.out.println("mon_vol_list:"+mon_vol_list.length);
        //System.out.println(" mon_tmp_list:"+mon_tmp_list.length);
        //System.out.println(" mon_tmp_list:"+mon_tmp_list.length);
        //System.out.println(" groupinfo:"+groupinfo.size());
        //System.out.println(groupinfo);
        //System.out.println(echarttitle);
        //System.out.println(datas);
        try {
            //组端电压曲线图
            if (ServletUtils.isNotNull(ltop_echart)) {
                String[] url = ltop_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            //电池电流曲线图
            if (ServletUtils.isNotNull(rtop_echart)) {
                String[] url = rtop_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            //电池单体终止电压曲线图
            if (ServletUtils.isNotNull(last_vol_echart)) {
                String[] url = last_vol_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            //电池单体终止温度曲线图
            if (ServletUtils.isNotNull(last_tmp_echart)) {
                String[] url = last_tmp_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            //单体内阻柱状图
           /* if (ServletUtils.isNotNull(mon_res_echart)) {
                String[] url = mon_res_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            //单体均衡柱状图
            if (ServletUtils.isNotNull(mon_jhcurr_eachart)) {
                String[] url = mon_jhcurr_eachart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }*/
            //单体电压柱状图
            if (ServletUtils.isNotNull(rbottom_echart)) {
                String[] url = rbottom_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            //单体实际容量柱状图
            if(ServletUtils.isNotNull(actucap_echart)){
                String[] url = actucap_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            //单体剩余容量柱状图
            if(ServletUtils.isNotNull(restcap_echart)){
                String[] url = restcap_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            //单体容量百分比柱状图
            if(ServletUtils.isNotNull(capperc_echart)){
                String[] url = capperc_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            //单体电压曲线图
            if (ServletUtils.isNotNull(lbottom_echart)) {
                String[] url = lbottom_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            //单体温度折线图
            if(ServletUtils.isNotNull(montmp_echart)){
                String[] url = montmp_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            //单体剩余容量折线图
            if(ServletUtils.isNotNull(restcap_line_echart)){
                String[] url = restcap_line_echart.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        if(bytes.size()>0){
            createExcel2007DZ(bytes, echarttitle,qth, datas, bmd,mon_vol_list,mon_tmp_list,groupinfo,splitTime,timeCompareList,monVolCompareList,monTempCompareList,monVolComparePic,monTempComparePic, resp, req);
        }
    }
    /**
     * 导出报表
     * @param req
     * @param resp
     */
    private void ExprotReport(HttpServletRequest req, HttpServletResponse resp) {
        String ltop_echart = req.getParameter("ltop_echart");            //组端电压折线图
        String rtop_echart = req.getParameter("rtop_echart");            //电池电流折线图
        String lbottom_echart = req.getParameter("lbottom_echart");        //单体电压折线图
        String rbottom_echart = req.getParameter("rbottom_echart");        //单体电压柱状图
        String actucap_echart = req.getParameter("actucap_echart");        //实际容量折线图
        String restcap_echart = req.getParameter("restcap_echart");        //剩余容量柱状图
        String capperc_echart = req.getParameter("capperc_echart");        //单体实际容量百分比图
        String montmp_echart = req.getParameter("tmp_echart");            //单体温度折线图
        String mon_res_echart = req.getParameter("mon_res");            //单体内阻折线图
        String mon_jhcurr_eachart = req.getParameter("JH_curr");        //单体均衡电流柱状图
        String last_vol_echart = req.getParameter("last_vol");            //单体终止电压折线图
        String last_tmp_echart = req.getParameter("last_tmp");            //单体终止电压折线图
        String restcap_line_echart = req.getParameter("restcap_line_echart");  //剩余容量折线图
        String monVolComparePic = req.getParameter("mon_vol_compare_pic");//追加的单体电压对比 图片
        String monTempComparePic = req.getParameter("mon_temp_compare_pic");//追加的单体温度对比 图片
        Qth qth = ActionUtil.getGson().fromJson(req.getParameter("group_vol_qth"), Qth.class);
        bytes = new ArrayList<byte[]>();
        BattMaintDealarm bmd = ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(req.getParameter("obj-bmd"), BattMaintDealarm.class);
        String stateFlag = req.getParameter("stateFlag");//时间+第几次放电
        bmd.getBinf().setStationName9(stateFlag);//StationName9放文本信息用于8059、8060设备加文件名信息
        Title echarttitle = ActionUtil.getGson().fromJson(req.getParameter("obj-title"), Title.class);
        String[][] datas = ActionUtil.getGson().fromJson(req.getParameter("arr-data"), String[][].class);
@@ -565,7 +816,8 @@
            e.printStackTrace();
        }
        if(bytes.size()>0){
            createExcel(bytes, echarttitle,qth, datas, bmd,mon_vol_list,mon_tmp_list,groupinfo,splitTime,timeCompareList,monVolCompareList,monTempCompareList,monVolComparePic,monTempComparePic, resp, req);
            //createExcel(bytes, echarttitle,qth, datas, bmd,mon_vol_list,mon_tmp_list,groupinfo,splitTime,timeCompareList,monVolCompareList,monTempCompareList,monVolComparePic,monTempComparePic, resp, req);
            createExcel2007(bytes, echarttitle,qth, datas, bmd,mon_vol_list,mon_tmp_list,groupinfo,splitTime,timeCompareList,monVolCompareList,monTempCompareList,monVolComparePic,monTempComparePic, resp, req);
        }
    }
    /**
@@ -646,13 +898,16 @@
            // 创建一个工作薄
            HSSFWorkbook wb = new HSSFWorkbook();
            HSSFSheet sheet1 = wb.createSheet("数据总表");
            sheet1.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
            sheet1.setDefaultRowHeight((short) (1 * 256));
            ; //设置默认行高,表示2个字符的高度
            // HSSFRow row = sheet1.createRow(2);
            HSSFPatriarch patriarch = sheet1.createDrawingPatriarch();
            int rownum = 1;
            sheet1.createRow(rownum);
            sheet1.getRow(rownum).createCell(1).setCellValue("电池组名称");
            sheet1.getRow(rownum).createCell(2).setCellValue(binf.getStationName()+"-"+binf.getBattGroupName());
            sheet1.getRow(rownum).createCell(2).setCellValue(binf.getStationName() + "-" + binf.getBattGroupName());
            rownum++;
            sheet1.createRow(rownum);
@@ -718,67 +973,75 @@
    //创建整组放电折线图
    private void createLD9AllGroupVolLine(HSSFWorkbook wb, List<byte[]> bytes1) {
        HSSFSheet sheet = wb.createSheet("整组折线图");
        sheet.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
        int picnum = 0;
        int rownum = 0;
        String[] picName = new String[]{
                "整组端电压折线图","多单体电流折线图","多单体电压折线图"
                "整组端电压折线图", "多单体电流折线图", "多单体电压折线图"
        };
        if(picName.length>0){
            for(int i=0;i<picName.length;i++){
        if (picName.length > 0) {
            for (int i = 0; i < picName.length; i++) {
                sheet.createRow(rownum);
                sheet.getRow(rownum).createCell(1).setCellValue(picName[i]);
                rownum++;
                if(bytes1.size()>0){
                    HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, rownum, (short) 10, 25 * (picnum + 1));
                if (bytes1.size() > 0) {
                    HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255, (short) 1, rownum, (short) 10, 25 * (picnum + 1));
                    anchor.setAnchorType(3);
                    patriarch.createPicture(anchor,wb.addPicture(bytes1.get(picnum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                    patriarch.createPicture(anchor, wb.addPicture(bytes1.get(picnum), HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                }
                picnum ++;rownum+=25;
                picnum++;
                rownum += 25;
            }
        }
    }
    /*更改ld9文件导出时改为整组放电信息导出*/
    public void createLD9AllGroup(HSSFWorkbook wb,Ld9testdataInf mondatainfo){
    public void createLD9AllGroup(HSSFWorkbook wb, Ld9testdataInf mondatainfo) {
        HSSFSheet sheet = wb.createSheet("LD9整组测试数据表");
        sheet.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        //根据电池组id和test_record_count查询出整组的放电记录
        int monNum=0;//放电记录中的单体编号
        int maxcol = 254;         //设置最大列数
        int currRow = 0;         //当前行
        int currCel= 0;             //当前列
        if(mondatainfo != null){
            List<Ld9testdata> montestdata=ld9service.getLD9AllGroupByTestRecordCount(mondatainfo);
            for(int i=0;i<montestdata.size();i++){
                Ld9testdata data=montestdata.get(i);
                if(currCel>=maxcol){
                    monNum=0;
                    currRow=currRow+10;
        int monNum = 0;//放电记录中的单体编号
        int maxcol = 254;            //设置最大列数
        int currRow = 0;            //当前行
        int currCel = 0;                //当前列
        if (mondatainfo != null) {
            List<Ld9testdata> montestdata = ld9service.getLD9AllGroupByTestRecordCount(mondatainfo);
            for (int i = 0; i < montestdata.size(); i++) {
                Ld9testdata data = montestdata.get(i);
                if (currCel >= maxcol) {
                    monNum = 0;
                    currRow = currRow + 10;
                }
                if(monNum!=data.getMonNum()){
                    if(monNum!=0){
                        currRow=currRow+10;
                if (monNum != data.getMonNum()) {
                    if (monNum != 0) {
                        currRow = currRow + 10;
                    }
                    currCel=0;
                    monNum=data.getMonNum();
                    currCel = 0;
                    monNum = data.getMonNum();
                    sheet.createRow(currRow);  //创建行
                    sheet.createRow(currRow+1);  //创建行
                    sheet.createRow(currRow+2);  //创建行
                    sheet.createRow(currRow+3);  //创建行
                    sheet.createRow(currRow+4);  //创建行
                    sheet.createRow(currRow+5);  //创建行
                    sheet.createRow(currRow+6);  //创建行
                    sheet.createRow(currRow+7);  //创建行
                    sheet.createRow(currRow+8);  //创建行
                    sheet.getRow(currRow).createCell(currCel).setCellValue(monNum+"#测试数据");
                    sheet.getRow(currRow+1).createCell(currCel).setCellValue("时间(HH:MM:SS)");
                    sheet.getRow(currRow+2).createCell(currCel).setCellValue("组端电压(V)");
                    sheet.getRow(currRow+3).createCell(currCel).setCellValue("在线电压(V)");
                    sheet.getRow(currRow+4).createCell(currCel).setCellValue("电流(A)");
                    sheet.getRow(currRow+5).createCell(currCel).setCellValue("测试容量(AH)");
                    sheet.getRow(currRow+6).createCell(currCel).setCellValue("单体电压"+monNum+"(V)");
                    sheet.getRow(currRow+7).createCell(currCel).setCellValue("实际容量(AH)");
                    sheet.getRow(currRow+8).createCell(currCel).setCellValue("剩余容量(AH)");
                    sheet.createRow(currRow + 1);  //创建行
                    sheet.createRow(currRow + 2);  //创建行
                    sheet.createRow(currRow + 3);  //创建行
                    sheet.createRow(currRow + 4);  //创建行
                    sheet.createRow(currRow + 5);  //创建行
                    sheet.createRow(currRow + 6);  //创建行
                    sheet.createRow(currRow + 7);  //创建行
                    sheet.createRow(currRow + 8);  //创建行
                    sheet.getRow(currRow).createCell(currCel).setCellValue(monNum + "#测试数据");
                    sheet.getRow(currRow + 1).createCell(currCel).setCellValue("时间(HH:MM:SS)");
                    sheet.getRow(currRow + 2).createCell(currCel).setCellValue("组端电压(V)");
                    sheet.getRow(currRow + 3).createCell(currCel).setCellValue("在线电压(V)");
                    sheet.getRow(currRow + 4).createCell(currCel).setCellValue("电流(A)");
                    sheet.getRow(currRow + 5).createCell(currCel).setCellValue("测试容量(AH)");
                    sheet.getRow(currRow + 6).createCell(currCel).setCellValue("单体电压" + monNum + "(V)");
                    sheet.getRow(currRow + 7).createCell(currCel).setCellValue("实际容量(AH)");
                    sheet.getRow(currRow + 8).createCell(currCel).setCellValue("剩余容量(AH)");
                }
                currCel++;
                sheet.getRow(currRow+1).createCell(currCel).setCellValue(formatTestLong(data.getTestTimelong()));
@@ -793,16 +1056,24 @@
        }
    }
    public void createNewLD9DataSheet(HSSFWorkbook wb,final List<Ld9testdata> montestdata){
    public void createNewLD9DataSheet(HSSFWorkbook wb, final List<Ld9testdata> montestdata) {
        HSSFSheet sheet = wb.createSheet("单体数据表");
        if(montestdata != null && montestdata.size()>0){
        sheet.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        if (montestdata != null && montestdata.size() > 0) {
            int mon_count = 1;                  //总单体数量
            int total_col = montestdata.size();      //总记录条数
            int mon_count = 1;                        //总单体数量
            int total_col = montestdata.size();        //总记录条数
            List<String> tabTh = new ArrayList<String>(){{
                this.add("时间(HH:MM:SS)");this.add("组端电压(V)");this.add("在线电压(V)");this.add("电流(A)");this.add("测试容量(AH)");this.add("单体电压"+montestdata.get(0).getTestMonnum()+"(V)");
            List<String> tabTh = new ArrayList<String>() {{
                this.add("时间(HH:MM:SS)");
                this.add("组端电压(V)");
                this.add("在线电压(V)");
                this.add("电流(A)");
                this.add("测试容量(AH)");
                this.add("单体电压" + montestdata.get(0).getTestMonnum() + "(V)");
            }};
            //for(int i=1;i<=mon_count;i++){
            //   tabTh.add("单体电压"+i+"(V)");
@@ -812,16 +1083,16 @@
            //System.out.println("data.length"+datas.length+"\t datas[0].length:"+datas[0].length);
            for(int j=0;j < datas.length;j++){
            for (int j = 0; j < datas.length; j++) {
                int currnum = 0;
                datas[j][currnum++] = formatTestLong(montestdata.get(j).getTestTimelong());
                datas[j][currnum++] = formartDouble(montestdata.get(j).getGroupVol(),1)+"";
                datas[j][currnum++] = formartDouble(montestdata.get(j).getOnlineVol(),1)+"";
                datas[j][currnum++] = formartDouble(montestdata.get(j).getTestCurr(),3)+"";
                datas[j][currnum++] = formartDouble(montestdata.get(j).getTestCap(),1)+"";
                datas[j][currnum++] = formartDouble(montestdata.get(j).getGroupVol(), 1) + "";
                datas[j][currnum++] = formartDouble(montestdata.get(j).getOnlineVol(), 1) + "";
                datas[j][currnum++] = formartDouble(montestdata.get(j).getTestCurr(), 3) + "";
                datas[j][currnum++] = formartDouble(montestdata.get(j).getTestCap(), 1) + "";
                datas[j][currnum++] =formartDouble(montestdata.get(j).getMonVol(),3)+"";
                datas[j][currnum++] = formartDouble(montestdata.get(j).getMonVol(), 3) + "";
                //datas[j][currnum++] = "";
@@ -896,25 +1167,24 @@
    }
    //生成报告封面
    private void CreateReportCover(HSSFWorkbook wb,BattMaintDealarm bmd){
    private void CreateReportCover(HSSFWorkbook wb, BattMaintDealarm bmd) {
        HSSFSheet sheet = wb.createSheet("报告封面");
        sheet.setDefaultColumnWidth(9);         // 设置单元格默认宽度
        sheet.setDefaultRowHeight((short)(30*11));
        sheet.setDefaultColumnWidth(9);            // 设置单元格默认宽度
        sheet.setDefaultRowHeight((short) (30 * 11));
        //sheet.setDefaultRowHeightInPoints(18);    //设置单元格默认高度
        //System.out.println(bmd.getSdata());
        HSSFCellStyle titleCellStyle = ExcelUtil.createCellStyle(wb,"楷体_GB2312",28,true,true);      //单元格样式
        HSSFCellStyle titleCellStyle = ExcelUtil.createCellStyle(wb, "楷体_GB2312", 28, true, true);        //单元格样式
        HSSFCellStyle menuCellStyle = ExcelUtil.createCellStyle(wb,"楷体_GB2312",20,false,true);      //单元格样式
        HSSFCellStyle textCellStyle = ExcelUtil.createCellStyle(wb,"楷体_GB2312",20,true,true);      //单元格样式
        sheet.setColumnWidth(3, 24*256);
        HSSFCellStyle menuCellStyle = ExcelUtil.createCellStyle(wb, "楷体_GB2312", 20, false, true);        //单元格样式
        HSSFCellStyle textCellStyle = ExcelUtil.createCellStyle(wb, "楷体_GB2312", 20, true, true);        //单元格样式
        sheet.setColumnWidth(3, 24 * 256);
        //sheet.setColumnWidth(3, 20*256);
        int rowNum = 1;
        sheet.createRow(rowNum++);
        sheet.createRow(rowNum++);
        sheet.createRow(rowNum++);
        sheet.addMergedRegion(new CellRangeAddress(2,3,2,8));         //合并指定的单元格  param1 开始行    param2  结束行   param3  开始列     param4  结束列
        sheet.addMergedRegion(new CellRangeAddress(2, 3, 2, 8));            //合并指定的单元格  param1 开始行    param2  结束行   param3  开始列     param4  结束列
        sheet.getRow(2).createCell(2).setCellValue("蓄电池容量测试报告");
        sheet.getRow(2).getCell(2).setCellStyle(titleCellStyle);
        sheet.getRow(2).setHeightInPoints(17);
@@ -1012,19 +1282,19 @@
    }
    //生成起止电压数据
    private void CreateStartEndVol(HSSFWorkbook wb,String[][] data){
    private void CreateStartEndVol(HSSFWorkbook wb, String[][] data) {
        HSSFSheet sheet = wb.createSheet("起止电压数据");
        HSSFCellStyle titleCellStyle = ExcelUtil.createCellStyle(wb,"宋体",12,true,true);      //单元格样式
        HSSFCellStyle numCellStyle = ExcelUtil.createCellStyle(wb,"Times New Roman",12,true,true);         //单元格样式
        HSSFCellStyle txtCellStyle = ExcelUtil.createCellStyle(wb,"宋体",12,true,false);      //单元格样式
        HSSFCellStyle titleCellStyle = ExcelUtil.createCellStyle(wb, "宋体", 12, true, true);        //单元格样式
        HSSFCellStyle numCellStyle = ExcelUtil.createCellStyle(wb, "Times New Roman", 12, true, true);            //单元格样式
        HSSFCellStyle txtCellStyle = ExcelUtil.createCellStyle(wb, "宋体", 12, true, false);        //单元格样式
        sheet.setColumnWidth(2, 24*256);
        sheet.setColumnWidth(3, 24*256);
        sheet.setColumnWidth(4, 24*256);
        sheet.setColumnWidth(2, 24 * 256);
        sheet.setColumnWidth(3, 24 * 256);
        sheet.setColumnWidth(4, 24 * 256);
        sheet.setDefaultColumnWidth(9);                  // 设置单元格默认宽度
        sheet.setDefaultRowHeight((short)(30*11));
        sheet.setDefaultColumnWidth(9);                        // 设置单元格默认宽度
        sheet.setDefaultRowHeight((short) (30 * 11));
        int rowNum = 0;
        sheet.createRow(rowNum);
        sheet.getRow(rowNum).createCell(3).setCellValue("起始值(V)");
@@ -1056,32 +1326,32 @@
        sheet.getRow(rowNum++).getCell(4).setCellStyle(txtCellStyle);
        for(int i=0;i<startArr.length;i++){
            sheet.createRow(rowNum);
            sheet.getRow(rowNum).createCell(2).setCellValue("#"+(i+1));
            sheet.getRow(rowNum).createCell(2).setCellValue("#" + (i + 1));
            sheet.getRow(rowNum).getCell(2).setCellStyle(numCellStyle);
            sheet.getRow(rowNum).createCell(3).setCellValue(""+startArr[i]);
            sheet.getRow(rowNum).createCell(3).setCellValue("" + startArr[i]);
            sheet.getRow(rowNum).getCell(3).setCellStyle(txtCellStyle);
            sheet.getRow(rowNum).createCell(4).setCellValue(""+endArr[i]);
            sheet.getRow(rowNum).createCell(4).setCellValue("" + endArr[i]);
            sheet.getRow(rowNum++).getCell(4).setCellStyle(txtCellStyle);
        }
    }
    //生成容量分析表
    private void CreateCapAnalyTable(HSSFWorkbook wb,String[][] data,String picstr){
    private void CreateCapAnalyTable(HSSFWorkbook wb, String[][] data, String picstr) {
        HSSFSheet sheet = wb.createSheet("容量分析表");
        HSSFCellStyle titleCellStyle = ExcelUtil.createCellStyle(wb,"宋体",12,true,true);      //单元格样式
        HSSFCellStyle txtCellStyle = ExcelUtil.createCellStyle(wb,"宋体",12,true,false);      //单元格样式
        HSSFCellStyle titleCellStyle = ExcelUtil.createCellStyle(wb, "宋体", 12, true, true);        //单元格样式
        HSSFCellStyle txtCellStyle = ExcelUtil.createCellStyle(wb, "宋体", 12, true, false);        //单元格样式
        sheet.setDefaultColumnWidth(9);                  // 设置单元格默认宽度
        sheet.setColumnWidth(0, 8*256);
        sheet.setColumnWidth(1, 6*256);
        sheet.setColumnWidth(2, 13*256);
        sheet.setColumnWidth(3, 18*256);
        sheet.setColumnWidth(4, 18*256);
        sheet.setColumnWidth(5, 18*256);
        sheet.setColumnWidth(6, 18*256);
        byte [] pic = null;
        if(ServletUtils.isNotNull(picstr)){
        sheet.setDefaultColumnWidth(9);                        // 设置单元格默认宽度
        sheet.setColumnWidth(0, 8 * 256);
        sheet.setColumnWidth(1, 6 * 256);
        sheet.setColumnWidth(2, 13 * 256);
        sheet.setColumnWidth(3, 18 * 256);
        sheet.setColumnWidth(4, 18 * 256);
        sheet.setColumnWidth(5, 18 * 256);
        sheet.setColumnWidth(6, 18 * 256);
        byte[] pic = null;
        if (ServletUtils.isNotNull(picstr)) {
            try {
                String[] url = picstr.split(",");
                pic = new BASE64Decoder().decodeBuffer(url[1]);
@@ -1090,11 +1360,11 @@
            }
        }
        HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
        if(pic != null){
            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, 25 * 0 + 1, (short) 10, 25 * (0 + 1));
        if (pic != null) {
            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255, (short) 1, 25 * 0 + 1, (short) 10, 25 * (0 + 1));
            anchor.setAnchorType(3);
            // 插入图片
            patriarch.createPicture(anchor,   wb.addPicture(pic,HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
            patriarch.createPicture(anchor, wb.addPicture(pic, HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
        }
        int rouNum = 26;
@@ -1123,20 +1393,20 @@
    }
    //生成电压特性比较图
    private void CreateMonVolAnalyTable(HSSFWorkbook wb,String[][] data,String picstr){
    private void CreateMonVolAnalyTable(HSSFWorkbook wb, String[][] data, String picstr) {
        HSSFSheet sheet = wb.createSheet("电压特性比较图");
        HSSFCellStyle titleCellStyle = ExcelUtil.createCellStyle(wb,"宋体",12,true,true);      //单元格样式
        HSSFCellStyle txtCellStyle = ExcelUtil.createCellStyle(wb,"宋体",12,true,false);      //单元格样式
        HSSFCellStyle titleCellStyle = ExcelUtil.createCellStyle(wb, "宋体", 12, true, true);        //单元格样式
        HSSFCellStyle txtCellStyle = ExcelUtil.createCellStyle(wb, "宋体", 12, true, false);        //单元格样式
        sheet.setDefaultColumnWidth(9);                  // 设置单元格默认宽度
        sheet.setDefaultColumnWidth(9);                        // 设置单元格默认宽度
        sheet.setColumnWidth(2, 19*256);
        sheet.setColumnWidth(3, 19*256);
        sheet.setColumnWidth(4, 19*256);
        sheet.setColumnWidth(2, 19 * 256);
        sheet.setColumnWidth(3, 19 * 256);
        sheet.setColumnWidth(4, 19 * 256);
        byte [] pic = null;
        if(ServletUtils.isNotNull(picstr)){
        byte[] pic = null;
        if (ServletUtils.isNotNull(picstr)) {
            try {
                String[] url = picstr.split(",");
                pic = new BASE64Decoder().decodeBuffer(url[1]);
@@ -1145,18 +1415,18 @@
            }
        }
        HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
        if(pic != null){
            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, 25 * 0 + 1, (short) 10, 25 * (0 + 1));
        if (pic != null) {
            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255, (short) 1, 25 * 0 + 1, (short) 10, 25 * (0 + 1));
            anchor.setAnchorType(3);
            // 插入图片
            patriarch.createPicture(anchor,   wb.addPicture(pic,HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
            patriarch.createPicture(anchor, wb.addPicture(pic, HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
        }
        int rouNum = 26;
        sheet.createRow(rouNum);
        float maxStart = Float.parseFloat(data[1][0]);
        float maxEnd = Float.parseFloat(data[2][0]);
        int maxStartNum = 1,maxEndNum = 1;
        int maxStartNum = 1, maxEndNum = 1;
        for(int i=0;i<data[0].length;i++){
            if(Float.parseFloat(data[1][i])>maxStart){
                maxStart = Float.parseFloat(data[1][i]);
@@ -1195,12 +1465,14 @@
    }
    //生成单个图片工作簿
    private void CreateTotalVolAnalyTable(HSSFWorkbook wb,String sheetName,String picstr){
    private void CreateTotalVolAnalyTable(HSSFWorkbook wb, String sheetName, String picstr) {
        HSSFSheet sheet = wb.createSheet(sheetName);
        sheet.setDefaultColumnWidth(9);                  // 设置单元格默认宽度
        sheet.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        byte [] pic = null;
        if(ServletUtils.isNotNull(picstr)){
        byte[] pic = null;
        if (ServletUtils.isNotNull(picstr)) {
            try {
                String[] url = picstr.split(",");
                pic = new BASE64Decoder().decodeBuffer(url[1]);
@@ -1209,11 +1481,11 @@
            }
        }
        HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
        if(pic != null){
            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, 25 * 0 + 1, (short) 10, 25 * (0 + 1));
        if (pic != null) {
            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255, (short) 1, 25 * 0 + 1, (short) 10, 25 * (0 + 1));
            anchor.setAnchorType(3);
            // 插入图片
            patriarch.createPicture(anchor,   wb.addPicture(pic,HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
            patriarch.createPicture(anchor, wb.addPicture(pic, HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
        }
    }
@@ -1240,12 +1512,15 @@
            int nowColIndex = 0;
            int rowNum = 0;
            for(int i =0;i<=mon_vol_list.length;i++){
                if(i%maxColCount == 0){
                if (i % maxColCount == 0) {
                    //创建新的工作簿
                    sheet = wb.createSheet("电压数据表格"+tableCount++);
                    for(int k = 0;k<tabTh.size();k++){
                    sheet = wb.createSheet("电压数据表格" + tableCount++);
                    sheet.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
                    sheet.setDefaultRowHeight((short) (1 * 256));
                    ; //设置默认行高,表示2个字符的高度
                    for (int k = 0; k < tabTh.size(); k++) {
                        sheet.createRow(k);
                        sheet.setDefaultColumnWidth(12);                  // 设置单元格默认宽度
                        sheet.setDefaultColumnWidth(12);                        // 设置单元格默认宽度
                    }
                }
                rowNum = 0;
@@ -1288,148 +1563,200 @@
    //生成历史数据中的报表
    private void createExcel(List<byte[]> bytes,Title title,Qth qth,String[][] datas,BattMaintDealarm bmd,String[][] mon_vol_list ,String[][] mon_tmp_list,List<BatttestdataId> groupinfo,String splitTime,String[] timeCompareList,String[][] monVolCompareList,String[][] monTempCompareList,String monVolComparePic, String monTempComparePic,HttpServletResponse resp,
                             HttpServletRequest req) {
        String[] arrTh = new String[]{
                "单体编号","起始单体电压(V)","截止单体电压(V)","实际容量(AH)","剩余容量(AH)","实际容量百分比(%)","单体内阻(mΩ)","起始单体温度(℃)","终止单体温度(℃)"
        };
        String[] picName = new String[]{
                "组端电压曲线","电池电流曲线","终止单体电压","终止单体温度","单体内阻","单体均衡电流","单体电压","单体实际容量","单体剩余容量","单体实际容量百分比","单体电压曲线","单体温度曲线","单体剩余容量曲线"
        };
        //根据当前的语言环境设置不同的日志记录
        String lang = ActionUtil.getLang();
        String[] arrTh = null;
        String[] picName = null;
        if (lang.contains("zh")) {
            arrTh = new String[]{
                    "单体编号", "起始单体电压(V)", "截止单体电压(V)", "实际容量(AH)", "剩余容量(AH)", "实际容量百分比(%)", "单体内阻(mΩ)", "起始单体温度(℃)", "终止单体温度(℃)"
            };
            picName = new String[]{
                    "组端电压曲线", "电池电流曲线", "终止单体电压", "终止单体温度", "单体内阻", "单体均衡电流", "单体电压", "单体实际容量", "单体剩余容量", "单体实际容量百分比", "单体电压曲线", "单体温度曲线", "单体剩余容量曲线"
            };
        } else {
            arrTh = new String[]{
                    "Unit number", "Starting unit voltage(V)", "Cutoff cell voltage(V)", "Actual Capacity(AH)", "remaining capacity(AH)", "Actual capacity percentage(%)", "Individual internal resistance(mΩ)", "Starting monomer temperature(℃)", "Termination monomer temperature(℃)"
            };
            picName = new String[]{
                    "Group terminal voltage curve", "Battery current curve", "Termination unit voltage", "Termination monomer temperature", "Individual internal resistance", "Individual balanced current", "Individual voltage", "Actual capacity of individual units", "Remaining capacity of single unit", "Actual capacity percentage of individual units", "Individual voltage curve", "Individual temperature curve", "Individual residual capacity curve"
            };
        }
        try {
            // 创建一个工作薄
            HSSFWorkbook wb = new HSSFWorkbook();
            HSSFSheet sheet1 = wb.createSheet("数据总表");
            HSSFSheet sheet1 = null;
            if (lang.contains("zh")) {
                sheet1 = wb.createSheet("数据总表");
            } else {
                sheet1 = wb.createSheet("Data Summary Table");
            }
            sheet1.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
            sheet1.setDefaultRowHeight((short) (1 * 256));
            ; //设置默认行高,表示2个字符的高度
            // HSSFRow row = sheet1.createRow(2);
            HSSFPatriarch patriarch = sheet1.createDrawingPatriarch();
            int rownum = 1;
            sheet1.createRow(rownum);
            sheet1.getRow(rownum).createCell(1).setCellValue("电池组名称");
            sheet1.getRow(rownum).createCell(2).setCellValue(bmd.getBinf().getStationName()+"-"+bmd.getBinf().getBattGroupName());
            rownum++;
            sheet1.createRow(rownum);
            sheet1.getRow(rownum).createCell(1).setCellValue( "电池品牌:"+bmd.getBinf().getBattProducer());
            sheet1.getRow(rownum).createCell(2).setCellValue( "安装日期:"+formartDate(bmd.getBinf().getBattInUseDate(),"yyyy-MM-dd"));
            sheet1.getRow(rownum).createCell(3).setCellValue( "单体数量:"+bmd.getBinf().getMonCount());
            sheet1.getRow(rownum).createCell(4).setCellValue( "单体电压:"+bmd.getBinf().getMonVolStd()+"V");
            sheet1.getRow(rownum).createCell(5).setCellValue( "单体标称容量:"+formartDouble(bmd.getBinf().getMonCapStd(),0)+"AH");
            sheet1.getRow(rownum).createCell(6).setCellValue( "单体标称内阻:"+formartDouble(bmd.getBinf().getMonResStd(),3)+"mΩ");
            sheet1.getRow(rownum).createCell(7).setCellValue( "单体标称电导:"+formartDouble(bmd.getBinf().getMonSerStd(),0));
            rownum++;
            sheet1.createRow(rownum);
            sheet1.getRow(rownum).createCell(1).setCellValue( "测试类型:"+BattTestData.battState(bmd.getSdata().getTestType()));
            sheet1.getRow(rownum).createCell(2).setCellValue( "测试时间:"+formartDate(bmd.getSdata().getTestStarttime(),"yyyy-MM-dd HH:mm:ss"));
            sheet1.getRow(rownum).createCell(3).setCellValue( "测试电流:"+bmd.getSdata().getTestCurr()+"A");
            sheet1.getRow(rownum).createCell(4).setCellValue( "测试时长:"+formatTestLong(bmd.getSdata().getTestTimelong()));
            sheet1.getRow(rownum).createCell(5).setCellValue( "结束时间:"+formartDate(new Date(bmd.getSdata().getTestStarttime().getTime()+bmd.getSdata().getTestTimelong()*1000),"yyyy-MM-dd HH:mm:ss"));
            sheet1.getRow(rownum).createCell(6).setCellValue( "测试容量:"+formartDouble(bmd.getSdata().getTestCap(),0)+"AH");
            sheet1.getRow(rownum).createCell(7).setCellValue( "终止原因:"+(bmd.getSdata().getTestType()==2?"":bmd.getBinf().getStationIP()));
            rownum++;
            sheet1.createRow(rownum);
            sheet1.getRow(rownum).createCell(1).setCellValue( "报告日期:");
            sheet1.getRow(rownum).createCell(2).setCellValue(formartDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
            rownum+=4;
            int picnum = 0;
            for(int i=0;i<picName.length;i++){
                sheet1.createRow(rownum-1);
                sheet1.getRow(rownum-1).createCell(1).setCellValue(picName[i]);
                //rownum++;
                HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, rownum, (short) 10, rowNumAdd * (picnum + 1));
                anchor.setAnchorType(3);
                patriarch.createPicture(anchor,wb.addPicture(bytes.get(picnum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                picnum ++;rownum+=rowNumAdd;
            //钱煜要求电流计算出来(测试容量*3600/测试时长)
            String testCurr = bmd.getSdata().getTestCurr().toString();
            if (bmd.getSdata().getTestTimelong() != 0) {
                float curr = (bmd.getSdata().getTestCap() * 3600) / bmd.getSdata().getTestTimelong();
                testCurr = new Formatter().format("%.1f", curr).toString();
            }
            if (lang.contains("zh")) {
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("电池组名称");
                sheet1.getRow(rownum).createCell(2).setCellValue(bmd.getBinf().getStationName() + "-" + bmd.getBinf().getBattGroupName());
                rownum++;
         /*sheet1.createRow(rownum);
         sheet1.getRow(rownum).createCell(1).setCellValue("单体实际容量");
         rownum++;
         anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, rownum, (short) 10, 25 * (picnum + 1));
         anchor.setAnchorType(3);
         patriarch.createPicture(anchor,wb.addPicture(bytes.get(picnum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
         picnum ++;rownum+=25;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("电池品牌:" + bmd.getBinf().getBattProducer());
                sheet1.getRow(rownum).createCell(2).setCellValue("安装日期:" + formartDate(bmd.getBinf().getBattInUseDate(), "yyyy-MM-dd"));
                sheet1.getRow(rownum).createCell(3).setCellValue("单体数量:" + bmd.getBinf().getMonCount());
                sheet1.getRow(rownum).createCell(4).setCellValue("单体电压:" + bmd.getBinf().getMonVolStd() + "V");
                sheet1.getRow(rownum).createCell(5).setCellValue("单体标称容量:" + formartDouble(bmd.getBinf().getMonCapStd(), 0) + "AH");
                sheet1.getRow(rownum).createCell(6).setCellValue("单体标称内阻:" + formartDouble(bmd.getBinf().getMonResStd(), 3) + "mΩ");
                sheet1.getRow(rownum).createCell(7).setCellValue("单体标称电导:" + formartDouble(bmd.getBinf().getMonSerStd(), 0));
         sheet1.createRow(rownum);
         sheet1.getRow(rownum).createCell(1).setCellValue("单体剩余容量");
         rownum++;
         anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, rownum, (short) 10, 25 * (picnum + 1));
         anchor.setAnchorType(3);
         patriarch.createPicture(anchor,wb.addPicture(bytes.get(picnum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
         picnum ++;rownum+=25;
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("测试类型:" + MessageUtils.getMessageSocket(BattTestData.battState(bmd.getSdata().getTestType()), lang));
                sheet1.getRow(rownum).createCell(2).setCellValue("测试时间:" + formartDate(bmd.getSdata().getTestStarttime(), "yyyy-MM-dd HH:mm:ss"));
                //sheet1.getRow(rownum).createCell(3).setCellValue("测试电流:" + bmd.getSdata().getTestCurr() + "A");
                sheet1.getRow(rownum).createCell(3).setCellValue("测试电流:" + testCurr + "A");
                sheet1.getRow(rownum).createCell(4).setCellValue("测试时长:" + formatTestLong(bmd.getSdata().getTestTimelong()));
                sheet1.getRow(rownum).createCell(5).setCellValue("结束时间:" + formartDate(new Date(bmd.getSdata().getTestStarttime().getTime() + bmd.getSdata().getTestTimelong() * 1000), "yyyy-MM-dd HH:mm:ss"));
                sheet1.getRow(rownum).createCell(6).setCellValue("测试容量:" + formartDouble(bmd.getSdata().getTestCap(), 0) + "AH");
                //stationIp存放的终止原因
                sheet1.getRow(rownum).createCell(7).setCellValue("终止原因:" + (bmd.getSdata().getTestType() == 2 ? "" : bmd.getBinf().getStationIP()));
         sheet1.createRow(rownum);
         sheet1.getRow(rownum).createCell(1).setCellValue("单体实际容量百分比");
         rownum++;
         anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, rownum, (short) 10, 25 * (picnum + 1));
         anchor.setAnchorType(3);
         patriarch.createPicture(anchor,wb.addPicture(bytes.get(picnum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
         picnum ++;rownum+=25;
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("报告日期:");
                sheet1.getRow(rownum).createCell(2).setCellValue(formartDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
                rownum += 4;
         sheet1.createRow(rownum);
         sheet1.getRow(rownum).createCell(1).setCellValue("单体电压曲线");
         rownum++;
         anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, rownum, (short) 10, 25 * (picnum + 1));
         anchor.setAnchorType(3);
         patriarch.createPicture(anchor,wb.addPicture(bytes.get(picnum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
         picnum ++;rownum+=25;
                int picnum = 0;
         sheet1.createRow(rownum);
         sheet1.getRow(rownum).createCell(1).setCellValue("组端电压曲线");
         rownum++;
         anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, rownum, (short) 10, 25 * (picnum + 1));
         anchor.setAnchorType(3);
         patriarch.createPicture(anchor,wb.addPicture(bytes.get(picnum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
         picnum ++;rownum+=25;
                for (int i = 0; i < picName.length; i++) {
                    sheet1.createRow(rownum - 1);
                    sheet1.getRow(rownum - 1).createCell(1).setCellValue(picName[i]);
                    //rownum++;
                    HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255, (short) 1, rownum, (short) 10, rowNumAdd * (picnum + 1));
                    anchor.setAnchorType(3);
                    patriarch.createPicture(anchor, wb.addPicture(bytes.get(picnum), HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                    picnum++;
                    rownum += rowNumAdd;
                }
         sheet1.createRow(rownum);
         sheet1.getRow(rownum).createCell(1).setCellValue("电池电流曲线");
         rownum++;
         anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, rownum, (short) 10, 25 * (picnum + 1));
         anchor.setAnchorType(3);
         patriarch.createPicture(anchor,wb.addPicture(bytes.get(picnum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
         picnum ++;rownum+=25;*/
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("最高单体电压");
                sheet1.getRow(rownum).createCell(2).setCellValue("最低单体电压");
                sheet1.getRow(rownum).createCell(3).setCellValue("平均单体电压");
                sheet1.getRow(rownum).createCell(4).setCellValue("落后单体电压值");
                sheet1.getRow(rownum).createCell(5).setCellValue("落后单体数量");
                sheet1.getRow(rownum).createCell(6).setCellValue("落后单体数量百分比");
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue(title.getMax());
                sheet1.getRow(rownum).createCell(2).setCellValue(title.getMin());
                sheet1.getRow(rownum).createCell(3).setCellValue(title.getAvg());
                sheet1.getRow(rownum).createCell(4).setCellValue(title.getClow());
                sheet1.getRow(rownum).createCell(5).setCellValue(title.getLc());
                sheet1.getRow(rownum).createCell(6).setCellValue(title.getLp() + "%");
                rownum += 2;
            } else {
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Battery pack name");
                sheet1.getRow(rownum).createCell(2).setCellValue(bmd.getBinf().getStationName() + "-" + bmd.getBinf().getBattGroupName());
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Battery brand:" + bmd.getBinf().getBattProducer());
                sheet1.getRow(rownum).createCell(2).setCellValue("install date:" + formartDate(bmd.getBinf().getBattInUseDate(), "yyyy-MM-dd"));
                sheet1.getRow(rownum).createCell(3).setCellValue("Number of monomers:" + bmd.getBinf().getMonCount());
                sheet1.getRow(rownum).createCell(4).setCellValue("Individual voltage:" + bmd.getBinf().getMonVolStd() + "V");
                sheet1.getRow(rownum).createCell(5).setCellValue("Individual nominal capacity:" + formartDouble(bmd.getBinf().getMonCapStd(), 0) + "AH");
                sheet1.getRow(rownum).createCell(6).setCellValue("Individual nominal internal resistance:" + formartDouble(bmd.getBinf().getMonResStd(), 3) + "mΩ");
                sheet1.getRow(rownum).createCell(7).setCellValue("Individual nominal conductivity:" + formartDouble(bmd.getBinf().getMonSerStd(), 0));
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Test Type:" + MessageUtils.getMessageSocket(BattTestData.battState(bmd.getSdata().getTestType()), lang));
                sheet1.getRow(rownum).createCell(2).setCellValue("Test Time:" + formartDate(bmd.getSdata().getTestStarttime(), "yyyy-MM-dd HH:mm:ss"));
                sheet1.getRow(rownum).createCell(3).setCellValue("Test Curr:" + testCurr + "A");
                sheet1.getRow(rownum).createCell(4).setCellValue("Test TimeLong:" + formatTestLong(bmd.getSdata().getTestTimelong()));
                sheet1.getRow(rownum).createCell(5).setCellValue("Stop Time:" + formartDate(new Date(bmd.getSdata().getTestStarttime().getTime() + bmd.getSdata().getTestTimelong() * 1000), "yyyy-MM-dd HH:mm:ss"));
                sheet1.getRow(rownum).createCell(6).setCellValue("Test Cap:" + formartDouble(bmd.getSdata().getTestCap(), 0) + "AH");
                //stationIp存放的终止原因
                sheet1.getRow(rownum).createCell(7).setCellValue("Stop Reason:" + (bmd.getSdata().getTestType() == 2 ? "" : bmd.getBinf().getStationIP()));
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Report Date:");
                sheet1.getRow(rownum).createCell(2).setCellValue(formartDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
                rownum += 4;
                int picnum = 0;
                for (int i = 0; i < picName.length; i++) {
                    sheet1.createRow(rownum - 1);
                    sheet1.getRow(rownum - 1).createCell(1).setCellValue(picName[i]);
                    //rownum++;
                    HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255, (short) 1, rownum, (short) 10, rowNumAdd * (picnum + 1));
                    anchor.setAnchorType(3);
                    patriarch.createPicture(anchor, wb.addPicture(bytes.get(picnum), HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                    picnum++;
                    rownum += rowNumAdd;
                }
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Maximum individual voltage");
                sheet1.getRow(rownum).createCell(2).setCellValue("Minimum unit voltage");
                sheet1.getRow(rownum).createCell(3).setCellValue("Average individual voltage");
                sheet1.getRow(rownum).createCell(4).setCellValue("Backward unit voltage value");
                sheet1.getRow(rownum).createCell(5).setCellValue("Number of lagging units");
                sheet1.getRow(rownum).createCell(6).setCellValue("Percentage of lagging units");
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue(title.getMax());
                sheet1.getRow(rownum).createCell(2).setCellValue(title.getMin());
                sheet1.getRow(rownum).createCell(3).setCellValue(title.getAvg());
                sheet1.getRow(rownum).createCell(4).setCellValue(title.getClow());
                sheet1.getRow(rownum).createCell(5).setCellValue(title.getLc());
                sheet1.getRow(rownum).createCell(6).setCellValue(title.getLp() + "%");
                rownum += 2;
            }
            sheet1.createRow(rownum);
            sheet1.getRow(rownum).createCell(1).setCellValue("最高单体电压");
            sheet1.getRow(rownum).createCell(2).setCellValue("最低单体电压");
            sheet1.getRow(rownum).createCell(3).setCellValue("平均单体电压");
            sheet1.getRow(rownum).createCell(4).setCellValue("落后单体电压值");
            sheet1.getRow(rownum).createCell(5).setCellValue("落后单体数量");
            sheet1.getRow(rownum).createCell(6).setCellValue("落后单体数量百分比");
            rownum++;
            sheet1.createRow(rownum);
            sheet1.getRow(rownum).createCell(1).setCellValue(title.getMax());
            sheet1.getRow(rownum).createCell(2).setCellValue(title.getMin());
            sheet1.getRow(rownum).createCell(3).setCellValue(title.getAvg());
            sheet1.getRow(rownum).createCell(4).setCellValue(title.getClow());
            sheet1.getRow(rownum).createCell(5).setCellValue(title.getLc());
            sheet1.getRow(rownum).createCell(6).setCellValue(title.getLp()+"%");
            rownum+=2;
            sheet1.createRow(rownum);
            for(int i = 0 ;i<arrTh.length;i++){
                sheet1.getRow(rownum).createCell(i+1).setCellValue(arrTh[i]);
            for (int i = 0; i < arrTh.length; i++) {
                sheet1.getRow(rownum).createCell(i + 1).setCellValue(arrTh[i]);
            }
            rownum++;
            if(datas!=null && datas.length>0){
                for(int i=0;i<datas[0].length;i++){
            if (datas != null && datas.length > 0) {
                for (int i = 0; i < datas[0].length; i++) {
                    sheet1.createRow(rownum);
                    for(int j=0;j<datas.length;j++){
                        sheet1.getRow(rownum).createCell(j+1).setCellValue(datas[j][i]);
                    for (int j = 0; j < datas.length; j++) {
                        sheet1.getRow(rownum).createCell(j + 1).setCellValue(datas[j][i]);
                    }
                    rownum++;
                }
            }
            //单体数
            int monNum = mon_tmp_list.length;
            //导出的总笔数
            int exportNum = groupinfo.size();
            //单体电压数据表(flag(0:单体电压,1:温度))
            createMonInfoSheet(wb, mon_vol_list, groupinfo, monNum, exportNum, 0);
            //单体温度数据表
            createMonInfoSheet(wb, mon_tmp_list, groupinfo, monNum, exportNum, 1);
            //单体电压对比表-单体温度对比表
            createMonInfoSheet2(bytes, wb, splitTime, timeCompareList, monVolCompareList, monTempCompareList, monVolComparePic, monTempComparePic);
            createMonInfoSheet(wb,mon_vol_list ,mon_tmp_list,groupinfo);
            createMonInfoSheet2(bytes,wb,splitTime,timeCompareList,monVolCompareList ,monTempCompareList,monVolComparePic,monTempComparePic);
            if (qth.getCode()==1) {
            if (qth.getCode() == 1) {
                rownum += 2;
                //锅底   驼峰   Qg   Qt   Qh   电池性能
                sheet1.createRow(rownum);
@@ -1454,12 +1781,28 @@
                sheet1.getRow(rownum).createCell(6).setCellValue(qth.getTitle());
            }
            //取出电池组信息构建excel文件的名称
            String excelName =binfservice.serchExcelName(bmd.getBinf().getBattGroupId());
            //excel文件名
            String testTime = new SimpleDateFormat("yyyy-MM-dd").format(bmd.getSdata().getTestStarttime());
            excelName = excelName+"-"+testTime;
            String regEx="[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
            excelName = excelName.replace(regEx,"");
            String excelName = "";
            Battinf binf = binfservice.getdevIdByBattGroupId(bmd.getBinf().getBattGroupId());
            Long dev_id = binf.getFBSDeviceId();//获取设备id判断文件名
            if (dev_id != null) {
                if (dev_id / 100000 == DeviceTypeDTO.DEVICE8059 || dev_id / 100000 == DeviceTypeDTO.DEVICE8060) {
                    //StationName9放文本信息用于8059、8060设备加文件名信息
                    excelName = binfservice.serchExcelNameA059(bmd.getBinf().getBattGroupId(), bmd.getBinf().getStationName9());
                } else {
                    excelName = binfservice.serchExcelName(bmd.getBinf().getBattGroupId());
                    //excel文件名
                    String testTime = new SimpleDateFormat("yyyy-MM-dd").format(bmd.getSdata().getTestStarttime());
                    excelName = excelName + "-" + testTime;
                }
            } else {
                excelName = binfservice.serchExcelName(bmd.getBinf().getBattGroupId());
                //excel文件名
                String testTime = new SimpleDateFormat("yyyy-MM-dd").format(bmd.getSdata().getTestStarttime());
                excelName = excelName + "-" + testTime;
            }
            String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
            excelName = excelName.replaceAll(regEx, "");
            // 转码防止乱码
            resp.addHeader("Content-Disposition", "attachment;filename="
                    + new String(excelName.getBytes("UTF-8"), "ISO8859-1")
@@ -1473,7 +1816,524 @@
            e.printStackTrace();
        }
    }
    //生成历史数据中的报表
    private void createExcel2007DZ(List<byte[]> bytes,Title title,Qth qth,String[][] datas,BattMaintDealarm bmd,String[][] mon_vol_list ,String[][] mon_tmp_list,List<BatttestdataId> groupinfo,String splitTime,String[] timeCompareList,String[][] monVolCompareList,String[][] monTempCompareList,String monVolComparePic, String monTempComparePic,HttpServletResponse resp,
                                 HttpServletRequest req) {
        //根据当前的语言环境设置不同的日志记录
        String lang = ActionUtil.getLang();
        String[] arrTh = null;
        String[] picName = null;
        if (lang.contains("zh")) {
            arrTh = new String[]{
                    "单体编号", "起始单体电压(V)", "截止单体电压(V)", "实际容量(AH)", "剩余容量(AH)", "实际容量百分比(%)", "起始单体温度(℃)", "终止单体温度(℃)"
            };
            picName = new String[]{
                    "组端电压曲线", "电池电流曲线", "终止单体电压", "终止单体温度", "单体电压", "单体实际容量", "单体剩余容量", "单体实际容量百分比", "单体电压曲线", "单体温度曲线", "单体剩余容量曲线"
            };
        } else {
            arrTh = new String[]{
                    "Unit number", "Starting unit voltage(V)", "Cutoff cell voltage(V)", "Actual Capacity(AH)", "remaining capacity(AH)", "Actual capacity percentage(%)", "Starting monomer temperature(℃)", "Termination monomer temperature(℃)"
            };
            picName = new String[]{
                    "Group terminal voltage curve", "Battery current curve", "Termination unit voltage", "Termination monomer temperature",  "Individual voltage", "Actual capacity of individual units", "Remaining capacity of single unit", "Actual capacity percentage of individual units", "Individual voltage curve", "Individual temperature curve", "Individual residual capacity curve"
            };
        }
        try {
            // 创建一个工作薄
            XSSFWorkbook wb = new XSSFWorkbook();
            XSSFSheet sheet1 = null;
            if (lang.contains("zh")) {
                sheet1 = wb.createSheet("数据总表");
            } else {
                sheet1 = wb.createSheet("Data Summary Table");
            }
            sheet1.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
            sheet1.setDefaultRowHeight((short) (1 * 256));
            ; //设置默认行高,表示2个字符的高度
            // HSSFRow row = sheet1.createRow(2);
            XSSFDrawing patriarch = sheet1.createDrawingPatriarch();
            int rownum = 1;
            //钱煜要求电流计算出来(测试容量*3600/测试时长)
            String testCurr = bmd.getSdata().getTestCurr().toString();
            if (bmd.getSdata().getTestTimelong() != 0) {
                float curr = (bmd.getSdata().getTestCap() * 3600) / bmd.getSdata().getTestTimelong();
                testCurr = new Formatter().format("%.1f", curr).toString();
            }
            if (lang.contains("zh")) {
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("电池组名称");
                sheet1.getRow(rownum).createCell(2).setCellValue(bmd.getBinf().getStationName() + "-" + bmd.getBinf().getBattGroupName());
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("电池品牌:" + bmd.getBinf().getBattProducer());
                sheet1.getRow(rownum).createCell(2).setCellValue("安装日期:" + formartDate(bmd.getBinf().getBattInUseDate(), "yyyy-MM-dd"));
                sheet1.getRow(rownum).createCell(3).setCellValue("单体数量:" + bmd.getBinf().getMonCount());
                sheet1.getRow(rownum).createCell(4).setCellValue("单体电压:" + bmd.getBinf().getMonVolStd() + "V");
                sheet1.getRow(rownum).createCell(5).setCellValue("单体标称容量:" + formartDouble(bmd.getBinf().getMonCapStd(), 0) + "AH");
                sheet1.getRow(rownum).createCell(6).setCellValue("单体标称内阻:" + formartDouble(bmd.getBinf().getMonResStd(), 3) + "mΩ");
                sheet1.getRow(rownum).createCell(7).setCellValue("单体标称电导:" + formartDouble(bmd.getBinf().getMonSerStd(), 0));
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("测试类型:" + MessageUtils.getMessageSocket(BattTestData.battState(bmd.getSdata().getTestType()), lang));
                sheet1.getRow(rownum).createCell(2).setCellValue("测试时间:" + formartDate(bmd.getSdata().getTestStarttime(), "yyyy-MM-dd HH:mm:ss"));
                //sheet1.getRow(rownum).createCell(3).setCellValue("测试电流:" + bmd.getSdata().getTestCurr() + "A");
                sheet1.getRow(rownum).createCell(3).setCellValue("测试电流:" + testCurr + "A");
                sheet1.getRow(rownum).createCell(4).setCellValue("测试时长:" + formatTestLong(bmd.getSdata().getTestTimelong()));
                sheet1.getRow(rownum).createCell(5).setCellValue("结束时间:" + formartDate(new Date(bmd.getSdata().getTestStarttime().getTime() + bmd.getSdata().getTestTimelong() * 1000), "yyyy-MM-dd HH:mm:ss"));
                sheet1.getRow(rownum).createCell(6).setCellValue("测试容量:" + formartDouble(bmd.getSdata().getTestCap(), 0) + "AH");
                //stationIp存放的终止原因
                sheet1.getRow(rownum).createCell(7).setCellValue("终止原因:" + (bmd.getSdata().getTestType() == 2 ? "" : bmd.getBinf().getStationIP()));
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("报告日期:");
                sheet1.getRow(rownum).createCell(2).setCellValue(formartDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
                rownum += 4;
                int picnum = 0;
                for (int i = 0; i < picName.length; i++) {
                    sheet1.createRow(rownum - 1);
                    sheet1.getRow(rownum - 1).createCell(1).setCellValue(picName[i]);
                    //rownum++;
                    XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 512, 255, (short) 1, rownum, (short) 10, rowNumAdd * (picnum + 1));
                    anchor.setAnchorType(3);
                    patriarch.createPicture(anchor, wb.addPicture(bytes.get(picnum), XSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                    picnum++;
                    rownum += rowNumAdd;
                }
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("最高单体电压");
                sheet1.getRow(rownum).createCell(2).setCellValue("最低单体电压");
                sheet1.getRow(rownum).createCell(3).setCellValue("平均单体电压");
                sheet1.getRow(rownum).createCell(4).setCellValue("落后单体电压值");
                sheet1.getRow(rownum).createCell(5).setCellValue("落后单体数量");
                sheet1.getRow(rownum).createCell(6).setCellValue("落后单体数量百分比");
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue(title.getMax());
                sheet1.getRow(rownum).createCell(2).setCellValue(title.getMin());
                sheet1.getRow(rownum).createCell(3).setCellValue(title.getAvg());
                sheet1.getRow(rownum).createCell(4).setCellValue(title.getClow());
                sheet1.getRow(rownum).createCell(5).setCellValue(title.getLc());
                sheet1.getRow(rownum).createCell(6).setCellValue(title.getLp() + "%");
                rownum += 2;
            } else {
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Battery pack name");
                sheet1.getRow(rownum).createCell(2).setCellValue(bmd.getBinf().getStationName() + "-" + bmd.getBinf().getBattGroupName());
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Battery brand:" + bmd.getBinf().getBattProducer());
                sheet1.getRow(rownum).createCell(2).setCellValue("install date:" + formartDate(bmd.getBinf().getBattInUseDate(), "yyyy-MM-dd"));
                sheet1.getRow(rownum).createCell(3).setCellValue("Number of monomers:" + bmd.getBinf().getMonCount());
                sheet1.getRow(rownum).createCell(4).setCellValue("Individual voltage:" + bmd.getBinf().getMonVolStd() + "V");
                sheet1.getRow(rownum).createCell(5).setCellValue("Individual nominal capacity:" + formartDouble(bmd.getBinf().getMonCapStd(), 0) + "AH");
                sheet1.getRow(rownum).createCell(6).setCellValue("Individual nominal internal resistance:" + formartDouble(bmd.getBinf().getMonResStd(), 3) + "mΩ");
                sheet1.getRow(rownum).createCell(7).setCellValue("Individual nominal conductivity:" + formartDouble(bmd.getBinf().getMonSerStd(), 0));
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Test Type:" + MessageUtils.getMessageSocket(BattTestData.battState(bmd.getSdata().getTestType()), lang));
                sheet1.getRow(rownum).createCell(2).setCellValue("Test Time:" + formartDate(bmd.getSdata().getTestStarttime(), "yyyy-MM-dd HH:mm:ss"));
                sheet1.getRow(rownum).createCell(3).setCellValue("Test Curr:" + testCurr + "A");
                sheet1.getRow(rownum).createCell(4).setCellValue("Test TimeLong:" + formatTestLong(bmd.getSdata().getTestTimelong()));
                sheet1.getRow(rownum).createCell(5).setCellValue("Stop Time:" + formartDate(new Date(bmd.getSdata().getTestStarttime().getTime() + bmd.getSdata().getTestTimelong() * 1000), "yyyy-MM-dd HH:mm:ss"));
                sheet1.getRow(rownum).createCell(6).setCellValue("Test Cap:" + formartDouble(bmd.getSdata().getTestCap(), 0) + "AH");
                //stationIp存放的终止原因
                sheet1.getRow(rownum).createCell(7).setCellValue("Stop Reason:" + (bmd.getSdata().getTestType() == 2 ? "" : bmd.getBinf().getStationIP()));
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Report Date:");
                sheet1.getRow(rownum).createCell(2).setCellValue(formartDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
                rownum += 4;
                int picnum = 0;
                for (int i = 0; i < picName.length; i++) {
                    sheet1.createRow(rownum - 1);
                    sheet1.getRow(rownum - 1).createCell(1).setCellValue(picName[i]);
                    //rownum++;
                    XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 512, 255, (short) 1, rownum, (short) 10, rowNumAdd * (picnum + 1));
                    anchor.setAnchorType(3);
                    patriarch.createPicture(anchor, wb.addPicture(bytes.get(picnum), XSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                    picnum++;
                    rownum += rowNumAdd;
                }
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Maximum individual voltage");
                sheet1.getRow(rownum).createCell(2).setCellValue("Minimum unit voltage");
                sheet1.getRow(rownum).createCell(3).setCellValue("Average individual voltage");
                sheet1.getRow(rownum).createCell(4).setCellValue("Backward unit voltage value");
                sheet1.getRow(rownum).createCell(5).setCellValue("Number of lagging units");
                sheet1.getRow(rownum).createCell(6).setCellValue("Percentage of lagging units");
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue(title.getMax());
                sheet1.getRow(rownum).createCell(2).setCellValue(title.getMin());
                sheet1.getRow(rownum).createCell(3).setCellValue(title.getAvg());
                sheet1.getRow(rownum).createCell(4).setCellValue(title.getClow());
                sheet1.getRow(rownum).createCell(5).setCellValue(title.getLc());
                sheet1.getRow(rownum).createCell(6).setCellValue(title.getLp() + "%");
                rownum += 2;
            }
            sheet1.createRow(rownum);
            for (int i = 0; i < arrTh.length; i++) {
                sheet1.getRow(rownum).createCell(i + 1).setCellValue(arrTh[i]);
            }
            rownum++;
            if (datas != null && datas.length > 0) {
                for (int i = 0; i < datas[0].length; i++) {
                    sheet1.createRow(rownum);
                    for (int j = 0; j < datas.length; j++) {
                        sheet1.getRow(rownum).createCell(j + 1).setCellValue(datas[j][i]);
                    }
                    rownum++;
                }
            }
            //单体数
            int monNum = mon_tmp_list.length;
            //导出的总笔数
            int exportNum = groupinfo.size();
            //单体电压数据表(flag(0:单体电压,1:温度))
            //createMonInfoSheet(wb, mon_vol_list, groupinfo, monNum, exportNum, 0);
            createMonInfoSheet2007(wb, mon_vol_list, groupinfo, monNum, exportNum, 0);
            //单体温度数据表
            //createMonInfoSheet(wb, mon_tmp_list, groupinfo, monNum, exportNum, 1);
            createMonInfoSheet2007(wb, mon_tmp_list, groupinfo, monNum, exportNum, 1);
            //单体电压对比表-单体温度对比表
            //createMonInfoSheet2(bytes, wb, splitTime, timeCompareList, monVolCompareList, monTempCompareList, monVolComparePic, monTempComparePic);
            createMonInfoSheet2_2007(bytes, wb, splitTime, timeCompareList, monVolCompareList, monTempCompareList, monVolComparePic, monTempComparePic);
            if (qth.getCode() == 1) {
                rownum += 2;
                //锅底   驼峰   Qg   Qt   Qh   电池性能
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("锅底");
                sheet1.getRow(rownum).createCell(2).setCellValue("驼峰");
                sheet1.getRow(rownum).createCell(3).setCellValue("Qg");
                sheet1.getRow(rownum).createCell(4).setCellValue("Qt");
                sheet1.getRow(rownum).createCell(5).setCellValue("Qh");
                sheet1.getRow(rownum).createCell(6).setCellValue("电池性能");
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue(qth.getLowTime());
                sheet1.getRow(rownum).createCell(2).setCellValue(qth.getHighTime());
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue(qth.getLow() + "V");
                sheet1.getRow(rownum).createCell(2).setCellValue(qth.getHigh() + "V");
                sheet1.getRow(rownum).createCell(3).setCellValue(qth.getQg() + "%");
                sheet1.getRow(rownum).createCell(4).setCellValue(qth.getQt() + "%");
                sheet1.getRow(rownum).createCell(5).setCellValue(qth.getQh() + "%");
                sheet1.getRow(rownum).createCell(6).setCellValue(qth.getTitle());
            }
            //取出电池组信息构建excel文件的名称
            String excelName = "";
            Battinf binf = binfservice.getdevIdByBattGroupId(bmd.getBinf().getBattGroupId());
            Long dev_id = binf.getFBSDeviceId();//获取设备id判断文件名
            if (dev_id != null) {
                if (dev_id / 100000 == DeviceTypeDTO.DEVICE8059 || dev_id / 100000 == DeviceTypeDTO.DEVICE8060) {
                    //StationName9放文本信息用于8059、8060设备加文件名信息
                    excelName = binfservice.serchExcelNameA059(bmd.getBinf().getBattGroupId(), bmd.getBinf().getStationName9());
                } else {
                    excelName = binfservice.serchExcelName(bmd.getBinf().getBattGroupId());
                    //excel文件名
                    String testTime = new SimpleDateFormat("yyyy-MM-dd").format(bmd.getSdata().getTestStarttime());
                    excelName = excelName + "-" + testTime;
                }
            } else {
                excelName = binfservice.serchExcelName(bmd.getBinf().getBattGroupId());
                //excel文件名
                String testTime = new SimpleDateFormat("yyyy-MM-dd").format(bmd.getSdata().getTestStarttime());
                excelName = excelName + "-" + testTime;
            }
            String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
            excelName = excelName.replaceAll(regEx, "");
            // 转码防止乱码
            resp.addHeader("Content-Disposition", "attachment;filename="
                    + new String(excelName.getBytes("UTF-8"), "ISO8859-1")
                    + ".xlsx");
            OutputStream out = resp.getOutputStream();
            wb.write(out);
            out.close();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    //生成历史数据中的报表
    private void createExcel2007(List<byte[]> bytes,Title title,Qth qth,String[][] datas,BattMaintDealarm bmd,String[][] mon_vol_list ,String[][] mon_tmp_list,List<BatttestdataId> groupinfo,String splitTime,String[] timeCompareList,String[][] monVolCompareList,String[][] monTempCompareList,String monVolComparePic, String monTempComparePic,HttpServletResponse resp,
                             HttpServletRequest req) {
        //根据当前的语言环境设置不同的日志记录
        String lang = ActionUtil.getLang();
        String[] arrTh = null;
        String[] picName = null;
        if (lang.contains("zh")) {
            arrTh = new String[]{
                    "单体编号", "起始单体电压(V)", "截止单体电压(V)", "实际容量(AH)", "剩余容量(AH)", "实际容量百分比(%)", "单体内阻(mΩ)", "起始单体温度(℃)", "终止单体温度(℃)"
            };
            picName = new String[]{
                    "组端电压曲线", "电池电流曲线", "终止单体电压", "终止单体温度", "单体内阻", "单体均衡电流", "单体电压", "单体实际容量", "单体剩余容量", "单体实际容量百分比", "单体电压曲线", "单体温度曲线", "单体剩余容量曲线"
            };
        } else {
            arrTh = new String[]{
                    "Unit number", "Starting unit voltage(V)", "Cutoff cell voltage(V)", "Actual Capacity(AH)", "remaining capacity(AH)", "Actual capacity percentage(%)", "Individual internal resistance(mΩ)", "Starting monomer temperature(℃)", "Termination monomer temperature(℃)"
            };
            picName = new String[]{
                    "Group terminal voltage curve", "Battery current curve", "Termination unit voltage", "Termination monomer temperature", "Individual internal resistance", "Individual balanced current", "Individual voltage", "Actual capacity of individual units", "Remaining capacity of single unit", "Actual capacity percentage of individual units", "Individual voltage curve", "Individual temperature curve", "Individual residual capacity curve"
            };
        }
        try {
            // 创建一个工作薄
            XSSFWorkbook wb = new XSSFWorkbook();
            XSSFSheet sheet1 = null;
            if (lang.contains("zh")) {
                sheet1 = wb.createSheet("数据总表");
            } else {
                sheet1 = wb.createSheet("Data Summary Table");
            }
            sheet1.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
            sheet1.setDefaultRowHeight((short) (1 * 256));
            ; //设置默认行高,表示2个字符的高度
            // HSSFRow row = sheet1.createRow(2);
            XSSFDrawing patriarch = sheet1.createDrawingPatriarch();
            int rownum = 1;
            //钱煜要求电流计算出来(测试容量*3600/测试时长)
            String testCurr = bmd.getSdata().getTestCurr().toString();
            if (bmd.getSdata().getTestTimelong() != 0) {
                float curr = (bmd.getSdata().getTestCap() * 3600) / bmd.getSdata().getTestTimelong();
                testCurr = new Formatter().format("%.1f", curr).toString();
            }
            if (lang.contains("zh")) {
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("电池组名称");
                sheet1.getRow(rownum).createCell(2).setCellValue(bmd.getBinf().getStationName() + "-" + bmd.getBinf().getBattGroupName());
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("电池品牌:" + bmd.getBinf().getBattProducer());
                sheet1.getRow(rownum).createCell(2).setCellValue("安装日期:" + formartDate(bmd.getBinf().getBattInUseDate(), "yyyy-MM-dd"));
                sheet1.getRow(rownum).createCell(3).setCellValue("单体数量:" + bmd.getBinf().getMonCount());
                sheet1.getRow(rownum).createCell(4).setCellValue("单体电压:" + bmd.getBinf().getMonVolStd() + "V");
                sheet1.getRow(rownum).createCell(5).setCellValue("单体标称容量:" + formartDouble(bmd.getBinf().getMonCapStd(), 0) + "AH");
                sheet1.getRow(rownum).createCell(6).setCellValue("单体标称内阻:" + formartDouble(bmd.getBinf().getMonResStd(), 3) + "mΩ");
                sheet1.getRow(rownum).createCell(7).setCellValue("单体标称电导:" + formartDouble(bmd.getBinf().getMonSerStd(), 0));
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("测试类型:" + MessageUtils.getMessageSocket(BattTestData.battState(bmd.getSdata().getTestType()), lang));
                sheet1.getRow(rownum).createCell(2).setCellValue("测试时间:" + formartDate(bmd.getSdata().getTestStarttime(), "yyyy-MM-dd HH:mm:ss"));
                //sheet1.getRow(rownum).createCell(3).setCellValue("测试电流:" + bmd.getSdata().getTestCurr() + "A");
                sheet1.getRow(rownum).createCell(3).setCellValue("测试电流:" + testCurr + "A");
                sheet1.getRow(rownum).createCell(4).setCellValue("测试时长:" + formatTestLong(bmd.getSdata().getTestTimelong()));
                sheet1.getRow(rownum).createCell(5).setCellValue("结束时间:" + formartDate(new Date(bmd.getSdata().getTestStarttime().getTime() + bmd.getSdata().getTestTimelong() * 1000), "yyyy-MM-dd HH:mm:ss"));
                sheet1.getRow(rownum).createCell(6).setCellValue("测试容量:" + formartDouble(bmd.getSdata().getTestCap(), 0) + "AH");
                //stationIp存放的终止原因
                sheet1.getRow(rownum).createCell(7).setCellValue("终止原因:" + (bmd.getSdata().getTestType() == 2 ? "" : bmd.getBinf().getStationIP()));
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("报告日期:");
                sheet1.getRow(rownum).createCell(2).setCellValue(formartDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
                rownum += 4;
                int picnum = 0;
                for (int i = 0; i < picName.length; i++) {
                    sheet1.createRow(rownum - 1);
                    sheet1.getRow(rownum - 1).createCell(1).setCellValue(picName[i]);
                    //rownum++;
                    XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 512, 255, (short) 1, rownum, (short) 10, rowNumAdd * (picnum + 1));
                    anchor.setAnchorType(3);
                    patriarch.createPicture(anchor, wb.addPicture(bytes.get(picnum), XSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                    picnum++;
                    rownum += rowNumAdd;
                }
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("最高单体电压");
                sheet1.getRow(rownum).createCell(2).setCellValue("最低单体电压");
                sheet1.getRow(rownum).createCell(3).setCellValue("平均单体电压");
                sheet1.getRow(rownum).createCell(4).setCellValue("落后单体电压值");
                sheet1.getRow(rownum).createCell(5).setCellValue("落后单体数量");
                sheet1.getRow(rownum).createCell(6).setCellValue("落后单体数量百分比");
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue(title.getMax());
                sheet1.getRow(rownum).createCell(2).setCellValue(title.getMin());
                sheet1.getRow(rownum).createCell(3).setCellValue(title.getAvg());
                sheet1.getRow(rownum).createCell(4).setCellValue(title.getClow());
                sheet1.getRow(rownum).createCell(5).setCellValue(title.getLc());
                sheet1.getRow(rownum).createCell(6).setCellValue(title.getLp() + "%");
                rownum += 2;
            } else {
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Battery pack name");
                sheet1.getRow(rownum).createCell(2).setCellValue(bmd.getBinf().getStationName() + "-" + bmd.getBinf().getBattGroupName());
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Battery brand:" + bmd.getBinf().getBattProducer());
                sheet1.getRow(rownum).createCell(2).setCellValue("install date:" + formartDate(bmd.getBinf().getBattInUseDate(), "yyyy-MM-dd"));
                sheet1.getRow(rownum).createCell(3).setCellValue("Number of monomers:" + bmd.getBinf().getMonCount());
                sheet1.getRow(rownum).createCell(4).setCellValue("Individual voltage:" + bmd.getBinf().getMonVolStd() + "V");
                sheet1.getRow(rownum).createCell(5).setCellValue("Individual nominal capacity:" + formartDouble(bmd.getBinf().getMonCapStd(), 0) + "AH");
                sheet1.getRow(rownum).createCell(6).setCellValue("Individual nominal internal resistance:" + formartDouble(bmd.getBinf().getMonResStd(), 3) + "mΩ");
                sheet1.getRow(rownum).createCell(7).setCellValue("Individual nominal conductivity:" + formartDouble(bmd.getBinf().getMonSerStd(), 0));
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Test Type:" + MessageUtils.getMessageSocket(BattTestData.battState(bmd.getSdata().getTestType()), lang));
                sheet1.getRow(rownum).createCell(2).setCellValue("Test Time:" + formartDate(bmd.getSdata().getTestStarttime(), "yyyy-MM-dd HH:mm:ss"));
                sheet1.getRow(rownum).createCell(3).setCellValue("Test Curr:" + testCurr + "A");
                sheet1.getRow(rownum).createCell(4).setCellValue("Test TimeLong:" + formatTestLong(bmd.getSdata().getTestTimelong()));
                sheet1.getRow(rownum).createCell(5).setCellValue("Stop Time:" + formartDate(new Date(bmd.getSdata().getTestStarttime().getTime() + bmd.getSdata().getTestTimelong() * 1000), "yyyy-MM-dd HH:mm:ss"));
                sheet1.getRow(rownum).createCell(6).setCellValue("Test Cap:" + formartDouble(bmd.getSdata().getTestCap(), 0) + "AH");
                //stationIp存放的终止原因
                sheet1.getRow(rownum).createCell(7).setCellValue("Stop Reason:" + (bmd.getSdata().getTestType() == 2 ? "" : bmd.getBinf().getStationIP()));
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Report Date:");
                sheet1.getRow(rownum).createCell(2).setCellValue(formartDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
                rownum += 4;
                int picnum = 0;
                for (int i = 0; i < picName.length; i++) {
                    sheet1.createRow(rownum - 1);
                    sheet1.getRow(rownum - 1).createCell(1).setCellValue(picName[i]);
                    //rownum++;
                    XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 512, 255, (short) 1, rownum, (short) 10, rowNumAdd * (picnum + 1));
                    anchor.setAnchorType(3);
                    patriarch.createPicture(anchor, wb.addPicture(bytes.get(picnum), XSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
                    picnum++;
                    rownum += rowNumAdd;
                }
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("Maximum individual voltage");
                sheet1.getRow(rownum).createCell(2).setCellValue("Minimum unit voltage");
                sheet1.getRow(rownum).createCell(3).setCellValue("Average individual voltage");
                sheet1.getRow(rownum).createCell(4).setCellValue("Backward unit voltage value");
                sheet1.getRow(rownum).createCell(5).setCellValue("Number of lagging units");
                sheet1.getRow(rownum).createCell(6).setCellValue("Percentage of lagging units");
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue(title.getMax());
                sheet1.getRow(rownum).createCell(2).setCellValue(title.getMin());
                sheet1.getRow(rownum).createCell(3).setCellValue(title.getAvg());
                sheet1.getRow(rownum).createCell(4).setCellValue(title.getClow());
                sheet1.getRow(rownum).createCell(5).setCellValue(title.getLc());
                sheet1.getRow(rownum).createCell(6).setCellValue(title.getLp() + "%");
                rownum += 2;
            }
            sheet1.createRow(rownum);
            for (int i = 0; i < arrTh.length; i++) {
                sheet1.getRow(rownum).createCell(i + 1).setCellValue(arrTh[i]);
            }
            rownum++;
            if (datas != null && datas.length > 0) {
                for (int i = 0; i < datas[0].length; i++) {
                    sheet1.createRow(rownum);
                    for (int j = 0; j < datas.length; j++) {
                        sheet1.getRow(rownum).createCell(j + 1).setCellValue(datas[j][i]);
                    }
                    rownum++;
                }
            }
            //单体数
            int monNum = mon_tmp_list.length;
            //导出的总笔数
            int exportNum = groupinfo.size();
            //单体电压数据表(flag(0:单体电压,1:温度))
            //createMonInfoSheet(wb, mon_vol_list, groupinfo, monNum, exportNum, 0);
            createMonInfoSheet2007(wb, mon_vol_list, groupinfo, monNum, exportNum, 0);
            //单体温度数据表
            //createMonInfoSheet(wb, mon_tmp_list, groupinfo, monNum, exportNum, 1);
            createMonInfoSheet2007(wb, mon_tmp_list, groupinfo, monNum, exportNum, 1);
            //单体电压对比表-单体温度对比表
            //createMonInfoSheet2(bytes, wb, splitTime, timeCompareList, monVolCompareList, monTempCompareList, monVolComparePic, monTempComparePic);
            createMonInfoSheet2_2007(bytes, wb, splitTime, timeCompareList, monVolCompareList, monTempCompareList, monVolComparePic, monTempComparePic);
            if (qth.getCode() == 1) {
                rownum += 2;
                //锅底   驼峰   Qg   Qt   Qh   电池性能
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue("锅底");
                sheet1.getRow(rownum).createCell(2).setCellValue("驼峰");
                sheet1.getRow(rownum).createCell(3).setCellValue("Qg");
                sheet1.getRow(rownum).createCell(4).setCellValue("Qt");
                sheet1.getRow(rownum).createCell(5).setCellValue("Qh");
                sheet1.getRow(rownum).createCell(6).setCellValue("电池性能");
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue(qth.getLowTime());
                sheet1.getRow(rownum).createCell(2).setCellValue(qth.getHighTime());
                rownum++;
                sheet1.createRow(rownum);
                sheet1.getRow(rownum).createCell(1).setCellValue(qth.getLow() + "V");
                sheet1.getRow(rownum).createCell(2).setCellValue(qth.getHigh() + "V");
                sheet1.getRow(rownum).createCell(3).setCellValue(qth.getQg() + "%");
                sheet1.getRow(rownum).createCell(4).setCellValue(qth.getQt() + "%");
                sheet1.getRow(rownum).createCell(5).setCellValue(qth.getQh() + "%");
                sheet1.getRow(rownum).createCell(6).setCellValue(qth.getTitle());
            }
            //取出电池组信息构建excel文件的名称
            String excelName = "";
            Battinf binf = binfservice.getdevIdByBattGroupId(bmd.getBinf().getBattGroupId());
            Long dev_id = binf.getFBSDeviceId();//获取设备id判断文件名
            if (dev_id != null) {
                if (dev_id / 100000 == DeviceTypeDTO.DEVICE8059 || dev_id / 100000 == DeviceTypeDTO.DEVICE8060) {
                    //StationName9放文本信息用于8059、8060设备加文件名信息
                    excelName = binfservice.serchExcelNameA059(bmd.getBinf().getBattGroupId(), bmd.getBinf().getStationName9());
                } else {
                    excelName = binfservice.serchExcelName(bmd.getBinf().getBattGroupId());
                    //excel文件名
                    String testTime = new SimpleDateFormat("yyyy-MM-dd").format(bmd.getSdata().getTestStarttime());
                    excelName = excelName + "-" + testTime;
                }
            } else {
                excelName = binfservice.serchExcelName(bmd.getBinf().getBattGroupId());
                //excel文件名
                String testTime = new SimpleDateFormat("yyyy-MM-dd").format(bmd.getSdata().getTestStarttime());
                excelName = excelName + "-" + testTime;
            }
            String regEx = "[\n`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。, 、?]";
            excelName = excelName.replaceAll(regEx, "");
            // 转码防止乱码
            resp.addHeader("Content-Disposition", "attachment;filename="
                    + new String(excelName.getBytes("UTF-8"), "ISO8859-1")
                    + ".xlsx");
            OutputStream out = resp.getOutputStream();
            wb.write(out);
            out.close();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    ///生成Excel报表
    private void createExcel(HSSFWorkbook wb,HttpServletResponse resp){
        try {
@@ -1496,10 +2356,13 @@
            // 创建一个工作薄
            HSSFWorkbook wb = new HSSFWorkbook();
            HSSFSheet sheet1 = wb.createSheet("new sheet");
            sheet1.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
            sheet1.setDefaultRowHeight((short) (1 * 256));
            ; //设置默认行高,表示2个字符的高度
            // HSSFRow row = sheet1.createRow(2);
            HSSFPatriarch patriarch = sheet1.createDrawingPatriarch();
            for (int i = 0; i < bytes.size(); i++) {
                HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 1, 25 * i + 1, (short) 10, 25 * (i + 1));
                HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255, (short) 1, 25 * i + 1, (short) 10, 25 * (i + 1));
                anchor.setAnchorType(3);
                // 插入图片
                patriarch.createPicture(
@@ -1547,17 +2410,19 @@
                String[] url = ePriceDistributeMapPic.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        //当前日期
        String nowFormat = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        String excelName = "电价统计分析-"+nowFormat;
        String excelName = "电价统计分析-" + nowFormat;
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("Sheet1");
        sheet.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        //图片元素
        HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
@@ -1666,87 +2531,262 @@
    }
    //保留指定的位数
    public static double formartDouble(double b , int places){
        return new BigDecimal(b).setScale(places,   BigDecimal.ROUND_HALF_UP).doubleValue();
    public static double formartDouble(double b, int places) {
        return new BigDecimal(b).setScale(places, BigDecimal.ROUND_HALF_UP).doubleValue();
    }
    public void createMonInfoSheet(HSSFWorkbook wb,String[][] mon_vol_list ,String[][] mon_tmp_list,List<BatttestdataId> groupinfo){
        HSSFSheet sheet = wb.createSheet("单体数据表");
        if(mon_vol_list != null && mon_tmp_list != null && groupinfo != null){
            int mon_count = mon_tmp_list.length;      //总单体数量
            int total_col = mon_vol_list.length;      //总记录条数
            List<String> tabTh = new ArrayList<String>(){{
                this.add("时间(HH:MM:SS)");this.add("在线电压(V)");this.add("组端电压(V)");this.add("电流(A)");this.add("测试容量(AH)");
            }};
            for(int i=1;i<=mon_count;i++){
                tabTh.add("单体电压"+i+"(V)");
    public void createMonInfoSheet(HSSFWorkbook wb, String[][] datalist, List<BatttestdataId> groupinfo, int monNum, int exportNum, int flag) {
        String lang = ActionUtil.getLang();
        HSSFSheet sheet = null;
        if (lang.contains("zh")) {
            if (flag == 0) {
                sheet = wb.createSheet("单体电压表");
            } else {
                sheet = wb.createSheet("单体温度表");
            }
            for(int i=0;i<=mon_count;i++){
                if(i == 0){
        } else {
            if (flag == 0) {
                sheet = wb.createSheet("Voltage Data Table");
            } else {
                sheet = wb.createSheet("Temperature Data Table");
            }
        }
        sheet.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        if (datalist != null && groupinfo != null) {
           /* int mon_count = mon_tmp_list.length;        //总单体数量
            int total_col = mon_vol_list.length;        //总记录条数*/
            List<String> tabTh = null;
            if (lang.contains("zh")) {
                tabTh = new ArrayList<String>() {{
                    this.add("时间(HH:MM:SS)");
                    this.add("在线电压(V)");
                    this.add("组端电压(V)");
                    this.add("电流(A)");
                    this.add("测试容量(AH)");
                }};
            } else {
                tabTh = new ArrayList<String>() {{
                    this.add("Time(HH:MM:SS)");
                    this.add("On-line Voltage(V)");
                    this.add("Group terminal voltage(V)");
                    this.add("Current(A)");
                    this.add("Test capacity(AH)");
                }};
            }
            for (int i = 1; i <= monNum; i++) {
                if (lang.contains("zh")) {
                    if (flag == 0) {
                        tabTh.add("单体电压" + i + "(V)");
                    } else {
                        tabTh.add("单体温度" + i + "(℃)");
                    }
                } else {
                    if (flag == 0) {
                        tabTh.add("Individual voltage" + i + "(V)");
                    } else {
                        tabTh.add("Monomer temperature" + i + "(V)");
                    }
                }
            }
            /*for (int i = 0; i <= monNum; i++) {
                if (i == 0) {
                    tabTh.add("");
                    continue;
                }
                tabTh.add("单体温度"+i+"(℃)");
            }
                if (lang.contains("zh")) {
                    tabTh.add("单体温度" + i + "(℃)");
                } else {
                    tabTh.add("Monomer temperature" + i + "(V)");
                }
            String[][] datas = new String[total_col][tabTh.size()];
            }*/
            String[][] datas = new String[exportNum][tabTh.size()];
            //System.out.println("datas.length"+datas.length+"\t datas[0].length:"+datas[0].length+"==mon_vol_list.length:"+mon_vol_list.length+"\tmon_vol_list[0].length"+mon_vol_list[0].length+"\tmon_tmp:"+mon_tmp_list[0].length);
            for(int j=0;j < datas.length;j++){
            for (int j = 0; j < datas.length; j++) {
                int currnum = 0;
                datas[j][currnum++] = formatTestLong(groupinfo.get(j).getTestTimelong());
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getOnlineVol(),2)+"";
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getGroupVol(),2)+"";
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getTestCurr(),1)+"";
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getTestCap(),1)+"";
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getOnlineVol(), 2) + "";
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getGroupVol(), 2) + "";
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getTestCurr(), 1) + "";
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getTestCap(), 1) + "";
                for(int i=0;i<mon_vol_list[j].length;i++){
                    datas[j][currnum++] = mon_vol_list[j][i];
                if (flag == 0) {
                    for (int i = 0; i < monNum; i++) {
                        datas[j][currnum++] = datalist[j][i];
                    }
                } else {
                    for (int i = 0; i < monNum; i++) {
                        datas[j][currnum++] = datalist[i][j];
                    }
                }
                datas[j][currnum++] = "";
                for(int i=0;i<mon_tmp_list.length;i++){
                    datas[j][currnum++] = mon_tmp_list[i][j];
                }
                //datas[j][currnum++] = "";
            }
            //System.out.println("mon_vol_list"+mon_vol_list.length+"\t mon_tmp_list:"+mon_tmp_list.length);
            int maxcol = 254;         //设置最大列数
            int maxcol = 254;            //设置最大列数
            int countReLine = (int) Math.ceil((double)total_col/maxcol);
            int totalrow = countReLine *(tabTh.size()+1);               //excel总行数
            for(int i=0;i<totalrow;i++){
            int countReLine = (int) Math.ceil((double) exportNum / maxcol);
            int totalrow = countReLine * (tabTh.size() + 1);                    //excel总行数
            for (int i = 0; i < totalrow; i++) {
                sheet.createRow(i);
            }
            //System.out.println("countReLine:"+countReLine);
            int currRow = 0;         //当前行
            int arr_index = 0;         //当前列
            for(int i=0;i<countReLine;i++){
                for(int col = 0;col <= maxcol && col<=datas.length && arr_index<datas.length;col++){
                    if(col == 0){
                        for(int k=0;k<tabTh.size();k++){
                            sheet.getRow(k+currRow).createCell(col).setCellValue(tabTh.get(k));
            int currRow = 0;            //当前行
            int arr_index = 0;            //当前列
            for (int i = 0; i < countReLine; i++) {
                for (int col = 0; col <= maxcol && col <= datas.length && arr_index < datas.length; col++) {
                    if (col == 0) {
                        for (int k = 0; k < tabTh.size(); k++) {
                            sheet.getRow(k + currRow).createCell(col).setCellValue(tabTh.get(k));
                        }
                    }else{
                        for(int k = 0;k<datas[arr_index].length;k++){
                            sheet.getRow(k+currRow).createCell(col).setCellValue(datas[arr_index][k]);
                    } else {
                        for (int k = 0; k < datas[arr_index].length; k++) {
                            sheet.getRow(k + currRow).createCell(col).setCellValue(datas[arr_index][k]);
                        }
                        arr_index++;
                    }
                }
                currRow += tabTh.size()+1;
                currRow += tabTh.size() + 1;
            }
            //System.out.println("data.length"+datas.length+"\t datas[0].length:"+datas[0].length);
        }
    }
    private void createMonInfoSheet2(List<byte[]> bytes,HSSFWorkbook wb,String splitTime, String[] timeCompareList,String[][] monVolCompareList, String[][] monTempCompareList, String monVolComparePic, String monTempComparePic) {
    public void createMonInfoSheet2007(XSSFWorkbook wb, String[][] datalist, List<BatttestdataId> groupinfo, int monNum, int exportNum, int flag) {
        String lang = ActionUtil.getLang();
        XSSFSheet sheet = null;
        if (lang.contains("zh")) {
            if (flag == 0) {
                sheet = wb.createSheet("单体电压表");
            } else {
                sheet = wb.createSheet("单体温度表");
            }
        } else {
            if (flag == 0) {
                sheet = wb.createSheet("Voltage Data Table");
            } else {
                sheet = wb.createSheet("Temperature Data Table");
            }
        }
        sheet.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        if (datalist != null && groupinfo != null) {
           /* int mon_count = mon_tmp_list.length;        //总单体数量
            int total_col = mon_vol_list.length;        //总记录条数*/
            List<String> tabTh = null;
            if (lang.contains("zh")) {
                tabTh = new ArrayList<String>() {{
                    this.add("时间(HH:MM:SS)");
                    this.add("在线电压(V)");
                    this.add("组端电压(V)");
                    this.add("电流(A)");
                    this.add("测试容量(AH)");
                }};
            } else {
                tabTh = new ArrayList<String>() {{
                    this.add("Time(HH:MM:SS)");
                    this.add("On-line Voltage(V)");
                    this.add("Group terminal voltage(V)");
                    this.add("Current(A)");
                    this.add("Test capacity(AH)");
                }};
            }
            for (int i = 1; i <= monNum; i++) {
                if (lang.contains("zh")) {
                    if (flag == 0) {
                        tabTh.add("单体电压" + i + "(V)");
                    } else {
                        tabTh.add("单体温度" + i + "(℃)");
                    }
                } else {
                    if (flag == 0) {
                        tabTh.add("Individual voltage" + i + "(V)");
                    } else {
                        tabTh.add("Monomer temperature" + i + "(V)");
                    }
                }
            }
            /*for (int i = 0; i <= monNum; i++) {
                if (i == 0) {
                    tabTh.add("");
                    continue;
                }
                if (lang.contains("zh")) {
                    tabTh.add("单体温度" + i + "(℃)");
                } else {
                    tabTh.add("Monomer temperature" + i + "(V)");
                }
            }*/
            String[][] datas = new String[exportNum][tabTh.size()];
            //System.out.println("datas.length"+datas.length+"\t datas[0].length:"+datas[0].length+"==mon_vol_list.length:"+mon_vol_list.length+"\tmon_vol_list[0].length"+mon_vol_list[0].length+"\tmon_tmp:"+mon_tmp_list[0].length);
            for (int j = 0; j < datas.length; j++) {
                int currnum = 0;
                datas[j][currnum++] = formatTestLong(groupinfo.get(j).getTestTimelong());
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getOnlineVol(), 2) + "";
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getGroupVol(), 2) + "";
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getTestCurr(), 1) + "";
                datas[j][currnum++] = formartDouble(groupinfo.get(j).getTestCap(), 1) + "";
                if (flag == 0) {
                    for (int i = 0; i < monNum; i++) {
                        datas[j][currnum++] = datalist[j][i];
                    }
                } else {
                    for (int i = 0; i < monNum; i++) {
                        datas[j][currnum++] = datalist[i][j];
                    }
                }
                //datas[j][currnum++] = "";
            }
            //System.out.println("mon_vol_list"+mon_vol_list.length+"\t mon_tmp_list:"+mon_tmp_list.length);
            int maxcol = 254;            //设置最大列数
            int countReLine = (int) Math.ceil((double) exportNum / maxcol);
            int totalrow = countReLine * (tabTh.size() + 1);                    //excel总行数
            for (int i = 0; i < totalrow; i++) {
                sheet.createRow(i);
            }
            //System.out.println("countReLine:"+countReLine);
            int currRow = 0;            //当前行
            int arr_index = 0;            //当前列
            for (int i = 0; i < countReLine; i++) {
                for (int col = 0; col <= maxcol && col <= datas.length && arr_index < datas.length; col++) {
                    if (col == 0) {
                        for (int k = 0; k < tabTh.size(); k++) {
                            sheet.getRow(k + currRow).createCell(col).setCellValue(tabTh.get(k));
                        }
                    } else {
                        for (int k = 0; k < datas[arr_index].length; k++) {
                            sheet.getRow(k + currRow).createCell(col).setCellValue(datas[arr_index][k]);
                        }
                        arr_index++;
                    }
                }
                currRow += tabTh.size() + 1;
            }
        }
    }
    private void createMonInfoSheet2(List<byte[]> bytes,HSSFWorkbook wb,String splitTime, String[] timeCompareList,String[][] monVolCompareList, String[][] monTempCompareList, String monVolComparePic, String monTempComparePic) {
        String lang = ActionUtil.getLang();
        bytes=new ArrayList<byte[]>();
        //处理图片
        try {
@@ -1758,11 +2798,18 @@
                String[] url = monTempComparePic.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        HSSFSheet sheet = wb.createSheet("单体电压对比表");
        HSSFSheet sheet = null;
        if (lang.contains("zh")) {
            sheet = wb.createSheet("单体电压对比表");
        } else {
            sheet = wb.createSheet("Single unit voltage comparison table");
        }
        sheet.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        //图片元素
        HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
@@ -1776,45 +2823,70 @@
        int rowNum = 0;
        HSSFRow firstRow = sheet.createRow(rowNum++);
        HSSFCell cell = firstRow.createCell(0);
        cell.setCellValue("单体电压对比图");
        if (lang.contains("zh")) {
            cell.setCellValue("单体电压对比图");
        } else {
            cell.setCellValue("Comparison diagram of individual voltage");
        }
        cell.setCellStyle(cellStyle);
        //插入对比图片
        int picNum = 0;
        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 0, rowNum, (short) 10, rowNum+25);
        HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255, (short) 0, rowNum, (short) 10, rowNum + 25);
        anchor.setAnchorType(3);
        patriarch.createPicture(anchor,wb.addPicture(bytes.get(picNum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
        picNum ++;rowNum+=25;
        patriarch.createPicture(anchor, wb.addPicture(bytes.get(picNum), HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
        picNum++;
        rowNum += 25;
        //插入数据
        HSSFRow firstDataRow = sheet.createRow(rowNum++);
        HSSFCell dataCell = firstDataRow.createCell(0);
        dataCell.setCellValue("基准时间:"+splitTime+"分钟");
        if (lang.contains("zh")) {
            dataCell.setCellValue("基准时间:" + splitTime + "分钟");
        } else {
            dataCell.setCellValue("reference time:" + splitTime + "minute");
        }
        dataCell.setCellStyle(cellStyle);
        //数据行抬头
        HSSFRow rowDataTitle = sheet.createRow(rowNum++);
        for (int i = 0; i < monVolCompareList.length+1; i++) {
        for (int i = 0; i < monVolCompareList.length + 1; i++) {
            HSSFCell cellTemp = rowDataTitle.createCell(i);
            if(i==0){
                cellTemp.setCellValue("时间(HH:MM:SS)");
            }else{
                cellTemp.setCellValue("单体对比电压"+(i)+"(V)");
            if (i == 0) {
                if (lang.contains("zh")) {
                    cellTemp.setCellValue("时间(HH:MM:SS)");
                } else {
                    cellTemp.setCellValue("Time(HH:MM:SS)");
                }
            } else {
                if (lang.contains("zh")) {
                    cellTemp.setCellValue("单体对比电压" + (i) + "(V)");
                } else {
                    cellTemp.setCellValue("Single body comparison voltage" + (i) + "(V)");
                }
            }
            cellTemp.setCellStyle(cellStyle);
        }
        //数据行[1,1,1],[2,2,2]
        for (int i = 0; i < monVolCompareList[0].length; i++) {
            HSSFRow row = sheet.createRow(rowNum++);
            for (int j = 0; j < monVolCompareList.length+1; j++) {
            for (int j = 0; j < monVolCompareList.length + 1; j++) {
                row.createCell(0).setCellValue(timeCompareList[i]);
                if(j!=0){
                    row.createCell(j).setCellValue(monVolCompareList[j-1][i]);
                if (j != 0) {
                    row.createCell(j).setCellValue(monVolCompareList[j - 1][i]);
                }
            }
        }
        //第二个sheet
        HSSFSheet sheet1 = wb.createSheet("单体温度对比表");
        HSSFSheet sheet1 = null;
        if (lang.contains("zh")) {
            sheet1 = wb.createSheet("单体温度对比表");
        } else {
            sheet1 = wb.createSheet("Single body temperature comparison table");
        }
        sheet1.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet1.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        //图片元素
        HSSFPatriarch patriarch1 = sheet1.createDrawingPatriarch();
@@ -1828,38 +2900,279 @@
        int rowNum1 = 0;
        HSSFRow firstRow1 = sheet1.createRow(rowNum1++);
        HSSFCell cell1 = firstRow1.createCell(0);
        cell1.setCellValue("单体温度对比图");
        if (lang.contains("zh")) {
            cell1.setCellValue("单体温度对比图");
        } else {
            cell1.setCellValue("Comparison diagram of individual temperature");
        }
        cell1.setCellStyle(cellStyle);
        //插入对比图片
        HSSFClientAnchor anchor1 = new HSSFClientAnchor(0, 0, 512, 255,(short) 0, rowNum1, (short) 10, rowNum1+25);
        HSSFClientAnchor anchor1 = new HSSFClientAnchor(0, 0, 512, 255, (short) 0, rowNum1, (short) 10, rowNum1 + 25);
        anchor1.setAnchorType(3);
        patriarch1.createPicture(anchor1,wb.addPicture(bytes.get(picNum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
        rowNum1+=25;
        patriarch1.createPicture(anchor1, wb.addPicture(bytes.get(picNum), HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
        rowNum1 += 25;
        //插入数据
        HSSFRow firstDataRow1 = sheet1.createRow(rowNum1++);
        HSSFCell dataCell1 = firstDataRow1.createCell(0);
        dataCell1.setCellValue("基准时间:"+splitTime+"分钟");
        if (lang.contains("zh")) {
            dataCell1.setCellValue("基准时间:" + splitTime + "分钟");
        } else {
            dataCell1.setCellValue("reference time:" + splitTime + "minute");
        }
        dataCell1.setCellStyle(cellStyle1);
        //数据行抬头
        HSSFRow rowDataTitle1 = sheet1.createRow(rowNum1++);
        for (int i = 0; i < monTempCompareList.length+1; i++) {
        for (int i = 0; i < monTempCompareList.length + 1; i++) {
            HSSFCell cellTemp = rowDataTitle1.createCell(i);
            if(i==0){
                cellTemp.setCellValue("时间(HH:MM:SS)");
            }else{
                cellTemp.setCellValue("单体对比温度"+(i)+"(℃)");
            if (i == 0) {
                if (lang.contains("zh")) {
                    cellTemp.setCellValue("时间(HH:MM:SS)");
                } else {
                    cellTemp.setCellValue("Time(HH:MM:SS)");
                }
            } else {
                if (lang.contains("zh")) {
                    cellTemp.setCellValue("单体对比温度" + (i) + "(℃)");
                } else {
                    cellTemp.setCellValue("Single body comparison temperature" + (i) + "(℃)");
                }
            }
            cellTemp.setCellStyle(cellStyle1);
        }
        //数据行[1,1,1],[2,2,2]
        for (int i = 0; i < monTempCompareList[0].length; i++) {
            HSSFRow row = sheet1.createRow(rowNum1++);
            for (int j = 0; j < monTempCompareList.length+1; j++) {
            for (int j = 0; j < monTempCompareList.length + 1; j++) {
                row.createCell(0).setCellValue(timeCompareList[i]);
                if(j!=0){
                    row.createCell(j).setCellValue(monTempCompareList[j-1][i]);
                if (j != 0) {
                    row.createCell(j).setCellValue(monTempCompareList[j - 1][i]);
                }
            }
        }
      /*//基准时间
      HSSFRow row = sheet.createRow(rowNum++);
      HSSFCell cell = row.createCell(0);
      cell.setCellValue("基准时间:"+splitTime+"分钟");
      cell.setCellStyle(cellStyle);
      //时间行
      HSSFRow rowTitle = sheet.createRow(rowNum++);
      HSSFCell cellTitle = rowTitle.createCell(0);
      cellTitle.setCellValue("时间(HH:MM:SS)");
      cellTitle.setCellStyle(cellStyle);
      for (int i = 1; i < timeCompareList.length+1; i++) {
         rowTitle.createCell(i).setCellValue(timeCompareList[i-1]);
      }
      //单体电压对比行
      for (int i = 0; i < monVolCompareList.length; i++) { //行数
         HSSFRow rowTemp = sheet.createRow(rowNum++);
         HSSFCell firstCell = rowTemp.createCell(0);
         firstCell.setCellValue("单体对比电压"+(i+1)+"(V)");
         firstCell.setCellStyle(cellStyle);
         for (int j = 1; j < monVolCompareList[i].length+1; j++) { //每行列数
            rowTemp.createCell(j).setCellValue(monVolCompareList[i][j-1]);
         }
      }
      rowNum++; //空格一行
      //单体温度对比行
      for (int i = 0; i < monTempCompareList.length; i++) { //行数
         HSSFRow rowTemp = sheet.createRow(rowNum++);
         HSSFCell firstCell = rowTemp.createCell(0);
         firstCell.setCellValue("单体对比温度"+(i+1)+"(℃)");
         firstCell.setCellStyle(cellStyle);
         for (int j = 1; j < monTempCompareList[i].length+1; j++) { //每行列数
            rowTemp.createCell(j).setCellValue(monTempCompareList[i][j-1]);
         }
      }
      rowNum++; //空格一行
      //插入图片
      int picNum = 0;
      String[] picName = new String[]{
            "单体电压对比图","单体温度对比图"
      };
      for(int i=0;i<picName.length;i++){
         sheet.createRow(rowNum);
         sheet.getRow(rowNum).createCell(0).setCellValue(picName[i]);
         //rowNum++;
         HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 512, 255,(short) 0, rowNum, (short) 10, rowNum+25);
         anchor.setAnchorType(3);
         patriarch.createPicture(anchor,wb.addPicture(bytes.get(picNum),HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
         picNum ++;rowNum+=25;
      }*/
    }
    private void createMonInfoSheet2_2007(List<byte[]> bytes,XSSFWorkbook wb,String splitTime, String[] timeCompareList,String[][] monVolCompareList, String[][] monTempCompareList, String monVolComparePic, String monTempComparePic) {
        String lang = ActionUtil.getLang();
        bytes=new ArrayList<byte[]>();
        //处理图片
        try {
            if (ServletUtils.isNotNull(monVolComparePic)) {
                String[] url = monVolComparePic.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
            if (ServletUtils.isNotNull(monTempComparePic)) {
                String[] url = monTempComparePic.split(",");
                bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        XSSFSheet sheet = null;
        if (lang.contains("zh")) {
            sheet = wb.createSheet("单体电压对比表");
        } else {
            sheet = wb.createSheet("Single unit voltage comparison table");
        }
        sheet.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        //图片元素
        XSSFDrawing patriarch = sheet.createDrawingPatriarch();
        //字体格式-加粗
        XSSFCellStyle cellStyle = wb.createCellStyle();
        XSSFFont font = wb.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        cellStyle.setFont(font);
        //一行一行的填充数据
        int rowNum = 0;
        XSSFRow firstRow = sheet.createRow(rowNum++);
        XSSFCell cell = firstRow.createCell(0);
        if (lang.contains("zh")) {
            cell.setCellValue("单体电压对比图");
        } else {
            cell.setCellValue("Comparison diagram of individual voltage");
        }
        cell.setCellStyle(cellStyle);
        //插入对比图片
        int picNum = 0;
        XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 512, 255, (short) 0, rowNum, (short) 10, rowNum + 25);
        anchor.setAnchorType(3);
        patriarch.createPicture(anchor, wb.addPicture(bytes.get(picNum), XSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
        picNum++;
        rowNum += 25;
        //插入数据
        XSSFRow firstDataRow = sheet.createRow(rowNum++);
        XSSFCell dataCell = firstDataRow.createCell(0);
        if (lang.contains("zh")) {
            dataCell.setCellValue("基准时间:" + splitTime + "分钟");
        } else {
            dataCell.setCellValue("reference time:" + splitTime + "minute");
        }
        dataCell.setCellStyle(cellStyle);
        //数据行抬头
        XSSFRow rowDataTitle = sheet.createRow(rowNum++);
        for (int i = 0; i < monVolCompareList.length + 1; i++) {
            XSSFCell cellTemp = rowDataTitle.createCell(i);
            if (i == 0) {
                if (lang.contains("zh")) {
                    cellTemp.setCellValue("时间(HH:MM:SS)");
                } else {
                    cellTemp.setCellValue("Time(HH:MM:SS)");
                }
            } else {
                if (lang.contains("zh")) {
                    cellTemp.setCellValue("单体对比电压" + (i) + "(V)");
                } else {
                    cellTemp.setCellValue("Single body comparison voltage" + (i) + "(V)");
                }
            }
            cellTemp.setCellStyle(cellStyle);
        }
        //数据行[1,1,1],[2,2,2]
        for (int i = 0; i < monVolCompareList[0].length; i++) {
            XSSFRow row = sheet.createRow(rowNum++);
            for (int j = 0; j < monVolCompareList.length + 1; j++) {
                row.createCell(0).setCellValue(timeCompareList[i]);
                if (j != 0) {
                    row.createCell(j).setCellValue(monVolCompareList[j - 1][i]);
                }
            }
        }
        //第二个sheet
        XSSFSheet sheet1 = null;
        if (lang.contains("zh")) {
            sheet1 = wb.createSheet("单体温度对比表");
        } else {
            sheet1 = wb.createSheet("Single body temperature comparison table");
        }
        sheet1.setDefaultColumnWidth(15);    //设置默认列宽,实际上回多出2个字符,不知道为什么
        sheet1.setDefaultRowHeight((short) (1 * 256));
        ; //设置默认行高,表示2个字符的高度
        //图片元素
        XSSFDrawing patriarch1 = sheet1.createDrawingPatriarch();
        //字体格式-加粗
        XSSFCellStyle cellStyle1 = wb.createCellStyle();
        XSSFFont font1 = wb.createFont();
        font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
        cellStyle1.setFont(font1);
        //一行一行的填充数据
        int rowNum1 = 0;
        XSSFRow firstRow1 = sheet1.createRow(rowNum1++);
        XSSFCell cell1 = firstRow1.createCell(0);
        if (lang.contains("zh")) {
            cell1.setCellValue("单体温度对比图");
        } else {
            cell1.setCellValue("Comparison diagram of individual temperature");
        }
        cell1.setCellStyle(cellStyle);
        //插入对比图片
        XSSFClientAnchor anchor1 = new XSSFClientAnchor(0, 0, 512, 255, (short) 0, rowNum1, (short) 10, rowNum1 + 25);
        anchor1.setAnchorType(3);
        patriarch1.createPicture(anchor1, wb.addPicture(bytes.get(picNum), XSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
        rowNum1 += 25;
        //插入数据
        XSSFRow firstDataRow1 = sheet1.createRow(rowNum1++);
        XSSFCell dataCell1 = firstDataRow1.createCell(0);
        if (lang.contains("zh")) {
            dataCell1.setCellValue("基准时间:" + splitTime + "分钟");
        } else {
            dataCell1.setCellValue("reference time:" + splitTime + "minute");
        }
        dataCell1.setCellStyle(cellStyle1);
        //数据行抬头
        XSSFRow rowDataTitle1 = sheet1.createRow(rowNum1++);
        for (int i = 0; i < monTempCompareList.length + 1; i++) {
            XSSFCell cellTemp = rowDataTitle1.createCell(i);
            if (i == 0) {
                if (lang.contains("zh")) {
                    cellTemp.setCellValue("时间(HH:MM:SS)");
                } else {
                    cellTemp.setCellValue("Time(HH:MM:SS)");
                }
            } else {
                if (lang.contains("zh")) {
                    cellTemp.setCellValue("单体对比温度" + (i) + "(℃)");
                } else {
                    cellTemp.setCellValue("Single body comparison temperature" + (i) + "(℃)");
                }
            }
            cellTemp.setCellStyle(cellStyle1);
        }
        //数据行[1,1,1],[2,2,2]
        for (int i = 0; i < monTempCompareList[0].length; i++) {
            XSSFRow row = sheet1.createRow(rowNum1++);
            for (int j = 0; j < monTempCompareList.length + 1; j++) {
                row.createCell(0).setCellValue(timeCompareList[i]);
                if (j != 0) {
                    row.createCell(j).setCellValue(monTempCompareList[j - 1][i]);
                }
            }
        }