package com.whyc.service;
|
|
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.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;
|
import org.springframework.stereotype.Service;
|
import sun.misc.BASE64Decoder;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.*;
|
import java.math.BigDecimal;
|
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
|
public class EchartPictureDowloadService {
|
|
private List<byte[]> bytes;
|
private List<byte[]> bytes1;
|
private String excelName = "Echarts";
|
private int rowNumAdd=27;
|
|
@Autowired
|
private FBOTestDataService fboservice; //aA059的service
|
|
@Autowired
|
private Ld9testdataService ld9service; //ld9的service
|
|
@Autowired
|
private Ld9testdatastopService stopservice; //ld9stop的service
|
|
@Autowired
|
private BattInfService binfservice; //battinf的service
|
|
@Autowired
|
private Environment environment;
|
|
//文件导出
|
public void exportExcel( HttpServletRequest req, HttpServletResponse resp) throws Exception {
|
String pageName = req.getParameter("pageName");
|
if (ServletUtils.isNotNull(pageName)) {
|
if ("charge-test".equalsIgnoreCase(pageName)) {
|
chargeExcelExprot(req, resp); //导出单个图表
|
}else if("control".equalsIgnoreCase(pageName)){
|
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);
|
}else if("exportCTExcel".equalsIgnoreCase(pageName)){
|
ExprotCTReport(req,resp); //导出CT机类似报表
|
}else if("ePrice".equalsIgnoreCase(pageName)){
|
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) {
|
// String fileName = req.getParameter("filename");
|
|
String Big_picture=req.getParameter("big_pic");
|
// System.out.println(ltop_echart+"***");
|
bytes = new ArrayList<byte[]>();
|
try {
|
|
if(ServletUtils.isNotNull(Big_picture)){
|
String[] url = Big_picture.split(",");
|
bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
|
}
|
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
if (bytes.size() > 0) {
|
|
createExcel(bytes, resp, req);
|
}
|
}
|
//实时监测导出图表
|
private void controlExcelExprot(HttpServletRequest req,
|
HttpServletResponse resp) {
|
String only_echart=req.getParameter("only_echart");
|
bytes=new ArrayList<byte[]>();
|
if(ServletUtils.isNotNull(only_echart)){
|
try {
|
String[] url = only_echart.split(",");
|
bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
|
createExcel(bytes, resp, req);
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
/**
|
* A059一体机导出报表
|
* @param req
|
* @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[]>();
|
|
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充放电数据
|
|
//取出电池组信息构建excel文件的名称
|
String excelName = binfservice.serchExcelNameA059(battGroupId, stateFlag);
|
|
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)) {
|
String[] url = rtop_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(rbottom_echart)) {
|
String[] url = rbottom_echart.split(",");
|
bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
|
}
|
} 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();
|
|
//字体格式-加粗
|
HSSFCellStyle cellStyle = wb.createCellStyle();
|
HSSFFont font = wb.createFont();
|
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
cellStyle.setFont(font);
|
|
//新建行
|
//抬头
|
int rowNum = 0;
|
HSSFRow rowTitle = sheet.createRow(rowNum);
|
HSSFCell cellTitle = rowTitle.createCell(0);
|
cellTitle.setCellValue("一体机充放电数据");
|
cellTitle.setCellStyle(cellStyle);
|
rowNum++;
|
//属性栏
|
HSSFRow row = sheet.createRow(rowNum);
|
|
row.createCell(0).setCellValue("测试时长"); //创建单元格
|
row.createCell(1).setCellValue("总电压");
|
row.createCell(2).setCellValue("测试电流");
|
row.createCell(3).setCellValue("测试容量");
|
for(int i=0;i<monCount;i++){
|
row.createCell(4+i).setCellValue("#"+Integer.valueOf(i+1));
|
}
|
rowNum++;
|
|
//取出放电开始时间
|
Date test_starttime=null ;
|
//数据栏
|
if(monCount!=0){
|
for (int i = 0; i < list.size(); i++) {
|
sheet.createRow(rowNum); //创建行
|
for(int j=0;j<monCount;j++){
|
FBOTestData fbo=list.get(i+j);
|
if(i==0&&j==0){
|
test_starttime=fbo.getTestStartTime();
|
}
|
sheet.getRow(rowNum).createCell(0).setCellValue(ActionUtil.secToTime(fbo.getTestTimeLong()));
|
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());
|
}
|
i = i + monCount - 1;
|
rowNum++;
|
}
|
}
|
rowNum += 2;
|
|
//excel文件名
|
/*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]);
|
//rowNum++;
|
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;
|
}
|
|
rowNum++;
|
|
try {
|
// 转码防止乱码
|
resp.addHeader("Content-Disposition", "attachment;filename="
|
+ new String(excelName.getBytes("UTF-8"), "ISO8859-1")
|
+ ".xls");
|
OutputStream out = resp.getOutputStream();
|
wb.write(out);
|
out.close();
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 历史放电数据页面中导出LD9设备的整组放电数据(最新版)
|
* @param req
|
* @param 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); //最大最小信息
|
String[][] datas = ActionUtil.getGson().fromJson(req.getParameter("arr-data"), String[][].class);//二维数据信息
|
//电池组信息
|
Battinf binf = ActionUtil.getGson().fromJson(battinf, Battinf.class);
|
Ld9testdataInf linf = ActionUtil.getGson().fromJson(testdatainfo, Ld9testdataInf.class);
|
try {
|
// 创建一个工作薄
|
HSSFWorkbook wb = new HSSFWorkbook();
|
//LD9放电整组信息
|
createLd9GroupInfo(wb,echarttitle,datas,binf);
|
//ld9整组放电数据
|
createLD9AllGroup(wb,linf);
|
//查询存放ld9在testrecordcount下有哪些单体存在放电记录
|
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);
|
createGroupSheet(wb,binf,ld9stop);//创建每个单体的sheet
|
}
|
}
|
resp.addHeader("Content-Disposition", "attachment;filename="
|
+ new String(excelName.getBytes("gb2312"), "ISO8859-1")
|
+ ".xls");
|
OutputStream out = resp.getOutputStream();
|
wb.write(out);
|
out.close();
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
//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());
|
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));
|
|
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;
|
|
rownum++;
|
sheet1.createRow(rownum);
|
sheet1.getRow(rownum).createCell(1).setCellValue("最高单体电压");
|
sheet1.getRow(rownum).createCell(2).setCellValue("最低单体电压");
|
sheet1.getRow(rownum).createCell(3).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());
|
|
rownum+=2;
|
|
|
String[] arrTh = new String[]{
|
"单体编号","是否合格","起始单体电压(V)","截止单体电压(V)","测试容量(AH)","实际容量(AH)","剩余容量(AH)","容量百分比","单体内阻(mΩ)","起始单体温度(℃)","终止单体温度(℃)"
|
};
|
sheet1.createRow(rownum);
|
for(int i = 0 ;i<arrTh.length;i++){
|
sheet1.getRow(rownum).createCell(i+1).setCellValue(arrTh[i]);
|
}
|
rownum++;
|
float real_cap=0f;//实际容量
|
float cap_percent=0f;//容量百分比
|
float cap_qualify=0.8f;
|
int datacell=0;//列
|
if(datas!=null && datas.length>0){
|
for(int i=0;i<datas.length;i++){
|
sheet1.createRow(rownum);
|
for(int j=0;j<datas[i].length;j++){
|
datacell=1+j;
|
if(j>=1&&j<=5){
|
datacell=datacell+1;
|
}
|
if(j>=6){
|
datacell=datacell+2;
|
}
|
sheet1.getRow(rownum).createCell(datacell).setCellValue(datas[i][j]);
|
if(j==4){
|
real_cap=Float.parseFloat(datas[i][j]);
|
}
|
}
|
cap_percent= (float) formartDouble((real_cap/binf.getMonCapStd())*1.0,2);
|
sheet1.getRow(rownum).createCell(2).setCellValue(cap_percent>=cap_qualify?"合格":"不合格");
|
sheet1.getRow(rownum).createCell(8).setCellValue(cap_percent*100);
|
rownum++;
|
}
|
}
|
}
|
//生成每个单体放电单体表
|
private void createGroupSheet(HSSFWorkbook wb, Battinf binf, Ld9testdatastop ld9stop){
|
List<byte[]> listbyte=new ArrayList<byte[]>();//读取图片
|
//-----------------------读取4张图:单体电压折线图,组端/在线电压折线图,测试电流折线图,单体实际容量柱状图
|
String fileDirName = "";
|
int configType = Integer.parseInt(environment.getProperty("configFile.type"));
|
ApplicationHome applicationHome = new ApplicationHome(getClass());
|
File jarFile = applicationHome.getDir();
|
//测试版
|
if(configType==1){
|
fileDirName = jarFile.getParentFile().toString();
|
}else{
|
//打包版
|
fileDirName = jarFile.toString();
|
}
|
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()){
|
File[] files=f.listFiles();
|
for(int i=0;i<files.length;i++){
|
picName.add(files[i].getName().substring(0,files[i].getName().lastIndexOf(".")));//存放图片的名称
|
InputStream in = null;
|
byte[] data = null;
|
// 读取图片字节数组
|
try {
|
in = new FileInputStream(picroot + files[i].getName());
|
data = new byte[in.available()];
|
in.read(data);
|
} 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()) + "信息表");
|
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());
|
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));
|
|
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()));
|
|
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;
|
|
//画图
|
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).equals("测试容量") ? "单体测试容量柱状图" : picName.get(i));
|
rownum++;
|
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;
|
}
|
}
|
}
|
/**
|
* 导出报表
|
* @param req
|
* @param resp
|
*/
|
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");//追加的单体温度对比 图片
|
|
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);
|
|
//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);
|
|
//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){
|
//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);
|
}
|
}
|
/**
|
* 历史放电数据页面中导出LD9设备的放电数据
|
* @param req
|
* @param resp
|
*/
|
private void ExprotLD9MonTestData(HttpServletRequest req,
|
HttpServletResponse resp) {
|
String mon_vol_line = req.getParameter("mon_vol_line"); //单体电压折线图
|
String group_vol_line = req.getParameter("group_vol_line"); //组端/在线电压折线图
|
String test_curr_line = req.getParameter("test_curr_line"); //测试电流折线图
|
String batt_real_cap = req.getParameter("batt_real_cap"); //单体实际容量柱状图
|
|
String allGroup_vol_line = req.getParameter("allGroup_vol_line");//整组端电压折线图
|
String allGroup_curr_line = req.getParameter("allGroup_curr_line");//多单体电流折线图
|
String allmon_vol_line = req.getParameter("allmon_vol_line");//多单体电压折线图
|
|
String battinf = req.getParameter("battinf"); //电池组信息
|
String mon_test_data = req.getParameter("mon_test_data"); //单体测试数据
|
String testdatainfo = req.getParameter("testdatainfo"); //单体测试数据
|
|
|
bytes=new ArrayList<byte[]>();
|
bytes1=new ArrayList<byte[]>();
|
try {
|
//单体电压折线图
|
if (ServletUtils.isNotNull(mon_vol_line)) {
|
String[] url = mon_vol_line.split(",");
|
bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
|
}
|
|
//组端/在线电压折线图
|
if (ServletUtils.isNotNull(group_vol_line)) {
|
String[] url = group_vol_line.split(",");
|
bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
|
}
|
|
//单体电流曲线图
|
if (ServletUtils.isNotNull(test_curr_line)) {
|
String[] url = test_curr_line.split(",");
|
bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
|
}
|
|
//单体电流曲线图
|
if (ServletUtils.isNotNull(batt_real_cap)) {
|
String[] url = batt_real_cap.split(",");
|
bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
|
}
|
//整组端电压折线图
|
if (ServletUtils.isNotNull(allGroup_vol_line)) {
|
String[] url1 = allGroup_vol_line.split(",");
|
bytes1.add(new BASE64Decoder().decodeBuffer(url1[1]));
|
}
|
//多单体电流折线图
|
if (ServletUtils.isNotNull(allGroup_curr_line)) {
|
String[] url1 = allGroup_curr_line.split(",");
|
bytes1.add(new BASE64Decoder().decodeBuffer(url1[1]));
|
}
|
//多单体电压折线图
|
if (ServletUtils.isNotNull(allmon_vol_line)) {
|
String[] url1 = allmon_vol_line.split(",");
|
bytes1.add(new BASE64Decoder().decodeBuffer(url1[1]));
|
}
|
|
Battinf binf = ActionUtil.getGson().fromJson(battinf, Battinf.class);
|
Ld9testdataInf mondatainfo = ActionUtil.getGson().fromJson(testdatainfo, Ld9testdataInf.class);
|
List<Ld9testdata> montestdata = ActionUtil.getGson().fromJson(mon_test_data, new TypeToken<List<Ld9testdata>>(){}.getType());
|
createMonTestDataExcel(bytes,bytes1,binf,montestdata,mondatainfo,resp,req);
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
|
}
|
//生成历史数据中LD9单体数据的报表
|
private void createMonTestDataExcel(List<byte[]> bytes,List<byte[]> bytes1,Battinf binf,List<Ld9testdata> montestdata,Ld9testdataInf mondatainfo,HttpServletResponse resp,HttpServletRequest req) {
|
try {
|
// 创建一个工作薄
|
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());
|
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));
|
|
rownum++;
|
sheet1.createRow(rownum);
|
sheet1.getRow(rownum).createCell(1).setCellValue( "被测单体编号:#"+mondatainfo.getMonNum());
|
sheet1.getRow(rownum).createCell(2).setCellValue( "测试类型:"+binf.getBattGroupName5());
|
sheet1.getRow(rownum).createCell(3).setCellValue( "测试时间:"+formartDate(mondatainfo.getTestStarttime(),"yyyy-MM-dd HH:mm:ss"));
|
sheet1.getRow(rownum).createCell(4).setCellValue( "测试电流:"+mondatainfo.getTestCurr()+"A");
|
sheet1.getRow(rownum).createCell(5).setCellValue( "测试时长:"+formatTestLong(mondatainfo.getTestTimelong()));
|
sheet1.getRow(rownum).createCell(6).setCellValue( "测试容量:"+formartDouble(mondatainfo.getTestCap(),0)+"AH");
|
sheet1.getRow(rownum).createCell(7).setCellValue( "终止原因:"+binf.getBattGroupName6());
|
|
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;
|
String[] picName = new String[]{
|
"单体电压曲线图","端电压曲线图","单体电流曲线图","单体实际容量柱状图"
|
};
|
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;
|
}
|
|
|
|
//创建整组放电折线图
|
createLD9AllGroupVolLine(wb,bytes1);
|
/*更改ld9文件导出时改为整组放电信息导出*/
|
//createNewLD9DataSheet(wb,montestdata);
|
createLD9AllGroup(wb,mondatainfo);
|
|
// 转码防止乱码
|
resp.addHeader("Content-Disposition", "attachment;filename="
|
+ new String(excelName.getBytes("UTF-8"), "ISO8859-1")
|
+ ".xls");
|
OutputStream out = resp.getOutputStream();
|
wb.write(out);
|
out.close();
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
//创建整组放电折线图
|
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++) {
|
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));
|
anchor.setAnchorType(3);
|
patriarch.createPicture(anchor, wb.addPicture(bytes1.get(picnum), HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
|
}
|
picnum++;
|
rownum += 25;
|
}
|
}
|
|
}
|
|
/*更改ld9文件导出时改为整组放电信息导出*/
|
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;
|
}
|
if (monNum != data.getMonNum()) {
|
if (monNum != 0) {
|
currRow = currRow + 10;
|
}
|
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)");
|
}
|
currCel++;
|
sheet.getRow(currRow+1).createCell(currCel).setCellValue(formatTestLong(data.getTestTimelong()));
|
sheet.getRow(currRow+2).createCell(currCel).setCellValue(formartDouble(data.getGroupVol(),1));
|
sheet.getRow(currRow+3).createCell(currCel).setCellValue(formartDouble(data.getOnlineVol(),1));
|
sheet.getRow(currRow+4).createCell(currCel).setCellValue(formartDouble(data.getTestCurr(),3));
|
sheet.getRow(currRow+5).createCell(currCel).setCellValue(formartDouble(data.getTestCap(),1));
|
sheet.getRow(currRow+6).createCell(currCel).setCellValue(formartDouble(data.getMonVol(),3));
|
sheet.getRow(currRow+7).createCell(currCel).setCellValue(formartDouble(data.getMonCap(),1));
|
sheet.getRow(currRow+8).createCell(currCel).setCellValue(formartDouble(data.getMonRestCap(),1));
|
}
|
}
|
}
|
|
public void createNewLD9DataSheet(HSSFWorkbook wb, final List<Ld9testdata> montestdata) {
|
HSSFSheet sheet = wb.createSheet("单体数据表");
|
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(); //总记录条数
|
|
|
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)");
|
//}
|
|
String[][] datas = new String[total_col][tabTh.size()];
|
|
//System.out.println("data.length"+datas.length+"\t datas[0].length:"+datas[0].length);
|
|
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).getMonVol(), 3) + "";
|
|
//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)total_col/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;
|
}
|
|
//System.out.println("data.length"+datas.length+"\t datas[0].length:"+datas[0].length);
|
}
|
}
|
//导出CT机样式报表
|
private void ExprotCTReport(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 actucap_echart = req.getParameter("actucap_echart"); //实际容量折线图
|
|
bytes=new ArrayList<byte[]>();
|
BattMaintDealarm bmd = ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(req.getParameter("obj-bmd"), BattMaintDealarm.class);
|
Title echarttitle = ActionUtil.getGson().fromJson(req.getParameter("obj-title"), Title.class);
|
String[][] datas = ActionUtil.getGson().fromJson(req.getParameter("arr-data"), String[][].class);
|
|
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);
|
List<BatttestdataId> groupinfo = ActionUtil.getGson().fromJson(req.getParameter("mon-group-list"), new TypeToken<List<BatttestdataId>>(){}.getType());
|
// 创建一个工作薄
|
HSSFWorkbook wb = new HSSFWorkbook();
|
|
CreateReportCover(wb,bmd); //生成报告封面
|
|
CreateStartEndVol(wb,datas); //生成起止电压工作簿
|
|
CreateCapAnalyTable(wb,datas,actucap_echart); //生成容量分析表
|
|
CreateMonVolAnalyTable(wb,datas,lbottom_echart); //生成电压特性比较图
|
|
CreateTotalVolAnalyTable(wb,"总电压曲线图",ltop_echart); //生成总电压曲线图
|
|
CreateTotalVolAnalyTable(wb,"总电流曲线图",rtop_echart); //生成总电流曲线
|
|
createMonVolDataTable(wb,mon_vol_list,groupinfo); //生成电压数据表格
|
|
createExcel(wb,resp);
|
|
}
|
|
//生成报告封面
|
private void CreateReportCover(HSSFWorkbook wb, BattMaintDealarm bmd) {
|
HSSFSheet sheet = wb.createSheet("报告封面");
|
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 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.getRow(2).createCell(2).setCellValue("蓄电池容量测试报告");
|
sheet.getRow(2).getCell(2).setCellStyle(titleCellStyle);
|
sheet.getRow(2).setHeightInPoints(17);
|
sheet.getRow(3).setHeightInPoints(17);
|
sheet.createRow(rowNum++);
|
sheet.createRow(rowNum++);
|
sheet.getRow(4).setHeightInPoints(40);
|
sheet.createRow(rowNum++);
|
sheet.getRow(5).createCell(3).setCellValue("分 公 司");
|
sheet.getRow(5).getCell(3).setCellStyle(menuCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(5,5,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(6).createCell(3).setCellValue("电池组名");
|
sheet.getRow(6).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(6).createCell(4).setCellValue(bmd.getBinf().getBattGroupName());
|
sheet.getRow(6).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(6,6,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(7).createCell(3).setCellValue("电池品牌");
|
sheet.getRow(7).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(7).createCell(4).setCellValue(bmd.getBinf().getBattProducer());
|
sheet.getRow(7).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(7,7,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(8).createCell(3).setCellValue("电池型号");
|
sheet.getRow(8).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(8).createCell(4).setCellValue(bmd.getBinf().getBattModel());
|
sheet.getRow(8).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(8,8,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(9).createCell(3).setCellValue("电池生产日期");
|
sheet.getRow(9).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(9).createCell(4).setCellValue(formartDate(bmd.getBinf().getBattProductDate(),"yyyy-MM-dd"));
|
sheet.getRow(9).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(9,9,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(10).createCell(3).setCellValue("投入使用日期");
|
sheet.getRow(10).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(10).createCell(4).setCellValue(formartDate(bmd.getBinf().getBattInUseDate(),"yyyy-MM-dd"));
|
sheet.getRow(10).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(10,10,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(11).createCell(3).setCellValue("标称容量");
|
sheet.getRow(11).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(11).createCell(4).setCellValue(bmd.getBinf().getMonCapStd());
|
sheet.getRow(11).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(11,11,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(12).createCell(3).setCellValue("单体电压");
|
sheet.getRow(12).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(12).createCell(4).setCellValue(bmd.getBinf().getMonVolStd());
|
sheet.getRow(12).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(12,12,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(13).createCell(3).setCellValue("放 电 率");
|
sheet.getRow(13).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(13).createCell(4).setCellValue(10);
|
sheet.getRow(13).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(13,13,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(14).createCell(3).setCellValue("维护人员");
|
sheet.getRow(14).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(14).createCell(4).setCellValue("");
|
sheet.getRow(14).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(14,14,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(15).createCell(3).setCellValue("联系电话");
|
sheet.getRow(15).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(15).createCell(4).setCellValue("");
|
sheet.getRow(15).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(15,15,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(16).setHeightInPoints(24);
|
sheet.createRow(rowNum++);
|
sheet.getRow(17).createCell(3).setCellValue("测试单位");
|
sheet.getRow(17).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(17).createCell(4).setCellValue("");
|
sheet.getRow(17).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(17,17,4,9));
|
sheet.createRow(rowNum++);
|
sheet.getRow(18).createCell(3).setCellValue("测试时间");
|
sheet.getRow(18).getCell(3).setCellStyle(menuCellStyle);
|
sheet.getRow(18).createCell(4).setCellValue(formartDate(bmd.getSdata().getTestStarttime(),"yyyy-MM-dd HH:mm:ss"));
|
sheet.getRow(18).getCell(4).setCellStyle(textCellStyle);
|
sheet.addMergedRegion(new CellRangeAddress(18,18,4,9));
|
}
|
/**
|
* 将日期格式转换成指定的字符串格式
|
* @param date 日期
|
* @param str 字符串的格式
|
* @return
|
*/
|
public static String formartDate(Date date, String str){
|
return new SimpleDateFormat(str).format(date);
|
}
|
|
//生成起止电压数据
|
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); //单元格样式
|
|
sheet.setColumnWidth(2, 24 * 256);
|
sheet.setColumnWidth(3, 24 * 256);
|
sheet.setColumnWidth(4, 24 * 256);
|
|
sheet.setDefaultColumnWidth(9); // 设置单元格默认宽度
|
sheet.setDefaultRowHeight((short) (30 * 11));
|
int rowNum = 0;
|
sheet.createRow(rowNum);
|
sheet.getRow(rowNum).createCell(3).setCellValue("起始值(V)");
|
sheet.getRow(rowNum).getCell(3).setCellStyle(titleCellStyle);
|
sheet.getRow(rowNum).createCell(4).setCellValue("结束值(V)");
|
sheet.getRow(rowNum++).getCell(4).setCellStyle(titleCellStyle);
|
sheet.createRow(rowNum);
|
sheet.getRow(rowNum).createCell(2).setCellValue("最高电压");
|
sheet.getRow(rowNum).getCell(2).setCellStyle(titleCellStyle);
|
String[] startArr = data[1];
|
String[] endArr = data[2];
|
float maxStart = Float.parseFloat(startArr[0]);
|
int maxStartNum = 1;
|
float maxEnd = Float.parseFloat(endArr[0]);
|
int maxEndNum = 1;
|
for(int i = 0;i<startArr.length;i++){
|
if(Float.parseFloat(startArr[i]) > maxStart){
|
maxStart = Float.parseFloat(startArr[i]);
|
maxStartNum = i+1;
|
}
|
if(Float.parseFloat(endArr[i]) > maxEnd){
|
maxEnd = Float.parseFloat(endArr[i]);
|
maxEndNum = i+1;
|
}
|
}
|
sheet.getRow(rowNum).createCell(3).setCellValue(""+maxStart+"(#"+maxStartNum+")");
|
sheet.getRow(rowNum).getCell(3).setCellStyle(txtCellStyle);
|
sheet.getRow(rowNum).createCell(4).setCellValue(""+maxEnd+"(#"+maxEndNum+")");
|
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).getCell(2).setCellStyle(numCellStyle);
|
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++).getCell(4).setCellStyle(txtCellStyle);
|
}
|
}
|
|
//生成容量分析表
|
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); //单元格样式
|
|
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]);
|
} catch (IOException e) {
|
//e.printStackTrace();
|
}
|
}
|
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));
|
anchor.setAnchorType(3);
|
// 插入图片
|
patriarch.createPicture(anchor, wb.addPicture(pic, HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
|
}
|
|
int rouNum = 26;
|
sheet.createRow(rouNum);
|
sheet.getRow(rouNum).createCell(2).setCellValue("单体编号");
|
sheet.getRow(rouNum).getCell(2).setCellStyle(titleCellStyle);
|
sheet.getRow(rouNum).createCell(3).setCellValue("剩余容量(AH)");
|
sheet.getRow(rouNum).getCell(3).setCellStyle(titleCellStyle);
|
sheet.getRow(rouNum).createCell(4).setCellValue("实际容量(AH)");
|
sheet.getRow(rouNum).getCell(4).setCellStyle(titleCellStyle);
|
sheet.getRow(rouNum).createCell(5).setCellValue("容量百分比(%)");
|
sheet.getRow(rouNum++).getCell(5).setCellStyle(titleCellStyle);
|
|
for(int i=0;i<data[0].length;i++){
|
sheet.createRow(rouNum);
|
sheet.getRow(rouNum).createCell(2).setCellValue(data[0][i]);
|
sheet.getRow(rouNum).getCell(2).setCellStyle(titleCellStyle);
|
sheet.getRow(rouNum).createCell(3).setCellValue(data[4][i]);
|
sheet.getRow(rouNum).getCell(3).setCellStyle(txtCellStyle);
|
sheet.getRow(rouNum).createCell(4).setCellValue(data[3][i]);
|
sheet.getRow(rouNum).getCell(4).setCellStyle(txtCellStyle);
|
sheet.getRow(rouNum).createCell(5).setCellValue(data[5][i]);
|
sheet.getRow(rouNum++).getCell(5).setCellStyle(txtCellStyle);
|
|
}
|
}
|
|
//生成电压特性比较图
|
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); //单元格样式
|
|
sheet.setDefaultColumnWidth(9); // 设置单元格默认宽度
|
|
sheet.setColumnWidth(2, 19 * 256);
|
sheet.setColumnWidth(3, 19 * 256);
|
sheet.setColumnWidth(4, 19 * 256);
|
|
byte[] pic = null;
|
if (ServletUtils.isNotNull(picstr)) {
|
try {
|
String[] url = picstr.split(",");
|
pic = new BASE64Decoder().decodeBuffer(url[1]);
|
} catch (IOException e) {
|
//e.printStackTrace();
|
}
|
}
|
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));
|
anchor.setAnchorType(3);
|
// 插入图片
|
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;
|
for(int i=0;i<data[0].length;i++){
|
if(Float.parseFloat(data[1][i])>maxStart){
|
maxStart = Float.parseFloat(data[1][i]);
|
maxStartNum = i+1;
|
}
|
|
if(Float.parseFloat(data[2][i])>maxEnd){
|
maxEnd = Float.parseFloat(data[2][i]);
|
maxEndNum = i+1;
|
}
|
}
|
|
sheet.getRow(rouNum).createCell(3).setCellValue("起始值(V)");
|
sheet.getRow(rouNum).getCell(3).setCellStyle(titleCellStyle);
|
sheet.getRow(rouNum).createCell(4).setCellValue("结束值(V)");
|
sheet.getRow(rouNum++).getCell(4).setCellStyle(titleCellStyle);
|
sheet.createRow(rouNum);
|
sheet.getRow(rouNum).createCell(2).setCellValue("最高电压");
|
sheet.getRow(rouNum).getCell(2).setCellStyle(titleCellStyle);
|
sheet.getRow(rouNum).createCell(3).setCellValue(maxStart+"(#"+maxStartNum+")");
|
sheet.getRow(rouNum).getCell(3).setCellStyle(txtCellStyle);
|
sheet.getRow(rouNum).createCell(4).setCellValue(maxEnd+"(#"+maxEndNum+")");
|
sheet.getRow(rouNum++).getCell(4).setCellStyle(txtCellStyle);
|
|
|
for(int i=0;i<data[0].length;i++){
|
sheet.createRow(rouNum);
|
sheet.getRow(rouNum).createCell(2).setCellValue(data[0][i]);
|
sheet.getRow(rouNum).getCell(2).setCellStyle(titleCellStyle);
|
sheet.getRow(rouNum).createCell(3).setCellValue(data[1][i]);
|
sheet.getRow(rouNum).getCell(3).setCellStyle(txtCellStyle);
|
sheet.getRow(rouNum).createCell(4).setCellValue(data[2][i]);
|
sheet.getRow(rouNum++).getCell(4).setCellStyle(txtCellStyle);
|
|
}
|
}
|
|
//生成单个图片工作簿
|
private void CreateTotalVolAnalyTable(HSSFWorkbook wb, String sheetName, String picstr) {
|
HSSFSheet sheet = wb.createSheet(sheetName);
|
sheet.setDefaultColumnWidth(15); //设置默认列宽,实际上回多出2个字符,不知道为什么
|
sheet.setDefaultRowHeight((short) (1 * 256));
|
; //设置默认行高,表示2个字符的高度
|
|
byte[] pic = null;
|
if (ServletUtils.isNotNull(picstr)) {
|
try {
|
String[] url = picstr.split(",");
|
pic = new BASE64Decoder().decodeBuffer(url[1]);
|
} catch (IOException e) {
|
//e.printStackTrace();
|
}
|
}
|
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));
|
anchor.setAnchorType(3);
|
// 插入图片
|
patriarch.createPicture(anchor, wb.addPicture(pic, HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
|
}
|
|
}
|
|
//生成电压数据表格
|
private void createMonVolDataTable(HSSFWorkbook wb,String[][] mon_vol_list,List<BatttestdataId> groupinfo){
|
|
HSSFCellStyle titleCellStyle = ExcelUtil.createCellStyle(wb,"宋体",12,true,true); //单元格样式
|
HSSFCellStyle txtCellStyle = ExcelUtil.createCellStyle(wb,"宋体",12,true,false); //单元格样式
|
if(mon_vol_list != null && groupinfo != null){
|
int mon_count = mon_vol_list[0].length; //总单体数量
|
int total_col = mon_vol_list.length; //总记录条数
|
|
|
List<String> tabTh = new ArrayList<String>(){{
|
this.add("时间(HMS)");this.add("总电压(V)");this.add("总电流(A)");this.add("容量(AH)");this.add("标准电压(V)");
|
}};
|
for(int i=1;i<=mon_count;i++){
|
tabTh.add("#"+i);
|
}
|
int maxColCount = 221; //最大的列数
|
int tableCount = 1;
|
HSSFSheet sheet = null;
|
int nowColIndex = 0;
|
int rowNum = 0;
|
for(int i =0;i<=mon_vol_list.length;i++){
|
if (i % maxColCount == 0) {
|
//创建新的工作簿
|
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); // 设置单元格默认宽度
|
}
|
}
|
rowNum = 0;
|
nowColIndex = i%maxColCount;
|
|
if(i == 0){
|
//第一个数据表格
|
for(int j = 0 ;j<tabTh.size();j++){
|
//System.out.println(tabTh.get(j)+"\t"+j);
|
sheet.getRow(rowNum).createCell(nowColIndex).setCellValue(tabTh.get(j));
|
sheet.getRow(rowNum++).getCell(nowColIndex).setCellStyle(titleCellStyle);;
|
}
|
}else{
|
//其他的表格
|
sheet.getRow(rowNum).createCell(nowColIndex).setCellValue(formatTestLong(groupinfo.get(i-1).getTestTimelong()));
|
sheet.getRow(rowNum++).getCell(nowColIndex).setCellStyle(txtCellStyle);
|
sheet.getRow(rowNum).createCell(nowColIndex).setCellValue(formartDouble(groupinfo.get(i-1).getGroupVol(),1));
|
sheet.getRow(rowNum++).getCell(nowColIndex).setCellStyle(txtCellStyle);
|
sheet.getRow(rowNum).createCell(nowColIndex).setCellValue(formartDouble(groupinfo.get(i-1).getTestCurr(),1));
|
sheet.getRow(rowNum++).getCell(nowColIndex).setCellStyle(txtCellStyle);
|
sheet.getRow(rowNum).createCell(nowColIndex).setCellValue(formartDouble(groupinfo.get(i-1).getTestCap(),0));
|
sheet.getRow(rowNum++).getCell(nowColIndex).setCellStyle(txtCellStyle);
|
sheet.getRow(rowNum).createCell(nowColIndex).setCellValue(formartDouble(calMaxToArr(mon_vol_list[i-1]),3));
|
sheet.getRow(rowNum++).getCell(nowColIndex).setCellStyle(txtCellStyle);
|
for(int j = 0;j<mon_vol_list[i-1].length;j++){
|
sheet.getRow(rowNum).createCell(nowColIndex).setCellValue(mon_vol_list[i-1][j]);
|
sheet.getRow(rowNum++).getCell(nowColIndex).setCellStyle(txtCellStyle);
|
}
|
}
|
|
|
}
|
|
|
|
//System.out.println("data.length"+datas.length+"\t datas[0].length:"+datas[0].length);
|
}
|
}
|
|
//生成历史数据中的报表
|
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 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 = 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;
|
//钱煜要求电流计算出来(测试容量*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++;
|
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("最高单体电压");
|
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);
|
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);
|
//单体温度数据表
|
createMonInfoSheet(wb, mon_tmp_list, groupinfo, monNum, exportNum, 1);
|
//单体电压对比表-单体温度对比表
|
createMonInfoSheet2(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")
|
+ ".xls");
|
OutputStream out = resp.getOutputStream();
|
wb.write(out);
|
out.close();
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
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 {
|
// 转码防止乱码
|
resp.addHeader("Content-Disposition", "attachment;filename="
|
+ new String(excelName.getBytes("UTF-8"), "ISO8859-1")
|
+ ".xls");
|
OutputStream out = resp.getOutputStream();
|
wb.write(out);
|
out.close();
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
private void createExcel(List<byte[]> bytes, HttpServletResponse resp,
|
HttpServletRequest req) {
|
try {
|
// 创建一个工作薄
|
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));
|
anchor.setAnchorType(3);
|
// 插入图片
|
patriarch.createPicture(
|
anchor,
|
wb.addPicture(bytes.get(i),
|
HSSFWorkbook.PICTURE_TYPE_PNG)).resize(1);
|
}
|
|
// 转码防止乱码
|
resp.addHeader("Content-Disposition", "attachment;filename="
|
+ new String(excelName.getBytes("UTF-8"), "ISO8859-1")
|
+ ".xls");
|
OutputStream out = resp.getOutputStream();
|
wb.write(out);
|
out.close();
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 电价统计分析导出
|
* @param req
|
* @param resp
|
*/
|
private void ExportElectricityPrice(HttpServletRequest req,HttpServletResponse resp) {
|
|
bytes=new ArrayList<byte[]>();
|
//接收req中携带的数据/图片
|
String ePriceAnalysisPic = req.getParameter("ePriceAnalysisPic");
|
String ePriceDistributeMapPic = req.getParameter("ePriceDistributeMapPic");
|
|
List<ElePrice> data = ActionUtil.getGson().fromJson(req.getParameter("ePriceAnalysisData"), new TypeToken<List<ElePrice>>() {
|
}.getType());
|
|
//处理图片
|
try {
|
if (ServletUtils.isNotNull(ePriceAnalysisPic)) {
|
String[] url = ePriceAnalysisPic.split(",");
|
bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
|
}
|
if (ServletUtils.isNotNull(ePriceDistributeMapPic)) {
|
String[] url = ePriceDistributeMapPic.split(",");
|
bytes.add(new BASE64Decoder().decodeBuffer(url[1]));
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
|
//当前日期
|
String nowFormat = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
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();
|
|
//字体格式-加粗
|
HSSFCellStyle cellStyle = wb.createCellStyle();
|
HSSFFont font = wb.createFont();
|
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
cellStyle.setFont(font);
|
|
//新建行
|
//抬头
|
int rowNum = 0;
|
HSSFRow rowTitle = sheet.createRow(rowNum);
|
HSSFCell cellTitle = rowTitle.createCell(0);
|
cellTitle.setCellValue("节约电费统计数据");
|
cellTitle.setCellStyle(cellStyle);
|
rowNum++;
|
//属性栏
|
HSSFRow row = sheet.createRow(rowNum);
|
row.createCell(0).setCellValue("编号");
|
row.createCell(1).setCellValue("日期");
|
row.createCell(2).setCellValue("节约电费(度/元)");
|
rowNum++;
|
//数据栏
|
for (int i = 0; i < data.size(); i++) {
|
sheet.createRow(rowNum);
|
sheet.getRow(rowNum).createCell(0).setCellValue(data.get(i).getNum());
|
sheet.getRow(rowNum).createCell(1).setCellValue(data.get(i).getAnalysisDate());
|
sheet.getRow(rowNum).createCell(2).setCellValue(Double.parseDouble(String.valueOf(data.get(i).getElePrice())));
|
rowNum++;
|
|
}
|
|
|
|
//插入图片
|
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]);
|
//rowNum++;
|
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;
|
}
|
|
rowNum++;
|
|
try {
|
// 转码防止乱码
|
resp.addHeader("Content-Disposition", "attachment;filename="
|
+ new String(excelName.getBytes("UTF-8"), "ISO8859-1")
|
+ ".xls");
|
OutputStream out = resp.getOutputStream();
|
wb.write(out);
|
out.close();
|
} catch (UnsupportedEncodingException e) {
|
e.printStackTrace();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
//将秒转化成时:分:秒
|
public static String formatTestLong(long theTime) {
|
long theTime1 = 0;// 分
|
long theTime2 = 0;// 小时
|
// alert(theTime);
|
if(theTime >= 60) {
|
theTime1 = theTime/60;
|
theTime = theTime%60;
|
//alert(theTime1+"-"+theTime);
|
if(theTime1 >= 60) {
|
theTime2 = theTime1/60;
|
theTime1 = theTime1%60;
|
}
|
}
|
String result = (theTime<10?"0":"")+theTime;
|
if(theTime1 >= 0) {
|
result =(theTime1<10?"0":"")+theTime1+":"+result;
|
}
|
if(theTime2 >= 0) {
|
result =(theTime2<10?"0":"")+theTime2+":"+result;
|
}
|
//console.info(result);
|
return result;
|
}
|
|
//计算一个字符串数组的最大值并返回
|
public static double calMaxToArr(String[] arr){
|
double max = 0;
|
if(arr.length > 0){
|
max = Float.parseFloat(arr[0]);
|
for(int i=0;i<arr.length;i++){
|
if(Float.parseFloat(arr[i]) > max){
|
max = Float.parseFloat(arr[i]);
|
}
|
}
|
}
|
return max;
|
}
|
|
//保留指定的位数
|
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[][] 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("单体温度表");
|
}
|
} 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;
|
}
|
|
//System.out.println("data.length"+datas.length+"\t datas[0].length:"+datas[0].length);
|
}
|
}
|
|
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 {
|
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();
|
}
|
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();
|
|
//字体格式-加粗
|
HSSFCellStyle cellStyle = wb.createCellStyle();
|
HSSFFont font = wb.createFont();
|
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
cellStyle.setFont(font);
|
|
//一行一行的填充数据
|
int rowNum = 0;
|
HSSFRow firstRow = sheet.createRow(rowNum++);
|
HSSFCell cell = firstRow.createCell(0);
|
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);
|
anchor.setAnchorType(3);
|
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);
|
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++) {
|
HSSFCell 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++) {
|
HSSFRow 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
|
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();
|
|
//字体格式-加粗
|
HSSFCellStyle cellStyle1 = wb.createCellStyle();
|
HSSFFont font1 = wb.createFont();
|
font1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
cellStyle1.setFont(font1);
|
|
//一行一行的填充数据
|
int rowNum1 = 0;
|
HSSFRow firstRow1 = sheet1.createRow(rowNum1++);
|
HSSFCell cell1 = firstRow1.createCell(0);
|
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);
|
anchor1.setAnchorType(3);
|
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);
|
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++) {
|
HSSFCell 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++) {
|
HSSFRow 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]);
|
}
|
}
|
}
|
|
/*//基准时间
|
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]);
|
}
|
}
|
}
|
|
/*//基准时间
|
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;
|
}*/
|
|
}
|
}
|