添加IMS数据监测
This commit is contained in:
parent
165f009892
commit
8f63eb5acd
|
|
@ -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<ProvisionData> data = imsDataMonitorService.getParticulate(code, startDate, endDate);
|
||||
public Result<?> getParticulate() {
|
||||
|
||||
List<ProvisionData> 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<ProvisionData> data = imsDataMonitorService.getSpalax(code, startDate, endDate);
|
||||
public Result<?> getSpalax() {
|
||||
List<ProvisionData> 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<ProvisionData> data = imsDataMonitorService.getSauna2(code, startDate, endDate);
|
||||
public Result<?> getSauna2() {
|
||||
List<ProvisionData> 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<ProvisionData> data = imsDataMonitorService.getSauna3(code, startDate, endDate);
|
||||
public Result<?> getSauna3() {
|
||||
List<ProvisionData> data = imsDataMonitorService.getSauna3();
|
||||
// return Result.OK(data);
|
||||
//TODO 测试待删除
|
||||
try (InputStream inputStream = imsDataMonitorController.class.getClassLoader()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package org.jeecg.imsDataMonitor.entity;
|
||||
|
||||
public class Particulate extends BaseParameter {
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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<Integer> stationId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -22,13 +22,13 @@ public interface IMSDataMonitorService {
|
|||
*获取Particulate类型的有效率数据
|
||||
* @return Map<String, List<ProvisionData>>
|
||||
*/
|
||||
List<ProvisionData> getParticulate(String code, Date startDate, Date endDate);
|
||||
List<ProvisionData> getParticulate();
|
||||
|
||||
List<ProvisionData> getSpalax(String code, Date startDate, Date endDate);
|
||||
List<ProvisionData> getSpalax();
|
||||
|
||||
List<ProvisionData> getSauna2(String code, Date startDate, Date endDate);
|
||||
List<ProvisionData> getSauna2();
|
||||
|
||||
List<ProvisionData> getSauna3(String code, Date startDate, Date endDate);
|
||||
List<ProvisionData> getSauna3();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<GardsStations> getGardsStationList(String systemType) {
|
||||
return imsDataMonitorMapper.findStationList(systemType);
|
||||
}
|
||||
|
||||
//region Particulate
|
||||
|
||||
/**
|
||||
* 获取获取Particulate类型的台站有效率
|
||||
* <p>时间范围默认当前时间往前一个月</p>
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
public List<ProvisionData> getParticulate(String code, Date startDate, Date endDate) {
|
||||
public List<ProvisionData> getParticulate() {
|
||||
//获取Particulate类型的台站信息
|
||||
List<GardsStations> stations = imsDataMonitorMapper.findStationList("P");
|
||||
String[] times = getDataTime(startDate, endDate);
|
||||
String[] times = getDataTime();
|
||||
//有效率状态
|
||||
return getStationDailyData(stations, times[0], times[1]);
|
||||
|
||||
}
|
||||
|
||||
private List<ProvisionData> getStationDailyData(List<GardsStations> 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<Integer> 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<ProvisionData> getSpalax() {
|
||||
String actualCode = "SPALAX";
|
||||
//获取Particulate类型的台站信息
|
||||
List<GardsStations> stations = imsDataMonitorMapper.findEfficStationList(actualCode);
|
||||
String[] times = getDataTime();
|
||||
//有效率状态
|
||||
return getSpalaxStationDailyData(stations, times[0], times[1]);
|
||||
}
|
||||
|
||||
private List<ProvisionData> getSpalaxStationDailyData(List<GardsStations> stationList,
|
||||
String startTime, String endTime) {
|
||||
|
||||
if (CollectionUtil.isEmpty(stationList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//每个台站一个月的有效率
|
||||
Spalax spalax = (Spalax) configManager.getParameter("spalax");
|
||||
|
||||
PhdfProvisionEfficiency efficiency = new PhdfProvisionEfficiency();
|
||||
List<Integer> 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<ProvisionData> rawDataList =
|
||||
imsDataMonitorMapper.findPhdfSpalaxEfficiency(efficiency);
|
||||
//dataMap.put(station.getStationCode(), rawDataList);
|
||||
return rawDataList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//endregion
|
||||
|
||||
//region SAUNA II
|
||||
@Override
|
||||
public List<ProvisionData> getSauna2() {
|
||||
String actualCode = "SAUNA2";
|
||||
//获取Particulate类型的台站信息
|
||||
List<GardsStations> stations = imsDataMonitorMapper.findEfficStationList(actualCode);
|
||||
String[] times = getDataTime();
|
||||
//有效率状态
|
||||
return getSauna2StationDailyData(stations, times[0], times[1]);
|
||||
}
|
||||
|
||||
private List<ProvisionData> getSauna2StationDailyData(List<GardsStations> stationList,
|
||||
String startTime, String endTime) {
|
||||
|
||||
if (CollectionUtil.isEmpty(stationList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//每个台站一个月的有效率
|
||||
Sauna sauna2 = (Sauna) configManager.getParameter("sauna2");
|
||||
|
||||
PhdfProvisionEfficiency efficiency = new PhdfProvisionEfficiency();
|
||||
List<Integer> 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<ProvisionData> rawDataList =
|
||||
imsDataMonitorMapper.findPhdfSauna2Efficiency(efficiency);
|
||||
//dataMap.put(station.getStationCode(), rawDataList);
|
||||
return rawDataList;
|
||||
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region SAUNA III
|
||||
@Override
|
||||
public List<ProvisionData> getSauna3() {
|
||||
String actualCode = "SAUNA3";
|
||||
//获取Particulate类型的台站信息
|
||||
List<GardsStations> 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<ProvisionData> getSpalax(String code, Date startDate, Date endDate) {
|
||||
String actualCode = (code == null || code.trim().isEmpty()) ? "SPALAX" : code;
|
||||
//获取Particulate类型的台站信息
|
||||
List<GardsStations> stations = imsDataMonitorMapper.findEfficStationList(actualCode);
|
||||
String[] times = getDataTime(startDate, endDate);
|
||||
//有效率状态
|
||||
return getSpalaxStationDailyData(stations, times[0], times[1]);
|
||||
}
|
||||
|
||||
private List<ProvisionData> getSpalaxStationDailyData(List<GardsStations> 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<Integer> 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<ProvisionData> rawDataList =
|
||||
imsDataMonitorMapper.findPhdfSpalaxEfficiency(efficiency);
|
||||
//dataMap.put(station.getStationCode(), rawDataList);
|
||||
return rawDataList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//endregion
|
||||
|
||||
//region SAUNA II
|
||||
@Override
|
||||
public List<ProvisionData> getSauna2(String code, Date startDate, Date endDate) {
|
||||
String actualCode = (code == null || code.trim().isEmpty()) ? "SAUNA2" : code;
|
||||
//获取Particulate类型的台站信息
|
||||
List<GardsStations> stations = imsDataMonitorMapper.findEfficStationList(actualCode);
|
||||
String[] times = getDataTime(startDate, endDate);
|
||||
//有效率状态
|
||||
return getSauna2StationDailyData(stations, times[0], times[1]);
|
||||
}
|
||||
|
||||
private List<ProvisionData> getSauna2StationDailyData(List<GardsStations> 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<Integer> 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<ProvisionData> rawDataList =
|
||||
imsDataMonitorMapper.findPhdfSauna2Efficiency(efficiency);
|
||||
//dataMap.put(station.getStationCode(), rawDataList);
|
||||
return rawDataList;
|
||||
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region SAUNA III
|
||||
@Override
|
||||
public List<ProvisionData> getSauna3(String code, Date startDate, Date endDate) {
|
||||
String actualCode = (code == null || code.trim().isEmpty()) ? "SAUNA3" : code;
|
||||
//获取Particulate类型的台站信息
|
||||
List<GardsStations> stations = imsDataMonitorMapper.findEfficStationList(actualCode);
|
||||
String[] times = getDataTime(startDate, endDate);
|
||||
//有效率状态
|
||||
return getSauna2StationDailyData(stations, times[0], times[1]);
|
||||
}
|
||||
//endregion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, BaseParameter> parameterMap = new HashMap<>();
|
||||
// 配置状态
|
||||
private boolean initialized = false;
|
||||
|
||||
/**
|
||||
* 初始化配置
|
||||
*
|
||||
* <p>使用默认配置文件路径("compute_efficiency.xml")</p>
|
||||
*
|
||||
* <p><strong>文件位置:</strong>类路径资源:classpath:config.xml</p>
|
||||
*
|
||||
* @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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化配置管理器(指定文件路径)
|
||||
*
|
||||
* <p>使用指定的XML文件路径初始化配置管理器。</p>
|
||||
*
|
||||
* <p><strong>文件格式要求:</strong></p>
|
||||
* <ul>
|
||||
* <li>必须是有效的XML文件</li>
|
||||
* <li>必须符合预定义的XML Schema结构</li>
|
||||
* <li>编码推荐使用UTF-8</li>
|
||||
* <li>文件大小建议不超过10MB</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param filePath XML配置文件的完整路径或相对路径
|
||||
* <p><strong>路径格式:</strong></p>
|
||||
* <ul>
|
||||
* <li>绝对路径:/home/user/config.xml 或 C:\config\config.xml</li>
|
||||
* <li>相对路径:config.xml 或 ./config/config.xml</li>
|
||||
* <li>类路径资源:classpath:config.xml(暂不支持)</li>
|
||||
* </ul>
|
||||
* @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或解析异常
|
||||
*
|
||||
* <p><strong>示例:</strong></p>
|
||||
* <pre>
|
||||
* {@code
|
||||
* // 使用绝对路径
|
||||
* manager.init("/etc/app/config.xml");
|
||||
*
|
||||
* // 使用相对路径
|
||||
* manager.init("conf/production.xml");
|
||||
*
|
||||
* // 从命令行参数获取路径
|
||||
* if (args.length > 0) {
|
||||
* manager.init(args[0]);
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
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配置文件
|
||||
*
|
||||
* <p>内部方法,执行以下操作:</p>
|
||||
* <ol>
|
||||
* <li>配置XmlMapper解析器</li>
|
||||
* <li>解析XML到Java对象</li>
|
||||
* <li>构建设备配置映射表</li>
|
||||
* </ol>
|
||||
*
|
||||
* @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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建配置映射表
|
||||
*
|
||||
* <p>将解析后的配置对象转换为按名称索引的映射表,便于快速访问。</p>
|
||||
*
|
||||
* <p><strong>设备名称映射规则:</strong></p>
|
||||
* <ul>
|
||||
* <li>"particulate" → {@link Particulate} 对象</li>
|
||||
* <li>"spalax" → {@link Spalax} 对象</li>
|
||||
* <li>"sauna2" → {@link Sauna} 对象</li>
|
||||
* <li>"sauna3" → {@link Sauna} 对象</li>
|
||||
* </ul>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定名称的配置
|
||||
*
|
||||
* <p>根据名称返回对应的设备配置对象。</p>
|
||||
*
|
||||
* @param parameterName 名称,支持以下值:
|
||||
* <ul>
|
||||
* <li>"particulate" - 颗粒物</li>
|
||||
* <li>"spalax" - </li>
|
||||
* <li>"sauna2" - </li>
|
||||
* <li>"sauna3" - </li>
|
||||
* </ul>
|
||||
* @return 设备配置对象,如果名称不存在返回null
|
||||
* @throws IllegalStateException 如果配置未初始化
|
||||
*
|
||||
* <p><strong>示例:</strong></p>
|
||||
* <pre>
|
||||
* {@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();
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public BaseParameter getParameter(String parameterName) {
|
||||
return parameterMap.get(parameterName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有参数
|
||||
*/
|
||||
public Map<String, BaseParameter> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config>
|
||||
<phdf>
|
||||
<particulate>
|
||||
<liveLow>21.6</liveLow>
|
||||
<liveHigh>26.4</liveHigh>
|
||||
<quantity>10800</quantity>
|
||||
<collectLow>21.6</collectLow>
|
||||
<collectHigh>26.4</collectHigh>
|
||||
<number>1</number>
|
||||
</particulate>
|
||||
<spalax>
|
||||
<liveLow>10</liveLow>
|
||||
<liveHigh>11</liveHigh>
|
||||
<quantity>10</quantity>
|
||||
<collectLow>10.8</collectLow>
|
||||
<collectHigh>13.2</collectHigh>
|
||||
<number>4</number>
|
||||
<liveqc>240</liveqc>
|
||||
</spalax>
|
||||
<sauna2>
|
||||
<collectLow>5.4</collectLow>
|
||||
<collectHigh>6.6</collectHigh>
|
||||
<liveLow>4.2</liveLow>
|
||||
<liveHigh>6.6</liveHigh>
|
||||
<quantity>10</quantity>
|
||||
<xeVolume>0.87</xeVolume>
|
||||
<mdc>1</mdc>
|
||||
<nuclideName>Xe133</nuclideName>
|
||||
<liveQc>600</liveQc>
|
||||
<number>16</number>
|
||||
</sauna2>
|
||||
<sauna3>
|
||||
<collectLow>5.4</collectLow>
|
||||
<collectHigh>6.6</collectHigh>
|
||||
<liveLow>4.2</liveLow>
|
||||
<liveHigh>6.6</liveHigh>
|
||||
<quantity>10</quantity>
|
||||
<xeVolume>0.87</xeVolume>
|
||||
<mdc>1</mdc>
|
||||
<nuclideName>Xe133</nuclideName>
|
||||
<liveQc>600</liveQc>
|
||||
<number>16</number>
|
||||
</sauna3>
|
||||
</phdf>
|
||||
</config>
|
||||
Loading…
Reference in New Issue
Block a user