1、适配cpu信息表、容器信息表、挂载点信息表分表。

2、agent增加采集磁盘健康状态。
3、优化磁盘上报数据处理。
This commit is contained in:
gaoyutao
2026-02-05 18:04:34 +08:00
parent 0fb6a33f2e
commit 60db343cb0
42 changed files with 1455 additions and 77 deletions
@@ -76,4 +76,10 @@ public interface EpsInitialTrafficDataMapper {
void createDiskInfo(String tableName);
void batchInsertRecoverDetailTraffic(EpsInitialTrafficData batchData);
void createCpuInfo(String tableName);
void createMountPointInfo(String tableName);
void createDockerInfo(String tableName);
}
@@ -123,9 +123,9 @@ public interface RmResourceRegistrationMapper
int countChildNetwork(@Param("clientId") String clientId,
@Param("interfaceName") String interfaceName);
List<RmResourceRegistration> getCpuUtil(@Param("clientIdsStr") String clientIdsStr);
List<RmResourceRegistration> getCpuUtil(@Param("clientIdsStr") String clientIdsStr, @Param("tableName") String tableName);
List<RmResourceRegistration> getMemUtil(@Param("clientIdsStr") String clientIdsStr);
List<RmResourceRegistration> getMemUtil(@Param("clientIdsStr") String clientIdsStr, @Param("tableName") String tableName);
int removeAlarmFlag(RmResourceRegistration rmResourceRegistration);
@@ -76,6 +76,12 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
createSwitchOpMdTable(year, month);
// 创建磁盘信息表
createDiskInfo(year, month);
// 创建cpu信息表
createCpuInfo(year, month);
// 创建挂载点信息表
createMountPointInfo(year, month);
// 创建容器信息表
createDockerInfo(year, month);
}
public void createNextMonthTables(Long plusMonth) {
LocalDate nextMonth = LocalDate.now().plusMonths(plusMonth);
@@ -98,6 +104,12 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
createSwitchOpMdTable(year, month);
// 创建磁盘信息表
createDiskInfo(year, month);
// 创建cpu信息表
createCpuInfo(year, month);
// 创建挂载点信息表
createMountPointInfo(year, month);
// 创建容器信息表
createDockerInfo(year, month);
}
private void createTrafficDetailsTable(int year, int month) {
createRangeTables(year, month, "eps_traffic_details", (tableName) -> {
@@ -142,7 +154,22 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
epsInitialTrafficDataMapper.createDiskInfo(tableName);
});
}
private void createCpuInfo(int year, int month) {
createRangeTables(year, month, "initial_cpu_info", (tableName) -> {
epsInitialTrafficDataMapper.createCpuInfo(tableName);
});
}
private void createMountPointInfo(int year, int month) {
createRangeTables(year, month, "initial_mount_point_info", (tableName) -> {
epsInitialTrafficDataMapper.createMountPointInfo(tableName);
});
}
private void createDockerInfo(int year, int month) {
createRangeTables(year, month, "initial_docker_info", (tableName) -> {
epsInitialTrafficDataMapper.createDockerInfo(tableName);
});
}
/**
* 通用创建表方法
@@ -6,6 +6,7 @@ import com.tongran.common.core.domain.R;
import com.tongran.common.core.enums.MsgEnum;
import com.tongran.common.core.utils.DateUtils;
import com.tongran.common.core.utils.StringUtils;
import com.tongran.common.core.utils.TableSubUtil;
import com.tongran.common.core.web.domain.AjaxResult;
import com.tongran.common.core.web.page.PageDomain;
import com.tongran.common.security.utils.SecurityUtils;
@@ -338,7 +339,8 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
if (CollectionUtils.isEmpty(pageList)) {
return;
}
String cpuTbaleName = TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_cpu_info");
String memTbaleName = TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_system_other_collect_data");
long startTime = System.currentTimeMillis();
int batchSize = 200;
int totalBatches = (int) Math.ceil((double) pageList.size() / batchSize);
@@ -361,10 +363,10 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
try {
// 并行查询
CompletableFuture<List<RmResourceRegistration>> cpuFuture = CompletableFuture
.supplyAsync(() -> rmResourceRegistrationMapper.getCpuUtil(clientIdsStr));
.supplyAsync(() -> rmResourceRegistrationMapper.getCpuUtil(clientIdsStr, cpuTbaleName));
CompletableFuture<List<RmResourceRegistration>> memFuture = CompletableFuture
.supplyAsync(() -> rmResourceRegistrationMapper.getMemUtil(clientIdsStr));
.supplyAsync(() -> rmResourceRegistrationMapper.getMemUtil(clientIdsStr, memTbaleName));
CompletableFuture<List<RmNetworkInterfaceRemote>> networkFuture = CompletableFuture
.supplyAsync(() -> {
@@ -530,10 +532,12 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
*/
public void setNetWorkMsg(RmResourceRegistration registration) {
String clientId = registration.getClientId();
String cpuTbaleName = TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_cpu_info");
String memTbaleName = TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_system_other_collect_data");
// 根据clientId查询cpu利用率
List<RmResourceRegistration> cpuUtilList = rmResourceRegistrationMapper.getCpuUtil(clientId);
List<RmResourceRegistration> cpuUtilList = rmResourceRegistrationMapper.getCpuUtil(clientId, cpuTbaleName);
// 根据clientId查询mem利用率
List<RmResourceRegistration> memUtilList = rmResourceRegistrationMapper.getMemUtil(clientId);
List<RmResourceRegistration> memUtilList = rmResourceRegistrationMapper.getMemUtil(clientId, memTbaleName);
// 查询agent最新版本
RmResourceRegistration rmResourceRegistration = rmResourceRegistrationMapper.getMaxAgentVersion();
if(cpuUtilList != null && !cpuUtilList.isEmpty()){
@@ -222,11 +222,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`type` varchar(255) COMMENT '磁盘类型',
`used_space` bigint(20) COMMENT '已用空间',
`health_status` int(2) COMMENT '健康状态(0-不健康,1-健康)',
PRIMARY KEY (`id`),
UNIQUE KEY uk_client_disk_time (`client_id`, `name`, `create_time`),
INDEX idx_clent_type_time(`client_id`, `create_time`, `type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='磁盘监控信息表';
</update>
<update id="createCpuInfo">
CREATE TABLE IF NOT EXISTS ${tableName} (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`client_id` varchar(255) NOT NULL COMMENT '客户端ID',
`avg1` double(20, 2) COMMENT 'CPU1分钟负载',
`avg5` double(20, 2) COMMENT 'CPU5分钟负载',
`avg15` double(20, 2) COMMENT 'CPU15分钟负载',
`interrupt` double(20, 2) COMMENT 'CPU硬件中断提供服务时间',
`uti` double(20, 2) COMMENT 'CPU使用率(%)',
`num` double(20, 2) COMMENT 'CPU数量',
`cores` int(11) COMMENT 'cpu核数',
`normal` bigint(20) COMMENT 'CPU正常运行时间',
`idle` double(20, 2) COMMENT 'CPU空闲时间',
`iowait` double(20, 2) COMMENT 'CPU等待响应时间',
`system` double(20, 2) COMMENT 'CPU系统时间',
`noresp` double(20, 2) COMMENT 'CPU软件无响应时间',
`user` double(20, 2) COMMENT 'CPU用户进程所花费的时间',
`create_by` varchar(50) COMMENT '创建人',
`update_by` varchar(50) COMMENT '更新人',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`temperature` double(20, 1) COMMENT 'cpu温度',
PRIMARY KEY (`id`),
UNIQUE INDEX `idx_unnque_key`(`client_id`, `create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = 'CPU监控信息表';
</update>
<update id="createDockerInfo">
CREATE TABLE ${tableName} (
`id` varchar(64) COMMENT '容器ID',
`name` varchar(255) COMMENT '容器名称',
`status` varchar(20) COMMENT '容器状态(running/stopped/error等)',
`auto_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`cpu_util` varchar(10) COMMENT '容器CPU使用率(%)',
`mem_util` varchar(10) COMMENT '容器内存使用率(%)',
`net_in_speed` varchar(20) COMMENT '容器网络接收速率(KB/s)',
`net_out_speed` varchar(20) COMMENT '容器网络发送速率(KB/s)',
`client_id` varchar(255) COMMENT '设备唯一标识',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`create_by` varchar(20) COMMENT '创建人',
`update_by` varchar(20) COMMENT '修改人',
PRIMARY KEY (`auto_id`),
UNIQUE INDEX `idx_unique_key`(`id`, `client_id`, `create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = '容器监控信息表';
</update>
<update id="createMountPointInfo">
CREATE TABLE ${tableName} (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增主键ID',
`client_id` varchar(255) NOT NULL COMMENT '客户端ID',
`mount` varchar(255) NOT NULL COMMENT '挂载点路径(如\"/\"、\"/data\"等)',
`vfs_type` varchar(50) COMMENT '文件系统类型(如ext4、xfs、ntfs等)',
`vfs_free` bigint(20) COMMENT '可用空间(字节)',
`vfs_total` bigint(20) COMMENT '总空间(字节)',
`vfs_util` double(5, 2) COMMENT '空间利用率(%)',
`create_by` varchar(50) COMMENT '创建人',
`update_by` varchar(50) COMMENT '更新人',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE INDEX `idx_unique_key`(`client_id`, `mount`, `create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT = '挂载点监控信息表';
</update>
<!-- 单条插入语句 -->
<insert id="insert">
INSERT INTO ${tableName} (
@@ -336,12 +336,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.client_id as clientId,
d.cores as cpuCores,
d.uti as cpuUtil
FROM initial_cpu_info d
FROM ${tableName} d
INNER JOIN (
SELECT
client_id,
MAX(create_time) as latest_time
FROM initial_cpu_info
FROM ${tableName}
WHERE client_id in
<foreach collection="clientIdsStr.split(',')" item="clientId" open="(" separator="," close=")">
#{clientId}
@@ -354,12 +354,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT
d.client_id as clientId,
ROUND(d.collect_value, 1) as memUtil
FROM initial_system_other_collect_data d
FROM ${tableName} d
INNER JOIN (
SELECT
client_id,
MAX(create_time) as max_time
FROM initial_system_other_collect_data
FROM ${tableName}
WHERE collect_type='memoryUtilizationCollect'
AND client_id in
<foreach collection="clientIdsStr.split(',')" item="clientId" open="(" separator="," close=")">
@@ -0,0 +1,98 @@
package com.tongran.rocketmq.controller;
import com.tongran.common.core.utils.poi.ExcelUtil;
import com.tongran.common.core.web.controller.BaseController;
import com.tongran.common.core.web.domain.AjaxResult;
import com.tongran.common.core.web.page.TableDataInfo;
import com.tongran.common.log.annotation.Log;
import com.tongran.common.log.enums.BusinessType;
import com.tongran.common.security.annotation.RequiresPermissions;
import com.tongran.rocketmq.domain.AllDockerName;
import com.tongran.rocketmq.service.IAllDockerNameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 容器id存储Controller
*
* @author gyt
* @date 2026-02-05
*/
@RestController
@RequestMapping("/allDockerName")
public class AllDockerNameController extends BaseController
{
@Autowired
private IAllDockerNameService allDockerNameService;
/**
* 查询容器id存储列表
*/
@RequiresPermissions("rocketmq:allDockerName:list")
@GetMapping("/list")
public TableDataInfo list(AllDockerName allDockerName)
{
startPage();
List<AllDockerName> list = allDockerNameService.selectAllDockerNameList(allDockerName);
return getDataTable(list);
}
/**
* 导出容器id存储列表
*/
@RequiresPermissions("rocketmq:allDockerName:export")
@Log(title = "容器id存储", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, AllDockerName allDockerName)
{
List<AllDockerName> list = allDockerNameService.selectAllDockerNameList(allDockerName);
ExcelUtil<AllDockerName> util = new ExcelUtil<AllDockerName>(AllDockerName.class);
util.exportExcel(response, list, "容器id存储数据");
}
/**
* 获取容器id存储详细信息
*/
@RequiresPermissions("rocketmq:allDockerName:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(allDockerNameService.selectAllDockerNameById(id));
}
/**
* 新增容器id存储
*/
@RequiresPermissions("rocketmq:allDockerName:add")
@Log(title = "容器id存储", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody AllDockerName allDockerName)
{
return toAjax(allDockerNameService.insertAllDockerName(allDockerName));
}
/**
* 修改容器id存储
*/
@RequiresPermissions("rocketmq:allDockerName:edit")
@Log(title = "容器id存储", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody AllDockerName allDockerName)
{
return toAjax(allDockerNameService.updateAllDockerName(allDockerName));
}
/**
* 删除容器id存储
*/
@RequiresPermissions("rocketmq:allDockerName:remove")
@Log(title = "容器id存储", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(allDockerNameService.deleteAllDockerNameByIds(ids));
}
}
@@ -0,0 +1,98 @@
package com.tongran.rocketmq.controller;
import com.tongran.common.core.utils.poi.ExcelUtil;
import com.tongran.common.core.web.controller.BaseController;
import com.tongran.common.core.web.domain.AjaxResult;
import com.tongran.common.core.web.page.TableDataInfo;
import com.tongran.common.log.annotation.Log;
import com.tongran.common.log.enums.BusinessType;
import com.tongran.common.security.annotation.RequiresPermissions;
import com.tongran.rocketmq.domain.AllMountName;
import com.tongran.rocketmq.service.IAllMountNameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 挂载点路径名称存储Controller
*
* @author gyt
* @date 2026-02-05
*/
@RestController
@RequestMapping("/allMountName")
public class AllMountNameController extends BaseController
{
@Autowired
private IAllMountNameService allMountNameService;
/**
* 查询挂载点路径名称存储列表
*/
@RequiresPermissions("rocketmq:allMountName:list")
@GetMapping("/list")
public TableDataInfo list(AllMountName allMountName)
{
startPage();
List<AllMountName> list = allMountNameService.selectAllMountNameList(allMountName);
return getDataTable(list);
}
/**
* 导出挂载点路径名称存储列表
*/
@RequiresPermissions("rocketmq:allMountName:export")
@Log(title = "挂载点路径名称存储", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, AllMountName allMountName)
{
List<AllMountName> list = allMountNameService.selectAllMountNameList(allMountName);
ExcelUtil<AllMountName> util = new ExcelUtil<AllMountName>(AllMountName.class);
util.exportExcel(response, list, "挂载点路径名称存储数据");
}
/**
* 获取挂载点路径名称存储详细信息
*/
@RequiresPermissions("rocketmq:allMountName:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(allMountNameService.selectAllMountNameById(id));
}
/**
* 新增挂载点路径名称存储
*/
@RequiresPermissions("rocketmq:allMountName:add")
@Log(title = "挂载点路径名称存储", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody AllMountName allMountName)
{
return toAjax(allMountNameService.insertAllMountName(allMountName));
}
/**
* 修改挂载点路径名称存储
*/
@RequiresPermissions("rocketmq:allMountName:edit")
@Log(title = "挂载点路径名称存储", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody AllMountName allMountName)
{
return toAjax(allMountNameService.updateAllMountName(allMountName));
}
/**
* 删除挂载点路径名称存储
*/
@RequiresPermissions("rocketmq:allMountName:remove")
@Log(title = "挂载点路径名称存储", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(allMountNameService.deleteAllMountNameByIds(ids));
}
}
@@ -63,5 +63,7 @@ public class AllDiskName extends BaseEntity
private String type;
/** 表名 */
private String tableName;
/** 健康状态 0 不健康,1健康 */
private Long healthStatus;
}
@@ -0,0 +1,71 @@
package com.tongran.rocketmq.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.tongran.common.core.annotation.Excel;
import com.tongran.common.core.web.domain.BaseEntity;
/**
* 容器id存储对象 all_docker_name
*
* @author gyt
* @date 2026-02-05
*/
public class AllDockerName extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 客户端ID */
@Excel(name = "客户端ID")
private String clientId;
/** 容器id */
@Excel(name = "容器id")
private String dockerId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setClientId(String clientId)
{
this.clientId = clientId;
}
public String getClientId()
{
return clientId;
}
public void setDockerId(String dockerId)
{
this.dockerId = dockerId;
}
public String getDockerId()
{
return dockerId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("clientId", getClientId())
.append("dockerId", getDockerId())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.toString();
}
}
@@ -0,0 +1,71 @@
package com.tongran.rocketmq.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.tongran.common.core.annotation.Excel;
import com.tongran.common.core.web.domain.BaseEntity;
/**
* 挂载点路径名称存储对象 all_mount_name
*
* @author gyt
* @date 2026-02-05
*/
public class AllMountName extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 客户端ID */
@Excel(name = "客户端ID")
private String clientId;
/** 挂载路径 */
@Excel(name = "挂载路径")
private String mount;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setClientId(String clientId)
{
this.clientId = clientId;
}
public String getClientId()
{
return clientId;
}
public void setMount(String mount)
{
this.mount = mount;
}
public String getMount()
{
return mount;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("clientId", getClientId())
.append("mount", getMount())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.toString();
}
}
@@ -4,6 +4,8 @@ import com.tongran.common.core.annotation.Excel;
import com.tongran.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.util.List;
/**
* CPU监控信息对象 initial_cpu_info
*
@@ -78,4 +80,8 @@ public class InitialCpuInfo extends BaseEntity
private String startTime;
/** 结束时间 */
private String endTime;
/** 表名 */
private String tableName;
/** cpu信息列表 */
private List<InitialCpuInfo> list;
}
@@ -85,6 +85,8 @@ public class InitialDiskInfo extends BaseEntity
private List<InitialDiskInfo> list;
/** 单位 */
private String unit;
/** 健康状态 0-不健康 1-健康) */
private Long healthStatus;
}
@@ -4,6 +4,8 @@ import com.tongran.common.core.annotation.Excel;
import com.tongran.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.util.List;
/**
* 容器监控信息对象 initial_docker_info
*
@@ -51,4 +53,8 @@ public class InitialDockerInfo extends BaseEntity
private String startTime;
/** 结束时间 */
private String endTime;
/** 表名 */
private String tableName;
/** 容器信息列表 */
private List<InitialDockerInfo> list;
}
@@ -5,6 +5,7 @@ import com.tongran.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 挂载点监控信息对象 initial_mount_point_info
@@ -47,4 +48,8 @@ public class InitialMountPointInfo extends BaseEntity
private String startTime;
/** 结束时间 */
private String endTime;
/** 表名 */
private String tableName;
/** 挂载点信息列表 */
private List<InitialMountPointInfo> list;
}
@@ -223,7 +223,7 @@ public class DeviceMessageHandler {
iface.setCreateTime(createTime);
});
// 初始容器数据入库
initialDockerInfoService.batchInsertInitialDockerInfo(dockers);
initialDockerInfoService.batchInsertInitialDockerInfo(dockers, createTime);
}else{
throw new RuntimeException("DOCKER容器data数据为空");
}
@@ -244,7 +244,7 @@ public class DeviceMessageHandler {
iface.setCreateTime(createTime);
});
// 初始CPU数据入库
initialCpuInfoService.batchInsertInitialCpuInfo(cpus);
initialCpuInfoService.batchInsertInitialCpuInfo(cpus, createTime);
}else{
throw new RuntimeException("CPUdata数据为空");
}
@@ -307,7 +307,7 @@ public class DeviceMessageHandler {
iface.setCreateTime(createTime);
});
// 初始挂载点数据入库
initialMountPointInfoService.batchInsertInitialMountPointInfo(mountPointInfos);
initialMountPointInfoService.batchInsertInitialMountPointInfo(mountPointInfos, createTime);
}else{
throw new RuntimeException("挂载点data数据为空");
}
@@ -1067,7 +1067,7 @@ public class MessageHandler {
iface.setCreateTime(createTime);
});
// 初始容器数据入库
initialDockerInfoService.batchInsertInitialDockerInfo(dockers);
initialDockerInfoService.batchInsertInitialDockerInfo(dockers, createTime);
}else{
throw new RuntimeException("DOCKER容器data数据为空");
}
@@ -1091,7 +1091,7 @@ public class MessageHandler {
}
});
// 初始CPU数据入库
initialCpuInfoService.batchInsertInitialCpuInfo(cpus);
initialCpuInfoService.batchInsertInitialCpuInfo(cpus, createTime);
}else{
throw new RuntimeException("CPUdata数据为空");
}
@@ -1223,7 +1223,7 @@ public class MessageHandler {
iface.setCreateTime(createTime);
});
// 初始挂载点数据入库
initialMountPointInfoService.batchInsertInitialMountPointInfo(mountPointInfos);
initialMountPointInfoService.batchInsertInitialMountPointInfo(mountPointInfos, createTime);
}else{
throw new RuntimeException("挂载点data数据为空");
}
@@ -0,0 +1,64 @@
package com.tongran.rocketmq.mapper;
import com.tongran.rocketmq.domain.AllDockerName;
import java.util.List;
/**
* 容器id存储Mapper接口
*
* @author gyt
* @date 2026-02-05
*/
public interface AllDockerNameMapper
{
/**
* 查询容器id存储
*
* @param id 容器id存储主键
* @return 容器id存储
*/
public AllDockerName selectAllDockerNameById(Long id);
/**
* 查询容器id存储列表
*
* @param allDockerName 容器id存储
* @return 容器id存储集合
*/
public List<AllDockerName> selectAllDockerNameList(AllDockerName allDockerName);
/**
* 新增容器id存储
*
* @param allDockerName 容器id存储
* @return 结果
*/
public int insertAllDockerName(AllDockerName allDockerName);
/**
* 修改容器id存储
*
* @param allDockerName 容器id存储
* @return 结果
*/
public int updateAllDockerName(AllDockerName allDockerName);
/**
* 删除容器id存储
*
* @param id 容器id存储主键
* @return 结果
*/
public int deleteAllDockerNameById(Long id);
/**
* 批量删除容器id存储
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteAllDockerNameByIds(Long[] ids);
void batchInsertAllDockerId(List<AllDockerName> list);
}
@@ -0,0 +1,64 @@
package com.tongran.rocketmq.mapper;
import com.tongran.rocketmq.domain.AllMountName;
import java.util.List;
/**
* 挂载点路径名称存储Mapper接口
*
* @author gyt
* @date 2026-02-05
*/
public interface AllMountNameMapper
{
/**
* 查询挂载点路径名称存储
*
* @param id 挂载点路径名称存储主键
* @return 挂载点路径名称存储
*/
public AllMountName selectAllMountNameById(Long id);
/**
* 查询挂载点路径名称存储列表
*
* @param allMountName 挂载点路径名称存储
* @return 挂载点路径名称存储集合
*/
public List<AllMountName> selectAllMountNameList(AllMountName allMountName);
/**
* 新增挂载点路径名称存储
*
* @param allMountName 挂载点路径名称存储
* @return 结果
*/
public int insertAllMountName(AllMountName allMountName);
/**
* 修改挂载点路径名称存储
*
* @param allMountName 挂载点路径名称存储
* @return 结果
*/
public int updateAllMountName(AllMountName allMountName);
/**
* 删除挂载点路径名称存储
*
* @param id 挂载点路径名称存储主键
* @return 结果
*/
public int deleteAllMountNameById(Long id);
/**
* 批量删除挂载点路径名称存储
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteAllMountNameByIds(Long[] ids);
void batchInsertAllMount(List<AllMountName> list);
}
@@ -1,7 +1,7 @@
package com.tongran.rocketmq.mapper;
import com.tongran.rocketmq.domain.InitialCpuInfo;
import org.springframework.data.repository.query.Param;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -63,10 +63,12 @@ public interface InitialCpuInfoMapper
/**
* 批量新增CPU监控信息
*
* @param list CPU监控信息集合
* @param initialCpuInfo CPU监控信息
* @return 结果
*/
public int batchInsertInitialCpuInfo(@Param("list") List<InitialCpuInfo> list);
public int batchInsertInitialCpuInfo(InitialCpuInfo initialCpuInfo);
InitialCpuInfo getCpuInfoByClientId(String clientId);
InitialCpuInfo getCpuInfoByClientId(@Param("clientId") String clientId, @Param("tableName") String tableName);
List<InitialCpuInfo> selectInitialCpuInfoListByCondition(InitialCpuInfo condition);
}
@@ -1,7 +1,6 @@
package com.tongran.rocketmq.mapper;
import com.tongran.rocketmq.domain.InitialDockerInfo;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Map;
@@ -62,7 +61,7 @@ public interface InitialDockerInfoMapper
*/
public int deleteInitialDockerInfoByIds(Long[] autoId);
int batchInsertInitialDockerInfo(@Param("list") List<InitialDockerInfo> list);
int batchInsertInitialDockerInfo(InitialDockerInfo initialDockerInfo);
/**
* 容器基础信息
@@ -77,4 +76,6 @@ public interface InitialDockerInfoMapper
* @return
*/
List<Map> getAllDockerId(InitialDockerInfo initialDockerInfo);
List<InitialDockerInfo> selectInitialDockerInfoListByCondition(InitialDockerInfo condition);
}
@@ -1,7 +1,6 @@
package com.tongran.rocketmq.mapper;
import com.tongran.rocketmq.domain.InitialMountPointInfo;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Map;
@@ -64,10 +63,10 @@ public interface InitialMountPointInfoMapper
/**
* 批量新增挂载点监控信息
*
* @param list 挂载点监控信息集合
* @param initialMountPointInfo 挂载点监控信息集合
* @return 结果
*/
public int batchInsertInitialMountPointInfo(@Param("list") List<InitialMountPointInfo> list);
public int batchInsertInitialMountPointInfo(InitialMountPointInfo initialMountPointInfo);
/**
* 挂载文件系统基础信息
@@ -82,4 +81,6 @@ public interface InitialMountPointInfoMapper
* @return
*/
List<Map> getAllMountName(InitialMountPointInfo initialMountPointInfo);
List<InitialMountPointInfo> selectInitialMountPointInfoListByCondition(InitialMountPointInfo condition);
}
@@ -0,0 +1,65 @@
package com.tongran.rocketmq.service;
import com.tongran.rocketmq.domain.AllDockerName;
import com.tongran.rocketmq.domain.InitialDockerInfo;
import java.util.List;
/**
* 容器id存储Service接口
*
* @author gyt
* @date 2026-02-05
*/
public interface IAllDockerNameService
{
/**
* 查询容器id存储
*
* @param id 容器id存储主键
* @return 容器id存储
*/
public AllDockerName selectAllDockerNameById(Long id);
/**
* 查询容器id存储列表
*
* @param allDockerName 容器id存储
* @return 容器id存储集合
*/
public List<AllDockerName> selectAllDockerNameList(AllDockerName allDockerName);
/**
* 新增容器id存储
*
* @param allDockerName 容器id存储
* @return 结果
*/
public int insertAllDockerName(AllDockerName allDockerName);
/**
* 修改容器id存储
*
* @param allDockerName 容器id存储
* @return 结果
*/
public int updateAllDockerName(AllDockerName allDockerName);
/**
* 批量删除容器id存储
*
* @param ids 需要删除的容器id存储主键集合
* @return 结果
*/
public int deleteAllDockerNameByIds(Long[] ids);
/**
* 删除容器id存储信息
*
* @param id 容器id存储主键
* @return 结果
*/
public int deleteAllDockerNameById(Long id);
void batchInsertAllDockerId(List<InitialDockerInfo> dataList);
}
@@ -0,0 +1,65 @@
package com.tongran.rocketmq.service;
import com.tongran.rocketmq.domain.AllMountName;
import com.tongran.rocketmq.domain.InitialMountPointInfo;
import java.util.List;
/**
* 挂载点路径名称存储Service接口
*
* @author gyt
* @date 2026-02-05
*/
public interface IAllMountNameService
{
/**
* 查询挂载点路径名称存储
*
* @param id 挂载点路径名称存储主键
* @return 挂载点路径名称存储
*/
public AllMountName selectAllMountNameById(Long id);
/**
* 查询挂载点路径名称存储列表
*
* @param allMountName 挂载点路径名称存储
* @return 挂载点路径名称存储集合
*/
public List<AllMountName> selectAllMountNameList(AllMountName allMountName);
/**
* 新增挂载点路径名称存储
*
* @param allMountName 挂载点路径名称存储
* @return 结果
*/
public int insertAllMountName(AllMountName allMountName);
/**
* 修改挂载点路径名称存储
*
* @param allMountName 挂载点路径名称存储
* @return 结果
*/
public int updateAllMountName(AllMountName allMountName);
/**
* 批量删除挂载点路径名称存储
*
* @param ids 需要删除的挂载点路径名称存储主键集合
* @return 结果
*/
public int deleteAllMountNameByIds(Long[] ids);
/**
* 删除挂载点路径名称存储信息
*
* @param id 挂载点路径名称存储主键
* @return 结果
*/
public int deleteAllMountNameById(Long id);
void batchInsertAllMount(List<InitialMountPointInfo> dataList);
}
@@ -2,6 +2,7 @@ package com.tongran.rocketmq.service;
import com.tongran.rocketmq.domain.InitialCpuInfo;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -66,7 +67,7 @@ public interface IInitialCpuInfoService
* @param list CPU监控信息信息集合
* @return 结果
*/
public int batchInsertInitialCpuInfo(List<InitialCpuInfo> list);
public int batchInsertInitialCpuInfo(List<InitialCpuInfo> list, Date createTime);
Map<String, Object> cupLoadEcharts(InitialCpuInfo initialCpuInfo);
@@ -2,6 +2,7 @@ package com.tongran.rocketmq.service;
import com.tongran.rocketmq.domain.InitialDockerInfo;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -67,7 +68,7 @@ public interface IInitialDockerInfoService
* @param initialDockerInfo 容器监控信息集合
* @return 结果
*/
public int batchInsertInitialDockerInfo(List<InitialDockerInfo> initialDockerInfo);
public int batchInsertInitialDockerInfo(List<InitialDockerInfo> initialDockerInfo, Date createTime);
/**
* 容器基础信息
@@ -1,8 +1,8 @@
package com.tongran.rocketmq.service;
import com.tongran.rocketmq.domain.InitialMountPointInfo;
import org.springframework.data.repository.query.Param;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -67,7 +67,7 @@ public interface IInitialMountPointInfoService
* @param list 挂载点监控信息集合
* @return 结果
*/
public int batchInsertInitialMountPointInfo(@Param("list") List<InitialMountPointInfo> list);
public int batchInsertInitialMountPointInfo(List<InitialMountPointInfo> list, Date createTime);
/**
* 获取挂载点监控信息详细信息
*/
@@ -0,0 +1,113 @@
package com.tongran.rocketmq.service.impl;
import com.tongran.common.core.utils.DateUtils;
import com.tongran.rocketmq.domain.AllDockerName;
import com.tongran.rocketmq.domain.InitialDockerInfo;
import com.tongran.rocketmq.mapper.AllDockerNameMapper;
import com.tongran.rocketmq.service.IAllDockerNameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 容器id存储Service业务层处理
*
* @author gyt
* @date 2026-02-05
*/
@Service
public class AllDockerNameServiceImpl implements IAllDockerNameService
{
@Autowired
private AllDockerNameMapper allDockerNameMapper;
/**
* 查询容器id存储
*
* @param id 容器id存储主键
* @return 容器id存储
*/
@Override
public AllDockerName selectAllDockerNameById(Long id)
{
return allDockerNameMapper.selectAllDockerNameById(id);
}
/**
* 查询容器id存储列表
*
* @param allDockerName 容器id存储
* @return 容器id存储
*/
@Override
public List<AllDockerName> selectAllDockerNameList(AllDockerName allDockerName)
{
return allDockerNameMapper.selectAllDockerNameList(allDockerName);
}
/**
* 新增容器id存储
*
* @param allDockerName 容器id存储
* @return 结果
*/
@Override
public int insertAllDockerName(AllDockerName allDockerName)
{
allDockerName.setCreateTime(DateUtils.getNowDate());
return allDockerNameMapper.insertAllDockerName(allDockerName);
}
/**
* 修改容器id存储
*
* @param allDockerName 容器id存储
* @return 结果
*/
@Override
public int updateAllDockerName(AllDockerName allDockerName)
{
allDockerName.setUpdateTime(DateUtils.getNowDate());
return allDockerNameMapper.updateAllDockerName(allDockerName);
}
/**
* 批量删除容器id存储
*
* @param ids 需要删除的容器id存储主键
* @return 结果
*/
@Override
public int deleteAllDockerNameByIds(Long[] ids)
{
return allDockerNameMapper.deleteAllDockerNameByIds(ids);
}
/**
* 删除容器id存储信息
*
* @param id 容器id存储主键
* @return 结果
*/
@Override
public int deleteAllDockerNameById(Long id)
{
return allDockerNameMapper.deleteAllDockerNameById(id);
}
@Override
public void batchInsertAllDockerId(List<InitialDockerInfo> dataList) {
List<AllDockerName> nameList = new ArrayList<>();
for (InitialDockerInfo initialDockerInfo : dataList) {
AllDockerName allDockerName = new AllDockerName();
allDockerName.setClientId(initialDockerInfo.getClientId());
allDockerName.setDockerId(initialDockerInfo.getId());
allDockerName.setCreateTime(initialDockerInfo.getCreateTime());
allDockerName.setUpdateTime(DateUtils.getNowDate());
nameList.add(allDockerName);
}
allDockerNameMapper.batchInsertAllDockerId(nameList);
}
}
@@ -0,0 +1,113 @@
package com.tongran.rocketmq.service.impl;
import com.tongran.common.core.utils.DateUtils;
import com.tongran.rocketmq.domain.AllMountName;
import com.tongran.rocketmq.domain.InitialMountPointInfo;
import com.tongran.rocketmq.mapper.AllMountNameMapper;
import com.tongran.rocketmq.service.IAllMountNameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 挂载点路径名称存储Service业务层处理
*
* @author gyt
* @date 2026-02-05
*/
@Service
public class AllMountNameServiceImpl implements IAllMountNameService
{
@Autowired
private AllMountNameMapper allMountNameMapper;
/**
* 查询挂载点路径名称存储
*
* @param id 挂载点路径名称存储主键
* @return 挂载点路径名称存储
*/
@Override
public AllMountName selectAllMountNameById(Long id)
{
return allMountNameMapper.selectAllMountNameById(id);
}
/**
* 查询挂载点路径名称存储列表
*
* @param allMountName 挂载点路径名称存储
* @return 挂载点路径名称存储
*/
@Override
public List<AllMountName> selectAllMountNameList(AllMountName allMountName)
{
return allMountNameMapper.selectAllMountNameList(allMountName);
}
/**
* 新增挂载点路径名称存储
*
* @param allMountName 挂载点路径名称存储
* @return 结果
*/
@Override
public int insertAllMountName(AllMountName allMountName)
{
allMountName.setCreateTime(DateUtils.getNowDate());
return allMountNameMapper.insertAllMountName(allMountName);
}
/**
* 修改挂载点路径名称存储
*
* @param allMountName 挂载点路径名称存储
* @return 结果
*/
@Override
public int updateAllMountName(AllMountName allMountName)
{
allMountName.setUpdateTime(DateUtils.getNowDate());
return allMountNameMapper.updateAllMountName(allMountName);
}
/**
* 批量删除挂载点路径名称存储
*
* @param ids 需要删除的挂载点路径名称存储主键
* @return 结果
*/
@Override
public int deleteAllMountNameByIds(Long[] ids)
{
return allMountNameMapper.deleteAllMountNameByIds(ids);
}
/**
* 删除挂载点路径名称存储信息
*
* @param id 挂载点路径名称存储主键
* @return 结果
*/
@Override
public int deleteAllMountNameById(Long id)
{
return allMountNameMapper.deleteAllMountNameById(id);
}
@Override
public void batchInsertAllMount(List<InitialMountPointInfo> dataList) {
List<AllMountName> nameList = new ArrayList<>();
for (InitialMountPointInfo initialMountPointInfo : dataList) {
AllMountName allMountName = new AllMountName();
allMountName.setClientId(initialMountPointInfo.getClientId());
allMountName.setMount(initialMountPointInfo.getMount());
allMountName.setCreateTime(initialMountPointInfo.getCreateTime());
allMountName.setUpdateTime(DateUtils.getNowDate());
nameList.add(allMountName);
}
allMountNameMapper.batchInsertAllMount(nameList);
}
}
@@ -683,7 +683,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
String memTotalSize = initialSystemOtherCollectDataMapper.getMemTotalSize(memQuery);
resultMap.put("memTotalSize", memTotalSize);
// 获取cpu数量
InitialCpuInfo cpuInfo = initialCpuInfoMapper.getCpuInfoByClientId(initialBandwidthTraffic.getClientId());
String cpuTbaleName = TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_cpu_info");
InitialCpuInfo cpuInfo = initialCpuInfoMapper.getCpuInfoByClientId(initialBandwidthTraffic.getClientId(), cpuTbaleName);
if (cpuInfo == null) {
cpuInfo = new InitialCpuInfo();
}
@@ -2,6 +2,7 @@ package com.tongran.rocketmq.service.impl;
import com.tongran.common.core.utils.DateUtils;
import com.tongran.common.core.utils.EchartsDataUtils;
import com.tongran.common.core.utils.TableSubUtil;
import com.tongran.rocketmq.domain.InitialCpuInfo;
import com.tongran.rocketmq.domain.RmAlarmLog;
import com.tongran.rocketmq.domain.RmAlarmThreshold;
@@ -13,16 +14,16 @@ import com.tongran.rocketmq.mapper.RmAlarmThresholdMapper;
import com.tongran.rocketmq.service.IInitialCpuInfoService;
import com.tongran.rocketmq.utils.SendAlarmPushUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.tongran.common.core.utils.EchartsDataUtils.convertMicrosecondsToSeconds;
@@ -37,6 +38,7 @@ import static com.tongran.common.core.utils.EchartsDataUtils.convertMicroseconds
@Slf4j
public class InitialCpuInfoServiceImpl implements IInitialCpuInfoService
{
private static final String TABLE_PREFIX = "initial_cpu_info";
@Autowired
private InitialCpuInfoMapper initialCpuInfoMapper;
@Autowired
@@ -128,7 +130,10 @@ public class InitialCpuInfoServiceImpl implements IInitialCpuInfoService
*/
@Override
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
public int batchInsertInitialCpuInfo(List<InitialCpuInfo> list) {
public int batchInsertInitialCpuInfo(List<InitialCpuInfo> list, Date createTime) {
if (list == null || list.isEmpty()) {
return 0;
}
try {
// 查询告警阈值
RmAlarmThreshold thresholdQuery = new RmAlarmThreshold();
@@ -172,13 +177,64 @@ public class InitialCpuInfoServiceImpl implements IInitialCpuInfoService
}
}
}
return initialCpuInfoMapper.batchInsertInitialCpuInfo(list);
// 按表名分组批量插入
Map<String, List<InitialCpuInfo>> groupedData = list.stream()
.map(data -> {
try {
InitialCpuInfo processed = new InitialCpuInfo();
BeanUtils.copyProperties(data,processed);
if (data.getCreateTime() == null) {
data.setCreateTime(DateUtils.getNowDate());
}
processed.setTableName(TableSubUtil.getTableName(createTime, TABLE_PREFIX));
return processed;
} catch (Exception e){
log.error("数据处理失败",e.getMessage());
return null;
}
}).collect(Collectors.groupingBy(
InitialCpuInfo::getTableName,
LinkedHashMap::new, // 保持插入顺序
Collectors.toList()));
groupedData.forEach((tableName, dataList) -> {
try {
InitialCpuInfo data = new InitialCpuInfo();
data.setTableName(tableName);
data.setList(dataList);
initialCpuInfoMapper.batchInsertInitialCpuInfo(data);
} catch (Exception e) {
log.error("表{}插入失败", tableName, e);
throw new RuntimeException("批量插入失败", e);
}
});
return 1;
}catch (Exception e){
log.error("批量插入CPU信息失败,失败数量:{}", list.size(), e);
throw new RuntimeException("批量保存失败",e);
}
}
/**
* 分表查询硬盘信息
* @param queryParam
* @return
*/
public List<InitialCpuInfo> getCpuInfoSharding(InitialCpuInfo queryParam) {
// 获取涉及的表名
Set<String> tableNames = TableSubUtil.getExistingTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
// 并行查询各表
return tableNames.parallelStream()
.flatMap(tableName -> {
InitialCpuInfo condition = new InitialCpuInfo();
condition.setTableName(tableName);
condition.setClientId(queryParam.getClientId());
condition.setStartTime(queryParam.getStartTime());
condition.setEndTime(queryParam.getEndTime());
return initialCpuInfoMapper.selectInitialCpuInfoListByCondition(condition).stream();
})
.collect(Collectors.toList());
}
/**
* cpu负载
* @param initialCpuInfo
@@ -187,7 +243,7 @@ public class InitialCpuInfoServiceImpl implements IInitialCpuInfoService
@Override
public Map<String, Object> cupLoadEcharts(InitialCpuInfo initialCpuInfo) {
// 查询原始CPU监控数据并按时间排序
List<InitialCpuInfo> list = initialCpuInfoMapper.selectInitialCpuInfoList(initialCpuInfo);
List<InitialCpuInfo> list = getCpuInfoSharding(initialCpuInfo);
Map<String, Function<InitialCpuInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("load1Data", InitialCpuInfo::getAvg1);
@@ -204,7 +260,7 @@ public class InitialCpuInfoServiceImpl implements IInitialCpuInfoService
*/
@Override
public Map<String, Object> cpuTimeEcharts(InitialCpuInfo initialCpuInfo) {
List<InitialCpuInfo> list = initialCpuInfoMapper.selectInitialCpuInfoList(initialCpuInfo);
List<InitialCpuInfo> list = getCpuInfoSharding(initialCpuInfo);
Map<String, Function<InitialCpuInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("normalData", info -> convertMicrosecondsToSeconds(info.getNormal()));
@@ -224,7 +280,7 @@ public class InitialCpuInfoServiceImpl implements IInitialCpuInfoService
@Override
public Map<String, Object> cupTemperatureEcharts(InitialCpuInfo initialCpuInfo) {
// 查询原始CPU监控数据并按时间排序
List<InitialCpuInfo> list = initialCpuInfoMapper.selectInitialCpuInfoList(initialCpuInfo);
List<InitialCpuInfo> list = getCpuInfoSharding(initialCpuInfo);
Map<String, Function<InitialCpuInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("temperatureData", InitialCpuInfo::getTemperature);
@@ -2,19 +2,21 @@ package com.tongran.rocketmq.service.impl;
import com.tongran.common.core.utils.DateUtils;
import com.tongran.common.core.utils.EchartsDataUtils;
import com.tongran.common.core.utils.TableSubUtil;
import com.tongran.rocketmq.domain.InitialDockerInfo;
import com.tongran.rocketmq.mapper.InitialDockerInfoMapper;
import com.tongran.rocketmq.service.IAllDockerNameService;
import com.tongran.rocketmq.service.IInitialDockerInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 容器监控信息Service业务层处理
@@ -26,8 +28,11 @@ import java.util.function.Function;
@Slf4j
public class InitialDockerInfoServiceImpl implements IInitialDockerInfoService
{
private static final String TABLE_PREFIX = "initial_docker_info";
@Autowired
private InitialDockerInfoMapper initialDockerInfoMapper;
@Autowired
private IAllDockerNameService allDockerNameService;
/**
* 查询容器监控信息
@@ -106,20 +111,74 @@ public class InitialDockerInfoServiceImpl implements IInitialDockerInfoService
/**
* 批量新增容器监控信息
*
* @param initialDockerInfo 容器监控信息集合
* @param list 容器监控信息集合
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
public int batchInsertInitialDockerInfo(List<InitialDockerInfo> initialDockerInfo){
public int batchInsertInitialDockerInfo(List<InitialDockerInfo> list, Date createTime){
try {
return initialDockerInfoMapper.batchInsertInitialDockerInfo(initialDockerInfo);
// 按表名分组批量插入
Map<String, List<InitialDockerInfo>> groupedData = list.stream()
.map(data -> {
try {
InitialDockerInfo processed = new InitialDockerInfo();
BeanUtils.copyProperties(data,processed);
if (data.getCreateTime() == null) {
data.setCreateTime(DateUtils.getNowDate());
}
processed.setTableName(TableSubUtil.getTableName(createTime, TABLE_PREFIX));
return processed;
} catch (Exception e){
log.error("数据处理失败",e.getMessage());
return null;
}
}).collect(Collectors.groupingBy(
InitialDockerInfo::getTableName,
LinkedHashMap::new, // 保持插入顺序
Collectors.toList()));
groupedData.forEach((tableName, dataList) -> {
try {
InitialDockerInfo data = new InitialDockerInfo();
data.setTableName(tableName);
data.setList(dataList);
initialDockerInfoMapper.batchInsertInitialDockerInfo(data);
// 记录挂载点路径名称
allDockerNameService.batchInsertAllDockerId(dataList);
} catch (Exception e) {
log.error("表{}插入失败", tableName, e);
throw new RuntimeException("批量插入失败", e);
}
});
return 1;
}catch (Exception e){
log.error("批量插入Docker信息失败,失败数量:{}", initialDockerInfo.size(), e);
log.error("批量插入Docker信息失败,失败数量:{}", list.size(), e);
throw new RuntimeException("批量保存失败",e);
}
}
/**
* 分表查询硬盘信息
* @param queryParam
* @return
*/
public List<InitialDockerInfo> getDockerInfoSharding(InitialDockerInfo queryParam) {
// 获取涉及的表名
Set<String> tableNames = TableSubUtil.getExistingTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
// 并行查询各表
return tableNames.parallelStream()
.flatMap(tableName -> {
InitialDockerInfo condition = new InitialDockerInfo();
condition.setTableName(tableName);
condition.setClientId(queryParam.getClientId());
condition.setId(queryParam.getId());
condition.setStartTime(queryParam.getStartTime());
condition.setEndTime(queryParam.getEndTime());
return initialDockerInfoMapper.selectInitialDockerInfoListByCondition(condition).stream();
})
.collect(Collectors.toList());
}
/**
* 容器基础信息
* @param initialDockerInfo
@@ -127,17 +186,19 @@ public class InitialDockerInfoServiceImpl implements IInitialDockerInfoService
*/
@Override
public InitialDockerInfo getDockerDetailsMsg(InitialDockerInfo initialDockerInfo) {
String tableName = TableSubUtil.getTableName(DateUtils.getNowDate(), TABLE_PREFIX);
initialDockerInfo.setTableName(tableName);
return initialDockerInfoMapper.getDockerDetailsMsg(initialDockerInfo);
}
/**
* cou利用率
* cpu利用率
* @param initialDockerInfo
* @return
*/
@Override
public Map<String, Object> cpuUtilEcharts(InitialDockerInfo initialDockerInfo) {
List<InitialDockerInfo> list = initialDockerInfoMapper.selectInitialDockerInfoList(initialDockerInfo);
List<InitialDockerInfo> list = getDockerInfoSharding(initialDockerInfo);
Map<String, Function<InitialDockerInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("cpuUtilData", info -> info.getCpuUtil());
return EchartsDataUtils.buildEchartsData(list, InitialDockerInfo::getCreateTime, extractors);
@@ -149,7 +210,7 @@ public class InitialDockerInfoServiceImpl implements IInitialDockerInfoService
*/
@Override
public Map<String, Object> memUtilEcharts(InitialDockerInfo initialDockerInfo) {
List<InitialDockerInfo> list = initialDockerInfoMapper.selectInitialDockerInfoList(initialDockerInfo);
List<InitialDockerInfo> list = getDockerInfoSharding(initialDockerInfo);
Map<String, Function<InitialDockerInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("memUtilData", info -> info.getMemUtil());
return EchartsDataUtils.buildEchartsData(list, InitialDockerInfo::getCreateTime, extractors);
@@ -161,7 +222,7 @@ public class InitialDockerInfoServiceImpl implements IInitialDockerInfoService
*/
@Override
public Map<String, Object> netSpeedEcharts(InitialDockerInfo initialDockerInfo) {
List<InitialDockerInfo> list = initialDockerInfoMapper.selectInitialDockerInfoList(initialDockerInfo);
List<InitialDockerInfo> list = getDockerInfoSharding(initialDockerInfo);
Map<String, Function<InitialDockerInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("netInSpeedData", info -> info.getNetInSpeed());
extractors.put("netOutSpeedData", info -> info.getNetOutSpeed());
@@ -2,20 +2,22 @@ package com.tongran.rocketmq.service.impl;
import com.tongran.common.core.utils.DateUtils;
import com.tongran.common.core.utils.EchartsDataUtils;
import com.tongran.common.core.utils.TableSubUtil;
import com.tongran.common.core.utils.UnitChangeUtil;
import com.tongran.rocketmq.domain.InitialMountPointInfo;
import com.tongran.rocketmq.mapper.InitialMountPointInfoMapper;
import com.tongran.rocketmq.service.IAllMountNameService;
import com.tongran.rocketmq.service.IInitialMountPointInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 挂载点监控信息Service业务层处理
@@ -27,8 +29,12 @@ import java.util.function.Function;
@Slf4j
public class InitialMountPointInfoServiceImpl implements IInitialMountPointInfoService
{
private static final String TABLE_PREFIX = "initial_mount_point_info";
@Autowired
private InitialMountPointInfoMapper initialMountPointInfoMapper;
@Autowired
private IAllMountNameService allMountNameService;
/**
* 查询挂载点监控信息
@@ -111,17 +117,73 @@ public class InitialMountPointInfoServiceImpl implements IInitialMountPointInfoS
*/
@Override
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
public int batchInsertInitialMountPointInfo(List<InitialMountPointInfo> list) {
public int batchInsertInitialMountPointInfo(List<InitialMountPointInfo> list, Date createTime) {
try {
return initialMountPointInfoMapper.batchInsertInitialMountPointInfo(list);
// 按表名分组批量插入
Map<String, List<InitialMountPointInfo>> groupedData = list.stream()
.map(data -> {
try {
InitialMountPointInfo processed = new InitialMountPointInfo();
BeanUtils.copyProperties(data,processed);
if (data.getCreateTime() == null) {
data.setCreateTime(DateUtils.getNowDate());
}
processed.setTableName(TableSubUtil.getTableName(createTime, TABLE_PREFIX));
return processed;
} catch (Exception e){
log.error("数据处理失败",e.getMessage());
return null;
}
}).collect(Collectors.groupingBy(
InitialMountPointInfo::getTableName,
LinkedHashMap::new, // 保持插入顺序
Collectors.toList()));
groupedData.forEach((tableName, dataList) -> {
try {
InitialMountPointInfo data = new InitialMountPointInfo();
data.setTableName(tableName);
data.setList(dataList);
initialMountPointInfoMapper.batchInsertInitialMountPointInfo(data);
// 记录挂载点路径名称
allMountNameService.batchInsertAllMount(dataList);
} catch (Exception e) {
log.error("表{}插入失败", tableName, e);
throw new RuntimeException("批量插入失败", e);
}
});
return 1;
}catch (Exception e){
log.error("批量插入挂载点信息失败,失败数量:{}", list.size(), e);
throw new RuntimeException("批量保存失败",e);
}
}
/**
* 分表查询硬盘信息
* @param queryParam
* @return
*/
public List<InitialMountPointInfo> getMountPointInfoSharding(InitialMountPointInfo queryParam) {
// 获取涉及的表名
Set<String> tableNames = TableSubUtil.getExistingTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime(), TABLE_PREFIX);
// 并行查询各表
return tableNames.parallelStream()
.flatMap(tableName -> {
InitialMountPointInfo condition = new InitialMountPointInfo();
condition.setTableName(tableName);
condition.setClientId(queryParam.getClientId());
condition.setMount(queryParam.getMount());
condition.setStartTime(queryParam.getStartTime());
condition.setEndTime(queryParam.getEndTime());
return initialMountPointInfoMapper.selectInitialMountPointInfoListByCondition(condition).stream();
})
.collect(Collectors.toList());
}
@Override
public InitialMountPointInfo pointDetailsMsg(InitialMountPointInfo initialMountPointInfo) {
String tableName = TableSubUtil.getTableName(DateUtils.getNowDate(), TABLE_PREFIX);
initialMountPointInfo.setTableName(tableName);
return initialMountPointInfoMapper.pointDetailsMsg(initialMountPointInfo);
}
@@ -132,7 +194,7 @@ public class InitialMountPointInfoServiceImpl implements IInitialMountPointInfoS
*/
@Override
public Map<String, Object> spaceEcharts(InitialMountPointInfo initialMountPointInfo) {
List<InitialMountPointInfo> list = initialMountPointInfoMapper.selectInitialMountPointInfoList(initialMountPointInfo);
List<InitialMountPointInfo> list = getMountPointInfoSharding(initialMountPointInfo);
Map<String, Function<InitialMountPointInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("vfsFreeData", info -> UnitChangeUtil.bytesToGb(info.getVfsFree()));
extractors.put("vfsTotalData", info -> UnitChangeUtil.bytesToGb(info.getVfsTotal()));
@@ -146,7 +208,7 @@ public class InitialMountPointInfoServiceImpl implements IInitialMountPointInfoS
*/
@Override
public Map<String, Object> spaceRateEcharts(InitialMountPointInfo initialMountPointInfo) {
List<InitialMountPointInfo> list = initialMountPointInfoMapper.selectInitialMountPointInfoList(initialMountPointInfo);
List<InitialMountPointInfo> list = getMountPointInfoSharding(initialMountPointInfo);
Map<String, Function<InitialMountPointInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("vfsUtilData", InitialMountPointInfo::getVfsUtil);
extractors.put("usedData", info -> {
@@ -2,6 +2,7 @@ package com.tongran.rocketmq.service.impl;
import com.tongran.common.core.utils.DateUtils;
import com.tongran.common.core.utils.EchartsDataUtils;
import com.tongran.common.core.utils.TableSubUtil;
import com.tongran.rocketmq.domain.InitialCpuInfo;
import com.tongran.rocketmq.domain.InitialMemoryInfo;
import com.tongran.rocketmq.domain.InitialSystemInfo;
@@ -168,7 +169,8 @@ public class InitialSystemInfoServiceImpl implements IInitialSystemInfoService
// 获取总内存信息
InitialMemoryInfo memoryInfo = initialMemoryInfoMapper.getMemoryInfoByClientId(initialSystemInfo.getClientId());
// 获取cpu数量
InitialCpuInfo cpuInfo = initialCpuInfoMapper.getCpuInfoByClientId(initialSystemInfo.getClientId());
String cpuTbaleName = TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_cpu_info");
InitialCpuInfo cpuInfo = initialCpuInfoMapper.getCpuInfoByClientId(initialSystemInfo.getClientId(), cpuTbaleName);
// 获取系统信息
SystemMsgVo systemMsgVo = initialSystemInfoMapper.getSystemMsgByClientId(initialSystemInfo.getClientId());
systemMsgVo.setNum(cpuInfo.getNum());
@@ -136,7 +136,8 @@ public class InitialSystemOtherCollectDataServiceImpl implements IInitialSystemO
"0".equals(uptime) ? null : UnitChangeUtil.formatUptimeSeconds(Long.parseLong(uptime)));
}
// 获取cpu数量
InitialCpuInfo cpuInfo = initialCpuInfoMapper.getCpuInfoByClientId(initialSystemOtherCollectData.getClientId());
String cpuTbaleName = TableSubUtil.getTableName(DateUtils.getNowDate(), "initial_cpu_info");
InitialCpuInfo cpuInfo = initialCpuInfoMapper.getCpuInfoByClientId(initialSystemOtherCollectData.getClientId(), cpuTbaleName);
if (cpuInfo == null) {
cpuInfo = new InitialCpuInfo();
}
@@ -115,7 +115,7 @@
</foreach>
</delete>
<insert id="batchInsertAllDistName" parameterType="java.util.List">
insert IGNORE into all_disk_name
insert into all_disk_name
(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=",">
@@ -132,6 +132,8 @@
#{item.updateBy}
)
</foreach>
ON DUPLICATE KEY UPDATE
status = 1
</insert>
<select id="selectDiskInfoList" parameterType="AllDiskName" resultType="AllDiskName">
@@ -150,7 +152,8 @@
TRUNCATE(IFNULL(b.write_speed,0)/(1024*1024), 0) as writeSpeed,
TRUNCATE(IFNULL(b.read_speed,0)/(1024*1024), 0) as readSpeed,
b.type,
TRUNCATE(IFNULL(b.used_space,0)/(1024 * 1024 * 1024), 0) as usedSpace
TRUNCATE(IFNULL(b.used_space,0)/(1024 * 1024 * 1024), 0) as usedSpace,
b.health_status as healthStatus
FROM all_disk_name a
LEFT JOIN (
SELECT client_id, name, MAX(create_time) as max_create_time
@@ -0,0 +1,92 @@
<?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">
<mapper namespace="com.tongran.rocketmq.mapper.AllDockerNameMapper">
<resultMap type="AllDockerName" id="AllDockerNameResult">
<result property="id" column="id" />
<result property="clientId" column="client_id" />
<result property="dockerId" column="docker_id" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectAllDockerNameVo">
select id, client_id, docker_id, create_time, update_time, create_by, update_by from all_docker_name
</sql>
<select id="selectAllDockerNameList" parameterType="AllDockerName" resultMap="AllDockerNameResult">
<include refid="selectAllDockerNameVo"/>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="dockerId != null and dockerId != ''"> and docker_id = #{dockerId}</if>
</where>
</select>
<select id="selectAllDockerNameById" parameterType="Long" resultMap="AllDockerNameResult">
<include refid="selectAllDockerNameVo"/>
where id = #{id}
</select>
<insert id="insertAllDockerName" parameterType="AllDockerName" useGeneratedKeys="true" keyProperty="id">
insert into all_docker_name
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="clientId != null">client_id,</if>
<if test="dockerId != null">docker_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null">#{clientId},</if>
<if test="dockerId != null">#{dockerId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateAllDockerName" parameterType="AllDockerName">
update all_docker_name
<trim prefix="SET" suffixOverrides=",">
<if test="clientId != null">client_id = #{clientId},</if>
<if test="dockerId != null">docker_id = #{dockerId},</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>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAllDockerNameById" parameterType="Long">
delete from all_docker_name where id = #{id}
</delete>
<delete id="deleteAllDockerNameByIds" parameterType="String">
delete from all_docker_name where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsertAllDockerId" parameterType="java.util.List">
insert IGNORE into all_docker_name
(client_id, docker_id, create_time, update_time, create_by, update_by)
values
<foreach collection="list" item="item" separator=",">
(
#{item.clientId},
#{item.dockerId},
#{item.createTime},
#{item.updateTime},
#{item.createBy},
#{item.updateBy}
)
</foreach>
</insert>
</mapper>
@@ -0,0 +1,92 @@
<?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">
<mapper namespace="com.tongran.rocketmq.mapper.AllMountNameMapper">
<resultMap type="AllMountName" id="AllMountNameResult">
<result property="id" column="id" />
<result property="clientId" column="client_id" />
<result property="mount" column="mount" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
</resultMap>
<sql id="selectAllMountNameVo">
select id, client_id, mount, create_time, update_time, create_by, update_by from all_mount_name
</sql>
<select id="selectAllMountNameList" parameterType="AllMountName" resultMap="AllMountNameResult">
<include refid="selectAllMountNameVo"/>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="mount != null and mount != ''"> and mount = #{mount}</if>
</where>
</select>
<select id="selectAllMountNameById" parameterType="Long" resultMap="AllMountNameResult">
<include refid="selectAllMountNameVo"/>
where id = #{id}
</select>
<insert id="insertAllMountName" parameterType="AllMountName" useGeneratedKeys="true" keyProperty="id">
insert into all_mount_name
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="clientId != null">client_id,</if>
<if test="mount != null">mount,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null">#{clientId},</if>
<if test="mount != null">#{mount},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
</trim>
</insert>
<update id="updateAllMountName" parameterType="AllMountName">
update all_mount_name
<trim prefix="SET" suffixOverrides=",">
<if test="clientId != null">client_id = #{clientId},</if>
<if test="mount != null">mount = #{mount},</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>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAllMountNameById" parameterType="Long">
delete from all_mount_name where id = #{id}
</delete>
<delete id="deleteAllMountNameByIds" parameterType="String">
delete from all_mount_name where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsertAllMount" parameterType="java.util.List">
insert IGNORE into all_mount_name
(client_id, mount, create_time, update_time, create_by, update_by)
values
<foreach collection="list" item="item" separator=",">
(
#{item.clientId},
#{item.mount},
#{item.createTime},
#{item.updateTime},
#{item.createBy},
#{item.updateBy}
)
</foreach>
</insert>
</mapper>
@@ -155,8 +155,8 @@
</foreach>
</delete>
<insert id="batchInsertInitialCpuInfo" parameterType="java.util.List">
INSERT IGNORE INTO initial_cpu_info
<insert id="batchInsertInitialCpuInfo" parameterType="InitialCpuInfo">
INSERT IGNORE INTO ${tableName}
(
client_id,
avg1,
@@ -218,10 +218,45 @@
</foreach>
</insert>
<select id="getCpuInfoByClientId" parameterType="String" resultMap="InitialCpuInfoResult">
<include refid="selectInitialCpuInfoVo"/>
<select id="getCpuInfoByClientId" resultMap="InitialCpuInfoResult">
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 ${tableName}
where client_id = #{clientId}
order by create_time desc
limit 1
</select>
<select id="selectInitialCpuInfoListByCondition" parameterType="InitialCpuInfo" resultMap="InitialCpuInfoResult">
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 ${tableName}
<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 &gt;= #{startTime}</if>
<if test="endTime != null and endTime != ''"> and create_time &lt;= #{endTime}</if>
</where>
order by create_time desc
</select>
</mapper>
@@ -19,6 +19,7 @@
<!-- 新增的两个字段 -->
<result property="type" column="type" />
<result property="usedSpace" column="used_space" />
<result property="healthStatus" column="health_status" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="createTime" column="create_time" />
@@ -42,7 +43,7 @@
</select>
<select id="selectInitialDiskInfoListByCondition" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
select id, client_id, name, serial, total, write_speed, read_speed, write_times, read_times, write_bytes,
read_bytes, type, used_space, create_by, update_by, create_time, update_time
read_bytes, type, used_space,health_status, create_by, update_by, create_time, update_time
from ${tableName}
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
@@ -154,6 +155,7 @@
read_bytes,
type,
used_space,
health_status,
create_by,
update_by,
create_time,
@@ -175,6 +177,7 @@
#{item.readBytes},
#{item.type},
#{item.usedSpace},
#{item.healthStatus},
#{item.createBy},
#{item.updateBy},
<choose>
@@ -199,7 +202,7 @@
<select id="getDistDetailsMsgByClientId" parameterType="InitialDiskInfo" resultMap="InitialDiskInfoResult">
select id, client_id, name, serial, total, write_speed, read_speed, write_times, read_times, write_bytes,
read_bytes, type, used_space, create_by, update_by, create_time, update_time
read_bytes, type, used_space,health_status, create_by, update_by, create_time, update_time
from ${tableName}
where client_id = #{clientId} and `name`= #{name}
order by create_time desc
@@ -102,8 +102,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<insert id="batchInsertInitialDockerInfo" parameterType="java.util.List">
INSERT IGNORE INTO initial_docker_info
<insert id="batchInsertInitialDockerInfo" parameterType="InitialDockerInfo">
INSERT IGNORE INTO ${tableName}
(
`id`,
`name`,
@@ -152,16 +152,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<select id="getDockerDetailsMsg" parameterType="InitialDockerInfo" resultMap="InitialDockerInfoResult">
<include refid="selectInitialDockerInfoVo"/>
select auto_id, id, name, status, cpu_util, mem_util, net_in_speed, net_out_speed, client_id, create_time, update_time, create_by, update_by from ${tableName}
where client_id = #{clientId} and `id` = #{id}
order by create_time desc
limit 1
</select>
<select id="getAllDockerId" parameterType="String" resultType="java.util.Map">
select id from initial_docker_info
select docker_id id from all_docker_name
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
</where>
group by id
</select>
<select id="selectInitialDockerInfoListByCondition" parameterType="InitialDockerInfo" resultMap="InitialDockerInfoResult">
select auto_id, id, name, status, cpu_util, mem_util, net_in_speed, net_out_speed, client_id, create_time, update_time, create_by, update_by from ${tableName}
<where>
<if test="id != null"> and id = #{id}</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="startTime != null and startTime != ''"> and create_time &gt;= #{startTime}</if>
<if test="endTime != null and endTime != ''"> and create_time &lt;= #{endTime}</if>
</where>
order by create_time desc
</select>
</mapper>
@@ -94,8 +94,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<insert id="batchInsertInitialMountPointInfo" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
INSERT IGNORE INTO initial_mount_point_info
<insert id="batchInsertInitialMountPointInfo" parameterType="java.util.List">
INSERT IGNORE INTO ${tableName}
(
client_id,
mount,
@@ -140,7 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<select id="pointDetailsMsg" parameterType="InitialMountPointInfo" resultMap="InitialMountPointInfoResult">
<include refid="selectInitialMountPointInfoVo"/>
select id, client_id, mount, vfs_type, vfs_free, vfs_total, vfs_util, create_by, update_by, create_time, update_time from ${tableName}
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="mount != null and mount != ''"> and mount = #{mount}</if>
@@ -149,10 +149,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
limit 1
</select>
<select id="getAllMountName" parameterType="String" resultType="java.util.Map">
select mount from initial_mount_point_info
select mount from all_mount_name
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
</where>
group by mount
</select>
<select id="selectInitialMountPointInfoListByCondition" parameterType="InitialMountPointInfo" resultMap="InitialMountPointInfoResult">
select id, client_id, mount, vfs_type, vfs_free, vfs_total, vfs_util, create_by, update_by, create_time, update_time from ${tableName}
<where>
<if test="mount != null and mount != ''"> and mount = #{mount}</if>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="startTime != null and startTime != ''"> and create_time &gt;= #{startTime}</if>
<if test="endTime != null and endTime != ''"> and create_time &lt;= #{endTime}</if>
</where>
order by create_time desc
</select>
</mapper>