From 165f009892855f52c77498d25ee8a9cff12c9233 Mon Sep 17 00:00:00 2001 From: duwenyuan <15600000461@163.com> Date: Wed, 8 Jul 2026 14:57:53 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=A2=E6=B5=8B?= =?UTF-8?q?=E5=99=A8=E6=A8=A1=E6=8B=9F=E5=8F=8A=E8=81=94=E7=AC=A6=E5=90=88?= =?UTF-8?q?=E6=A0=A1=E6=AD=A3=E5=9B=A0=E5=AD=90=E5=BA=93=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuration/GardsCorrectionFactor.java | 5 ++ .../GardsCorrectionFactorDetail.java | 67 +++++++++++++++ .../GardsCorrectionFactorEff.java | 67 +++++++++++++++ .../GardsCorrectionFactorDetailMapper.java | 25 ++++++ .../GardsCorrectionFactorEffMapper.java | 36 ++++++++ .../xml/GardsCorrectionFactorDetailMapper.xml | 85 +++++++++++++++++++ .../xml/GardsCorrectionFactorEffMapper.xml | 85 +++++++++++++++++++ .../jeecg/modules/base/vo/DetectorMapDTO.java | 10 +++ .../modules/base/vo/DetectorOptionVO.java | 14 +++ .../vo/GardsCorrectionFactorDetailVO.java | 18 ++++ .../base/vo/GardsCorrectionFactorEffVO.java | 16 ++++ .../modules/base/vo/StationOptionVO.java | 14 +++ 12 files changed, 442 insertions(+) create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactorDetail.java create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactorEff.java create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/GardsCorrectionFactorDetailMapper.java create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/GardsCorrectionFactorEffMapper.java create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/xml/GardsCorrectionFactorDetailMapper.xml create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/xml/GardsCorrectionFactorEffMapper.xml create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/DetectorMapDTO.java create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/DetectorOptionVO.java create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/GardsCorrectionFactorDetailVO.java create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/GardsCorrectionFactorEffVO.java create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/StationOptionVO.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactor.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactor.java index 4bbd2a6..74c83e9 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactor.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactor.java @@ -8,6 +8,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.util.Date; +import java.util.List; /** * 探测器模拟及联符合校正因子库数据 @@ -89,4 +90,8 @@ public class GardsCorrectionFactor implements Serializable { @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date moddate; + + + @TableField(exist = false) + private List details; } \ No newline at end of file diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactorDetail.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactorDetail.java new file mode 100644 index 0000000..e475763 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactorDetail.java @@ -0,0 +1,67 @@ +package org.jeecg.modules.base.entity.configuration; + + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 探测器模拟及联符合校正因子库数据---校正因子 + * + */ +@Data +@TableName("CONFIGURATION.GARDS_CORRECTION_FACTOR_DETAIL") +public class GardsCorrectionFactorDetail { + + /** + * 校正因子ID + */ + @TableId(value = "ID", type = IdType.AUTO) + private Integer id; + + /** + * 台站ID + */ + @TableField(value = "STATION_ID") + private Integer stationId; + + /** + * 探测器ID + */ + @TableField(value = "DETECTOR_ID") + private Integer detectorId; + + /** + * 能量 + */ + @Excel(name = "核素", width = 20, height = 20, orderNum = "1") + @TableField(value = "NUCLIDE_NAME") + private String nuclideName; + + /** + * 能量 + */ + @Excel(name = "能量", width = 20, height = 20, orderNum = "2") + @TableField(value = "ENERGY") + private Double energy; + + /** + * 校正因子 + */ + @Excel(name = "校正因子", width = 20, height = 20, orderNum = "3") + @TableField(value = "CORRECTION_FACTOR") + private Double correctionFactor; + + /** + * 修改时间 + */ + @TableField(value = "MODDATE", fill = FieldFill.INSERT_UPDATE) + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date moddate; + +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactorEff.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactorEff.java new file mode 100644 index 0000000..300f01c --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsCorrectionFactorEff.java @@ -0,0 +1,67 @@ +package org.jeecg.modules.base.entity.configuration; + + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 探测器模拟及联符合校正因子库数据---效率 + * + */ +@Data +@TableName("CONFIGURATION.GARDS_CORRECTION_FACTOR_EFF") +public class GardsCorrectionFactorEff { + + /** + * 主键ID + */ + @TableId(value = "ID", type = IdType.AUTO) + private Integer id; + /** + * 台站ID + */ + @TableField(value = "STATION_ID") + private Integer stationId; + + /** + * 探测器ID + */ + @TableField(value = "DETECTOR_ID") + private Integer detectorId; + + /** + * 峰效率 + */ + @Excel(name = "峰效率", width = 20, height = 20, orderNum = "1") + @TableField(value = "PEAK_EFFICIENCY") + private Double peakEfficiency; + + /** + * 总效率 + */ + @Excel(name = "总效率", width = 20, height = 20, orderNum = "2") + @TableField(value = "TOTAL_EFFICIENCY") + private Double totalEfficiency; + + /** + * 能量 + */ + @Excel(name = "能量", width = 20, height = 20, orderNum = "3") + @TableField(value = "ENERGY") + private Double energy; + + + /** + * 修改时间 + */ + @TableField(value = "MODDATE", fill = FieldFill.INSERT_UPDATE) + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date moddate; + +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/GardsCorrectionFactorDetailMapper.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/GardsCorrectionFactorDetailMapper.java new file mode 100644 index 0000000..27eeacd --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/GardsCorrectionFactorDetailMapper.java @@ -0,0 +1,25 @@ +package org.jeecg.modules.base.mapper; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorDetail; +import org.jeecg.modules.base.vo.GardsCorrectionFactorDetailVO; + +import java.util.List; +import java.util.Map; + +public interface GardsCorrectionFactorDetailMapper extends BaseMapper { + IPage selectCombinedPage( + Page page,@Param("stationCode")String stationCode,@Param("detectorCode") String detectorCode,@Param("nuclideName") String nuclideName); + + List findList(@Param("stationCode")String stationCode,@Param("detectorCode") String detectorCode,@Param("nuclideName") String nuclideName); + + List>selectStations(); + + List>selectdetectors(); + +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/GardsCorrectionFactorEffMapper.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/GardsCorrectionFactorEffMapper.java new file mode 100644 index 0000000..dc15b47 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/GardsCorrectionFactorEffMapper.java @@ -0,0 +1,36 @@ +package org.jeecg.modules.base.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorEff; +import org.jeecg.modules.base.vo.DetectorMapDTO; +import org.jeecg.modules.base.vo.DetectorOptionVO; +import org.jeecg.modules.base.vo.GardsCorrectionFactorEffVO; +import org.jeecg.modules.base.vo.StationOptionVO; + +import java.util.List; + +public interface GardsCorrectionFactorEffMapper extends BaseMapper { + + IPage selectCombinedPage( + Page page, + @Param("stationCode") String stationCode, @Param("detectorCode") String detectorCode); + + List selectVOList(@Param("stationCode") String stationCode, + @Param("detectorCode") String detectorCode); + + @Select("SELECT DETECTOR_ID, DETECTOR_CODE, STATION_ID FROM CONFIGURATION.GARDS_DETECTORS") + List queryAllDetectorRef(); + + + // 获取所有站点 + List getStationOptions(); + + // 根据站点联动获取探测器 + List getDetectorOptions(@Param("stationId")Long stationId); + + +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/xml/GardsCorrectionFactorDetailMapper.xml b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/xml/GardsCorrectionFactorDetailMapper.xml new file mode 100644 index 0000000..1a54c4f --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/xml/GardsCorrectionFactorDetailMapper.xml @@ -0,0 +1,85 @@ + + + + + + + + + + \ No newline at end of file diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/xml/GardsCorrectionFactorEffMapper.xml b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/xml/GardsCorrectionFactorEffMapper.xml new file mode 100644 index 0000000..a602b1a --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/mapper/xml/GardsCorrectionFactorEffMapper.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/DetectorMapDTO.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/DetectorMapDTO.java new file mode 100644 index 0000000..9fe7bb2 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/DetectorMapDTO.java @@ -0,0 +1,10 @@ +package org.jeecg.modules.base.vo; + +import lombok.Data; + +@Data +public class DetectorMapDTO { + private Integer detectorId; + private String detectorCode; + private Integer stationId; +} \ No newline at end of file diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/DetectorOptionVO.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/DetectorOptionVO.java new file mode 100644 index 0000000..873ee2b --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/DetectorOptionVO.java @@ -0,0 +1,14 @@ +package org.jeecg.modules.base.vo; + +import lombok.Data; + +@Data +public class DetectorOptionVO { + private Long detectorId; + private String detectorCode; + + public DetectorOptionVO(Long detectorId, String detectorCode) { + this.detectorId = detectorId; + this.detectorCode = detectorCode; + } +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/GardsCorrectionFactorDetailVO.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/GardsCorrectionFactorDetailVO.java new file mode 100644 index 0000000..0a2df92 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/GardsCorrectionFactorDetailVO.java @@ -0,0 +1,18 @@ +package org.jeecg.modules.base.vo; + +import lombok.Data; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorDetail; +import org.jeecgframework.poi.excel.annotation.Excel; + +import java.io.Serializable; +import java.util.Date; + +@Data +public class GardsCorrectionFactorDetailVO extends GardsCorrectionFactorDetail implements Serializable { + + @Excel(name = "台站编码", orderNum = "0") + private String stationCode; + + @Excel(name = "探测器编码", orderNum = "0") + private String detectorCode; +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/GardsCorrectionFactorEffVO.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/GardsCorrectionFactorEffVO.java new file mode 100644 index 0000000..9e733c1 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/GardsCorrectionFactorEffVO.java @@ -0,0 +1,16 @@ +package org.jeecg.modules.base.vo; + +import lombok.Data; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorEff; +import org.jeecgframework.poi.excel.annotation.Excel; + +import java.io.Serializable; + +@Data +public class GardsCorrectionFactorEffVO extends GardsCorrectionFactorEff implements Serializable { + @Excel(name = "台站编码", orderNum = "0") + private String stationCode; + + @Excel(name = "探测器编码", orderNum = "0") + private String detectorCode; +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/StationOptionVO.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/StationOptionVO.java new file mode 100644 index 0000000..5d66873 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/vo/StationOptionVO.java @@ -0,0 +1,14 @@ +package org.jeecg.modules.base.vo; + +import lombok.Data; + +@Data +public class StationOptionVO { + private Long stationId; + private String stationCode; + + public StationOptionVO(Long stationId, String stationCode) { + this.stationId = stationId; + this.stationCode = stationCode; + } +} From 8f63eb5acd8f9e5343e83c0824e52c6648091689 Mon Sep 17 00:00:00 2001 From: duwenyuan <15600000461@163.com> Date: Wed, 8 Jul 2026 15:05:38 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0IMS=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9B=91=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/imsDataMonitorController.java | 54 +--- .../imsDataMonitor/entity/BaseParameter.java | 26 ++ .../jeecg/imsDataMonitor/entity/Config.java | 13 + .../imsDataMonitor/entity/Particulate.java | 4 + .../org/jeecg/imsDataMonitor/entity/Phdf.java | 19 ++ .../entity/PhdfProvisionEfficiency.java | 18 +- .../jeecg/imsDataMonitor/entity/Sauna.java | 19 ++ .../jeecg/imsDataMonitor/entity/Spalax.java | 10 + .../service/IMSDataMonitorService.java | 8 +- .../impl/IMSDataMonitorServiceImpl.java | 279 +++++++++--------- .../org/jeecg/utils/EffConfigManager.java | 271 +++++++++++++++++ .../src/main/resources/compute_efficiency.xml | 46 +++ 12 files changed, 565 insertions(+), 202 deletions(-) create mode 100644 jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/BaseParameter.java create mode 100644 jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Config.java create mode 100644 jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Particulate.java create mode 100644 jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Phdf.java create mode 100644 jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Sauna.java create mode 100644 jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Spalax.java create mode 100644 jeecg-module-large-screen/src/main/java/org/jeecg/utils/EffConfigManager.java create mode 100644 jeecg-module-large-screen/src/main/resources/compute_efficiency.xml diff --git a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/controller/imsDataMonitorController.java b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/controller/imsDataMonitorController.java index b241ce4..584fe8f 100644 --- a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/controller/imsDataMonitorController.java +++ b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/controller/imsDataMonitorController.java @@ -9,6 +9,7 @@ import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.imsDataMonitor.entity.ProvisionData; import org.jeecg.imsDataMonitor.entity.StationInfo; import org.jeecg.imsDataMonitor.service.IMSDataMonitorService; +import org.jeecg.utils.EffConfigManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.GetMapping; @@ -35,21 +36,13 @@ public class imsDataMonitorController { /** * 获取Particulate 台站的有效率和提供率 * - * @param code 类型代码 - * @param startDate 开始日期 - * @param endDate 结束日期 * @return 返回 Result */ @AutoLog(value = "Particulate 台站的有效率") @GetMapping("getParticulate") - public Result getParticulate(@RequestParam(value = "code", required = false) String code, - @RequestParam(value = "startDate", required = false) - @DateTimeFormat(pattern = "yyyy-MM-dd") - Date startDate, - @RequestParam(value = "endDate", required = false) - @DateTimeFormat(pattern = "yyyy-MM-dd") - Date endDate) { -// List data = imsDataMonitorService.getParticulate(code, startDate, endDate); + public Result getParticulate() { + + List data = imsDataMonitorService.getParticulate(); // return Result.OK(data); //TODO 测试待删除 try (InputStream inputStream = imsDataMonitorController.class.getClassLoader() @@ -70,21 +63,12 @@ public class imsDataMonitorController { /** * Spalax 台站的有效率 * - * @param code - * @param startDate - * @param endDate * @return */ @AutoLog(value = "Spalax 台站的有效率") @GetMapping("getSpalax") - public Result getSpalax(@RequestParam(value = "code", required = false) String code, - @RequestParam(value = "startDate", required = false) - @DateTimeFormat(pattern = "yyyy-MM-dd") - Date startDate, - @RequestParam(value = "endDate", required = false) - @DateTimeFormat(pattern = "yyyy-MM-dd") - Date endDate) { -// List data = imsDataMonitorService.getSpalax(code, startDate, endDate); + public Result getSpalax() { + List data = imsDataMonitorService.getSpalax(); // return Result.OK(data); //TODO 测试待删除 try (InputStream inputStream = imsDataMonitorController.class.getClassLoader() @@ -106,21 +90,12 @@ public class imsDataMonitorController { /** * Sauna2 台站的有效率 * - * @param code - * @param startDate - * @param endDate * @return */ @AutoLog(value = "Sauna2 台站的有效率") @GetMapping("getSauna2") - public Result getSauna2(@RequestParam(value = "code", required = false) String code, - @RequestParam(value = "startDate", required = false) - @DateTimeFormat(pattern = "yyyy-MM-dd") - Date startDate, - @RequestParam(value = "endDate", required = false) - @DateTimeFormat(pattern = "yyyy-MM-dd") - Date endDate) { -// List data = imsDataMonitorService.getSauna2(code, startDate, endDate); + public Result getSauna2() { + List data = imsDataMonitorService.getSauna2(); // return Result.OK(data); //TODO 测试待删除 try (InputStream inputStream = imsDataMonitorController.class.getClassLoader() @@ -141,21 +116,12 @@ public class imsDataMonitorController { /** * Sauna3 台站的有效率 * - * @param code - * @param startDate - * @param endDate * @return */ @AutoLog(value = "Sauna3 台站的有效率") @GetMapping("getSauna3") - public Result getSauna3(@RequestParam(value = "code", required = false) String code, - @RequestParam(value = "startDate", required = false) - @DateTimeFormat(pattern = "yyyy-MM-dd") - Date startDate, - @RequestParam(value = "endDate", required = false) - @DateTimeFormat(pattern = "yyyy-MM-dd") - Date endDate) { -// List data = imsDataMonitorService.getSauna3(code, startDate, endDate); + public Result getSauna3() { + List data = imsDataMonitorService.getSauna3(); // return Result.OK(data); //TODO 测试待删除 try (InputStream inputStream = imsDataMonitorController.class.getClassLoader() diff --git a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/BaseParameter.java b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/BaseParameter.java new file mode 100644 index 0000000..6d16c9c --- /dev/null +++ b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/BaseParameter.java @@ -0,0 +1,26 @@ +package org.jeecg.imsDataMonitor.entity; + +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import lombok.Data; + +@Data +public abstract class BaseParameter { + @JacksonXmlProperty(localName = "liveLow") + private double liveLow; + + @JacksonXmlProperty(localName = "liveHigh") + private double liveHigh; + + @JacksonXmlProperty(localName = "quantity") + private int quantity; + + @JacksonXmlProperty(localName = "collectLow") + private double collectLow; + + @JacksonXmlProperty(localName = "collectHigh") + private double collectHigh; + + @JacksonXmlProperty(localName = "number") + private int number; + +} diff --git a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Config.java b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Config.java new file mode 100644 index 0000000..a735cf8 --- /dev/null +++ b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Config.java @@ -0,0 +1,13 @@ +package org.jeecg.imsDataMonitor.entity; + +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import lombok.Data; + +@Data +@JacksonXmlRootElement(localName = "config") +public class Config { + @JacksonXmlProperty(localName = "phdf") + private Phdf phdf; + +} diff --git a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Particulate.java b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Particulate.java new file mode 100644 index 0000000..48b2fc7 --- /dev/null +++ b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Particulate.java @@ -0,0 +1,4 @@ +package org.jeecg.imsDataMonitor.entity; + +public class Particulate extends BaseParameter { +} diff --git a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Phdf.java b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Phdf.java new file mode 100644 index 0000000..4901939 --- /dev/null +++ b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Phdf.java @@ -0,0 +1,19 @@ +package org.jeecg.imsDataMonitor.entity; + +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import lombok.Data; + +@Data +public class Phdf { + @JacksonXmlProperty(localName = "particulate") + private Particulate particulate; + + @JacksonXmlProperty(localName = "spalax") + private Spalax spalax; + + @JacksonXmlProperty(localName = "sauna2") + private Sauna sauna2; + + @JacksonXmlProperty(localName = "sauna3") + private Sauna sauna3; +} diff --git a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/PhdfProvisionEfficiency.java b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/PhdfProvisionEfficiency.java index c7daef8..b51bdf4 100644 --- a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/PhdfProvisionEfficiency.java +++ b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/PhdfProvisionEfficiency.java @@ -7,27 +7,27 @@ import java.util.List; @Data public class PhdfProvisionEfficiency { //liveLow - private String liveLow; + private double liveLow; //liveHigh - private String liveHigh; + private double liveHigh; //quantity - private String quantity; + private double quantity; //collectLow - private String collectLow; + private double collectLow; //collectHigh - private String collectHigh; + private double collectHigh; //curDateTime private String curDateTime; //pretime private String pretime; //number - private String number; + private int number; private String nuclideName; - private String liveQc; - private String mdc; - private String xeVolume; + private double liveQc; + private double mdc; + private double xeVolume; //stationId private List stationId; } diff --git a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Sauna.java b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Sauna.java new file mode 100644 index 0000000..5383103 --- /dev/null +++ b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Sauna.java @@ -0,0 +1,19 @@ +package org.jeecg.imsDataMonitor.entity; + +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import lombok.Data; + +@Data +public class Sauna extends BaseParameter { + @JacksonXmlProperty(localName = "xeVolume") + private double xeVolume; + + @JacksonXmlProperty(localName = "mdc") + private int mdc; + + @JacksonXmlProperty(localName = "nuclideName") + private String nuclideName; + + @JacksonXmlProperty(localName = "liveQc") + private int liveQc; +} diff --git a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Spalax.java b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Spalax.java new file mode 100644 index 0000000..795cd25 --- /dev/null +++ b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/entity/Spalax.java @@ -0,0 +1,10 @@ +package org.jeecg.imsDataMonitor.entity; + +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import lombok.Data; + +@Data +public class Spalax extends BaseParameter { + @JacksonXmlProperty(localName = "liveqc") + private int liveqc; +} diff --git a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/service/IMSDataMonitorService.java b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/service/IMSDataMonitorService.java index 3761867..4b48f1d 100644 --- a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/service/IMSDataMonitorService.java +++ b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/service/IMSDataMonitorService.java @@ -22,13 +22,13 @@ public interface IMSDataMonitorService { *获取Particulate类型的有效率数据 * @return Map> */ - List getParticulate(String code, Date startDate, Date endDate); + List getParticulate(); - List getSpalax(String code, Date startDate, Date endDate); + List getSpalax(); - List getSauna2(String code, Date startDate, Date endDate); + List getSauna2(); - List getSauna3(String code, Date startDate, Date endDate); + List getSauna3(); } diff --git a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/service/impl/IMSDataMonitorServiceImpl.java b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/service/impl/IMSDataMonitorServiceImpl.java index e9aaeff..8317a2d 100644 --- a/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/service/impl/IMSDataMonitorServiceImpl.java +++ b/jeecg-module-large-screen/src/main/java/org/jeecg/imsDataMonitor/service/impl/IMSDataMonitorServiceImpl.java @@ -3,17 +3,18 @@ package org.jeecg.imsDataMonitor.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.annotations.Param; import org.jeecg.common.util.DateUtils; -import org.jeecg.imsDataMonitor.entity.PhdfProvisionEfficiency; -import org.jeecg.imsDataMonitor.entity.ProvisionData; +import org.jeecg.imsDataMonitor.entity.*; import org.jeecg.imsDataMonitor.mapper.IMSDataMonitorMapper; import org.jeecg.imsDataMonitor.service.IMSDataMonitorService; import org.jeecg.modules.base.entity.configuration.GardsStations; import org.jeecg.modules.base.mapper.GardsStationsMapper; import org.jeecg.modules.base.mapper.StasStationSettingMapper; +import org.jeecg.utils.EffConfigManager; import org.jspecify.annotations.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,26 +27,35 @@ import java.util.stream.Collectors; @Slf4j @Service @DS("ora") +@RequiredArgsConstructor() public class IMSDataMonitorServiceImpl implements IMSDataMonitorService { @Autowired private IMSDataMonitorMapper imsDataMonitorMapper; @Autowired private StasStationSettingMapper settingMapper; + private final EffConfigManager configManager; + @Override public List getGardsStationList(String systemType) { return imsDataMonitorMapper.findStationList(systemType); } //region Particulate + + /** + * 获取获取Particulate类型的台站有效率 + *

时间范围默认当前时间往前一个月

+ * + * @return List + */ @Override - public List getParticulate(String code, Date startDate, Date endDate) { + public List getParticulate() { //获取Particulate类型的台站信息 List stations = imsDataMonitorMapper.findStationList("P"); - String[] times = getDataTime(startDate, endDate); + String[] times = getDataTime(); //有效率状态 return getStationDailyData(stations, times[0], times[1]); - } private List getStationDailyData(List stationList, @@ -55,26 +65,19 @@ public class IMSDataMonitorServiceImpl implements IMSDataMonitorService { return new ArrayList<>(); } - - String liveLow = "21.6"; - String liveHigh = "26.4"; - String quantity = "10800"; - String collectLow = "21.6"; - String collectHigh = "26.4"; - String number = "1"; + Particulate particulate = (Particulate) configManager.getParameter("particulate"); //每个台站一个月的有效率 - PhdfProvisionEfficiency efficiency = new PhdfProvisionEfficiency(); List sts = stationList.stream() .map(GardsStations::getStationId) .collect(Collectors.toList()); efficiency.setStationId(sts); - efficiency.setNumber(number); - efficiency.setCollectHigh(collectHigh); - efficiency.setLiveHigh(liveHigh); - efficiency.setCollectLow(collectLow); - efficiency.setLiveLow(liveLow); - efficiency.setQuantity(quantity); + efficiency.setNumber(particulate.getNumber()); + efficiency.setCollectHigh(particulate.getCollectHigh()); + efficiency.setCollectLow(particulate.getCollectLow()); + efficiency.setLiveHigh(particulate.getLiveHigh()); + efficiency.setLiveLow(particulate.getLiveLow()); + efficiency.setQuantity(particulate.getQuantity()); efficiency.setCurDateTime(endTime); efficiency.setPretime(startTime); //查询数据库 获取台站有效率 @@ -85,9 +88,119 @@ public class IMSDataMonitorServiceImpl implements IMSDataMonitorService { } - private String[] getDataTime(Date startDate, Date endDate) { + //endregion - // 使用final确保不可变性,提供更好的线程安全性 + //region SPALAX + @Override + public List getSpalax() { + String actualCode = "SPALAX"; + //获取Particulate类型的台站信息 + List stations = imsDataMonitorMapper.findEfficStationList(actualCode); + String[] times = getDataTime(); + //有效率状态 + return getSpalaxStationDailyData(stations, times[0], times[1]); + } + + private List getSpalaxStationDailyData(List stationList, + String startTime, String endTime) { + + if (CollectionUtil.isEmpty(stationList)) { + return new ArrayList<>(); + } + //每个台站一个月的有效率 + Spalax spalax = (Spalax) configManager.getParameter("spalax"); + + PhdfProvisionEfficiency efficiency = new PhdfProvisionEfficiency(); + List sts = stationList.stream() + .map(GardsStations::getStationId) + .collect(Collectors.toList()); + efficiency.setStationId(sts); + efficiency.setNumber(spalax.getNumber()); + efficiency.setCollectHigh(spalax.getCollectHigh()); + efficiency.setLiveHigh(spalax.getLiveHigh()); + efficiency.setCollectLow(spalax.getCollectLow()); + efficiency.setLiveLow(spalax.getLiveLow()); + efficiency.setQuantity(spalax.getQuantity()); + efficiency.setCurDateTime(endTime); + efficiency.setPretime(startTime); + efficiency.setLiveQc(spalax.getLiveqc()); + //查询数据库 获取台站有效率 + List rawDataList = + imsDataMonitorMapper.findPhdfSpalaxEfficiency(efficiency); + //dataMap.put(station.getStationCode(), rawDataList); + return rawDataList; + + } + + + //endregion + + //region SAUNA II + @Override + public List getSauna2() { + String actualCode = "SAUNA2"; + //获取Particulate类型的台站信息 + List stations = imsDataMonitorMapper.findEfficStationList(actualCode); + String[] times = getDataTime(); + //有效率状态 + return getSauna2StationDailyData(stations, times[0], times[1]); + } + + private List getSauna2StationDailyData(List stationList, + String startTime, String endTime) { + + if (CollectionUtil.isEmpty(stationList)) { + return new ArrayList<>(); + } + //每个台站一个月的有效率 + Sauna sauna2 = (Sauna) configManager.getParameter("sauna2"); + + PhdfProvisionEfficiency efficiency = new PhdfProvisionEfficiency(); + List sts = stationList.stream() + .map(GardsStations::getStationId) + .collect(Collectors.toList()); + efficiency.setStationId(sts); + efficiency.setNumber(sauna2.getNumber()); + efficiency.setCollectHigh(sauna2.getCollectHigh()); + efficiency.setLiveHigh(sauna2.getLiveHigh()); + efficiency.setCollectLow(sauna2.getCollectLow()); + efficiency.setLiveLow(sauna2.getLiveLow()); + efficiency.setQuantity(sauna2.getQuantity()); + efficiency.setCurDateTime(endTime); + efficiency.setPretime(startTime); + efficiency.setNuclideName(sauna2.getNuclideName()); + efficiency.setMdc(sauna2.getMdc()); + efficiency.setLiveQc(sauna2.getLiveQc()); + efficiency.setXeVolume(sauna2.getXeVolume()); + //查询数据库 获取台站有效率 + List rawDataList = + imsDataMonitorMapper.findPhdfSauna2Efficiency(efficiency); + //dataMap.put(station.getStationCode(), rawDataList); + return rawDataList; + + } + //endregion + + //region SAUNA III + @Override + public List getSauna3() { + String actualCode = "SAUNA3"; + //获取Particulate类型的台站信息 + List stations = imsDataMonitorMapper.findEfficStationList(actualCode); + String[] times = getDataTime(); + //TODO 有效率状态 + return getSauna2StationDailyData(stations, times[0], times[1]); + } + //endregion + + /** + * 获取时间范围 默认30天 + * + * @return + */ + private String[] getDataTime() { + Date startDate = null, endDate = null; + //当前时间 final LocalDateTime currentTime = LocalDateTime.now(); // 计算默认时间范围 @@ -110,128 +223,4 @@ public class IMSDataMonitorServiceImpl implements IMSDataMonitorService { return new String[] {startTime, endTime}; } - - //endregion - - //region SPALAX - @Override - public List getSpalax(String code, Date startDate, Date endDate) { - String actualCode = (code == null || code.trim().isEmpty()) ? "SPALAX" : code; - //获取Particulate类型的台站信息 - List stations = imsDataMonitorMapper.findEfficStationList(actualCode); - String[] times = getDataTime(startDate, endDate); - //有效率状态 - return getSpalaxStationDailyData(stations, times[0], times[1]); - } - - private List getSpalaxStationDailyData(List stationList, - String startTime, String endTime) { - - if (CollectionUtil.isEmpty(stationList)) { - return new ArrayList<>(); - } - - - String liveLow = "10"; - String liveHigh = "11"; - String quantity = "10"; - String collectLow = "10.8"; - String collectHigh = "13.2"; - String number = "4"; - String liveqc = "240"; - //每个台站一个月的有效率 - - PhdfProvisionEfficiency efficiency = new PhdfProvisionEfficiency(); - List sts = stationList.stream() - .map(GardsStations::getStationId) - .collect(Collectors.toList()); - efficiency.setStationId(sts); - efficiency.setNumber(number); - efficiency.setCollectHigh(collectHigh); - efficiency.setLiveHigh(liveHigh); - efficiency.setCollectLow(collectLow); - efficiency.setLiveLow(liveLow); - efficiency.setQuantity(quantity); - efficiency.setCurDateTime(endTime); - efficiency.setPretime(startTime); - efficiency.setLiveQc(liveqc); - //查询数据库 获取台站有效率 - List rawDataList = - imsDataMonitorMapper.findPhdfSpalaxEfficiency(efficiency); - //dataMap.put(station.getStationCode(), rawDataList); - return rawDataList; - - } - - - //endregion - - //region SAUNA II - @Override - public List getSauna2(String code, Date startDate, Date endDate) { - String actualCode = (code == null || code.trim().isEmpty()) ? "SAUNA2" : code; - //获取Particulate类型的台站信息 - List stations = imsDataMonitorMapper.findEfficStationList(actualCode); - String[] times = getDataTime(startDate, endDate); - //有效率状态 - return getSauna2StationDailyData(stations, times[0], times[1]); - } - - private List getSauna2StationDailyData(List stationList, - String startTime, String endTime) { - - if (CollectionUtil.isEmpty(stationList)) { - return new ArrayList<>(); - } - - - String collectLow = "5.4"; - String collectHigh = "6.6"; - String liveLow = "4.2"; - String liveHigh = "6.6"; - String quantity = "10"; - String xeVolume = "0.87"; - String mdc = "1"; - String nuclideName = "Xe133"; - String liveQc = "600"; - String number = "16"; - //每个台站一个月的有效率 - - PhdfProvisionEfficiency efficiency = new PhdfProvisionEfficiency(); - List sts = stationList.stream() - .map(GardsStations::getStationId) - .collect(Collectors.toList()); - efficiency.setStationId(sts); - efficiency.setNumber(number); - efficiency.setCollectHigh(collectHigh); - efficiency.setLiveHigh(liveHigh); - efficiency.setCollectLow(collectLow); - efficiency.setLiveLow(liveLow); - efficiency.setQuantity(quantity); - efficiency.setCurDateTime(endTime); - efficiency.setPretime(startTime); - efficiency.setNuclideName(nuclideName); - efficiency.setMdc(mdc); - efficiency.setLiveQc(liveQc); - efficiency.setXeVolume(xeVolume); - //查询数据库 获取台站有效率 - List rawDataList = - imsDataMonitorMapper.findPhdfSauna2Efficiency(efficiency); - //dataMap.put(station.getStationCode(), rawDataList); - return rawDataList; - - } - //endregion - - //region SAUNA III - @Override - public List getSauna3(String code, Date startDate, Date endDate) { - String actualCode = (code == null || code.trim().isEmpty()) ? "SAUNA3" : code; - //获取Particulate类型的台站信息 - List stations = imsDataMonitorMapper.findEfficStationList(actualCode); - String[] times = getDataTime(startDate, endDate); - //有效率状态 - return getSauna2StationDailyData(stations, times[0], times[1]); - } - //endregion } diff --git a/jeecg-module-large-screen/src/main/java/org/jeecg/utils/EffConfigManager.java b/jeecg-module-large-screen/src/main/java/org/jeecg/utils/EffConfigManager.java new file mode 100644 index 0000000..1585f93 --- /dev/null +++ b/jeecg-module-large-screen/src/main/java/org/jeecg/utils/EffConfigManager.java @@ -0,0 +1,271 @@ +package org.jeecg.utils; + +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.imsDataMonitor.entity.*; +import org.springframework.stereotype.Component; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; + +import java.nio.file.InvalidPathException; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@Slf4j +@Component +public class EffConfigManager { + + // 私有构造方法 + private EffConfigManager() { + init(); + } + + private static EffConfigManager instance; + + //全局变量 + private Config config; + + // XML文件路径 + private String xmlFilePath = "compute_efficiency.xml"; + // 解析后的设备配置映射 + private Map parameterMap = new HashMap<>(); + // 配置状态 + private boolean initialized = false; + + /** + * 初始化配置 + * + *

使用默认配置文件路径("compute_efficiency.xml")

+ * + *

文件位置:类路径资源:classpath:config.xml

+ * + * @throws Exception + */ + public void init() { + try { + String filePath = this.getClass().getClassLoader().getResource(xmlFilePath).getPath(); + initializeCache(filePath); + this.initialized = true; + } catch (Exception e) { + log.error("参数初始化失败:" + e.getMessage()); + } + + } + + /** + * 初始化配置管理器(指定文件路径) + * + *

使用指定的XML文件路径初始化配置管理器。

+ * + *

文件格式要求:

+ *
    + *
  • 必须是有效的XML文件
  • + *
  • 必须符合预定义的XML Schema结构
  • + *
  • 编码推荐使用UTF-8
  • + *
  • 文件大小建议不超过10MB
  • + *
+ * + * @param filePath XML配置文件的完整路径或相对路径 + *

路径格式:

+ *
    + *
  • 绝对路径:/home/user/config.xml 或 C:\config\config.xml
  • + *
  • 相对路径:config.xml 或 ./config/config.xml
  • + *
  • 类路径资源:classpath:config.xml(暂不支持)
  • + *
+ * @throws IllegalArgumentException 如果文件路径为null、空字符串或无效路径 + * @throws java.nio.file.NoSuchFileException 如果指定的文件不存在 + * @throws java.nio.file.AccessDeniedException 如果没有文件读取权限 + * @throws com.fasterxml.jackson.core.JsonParseException 如果XML格式不正确 + * @throws com.fasterxml.jackson.databind.JsonMappingException 如果XML结构不匹配 + * @throws Exception 其他IO或解析异常 + * + *

示例:

+ *
+     *                                                             {@code
+     *                                                             // 使用绝对路径
+     *                                                             manager.init("/etc/app/config.xml");
+     *
+     *                                                             // 使用相对路径
+     *                                                             manager.init("conf/production.xml");
+     *
+     *                                                             // 从命令行参数获取路径
+     *                                                             if (args.length > 0) {
+     *                                                                 manager.init(args[0]);
+     *                                                             }
+     *                                                             }
+     *                                                             
+ */ + public void init(String filePath) throws Exception { + if (filePath == null || filePath.trim().isEmpty()) { + throw new IllegalArgumentException("文件路径不能为空"); + } + + try { + Paths.get(filePath); + } catch (InvalidPathException e) { + throw new IllegalArgumentException("无效的文件路径: " + filePath, e); + } + this.xmlFilePath = filePath; + initializeCache(filePath); + + this.initialized = true; + } + + // 获取单例实例 + public static synchronized EffConfigManager getInstance() { + if (instance == null) { + instance = new EffConfigManager(); + } + return instance; + } + + + /** + * 加载并解析XML配置文件 + * + *

内部方法,执行以下操作:

+ *
    + *
  1. 配置XmlMapper解析器
  2. + *
  3. 解析XML到Java对象
  4. + *
  5. 构建设备配置映射表
  6. + *
+ * + * @param xmlFilePath XML文件路径 + * @throws Exception 参考{@link #init(String)}的异常说明 + * @see #init(String) + */ + public void initializeCache(String xmlFilePath) throws Exception { + try { + File file = new File(xmlFilePath); + XmlMapper xmlMapper = new XmlMapper(); + config = xmlMapper.readValue(file, Config.class); + buildMap(); + + } catch (Exception e) { + System.out.println("错误:" + e.getMessage()); + } + } + + /** + * 构建配置映射表 + * + *

将解析后的配置对象转换为按名称索引的映射表,便于快速访问。

+ * + *

设备名称映射规则:

+ *
    + *
  • "particulate" → {@link Particulate} 对象
  • + *
  • "spalax" → {@link Spalax} 对象
  • + *
  • "sauna2" → {@link Sauna} 对象
  • + *
  • "sauna3" → {@link Sauna} 对象
  • + *
+ * + * @throws IllegalStateException 如果全局配置未初始化 + */ + private void buildMap() { + parameterMap.clear(); + if (config == null) { + throw new IllegalStateException("全局配置未初始化"); + } + if (config != null && config.getPhdf() != null) { + Phdf phdf = config.getPhdf(); + + if (phdf.getParticulate() != null) { + parameterMap.put("particulate", phdf.getParticulate()); + } + if (phdf.getSpalax() != null) { + parameterMap.put("spalax", phdf.getSpalax()); + } + if (phdf.getSauna2() != null) { + parameterMap.put("sauna2", phdf.getSauna2()); + } + if (phdf.getSauna3() != null) { + parameterMap.put("sauna3", phdf.getSauna3()); + } + } + } + + /** + * 获取全局配置对象 + */ + public Config getGlobalConfig() { + return config; + } + + /** + * 获取指定名称的配置 + * + *

根据名称返回对应的设备配置对象。

+ * + * @param parameterName 名称,支持以下值: + *
    + *
  • "particulate" - 颗粒物
  • + *
  • "spalax" -
  • + *
  • "sauna2" -
  • + *
  • "sauna3" -
  • + *
+ * @return 设备配置对象,如果名称不存在返回null + * @throws IllegalStateException 如果配置未初始化 + * + *

示例:

+ *
+     * {@code
+     * // 获取颗粒物设备配置
+     * BaseParameter particulate = manager.getDevice("particulate");
+     * if (particulate != null) {
+     *     double liveLow = particulate.getLiveLow();
+     *     // 处理配置...
+     * }
+     *
+     * // 获取氙气设备并转换类型
+     * Sauna sauna2 = (Sauna) manager.getDevice("sauna2");
+     * if (sauna2 != null) {
+     *     String nuclide = sauna2.getNuclideName();
+     * }
+     * }
+     * 
+ */ + public BaseParameter getParameter(String parameterName) { + return parameterMap.get(parameterName); + } + + /** + * 获取所有参数 + */ + public Map getAllDevices() { + return new HashMap<>(parameterMap); + } + + /** + * 重新加载配置 + */ + public void reload() throws Exception { + initializeCache(xmlFilePath); + } + + /** + * 重新加载配置(新文件) + */ + public void reload(String newFilePath) throws Exception { + this.xmlFilePath = newFilePath; + initializeCache(newFilePath); + } + + /** + * 检查配置是否已初始化 + * + * @return true如果配置已初始化,否则false + */ + public boolean isInitialized() { + return initialized && config != null; + } + +} diff --git a/jeecg-module-large-screen/src/main/resources/compute_efficiency.xml b/jeecg-module-large-screen/src/main/resources/compute_efficiency.xml new file mode 100644 index 0000000..128b198 --- /dev/null +++ b/jeecg-module-large-screen/src/main/resources/compute_efficiency.xml @@ -0,0 +1,46 @@ + + + + + 21.6 + 26.4 + 10800 + 21.6 + 26.4 + 1 + + + 10 + 11 + 10 + 10.8 + 13.2 + 4 + 240 + + + 5.4 + 6.6 + 4.2 + 6.6 + 10 + 0.87 + 1 + Xe133 + 600 + 16 + + + 5.4 + 6.6 + 4.2 + 6.6 + 10 + 0.87 + 1 + Xe133 + 600 + 16 + + + \ No newline at end of file From 7f3b639bf3b482d72bbe0e23f5a8118acd3e7d99 Mon Sep 17 00:00:00 2001 From: duwenyuan <15600000461@163.com> Date: Wed, 8 Jul 2026 15:15:10 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BA=93jackson-dataform?= =?UTF-8?q?at-xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jeecg-module-large-screen/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jeecg-module-large-screen/pom.xml b/jeecg-module-large-screen/pom.xml index 235bd74..65f3811 100644 --- a/jeecg-module-large-screen/pom.xml +++ b/jeecg-module-large-screen/pom.xml @@ -27,5 +27,10 @@ org.springframework.cloud spring-cloud-openfeign-core + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.15.2 + \ No newline at end of file From 3a1c57b161b6a67c6ae1ba562559b99ab0d7a86b Mon Sep 17 00:00:00 2001 From: duwenyuan <15600000461@163.com> Date: Wed, 8 Jul 2026 15:15:53 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BA=A7=E8=81=94?= =?UTF-8?q?=E7=AC=A6=E5=90=88=E6=A0=A1=E6=AD=A3=E5=9B=A0=E5=AD=90=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jeecg-module-monitor-info-database/pom.xml | 6 + ...GardsCorrectionFactorDetailController.java | 217 ++++++++++++++++ .../GardsCorrectionFactorEffController.java | 234 ++++++++++++++++++ .../GardsCorrectionFactorDetailService.java | 28 +++ .../GardsCorrectionFactorEffService.java | 59 +++++ ...ardsCorrectionFactorDetailServiceImpl.java | 58 +++++ .../GardsCorrectionFactorEffServiceImpl.java | 87 +++++++ 7 files changed, 689 insertions(+) create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorDetailController.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorEffController.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorDetailService.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorEffService.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorDetailServiceImpl.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorEffServiceImpl.java diff --git a/jeecg-module-monitor-info-database/pom.xml b/jeecg-module-monitor-info-database/pom.xml index b52058d..6108559 100644 --- a/jeecg-module-monitor-info-database/pom.xml +++ b/jeecg-module-monitor-info-database/pom.xml @@ -23,5 +23,11 @@ jeecg-boot-base-core ${jeecgboot.version} + + io.swagger + swagger-annotations + 1.6.6 + compile + \ No newline at end of file diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorDetailController.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorDetailController.java new file mode 100644 index 0000000..d78880c --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorDetailController.java @@ -0,0 +1,217 @@ +package org.jeecg.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactor; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorDetail; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorEff; +import org.jeecg.modules.base.vo.DetectorMapDTO; +import org.jeecg.modules.base.vo.GardsCorrectionFactorDetailVO; +import org.jeecg.modules.base.vo.GardsCorrectionFactorEffVO; +import org.jeecg.service.GardsCorrectionFactorDetailService; +import org.jeecg.service.GardsCorrectionFactorEffService; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 级联符合校正因子库--校正因子 + */ +@Slf4j +@RestController +@RequestMapping("/gardsCorrectionFactorDetail") +public class GardsCorrectionFactorDetailController { + final short titleHeight = 8; + @Autowired + private GardsCorrectionFactorDetailService detailService; + @Autowired + private GardsCorrectionFactorEffService effService; + + /** + * 分页查询 + */ + @GetMapping("/page") + @Operation(summary = "分页查询") + public Result> list( + @RequestParam(defaultValue = "1") int pageNum, + @RequestParam(defaultValue = "10") int size, + @RequestParam(required = false)String stationCode, + @RequestParam(required = false)String detectorCode, + @RequestParam(required = false)String nuclideName) { + return Result.ok( + detailService.findPage(pageNum, size, stationCode, detectorCode, nuclideName)); + } + + /** + * 添加 + * + * @param detail + * @return + */ + @PostMapping("/add") + @Operation(summary = "添加") + public Result add(@RequestBody GardsCorrectionFactorDetail detail) { + return Result.ok(detailService.save(detail)); + } + + /** + * 更新 + * + * @param detail + * @return + */ + @PutMapping("/update") + @Operation(summary = "更新") + public Result update(@RequestBody GardsCorrectionFactorDetail detail) { + return Result.ok(detailService.updateById(detail)); + } + + /** + * 删除 + * + * @param id + * @return + */ + @DeleteMapping("/delete") + @Operation(summary = "删除") + public Result delete(@RequestParam(name = "id") Integer id) { + return Result.ok(detailService.removeById(id)); + } + + @AutoLog(value = "导出模版") + @Operation(summary = "导出模版") + @GetMapping("/exportTemplate") + public void exportTemplate(HttpServletResponse response) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("探测器模拟及联符合校正因子信息"); + params.setFixedTitle(true); + params.setTitleHeight(titleHeight); + params.setType(ExcelType.XSSF); + ExcelExportUtil.exportExcel(params, GardsCorrectionFactorDetailVO.class, new ArrayList<>()) + .write(response.getOutputStream()); + } + + @AutoLog(value = "导出Excel") + @Operation(summary = "导出校正因子Excel") + @GetMapping("/exportExcel") + public void exportExcel(HttpServletResponse response, + @RequestParam(required = false) String stationCode, + @RequestParam(required = false) String detectorCode, + @RequestParam(required = false) String nuclideName) + throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("探测器模拟及联符合校正因子信息"); + params.setFixedTitle(true); + params.setTitleHeight(titleHeight); + params.setType(ExcelType.XSSF); + + List list = detailService.findList( + stationCode, detectorCode, nuclideName); + ExcelExportUtil.exportExcel(params, GardsCorrectionFactorDetailVO.class, list) + .write(response.getOutputStream()); + } + + + /** + * 通过excel导入数据 + * + * @param request + * @return + */ + @AutoLog(value = "导入GardsAccelerator数据") + @PostMapping(value = "/importExcel") + public Result importExcel(HttpServletRequest request) { + // 1. 获取上传文件 + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + + // 2. 遍历文件进行处理 + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + ImportParams params = new ImportParams(); + // 设置标题行行数(通常为1,如果没有标题填0) + params.setTitleRows(1); + // 设置表头行数(通常为1) + params.setHeadRows(1); + params.setNeedSave(true); + + try { + // 3. 使用 AutoPoi 工具类解析 Excel + List list = + ExcelImportUtil.importExcel(file.getInputStream(), + GardsCorrectionFactorDetailVO.class, params); + + // 预加载映射关系 (Key: Code, Value: DTO) + // SQL: SELECT DETECTOR_ID, DETECTOR_CODE, STATION_ID FROM GARDS_DETECTORS + Map refMap = effService.queryAllDetectorRef().stream() + .collect(Collectors.toMap(DetectorMapDTO::getDetectorCode, d -> d, + (k1, k2) -> k1)); + + // 转换GardsCorrectionFactorDetail并保存 + List entityList = new ArrayList<>(); + + for (GardsCorrectionFactorDetailVO vo : list) { + if (StringUtils.isEmpty(vo.getDetectorCode())) { + continue; + } + + // 根据 Excel 里的探测器代码获取数据库 ID + DetectorMapDTO ref = refMap.get(vo.getDetectorCode().trim()); + + if (ref == null) { + return Result.error( + "导入中止:系统中不存在探测器代码 [" + vo.getDetectorCode() + "]"); + } + GardsCorrectionFactorDetail effEntity = new GardsCorrectionFactorDetail(); + BeanUtils.copyProperties(vo, effEntity); + // 填充两个关联 ID + effEntity.setDetectorId(ref.getDetectorId()); + effEntity.setStationId(ref.getStationId()); + entityList.add(effEntity); + } + + // 4. 批量保存数据到数据库 + if (!CollectionUtils.isEmpty(entityList)) { + + //detailService.saveBatch(entityList); + + + entityList.forEach(item -> detailService.save(item)); + } + return Result.OK("文件导入成功!数据行数:" + list.size()); + } catch (Exception e) { + return Result.error("文件导入失败:" + e.getMessage()); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.error("文件导入失败!"); + } + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorEffController.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorEffController.java new file mode 100644 index 0000000..2c596c3 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorEffController.java @@ -0,0 +1,234 @@ +package org.jeecg.controller; + +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactor; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorEff; +import org.jeecg.modules.base.vo.DetectorMapDTO; +import org.jeecg.modules.base.vo.DetectorOptionVO; +import org.jeecg.modules.base.vo.GardsCorrectionFactorEffVO; +import org.jeecg.modules.base.vo.StationOptionVO; +import org.jeecg.service.GardsCorrectionFactorEffService; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * 级联符合校正因子库--峰效率 + */ +@Slf4j +@RestController +@RequestMapping("/gardsCorrectionFactorEff") +public class GardsCorrectionFactorEffController { + private final short titleHeight = 8; + @Autowired + private GardsCorrectionFactorEffService effService; + + /** + * 分页查询 + */ + @GetMapping("/page") + @Operation(summary = "分页查询") + public Result list(@RequestParam(defaultValue = "1") int pageNum, + @RequestParam(defaultValue = "10") int size, + @RequestParam(required = false) String stationCode, + @RequestParam(required = false) String detectorCode) { + return Result.OK(effService.findPage(pageNum, size, stationCode, detectorCode)); + } + + /** + * 添加 + * + * @param eff 实体 + * @return Result + */ + @PostMapping("/add") + @Operation(summary = "添加") + public Result add(@RequestBody GardsCorrectionFactorEff eff) { + + return Result.OK(effService.add(eff)); + } + + /** + * 更新 + * + * @param eff 实体 + * @return Result + */ + @PutMapping("/update") + @Operation(summary = "更新") + public Result update(@RequestBody GardsCorrectionFactorEff eff) { + return Result.OK(effService.update(eff)); + } + + /** + * 删除 + * + * @param id 主键ID + * @return Result + */ + @DeleteMapping("/delete") + @Operation(summary = "删除") + public Result delete(@RequestParam(name = "id") Integer id) { + effService.delete(id); + return Result.OK(); + } + + + @AutoLog(value = "导出模版") + @Operation(summary = "导出模版") + @GetMapping("/exportTemplate") + public void exportTemplate(HttpServletResponse response) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("探测器模拟及联符合校正因子信息"); + params.setFixedTitle(true); + params.setTitleHeight(titleHeight); + params.setType(ExcelType.XSSF); + ExcelExportUtil.exportExcel(params, GardsCorrectionFactorEffVO.class, new ArrayList<>()) + .write(response.getOutputStream()); + } + + @AutoLog(value = "导出Excel") + @Operation(summary = "导出校正因子Excel") + @GetMapping("/exportExcel") + public void exportExcel(HttpServletResponse response, + @RequestParam(required = false) String stationCode, + @RequestParam(required = false) String detectorCode) + throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("探测器模拟及联符合校正因子效率信息"); + params.setFixedTitle(true); + params.setTitleHeight(titleHeight); + params.setType(ExcelType.XSSF); + + List list = effService.selectVOList( + stationCode, detectorCode); + ExcelExportUtil.exportExcel(params, GardsCorrectionFactor.class, list) + .write(response.getOutputStream()); + } + + + /** + * 通过excel导入数据 + * + * @param request + * @return + */ + @AutoLog(value = "导入GardsAccelerator数据") + @PostMapping(value = "/importExcel") + public Result importExcel(HttpServletRequest request) { + // 1. 获取上传文件 + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + + // 2. 遍历文件进行处理 + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + ImportParams params = new ImportParams(); + // 设置标题行行数(通常为1,如果没有标题填0) + params.setTitleRows(1); + // 设置表头行数(通常为1) + params.setHeadRows(1); + params.setNeedSave(true); + + try { + // 使用 AutoPoi 工具类解析 Excel + List voList = + ExcelImportUtil.importExcel(file.getInputStream(), + GardsCorrectionFactorEffVO.class, params); + + if (!CollectionUtils.isEmpty(voList)) { + + // 预加载映射关系 (Key: Code, Value: DTO) + // SQL: SELECT DETECTOR_ID, DETECTOR_CODE, STATION_ID FROM GARDS_DETECTORS + Map refMap = effService.queryAllDetectorRef().stream() + .collect(Collectors.toMap(DetectorMapDTO::getDetectorCode, d -> d, + (k1, k2) -> k1)); + + // 转换GardsCorrectionFactorEff并保存 + List entityList = new ArrayList<>(); + + for (GardsCorrectionFactorEffVO vo : voList) { + if (StringUtils.isEmpty(vo.getDetectorCode())) { + continue; + } + + // 根据 Excel 里的探测器代码获取数据库 ID + DetectorMapDTO ref = refMap.get(vo.getDetectorCode().trim()); + + if (ref == null) { + return Result.error( + "导入中止:系统中不存在探测器代码 [" + vo.getDetectorCode() + + "]"); + } + GardsCorrectionFactorEff effEntity = new GardsCorrectionFactorEff(); + BeanUtils.copyProperties(vo, effEntity); + // 填充两个关联 ID + effEntity.setDetectorId(ref.getDetectorId()); + effEntity.setStationId(ref.getStationId()); + entityList.add(effEntity); + } + // 4. 批量保存数据到数据库 + if (!CollectionUtils.isEmpty(entityList)) { + entityList.forEach(item -> effService.save(item)); + + //effService.saveBatch(entityList); + } + return Result.OK("文件导入成功!数据行数:" + entityList.size()); + } + + } catch (Exception e) { + return Result.error("文件导入失败:" + e.getMessage()); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.error("文件导入失败!"); + } + + @AutoLog(value = "获取站点列表") + + + // 下拉框:站点 + @GetMapping("/stations") + public List getStations() { + return effService.getStationOptions(); + } + + // 根据站点 ID 过滤探测器 + @AutoLog(value = "获取探测器") + @GetMapping("/detectors") + public List getDetectors(@RequestParam(value = "stationId",required = false) Long stationId) { + if (stationId == null) { + return Collections.emptyList(); + } + return effService.getDetectorOptions(stationId); + } + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorDetailService.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorDetailService.java new file mode 100644 index 0000000..74a1e0f --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorDetailService.java @@ -0,0 +1,28 @@ +package org.jeecg.service; + +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactor; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorDetail; +import org.jeecg.modules.base.vo.GardsCorrectionFactorDetailVO; + +import java.util.List; +import java.util.Map; + +public interface GardsCorrectionFactorDetailService extends IService { + + IPage findPage(Integer pageNum, Integer pageSize, + String stationCode, String detectorCode, String nuclideName); + + List findList(String stationCode, String detectorCode, String nuclideName); + + + List>selectStations(); + + List>selectdetectors(); + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorEffService.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorEffService.java new file mode 100644 index 0000000..dd68ee0 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorEffService.java @@ -0,0 +1,59 @@ +package org.jeecg.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorEff; +import org.jeecg.modules.base.vo.*; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.stream.Collectors; + +public interface GardsCorrectionFactorEffService extends IService { + IPage findPage(Integer pageNum, Integer pageSize, + String stationCode, String detectorCode); + + + /** + * 添加 + */ + + boolean add(GardsCorrectionFactorEff entity); + + /** + * 修改 + * + * @param entity + * @return + */ + boolean update(GardsCorrectionFactorEff entity); + + /** + * 删除 + * + * @param id 主键ID + * @return + */ + boolean delete(Integer id); + + + /** + * 导出数据 + * + * @param stationCode 台站编码 + * @param detectorCode 探测器编码 + * @return List + */ + List selectVOList(String stationCode, String detectorCode); + + List queryAllDetectorRef(); + + + // 获取所有站点 + List getStationOptions(); + + // 根据站点联动获取探测器 + List getDetectorOptions(Long stationId); + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorDetailServiceImpl.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorDetailServiceImpl.java new file mode 100644 index 0000000..d568d28 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorDetailServiceImpl.java @@ -0,0 +1,58 @@ +package org.jeecg.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactor; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorDetail; +import org.jeecg.modules.base.mapper.GardsCorrectionFactorDetailMapper; +import org.jeecg.modules.base.mapper.GardsCorrectionFactorMapper; +import org.jeecg.service.GardsCorrectionFactorDetailService; +import org.jeecg.modules.base.vo.GardsCorrectionFactorDetailVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.List; +import java.util.Map; + +@Service +@DS("ora") +public class GardsCorrectionFactorDetailServiceImpl + extends ServiceImpl + implements GardsCorrectionFactorDetailService { + @Autowired + private GardsCorrectionFactorMapper factorMapper; + + @Override + public IPage findPage(Integer pageNum, Integer pageSize, + String stationCode, String detectorCode, String nuclideName) { + Page page = new Page<>(pageNum, pageSize); + // 对应界面顶部的搜索框逻辑 + + return baseMapper.selectCombinedPage(page, stationCode,detectorCode,nuclideName); + } + + @Override + public List findList(String stationCode, String detectorCode, String nuclideName) { + + return baseMapper.findList(stationCode,detectorCode,nuclideName); + + } + + @Override + public List> selectStations() { + List> stations= baseMapper.selectStations(); + return stations; + } + + @Override + public List> selectdetectors() { + List> detectors= baseMapper.selectdetectors(); + return detectors; + } + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorEffServiceImpl.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorEffServiceImpl.java new file mode 100644 index 0000000..209e8c3 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorEffServiceImpl.java @@ -0,0 +1,87 @@ +package org.jeecg.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorDetail; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactorEff; +import org.jeecg.modules.base.mapper.GardsCorrectionFactorEffMapper; +import org.jeecg.modules.base.vo.*; +import org.jeecg.service.GardsCorrectionFactorEffService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +@DS("ora") +public class GardsCorrectionFactorEffServiceImpl + extends ServiceImpl + implements GardsCorrectionFactorEffService { + + @Override + public IPage findPage(Integer pageNum, Integer pageSize, + String stationCode, String detectorCode) { + Page page = new Page<>(pageNum, pageSize); + + return baseMapper.selectCombinedPage(page, stationCode, detectorCode); + } + + + // 增加 (增) + @Transactional + public boolean add(GardsCorrectionFactorEff entity) { + return this.save(entity); + } + + // 修改 (改) + @Transactional + public boolean update(GardsCorrectionFactorEff entity) { + return this.updateById(entity); + } + + // 删除 (删) + @Transactional + public boolean delete(Integer id) { + return this.removeById(id); + } + + /** + * 导出数据 + * @param stationCode 台站编码 + * @param detectorCode 探测器编码 + * @return List + */ + public List selectVOList(String stationCode, String detectorCode) { + return baseMapper.selectVOList(stationCode, detectorCode); + + } + + @Override + public List queryAllDetectorRef() { + return baseMapper.queryAllDetectorRef(); + } + + + // 获取所有站点 + public List getStationOptions() { + return baseMapper.getStationOptions().stream() + .map(s -> new StationOptionVO(s.getStationId(), s.getStationCode())) + .collect(Collectors.toList()); + } + + // 根据站点联动获取探测器 + public List getDetectorOptions(Long stationId) { + return baseMapper.getDetectorOptions(stationId).stream() + .map(d -> new DetectorOptionVO(d.getDetectorId(), d.getDetectorCode())) + .collect(Collectors.toList()); + } + + + + +} From 70852d88b8b04aa9852e7d9e9f092a48f4c1dc77 Mon Sep 17 00:00:00 2001 From: duwenyuan <15600000461@163.com> Date: Wed, 8 Jul 2026 15:20:05 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/HostMonitorServiceImpl.java | 325 +++++++++++------- 1 file changed, 195 insertions(+), 130 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/monitor/service/impl/HostMonitorServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/monitor/service/impl/HostMonitorServiceImpl.java index beecfa5..6bcdbbe 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/monitor/service/impl/HostMonitorServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/monitor/service/impl/HostMonitorServiceImpl.java @@ -33,82 +33,94 @@ public class HostMonitorServiceImpl implements HostMonitorService { * 获取CPU信息 */ @Override - public Map getCpuInfo(String ip,String conditions) { - Map result = new HashMap<>(); + public Map getCpuInfo(String ip, String conditions) { + Map result = new HashMap<>(); try { //Prometheus 服务器地址 String url = serverProperties.getServerUrl(); //目标主机实例(node-exporter 的地址) String instance = this.getInstance(ip); //查询CPU利用率 - PrometheusHostQueryTypeEnum queryTypeEnum = PrometheusHostQueryTypeEnum.getQueryTypeEnum(conditions); + PrometheusHostQueryTypeEnum queryTypeEnum = + PrometheusHostQueryTypeEnum.getQueryTypeEnum(conditions); String exprTime = queryTypeEnum.getExprTime(); - String cpuQuery = "100 * (1 - avg(rate(node_cpu_seconds_total{mode=\"idle\", instance=\""+instance+"\"}["+exprTime+"])))"; + String cpuQuery = + "100 * (1 - avg(rate(node_cpu_seconds_total{mode=\"idle\", instance=\"" + + instance + "\"}[" + exprTime + "])))"; PrometheusResponse response = webClient.get() - .uri(buildUri(url,cpuQuery)) + .uri(buildUri(url, cpuQuery)) .retrieve() .bodyToMono(PrometheusResponse.class) .block(); - if(Objects.nonNull(response) && + if (Objects.nonNull(response) && Objects.nonNull(response.getData()) && CollUtil.isNotEmpty(response.getData().getResult()) ) { - PrometheusResponse.Result cpuInfo = response.getData().getResult().get(0); - if(CollUtil.isNotEmpty(cpuInfo.getValue())) { - Date date = new Date(cpuInfo.getValue().get(0).longValue()*1000); - Double useRate = BigDecimal.valueOf(cpuInfo.getValue().get(1)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + PrometheusResponse.Result cpuInfo = response.getData().getResult().get(0); + if (CollUtil.isNotEmpty(cpuInfo.getValue())) { + Date date = new Date(cpuInfo.getValue().get(0).longValue() * 1000); + Double useRate = BigDecimal.valueOf(cpuInfo.getValue().get(1)) + .setScale(2, RoundingMode.HALF_UP).doubleValue(); result.put("date", DateUtil.format(date, "MM/dd HH:mm:ss")); result.put("usageRate", useRate); } } - }catch (Exception e){ - log.error("获取CPU信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}",e.getMessage()); + } catch (Exception e) { + log.error( + "获取CPU信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}", + e.getMessage()); } - return result; + return result; } /** * 获取CPU信息列表 */ @Override - public List> getCpuInfoList(String ip,String conditions) { - List> result = new ArrayList<>(); + public List> getCpuInfoList(String ip, String conditions) { + List> result = new ArrayList<>(); try { //Prometheus 服务器地址 String url = serverProperties.getServerUrl(); //目标主机实例(node-exporter 的地址) String instance = this.getInstance(ip); //查询CPU利用率 - PrometheusHostQueryTypeEnum queryTypeEnum = PrometheusHostQueryTypeEnum.getQueryTypeEnum(conditions); + PrometheusHostQueryTypeEnum queryTypeEnum = + PrometheusHostQueryTypeEnum.getQueryTypeEnum(conditions); long end = Instant.now().getEpochSecond(); long start = end - queryTypeEnum.getLastSecond(); String step = queryTypeEnum.getStep(); String exprTime = queryTypeEnum.getExprTime(); - String cpuQuery = "100 * (1 - avg(rate(node_cpu_seconds_total{mode=\"idle\", instance=\""+instance+"\"}["+exprTime+"])))"; + String cpuQuery = + "100 * (1 - avg(rate(node_cpu_seconds_total{mode=\"idle\", instance=\"" + + instance + "\"}[" + exprTime + "])))"; PrometheusResponse response = webClient.get() - .uri(buildUri(url,cpuQuery,start,end,step)) + .uri(buildUri(url, cpuQuery, start, end, step)) .retrieve() .bodyToMono(PrometheusResponse.class) .block(); - if(Objects.nonNull(response) && + if (Objects.nonNull(response) && Objects.nonNull(response.getData()) && CollUtil.isNotEmpty(response.getData().getResult()) ) { - PrometheusResponse.Result cpuInfoList = response.getData().getResult().get(0); - if(CollUtil.isNotEmpty(cpuInfoList.getValues())) { + PrometheusResponse.Result cpuInfoList = response.getData().getResult().get(0); + if (CollUtil.isNotEmpty(cpuInfoList.getValues())) { List> pointDatas = cpuInfoList.getValues(); - for(List pointData : pointDatas) { - Map pointDataMap = new HashMap<>(); - Date date = new Date(pointData.get(0).longValue()*1000); - Double useRate = BigDecimal.valueOf(pointData.get(1)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + for (List pointData : pointDatas) { + Map pointDataMap = new HashMap<>(); + Date date = new Date(pointData.get(0).longValue() * 1000); + Double useRate = BigDecimal.valueOf(pointData.get(1)) + .setScale(2, RoundingMode.HALF_UP).doubleValue(); pointDataMap.put("date", DateUtil.format(date, "MM/dd HH:mm:ss")); pointDataMap.put("usageRate", useRate); result.add(pointDataMap); } } } - }catch (Exception e){ - log.error("获取CPU信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}",e.getMessage()); + } catch (Exception e) { + log.error( + "获取CPU信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}", + e.getMessage()); } return result; } @@ -117,42 +129,45 @@ public class HostMonitorServiceImpl implements HostMonitorService { * 获取CPU核心数 */ @Override - public Map getCpuCoreInfo(String ip) { - Map result = new HashMap<>(); + public Map getCpuCoreInfo(String ip) { + Map result = new HashMap<>(); try { //Prometheus 服务器地址 String url = serverProperties.getServerUrl(); //目标主机实例(node-exporter 的地址) String instance = this.getInstance(ip); //查询CPU核数 - String cpuCoreQuery = "count(count by (cpu) (node_cpu_seconds_total{instance=\"" + instance + "\"}))"; + String cpuCoreQuery = + "count(count by (cpu) (node_cpu_seconds_total{instance=\"" + instance + "\"}))"; PrometheusResponse response = webClient.get() - .uri(buildUri(url,cpuCoreQuery)) + .uri(buildUri(url, cpuCoreQuery)) .retrieve() .bodyToMono(PrometheusResponse.class) .block(); - if(Objects.nonNull(response) && + if (Objects.nonNull(response) && Objects.nonNull(response.getData()) && CollUtil.isNotEmpty(response.getData().getResult()) ) { - PrometheusResponse.Result cpuInfo = response.getData().getResult().get(0); - if(CollUtil.isNotEmpty(cpuInfo.getValue())) { + PrometheusResponse.Result cpuInfo = response.getData().getResult().get(0); + if (CollUtil.isNotEmpty(cpuInfo.getValue())) { Integer cpuCores = cpuInfo.getValue().get(1).intValue(); result.put("cpuCores", cpuCores); } } - }catch (Exception e){ - log.error("获取CPU核心数错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}",e.getMessage()); + } catch (Exception e) { + log.error( + "获取CPU核心数错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}", + e.getMessage()); } - return result; + return result; } /** * 获取内存信息 */ @Override - public Map getMemoryInfo(String ip) { - Map result = new HashMap<>(); + public Map getMemoryInfo(String ip) { + Map result = new HashMap<>(); try { //Prometheus 服务器地址 String url = serverProperties.getServerUrl(); @@ -193,28 +208,33 @@ public class HostMonitorServiceImpl implements HostMonitorService { // } // } //使用率 - String usageRateQuery = "(1 - (node_memory_MemAvailable_bytes{instance=\""+instance+"\"} / node_memory_MemTotal_bytes{instance=\""+instance+"\"})) * 100"; + String usageRateQuery = "(1 - (node_memory_MemAvailable_bytes{instance=\"" + instance + + "\"} / node_memory_MemTotal_bytes{instance=\"" + instance + "\"})) * 100"; PrometheusResponse usageRateResponse = webClient.get() - .uri(buildUri(url,usageRateQuery)) + .uri(buildUri(url, usageRateQuery)) .retrieve() .bodyToMono(PrometheusResponse.class) .block(); - if(Objects.nonNull(usageRateResponse) && + if (Objects.nonNull(usageRateResponse) && Objects.nonNull(usageRateResponse.getData()) && CollUtil.isNotEmpty(usageRateResponse.getData().getResult()) ) { - PrometheusResponse.Result usageRateInfo = usageRateResponse.getData().getResult().get(0); - if(CollUtil.isNotEmpty(usageRateInfo.getValue())) { - Date date = new Date(usageRateInfo.getValue().get(0).longValue()*1000); - Double usageRate = BigDecimal.valueOf(usageRateInfo.getValue().get(1)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + PrometheusResponse.Result usageRateInfo = + usageRateResponse.getData().getResult().get(0); + if (CollUtil.isNotEmpty(usageRateInfo.getValue())) { + Date date = new Date(usageRateInfo.getValue().get(0).longValue() * 1000); + Double usageRate = BigDecimal.valueOf(usageRateInfo.getValue().get(1)) + .setScale(2, RoundingMode.HALF_UP).doubleValue(); result.put("date", DateUtil.format(date, "MM/dd HH:mm:ss")); result.put("usageRate", usageRate); } } - }catch (Exception e){ - log.error("获取内存信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}",e.getMessage()); + } catch (Exception e) { + log.error( + "获取内存信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}", + e.getMessage()); } - return result; + return result; } /** @@ -223,43 +243,48 @@ public class HostMonitorServiceImpl implements HostMonitorService { * @param conditions */ @Override - public List> getMemoryInfoList(String ip,String conditions) { - List> result = new ArrayList<>(); + public List> getMemoryInfoList(String ip, String conditions) { + List> result = new ArrayList<>(); try { //Prometheus 服务器地址 String url = serverProperties.getServerUrl(); //目标主机实例(node-exporter 的地址) String instance = this.getInstance(ip); //使用率 - String usageRateQuery = "(1 - (node_memory_MemAvailable_bytes{instance=\""+instance+"\"} / node_memory_MemTotal_bytes{instance=\""+instance+"\"})) * 100"; - PrometheusHostQueryTypeEnum queryTypeEnum = PrometheusHostQueryTypeEnum.getQueryTypeEnum(conditions); + String usageRateQuery = "(1 - (node_memory_MemAvailable_bytes{instance=\"" + instance + + "\"} / node_memory_MemTotal_bytes{instance=\"" + instance + "\"})) * 100"; + PrometheusHostQueryTypeEnum queryTypeEnum = + PrometheusHostQueryTypeEnum.getQueryTypeEnum(conditions); long end = Instant.now().getEpochSecond(); long start = end - queryTypeEnum.getLastSecond(); String step = queryTypeEnum.getStep(); PrometheusResponse response = webClient.get() - .uri(buildUri(url,usageRateQuery,start,end,step)) + .uri(buildUri(url, usageRateQuery, start, end, step)) .retrieve() .bodyToMono(PrometheusResponse.class) .block(); - if(Objects.nonNull(response) && + if (Objects.nonNull(response) && Objects.nonNull(response.getData()) && CollUtil.isNotEmpty(response.getData().getResult()) ) { - PrometheusResponse.Result usageRateList = response.getData().getResult().get(0); - if(CollUtil.isNotEmpty(usageRateList.getValues())) { + PrometheusResponse.Result usageRateList = response.getData().getResult().get(0); + if (CollUtil.isNotEmpty(usageRateList.getValues())) { List> pointDatas = usageRateList.getValues(); - for(List pointData : pointDatas) { - Map pointDataMap = new HashMap<>(); - Date date = new Date(pointData.get(0).longValue()*1000); - Double useRate = BigDecimal.valueOf(pointData.get(1)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + for (List pointData : pointDatas) { + Map pointDataMap = new HashMap<>(); + Date date = new Date(pointData.get(0).longValue() * 1000); + Double useRate = BigDecimal.valueOf(pointData.get(1)) + .setScale(2, RoundingMode.HALF_UP).doubleValue(); pointDataMap.put("date", DateUtil.format(date, "MM/dd HH:mm:ss")); pointDataMap.put("usageRate", useRate); result.add(pointDataMap); } } } - }catch (Exception e){ - log.error("获取CPU信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}",e.getMessage()); + } catch (Exception e) { + log.error( + "获取CPU信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}", + e.getMessage()); } return result; } @@ -279,18 +304,21 @@ public class HostMonitorServiceImpl implements HostMonitorService { //查询总内存 String totalMemoryQuery = "node_memory_MemTotal_bytes{instance=\"" + instance + "\"}"; PrometheusResponse totalMemoryResponse = webClient.get() - .uri(buildUri(url,totalMemoryQuery)) + .uri(buildUri(url, totalMemoryQuery)) .retrieve() .bodyToMono(PrometheusResponse.class) .block(); - if(Objects.nonNull(totalMemoryResponse) && + if (Objects.nonNull(totalMemoryResponse) && Objects.nonNull(totalMemoryResponse.getData()) && CollUtil.isNotEmpty(totalMemoryResponse.getData().getResult()) ) { - PrometheusResponse.Result totalMemoryInfo = totalMemoryResponse.getData().getResult().get(0); - if(CollUtil.isNotEmpty(totalMemoryInfo.getValue())) { - Double totalMemory = BigDecimal.valueOf(totalMemoryInfo.getValue().get(1)/1024/1024/1024).setScale(2, RoundingMode.HALF_UP).doubleValue(); - result.put("totalMemory",totalMemory); + PrometheusResponse.Result totalMemoryInfo = + totalMemoryResponse.getData().getResult().get(0); + if (CollUtil.isNotEmpty(totalMemoryInfo.getValue())) { + Double totalMemory = + BigDecimal.valueOf(totalMemoryInfo.getValue().get(1) / 1024 / 1024 / 1024) + .setScale(2, RoundingMode.HALF_UP).doubleValue(); + result.put("totalMemory", totalMemory); } } return result; @@ -300,58 +328,71 @@ public class HostMonitorServiceImpl implements HostMonitorService { * 获取网络信息 */ @Override - public Map getNetworkInfo(String ip,String conditions) { - Map result = new HashMap<>(); + public Map getNetworkInfo(String ip, String conditions) { + Map result = new HashMap<>(); try { //Prometheus 服务器地址 String url = serverProperties.getServerUrl(); //目标主机实例(node-exporter 的地址) String instance = this.getInstance(ip); - PrometheusHostQueryTypeEnum queryTypeEnum = PrometheusHostQueryTypeEnum.getQueryTypeEnum(conditions); + PrometheusHostQueryTypeEnum queryTypeEnum = + PrometheusHostQueryTypeEnum.getQueryTypeEnum(conditions); String exprTime = queryTypeEnum.getExprTime(); //接收带宽 (Kbps) - String receiveKbpsQuery = "rate(node_network_receive_bytes_total{instance=\"" + instance + "\", device=\""+serverProperties.getNetworkCardName()+"\"}["+exprTime+"]) * 8 / 1000"; + String receiveKbpsQuery = + "rate(node_network_receive_bytes_total{instance=\"" + instance + + "\", device=\"" + serverProperties.getNetworkCardName() + "\"}[" + + exprTime + "]) * 8 / 1000"; PrometheusResponse receiveKbpsResponse = webClient.get() - .uri(buildUri(url,receiveKbpsQuery)) + .uri(buildUri(url, receiveKbpsQuery)) .retrieve() .bodyToMono(PrometheusResponse.class) .block(); - if(Objects.nonNull(receiveKbpsResponse) && + if (Objects.nonNull(receiveKbpsResponse) && Objects.nonNull(receiveKbpsResponse.getData()) && CollUtil.isNotEmpty(receiveKbpsResponse.getData().getResult()) ) { - PrometheusResponse.Result receiveKbpsInfo = receiveKbpsResponse.getData().getResult().get(0); - if(CollUtil.isNotEmpty(receiveKbpsInfo.getValue())) { - Date date = new Date(receiveKbpsInfo.getValue().get(0).longValue()*1000); - Double receiveKbps = BigDecimal.valueOf(receiveKbpsInfo.getValue().get(1)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + PrometheusResponse.Result receiveKbpsInfo = + receiveKbpsResponse.getData().getResult().get(0); + if (CollUtil.isNotEmpty(receiveKbpsInfo.getValue())) { + Date date = new Date(receiveKbpsInfo.getValue().get(0).longValue() * 1000); + Double receiveKbps = BigDecimal.valueOf(receiveKbpsInfo.getValue().get(1)) + .setScale(2, RoundingMode.HALF_UP).doubleValue(); result.put("receiveDate", DateUtil.format(date, "MM/dd HH:mm:ss")); result.put("receiveKbps", receiveKbps); } } //发送带宽 (Kbps) - String transmitKbpsQuery = "rate(node_network_transmit_bytes_total{instance=\"" + instance + "\", device=\""+serverProperties.getNetworkCardName()+"\"}["+exprTime+"]) * 8 / 1000"; + String transmitKbpsQuery = + "rate(node_network_transmit_bytes_total{instance=\"" + instance + + "\", device=\"" + serverProperties.getNetworkCardName() + "\"}[" + + exprTime + "]) * 8 / 1000"; PrometheusResponse transmitKbpsResponse = webClient.get() - .uri(buildUri(url,transmitKbpsQuery)) + .uri(buildUri(url, transmitKbpsQuery)) .retrieve() .bodyToMono(PrometheusResponse.class) .block(); - if(Objects.nonNull(transmitKbpsResponse) && + if (Objects.nonNull(transmitKbpsResponse) && Objects.nonNull(transmitKbpsResponse.getData()) && CollUtil.isNotEmpty(transmitKbpsResponse.getData().getResult()) ) { - PrometheusResponse.Result transmitKbpsInfo = transmitKbpsResponse.getData().getResult().get(0); - if(CollUtil.isNotEmpty(transmitKbpsInfo.getValue())) { - Date date = new Date(transmitKbpsInfo.getValue().get(0).longValue()*1000); - Double transmitKbps = BigDecimal.valueOf(transmitKbpsInfo.getValue().get(1)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + PrometheusResponse.Result transmitKbpsInfo = + transmitKbpsResponse.getData().getResult().get(0); + if (CollUtil.isNotEmpty(transmitKbpsInfo.getValue())) { + Date date = new Date(transmitKbpsInfo.getValue().get(0).longValue() * 1000); + Double transmitKbps = BigDecimal.valueOf(transmitKbpsInfo.getValue().get(1)) + .setScale(2, RoundingMode.HALF_UP).doubleValue(); result.put("transmitDate", DateUtil.format(date, "MM/dd HH:mm:ss")); result.put("transmitKbps", transmitKbps); } } - }catch (Exception e){ - log.error("获取网络信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}",e.getMessage()); + } catch (Exception e) { + log.error( + "获取网络信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}", + e.getMessage()); } - return result; + return result; } /** @@ -360,38 +401,44 @@ public class HostMonitorServiceImpl implements HostMonitorService { * @return */ @Override - public Map>> getNetworkInfoList(String ip,String conditions) { - Map>> result = new HashMap<>(); + public Map>> getNetworkInfoList(String ip, String conditions) { + Map>> result = new HashMap<>(); try { //Prometheus 服务器地址 String url = serverProperties.getServerUrl(); //目标主机实例(node-exporter 的地址) String instance = this.getInstance(ip); //构建查询参数 - PrometheusHostQueryTypeEnum queryTypeEnum = PrometheusHostQueryTypeEnum.getQueryTypeEnum(conditions); + PrometheusHostQueryTypeEnum queryTypeEnum = + PrometheusHostQueryTypeEnum.getQueryTypeEnum(conditions); long end = Instant.now().getEpochSecond(); long start = end - queryTypeEnum.getLastSecond(); String step = queryTypeEnum.getStep(); String exprTime = queryTypeEnum.getExprTime(); //接收带宽 (Kbps) - String receiveKbpsQuery = "rate(node_network_receive_bytes_total{instance=\"" + instance + "\", device=\""+serverProperties.getNetworkCardName()+"\"}["+exprTime+"]) * 8 / 1000"; + String receiveKbpsQuery = + "rate(node_network_receive_bytes_total{instance=\"" + instance + + "\", device=\"" + serverProperties.getNetworkCardName() + "\"}[" + + exprTime + "]) * 8 / 1000"; PrometheusResponse receiveKbpsResponse = webClient.get() - .uri(buildUri(url,receiveKbpsQuery,start,end,step)) + .uri(buildUri(url, receiveKbpsQuery, start, end, step)) .retrieve() .bodyToMono(PrometheusResponse.class) .block(); - if(Objects.nonNull(receiveKbpsResponse) && + if (Objects.nonNull(receiveKbpsResponse) && Objects.nonNull(receiveKbpsResponse.getData()) && CollUtil.isNotEmpty(receiveKbpsResponse.getData().getResult()) ) { - PrometheusResponse.Result receiveKbpsInfo = receiveKbpsResponse.getData().getResult().get(0); - if(CollUtil.isNotEmpty(receiveKbpsInfo.getValues())) { + PrometheusResponse.Result receiveKbpsInfo = + receiveKbpsResponse.getData().getResult().get(0); + if (CollUtil.isNotEmpty(receiveKbpsInfo.getValues())) { List> receiveDataList = new ArrayList<>(); List> pointDatas = receiveKbpsInfo.getValues(); - for(List pointData : pointDatas) { - Map pointDataMap = new HashMap<>(); - Date date = new Date(pointData.get(0).longValue()*1000); - Double useRate = BigDecimal.valueOf(pointData.get(1)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + for (List pointData : pointDatas) { + Map pointDataMap = new HashMap<>(); + Date date = new Date(pointData.get(0).longValue() * 1000); + Double useRate = BigDecimal.valueOf(pointData.get(1)) + .setScale(2, RoundingMode.HALF_UP).doubleValue(); pointDataMap.put("receiveDate", DateUtil.format(date, "MM/dd HH:mm:ss")); pointDataMap.put("receiveKbps", useRate); receiveDataList.add(pointDataMap); @@ -401,24 +448,29 @@ public class HostMonitorServiceImpl implements HostMonitorService { } //发送带宽 (Kbps) - String transmitKbpsQuery = "rate(node_network_transmit_bytes_total{instance=\"" + instance + "\", device=\""+serverProperties.getNetworkCardName()+"\"}["+exprTime+"]) * 8 / 1000"; + String transmitKbpsQuery = + "rate(node_network_transmit_bytes_total{instance=\"" + instance + + "\", device=\"" + serverProperties.getNetworkCardName() + "\"}[" + + exprTime + "]) * 8 / 1000"; PrometheusResponse transmitKbpsResponse = webClient.get() - .uri(buildUri(url,transmitKbpsQuery,start,end,step)) + .uri(buildUri(url, transmitKbpsQuery, start, end, step)) .retrieve() .bodyToMono(PrometheusResponse.class) .block(); - if(Objects.nonNull(transmitKbpsResponse) && + if (Objects.nonNull(transmitKbpsResponse) && Objects.nonNull(transmitKbpsResponse.getData()) && CollUtil.isNotEmpty(transmitKbpsResponse.getData().getResult()) ) { - PrometheusResponse.Result transmitKbpsInfo = transmitKbpsResponse.getData().getResult().get(0); - if(CollUtil.isNotEmpty(transmitKbpsInfo.getValues())) { + PrometheusResponse.Result transmitKbpsInfo = + transmitKbpsResponse.getData().getResult().get(0); + if (CollUtil.isNotEmpty(transmitKbpsInfo.getValues())) { List> transmitDataList = new ArrayList<>(); List> pointDatas = transmitKbpsInfo.getValues(); - for(List pointData : pointDatas) { - Map pointDataMap = new HashMap<>(); - Date date = new Date(pointData.get(0).longValue()*1000); - Double useRate = BigDecimal.valueOf(pointData.get(1)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + for (List pointData : pointDatas) { + Map pointDataMap = new HashMap<>(); + Date date = new Date(pointData.get(0).longValue() * 1000); + Double useRate = BigDecimal.valueOf(pointData.get(1)) + .setScale(2, RoundingMode.HALF_UP).doubleValue(); pointDataMap.put("receiveDate", DateUtil.format(date, "MM/dd HH:mm:ss")); pointDataMap.put("receiveKbps", useRate); transmitDataList.add(pointDataMap); @@ -426,42 +478,51 @@ public class HostMonitorServiceImpl implements HostMonitorService { result.put("transmitData", transmitDataList); } } - }catch (Exception e){ - log.error("获取网络信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}",e.getMessage()); + } catch (Exception e) { + log.error( + "获取网络信息错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}", + e.getMessage()); } - return result; + return result; } /** * 获取磁盘使用率 */ @Override - public Map getDiskInfo(String ip) { - Map result = new HashMap<>(); + public Map getDiskInfo(String ip) { + Map result = new HashMap<>(); try { //Prometheus 服务器地址 String url = serverProperties.getServerUrl(); //目标主机实例(node-exporter 的地址) String instance = this.getInstance(ip); //磁盘使用率 - String diskUsageQuery = "((node_filesystem_size_bytes{instance=\""+instance+"\", device!~\"rootfs\"} - node_filesystem_avail_bytes{instance=\""+instance+"\", device!~\"rootfs\"}) / node_filesystem_size_bytes{instance=\""+instance+"\", device!~\"rootfs\"}) * 100"; + String diskUsageQuery = "((node_filesystem_size_bytes{instance=\"" + instance + + "\", device!~\"rootfs\"} - node_filesystem_avail_bytes{instance=\"" + instance + + "\", device!~\"rootfs\"}) / node_filesystem_size_bytes{instance=\"" + instance + + "\", device!~\"rootfs\"}) * 100"; PrometheusResponse diskUsageResponse = webClient.get() - .uri(buildUri(url,diskUsageQuery)) + .uri(buildUri(url, diskUsageQuery)) .retrieve() .bodyToMono(PrometheusResponse.class) .block(); - if(Objects.nonNull(diskUsageResponse) && + if (Objects.nonNull(diskUsageResponse) && Objects.nonNull(diskUsageResponse.getData()) && CollUtil.isNotEmpty(diskUsageResponse.getData().getResult()) ) { - for (PrometheusResponse.Result responseData :diskUsageResponse.getData().getResult()){ + for (PrometheusResponse.Result responseData : diskUsageResponse.getData() + .getResult()) { String mountpoint = responseData.getMetric().getMountpoint(); - Double usageRate = BigDecimal.valueOf(responseData.getValue().get(1)).setScale(2, RoundingMode.HALF_UP).doubleValue(); - result.put(mountpoint,usageRate); + Double usageRate = BigDecimal.valueOf(responseData.getValue().get(1)) + .setScale(2, RoundingMode.HALF_UP).doubleValue(); + result.put(mountpoint, usageRate); } } - }catch (Exception e){ - log.error("获取磁盘使用率错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}",e.getMessage()); + } catch (Exception e) { + log.error( + "获取磁盘使用率错误,请检查Prometheus服务是否正常启动或Java请求参数是否正确,详细堆栈错误为:{}", + e.getMessage()); } return result; } @@ -478,29 +539,32 @@ public class HostMonitorServiceImpl implements HostMonitorService { /** * 获取服务器实例 + * * @param ip * @return */ private String getInstance(String ip) { - if(StrUtil.isBlank(ip)){ - Map.Entry first = serverProperties.getInstances().entrySet().stream().findFirst().get(); - return first.getKey()+":"+first.getValue(); + if (StrUtil.isBlank(ip)) { + Map.Entry first = + serverProperties.getInstances().entrySet().stream().findFirst().get(); + return first.getKey() + ":" + first.getValue(); } - if (!serverProperties.getInstances().containsKey(ip)){ + if (!serverProperties.getInstances().containsKey(ip)) { throw new RuntimeException("此ip不在服务器列表中,请检查监控ip列表配置"); } Integer port = serverProperties.getInstances().get(ip); //return "192.168.186.143"+":"+port; - return ip+":"+port; + return ip + ":" + port; } /** * 构建URI + * * @param url * @param query * @return */ - private URI buildUri(String url,String query){ + private URI buildUri(String url, String query) { URI uri = UriComponentsBuilder.fromHttpUrl(url + "/api/v1/query") .queryParam("query", query) .build() @@ -510,11 +574,12 @@ public class HostMonitorServiceImpl implements HostMonitorService { /** * 构建URI + * * @param url * @param query * @return */ - private URI buildUri(String url,String query,Long start,Long end,String step){ + private URI buildUri(String url, String query, Long start, Long end, String step) { String uriAddr = String.format( "%s/api/v1/query_range?query=%s&start=%d&end=%d&step=%s", url, From 295a3d46031faa17fa915e9959eebb82d34d6529 Mon Sep 17 00:00:00 2001 From: duwenyuan <15600000461@163.com> Date: Wed, 8 Jul 2026 15:34:13 +0800 Subject: [PATCH 6/6] =?UTF-8?q?DateUtils=E7=B1=BB=E6=B7=BB=E5=8A=A0addDays?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/jeecg/common/util/DateUtils.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java index 68b8706..99894de 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java @@ -848,5 +848,10 @@ public class DateUtils extends PropertyEditorSupport { return dateList; } - + public static Date addDays(Date date, int days) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.add(Calendar.DAY_OF_MONTH, days); + return cal.getTime(); + } } \ No newline at end of file