| | |
| | | package com.whyc.service; |
| | | |
| | | import com.whyc.bts.*; |
| | | import com.whyc.fbo.FboData; |
| | | import com.whyc.fbo.FboDataHeadStart; |
| | | import com.whyc.fbo.FboDataHeadStop; |
| | | import com.whyc.fbo.FboDataInf; |
| | | import com.whyc.mcp.*; |
| | | import com.whyc.res.RESData; |
| | | import com.whyc.res.RESDataInfo; |
| | | import com.whyc.util.ServletUtils; |
| | |
| | | @Autowired |
| | | private RESDataInfoService resService; |
| | | |
| | | @Autowired |
| | | private TestDataInfoService testDataInfoService; |
| | | |
| | | @Autowired |
| | | private BtsDisChargeService disDataService; |
| | | |
| | | @Autowired |
| | | private BtsChargeDataService chargeDataService; |
| | | |
| | | //导出fbx |
| | | public void exportFbx(HttpServletRequest req, HttpServletResponse resp){ |
| | | |
| | |
| | | |
| | | String filePath = req.getParameter("filePath"); |
| | | FboDataInf fboDataInf=fboService.readFboFile(filePath); |
| | | // if (fboDataInf==null){ |
| | | // fboDataInf = new FboDataInf(); |
| | | // if (filePath==null || "".equals(filePath)){ |
| | | // filePath = fileUrl; |
| | | // } |
| | | // fboDataInf.readFboFile(filePath); |
| | | // } |
| | | //从文件中获取数据 |
| | | List<FboData> list = fboDataInf.fboData; |
| | | //图片base64后的数据 |
| | |
| | | String[] url = cap_echart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | //if (ServletUtils.isNotNull(actualCap_echart)) { |
| | | // String[] url = actualCap_echart.split(","); |
| | | // bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | //} |
| | | if (ServletUtils.isNotNull(vol_echart)) { |
| | | String[] url = vol_echart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | |
| | | //当前日期 |
| | | String nowFormat = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); |
| | | String excelName = "FBX-"+nowFormat; |
| | | //HSSFWorkbook wb = new HSSFWorkbook(); |
| | | //HSSFSheet sheet = wb.createSheet("数据总表"); |
| | | |
| | | XSSFWorkbook wb = new XSSFWorkbook(); |
| | | XSSFSheet sheet = wb.createSheet("数据总表"); |
| | | //图片元素 |
| | | //HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); |
| | | XSSFDrawing patriarch = sheet.createDrawingPatriarch(); |
| | | ////字体格式-加粗 |
| | | //HSSFCellStyle cellStyle = wb.createCellStyle(); |
| | | //HSSFFont font = wb.createFont(); |
| | | //font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); |
| | | //cellStyle.setFont(font); |
| | | |
| | | XSSFDrawing patriarch = sheet.createDrawingPatriarch(); |
| | | int rowNumSheet = 0; |
| | | FboDataHeadStart start = fboDataInf.fboDataStart; |
| | | FboDataHeadStop stop = fboDataInf.fboDataStop; |
| | |
| | | } |
| | | |
| | | XSSFSheet sheet1 = wb.createSheet("数据"); |
| | | //新建行 |
| | | |
| | | //抬头 |
| | | int rowNum = 0; |
| | | sheet1.createRow(rowNum).createCell(0).setCellValue("测试数据"); |
| | | rowNum++; |
| | | |
| | | |
| | | |
| | | |
| | | //属性栏 |
| | | String[] rowName = getRowName(start.DataType); |
| | | XSSFRow row = sheet1.createRow(rowNum); |
| | |
| | | XSSFSheet sheet = wb.createSheet("数据总表"); |
| | | //图片元素 |
| | | XSSFDrawing patriarch = sheet.createDrawingPatriarch(); |
| | | |
| | | int rowNumSheet = 0; |
| | | int rowNumSheet = 1; |
| | | //插入图片 |
| | | int picNum = 0; |
| | | String[] picName =new String[]{"单体电压折线图","单体内阻折线图","单体温度折线图"}; |
| | |
| | | anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE); |
| | | patriarch.createPicture(anchor,wb.addPicture(bytes.get(picNum),XSSFWorkbook.PICTURE_TYPE_PNG)).resize(1); |
| | | picNum ++; |
| | | rowNumSheet+=27; |
| | | rowNumSheet+=30; |
| | | } |
| | | } |
| | | //数据 |
| | | RESDataInfo resDataInfo =resService.readFileData(filePath); |
| | | //从文件中获取数据 |
| | | List<RESData> list = resDataInfo.resDatas; |
| | | XSSFSheet sheet1 = wb.createSheet("内阻数据"); |
| | | //新建行 |
| | | |
| | | int battNum=list.get(0).getBattSum();//单体个数 |
| | | //创建不同sheet |
| | | createBresSheet(wb,battNum,list,1);//创建内阻数据 |
| | | createBresSheet(wb,battNum,list,2);//创建温度数据 |
| | | createBresSheet(wb,battNum,list,3);//创建电压数据 |
| | | try { |
| | | // 转码防止乱码 |
| | | 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(); |
| | | } |
| | | } |
| | | //bres中内阻数据/温度数据/单体电压数据放在不同的sheet中 |
| | | public void createBresSheet(XSSFWorkbook wb,int battNum,List<RESData> list,int type){ |
| | | String sheetName=""; |
| | | String testName=""; |
| | | switch (type){ |
| | | case 1:sheetName= "内阻数据";testName="测试数据(内阻)";break; |
| | | case 2:sheetName= "温度数据";testName="测试数据(温度)";break; |
| | | case 3:sheetName= "电压数据";testName="测试数据(电压)";break; |
| | | } |
| | | XSSFSheet sheet1 = wb.createSheet(sheetName); |
| | | //抬头 |
| | | int rowNum = 0; |
| | | sheet1.createRow(rowNum).createCell(0).setCellValue("测试数据(内阻)"); |
| | | sheet1.createRow(rowNum).createCell(0).setCellValue(testName); |
| | | rowNum++; |
| | | //属性栏 |
| | | String[] rowName =new String[]{"测试时间"}; |
| | | XSSFRow row = sheet1.createRow(rowNum); |
| | | row.createCell(0).setCellValue("测试时间"); |
| | | |
| | | for(int i=0;i<battNum;i++){ |
| | | row.createCell(1+i).setCellValue("#"+Integer.valueOf(i+1)); |
| | | } |
| | | rowNum++; |
| | | float[] datas=new float[]{}; |
| | | //数据栏 |
| | | for (int i = 0; i < list.size(); i++) { |
| | | sheet1.createRow(rowNum); //创建行 |
| | | RESData resData= list.get(i); |
| | | switch (type){ |
| | | case 1:datas= resData.getMonomerRes();break; |
| | | case 2:datas= resData.getMonomerTemp();break; |
| | | case 3:datas= resData.getMonomerVol();break; |
| | | } |
| | | sheet1.getRow(rowNum).createCell(0).setCellValue(formartDate(resData.getData_Time(),"yyyy-MM-dd HH:mm:ss")); |
| | | for (int k = 0;k<battNum;k++){ |
| | | sheet1.getRow(rowNum).createCell(k+1).setCellValue(datas[k]); |
| | | } |
| | | rowNum++; |
| | | } |
| | | rowNum++; |
| | | } |
| | | |
| | | /** |
| | | * 将日期格式转换成指定的字符串格式 |
| | | * @param date 日期 |
| | | * @param str 字符串的格式 |
| | | * @return |
| | | */ |
| | | public static String formartDate(Date date, String str){ |
| | | return new SimpleDateFormat(str).format(date); |
| | | } |
| | | |
| | | |
| | | |
| | | //导出mch,mcp |
| | | public void exportMcph(HttpServletRequest req, HttpServletResponse resp){ |
| | | String volEchart = req.getParameter("vol_echart"); //单体电压折线图 |
| | | String currEchart = req.getParameter("curr_echart"); //电池电流折线图 |
| | | String groupVolEchart = req.getParameter("groupVol_echart"); //组端电压折线图 |
| | | String capEchart = req.getParameter("cap_echart"); //测试容量折线图 |
| | | String filePath = req.getParameter("filePath"); |
| | | //数据 |
| | | TestDataInfo testDataInfoMcp=testDataInfoService.readFileData(filePath); |
| | | MonitorDataInfo info = testDataInfoMcp.monitorDataInfo;//组端数据 |
| | | |
| | | //图片base64后的数据 |
| | | List<byte[]> bytes = new ArrayList<>(); |
| | | try { |
| | | if (ServletUtils.isNotNull(volEchart)) { |
| | | String[] url = volEchart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | if (ServletUtils.isNotNull(currEchart)) { |
| | | String[] url = currEchart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | if (ServletUtils.isNotNull(groupVolEchart)) { |
| | | String[] url = groupVolEchart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | if (ServletUtils.isNotNull(capEchart)) { |
| | | String[] url = capEchart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | //当前日期 |
| | | String nowFormat = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); |
| | | String excelName =""; |
| | | int fileType=testDataInfoMcp.getFile_type(); |
| | | if(fileType==0xFA){ |
| | | excelName="MCP-"+nowFormat; |
| | | }else{ |
| | | excelName="MCH-"+nowFormat; |
| | | } |
| | | XSSFWorkbook wb = new XSSFWorkbook(); |
| | | XSSFSheet sheet = wb.createSheet("数据总表"); |
| | | //图片元素 |
| | | XSSFDrawing patriarch = sheet.createDrawingPatriarch(); |
| | | BattParam battParam=info.battparam;//电池参数 |
| | | SYSMonitorParam sysParam=info.monitorparam;//组端参数 |
| | | SYSMonitorState sysState=info.monitorstate;//组端状态 |
| | | int rowNumSheet = 0; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("电池参数:"); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("标称容量(1AH):"+battParam.STD_CAP); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("标称内阻(0.001mΩ):"+battParam.STD_RES); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("单体标称电压(0.1V):"+battParam.monomerVol); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("组数:"+battParam.battGroupCount); |
| | | |
| | | int battNum=battParam.eachGroupBattCount;//单体个数 |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("每组单体个数:"+battNum); |
| | | rowNumSheet++; |
| | | |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("组端参数:"); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("放电电流:"+sysParam.disCurr); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("放电容量:"+sysParam.disCap); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("放电时长:"+sysParam.disTime); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("组端下限:"+sysParam.groupVol_LOW); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("单体下限:"+sysParam.monomerVol_LOW); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("下限个数:"+sysParam.monomerLowCount); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("充电电流:"+sysParam.chrCurr); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("充电容量:"+sysParam.chrCap); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("充电时长:"+sysParam.chrTime); |
| | | rowNumSheet++; |
| | | |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("组端状态:"); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("启动放电的日期时间:"+formartDate(sysState.startDT.time,"yyyy-MM-dd HH:mm:ss")); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("终止放电的日期时间:"+formartDate(sysState.stopDT.time,"yyyy-MM-dd HH:mm:ss")); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("已测试时间(HMS):"+sysState.test_Time.testTime); |
| | | |
| | | rowNumSheet+=4; |
| | | //插入图片 |
| | | int picNum = 0; |
| | | String[] picName =new String[]{"单体电压折线图","电池电流折线图","组端电压折线图","测试容量折线图"}; |
| | | if (picName.length==bytes.size()){ |
| | | for(int i=0;i<picName.length;i++){ |
| | | sheet.createRow(rowNumSheet-1); |
| | | sheet.getRow(rowNumSheet-1).createCell(0).setCellValue(picName[i]); |
| | | //rowNum++; |
| | | XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 512, 255,(short) 0, rowNumSheet, (short) 10, rowNumSheet+27); |
| | | anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE); |
| | | patriarch.createPicture(anchor,wb.addPicture(bytes.get(picNum),XSSFWorkbook.PICTURE_TYPE_PNG)).resize(1); |
| | | picNum ++; |
| | | rowNumSheet+=30; |
| | | } |
| | | } |
| | | |
| | | //从文件中获取数据 |
| | | List<FBSData> list=testDataInfoMcp.fbsDatas;//充放电数据 |
| | | String sheetName="放电数据"; |
| | | String testName="测试数据"; |
| | | XSSFSheet sheet1 = wb.createSheet(sheetName); |
| | | //抬头 |
| | | int rowNum = 0; |
| | | sheet1.createRow(rowNum).createCell(0).setCellValue(testName); |
| | | rowNum++; |
| | | |
| | | XSSFRow row = sheet1.createRow(rowNum); |
| | | //属性栏 |
| | | String[] rowName =new String[]{"测试时间","在线电压","组端电压","电池电流","电池容量","电池温度"}; |
| | | for (int i=0;i<rowName.length;i++){ |
| | | row.createCell(i).setCellValue(rowName[i]); |
| | | } |
| | | int battNum=list.get(0).getBattSum();//单体个数 |
| | | for(int i=0;i<battNum;i++){ |
| | | row.createCell(rowName.length+i).setCellValue("#"+Integer.valueOf(i+1)); |
| | | row.createCell(6+i).setCellValue("#"+Integer.valueOf(i+1)); |
| | | } |
| | | rowNum++; |
| | | //数据栏 |
| | | for (int i = 0; i < list.size(); i++) { |
| | | sheet1.createRow(rowNum); //创建行 |
| | | RESData resData=list.get(i); |
| | | float[] monomerRes=resData.getMonomerRes(); |
| | | sheet1.getRow(rowNum).createCell(0).setCellValue(resData.getData_Time()); |
| | | FBSData fbsData= list.get(i); |
| | | sheet1.getRow(rowNum).createCell(0).setCellValue(fbsData.testTime.testTime); |
| | | sheet1.getRow(rowNum).createCell(1).setCellValue(fbsData.vcData.onlinevol[0]); |
| | | sheet1.getRow(rowNum).createCell(2).setCellValue(fbsData.vcData.groupvol[0]); |
| | | sheet1.getRow(rowNum).createCell(3).setCellValue(fbsData.vcData.battcurr[0]); |
| | | sheet1.getRow(rowNum).createCell(4).setCellValue(fbsData.vcData.battcap[0]); |
| | | sheet1.getRow(rowNum).createCell(5).setCellValue(fbsData.vcData.batttemp[0]); |
| | | float[] datas=fbsData.mvol.vol; |
| | | for (int k = 0;k<battNum;k++){ |
| | | sheet1.getRow(rowNum).createCell(k+1).setCellValue(monomerRes[i]); |
| | | sheet1.getRow(rowNum).createCell(k+6).setCellValue(datas[k]); |
| | | } |
| | | rowNum++; |
| | | } |
| | | rowNum++; |
| | | |
| | | try { |
| | | // 转码防止乱码 |
| | | 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(); |
| | | } |
| | | } |
| | | //导出bts的放电数据bcp |
| | | public void exportBcp(HttpServletRequest req, HttpServletResponse resp) { |
| | | String volEchart = req.getParameter("vol_echart"); //单体电压折线图 |
| | | String currEchart = req.getParameter("curr_echart"); //电池电流折线图 |
| | | String groupVolEchart = req.getParameter("groupVol_echart"); //组端电压折线图 |
| | | String online_echart = req.getParameter("online_echart"); //在线电压折线图 |
| | | String filePath = req.getParameter("filePath"); |
| | | //图片base64后的数据 |
| | | List<byte[]> bytes = new ArrayList<>(); |
| | | try { |
| | | if (ServletUtils.isNotNull(volEchart)) { |
| | | String[] url = volEchart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | if (ServletUtils.isNotNull(currEchart)) { |
| | | String[] url = currEchart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | if (ServletUtils.isNotNull(groupVolEchart)) { |
| | | String[] url = groupVolEchart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | if (ServletUtils.isNotNull(online_echart)) { |
| | | String[] url = online_echart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | //当前日期 |
| | | String nowFormat = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); |
| | | String excelName="BCP-"+nowFormat; |
| | | //数据 |
| | | BTS_DisChargeData disData=disDataService.getDisData(filePath); |
| | | BTS_BattParam btsbattParam = disData.battParam;//电池参数 |
| | | BTS_DischargeParam btsdisParam=disData.dischargeParam;//放电参数 |
| | | BTS_CapState btscapState=disData.capState;//放电时长 |
| | | XSSFWorkbook wb = new XSSFWorkbook(); |
| | | XSSFSheet sheet = wb.createSheet("数据总表"); |
| | | //图片元素 |
| | | XSSFDrawing patriarch = sheet.createDrawingPatriarch(); |
| | | int rowNumSheet = 0; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("电池参数:"); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("标称容量(1AH):"+btsbattParam.STD_CAP); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("标称内阻(0.001mΩ):"+btsbattParam.STD_RES); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("单体标称电压(0.1V):"+btsbattParam.MonomerVol); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("组数:"+btsbattParam.BattGroupCount); |
| | | |
| | | int battNum=btsbattParam.EachGroupBattCount;//单体个数 |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("每组单体个数:"+battNum); |
| | | rowNumSheet++; |
| | | |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("组端参数:"); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("放电电流:"+btsdisParam.DisCurr); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("放电容量:"+btsdisParam.DisCap); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("放电时长:"+btsdisParam.DisTime); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("升压上限:"+btsdisParam.DCVolHighLimit); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("温度上限:"+btsdisParam.MonomerTmp_High); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("组端下限:"+btsdisParam.GroupVol_LOW); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("单体下限:"+btsdisParam.MonomerVol_LOW); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("下限个数:"+btsdisParam.MonomerLowCount); |
| | | rowNumSheet++; |
| | | |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("组端状态:"); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("启动放电的日期时间:"+formartDate(btscapState.StartDT.getDateTime(),"yyyy-MM-dd HH:mm:ss")); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("终止放电的日期时间:"+formartDate(btscapState.StopDT.getDateTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("已测试时间(HMS):"+btscapState.Test_Time.testTime); |
| | | |
| | | rowNumSheet+=4; |
| | | //插入图片 |
| | | int picNum = 0; |
| | | String[] picName =new String[]{"单体电压折线图","电池电流折线图","组端电压折线图","在线电压折线图"}; |
| | | if (picName.length==bytes.size()){ |
| | | for(int i=0;i<picName.length;i++){ |
| | | sheet.createRow(rowNumSheet-1); |
| | | sheet.getRow(rowNumSheet-1).createCell(0).setCellValue(picName[i]); |
| | | //rowNum++; |
| | | XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 512, 255,(short) 0, rowNumSheet, (short) 10, rowNumSheet+27); |
| | | anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE); |
| | | patriarch.createPicture(anchor,wb.addPicture(bytes.get(picNum),XSSFWorkbook.PICTURE_TYPE_PNG)).resize(1); |
| | | picNum ++; |
| | | rowNumSheet+=30; |
| | | } |
| | | } |
| | | |
| | | //从文件中获取数据 |
| | | List<BTS_FbsData> list=disData.fbsDatas;//放电数据 |
| | | String sheetName="放电数据"; |
| | | String testName="测试数据"; |
| | | XSSFSheet sheet1 = wb.createSheet(sheetName); |
| | | //抬头 |
| | | int rowNum = 0; |
| | | sheet1.createRow(rowNum).createCell(0).setCellValue(testName); |
| | | rowNum++; |
| | | |
| | | XSSFRow row = sheet1.createRow(rowNum); |
| | | //属性栏 |
| | | String[] rowName =new String[]{"测试时间","在线电压","组端电压","电池电流","电池容量","电池温度"}; |
| | | for (int i=0;i<rowName.length;i++){ |
| | | row.createCell(i).setCellValue(rowName[i]); |
| | | } |
| | | for(int i=0;i<battNum;i++){ |
| | | row.createCell(6+i).setCellValue("#"+Integer.valueOf(i+1)); |
| | | } |
| | | rowNum++; |
| | | //数据栏 |
| | | for (int i = 0; i < list.size(); i++) { |
| | | sheet1.createRow(rowNum); //创建行 |
| | | BTS_FbsData fbsData= list.get(i); |
| | | sheet1.getRow(rowNum).createCell(0).setCellValue(fbsData.testTime.testTime); |
| | | sheet1.getRow(rowNum).createCell(1).setCellValue(fbsData.onlinevol[0]); |
| | | sheet1.getRow(rowNum).createCell(2).setCellValue(fbsData.groupvol[0]); |
| | | sheet1.getRow(rowNum).createCell(3).setCellValue(fbsData.battcurr[0]); |
| | | sheet1.getRow(rowNum).createCell(4).setCellValue(fbsData.battcap[0]); |
| | | sheet1.getRow(rowNum).createCell(5).setCellValue(fbsData.batttemp[0]); |
| | | double[] datas=fbsData.vol; |
| | | for (int k = 0;k<battNum;k++){ |
| | | sheet1.getRow(rowNum).createCell(k+6).setCellValue(datas[k]); |
| | | } |
| | | rowNum++; |
| | | } |
| | | rowNum++; |
| | | |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | //导出bts的充电数据chr |
| | | public void exportChr(HttpServletRequest req, HttpServletResponse resp) { |
| | | String volEchart = req.getParameter("vol_echart"); //单体电压折线图 |
| | | String currEchart = req.getParameter("curr_echart"); //电池电流折线图 |
| | | String groupVolEchart = req.getParameter("groupVol_echart"); //组端电压折线图 |
| | | String online_echart = req.getParameter("online_echart"); //在线电压折线图 |
| | | String filePath = req.getParameter("filePath"); |
| | | //图片base64后的数据 |
| | | List<byte[]> bytes = new ArrayList<>(); |
| | | try { |
| | | if (ServletUtils.isNotNull(volEchart)) { |
| | | String[] url = volEchart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | if (ServletUtils.isNotNull(currEchart)) { |
| | | String[] url = currEchart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | if (ServletUtils.isNotNull(groupVolEchart)) { |
| | | String[] url = groupVolEchart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | if (ServletUtils.isNotNull(online_echart)) { |
| | | String[] url = online_echart.split(","); |
| | | bytes.add(new BASE64Decoder().decodeBuffer(url[1])); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | //当前日期 |
| | | String nowFormat = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); |
| | | String excelName="CHR-"+nowFormat; |
| | | //数据 |
| | | BTS_ChargeData chargeData=chargeDataService.getChrData(filePath); |
| | | BTS_BattParam btsbattParam = chargeData.battParam;//电池参数 |
| | | BTS_ChargeParam btschargeParam=chargeData.chargeParam;//放电参数 |
| | | BTS_ChargeState btschargeState=chargeData.charState;//放电时长 |
| | | XSSFWorkbook wb = new XSSFWorkbook(); |
| | | XSSFSheet sheet = wb.createSheet("数据总表"); |
| | | //图片元素 |
| | | XSSFDrawing patriarch = sheet.createDrawingPatriarch(); |
| | | int rowNumSheet = 0; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("电池参数:"); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("标称容量(1AH):"+btsbattParam.STD_CAP); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("标称内阻(0.001mΩ):"+btsbattParam.STD_RES); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("单体标称电压(0.1V):"+btsbattParam.MonomerVol); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("组数:"+btsbattParam.BattGroupCount); |
| | | |
| | | /** |
| | | * 将日期格式转换成指定的字符串格式 |
| | | * @param date 日期 |
| | | * @param str 字符串的格式 |
| | | * @return |
| | | */ |
| | | public static String formartDate(Date date, String str){ |
| | | return new SimpleDateFormat(str).format(date); |
| | | int battNum=btsbattParam.EachGroupBattCount;//单体个数 |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("每组单体个数:"+battNum); |
| | | rowNumSheet++; |
| | | |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("组端参数:"); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("充电电流:"+btschargeParam.ChargeCurr); |
| | | rowNumSheet++; |
| | | |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("组端状态:"); |
| | | rowNumSheet++; |
| | | sheet.createRow(rowNumSheet); |
| | | sheet.getRow(rowNumSheet).createCell(0).setCellValue("启动放电的日期时间:"+formartDate(btschargeState.StartDT.getDateTime(),"yyyy-MM-dd HH:mm:ss")); |
| | | sheet.getRow(rowNumSheet).createCell(1).setCellValue("终止放电的日期时间:"+formartDate(btschargeState.StopDT.getDateTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | sheet.getRow(rowNumSheet).createCell(2).setCellValue("已测试时间(HMS):"+btschargeState.Test_Time.testTime); |
| | | |
| | | rowNumSheet+=4; |
| | | //插入图片 |
| | | int picNum = 0; |
| | | String[] picName =new String[]{"单体电压折线图","电池电流折线图","组端电压折线图","在线电压折线图"}; |
| | | if (picName.length==bytes.size()){ |
| | | for(int i=0;i<picName.length;i++){ |
| | | sheet.createRow(rowNumSheet-1); |
| | | sheet.getRow(rowNumSheet-1).createCell(0).setCellValue(picName[i]); |
| | | //rowNum++; |
| | | XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 512, 255,(short) 0, rowNumSheet, (short) 10, rowNumSheet+27); |
| | | anchor.setAnchorType(ClientAnchor.AnchorType.DONT_MOVE_AND_RESIZE); |
| | | patriarch.createPicture(anchor,wb.addPicture(bytes.get(picNum),XSSFWorkbook.PICTURE_TYPE_PNG)).resize(1); |
| | | picNum ++; |
| | | rowNumSheet+=30; |
| | | } |
| | | } |
| | | |
| | | //从文件中获取数据 |
| | | List<BTS_FbsData> list=chargeData.fbsDatas;//放电数据 |
| | | String sheetName="充电数据"; |
| | | String testName="测试数据"; |
| | | XSSFSheet sheet1 = wb.createSheet(sheetName); |
| | | //抬头 |
| | | int rowNum = 0; |
| | | sheet1.createRow(rowNum).createCell(0).setCellValue(testName); |
| | | rowNum++; |
| | | |
| | | XSSFRow row = sheet1.createRow(rowNum); |
| | | //属性栏 |
| | | String[] rowName =new String[]{"测试时间","在线电压","组端电压","电池电流","电池容量","电池温度"}; |
| | | for (int i=0;i<rowName.length;i++){ |
| | | row.createCell(i).setCellValue(rowName[i]); |
| | | } |
| | | for(int i=0;i<battNum;i++){ |
| | | row.createCell(6+i).setCellValue("#"+Integer.valueOf(i+1)); |
| | | } |
| | | rowNum++; |
| | | //数据栏 |
| | | for (int i = 0; i < list.size(); i++) { |
| | | sheet1.createRow(rowNum); //创建行 |
| | | BTS_FbsData fbsData= list.get(i); |
| | | sheet1.getRow(rowNum).createCell(0).setCellValue(fbsData.testTime.testTime); |
| | | sheet1.getRow(rowNum).createCell(1).setCellValue(fbsData.onlinevol[0]); |
| | | sheet1.getRow(rowNum).createCell(2).setCellValue(fbsData.groupvol[0]); |
| | | sheet1.getRow(rowNum).createCell(3).setCellValue(fbsData.battcurr[0]); |
| | | sheet1.getRow(rowNum).createCell(4).setCellValue(fbsData.battcap[0]); |
| | | sheet1.getRow(rowNum).createCell(5).setCellValue(fbsData.batttemp[0]); |
| | | double[] datas=fbsData.vol; |
| | | for (int k = 0;k<battNum;k++){ |
| | | sheet1.getRow(rowNum).createCell(k+6).setCellValue(datas[k]); |
| | | } |
| | | rowNum++; |
| | | } |
| | | rowNum++; |
| | | |
| | | try { |
| | | // 转码防止乱码 |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | } |