src/main/java/com/whyc/controller/BatttestdataInfController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/dto/A200stopReason.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/dto/ActmstopReason.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataId.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/BatttestdataInfService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/ExcelExportService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/SubTablePageInfoService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/BatttestdataInfController.java
@@ -55,6 +55,11 @@ @GetMapping("exportData") public void exportData(@RequestParam Integer devId, @RequestParam Integer testRecordCount , HttpServletResponse resp){ exportService.exportExcel(devId,testRecordCount,resp); if(devId/100000000==1){ exportService.exportExcelA200(devId,testRecordCount,resp); }else{ exportService.exportExcelActm(devId,testRecordCount,resp); } } } src/main/java/com/whyc/dto/A200stopReason.java
New file @@ -0,0 +1,36 @@ package com.whyc.dto; public class A200stopReason { //a200停止原因 public static String getStopReason(int stopType){ String stopReason="未知"; switch (stopType){ case 1:stopReason="手动停止";break; case 2:stopReason="测试时间到";break; case 3:stopReason="预放容量到";break; case 4:stopReason="预充容量到";break; case 5:stopReason="单体下限到";break; case 6:stopReason="单体上限到";break; case 7:stopReason="模组下限到";break; case 8:stopReason="模组上限到";break; case 9:stopReason="硬件告警";break; case 10:stopReason="通信异常";break; case 11:stopReason="整流器电压过高";break; case 12:stopReason="整流器电压过低";break; case 13:stopReason="单体压差到达设定值";break; case 14:stopReason="模组电压与充电目标电压之差小于0.5V 且 测试电流到达设置阀值,停止充电";break; case 15:stopReason="模组电压与放电目标电压之差小于0.5V 且 测试电流到达设置阀值,停止放电";break; case 16:stopReason="紧急停机";break; case 17:stopReason="模组电压异常或DC断路器已断开";break; case 18:stopReason="单体电压采集模块未连接";break; case 19:stopReason="模组电压到达保护电压值";break; case 20:stopReason="单体温度过高";break; case 21:stopReason="组压持续3分钟异常";break; case 22:stopReason="温度3分钟内升高5°C";break; case 23:stopReason="单体温度采集模块未连接";break; } return stopReason; } } src/main/java/com/whyc/dto/ActmstopReason.java
New file @@ -0,0 +1,55 @@ package com.whyc.dto; public class ActmstopReason { //actm停止原因 public static String getStopReason(int stopType){ String stopReason="未知"; switch (stopType){ case 1:stopReason="手动停止";break; case 2:stopReason="测试时间到";break; case 3:stopReason="预放容量到";break; case 4:stopReason="预充容量到";break; case 5:stopReason="单体下限到";break; case 6:stopReason="单体上限到";break; case 7:stopReason="模组下限到";break; case 8:stopReason="模组上限到";break; case 9:stopReason="硬件告警";break; case 10:stopReason="通信异常";break; case 11:stopReason="整流器电压过高";break; case 12:stopReason="整流器电压过低";break; case 13:stopReason="单体压差到达设定值";break; case 14:stopReason="模组电压与充电目标电压之差小于0.5V 且 测试电流到达设置阀值,停止充电";break; case 15:stopReason="模组电压与放电目标电压之差小于0.5V 且 测试电流到达设置阀值,停止放电";break; case 16:stopReason="紧急停机";break; case 17:stopReason="模组电压异常或DC断路器已断开";break; case 18:stopReason="单体电压采集模块未连接";break; case 19:stopReason="模组电压到达保护电压值";break; case 20:stopReason="单体温度过高";break; case 21:stopReason="组压持续3分钟异常";break; case 22:stopReason="温度3分钟内升高5°C";break; case 23:stopReason="单体温度采集模块未连接";break; } return stopReason; } //电池类型 public static String getBattType(int battType){ String typeName="未知"; switch (battType){ case 1:typeName="手动停止";break; case 2:typeName="测试时间到";break; case 3:typeName="预放容量到";break; } return typeName; } //测试类型 public static String getTestType(int testType){ String typeName="未知"; switch (testType){ case 2:typeName="充电";break; case 3:typeName="放电";break; case 4:typeName="均衡";break; } return typeName; } } src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataId.java
@@ -1,6 +1,7 @@ package com.whyc.pojo.db_batt_testdata; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; @@ -12,6 +13,7 @@ import java.io.Serializable; import java.util.Date; import java.util.List; /** * <p> @@ -94,4 +96,27 @@ @ApiModelProperty(value = "是否需要测试") private Integer needTest; @TableField(exist = false) private List<Float> monVols; @TableField(exist = false) private List<Integer> monNums; @TableField(exist = false) private List<Float> monCurrs; @TableField(exist = false) private List<Float> monCaps; @TableField(exist = false) private List<Float> monWhs; @TableField(exist = false) private Float maxTmp; @TableField(exist = false) private Float minTmp; } src/main/java/com/whyc/pojo/db_batt_testdata/BatttestdataInf.java
@@ -53,7 +53,7 @@ private Date testStarttime; @ApiModelProperty(value = "测试时长") private Long testTimelong; private Integer testTimelong; @ApiModelProperty(value = "记录时间") private Date recordTime; @@ -82,6 +82,44 @@ @ApiModelProperty(value = "最小单体电压编号") private Integer minMonvolnum; @ApiModelProperty(value = "单串上限") private Float monVolHigh; @ApiModelProperty(value = "电流阈值") private Float testcurrLimit; @ApiModelProperty(value = "电芯串数") private Integer batteryNumber; @ApiModelProperty(value = "充电限压") private Float charVoltage; @ApiModelProperty(value = "采集频率(秒)") private Integer saveInverter; @ApiModelProperty(value = "最高温度(℃)") private Float maxTemp; @ApiModelProperty(value = "最低温度") private Float minTemp; @ApiModelProperty(value = "组端电压下限") private Float groupVolLow; @ApiModelProperty(value = "PACK/模组号") private String batteryName; @ApiModelProperty(value = "单串下限") private Float monVolLow; @ApiModelProperty(value = "电压阈值") private Float volThreshold; @ApiModelProperty(value = "电池类型[0-铁锂 1-三元锂 2-钛酸锂电 3-锰酸锂]") private Integer battType; @ApiModelProperty(value = "设备类型") @TableField(exist = false) private Integer devType; src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -1,5 +1,6 @@ package com.whyc.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.whyc.dto.Response; import com.whyc.mapper.BatttestdataIdMapper; import com.whyc.mapper.BatttestdataInfMapper; @@ -39,6 +40,7 @@ Map<Integer,Integer> actmYearMap=new HashMap<>(); actmYearMap.put(2,0); actmYearMap.put(3,0); actmYearMap.put(4,0); //本年 Map<Integer, List<BatttestdataInf>> typeMapY = listYear.stream().collect(Collectors.groupingBy(BatttestdataInf::getDevType)); @@ -65,6 +67,7 @@ Map<Integer,Integer> actmMonthMap=new HashMap<>(); actmMonthMap.put(2,0); actmMonthMap.put(3,0); actmMonthMap.put(4,0); List<BatttestdataInf> listMonth=mapper.getDevTinfByMonth(userId); Map<Integer, List<BatttestdataInf>> typeMapM = listMonth.stream().collect(Collectors.groupingBy(BatttestdataInf::getDevType)); for (Integer type : typeMapM.keySet()) { @@ -101,6 +104,7 @@ Map<Integer,Integer> actmweekDataMap=new HashMap<>(); actmweekDataMap.put(2,0); actmweekDataMap.put(3,0); actmweekDataMap.put(4,0); // 当前日期 LocalDate today = LocalDate.now(); @@ -134,6 +138,7 @@ Map<Integer,Integer> actmweekMap=new HashMap<>(); actmweekMap.put(2,0); actmweekMap.put(3,0); actmweekMap.put(4,0); for (Integer test : testMapM2.keySet()) { actmweekMap.put(test, testMapM2.get(test).size()); } @@ -149,13 +154,25 @@ //获取充放电数据 List<BatttestdataInf> listDis=mapper.getTinfById(3,devId); List<BatttestdataInf> listChr=mapper.getTinfById(2,devId); List<BatttestdataInf> listJun=mapper.getTinfById(4,devId); map.put("dis",listDis); map.put("chr",listChr); map.put("jun",listJun); return new Response().setII(1,true,map,"获取设备的充放电记录"); } //获取设备某次记录详细的单体放电过程 public Response getTdataById(Integer devId, Integer testRecordCount) { List<BatttestdataId> list=subService.getTdataById(devId,testRecordCount); return new Response().setII(1,list!=null,list,"获取设备某次记录详细的单体放电过程"); } //获取放电inf public BatttestdataInf getTinfExport(Integer devId, Integer testRecordCount) { QueryWrapper wrapper=new QueryWrapper(); wrapper.eq("dev_id",devId); wrapper.eq("test_record_count",testRecordCount); wrapper.last("limit 1"); BatttestdataInf tinf=mapper.selectOne(wrapper); return tinf; } } src/main/java/com/whyc/service/ExcelExportService.java
@@ -1,7 +1,12 @@ package com.whyc.service; import com.whyc.dto.A200stopReason; import com.whyc.dto.ActmstopReason; import com.whyc.pojo.db_batt_testdata.BatttestdataId; import com.whyc.pojo.db_batt_testdata.BatttestdataInf; import com.whyc.util.ActionUtil; import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; @@ -20,11 +25,14 @@ @Autowired(required = false) private SubTablePageInfoService subService; @Autowired(required = false) private BatttestdataInfService infService; //导出文件 public void exportExcel(Integer devId, Integer testRecordCount,HttpServletResponse response) { public void exportExcel1(Integer devId, Integer testRecordCount,HttpServletResponse response) { Workbook workbook = new XSSFWorkbook(); Sheet sheet = workbook.createSheet("设备历史数据"); String[] titiles=new String[]{"测试时间","电池组编号","单体编号","测试次数","测试类型","测试容量" String[] titiles=new String[]{"测试时间","电池组编号","单体编号","测试次数","测试类型","测试记录数" ,"组端电压(V)","测试电流(A)","测试容量(AH)","单体电压(V)","单体温度(℃)" ,"单体电流(A)","单体容量(AH)","单体能量","单体状态","故障信息"}; int rowNum=0; @@ -84,4 +92,233 @@ e.printStackTrace(); } } //导出文件A200 public void exportExcelA200(Integer devId, Integer testRecordCount,HttpServletResponse response) { Workbook wb = new XSSFWorkbook(); //测试报告封面 exportExcelCoverA200(devId,testRecordCount,wb); Sheet sheet = wb.createSheet("测试数据详情"); // 创建一个单元格样式,并设置字体大小为5 CellStyle cellStyle = wb.createCellStyle(); cellStyle.setAlignment(HorizontalAlignment.CENTER); // 设置水平居中 cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 设置垂直居中 Font font = wb.createFont(); font.setFontHeightInPoints((short)20); cellStyle.setFont(font); String[] titiles=new String[]{"Time(H:M:S)","Group V(V)","Group A(A)","Cap (AH)","Temp H(°C)","Temp L(°C)"}; List<BatttestdataId> list=subService.getTdataByIdWithListA200(devId,testRecordCount); int rowNum=0; // 创建标题行 Row row = sheet.createRow(rowNum); row.setHeightInPoints(20.0f); // 填充数据 for(int i=0;i<titiles.length;i++){ row.createCell(i).setCellValue(titiles[i]); } if(list!=null&&list.size()>0){ List<Integer> monNums=list.get(0).getMonNums(); for (int i=0;i<monNums.size();i++){ row.createCell(i+titiles.length).setCellValue("V"+monNums.get(i)); } } rowNum++; if(list!=null){ //数据栏 for (int i = 0; i < list.size(); i++) { Row row1 = sheet.createRow(rowNum); //创建行 row1.setHeightInPoints(20.0f); BatttestdataId tdata=list.get(i); sheet.getRow(rowNum).createCell(0 ).setCellValue(ActionUtil.secToTime(tdata.getTestTimelong())); sheet.getRow(rowNum).createCell(1).setCellValue(String.format("%.1f",tdata.getGroupVol())); sheet.getRow(rowNum).createCell(2).setCellValue(String.format("%.1f",tdata.getTestCurr())); sheet.getRow(rowNum).createCell(3).setCellValue(String.format("%.1f",tdata.getTestCap())); sheet.getRow(rowNum).createCell(4).setCellValue(String.format("%.1f",tdata.getMaxTmp())); sheet.getRow(rowNum).createCell(5).setCellValue(String.format("%.1f",tdata.getMinTmp())); if (tdata.getMonVols() != null) { List<Float> monVols = tdata.getMonVols(); for (int j = 0; j < monVols.size(); j++) { sheet.getRow(rowNum).createCell(6 + j).setCellValue(String.format("%.3f", monVols.get(j))); } } rowNum++; } } try { // 写入到输出流 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); wb.write(byteArrayOutputStream); wb.close(); // 设置响应头 String filename = "设备历史数据"; response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + URLEncoder.encode (filename, "utf-8") + ".xlsx"); response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); // 写入响应流并关闭 response.getOutputStream().write(byteArrayOutputStream.toByteArray()); response.getOutputStream().flush(); response.getOutputStream().close(); } catch (IOException e) { e.printStackTrace(); } } //测试报告封面 private void exportExcelCoverA200(Integer devId, Integer testRecordCount, Workbook wb) { Sheet sheet = wb.createSheet("测试报告封面"); // 创建一个单元格样式,并设置字体大小为5 CellStyle cellStyle = wb.createCellStyle(); cellStyle.setAlignment(HorizontalAlignment.CENTER); // 设置水平居中 cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 设置垂直居中 Font font = wb.createFont(); font.setFontHeightInPoints((short)20); cellStyle.setFont(font); //获取放电inf BatttestdataInf tinf=infService.getTinfExport(devId,testRecordCount); String[] titiles33=new String[]{"PACK/模组号:","测试开始时间:","测试结束时间:","数据类型:","停止原因:","预放容量(AH):" ,"放电电流(A):","测试时长(h:m:s):","单串下限(V):","组端下限(V):","电芯串数:","最高温度(°C):","最低温度(°C):","采集频率(秒):"}; String[] titiles34=new String[]{tinf.getBatteryName(),ActionUtil.sdf.format(tinf.getTestStarttime()),ActionUtil.sdf.format(tinf.getRecordTime()), "放电数据",A200stopReason.getStopReason(tinf.getTestStoptype()),String.format("%.1f",tinf.getTestCap()) ,String.format("%.1f",tinf.getTestCurr()),ActionUtil.secToTime(tinf.getTestTimelong()),String.format("%.1f",tinf.getMonVolLow()),String.format("%.1f",tinf.getGroupVolLow()),String.valueOf(tinf.getBatteryNumber()) ,String.format("%.1f",tinf.getMaxTemp()),String.format("%.1f",tinf.getMinTemp()),String.valueOf(tinf.getSaveInverter())}; String[] titiles23=new String[]{"PACK/模组号:","测试开始时间:","测试结束时间:","数据类型:","停止原因:","充电限流(A):" ,"测试时长(h:m:s):","单串上限(V):","电流阀值(A):","电芯串数:","充电限压(V)","最高温度(°C):","最低温度(°C):","采集频率(秒):"}; String[] titiles24=new String[]{tinf.getBatteryName(),ActionUtil.sdf.format(tinf.getTestStarttime()),ActionUtil.sdf.format(tinf.getRecordTime()), "充电数据",A200stopReason.getStopReason(tinf.getTestStoptype()),String.format("%.1f",tinf.getTestCurr()) ,ActionUtil.secToTime(tinf.getTestTimelong()),String.format("%.1f",tinf.getMonVolHigh()),String.format("%.1f",tinf.getTestcurrLimit()),String.valueOf(tinf.getBatteryNumber()) ,String.format("%.1f",tinf.getCharVoltage()),String.format("%.1f",tinf.getMaxTemp()),String.format("%.1f",tinf.getMinTemp()),String.valueOf(tinf.getSaveInverter())}; int rowNum=5; if(tinf.getTestType()==3){//放电 for (int i=0;i<titiles33.length;i++){ Row row = sheet.createRow(rowNum); //创建行 row.setHeightInPoints(20.0f); row.createCell(3).setCellValue(titiles33[i]); row.createCell(4).setCellValue(titiles34[i]); rowNum++; } }else{ for (int i=0;i<titiles23.length;i++){ Row row = sheet.createRow(rowNum); //创建行 row.setHeightInPoints(20.0f); row.createCell(3).setCellValue(titiles23[i]); row.createCell(4).setCellValue(titiles24[i]); rowNum++; } } } //ACTM导出 public void exportExcelActm(Integer devId, Integer testRecordCount, HttpServletResponse response) { Workbook wb = new XSSFWorkbook(); //测试报告封面 exportExcelCoverActm(devId,testRecordCount,wb); Sheet sheet = wb.createSheet("测试数据"); // 创建一个单元格样式,并设置字体大小为5 CellStyle cellStyle = wb.createCellStyle(); cellStyle.setAlignment(HorizontalAlignment.CENTER); // 设置水平居中 cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 设置垂直居中 Font font = wb.createFont(); font.setFontHeightInPoints((short)20); cellStyle.setFont(font); String[] titiles=new String[]{"测试时长"}; List<BatttestdataId> list=subService.getTdataByIdWithListActm(devId,testRecordCount); int rowNum=0; // 创建标题行 Row row = sheet.createRow(rowNum); row.setHeightInPoints(20.0f); // 填充数据 for(int i=0;i<titiles.length;i++){ row.createCell(i).setCellValue(titiles[i]); } if(list!=null&&list.size()>0){ List<Integer> monNums=list.get(0).getMonNums(); for (int i=0;i<monNums.size();i++){ row.createCell(4*i+titiles.length).setCellValue(monNums.get(i)+"#电压"); row.createCell(4*i+titiles.length+1).setCellValue(monNums.get(i)+"#电流"); row.createCell(4*i+titiles.length+2).setCellValue(monNums.get(i)+"#容量(AH)"); row.createCell(4*i+titiles.length+3).setCellValue(monNums.get(i)+"#能量(WH)"); } } rowNum++; if(list!=null){ //数据栏 for (int i = 0; i < list.size(); i++) { Row row1 = sheet.createRow(rowNum); //创建行 row1.setHeightInPoints(20.0f); BatttestdataId tdata=list.get(i); sheet.getRow(rowNum).createCell(0 ).setCellValue(ActionUtil.secToTime(tdata.getTestTimelong())); List<Float> monVols = tdata.getMonVols(); List<Float> monCurrs = tdata.getMonCurrs(); List<Float> monCaps = tdata.getMonCaps(); List<Float> monWhs = tdata.getMonWhs(); List<Integer> monNums=list.get(i).getMonNums(); for (int j = 0; j < monNums.size(); j++) { sheet.getRow(rowNum).createCell(4*j+1 ).setCellValue(String.format("%.3f", monVols.get(j))); sheet.getRow(rowNum).createCell(4*j+1+1).setCellValue(String.format("%.3f", monCurrs.get(j))); sheet.getRow(rowNum).createCell(4*j+1+2).setCellValue(String.format("%.3f", monCaps.get(j))); sheet.getRow(rowNum).createCell(4*j+1+3).setCellValue(String.format("%.3f", monWhs.get(j))); } rowNum++; } } try { // 写入到输出流 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); wb.write(byteArrayOutputStream); wb.close(); // 设置响应头 String filename = "设备历史数据"; response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + URLEncoder.encode (filename, "utf-8") + ".xlsx"); response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); // 写入响应流并关闭 response.getOutputStream().write(byteArrayOutputStream.toByteArray()); response.getOutputStream().flush(); response.getOutputStream().close(); } catch (IOException e) { e.printStackTrace(); } } //测试报告封面 private void exportExcelCoverActm(Integer devId, Integer testRecordCount, Workbook wb) { Sheet sheet = wb.createSheet("模组配置"); // 创建一个单元格样式,并设置字体大小为5 CellStyle cellStyle = wb.createCellStyle(); cellStyle.setAlignment(HorizontalAlignment.CENTER); // 设置水平居中 cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 设置垂直居中 Font font = wb.createFont(); font.setFontHeightInPoints((short)20); cellStyle.setFont(font); //获取放电inf BatttestdataInf tinf=infService.getTinfExport(devId,testRecordCount); String[] titiles3=new String[]{"电池包序号:","模组编号:","工作模式:","电池类型:","电池串数:","电压阀值(v):" ,"工作电流(A):","开始测试时间:","结束测试时间:","停止原因:"}; String[] titiles4=new String[]{String.valueOf(tinf.getBattIdx()+1),tinf.getBatteryName(),ActmstopReason.getTestType(tinf.getTestType()),ActmstopReason.getBattType(tinf.getBattType()),String.valueOf(tinf.getBatteryNumber()),String.format("%.1f",tinf.getVolThreshold()) ,String.format("%.1f",tinf.getTestCurr()), ActionUtil.sdf.format(tinf.getTestStarttime()),ActionUtil.sdf.format(tinf.getRecordTime()), ActmstopReason.getStopReason(tinf.getTestStoptype())}; int rowNum=5; for (int i=0;i<titiles3.length;i++){ Row row = sheet.createRow(rowNum); //创建行 row.setHeightInPoints(20.0f); row.createCell(3).setCellValue(titiles3[i]); row.createCell(4).setCellValue(titiles4[i]); rowNum++; } } } src/main/java/com/whyc/service/SubTablePageInfoService.java
@@ -1,10 +1,12 @@ package com.whyc.service; import com.baomidou.mybatisplus.annotation.TableField; import com.whyc.dto.DalmDto; import com.whyc.mapper.CallBack; import com.whyc.pojo.db_alarm.DevalarmData; import com.whyc.pojo.db_alarm.DevalarmDataYear; import com.whyc.pojo.db_batt_testdata.BatttestdataId; import com.whyc.util.ActionUtil; import com.whyc.util.ThreadLocalUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -24,7 +26,6 @@ String sql="select * from db_batt_testdata.tb_batttestdata_" +devId +" where need_test=1 and test_record_count="+testRecordCount+" "; sql+=" ORDER BY record_num asc "; System.out.println(sql); List list = sqlExecuteService.executeQuery_call(sql, new CallBack() { @Override public List getResults(ResultSet rs) throws SQLException { @@ -60,7 +61,76 @@ return list; } //获取设备某次记录详细的单体放电过程 public List<BatttestdataId> getTdataByIdWithListA200(Integer devId, Integer testRecordCount) { String sql="select * from db_batt_testdata.tb_batttestdata_" +devId +" where need_test=1 and test_record_count="+testRecordCount+" "; sql+=" ORDER BY record_num asc "; List list = sqlExecuteService.executeQuery_call(sql, new CallBack() { @Override public List getResults(ResultSet rs) throws SQLException { List list=new ArrayList<>(); List<Float> monVols=null; List<Integer> monNums=null; BatttestdataId tdata=null; Float maxTmp=0f; Float minTmp=0f; int num=0; try { while (rs.next()){ int monNum=rs.getInt("mon_num"); float monvol=rs.getFloat("mon_vol"); int recordNum=rs.getInt("record_num"); Float monTmp=rs.getFloat("mon_tmp"); if(num!=recordNum){ if(num!=0){ tdata.setMonVols(monVols); tdata.setMonNums(monNums); tdata.setMaxTmp(maxTmp); tdata.setMinTmp(minTmp); maxTmp=0f; minTmp=0f; list.add(tdata); } tdata=new BatttestdataId(); monVols=new ArrayList<>(); monNums=new ArrayList<>(); tdata.setDevId(rs.getInt("dev_id")); tdata.setBattIdx(rs.getInt("batt_idx")); tdata.setTestRecordCount(rs.getInt("test_record_count")); tdata.setTestType(rs.getInt("test_type")); tdata.setRecordNum(recordNum); tdata.setTestStarttime(rs.getTimestamp("test_starttime")); tdata.setRecordTime(rs.getTimestamp("record_time")); tdata.setTestTimelong(rs.getInt("test_timelong")); tdata.setGroupVol(rs.getDouble("group_vol")); tdata.setTestCurr(rs.getDouble("test_curr")); tdata.setTestCap(rs.getDouble("test_cap")); tdata.setNeedTest(rs.getInt("need_test")); num=recordNum; } if(monTmp>maxTmp){ maxTmp =monTmp; } if(monTmp<minTmp){ minTmp=monTmp; } monVols.add(monvol); monNums.add(monNum); } tdata.setMaxTmp(maxTmp); tdata.setMinTmp(minTmp); tdata.setMonVols(monVols); tdata.setMonNums(monNums); list.add(tdata); } catch (SQLException e) { e.printStackTrace(); } return list; } }); return list; } //查询DevAlm历史告警数量 public int getCountForDevAlm(DalmDto dto) { String sql="select count(distinct num) as number from db_alarm." +dto.getTableName() @@ -158,4 +228,79 @@ } public List<BatttestdataId> getTdataByIdWithListActm(Integer devId, Integer testRecordCount) { String sql="select * from db_batt_testdata.tb_batttestdata_" +devId +" where need_test=1 and test_record_count="+testRecordCount+" "; sql+=" ORDER BY record_num asc "; List list = sqlExecuteService.executeQuery_call(sql, new CallBack() { @Override public List getResults(ResultSet rs) throws SQLException { List list=new ArrayList<>(); List<Float> monVols=null; List<Float> monCurrs=null; List<Float> monCaps=null; List<Float> monWhs=null; List<Integer> monNums=null; BatttestdataId tdata=null; int num=0; try { while (rs.next()){ int monNum=rs.getInt("mon_num"); float monvol=rs.getFloat("mon_vol"); float monCurr=rs.getFloat("mon_curr"); float monCap=rs.getFloat("mon_cap"); float monWh=rs.getFloat("mon_wh"); int recordNum=rs.getInt("record_num"); if(num!=recordNum){ if(num!=0){ tdata.setMonVols(monVols); tdata.setMonNums(monNums); tdata.setMonCurrs(monCurrs); tdata.setMonCaps(monCaps); tdata.setMonWhs(monWhs); list.add(tdata); } tdata=new BatttestdataId(); monVols=new ArrayList<>(); monNums=new ArrayList<>(); monCurrs=new ArrayList<>(); monCaps=new ArrayList<>(); monWhs=new ArrayList<>(); tdata.setDevId(rs.getInt("dev_id")); tdata.setBattIdx(rs.getInt("batt_idx")); tdata.setTestRecordCount(rs.getInt("test_record_count")); tdata.setTestType(rs.getInt("test_type")); tdata.setRecordNum(recordNum); tdata.setTestStarttime(rs.getTimestamp("test_starttime")); tdata.setRecordTime(rs.getTimestamp("record_time")); tdata.setTestTimelong(rs.getInt("test_timelong")); tdata.setGroupVol(rs.getDouble("group_vol")); tdata.setTestCurr(rs.getDouble("test_curr")); tdata.setTestCap(rs.getDouble("test_cap")); tdata.setNeedTest(rs.getInt("need_test")); tdata.setMonTmp(rs.getDouble("mon_tmp")); num=recordNum; } monVols.add(monvol); monNums.add(monNum); monCurrs.add(monCurr); monCaps.add(monCap); monWhs.add(monWh); } tdata.setMonVols(monVols); tdata.setMonNums(monNums); tdata.setMonCurrs(monCurrs); tdata.setMonCaps(monCaps); tdata.setMonWhs(monWhs); list.add(tdata); } catch (SQLException e) { e.printStackTrace(); } return list; } }); return list; } }