增加cpu温度处理
This commit is contained in:
+134
-67
@@ -53,7 +53,7 @@ public class EchartsDataUtils {
|
||||
return Math.round(microseconds / 1_000_000.0 * 100.0) / 100.0;
|
||||
}
|
||||
/**
|
||||
* 构建ECharts图表数据(带时间补全和特殊值处理)- 修复版本
|
||||
* 构建ECharts图表数据(带时间补全和特殊值处理)- 最终修复版本
|
||||
*/
|
||||
public static <T> Map<String, Object> buildEchartsDataAutoPadding(
|
||||
List<T> list,
|
||||
@@ -84,9 +84,6 @@ public class EchartsDataUtils {
|
||||
.sorted(Comparator.comparing(timeExtractor))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 自动检测时间间隔
|
||||
long timeInterval = detectTimeInterval(sortedList, timeExtractor);
|
||||
|
||||
// 获取数据实际的时间范围
|
||||
Date actualStartTime = timeExtractor.apply(sortedList.get(0));
|
||||
Date actualEndTime = timeExtractor.apply(sortedList.get(sortedList.size() - 1));
|
||||
@@ -96,39 +93,13 @@ public class EchartsDataUtils {
|
||||
long sparseInterval = totalTimeRange > 12L * 30 * 24 * 60 * 60 * 1000 ?
|
||||
30L * 24 * 60 * 60 * 1000 : 2L * 24 * 60 * 60 * 1000;
|
||||
|
||||
// 生成完整的时间序列
|
||||
List<Date> fullTimeSeries = new ArrayList<>();
|
||||
|
||||
// 1. 开始时间到数据开始时间(稀疏间隔)
|
||||
if (startDate.before(actualStartTime)) {
|
||||
List<Date> beforeSeries = generateSparseTimeSeries(startDate, actualStartTime, sparseInterval);
|
||||
fullTimeSeries.addAll(beforeSeries);
|
||||
}
|
||||
|
||||
// 2. 数据开始时间到数据结束时间 - 以第一个数据点的时间为基准生成序列
|
||||
List<Date> dataSeries = generateTimeSeriesFromDataPoints(actualStartTime, actualEndTime,
|
||||
timeInterval, actualStartTime);
|
||||
fullTimeSeries.addAll(dataSeries);
|
||||
|
||||
// 3. 数据结束时间到结束时间(稀疏间隔)
|
||||
if (actualEndTime.before(endDate)) {
|
||||
// 从actualEndTime的下一个时间点开始
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(actualEndTime);
|
||||
cal.add(Calendar.MILLISECOND, (int)timeInterval);
|
||||
Date nextAfterActualEnd = cal.getTime();
|
||||
|
||||
if (nextAfterActualEnd.before(endDate) || nextAfterActualEnd.equals(endDate)) {
|
||||
List<Date> afterSeries = generateSparseTimeSeries(nextAfterActualEnd, endDate, sparseInterval);
|
||||
fullTimeSeries.addAll(afterSeries);
|
||||
}
|
||||
}
|
||||
|
||||
// 去重并排序
|
||||
fullTimeSeries = fullTimeSeries.stream()
|
||||
.distinct()
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
// 核心修改:生成X轴时间序列
|
||||
List<Date> xAxisTimes = generateXAxisTimeSeries(
|
||||
startDate, endDate,
|
||||
actualStartTime, actualEndTime,
|
||||
sortedList, timeExtractor,
|
||||
sparseInterval
|
||||
);
|
||||
|
||||
// 创建时间到数据的映射
|
||||
Map<String, T> timeDataMap = new HashMap<>();
|
||||
@@ -152,7 +123,7 @@ public class EchartsDataUtils {
|
||||
dataExtractors.keySet().forEach(name ->
|
||||
yData.put(name, new ArrayList<>()));
|
||||
|
||||
for (Date time : fullTimeSeries) {
|
||||
for (Date time : xAxisTimes) {
|
||||
// X轴数据
|
||||
String timeStr = parseDateToStr(time);
|
||||
xAxisData.add(timeStr);
|
||||
@@ -177,7 +148,7 @@ public class EchartsDataUtils {
|
||||
} else {
|
||||
// 智能数据补全
|
||||
if (isInDataRange) {
|
||||
// 在数据时间范围内但该时间点无数据(数据缺失点)
|
||||
// 在数据时间范围内但该时间点无数据
|
||||
seriesData.add(getDefaultValue(name, fixedPercentile95Value, xAxisData.size()-1, hasRealData));
|
||||
} else {
|
||||
// 在数据时间范围外
|
||||
@@ -200,37 +171,54 @@ public class EchartsDataUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从第一个数据点开始生成时间序列
|
||||
* 生成X轴时间序列(核心方法)
|
||||
* 策略:优先使用实际数据的时间点,然后在数据点之间按需补全
|
||||
*/
|
||||
private static List<Date> generateTimeSeriesFromDataPoints(Date start, Date end,
|
||||
long interval, Date firstDataPoint) {
|
||||
private static <T> List<Date> generateXAxisTimeSeries(
|
||||
Date queryStart, Date queryEnd,
|
||||
Date dataStart, Date dataEnd,
|
||||
List<T> sortedList, Function<T, Date> timeExtractor,
|
||||
long sparseInterval) {
|
||||
|
||||
List<Date> timeSeries = new ArrayList<>();
|
||||
|
||||
if (interval <= 0) {
|
||||
interval = 300000L; // 默认5分钟
|
||||
// 1. 查询开始时间到数据开始时间(稀疏间隔)
|
||||
if (queryStart.before(dataStart)) {
|
||||
List<Date> beforeSeries = generateTimeSeries(queryStart, dataStart, sparseInterval, false);
|
||||
timeSeries.addAll(beforeSeries);
|
||||
}
|
||||
|
||||
// 使用第一个数据点的时间作为基准
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(firstDataPoint);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
// 2. 数据时间范围内的处理
|
||||
if (sortedList != null && !sortedList.isEmpty()) {
|
||||
// 优先使用实际数据的所有时间点
|
||||
List<Date> dataTimePoints = sortedList.stream()
|
||||
.map(timeExtractor)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
timeSeries.addAll(dataTimePoints);
|
||||
|
||||
// 从第一个数据点开始向前找,直到找到小于等于start的时间点
|
||||
while (calendar.getTime().after(start)) {
|
||||
calendar.add(Calendar.MILLISECOND, -(int)interval);
|
||||
// 检测数据点之间的间隔,补全缺失的时间点
|
||||
if (dataTimePoints.size() > 1) {
|
||||
List<Date> filledSeries = fillMissingTimePoints(dataTimePoints);
|
||||
timeSeries.addAll(filledSeries);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果当前位置在start之前,前进一个间隔
|
||||
if (calendar.getTime().before(start)) {
|
||||
calendar.add(Calendar.MILLISECOND, (int)interval);
|
||||
}
|
||||
// 3. 数据结束时间到查询结束时间(稀疏间隔)
|
||||
if (dataEnd.before(queryEnd)) {
|
||||
// 从数据结束时间的下一个稀疏间隔点开始
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(dataEnd);
|
||||
cal.add(Calendar.MILLISECOND, (int)sparseInterval);
|
||||
Date nextAfterDataEnd = cal.getTime();
|
||||
|
||||
// 生成时间序列
|
||||
while (!calendar.getTime().after(end)) {
|
||||
timeSeries.add(calendar.getTime());
|
||||
calendar.add(Calendar.MILLISECOND, (int)interval);
|
||||
if (nextAfterDataEnd.before(queryEnd) || nextAfterDataEnd.equals(queryEnd)) {
|
||||
List<Date> afterSeries = generateTimeSeries(nextAfterDataEnd, queryEnd, sparseInterval, false);
|
||||
timeSeries.addAll(afterSeries);
|
||||
}
|
||||
}
|
||||
|
||||
// 去重、排序
|
||||
return timeSeries.stream()
|
||||
.distinct()
|
||||
.sorted()
|
||||
@@ -238,21 +226,103 @@ public class EchartsDataUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成稀疏时间序列
|
||||
* 补全缺失的时间点
|
||||
* 在相邻数据点之间,如果间隔太大,插入中间点
|
||||
*/
|
||||
private static List<Date> generateSparseTimeSeries(Date start, Date end, long interval) {
|
||||
private static List<Date> fillMissingTimePoints(List<Date> dataTimePoints) {
|
||||
List<Date> filledPoints = new ArrayList<>();
|
||||
|
||||
if (dataTimePoints.size() < 2) {
|
||||
return filledPoints;
|
||||
}
|
||||
|
||||
// 检测常见间隔
|
||||
long commonInterval = detectCommonInterval(dataTimePoints);
|
||||
|
||||
for (int i = 0; i < dataTimePoints.size() - 1; i++) {
|
||||
Date current = dataTimePoints.get(i);
|
||||
Date next = dataTimePoints.get(i + 1);
|
||||
long diff = next.getTime() - current.getTime();
|
||||
|
||||
// 如果间隔大于常见间隔的1.5倍,说明中间有缺失
|
||||
if (diff > commonInterval * 1.5) {
|
||||
// 计算可以插入几个点
|
||||
int pointsToInsert = (int) (diff / commonInterval) - 1;
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(current);
|
||||
|
||||
for (int j = 1; j <= pointsToInsert; j++) {
|
||||
cal.add(Calendar.MILLISECOND, (int)commonInterval);
|
||||
Date insertedPoint = cal.getTime();
|
||||
|
||||
// 确保插入的点不晚于next
|
||||
if (insertedPoint.before(next)) {
|
||||
filledPoints.add(insertedPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filledPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测常见时间间隔
|
||||
*/
|
||||
private static long detectCommonInterval(List<Date> timePoints) {
|
||||
if (timePoints.size() < 2) {
|
||||
return 300000L; // 默认5分钟
|
||||
}
|
||||
|
||||
Map<Long, Integer> intervalCount = new HashMap<>();
|
||||
for (int i = 1; i < timePoints.size(); i++) {
|
||||
long interval = timePoints.get(i).getTime() - timePoints.get(i-1).getTime();
|
||||
if (interval > 0) {
|
||||
intervalCount.merge(interval, 1, Integer::sum);
|
||||
}
|
||||
}
|
||||
|
||||
if (intervalCount.isEmpty()) {
|
||||
return 300000L;
|
||||
}
|
||||
|
||||
return intervalCount.entrySet().stream()
|
||||
.max(Map.Entry.comparingByValue())
|
||||
.map(Map.Entry::getKey)
|
||||
.orElse(300000L);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成时间序列
|
||||
* @param alignToInterval 是否对齐到时间间隔
|
||||
*/
|
||||
private static List<Date> generateTimeSeries(Date start, Date end, long interval, boolean alignToInterval) {
|
||||
List<Date> timeSeries = new ArrayList<>();
|
||||
|
||||
if (interval <= 0) {
|
||||
interval = 2L * 24 * 60 * 60 * 1000; // 默认2天
|
||||
interval = 300000L;
|
||||
}
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(start);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
if (alignToInterval) {
|
||||
// 对齐到间隔
|
||||
long startMillis = calendar.getTimeInMillis();
|
||||
long normalizedStart = (startMillis / interval) * interval;
|
||||
calendar.setTimeInMillis(normalizedStart);
|
||||
|
||||
if (normalizedStart < startMillis) {
|
||||
calendar.add(Calendar.MILLISECOND, (int)interval);
|
||||
}
|
||||
}
|
||||
|
||||
// 包含开始时间
|
||||
timeSeries.add(calendar.getTime());
|
||||
if (!calendar.getTime().after(end)) {
|
||||
timeSeries.add(calendar.getTime());
|
||||
}
|
||||
|
||||
while (true) {
|
||||
calendar.add(Calendar.MILLISECOND, (int)interval);
|
||||
@@ -262,10 +332,7 @@ public class EchartsDataUtils {
|
||||
timeSeries.add(calendar.getTime());
|
||||
}
|
||||
|
||||
return timeSeries.stream()
|
||||
.distinct()
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
return timeSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+5
-13
@@ -385,35 +385,27 @@ public class SpeedUtils {
|
||||
}
|
||||
public static String determineUnitByValue(Long value) {
|
||||
if (value == null || value == 0) {
|
||||
return "KB";
|
||||
return "Kb";
|
||||
}
|
||||
|
||||
// 注意:这里使用二进制单位(1024)
|
||||
if (value >= 1024L * 1024 * 1024 * 1024) { // >= 1TB
|
||||
return "TB";
|
||||
} else if (value >= 1024L * 1024 * 1024) { // >= 1GB
|
||||
return "GB";
|
||||
if (value >= 1024L * 1024 * 1024) { // >= 1GB
|
||||
return "Gb";
|
||||
} else if (value >= 1024L * 1024) { // >= 1MB
|
||||
return "MB";
|
||||
return "Mb";
|
||||
} else {
|
||||
return "KB";
|
||||
return "Kb";
|
||||
}
|
||||
}
|
||||
// 工具方法:获取单位换算除数
|
||||
public static BigDecimal get1024Divisor(String unit) {
|
||||
switch (unit) {
|
||||
case "GB":
|
||||
case "Gb":
|
||||
return new BigDecimal(1024L * 1024 * 1024); // 1GB = 1024^3
|
||||
case "MB":
|
||||
case "Mb":
|
||||
return new BigDecimal(1024L * 1024); // 1MB = 1024^2
|
||||
case "KB":
|
||||
case "Kb":
|
||||
return new BigDecimal(1024); // 1KB = 1024
|
||||
case "TB":
|
||||
case "Tb":
|
||||
return new BigDecimal(1024L * 1024 * 1024 * 1024); // 1TB = 1024^4
|
||||
default:
|
||||
return new BigDecimal(1024); // 默认返回KB的除数
|
||||
}
|
||||
|
||||
+2
-2
@@ -88,11 +88,11 @@ public class EpsNodeBandwidth extends BaseEntity
|
||||
private String interfaceName;
|
||||
|
||||
/** 资源类型(1服务器,2交换机) */
|
||||
@Excel(name = "资源类型")
|
||||
@Excel(name = "资源类型", readConverterExp = "1=服务器,2=交换机")
|
||||
private String resourceType;
|
||||
|
||||
/** 接口连接设备类型(1服务器,2机房出口) */
|
||||
@Excel(name = "接口连接设备类型")
|
||||
@Excel(name = "接口连接设备类型", readConverterExp = "1=服务器,2=机房出口,3=交换机上联,4=交换机下联")
|
||||
private String interfaceLinkDeviceType;
|
||||
/** 业务名称 */
|
||||
@Excel(name = "业务名称")
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="machineFlow != null "> and machine_flow = #{machineFlow}</if>
|
||||
<if test="uplinkSwitch != null and uplinkSwitch != ''"> and uplink_switch like concat('%', #{uplinkSwitch}, '%')</if>
|
||||
<if test="switchSn != null and switchSn != ''"> and switch_sn = #{switchSn}</if>
|
||||
<if test="interfaceName != null and interfaceName != ''"> and interface_name like concat('%', #{interfaceName}, '%')</if>
|
||||
<if test="interfaceName != null and interfaceName != ''"> and interface_name = #{interfaceName}</if>
|
||||
<if test="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
|
||||
<if test="interfaceLinkDeviceType != null and interfaceLinkDeviceType != ''"> and interface_link_device_type = #{interfaceLinkDeviceType}</if>
|
||||
<if test="effectiveBandwidth95Daily != null "> and effective_bandwidth_95_daily = #{effectiveBandwidth95Daily}</if>
|
||||
|
||||
+8
@@ -112,4 +112,12 @@ public class InitialCpuInfoController extends BaseController
|
||||
Map<String, Object> echartsData = initialCpuInfoService.cpuTimeEcharts(initialCpuInfo);
|
||||
return success(echartsData);
|
||||
}
|
||||
/**
|
||||
* 查询CPU温度信息并封装为多折线ECharts图表数据
|
||||
*/
|
||||
@PostMapping("/cupTemperatureEcharts")
|
||||
public AjaxResult cupTemperatureEcharts(@RequestBody InitialCpuInfo initialCpuInfo) {
|
||||
Map<String, Object> echartsData = initialCpuInfoService.cupTemperatureEcharts(initialCpuInfo);
|
||||
return success(echartsData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ public class AllDiskName extends BaseEntity
|
||||
/** 磁盘状态(0:丢失,1:存在) */
|
||||
@Excel(name = "磁盘状态(0:丢失,1:存在)")
|
||||
private Integer status;
|
||||
/** 执行卸载(0未执行,1已执行) */
|
||||
@Excel(name = "执行卸载(0未执行,1已执行)")
|
||||
private Integer umountFlag;
|
||||
|
||||
/** 读取IOPS */
|
||||
@Excel(name = "读取IOPS")
|
||||
|
||||
@@ -72,6 +72,8 @@ public class InitialCpuInfo extends BaseEntity
|
||||
/** CPU用户进程所花费的时间(秒) */
|
||||
@Excel(name = "CPU用户进程所花费的时间")
|
||||
private Long user;
|
||||
/** cpu温度 */
|
||||
private Long temperature;
|
||||
/** 开始时间 */
|
||||
private String startTime;
|
||||
/** 结束时间 */
|
||||
|
||||
@@ -549,6 +549,9 @@ public class MessageHandler {
|
||||
cpus.forEach(iface -> {
|
||||
iface.setClientId(message.getClientId());
|
||||
iface.setCreateTime(createTime);
|
||||
if(iface.getTemperature() == 0L){
|
||||
iface.setTemperature(null);
|
||||
}
|
||||
});
|
||||
// 初始CPU数据入库
|
||||
initialCpuInfoService.batchInsertInitialCpuInfo(cpus);
|
||||
|
||||
+7
@@ -71,4 +71,11 @@ public interface IInitialCpuInfoService
|
||||
Map<String, Object> cupLoadEcharts(InitialCpuInfo initialCpuInfo);
|
||||
|
||||
Map<String, Object> cpuTimeEcharts(InitialCpuInfo initialCpuInfo);
|
||||
|
||||
/**
|
||||
* cpu温度
|
||||
* @param initialCpuInfo
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> cupTemperatureEcharts(InitialCpuInfo initialCpuInfo);
|
||||
}
|
||||
|
||||
+4
@@ -137,6 +137,10 @@ public class AllDiskNameServiceImpl implements IAllDiskNameService
|
||||
if(processType == 1){
|
||||
policyTypeVo.setDiskIopsTest(allDiskName.getName());
|
||||
}else if(processType ==2){
|
||||
AllDiskName updateDisk = new AllDiskName();
|
||||
updateDisk.setId(id);
|
||||
updateDisk.setUmountFlag(1);
|
||||
allDiskNameMapper.updateAllDiskName(updateDisk);
|
||||
policyTypeVo.setUmountDisk(allDiskName.getName());
|
||||
}
|
||||
MessageProducer messageProducer = new MessageProducer();
|
||||
|
||||
+15
@@ -160,5 +160,20 @@ public class InitialCpuInfoServiceImpl implements IInitialCpuInfoService
|
||||
|
||||
return EchartsDataUtils.buildEchartsData(list,InitialCpuInfo::getCreateTime, extractors);
|
||||
}
|
||||
/**
|
||||
* cpu负载
|
||||
* @param initialCpuInfo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> cupTemperatureEcharts(InitialCpuInfo initialCpuInfo) {
|
||||
// 查询原始CPU监控数据并按时间排序
|
||||
List<InitialCpuInfo> list = initialCpuInfoMapper.selectInitialCpuInfoList(initialCpuInfo);
|
||||
|
||||
Map<String, Function<InitialCpuInfo, ?>> extractors = new LinkedHashMap<>();
|
||||
extractors.put("temperatureData", InitialCpuInfo::getTemperature);
|
||||
|
||||
return EchartsDataUtils.buildEchartsDataAutoPadding(list, InitialCpuInfo::getCreateTime, extractors, initialCpuInfo.getStartTime(), initialCpuInfo.getEndTime());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ public class InitialDiskInfoServiceImpl implements IInitialDiskInfoService
|
||||
public Map<String, Object> usedSpaceEcharts(InitialDiskInfo initialDiskInfo) {
|
||||
initialDiskInfo.setType("HDD");
|
||||
List<InitialDiskInfo> list = getDistInfoSharding(initialDiskInfo);
|
||||
String unit = "KB";
|
||||
String unit = "Kb";
|
||||
if(list != null && !list.isEmpty()){
|
||||
Long totalUsedSpace = 0L;
|
||||
for (InitialDiskInfo diskInfo : list) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.tongran.rocketmq.mapper.AllDiskNameMapper">
|
||||
|
||||
|
||||
<resultMap type="AllDiskName" id="AllDiskNameResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="clientId" column="client_id" />
|
||||
@@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="status" column="status" />
|
||||
<result property="readIops" column="read_iops" />
|
||||
<result property="writeIops" column="write_iops" />
|
||||
<result property="umountFlag" column="umount_flag" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
@@ -18,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAllDiskNameVo">
|
||||
select id, client_id, name, status, read_iops, write_iops, create_time, update_time, create_by, update_by from all_disk_name
|
||||
select id, client_id, name, status, read_iops, write_iops, umount_flag, create_time, update_time, create_by, update_by from all_disk_name
|
||||
</sql>
|
||||
|
||||
<select id="selectAllDiskNameList" parameterType="AllDiskName" resultMap="AllDiskNameResult">
|
||||
@@ -29,9 +30,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="readIops != null and readIops != ''"> and read_iops = #{readIops}</if>
|
||||
<if test="writeIops != null and writeIops != ''"> and write_iops = #{writeIops}</if>
|
||||
<if test="umountFlag != null "> and umount_flag = #{umountFlag}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectAllDiskNameById" parameterType="Long" resultMap="AllDiskNameResult">
|
||||
<include refid="selectAllDiskNameVo"/>
|
||||
where id = #{id}
|
||||
@@ -45,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="status != null">status,</if>
|
||||
<if test="readIops != null">read_iops,</if>
|
||||
<if test="writeIops != null">write_iops,</if>
|
||||
<if test="umountFlag != null">umount_flag,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
@@ -56,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="readIops != null">#{readIops},</if>
|
||||
<if test="writeIops != null">#{writeIops},</if>
|
||||
<if test="umountFlag != null">#{umountFlag},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
@@ -67,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="readIops != null">read_iops = #{readIops},</if>
|
||||
<if test="writeIops != null">write_iops = #{writeIops},</if>
|
||||
<if test="umountFlag != null">umount_flag = #{umountFlag},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
</trim>
|
||||
@@ -78,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="readIops != null">read_iops = #{readIops},</if>
|
||||
<if test="writeIops != null">write_iops = #{writeIops},</if>
|
||||
<if test="umountFlag != null">umount_flag = #{umountFlag},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
@@ -103,14 +109,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAllDiskNameByIds" parameterType="String">
|
||||
delete from all_disk_name where id in
|
||||
delete from all_disk_name where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<insert id="batchInsertAllDistName" parameterType="java.util.List">
|
||||
insert IGNORE into all_disk_name
|
||||
(client_id, name, status, read_iops, write_iops, create_time, update_time, create_by, update_by)
|
||||
(client_id, name, status, read_iops, write_iops, umount_flag, create_time, update_time, create_by, update_by)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
@@ -119,6 +125,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{item.status},
|
||||
#{item.readIops},
|
||||
#{item.writeIops},
|
||||
#{item.umountFlag},
|
||||
#{item.createTime},
|
||||
#{item.updateTime},
|
||||
#{item.createBy},
|
||||
@@ -135,6 +142,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
a.status,
|
||||
a.read_iops as readIops,
|
||||
a.write_iops as writeIops,
|
||||
a.umount_flag as umountFlag,
|
||||
a.create_time as createTime,
|
||||
a.update_time as updateTime,
|
||||
b.serial,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.tongran.rocketmq.mapper.InitialCpuInfoMapper">
|
||||
|
||||
|
||||
<resultMap type="InitialCpuInfo" id="InitialCpuInfoResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="clientId" column="client_id" />
|
||||
@@ -20,6 +20,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="system" column="system" />
|
||||
<result property="noresp" column="noresp" />
|
||||
<result property="user" column="user" />
|
||||
|
||||
<result property="temperature" column="temperature" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
@@ -27,19 +29,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectInitialCpuInfoVo">
|
||||
select id, client_id, avg1, avg5, avg15, interrupt, uti, num, cores, normal, idle, iowait, system, noresp, user, create_by, update_by, create_time, update_time from initial_cpu_info
|
||||
select
|
||||
id,
|
||||
client_id,
|
||||
avg1,
|
||||
avg5,
|
||||
avg15,
|
||||
interrupt,
|
||||
uti,
|
||||
num,
|
||||
cores,
|
||||
normal,
|
||||
idle,
|
||||
iowait,
|
||||
system,
|
||||
noresp,
|
||||
user,
|
||||
temperature,
|
||||
create_by,
|
||||
update_by,
|
||||
create_time,
|
||||
update_time
|
||||
from initial_cpu_info
|
||||
</sql>
|
||||
|
||||
<select id="selectInitialCpuInfoList" parameterType="InitialCpuInfo" resultMap="InitialCpuInfoResult">
|
||||
<include refid="selectInitialCpuInfoVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="temperature != null"> and temperature = #{temperature}</if>
|
||||
<if test="startTime != null and startTime != ''"> and create_time >= #{startTime}</if>
|
||||
<if test="endTime != null and endTime != ''"> and create_time <= #{endTime}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectInitialCpuInfoById" parameterType="Long" resultMap="InitialCpuInfoResult">
|
||||
<include refid="selectInitialCpuInfoVo"/>
|
||||
where id = #{id}
|
||||
@@ -62,11 +86,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="system != null">system,</if>
|
||||
<if test="noresp != null">noresp,</if>
|
||||
<if test="user != null">user,</if>
|
||||
|
||||
<if test="temperature != null">temperature,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null and clientId != ''">#{clientId},</if>
|
||||
<if test="avg1 != null">#{avg1},</if>
|
||||
@@ -82,11 +108,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="system != null">#{system},</if>
|
||||
<if test="noresp != null">#{noresp},</if>
|
||||
<if test="user != null">#{user},</if>
|
||||
|
||||
<if test="temperature != null">#{temperature},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateInitialCpuInfo" parameterType="InitialCpuInfo">
|
||||
@@ -106,6 +134,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="system != null">system = #{system},</if>
|
||||
<if test="noresp != null">noresp = #{noresp},</if>
|
||||
<if test="user != null">user = #{user},</if>
|
||||
|
||||
<if test="temperature != null">temperature = #{temperature},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
@@ -119,7 +149,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<delete id="deleteInitialCpuInfoByIds" parameterType="String">
|
||||
delete from initial_cpu_info where id in
|
||||
delete from initial_cpu_info where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
@@ -142,6 +172,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
`system`,
|
||||
noresp,
|
||||
`user`,
|
||||
temperature,
|
||||
create_by,
|
||||
update_by,
|
||||
create_time,
|
||||
@@ -164,6 +195,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{item.system},
|
||||
#{item.noresp},
|
||||
#{item.user},
|
||||
#{item.temperature},
|
||||
#{item.createBy},
|
||||
#{item.updateBy},
|
||||
<choose>
|
||||
@@ -185,6 +217,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getCpuInfoByClientId" parameterType="String" resultMap="InitialCpuInfoResult">
|
||||
<include refid="selectInitialCpuInfoVo"/>
|
||||
where client_id = #{clientId}
|
||||
|
||||
Reference in New Issue
Block a user