|
|
@ -17,7 +17,7 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
public class ExcelExportService { |
|
|
|
|
|
|
|
public void exportDataToExcel(Map<Integer, List<Status>> ipMap, Map<String, List<Status> >categoryMap, String filePath) { |
|
|
|
public void exportDataToExcel(Map<Integer, List<Status>> ipMap, Map<String, List<Status>> categoryMap, String filePath) { |
|
|
|
Workbook workbook = new XSSFWorkbook(); |
|
|
|
Map<Integer, List<Status>> map = new TreeMap<>(ipMap); |
|
|
|
Sheet sheet = workbook.createSheet(UniversalEnum.DEVICE_FAILURE_RATE_TIME_SHARING_STATISTICS_PAGE.getValue()); |
|
|
@ -37,41 +37,50 @@ public class ExcelExportService { |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.FOUR.getNumber(), UniversalEnum.FOUR.getNumber())); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.FIVE.getNumber(), UniversalEnum.FIVE.getNumber())); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.SIX.getNumber(), UniversalEnum.SIX.getNumber())); |
|
|
|
int i=UniversalEnum.ZERO.getNumber(); |
|
|
|
int i = UniversalEnum.ZERO.getNumber(); |
|
|
|
boolean flag = true; |
|
|
|
Row row1= sheet.createRow(UniversalEnum.ONE.getNumber()); |
|
|
|
Row row1 = sheet.createRow(UniversalEnum.ONE.getNumber()); |
|
|
|
for (Map.Entry<Integer, List<Status>> entry : map.entrySet()) { |
|
|
|
row0.createCell(UniversalEnum.TWO.getNumber()*i+UniversalEnum.SEVEN.getNumber()).setCellValue(entry.getKey()+UniversalEnum.HOUR.getValue()); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.TWO.getNumber()*i+UniversalEnum.SEVEN.getNumber(), UniversalEnum.TWO.getNumber()*i+UniversalEnum.EIGHT.getNumber())); |
|
|
|
row1.createCell(UniversalEnum.TWO.getNumber()*i+UniversalEnum.SEVEN.getNumber()).setCellValue(UniversalEnum.ONLINE_RATE.getValue()); |
|
|
|
row1.createCell(UniversalEnum.TWO.getNumber()*i+UniversalEnum.EIGHT.getNumber()).setCellValue(UniversalEnum.PACKET_LOSS_RATE.getValue()); |
|
|
|
row0.createCell(UniversalEnum.TWO.getNumber() * i + UniversalEnum.SEVEN.getNumber()).setCellValue(entry.getKey() + UniversalEnum.HOUR.getValue()); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.TWO.getNumber() * i + UniversalEnum.SEVEN.getNumber(), UniversalEnum.TWO.getNumber() * i + UniversalEnum.EIGHT.getNumber())); |
|
|
|
row1.createCell(UniversalEnum.TWO.getNumber() * i + UniversalEnum.SEVEN.getNumber()).setCellValue(UniversalEnum.ONLINE_RATE.getValue()); |
|
|
|
row1.createCell(UniversalEnum.TWO.getNumber() * i + UniversalEnum.EIGHT.getNumber()).setCellValue(UniversalEnum.PACKET_LOSS_RATE.getValue()); |
|
|
|
rowNum = UniversalEnum.TWO.getNumber(); |
|
|
|
List<Status> groupItems = entry.getValue(); |
|
|
|
for (Status ignored : groupItems) { |
|
|
|
int a=rowNum++; |
|
|
|
int a = rowNum++; |
|
|
|
Row row = sheet.getRow(a); // 获取指定索引的行
|
|
|
|
if (row == null) { // 如果行不存在,则创建新行
|
|
|
|
row = sheet.createRow(a); |
|
|
|
} |
|
|
|
if(flag) { |
|
|
|
if (flag) { |
|
|
|
row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getDeviceName()); |
|
|
|
row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getDeviceIp()); |
|
|
|
row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getDeviceNo()); |
|
|
|
row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getDirection()); |
|
|
|
row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getProduction()); |
|
|
|
row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getModel()); |
|
|
|
row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(ignored.getContent()); |
|
|
|
row.createCell(UniversalEnum.ONE.getNumber()).setCellValue(ignored.getDeviceIp()); |
|
|
|
row.createCell(UniversalEnum.TWO.getNumber()).setCellValue(ignored.getDeviceNo()); |
|
|
|
Integer direction = Integer.parseInt(ignored.getDirection() != null ? ignored.getDirection() : UniversalEnum.FOUR.getValue()); |
|
|
|
String directionDescription = UniversalEnum.UNKNOWN_DIRECTION.getValue(); |
|
|
|
if (Objects.equals(direction, UniversalEnum.DIRECTION_OF_HEZE.getNumber())) { |
|
|
|
directionDescription = UniversalEnum.DIRECTION_OF_HEZE.getValue(); |
|
|
|
} else if (Objects.equals(direction, UniversalEnum.BIDIRECTIONAL.getNumber())) { |
|
|
|
directionDescription = UniversalEnum.BIDIRECTIONAL.getValue(); |
|
|
|
} else if (Objects.equals(direction, UniversalEnum.DIRECTION_OF_JINAN.getNumber())) { |
|
|
|
directionDescription = UniversalEnum.DIRECTION_OF_JINAN.getValue(); |
|
|
|
} |
|
|
|
row.createCell(UniversalEnum.TWO.getNumber()*i+UniversalEnum.SEVEN.getNumber()).setCellValue(ignored.getSuccessRate()); |
|
|
|
row.createCell(UniversalEnum.TWO.getNumber()*i+UniversalEnum.EIGHT.getNumber()).setCellValue(ignored.getLostRate()); |
|
|
|
row.createCell(UniversalEnum.THREE.getNumber()).setCellValue(directionDescription); |
|
|
|
row.createCell(UniversalEnum.FOUR.getNumber()).setCellValue(ignored.getProduction()); |
|
|
|
row.createCell(UniversalEnum.FIVE.getNumber()).setCellValue(ignored.getModel()); |
|
|
|
row.createCell(UniversalEnum.SIX.getNumber()).setCellValue(ignored.getContent()); |
|
|
|
} |
|
|
|
row.createCell(UniversalEnum.TWO.getNumber() * i + UniversalEnum.SEVEN.getNumber()).setCellValue(ignored.getSuccessRate()); |
|
|
|
row.createCell(UniversalEnum.TWO.getNumber() * i + UniversalEnum.EIGHT.getNumber()).setCellValue(ignored.getLostRate()); |
|
|
|
} |
|
|
|
i++; |
|
|
|
flag = false; |
|
|
|
//flag = false;
|
|
|
|
} |
|
|
|
Sheet sheets = workbook.createSheet(UniversalEnum.DEVICE_FAILURE_RATE_SUMMARY_PAGE.getValue()); |
|
|
|
createSheet(sheets,categoryMap); |
|
|
|
createSheet(sheets, categoryMap); |
|
|
|
Sheet sheet1 = workbook.createSheet(UniversalEnum.EQUIPMENT_FAILURE_RATE_TIME_SHARING_SUMMARY_PAGE.getValue()); |
|
|
|
createSheet1(sheet1,ipMap); |
|
|
|
createSheet1(sheet1, ipMap); |
|
|
|
try (FileOutputStream outputStream = new FileOutputStream(filePath)) { |
|
|
|
workbook.write(outputStream); |
|
|
|
} catch (IOException e) { |
|
|
@ -80,15 +89,16 @@ public class ExcelExportService { |
|
|
|
System.out.println("excel写入成功!!!!!!"); |
|
|
|
|
|
|
|
} |
|
|
|
public void createSheet1(Sheet sheet,Map<Integer, List<Status>> ipMap){ |
|
|
|
|
|
|
|
public void createSheet1(Sheet sheet, Map<Integer, List<Status>> ipMap) { |
|
|
|
Map<Integer, List<Status>> map = new TreeMap<>(ipMap); |
|
|
|
int rowNum = UniversalEnum.ZERO.getNumber(); |
|
|
|
Row row0 = sheet.createRow(rowNum); |
|
|
|
row0.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(UniversalEnum.EQUIPMENT_CLASSIFICATION.getValue()); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ONE.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber())); |
|
|
|
int i=UniversalEnum.ZERO.getNumber(); |
|
|
|
int i = UniversalEnum.ZERO.getNumber(); |
|
|
|
boolean flag = true; |
|
|
|
Row row1= sheet.createRow(UniversalEnum.ONE.getNumber()); |
|
|
|
Row row1 = sheet.createRow(UniversalEnum.ONE.getNumber()); |
|
|
|
for (Map.Entry<Integer, List<Status>> entry : map.entrySet()) { |
|
|
|
row0.createCell(UniversalEnum.THREE.getNumber() * i + UniversalEnum.ONE.getNumber()).setCellValue(entry.getKey() + UniversalEnum.HOUR.getNumber()); |
|
|
|
sheet.addMergedRegion(new CellRangeAddress(UniversalEnum.ZERO.getNumber(), UniversalEnum.ZERO.getNumber(), UniversalEnum.THREE.getNumber() * i + UniversalEnum.ONE.getNumber(), UniversalEnum.THREE.getNumber() * i + UniversalEnum.THREE.getNumber())); |
|
|
@ -114,6 +124,7 @@ public class ExcelExportService { |
|
|
|
itemTypeMap.put(UniversalEnum.ONE_FOUR.getValue(), UniversalEnum.THREE_HUNDRED_SIXTY_PANORAMIC_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.ONE_FIVE.getValue(), UniversalEnum.ONE_HUNDRED_EIGHTY_PANORAMIC_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWO_ONE.getValue(), UniversalEnum.GANTRY_TYPE_VARIABLE_MESSAGE_SIGN.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWO_TWO.getValue(), UniversalEnum.VARIABLE_MESSAGE_SIGN_IN_FRONT_OF_STATION.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWO_THREE.getValue(), UniversalEnum.AWNING_VARIABLE_INFORMATION_SIGN.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWO_FOUR.getValue(), UniversalEnum.CANTILEVER_VARIABLE_INFORMATION_SIGN_IN_FRONT_OF_STATION.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.THREE.getValue(), UniversalEnum.METEOROLOGICAL_DETECTOR.getValue()); |
|
|
@ -125,6 +136,8 @@ public class ExcelExportService { |
|
|
|
itemTypeMap.put(UniversalEnum.ELEVEN.getValue(), UniversalEnum.CLASS_I_TRAFFIC_SURVEY_STATION.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWELVE.getValue(), UniversalEnum.INTELLIGENT_DRIVING_GUIDANCE_SYSTEM.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.THIRTEEN.getValue(), UniversalEnum.SMART_DEVICE_BOX.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.FIFTEEN.getValue(), UniversalEnum.SOLAR_PANEL.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.SIXTEEN.getValue(), UniversalEnum.REMOTE_COMPUTER.getValue()); |
|
|
|
String type = groupItems.get(UniversalEnum.ZERO.getNumber()).getType(); |
|
|
|
String description = itemTypeMap.get(type); |
|
|
|
if (flag) { |
|
|
@ -141,7 +154,7 @@ public class ExcelExportService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void createSheet(Sheet sheet,Map<String, List<Status> >categoryMap){ |
|
|
|
public void createSheet(Sheet sheet, Map<String, List<Status>> categoryMap) { |
|
|
|
int rowNum = UniversalEnum.ZERO.getNumber(); |
|
|
|
Row row = sheet.createRow(rowNum); |
|
|
|
row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(UniversalEnum.EQUIPMENT_CLASSIFICATION.getValue()); |
|
|
@ -151,26 +164,29 @@ public class ExcelExportService { |
|
|
|
rowNum = UniversalEnum.ONE.getNumber(); |
|
|
|
for (Map.Entry<String, List<Status>> entry : categoryMap.entrySet()) { |
|
|
|
List<Status> groupItems = entry.getValue(); |
|
|
|
long a=groupItems.stream().filter(iteam-> Objects.equals(iteam.getDeviceStatus(), UniversalEnum.ONE.getValue())).count(); |
|
|
|
long a = groupItems.stream().filter(iteam -> Objects.equals(iteam.getDeviceStatus(), UniversalEnum.ONE.getValue())).count(); |
|
|
|
row = sheet.createRow(rowNum++); |
|
|
|
HashMap<String, String> itemTypeMap = new HashMap<>(); |
|
|
|
itemTypeMap.put(UniversalEnum.ONE.getValue(), UniversalEnum.HD_NETWORK_GUN_TYPE_FIXED_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWO.getValue(), UniversalEnum.HD_NETWORK_SPHERICAL_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.THREE.getValue(), UniversalEnum.UNDER_THE_BRIDGE_HD_NETWORK_SPHERICAL_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.FOUR.getValue(), UniversalEnum.THREE_HUNDRED_SIXTY_PANORAMIC_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.FIVE.getValue(), UniversalEnum.ONE_HUNDRED_EIGHTY_PANORAMIC_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.SIX.getValue(), UniversalEnum.GANTRY_TYPE_VARIABLE_MESSAGE_SIGN.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.SEVEN.getValue(), UniversalEnum.AWNING_VARIABLE_INFORMATION_SIGN.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.EIGHT.getValue(), UniversalEnum.CANTILEVER_VARIABLE_INFORMATION_SIGN_IN_FRONT_OF_STATION.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.NINE.getValue(), UniversalEnum.METEOROLOGICAL_DETECTOR.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TEN.getValue(), UniversalEnum.SECTION_VOICE_BROADCAST_SYSTEM.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.ELEVEN.getValue(), UniversalEnum.GUARDRAIL_COLLISION_WARNING_SYSTEM.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWELVE.getValue(), UniversalEnum.MILLIMETER_WAVE_RADAR.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.THIRTEEN.getValue(), UniversalEnum.CONFLUENCE_AREA_EARLY_WARNING_SYSTEM.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.FOURTEEN.getValue(), UniversalEnum.LASER_FATIGUE_AWAKENING.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.FIFTEEN.getValue(), UniversalEnum.CLASS_I_TRAFFIC_SURVEY_STATION.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.SIXTEEN.getValue(), UniversalEnum.INTELLIGENT_DRIVING_GUIDANCE_SYSTEM.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.SEVENTEEN.getValue(), UniversalEnum.SMART_DEVICE_BOX.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.ONE_ONE.getValue(), UniversalEnum.HD_NETWORK_GUN_TYPE_FIXED_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.ONE_TWO.getValue(), UniversalEnum.HD_NETWORK_SPHERICAL_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.ONE_THREE.getValue(), UniversalEnum.UNDER_THE_BRIDGE_HD_NETWORK_SPHERICAL_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.ONE_FOUR.getValue(), UniversalEnum.THREE_HUNDRED_SIXTY_PANORAMIC_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.ONE_FIVE.getValue(), UniversalEnum.ONE_HUNDRED_EIGHTY_PANORAMIC_CAMERA.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWO_ONE.getValue(), UniversalEnum.GANTRY_TYPE_VARIABLE_MESSAGE_SIGN.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWO_TWO.getValue(), UniversalEnum.VARIABLE_MESSAGE_SIGN_IN_FRONT_OF_STATION.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWO_THREE.getValue(), UniversalEnum.AWNING_VARIABLE_INFORMATION_SIGN.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWO_FOUR.getValue(), UniversalEnum.CANTILEVER_VARIABLE_INFORMATION_SIGN_IN_FRONT_OF_STATION.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.THREE.getValue(), UniversalEnum.METEOROLOGICAL_DETECTOR.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.FIVE.getValue(), UniversalEnum.SECTION_VOICE_BROADCAST_SYSTEM.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.SIX.getValue(), UniversalEnum.GUARDRAIL_COLLISION_WARNING_SYSTEM.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.SEVEN.getValue(), UniversalEnum.MILLIMETER_WAVE_RADAR.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.EIGHT.getValue(), UniversalEnum.CONFLUENCE_AREA_EARLY_WARNING_SYSTEM.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TEN.getValue(), UniversalEnum.LASER_FATIGUE_AWAKENING.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.ELEVEN.getValue(), UniversalEnum.CLASS_I_TRAFFIC_SURVEY_STATION.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.TWELVE.getValue(), UniversalEnum.INTELLIGENT_DRIVING_GUIDANCE_SYSTEM.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.THIRTEEN.getValue(), UniversalEnum.SMART_DEVICE_BOX.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.FIFTEEN.getValue(), UniversalEnum.SOLAR_PANEL.getValue()); |
|
|
|
itemTypeMap.put(UniversalEnum.SIXTEEN.getValue(), UniversalEnum.REMOTE_COMPUTER.getValue()); |
|
|
|
String type = groupItems.get(UniversalEnum.ZERO.getNumber()).getType(); |
|
|
|
String description = itemTypeMap.get(type); |
|
|
|
row.createCell(UniversalEnum.ZERO.getNumber()).setCellValue(description); |
|
|
@ -183,8 +199,5 @@ public class ExcelExportService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|