| | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | @Service |
| | | public class ExcelService { |
| | |
| | | //创建一个工作簿 |
| | | XSSFWorkbook workbook = new XSSFWorkbook(); |
| | | //创建sheet1 |
| | | //createSheet1(workbook,battGroupId,testRecordCount); |
| | | createSheet1(workbook,battGroupId,testRecordCount); |
| | | //创建sheet2 -- 每月电压,12个月,取每月1号零点零分 |
| | | //创建sheet3 -- 每月内阻, 12个月,取每月1号零点零分 |
| | | createSheet2And3(workbook,battGroupId); |
| | | //createSheet2And3(workbook,battGroupId); |
| | | //创建sheet4 -- 每天温度, 30天, 取每天零点零分 |
| | | createSheet4(workbook,battGroupId); |
| | | //createSheet4(workbook,battGroupId); |
| | | |
| | | // 将工作簿写入文件 |
| | | FileOutputStream fileOut = new FileOutputStream(filePath); |
| | |
| | | |
| | | |
| | | // 创建绘图工具 |
| | | createChart(sheet2, columnCount,"电压折线图"); |
| | | createChart(sheet3, columnCount,"内阻折线图"); |
| | | createChart(sheet2, columnCount,3,"电压折线图"); |
| | | createChart(sheet3, columnCount,3,"内阻折线图"); |
| | | |
| | | } |
| | | |
| | | private void createChart(XSSFSheet sheet2, int columnCount, String titleTextSuffix) { |
| | | private void createChart(XSSFSheet sheet2, int columnCount,int rowStartIndex, String titleTextSuffix) { |
| | | XSSFDrawing drawing = sheet2.createDrawingPatriarch(); |
| | | //108个单体,10个单体一个图标 |
| | | int chartCol = 1; |
| | |
| | | XDDFLineChartData dataChart = (XDDFLineChartData) chart.createData(ChartTypes.LINE, categoryAxis, valueAxis); |
| | | for (int j = i ; j < i+10; j++) { |
| | | if(j<104) { |
| | | XDDFNumericalDataSource<Double> ys = XDDFDataSourcesFactory.fromNumericCellRange(sheet2, new CellRangeAddress(j + 3, j + 3, 1, columnCount -2)); |
| | | XDDFNumericalDataSource<Double> ys = XDDFDataSourcesFactory.fromNumericCellRange(sheet2, new CellRangeAddress(j + rowStartIndex, j + rowStartIndex, 1, columnCount -2)); |
| | | XDDFLineChartData.Series series = (XDDFLineChartData.Series) dataChart.addSeries(xs, ys); |
| | | //选择布局1 |
| | | series.setTitle(((XSSFRow) sheet2.getRow(j + 3)).getCell(0).getStringCellValue(), new CellReference(sheet2.getSheetName(), j + 3, 0, true, true)); |
| | | series.setTitle(((XSSFRow) sheet2.getRow(j + 6)).getCell(0).getStringCellValue(), new CellReference(sheet2.getSheetName(), j + rowStartIndex, 0, true, true)); |
| | | series.setMarkerStyle(MarkerStyle.CIRCLE); // 设置标记点 |
| | | } |
| | | |
| | |
| | | XSSFCell cellOfSheet4 = sheet4.createRow(0).createCell(0); |
| | | cellOfSheet4.setCellValue( battInfo.getPowerName()+ battInfo.getBattGroupName()+"温度数据"); |
| | | |
| | | int columnCount = 2; |
| | | //30天+2列其他列 |
| | | int columnCount = 30+2; |
| | | //查询历史实时表. 存在的月份. 如果存在的话,取第一笔记录(104条) |
| | | //首先查询当前月份对应的日期 |
| | | List<String> tableListLike = commonMapper.getTableListLike("db_power_history", "tb_batt_realdata_"+battGroupId); |
| | | //当前月份往前推11个月 |
| | | //获取当前日期往前30天的凌晨零秒的数据. 往前推30天 |
| | | List<String> tableListInDB = new ArrayList<>(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | for (int i = 0; i < 12; i++) { |
| | | int year = calendar.get(Calendar.YEAR); |
| | | int month = calendar.get(Calendar.MONTH) + 1; |
| | | String monthStr; |
| | | if (month < 10) { |
| | | monthStr = "0" + month; |
| | | } else { |
| | | monthStr = String.valueOf(month); |
| | | } |
| | | if (tableListLike.contains("tb_batt_realdata_" + battGroupId + "_" + year + "_" + monthStr)) { |
| | | //存在,列数+1 |
| | | columnCount++; |
| | | tableListInDB.add("tb_batt_realdata_" + battGroupId + "_" + year + "_" + monthStr); |
| | | } |
| | | calendar.add(Calendar.MONTH, -1); |
| | | int year = calendar.get(Calendar.YEAR); |
| | | int month = calendar.get(Calendar.MONTH) + 1; |
| | | String monthStr; |
| | | if (month < 10) { |
| | | monthStr = "0" + month; |
| | | } else { |
| | | monthStr = String.valueOf(month); |
| | | } |
| | | //当前时间往前30天 |
| | | calendar.add(Calendar.DAY_OF_MONTH, -30); |
| | | Date timeAgo = calendar.getTime(); |
| | | int yearAgo = calendar.get(Calendar.YEAR); |
| | | int monthAgo = calendar.get(Calendar.MONTH) + 1; |
| | | String monthAgoStr; |
| | | if (monthAgo < 10) { |
| | | monthAgoStr = "0" + (monthAgo); |
| | | } else { |
| | | monthAgoStr = String.valueOf(monthAgo); |
| | | } |
| | | String tableName = "tb_batt_realdata_" + battGroupId + "_" + year + "_" + monthStr; |
| | | //30天前的时间 |
| | | String tableNameAgo = "tb_batt_realdata_" + battGroupId + "_" + yearAgo + "_" + monthAgoStr; |
| | | if (tableListLike.contains(tableName)) { |
| | | tableListInDB.add(tableName); |
| | | } |
| | | if (tableListLike.contains(tableNameAgo)) { |
| | | tableListInDB.add(tableNameAgo); |
| | | } |
| | | |
| | | //获取所有数据 |
| | | List<BattRealTimeDataHistory> dataList = new ArrayList<>(); |
| | | for (int i = 0; i < tableListInDB.size(); i++) { |
| | | String tableNameTmp = tableListInDB.get(i); |
| | | List<BattRealTimeDataHistory> list; |
| | | if(tableNameTmp.equals(tableName)){ |
| | | list = battRTDataHisService.getFirstRecordListOfDay(tableNameTmp, null); |
| | | }else{ |
| | | //说明是上个月的记录,需要记录时间大于30天前的时间 |
| | | list = battRTDataHisService.getFirstRecordListOfDay(tableNameTmp, timeAgo); |
| | | } |
| | | dataList.addAll(list); |
| | | } |
| | | //按时间排序和分组 |
| | | dataList.sort(Comparator.comparing(BattRealTimeDataHistory::getRecordTime)); |
| | | Map<Date, List<BattRealTimeDataHistory>> dataListMap = dataList.stream().collect(Collectors.groupingBy(BattRealTimeDataHistory::getRecordTime)); |
| | | Set<Date> dateKeySet = dataListMap.keySet(); |
| | | dataListMap.forEach((key,data)->{ |
| | | addStatistics(data, "tmp"); |
| | | }); |
| | | //给列数赋值 |
| | | columnCount = dateKeySet.size()+2; |
| | | |
| | | //列根据实际情况变动 |
| | | sheet4.addMergedRegion(new CellRangeAddress(0, 0, 0, columnCount-1)); |
| | |
| | | if(j==0){ |
| | | sheet4.setColumnWidth(j, 170 * 20); |
| | | }else { |
| | | sheet4.setColumnWidth(j, 128 * 20); |
| | | sheet4.setColumnWidth(j, 138 * 20); |
| | | } |
| | | } |
| | | //行宽 |
| | |
| | | } else if (i == 107) { |
| | | sheet4.createRow(i + 2).createCell(0).setCellValue("单节最小温度"); |
| | | }else if (i == 108) { |
| | | sheet4.createRow(i + 2).createCell(0).setCellValue("单节最大温度"); |
| | | sheet4.createRow(i + 2).createCell(0).setCellValue("单节最大差值"); |
| | | } |
| | | } |
| | | } |
| | | //创建第三行 |
| | | XSSFRow row2OfSheet4 = sheet4.createRow(2); |
| | | |
| | | row2OfSheet4.setHeightInPoints(40); |
| | | sheet4.getRow(0).createCell(columnCount-1); |
| | | for (int i = 0; i <= tableListInDB.size(); i++) { //这个是列的遍历 |
| | | if (i == tableListInDB.size()) { |
| | | //最后一列备注:全部填空 |
| | | row2OfSheet4.createCell(i + 1); |
| | | for (int j = 1; j <= 108; j++) { //这个是行的遍历 |
| | | sheet4.getRow(j + 2).createCell(i + 1); |
| | | } |
| | | } else { |
| | | //获取数据 |
| | | List<BattRealTimeDataHistory> list = battRTDataHisService.getFirstRecordList(tableListInDB.get(i)); |
| | | list.sort(Comparator.comparing(BattRealTimeDataHistory::getMonNum)); |
| | | //第三行的时间列填充 |
| | | Date testStartTime = list.get(0).getTestStartTime(); |
| | | //获取年月 |
| | | String testMonth = DateUtil.YYYY_DOT_MM.format(testStartTime); |
| | | row2OfSheet4.createCell(i + 1).setCellValue(testMonth); |
| | | addStatistics(list, "vol", "res"); |
| | | for (int j = 1; j <= 108; j++) { //这个是行的遍历 |
| | | sheet4.getRow(j + 2).createCell(i + 1).setCellValue((list.get(j - 1).getMonVol())); |
| | | } |
| | | |
| | | //填充数据列,key是列日期. value是列数据 |
| | | AtomicInteger count = new AtomicInteger(); |
| | | //对dateKeySet按时间排序 |
| | | Stream<Date> dateKeySetSorted = dateKeySet.stream().sorted(Comparator.comparing(Date::getTime)); |
| | | dateKeySetSorted.forEach(key -> { |
| | | List<BattRealTimeDataHistory> value = dataListMap.get(key); |
| | | //第三行时间列填充 |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd\nHH:mm:ss"); |
| | | row2OfSheet4.createCell(count.get() + 1).setCellValue(format.format(key)); |
| | | for (int j = 1; j <= 108; j++) { //这个是行的遍历 |
| | | sheet4.getRow(j + 2).createCell(count.get() + 1).setCellValue(value.get(j - 1).getMonTmp()); |
| | | } |
| | | count.getAndIncrement(); |
| | | }); |
| | | //最后一列备注:全部填空 |
| | | row2OfSheet4.createCell(columnCount-1); |
| | | for (int j = 1; j <= 108; j++) { //这个是行的遍历 |
| | | sheet4.getRow(j + 2).createCell(columnCount-1); |
| | | } |
| | | |
| | | addGlobalStylesToAllCells(sheet4, workbook); |
| | |
| | | XSSFCellStyle cellStyleNew = getCellStyleFont(cellStyleOriginal,workbook, true, 15); |
| | | cellOfSheet4.setCellStyle(cellStyleNew); |
| | | |
| | | createChart(sheet4, columnCount,"温度折线图"); |
| | | //第三行 所有列水平垂直居中,自动换行 |
| | | for (int i = 1; i < columnCount; i++) { |
| | | XSSFCell cell = sheet4.getRow(2).getCell(i); |
| | | XSSFCellStyle cellStyle = cell.getCellStyle(); |
| | | cellStyle.setAlignment(HorizontalAlignment.CENTER); |
| | | cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); |
| | | cellStyle.setWrapText(true); |
| | | cell.setCellStyle(cellStyle); |
| | | } |
| | | |
| | | createChart(sheet4, columnCount,3,"温度折线图"); |
| | | |
| | | } |
| | | public CTValAx getCTValAx(XDDFValueAxis valueAxis, XSSFChart chart) { |
| | |
| | | CellRangeAddress region25 = new CellRangeAddress(1, 1, 18, 24); |
| | | sheet.addMergedRegion(region25); |
| | | |
| | | //第三行的合并列 |
| | | CellRangeAddress region31 = new CellRangeAddress(2, 2, 1, 2); |
| | | CellRangeAddress region32 = new CellRangeAddress(2, 2, 3, 4); |
| | | CellRangeAddress region33 = new CellRangeAddress(2, 2, 5, 6); |
| | | CellRangeAddress region34 = new CellRangeAddress(2, 2, 7, 8); |
| | | //第三行的合并列,前两个单元模块是固定的,其中1个合并单元 |
| | | CellRangeAddress region31 = new CellRangeAddress(2, 2, 2, 3); |
| | | sheet.addMergedRegion(region31); |
| | | sheet.addMergedRegion(region32); |
| | | sheet.addMergedRegion(region33); |
| | | sheet.addMergedRegion(region34); |
| | | |
| | | |
| | | // 创建居中样式 |
| | | CellStyle style = workbook.createCellStyle(); |
| | |
| | | //setRowStyle(sheet.getRow(1),cellStyleFontBold); |
| | | |
| | | //第三行是电池号和电压等相关抬头 |
| | | //第四行是电压列和温度列标识 |
| | | XSSFRow row2 = sheet.createRow(2); |
| | | XSSFRow row3 = sheet.createRow(3); |
| | | row2.createCell(0).setCellValue("蓄电池号(#)"); |
| | | row2.createCell(1).setCellValue("蓄电池浮充电压值(V)"); |
| | | row2.createCell(3).setCellValue("放电前蓄电池开路电压值(V)"); |
| | | row2.createCell(2).setCellValue("放电前蓄电池开路电压值(V)"); |
| | | |
| | | row3.createCell(0).setCellValue("项目"); |
| | | row3.createCell(1).setCellValue("-1(电压)"); |
| | | row3.createCell(2).setCellValue("0(电压)"); |
| | | row3.createCell(3).setCellValue("0(温度)"); |
| | | |
| | | //放电特定电压值 |
| | | int columnIndex = 3; |
| | | if(dischargeColumnCount > 0){ |
| | | row2.createCell(5).setCellValue("放电0.5h蓄电池电压值(V)"); |
| | | CellRangeAddress region33 = new CellRangeAddress(2, 2, 4, 5); |
| | | sheet.addMergedRegion(region33); |
| | | row3.createCell(4).setCellValue("0.5(电压)"); |
| | | row3.createCell(5).setCellValue("0.5(温度)"); |
| | | columnIndex+=2; |
| | | if(dischargeColumnCount > 2){ //合并单元格了,所以索引+2 |
| | | row2.createCell(7).setCellValue("放电1h蓄电池电压值(V)"); |
| | | CellRangeAddress region34 = new CellRangeAddress(2, 2, 6, 7); |
| | | sheet.addMergedRegion(region34); |
| | | row3.createCell(6).setCellValue("1(电压)"); |
| | | row3.createCell(7).setCellValue("1(温度)"); |
| | | columnIndex+=2; |
| | | if(dischargeColumnCount > 4){ |
| | | columnIndex++; |
| | | //放电nh蓄电池电压值(V),n从2开始 |
| | | for(int i = 4;i < dischargeColumnCount;i++){ |
| | | row2.createCell(i+5).setCellValue("放电" + (i-2) + "h蓄电池电压值(V)"); |
| | | row3.createCell(i+5).setCellValue(String.valueOf(i-2)); |
| | | columnIndex++; |
| | | } |
| | | |
| | |
| | | |
| | | //充电特定电压值 |
| | | row2.createCell(++columnIndex).setCellValue("放电结束0.5h后蓄电池开路电压值(V)"); |
| | | row3.createCell(columnIndex).setCellValue("10.5"); |
| | | if(chargeColumnCount > 0){ |
| | | columnIndex++; |
| | | row2.createCell(columnIndex).setCellValue("充电0.5h"); |
| | |
| | | for(int i = 1;i < chargeColumnCount;i++){ |
| | | columnIndex++; |
| | | row2.createCell(columnIndex).setCellValue("充电" + (i) + "h蓄电池电压值(V)"); |
| | | row3.createCell(columnIndex);//填充单元格的作用 |
| | | } |
| | | |
| | | } |
| | | } |
| | | row2.createCell(++columnIndex).setCellValue("充满后蓄电池电压值(V)(电流为0)"); |
| | | row3.createCell(columnIndex).setCellValue("11"); |
| | | row2.createCell(++columnIndex).setCellValue("备注"); |
| | | row3.createCell(columnIndex);//填充单元格的作用 |
| | | |
| | | |
| | | //从rowIndex=6开始 |
| | | int rowIndex = 6; |
| | | |
| | | //从rowIndex=4开始 |
| | | int rowIndex = 4; |
| | | // 共104节单体,104行. 进行遍历,填充 |
| | | //蓄电池浮充电压值列表 |
| | | List<BattRealTimeDataHistory> fcVolList = new ArrayList<>(); |
| | | fcVolList = battRTDataHisService.getFcVolList(battGroupId,dischargeStartTime); |
| | | List<BattRealTimeDataHistory> fcVolListOriginal = battRTDataHisService.getFcVolList(battGroupId,dischargeStartTime); |
| | | //按单体编号排序,按编号升序 |
| | | fcVolList.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum)); |
| | | fcVolListOriginal.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum)); |
| | | addStatistics(fcVolListOriginal,"vol"); |
| | | //总电流总电压列入 |
| | | Float fcGroupVol = fcVolListOriginal.get(0).getGroupVol(); |
| | | Float fcGroupCurr = fcVolListOriginal.get(0).getGroupCurr(); |
| | | |
| | | BattRealTimeDataHistory fcGroupVolData = new BattRealTimeDataHistory(); |
| | | fcGroupVolData.setMonNum(-2); |
| | | fcGroupVolData.setGroupVol(fcGroupVol); |
| | | |
| | | BattRealTimeDataHistory fcGroupCurrData = new BattRealTimeDataHistory(); |
| | | fcGroupCurrData.setMonNum(-1); |
| | | fcGroupCurrData.setGroupCurr(fcGroupCurr); |
| | | |
| | | fcVolList.add(fcGroupVolData); |
| | | fcVolList.add(fcGroupCurrData); |
| | | fcVolList.addAll(fcVolListOriginal); |
| | | |
| | | //放点前蓄电池开路电压值 |
| | | List<BattRealTimeDataHistory> preVolList = new ArrayList<>(); |
| | | preVolList = battRTDataHisService.getPreVolList(battGroupId,dischargeStartTime); |
| | | List<BattRealTimeDataHistory> preVolListOriginal = battRTDataHisService.getPreVolList(battGroupId,dischargeStartTime); |
| | | addStatistics(preVolListOriginal,"vol","tmp"); |
| | | //总电流总电压列入 |
| | | Float preGroupVol = preVolListOriginal.get(0).getGroupVol(); |
| | | Float preGroupCurr = preVolListOriginal.get(0).getGroupCurr(); |
| | | |
| | | addStatistics(fcVolList,"vol"); |
| | | addStatistics(preVolList,"vol"); |
| | | BattRealTimeDataHistory preGroupVolData = new BattRealTimeDataHistory(); |
| | | preGroupVolData.setMonNum(-2); |
| | | preGroupVolData.setGroupVol(preGroupVol); |
| | | |
| | | //一共104节单体,再加上统计数据4列,一共108 |
| | | for(int j = 0; j < 108; j++){ |
| | | BattRealTimeDataHistory preGroupCurrData = new BattRealTimeDataHistory(); |
| | | preGroupCurrData.setMonNum(-1); |
| | | preGroupCurrData.setGroupCurr(preGroupCurr); |
| | | |
| | | preVolList.add(preGroupVolData); |
| | | preVolList.add(preGroupCurrData); |
| | | preVolList.addAll(preVolListOriginal); |
| | | |
| | | //放电结束0.5h后蓄电池开路电压值 |
| | | Calendar dischargeEndCalendar = Calendar.getInstance(); |
| | | dischargeEndCalendar.setTime(dischargeEndTime.getTime()); |
| | | dischargeEndCalendar.add(Calendar.MINUTE,30); |
| | | List<BattRealTimeDataHistory> dischargeSetVolListOne = new ArrayList<>(); |
| | | List<BattRealTimeDataHistory> dischargeSetVolListOneOriginal = battRTDataHisService.getRecordList(battGroupId, dischargeEndCalendar.getTime()); |
| | | dischargeSetVolListOneOriginal.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum)); |
| | | addStatistics(dischargeSetVolListOneOriginal,"vol","tmp"); |
| | | //总电流总电压列入 |
| | | Float groupVolOne = dischargeSetVolListOneOriginal.get(0).getGroupVol(); |
| | | Float groupCurrOne = dischargeSetVolListOneOriginal.get(0).getGroupCurr(); |
| | | |
| | | BattRealTimeDataHistory groupVolDataOne = new BattRealTimeDataHistory(); |
| | | groupVolDataOne.setMonNum(-2); |
| | | groupVolDataOne.setGroupVol(groupVolOne); |
| | | |
| | | BattRealTimeDataHistory groupCurrDataOne = new BattRealTimeDataHistory(); |
| | | groupCurrDataOne.setMonNum(-1); |
| | | groupCurrDataOne.setGroupCurr(groupCurrOne); |
| | | |
| | | dischargeSetVolListOne.add(groupVolDataOne); |
| | | dischargeSetVolListOne.add(groupCurrDataOne); |
| | | dischargeSetVolListOne.addAll(dischargeSetVolListOneOriginal); |
| | | |
| | | //定位到充电开始时间,状态变为充电的记录时间 |
| | | Date chargeStartTime = battRTDataHisService.getChargeStartTime(battGroupId, dischargeEndTime.getTime()); |
| | | //充满后蓄电池的电压 |
| | | Calendar chargeCalendar = Calendar.getInstance(); |
| | | chargeCalendar.setTime(chargeStartTime); |
| | | List<BattRealTimeDataHistory> fcVolListAfter = new ArrayList<>(); |
| | | List<BattRealTimeDataHistory> fcVolListAfterOriginal = battRTDataHisService.getFcVolListAfter(battGroupId, chargeCalendar.getTime()); |
| | | fcVolListAfterOriginal.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum)); |
| | | addStatistics(fcVolListAfterOriginal,"vol","tmp"); |
| | | //总电流总电压列入 |
| | | if(fcVolListAfterOriginal.size()>0) { |
| | | Float groupVolAfter = fcVolListAfterOriginal.get(0).getGroupVol(); |
| | | Float groupCurrAfter = fcVolListAfterOriginal.get(0).getGroupCurr(); |
| | | |
| | | BattRealTimeDataHistory groupVolDataAfter = new BattRealTimeDataHistory(); |
| | | groupVolDataAfter.setMonNum(-2); |
| | | groupVolDataAfter.setGroupVol(groupVolAfter); |
| | | |
| | | BattRealTimeDataHistory groupCurrDataAfter = new BattRealTimeDataHistory(); |
| | | groupCurrDataAfter.setMonNum(-1); |
| | | groupCurrDataAfter.setGroupCurr(groupCurrAfter); |
| | | |
| | | fcVolListAfter.add(groupVolDataAfter); |
| | | fcVolListAfter.add(groupCurrDataAfter); |
| | | fcVolListAfter.addAll(fcVolListAfterOriginal); |
| | | } |
| | | |
| | | //一共104节单体,再加上前面总电压和总电流2列,后面统计数据4列,一共110 |
| | | for(int j = 0; j < 110; j++){ |
| | | XSSFRow rowTemp = sheet.createRow(rowIndex++); |
| | | if(j<104) { |
| | | if(j == 0){ |
| | | rowTemp.createCell(0).setCellValue("总电压"); |
| | | }else if(j == 1){ |
| | | rowTemp.createCell(0).setCellValue("总电流"); |
| | | } |
| | | else if(j<106) { |
| | | rowTemp.createCell(0).setCellValue((j + 1) + "#"); |
| | | }else{ |
| | | if(j == 104){ |
| | | if(j == 106){ |
| | | rowTemp.createCell(0).setCellValue("单节平均电压"); |
| | | }else if (j == 105){ |
| | | }else if (j == 107){ |
| | | rowTemp.createCell(0).setCellValue("单节最大电压"); |
| | | }else if (j == 106){ |
| | | }else if (j == 108){ |
| | | rowTemp.createCell(0).setCellValue("单节最小电压"); |
| | | }else{ |
| | | rowTemp.createCell(0).setCellValue("单节最大差值"); |
| | |
| | | //rowTemp.createCell(2).setCellValue("蓄电池浮充温度值:"+(j+1)+"#"); |
| | | //rowTemp.createCell(3).setCellValue("放电前蓄电池开路电压值(V):"+(j+1)+"#"); |
| | | //rowTemp.createCell(4).setCellValue("放电前蓄电池开路温度值:"+(j+1)+"#"); |
| | | rowTemp.createCell(1).setCellValue(fcVolList.get(j).getMonVol()); |
| | | rowTemp.createCell(1).setCellValue(fcVolList.get(j).getMonTmp()); |
| | | if(j == 0){ |
| | | rowTemp.createCell(1).setCellValue(fcVolList.get(j).getGroupVol()); |
| | | rowTemp.createCell(2).setCellValue(preVolList.get(j).getGroupVol()); |
| | | }else if (j == 1){ |
| | | rowTemp.createCell(1).setCellValue(fcVolList.get(j).getGroupCurr()); |
| | | rowTemp.createCell(2).setCellValue(preVolList.get(j).getGroupCurr()); |
| | | }else { |
| | | rowTemp.createCell(1).setCellValue(fcVolList.get(j).getMonVol()); |
| | | |
| | | rowTemp.createCell(1).setCellValue(preVolList.get(j).getMonVol()); |
| | | rowTemp.createCell(1).setCellValue(preVolList.get(j).getMonTmp()); |
| | | rowTemp.createCell(2).setCellValue(preVolList.get(j).getMonVol()); |
| | | rowTemp.createCell(3).setCellValue(preVolList.get(j).getMonTmp()); |
| | | } |
| | | |
| | | |
| | | //放电特定电压值 |
| | |
| | | addStatistics(dischargeListOne,"vol"); |
| | | //rowTemp.createCell(5).setCellValue("放电0.5h电压值(V):"+(j+1)+"#"); |
| | | //rowTemp.createCell(6).setCellValue("放电0.5h温度值:"+(j+1)+"#"); |
| | | rowTemp.createCell(5).setCellValue(dischargeListOne.get(j).getMonVol()); |
| | | rowTemp.createCell(6).setCellValue(dischargeListOne.get(j).getMonTmp()); |
| | | rowTemp.createCell(4).setCellValue(dischargeListOne.get(j).getMonVol()); |
| | | rowTemp.createCell(5).setCellValue(dischargeListOne.get(j).getMonTmp()); |
| | | columnIndexTemp+=2; |
| | | if(dischargeColumnCount > 2){ //合并单元格了,所以索引+2 |
| | | //时间在测试开始时间+1h |
| | |
| | | addStatistics(dischargeListTwo,"vol"); |
| | | //rowTemp.createCell(7).setCellValue("放电1h电压值(V):"+(j+1)+"#"); |
| | | //rowTemp.createCell(8).setCellValue("放电1h温度值:"+(j+1)+"#"); |
| | | rowTemp.createCell(7).setCellValue(dischargeListTwo.get(j).getMonVol()); |
| | | rowTemp.createCell(8).setCellValue(dischargeListTwo.get(j).getMonTmp()); |
| | | rowTemp.createCell(6).setCellValue(dischargeListTwo.get(j).getMonVol()); |
| | | rowTemp.createCell(7).setCellValue(dischargeListTwo.get(j).getMonTmp()); |
| | | columnIndexTemp+=2; |
| | | if(dischargeColumnCount > 4){ |
| | | columnIndexTemp++; |
| | |
| | | } |
| | | } |
| | | |
| | | //充电特定电压值 |
| | | Calendar dischargeEndCalendar = Calendar.getInstance(); |
| | | dischargeEndCalendar.setTime(dischargeEndTime.getTime()); |
| | | dischargeEndCalendar.add(Calendar.MINUTE,30); |
| | | List<BattRealTimeDataHistory> dischargeSetVolListOne = battRTDataHisService.getRecordList(battGroupId, dischargeEndCalendar.getTime()); |
| | | dischargeSetVolListOne.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum)); |
| | | addStatistics(dischargeSetVolListOne,"vol"); |
| | | rowTemp.createCell(++columnIndexTemp).setCellValue(dischargeSetVolListOne.get(j).getMonVol()); |
| | | //填充放电0.5h后开路电压值 |
| | | if(j == 0){ |
| | | rowTemp.createCell(++columnIndexTemp).setCellValue(dischargeSetVolListOne.get(j).getGroupVol()); |
| | | }else if(j == 1){ |
| | | rowTemp.createCell(++columnIndexTemp).setCellValue(dischargeSetVolListOne.get(j).getGroupCurr()); |
| | | }else { |
| | | rowTemp.createCell(++columnIndexTemp).setCellValue(dischargeSetVolListOne.get(j).getMonVol()); |
| | | } |
| | | |
| | | //定位到充电开始时间,状态变为充电的记录时间 |
| | | Date chargeStartTime = battRTDataHisService.getChargeStartTime(battGroupId, dischargeEndTime.getTime()); |
| | | if(chargeColumnCount > 0){ |
| | | Calendar chargeCalendar = Calendar.getInstance(); |
| | | chargeCalendar = Calendar.getInstance(); |
| | | chargeCalendar.setTime(chargeStartTime); |
| | | chargeCalendar.add(Calendar.MINUTE,30); |
| | | List<BattRealTimeDataHistory> chargeVolListOne = battRTDataHisService.getRecordList(battGroupId, chargeCalendar.getTime()); |
| | |
| | | } |
| | | } |
| | | |
| | | Calendar chargeCalendar = Calendar.getInstance(); |
| | | chargeCalendar.setTime(chargeStartTime); |
| | | List<BattRealTimeDataHistory> fcVolListAfter = battRTDataHisService.getFcVolListAfter(battGroupId, chargeCalendar.getTime()); |
| | | fcVolListAfter.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum)); |
| | | addStatistics(fcVolListAfter,"vol"); |
| | | //填充充满后蓄电池电压 |
| | | //rowTemp.createCell(++columnIndexTemp).setCellValue("充满后蓄电池电压值(V)(电流为0)"); |
| | | if (fcVolListAfter.size() > 0){ |
| | | rowTemp.createCell(++columnIndexTemp).setCellValue(fcVolListAfter.get(j).getMonVol()); |
| | | if(j == 0){ |
| | | rowTemp.createCell(++columnIndexTemp).setCellValue(fcVolListAfter.get(j).getGroupVol()); |
| | | }else if(j == 1){ |
| | | rowTemp.createCell(++columnIndexTemp).setCellValue(fcVolListAfter.get(j).getGroupCurr()); |
| | | }else { |
| | | rowTemp.createCell(++columnIndexTemp).setCellValue(fcVolListAfter.get(j).getMonVol()); |
| | | } |
| | | }else { |
| | | rowTemp.createCell(++columnIndexTemp).setCellValue("-"); |
| | | } |
| | |
| | | setRowStyle(workbook,sheet.getRow(0),true,15); |
| | | //第二行设置加粗 |
| | | setRowStyle(workbook,sheet.getRow(1),true,15); |
| | | |
| | | //生成图表 |
| | | createChart(sheet, columnCount, 6,""); |
| | | } |
| | | |
| | | private XSSFCellStyle getCellStyleFont(XSSFCellStyle cellStyleOriginal, XSSFWorkbook workbook, boolean isFontBold, int fontSize) { |
| | |
| | | //最大差值 |
| | | float tmpGap = tmpMax - tmpMin; |
| | | |
| | | Date now = new Date(); |
| | | |
| | | hisAvg.setMonTmp(tmpAvg); |
| | | hisAvg.setRecordTime(now); |
| | | |
| | | hisMax.setMonTmp(tmpMax); |
| | | hisMax.setRecordTime(now); |
| | | |
| | | hisMin.setMonTmp(tmpMin); |
| | | hisMin.setRecordTime(now); |
| | | |
| | | hisGap.setMonTmp(tmpGap); |
| | | hisGap.setRecordTime(now); |
| | | } |
| | | |
| | | |