-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[manager] import and export by excel (#891)
[manager]export by excel via `ExcelImExportServiceImpl.java` [manager]import by excel via `ExcelImExportServiceImpl.java` [manager]fix log level and static method. Update pom.xml Signed-off-by: zqr10159 <[email protected]> --------- Signed-off-by: zqr10159 <[email protected]>
- Loading branch information
Showing
7 changed files
with
348 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,11 @@ | |
|
||
package org.dromara.hertzbeat.manager.service.impl; | ||
|
||
import cn.afterturn.easypoi.excel.annotation.*; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import lombok.Data; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.dromara.hertzbeat.common.entity.manager.Monitor; | ||
import org.dromara.hertzbeat.common.entity.manager.Param; | ||
import org.dromara.hertzbeat.common.entity.manager.Tag; | ||
|
@@ -41,6 +43,7 @@ | |
* @author <a href="mailto:[email protected]">gcdd1993</a> | ||
* Created by gcdd1993 on 2023/3/31 | ||
*/ | ||
@Slf4j | ||
abstract class AbstractImExportServiceImpl implements ImExportService { | ||
|
||
@Resource | ||
|
@@ -118,6 +121,7 @@ private MonitorDto convert(ExportMonitorDTO exportMonitor) { | |
var monitorDto = new MonitorDto(); | ||
monitorDto.setDetected(true); | ||
var monitor = new Monitor(); | ||
log.debug("exportMonitor.monitor{}", exportMonitor.monitor); | ||
BeanUtils.copyProperties(exportMonitor.monitor, monitor); | ||
monitor.setTags(tagService.listTag(new HashSet<>(exportMonitor.monitor.tags))); | ||
monitorDto.setMonitor(monitor); | ||
|
@@ -132,39 +136,59 @@ private MonitorDto convert(ExportMonitorDTO exportMonitor) { | |
return monitorDto; | ||
} | ||
|
||
protected String fileNamePrefix() { | ||
protected String | ||
fileNamePrefix() { | ||
return "hertzbeat_monitor_" + LocalDate.now(); | ||
} | ||
|
||
@Data | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@ExcelTarget(value = "ExportMonitorDTO") | ||
protected static class ExportMonitorDTO { | ||
@ExcelEntity(name = "Monitor") | ||
private MonitorDTO monitor; | ||
@ExcelCollection(name = "Params") | ||
private List<ParamDTO> params; | ||
@ExcelCollection(name = "Metrics") | ||
private List<String> metrics; | ||
} | ||
|
||
|
||
@Data | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@ExcelTarget(value = "MonitorDTO") | ||
protected static class MonitorDTO { | ||
@Excel(name = "Name") | ||
private String name; | ||
@Excel(name = "App") | ||
private String app; | ||
@Excel(name = "Host") | ||
private String host; | ||
@Excel(name = "Intervals") | ||
private Integer intervals; | ||
@Excel(name = "Status") | ||
private Byte status; | ||
@Excel(name = "Description") | ||
private String description; | ||
@Excel(name = "Tags") | ||
private List<Long> tags; | ||
} | ||
|
||
|
||
@Data | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@ExcelTarget(value = "ParamDTO") | ||
protected static class ParamDTO { | ||
@Excel(name = "Field") | ||
private String field; | ||
@Excel(name = "Value") | ||
private String value; | ||
@Excel(name = "Type") | ||
private Byte type; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.