diff --git a/pom.xml b/pom.xml index 65a95f9..d947f0c 100644 --- a/pom.xml +++ b/pom.xml @@ -260,6 +260,7 @@ ruoyi-gateway ruoyi-visual ruoyi-modules + ruoyi-rocketmq ruoyi-api ruoyi-common diff --git a/ruoyi-api/ruoyi-api-system/pom.xml b/ruoyi-api/ruoyi-api-system/pom.xml index 492e0e1..fb1f549 100644 --- a/ruoyi-api/ruoyi-api-system/pom.xml +++ b/ruoyi-api/ruoyi-api-system/pom.xml @@ -22,7 +22,11 @@ com.ruoyi ruoyi-common-core - + + org.projectlombok + lombok + + \ No newline at end of file diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteUserService.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteUserService.java index 95cb91d..7b4dd0e 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteUserService.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteUserService.java @@ -1,18 +1,15 @@ package com.ruoyi.system.api; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; import com.ruoyi.common.core.constant.SecurityConstants; import com.ruoyi.common.core.constant.ServiceNameConstants; import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.api.domain.EpsInitialTrafficDataRemote; +import com.ruoyi.system.api.domain.NodeBandwidth; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.factory.RemoteUserFallbackFactory; import com.ruoyi.system.api.model.LoginUser; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; /** * 用户服务 @@ -51,4 +48,35 @@ public interface RemoteUserService */ @PutMapping("/user/recordlogin") public R recordUserLogin(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + /** + * @param nodeBandwidth 服务器带宽收益 + * @param source 请求来源 + * @return 结果 + */ + @PostMapping("/bandwidth/list") + public R getBandwidth(@RequestBody NodeBandwidth nodeBandwidth, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** + * @param nodeBandwidth 服务器带宽收益 + * @param source 请求来源 + * @return 结果 + */ + @PostMapping("/bandwidth") + public R saveBandwidth(@RequestBody NodeBandwidth nodeBandwidth, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + /** + * 查询流量数据(POST方式) + * @param queryParam 查询参数实体 + * source 请求来源 + * @return 流量数据列表 + */ + @PostMapping("/query") + public R query(@RequestBody EpsInitialTrafficDataRemote queryParam, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + /** + * 批量保存流量数据 + * @param queryParam 流量数据列表 + * @return 操作结果 + */ + @PostMapping("/batch") + public R batchInitialTraffic(@RequestBody EpsInitialTrafficDataRemote queryParam, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + } diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/EpsInitialTrafficDataRemote.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/EpsInitialTrafficDataRemote.java new file mode 100644 index 0000000..d124a90 --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/EpsInitialTrafficDataRemote.java @@ -0,0 +1,109 @@ +package com.ruoyi.system.api.domain; + +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.LinkedHashSet; +import java.util.Set; + +/** + * EPS初始流量数据实体类 + * 用于存储设备的接收和发送流量数据 + * 支持按时间自动分表存储(每月分成3个表) + */ +@Data +public class EpsInitialTrafficDataRemote { + /** 主键ID */ + private Long id; + + /** + * 动态表名 + * 格式:eps_traffic_[年]_[月]_[日期范围] + * 示例:eps_traffic_2023_08_1_10 + */ + private String tableName; + + /** 流量统计开始时间 */ + private LocalDateTime startTime; + + /** 流量统计结束时间 */ + private LocalDateTime endTime; + + /** 接收流量(单位:MB) */ + private Double receiveTraffic; + + /** 发送流量(单位:MB) */ + private Double sendTraffic; + + /** 设备序列号 */ + private String deviceSn; + + /** 数据创建时间 */ + private LocalDateTime createTime; + + /** 备用字段1 */ + private String remark1; + + /** 备用字段2 */ + private String remark2; + + /** 备用字段3 */ + private String remark3; + + /** 备用字段4 */ + private String remark4; + + /** + * 根据createTime自动计算表名 + * 分表规则:每月分成3个表(1-10日、11-20日、21-31日) + */ + public void calculateTableName() { + if (this.createTime != null) { + int year = createTime.getYear(); + int month = createTime.getMonthValue(); + int day = createTime.getDayOfMonth(); + + String range; + if (day <= 10) { + range = "1_10"; + } else if (day <= 20) { + range = "11_20"; + } else { + range = "21_31"; + } + + this.tableName = String.format("eps_traffic_%d_%02d_%s", year, month, range); + } + } + + /** + * 获取时间范围内涉及的所有表名 + * @param start 开始时间 + * @param end 结束时间 + * @return 涉及的动态表名集合 + */ + public static Set getAffectedTables(LocalDateTime start, LocalDateTime end) { + Set tables = new LinkedHashSet<>(); + LocalDateTime current = start; + + while (!current.isAfter(end)) { + int year = current.getYear(); + int month = current.getMonthValue(); + int day = current.getDayOfMonth(); + + String range; + if (day <= 10) { + range = "1_10"; + } else if (day <= 20) { + range = "11_20"; + } else { + range = "21_31"; + } + + tables.add(String.format("eps_traffic_%d_%02d_%s", year, month, range)); + current = current.plusDays(1); + } + + return tables; + } +} \ No newline at end of file diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/NodeBandwidth.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/NodeBandwidth.java new file mode 100644 index 0000000..081a1ef --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/NodeBandwidth.java @@ -0,0 +1,236 @@ +package com.ruoyi.system.api.domain; + +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; + +/** + * 节点带宽信息对象 eps_node_bandwidth + * + * @author gyt + * @date 2025-08-12 + */ +public class NodeBandwidth extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 节点名称 */ + @Excel(name = "节点名称") + private String nodeName; + + /** 硬件SN */ + @Excel(name = "硬件SN") + private String hardwareSn; + + /** 95带宽值Mbps/日 */ + @Excel(name = "95带宽值Mbps/日") + private BigDecimal bandwidth95Daily; + + /** 95带宽值Mbps/月 */ + @Excel(name = "95带宽值Mbps/月") + private BigDecimal bandwidth95Monthly; + + /** 包端带宽值Mbps/日 */ + @Excel(name = "包端带宽值Mbps/日") + private BigDecimal packageBandwidthDaily; + + /** 设备业务客户id */ + @Excel(name = "设备业务客户id") + private String customerId; + + /** 设备业务客户名称 */ + @Excel(name = "设备业务客户名称") + private String customerName; + + /** 业务号 */ + @Excel(name = "业务号") + private String serviceNumber; + + /** 上联交换机 */ + @Excel(name = "上联交换机") + private String uplinkSwitch; + + /** 创建人id */ + @Excel(name = "创建人id") + private Long creatorId; + + /** 创建人名称 */ + @Excel(name = "创建人名称") + private String creatorName; + + /** remark1 */ + @Excel(name = "remark1") + private String remark1; + + /** remark2 */ + @Excel(name = "remark2") + private String remark2; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setNodeName(String nodeName) + { + this.nodeName = nodeName; + } + + public String getNodeName() + { + return nodeName; + } + + public void setHardwareSn(String hardwareSn) + { + this.hardwareSn = hardwareSn; + } + + public String getHardwareSn() + { + return hardwareSn; + } + + public void setBandwidth95Daily(BigDecimal bandwidth95Daily) + { + this.bandwidth95Daily = bandwidth95Daily; + } + + public BigDecimal getBandwidth95Daily() + { + return bandwidth95Daily; + } + + public void setBandwidth95Monthly(BigDecimal bandwidth95Monthly) + { + this.bandwidth95Monthly = bandwidth95Monthly; + } + + public BigDecimal getBandwidth95Monthly() + { + return bandwidth95Monthly; + } + + public void setPackageBandwidthDaily(BigDecimal packageBandwidthDaily) + { + this.packageBandwidthDaily = packageBandwidthDaily; + } + + public BigDecimal getPackageBandwidthDaily() + { + return packageBandwidthDaily; + } + + public void setCustomerId(String customerId) + { + this.customerId = customerId; + } + + public String getCustomerId() + { + return customerId; + } + + public void setCustomerName(String customerName) + { + this.customerName = customerName; + } + + public String getCustomerName() + { + return customerName; + } + + public void setServiceNumber(String serviceNumber) + { + this.serviceNumber = serviceNumber; + } + + public String getServiceNumber() + { + return serviceNumber; + } + + public void setUplinkSwitch(String uplinkSwitch) + { + this.uplinkSwitch = uplinkSwitch; + } + + public String getUplinkSwitch() + { + return uplinkSwitch; + } + + public void setCreatorId(Long creatorId) + { + this.creatorId = creatorId; + } + + public Long getCreatorId() + { + return creatorId; + } + + public void setCreatorName(String creatorName) + { + this.creatorName = creatorName; + } + + public String getCreatorName() + { + return creatorName; + } + + public void setRemark1(String remark1) + { + this.remark1 = remark1; + } + + public String getRemark1() + { + return remark1; + } + + public void setRemark2(String remark2) + { + this.remark2 = remark2; + } + + public String getRemark2() + { + return remark2; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("nodeName", getNodeName()) + .append("hardwareSn", getHardwareSn()) + .append("bandwidth95Daily", getBandwidth95Daily()) + .append("bandwidth95Monthly", getBandwidth95Monthly()) + .append("packageBandwidthDaily", getPackageBandwidthDaily()) + .append("customerId", getCustomerId()) + .append("customerName", getCustomerName()) + .append("serviceNumber", getServiceNumber()) + .append("uplinkSwitch", getUplinkSwitch()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .append("creatorId", getCreatorId()) + .append("creatorName", getCreatorName()) + .append("remark1", getRemark1()) + .append("remark2", getRemark2()) + .toString(); + } +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java index 5972b3f..f196f41 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java @@ -1,13 +1,15 @@ package com.ruoyi.system.api.factory; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.api.RemoteUserService; +import com.ruoyi.system.api.domain.EpsInitialTrafficDataRemote; +import com.ruoyi.system.api.domain.NodeBandwidth; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.model.LoginUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.stereotype.Component; -import com.ruoyi.common.core.domain.R; -import com.ruoyi.system.api.RemoteUserService; -import com.ruoyi.system.api.domain.SysUser; -import com.ruoyi.system.api.model.LoginUser; /** * 用户服务降级处理 @@ -42,6 +44,25 @@ public class RemoteUserFallbackFactory implements FallbackFactory getBandwidth(NodeBandwidth nodeBandwidth, String source) { + return R.fail("获取服务器带宽失败:" + throwable.getMessage()); + } + + @Override + public R saveBandwidth(NodeBandwidth nodeBandwidth, String source) { + return R.fail("新增服务器带宽失败:" + throwable.getMessage()); + } + + @Override + public R query(EpsInitialTrafficDataRemote queryParam, String source) { + return R.fail("获取初始流量数据失败:" + throwable.getMessage()); + } + @Override + public R batchInitialTraffic(EpsInitialTrafficDataRemote queryParam, String source) { + return R.fail("新增初始流量数据失败:" + throwable.getMessage()); + } }; } } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/PageUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/PageUtils.java index 95ee25b..d58a216 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/PageUtils.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/PageUtils.java @@ -32,4 +32,23 @@ public class PageUtils extends PageHelper { PageHelper.clearPage(); } + + /** + * post传参分页 + * @param pageDomain + */ + public static void startPage(PageDomain pageDomain) + { + if(pageDomain.getPageNum() == null) { + pageDomain.setPageNum(1); + } + if(pageDomain.getPageSize() == null) { + pageDomain.setPageSize(10); + } + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); + Boolean reasonable = pageDomain.getReasonable(); + PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable); + } } diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/controller/BaseController.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/controller/BaseController.java index cb3c580..f8afe4c 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/controller/BaseController.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/controller/BaseController.java @@ -1,12 +1,5 @@ package com.ruoyi.common.core.web.controller; -import java.beans.PropertyEditorSupport; -import java.util.Date; -import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.InitBinder; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.ruoyi.common.core.constant.HttpStatus; @@ -18,6 +11,14 @@ import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.page.PageDomain; import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.core.web.page.TableSupport; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.InitBinder; + +import java.beans.PropertyEditorSupport; +import java.util.Date; +import java.util.List; /** * web层通用数据处理 @@ -52,6 +53,14 @@ public class BaseController { PageUtils.startPage(); } + /** + * 设置请求分页数据 + * @param pageDomain + */ + protected void startPage(PageDomain pageDomain) + { + PageUtils.startPage(pageDomain); + } /** * 设置请求排序数据 diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java index eb9f783..4e6e8fc 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/web/domain/BaseEntity.java @@ -1,12 +1,13 @@ package com.ruoyi.common.core.web.domain; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; + import java.io.Serializable; import java.util.Date; import java.util.HashMap; import java.util.Map; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; /** * Entity基类 @@ -38,10 +39,28 @@ public class BaseEntity implements Serializable /** 备注 */ private String remark; + /** 当前记录起始索引 */ + private Integer pageNum; + + /** 每页显示记录数 */ + private Integer pageSize; + /** + * 选中的属性名称 + */ + private String[] properties; + /** 请求参数 */ @JsonInclude(JsonInclude.Include.NON_EMPTY) private Map params; + public String[] getProperties() { + return properties; + } + + public void setProperties(String[] properties) { + this.properties = properties; + } + public String getSearchValue() { return searchValue; @@ -102,6 +121,22 @@ public class BaseEntity implements Serializable this.remark = remark; } + public Integer getPageNum() { + return pageNum; + } + + public void setPageNum(Integer pageNum) { + this.pageNum = pageNum; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + public Map getParams() { if (params == null) diff --git a/ruoyi-modules/ruoyi-system/pom.xml b/ruoyi-modules/ruoyi-system/pom.xml index a3ae742..09f9447 100644 --- a/ruoyi-modules/ruoyi-system/pom.xml +++ b/ruoyi-modules/ruoyi-system/pom.xml @@ -70,6 +70,10 @@ com.ruoyi ruoyi-common-swagger + + org.projectlombok + lombok + diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/TableScheduleConfig.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/TableScheduleConfig.java new file mode 100644 index 0000000..51392fd --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/TableScheduleConfig.java @@ -0,0 +1,25 @@ +package com.ruoyi.system.config; + +import com.ruoyi.system.service.EpsInitialTrafficDataService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; + +/** + * 自动生成数据表 + */ +@Configuration +@EnableScheduling +public class TableScheduleConfig { + + @Autowired + private EpsInitialTrafficDataService epsInitialTrafficDataService; + + // 每月25号创建下月表 + @Scheduled(cron = "0 0 0 25 * ?") +// @Scheduled(initialDelay = 5000, fixedDelay = Long.MAX_VALUE) + public void createNextMonthTables() { + epsInitialTrafficDataService.createNextMonthTables(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsBusinessController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsBusinessController.java new file mode 100644 index 0000000..02bd5f2 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsBusinessController.java @@ -0,0 +1,142 @@ +package com.ruoyi.system.controller; + +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageDomain; +import com.ruoyi.common.core.web.page.TableDataInfo; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.system.domain.EpsBusiness; +import com.ruoyi.system.service.IEpsBusinessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Random; + +/** + * 业务信息Controller + * + * @author gyt + * @date 2025-08-18 + */ +@RestController +@RequestMapping("/business") +public class EpsBusinessController extends BaseController +{ + @Autowired + private IEpsBusinessService epsBusinessService; + + /** + * 查询业务信息列表 + */ + @RequiresPermissions("system:business:list") + @PostMapping("/list") + public TableDataInfo list(@RequestBody EpsBusiness epsBusiness) + { + PageDomain pageDomain = new PageDomain(); + pageDomain.setPageNum(epsBusiness.getPageNum()); + pageDomain.setPageSize(epsBusiness.getPageSize()); + startPage(pageDomain); + List list = epsBusinessService.selectEpsBusinessList(epsBusiness); + return getDataTable(list); + } + + /** + * 查询业务信息列表 + */ + @RequiresPermissions("system:business:list") + @PostMapping("/getAllBusinessMsg") + public AjaxResult getAllBusinessMsg(@RequestBody EpsBusiness epsBusiness) + { + List list = epsBusinessService.selectEpsBusinessList(epsBusiness); + return success(list); + } + + /** + * 导出业务信息列表 + */ + @RequiresPermissions("system:business:export") + @Log(title = "业务信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EpsBusiness epsBusiness) + { + List list = epsBusinessService.selectEpsBusinessList(epsBusiness); + ExcelUtil util = new ExcelUtil(EpsBusiness.class); + util.showColumn(epsBusiness.getProperties()); + util.exportExcel(response, list, "业务信息数据"); + } + + /** + * 获取业务信息详细信息 + */ + @RequiresPermissions("system:business:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return success(epsBusinessService.selectEpsBusinessById(id)); + } + + /** + * 新增业务信息 + */ + @RequiresPermissions("system:business:add") + @Log(title = "业务信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EpsBusiness epsBusiness) + { + int rows = epsBusinessService.insertEpsBusiness(epsBusiness); + if(-1==rows){ + return AjaxResult.error(500,"业务名称不可重复"); + } + return toAjax(rows); + } + + /** + * 修改业务信息 + */ + @RequiresPermissions("system:business:edit") + @Log(title = "业务信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EpsBusiness epsBusiness) + { + int rows = epsBusinessService.updateEpsBusiness(epsBusiness); + if(-1==rows){ + return AjaxResult.error(500,"业务名称不可重复"); + } + return toAjax(rows); + } + + + /** + * 生成12位唯一标识 + */ + @RequiresPermissions("system:business:list") + @GetMapping("/getBusinessCode") + public String getBusinessCode() + { + long timestamp = System.currentTimeMillis() / 100; // 取前10位(精确到0.1秒) + int random = new Random().nextInt(100); // 2位随机数(00~99) + return String.format("%010d%02d", timestamp, random); + } + /** + * 验证业务名称是否存在 + * @param epsBusiness + * @return + */ + @RequiresPermissions("system:business:list") + @PostMapping("/countByBusinessName") + public AjaxResult countByBusinessName(@RequestBody EpsBusiness epsBusiness) + { + int rows = epsBusinessService.countByBusinessName(epsBusiness); + if(rows>0){ + return AjaxResult.error(500,"业务名称不可重复"); + }else { + return AjaxResult.success("添加成功"); + } + } + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsInitialTrafficDataController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsInitialTrafficDataController.java new file mode 100644 index 0000000..78d3610 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsInitialTrafficDataController.java @@ -0,0 +1,56 @@ +package com.ruoyi.system.controller; + +import com.ruoyi.system.domain.EpsInitialTrafficData; +import com.ruoyi.system.service.EpsInitialTrafficDataService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * EPS初始流量数据控制器 + * 提供流量数据的REST接口 + */ +@RestController +@RequestMapping("/eps-traffic-data") +@RequiredArgsConstructor +public class EpsInitialTrafficDataController { + + private final EpsInitialTrafficDataService epsInitialTrafficDataService; + + /** + * 保存单条流量数据 + * @param data 流量数据实体 + * @return 操作结果 + */ + @PostMapping + public ResponseEntity save(@RequestBody EpsInitialTrafficData data) { + epsInitialTrafficDataService.save(data); + return ResponseEntity.ok().build(); + } + + /** + * 批量保存流量数据 + * @param dataList 流量数据表 + * @return 操作结果 + */ + @PostMapping("/batch") + public ResponseEntity saveBatch(@RequestBody EpsInitialTrafficData dataList) { + epsInitialTrafficDataService.saveBatch(dataList); + return ResponseEntity.ok().build(); + } + /** + * 查询流量数据(POST方式) + * @param queryParam 查询参数实体 + * @return 流量数据列表 + */ + @PostMapping("/query") + public ResponseEntity> query(@RequestBody EpsInitialTrafficData queryParam) { + List result = epsInitialTrafficDataService.query(queryParam); + return ResponseEntity.ok(result); + } +} \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsMethodChangeRecordController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsMethodChangeRecordController.java new file mode 100644 index 0000000..5ef9baa --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsMethodChangeRecordController.java @@ -0,0 +1,63 @@ +package com.ruoyi.system.controller; + +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.page.PageDomain; +import com.ruoyi.common.core.web.page.TableDataInfo; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.system.domain.EpsMethodChangeRecord; +import com.ruoyi.system.service.IEpsMethodChangeRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 收益方式修改记录Controller + * + * @author gyt + * @date 2025-08-19 + */ +@RestController +@RequestMapping("/record") +public class EpsMethodChangeRecordController extends BaseController +{ + @Autowired + private IEpsMethodChangeRecordService epsMethodChangeRecordService; + + /** + * 查询收益方式修改记录列表 + */ + @RequiresPermissions("system:record:list") + @PostMapping("/list") + public TableDataInfo list(@RequestBody EpsMethodChangeRecord epsMethodChangeRecord) + { + PageDomain pageDomain = new PageDomain(); + pageDomain.setPageNum(epsMethodChangeRecord.getPageNum()); + pageDomain.setPageSize(epsMethodChangeRecord.getPageSize()); + startPage(pageDomain); + List list = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(epsMethodChangeRecord); + return getDataTable(list); + } + + /** + * 导出收益方式修改记录列表 + */ + @RequiresPermissions("system:record:export") + @Log(title = "收益方式修改记录", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EpsMethodChangeRecord epsMethodChangeRecord) + { + List list = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(epsMethodChangeRecord); + ExcelUtil util = new ExcelUtil(EpsMethodChangeRecord.class); + util.showColumn(epsMethodChangeRecord.getProperties()); + util.exportExcel(response, list, "收益方式修改记录数据"); + } + +} \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsNodeBandwidthController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsNodeBandwidthController.java new file mode 100644 index 0000000..a9ffc8f --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsNodeBandwidthController.java @@ -0,0 +1,131 @@ +package com.ruoyi.system.controller; + +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageDomain; +import com.ruoyi.common.core.web.page.TableDataInfo; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.system.domain.EpsNodeBandwidth; +import com.ruoyi.system.service.IEpsNodeBandwidthService; +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 2025-08-12 + */ +@RestController +@RequestMapping("/bandwidth") +public class EpsNodeBandwidthController extends BaseController +{ + @Autowired + private IEpsNodeBandwidthService epsNodeBandwidthService; + + /** + * 查询节点带宽信息列表 + */ + @RequiresPermissions("system:bandwidth:list") + @PostMapping("/list") + public TableDataInfo list(@RequestBody EpsNodeBandwidth epsNodeBandwidth) + { + + PageDomain pageDomain = new PageDomain(); + pageDomain.setPageNum(epsNodeBandwidth.getPageNum()); + pageDomain.setPageSize(epsNodeBandwidth.getPageSize()); + startPage(pageDomain); + List list = epsNodeBandwidthService.selectEpsNodeBandwidthList(epsNodeBandwidth); + return getDataTable(list); + } + + /** + * 导出节点带宽信息列表 + */ + @RequiresPermissions("system:bandwidth:export") + @Log(title = "节点带宽信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EpsNodeBandwidth epsNodeBandwidth) + { + List list = epsNodeBandwidthService.selectEpsNodeBandwidthList(epsNodeBandwidth); + ExcelUtil util = new ExcelUtil(EpsNodeBandwidth.class); + util.showColumn(epsNodeBandwidth.getProperties()); + util.exportExcel(response, list, "节点带宽信息数据"); + } + + /** + * 获取节点带宽信息详细信息 + */ + @RequiresPermissions("system:bandwidth:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(epsNodeBandwidthService.selectEpsNodeBandwidthById(id)); + } + + /** + * 新增节点带宽信息 + */ + @RequiresPermissions("system:bandwidth:add") + @Log(title = "节点带宽信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EpsNodeBandwidth epsNodeBandwidth) + { + return toAjax(epsNodeBandwidthService.insertEpsNodeBandwidth(epsNodeBandwidth)); + } + + /** + * 修改节点带宽信息 + */ + @RequiresPermissions("system:bandwidth:edit") + @Log(title = "节点带宽信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EpsNodeBandwidth epsNodeBandwidth) + { + return toAjax(epsNodeBandwidthService.updateEpsNodeBandwidth(epsNodeBandwidth)); + } + /** + * 重新计算 + */ + @RequiresPermissions("system:bandwidth:query") + @GetMapping(value = "recalculate/{id}") + public AjaxResult recalculate(@PathVariable("id") Long id) + { + return success(epsNodeBandwidthService.selectEpsNodeBandwidthById(id));//TODO 待逻辑处理 + } + + /** + * 相关数据 + */ + @RequiresPermissions("system:bandwidth:query") + @GetMapping(value = "relatedData/{id}") + public AjaxResult relatedData(@PathVariable("id") Long id) + { + return success(epsNodeBandwidthService.relatedData(id)); + } + /** + * 相关数据-月均日95值 + */ + @RequiresPermissions("system:bandwidth:query") + @GetMapping(value = "getAvgDetailMsg/{id}") + public AjaxResult getAvgDetailMsg(@PathVariable("id") Long id) + { + return success(epsNodeBandwidthService.getAvgDetailMsg(id)); + } + /** + * 生成月均日95值 + */ + @RequiresPermissions("system:bandwidth:add") + @Log(title = "节点带宽信息", businessType = BusinessType.INSERT) + @PostMapping("/calculateAvg") + public AjaxResult calculateAvg(@RequestBody EpsNodeBandwidth epsNodeBandwidth) + { + return toAjax(epsNodeBandwidthService.insertEpsNodeBandwidth(epsNodeBandwidth)); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsServerRevenueConfigController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsServerRevenueConfigController.java new file mode 100644 index 0000000..0bf4359 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsServerRevenueConfigController.java @@ -0,0 +1,73 @@ +package com.ruoyi.system.controller; + +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageDomain; +import com.ruoyi.common.core.web.page.TableDataInfo; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.system.domain.EpsServerRevenueConfig; +import com.ruoyi.system.service.IEpsServerRevenueConfigService; +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 2025-08-19 + */ +@RestController +@RequestMapping("/revenueConfig") +public class EpsServerRevenueConfigController extends BaseController +{ + @Autowired + private IEpsServerRevenueConfigService epsServerRevenueConfigService; + + /** + * 查询服务器收益方式配置列表 + */ + @RequiresPermissions("system:config:list") + @PostMapping("/list") + public TableDataInfo list(EpsServerRevenueConfig epsServerRevenueConfig) + { + PageDomain pageDomain = new PageDomain(); + pageDomain.setPageNum(epsServerRevenueConfig.getPageNum()); + pageDomain.setPageSize(epsServerRevenueConfig.getPageSize()); + startPage(pageDomain); + List list = epsServerRevenueConfigService.selectEpsServerRevenueConfigList(epsServerRevenueConfig); + return getDataTable(list); + } + + /** + * 导出服务器收益方式配置列表 + */ + @RequiresPermissions("system:config:export") + @Log(title = "服务器收益方式配置", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EpsServerRevenueConfig epsServerRevenueConfig) + { + List list = epsServerRevenueConfigService.selectEpsServerRevenueConfigList(epsServerRevenueConfig); + ExcelUtil util = new ExcelUtil(EpsServerRevenueConfig.class); + util.showColumn(epsServerRevenueConfig.getProperties()); + util.exportExcel(response, list, "服务器收益方式配置数据"); + } + + + /** + * 修改服务器收益方式配置 + */ + @RequiresPermissions("system:config:edit") + @Log(title = "服务器收益方式配置", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EpsServerRevenueConfig epsServerRevenueConfig) + { + return toAjax(epsServerRevenueConfigService.updateEpsServerRevenueConfig(epsServerRevenueConfig)); + } + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsTrafficDataController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsTrafficDataController.java new file mode 100644 index 0000000..ac4a4bd --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/EpsTrafficDataController.java @@ -0,0 +1,105 @@ +package com.ruoyi.system.controller; + +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.system.domain.EpsTrafficData; +import com.ruoyi.system.service.IEpsTrafficDataService; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.page.TableDataInfo; + +/** + * 流量相关数据Controller + * + * @author gyt + * @date 2025-08-12 + */ +@RestController +@RequestMapping("/data") +public class EpsTrafficDataController extends BaseController +{ + @Autowired + private IEpsTrafficDataService epsTrafficDataService; + + /** + * 查询流量相关数据列表 + */ + @RequiresPermissions("system:data:list") + @GetMapping("/list") + public TableDataInfo list(EpsTrafficData epsTrafficData) + { + startPage(); + List list = epsTrafficDataService.selectEpsTrafficDataList(epsTrafficData); + return getDataTable(list); + } + + /** + * 导出流量相关数据列表 + */ + @RequiresPermissions("system:data:export") + @Log(title = "流量相关数据", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EpsTrafficData epsTrafficData) + { + List list = epsTrafficDataService.selectEpsTrafficDataList(epsTrafficData); + ExcelUtil util = new ExcelUtil(EpsTrafficData.class); + util.exportExcel(response, list, "流量相关数据数据"); + } + + /** + * 获取流量相关数据详细信息 + */ + @RequiresPermissions("system:data:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(epsTrafficDataService.selectEpsTrafficDataById(id)); + } + + /** + * 新增流量相关数据 + */ + @RequiresPermissions("system:data:add") + @Log(title = "流量相关数据", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EpsTrafficData epsTrafficData) + { + return toAjax(epsTrafficDataService.insertEpsTrafficData(epsTrafficData)); + } + + /** + * 修改流量相关数据 + */ + @RequiresPermissions("system:data:edit") + @Log(title = "流量相关数据", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EpsTrafficData epsTrafficData) + { + return toAjax(epsTrafficDataService.updateEpsTrafficData(epsTrafficData)); + } + + /** + * 删除流量相关数据 + */ + @RequiresPermissions("system:data:remove") + @Log(title = "流量相关数据", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(epsTrafficDataService.deleteEpsTrafficDataByIds(ids)); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/KnowledgeBaseController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/KnowledgeBaseController.java new file mode 100644 index 0000000..3b07131 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/KnowledgeBaseController.java @@ -0,0 +1,102 @@ +package com.ruoyi.system.controller; + +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageDomain; +import com.ruoyi.common.core.web.page.TableDataInfo; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.system.domain.KnowledgeBase; +import com.ruoyi.system.service.IKnowledgeBaseService; +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 2025-08-15 + */ +@RestController +@RequestMapping("/knowledgebase") +public class KnowledgeBaseController extends BaseController +{ + @Autowired + private IKnowledgeBaseService knowledgeBaseService; + + /** + * 查询知识库列表 + */ + @RequiresPermissions("system:knowledgebase:list") + @PostMapping("/list") + public TableDataInfo list(@RequestBody KnowledgeBase knowledgeBase) + { + PageDomain pageDomain = new PageDomain(); + pageDomain.setPageNum(knowledgeBase.getPageNum()); + pageDomain.setPageSize(knowledgeBase.getPageSize()); + startPage(pageDomain); + List list = knowledgeBaseService.selectKnowledgeBaseList(knowledgeBase); + return getDataTable(list); + } + + /** + * 导出知识库列表 + */ + @RequiresPermissions("system:knowledgebase:export") + @Log(title = "知识库", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, KnowledgeBase knowledgeBase) + { + List list = knowledgeBaseService.selectKnowledgeBaseList(knowledgeBase); + ExcelUtil util = new ExcelUtil(KnowledgeBase.class); + util.exportExcel(response, list, "知识库数据"); + } + + /** + * 获取知识库详细信息 + */ + @RequiresPermissions("system:knowledgebase:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(knowledgeBaseService.selectKnowledgeBaseById(id)); + } + + /** + * 新增知识库 + */ + @RequiresPermissions("system:knowledgebase:add") + @Log(title = "知识库", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody KnowledgeBase knowledgeBase) + { + return toAjax(knowledgeBaseService.insertKnowledgeBase(knowledgeBase)); + } + + /** + * 修改知识库 + */ + @RequiresPermissions("system:knowledgebase:edit") + @Log(title = "知识库", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody KnowledgeBase knowledgeBase) + { + return toAjax(knowledgeBaseService.updateKnowledgeBase(knowledgeBase)); + } + + /** + * 删除知识库 + */ + @RequiresPermissions("system:knowledgebase:remove") + @Log(title = "知识库", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(knowledgeBaseService.deleteKnowledgeBaseByIds(ids)); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/MtmMonitoringTemplateController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/MtmMonitoringTemplateController.java new file mode 100644 index 0000000..38f9aaa --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/MtmMonitoringTemplateController.java @@ -0,0 +1,105 @@ +package com.ruoyi.system.controller; + +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.system.domain.MtmMonitoringTemplate; +import com.ruoyi.system.service.IMtmMonitoringTemplateService; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.page.TableDataInfo; + +/** + * 监控模板管理Controller + * + * @author gyt + * @date 2025-08-12 + */ +@RestController +@RequestMapping("/template") +public class MtmMonitoringTemplateController extends BaseController +{ + @Autowired + private IMtmMonitoringTemplateService mtmMonitoringTemplateService; + + /** + * 查询监控模板管理列表 + */ + @RequiresPermissions("system:template:list") + @GetMapping("/list") + public TableDataInfo list(MtmMonitoringTemplate mtmMonitoringTemplate) + { + startPage(); + List list = mtmMonitoringTemplateService.selectMtmMonitoringTemplateList(mtmMonitoringTemplate); + return getDataTable(list); + } + + /** + * 导出监控模板管理列表 + */ + @RequiresPermissions("system:template:export") + @Log(title = "监控模板管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, MtmMonitoringTemplate mtmMonitoringTemplate) + { + List list = mtmMonitoringTemplateService.selectMtmMonitoringTemplateList(mtmMonitoringTemplate); + ExcelUtil util = new ExcelUtil(MtmMonitoringTemplate.class); + util.exportExcel(response, list, "监控模板管理数据"); + } + + /** + * 获取监控模板管理详细信息 + */ + @RequiresPermissions("system:template:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(mtmMonitoringTemplateService.selectMtmMonitoringTemplateById(id)); + } + + /** + * 新增监控模板管理 + */ + @RequiresPermissions("system:template:add") + @Log(title = "监控模板管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MtmMonitoringTemplate mtmMonitoringTemplate) + { + return toAjax(mtmMonitoringTemplateService.insertMtmMonitoringTemplate(mtmMonitoringTemplate)); + } + + /** + * 修改监控模板管理 + */ + @RequiresPermissions("system:template:edit") + @Log(title = "监控模板管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MtmMonitoringTemplate mtmMonitoringTemplate) + { + return toAjax(mtmMonitoringTemplateService.updateMtmMonitoringTemplate(mtmMonitoringTemplate)); + } + + /** + * 删除监控模板管理 + */ + @RequiresPermissions("system:template:remove") + @Log(title = "监控模板管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(mtmMonitoringTemplateService.deleteMtmMonitoringTemplateByIds(ids)); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/RmEpsTopologyManagementController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/RmEpsTopologyManagementController.java new file mode 100644 index 0000000..78944d4 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/RmEpsTopologyManagementController.java @@ -0,0 +1,113 @@ +package com.ruoyi.system.controller; + +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageDomain; +import com.ruoyi.common.core.web.page.TableDataInfo; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.system.domain.RmEpsTopologyManagement; +import com.ruoyi.system.service.IRmEpsTopologyManagementService; +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 2025-08-12 + */ +@RestController +@RequestMapping("/management") +public class RmEpsTopologyManagementController extends BaseController +{ + @Autowired + private IRmEpsTopologyManagementService rmEpsTopologyManagementService; + + /** + * 查询交换机/服务器名称 + */ + @RequiresPermissions("system:management:list") + @PostMapping ("/getNamesByResoureType") + public List getNamesByResoureType(@RequestBody RmEpsTopologyManagement rmEpsTopologyManagement) + { + List list = rmEpsTopologyManagementService.selectRmEpsTopologyManagementList(rmEpsTopologyManagement); + return list; + } + /** + * 查询拓扑管理列表 + */ + @RequiresPermissions("system:management:list") + @PostMapping("/list") + public TableDataInfo list(@RequestBody RmEpsTopologyManagement rmEpsTopologyManagement) + { + PageDomain pageDomain = new PageDomain(); + pageDomain.setPageNum(rmEpsTopologyManagement.getPageNum()); + pageDomain.setPageSize(rmEpsTopologyManagement.getPageSize()); + startPage(pageDomain); + List list = rmEpsTopologyManagementService.selectRmEpsTopologyManagementList(rmEpsTopologyManagement); + return getDataTable(list); + } + + /** + * 导出拓扑管理列表 + */ + @RequiresPermissions("system:management:export") + @Log(title = "拓扑管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, RmEpsTopologyManagement rmEpsTopologyManagement) + { + List list = rmEpsTopologyManagementService.selectRmEpsTopologyManagementList(rmEpsTopologyManagement); + ExcelUtil util = new ExcelUtil(RmEpsTopologyManagement.class); + util.showColumn(rmEpsTopologyManagement.getProperties()); + util.exportExcel(response, list, "拓扑管理数据"); + } + + /** + * 获取拓扑管理详细信息 + */ + @RequiresPermissions("system:management:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(rmEpsTopologyManagementService.selectRmEpsTopologyManagementById(id)); + } + + /** + * 新增拓扑管理 + */ + @RequiresPermissions("system:management:add") + @Log(title = "拓扑管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody RmEpsTopologyManagement rmEpsTopologyManagement) + { + return toAjax(rmEpsTopologyManagementService.insertRmEpsTopologyManagement(rmEpsTopologyManagement)); + } + + /** + * 修改拓扑管理 + */ + @RequiresPermissions("system:management:edit") + @Log(title = "拓扑管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody RmEpsTopologyManagement rmEpsTopologyManagement) + { + return toAjax(rmEpsTopologyManagementService.updateRmEpsTopologyManagement(rmEpsTopologyManagement)); + } + + /** + * 删除拓扑管理 + */ + @RequiresPermissions("system:management:remove") + @Log(title = "拓扑管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(rmEpsTopologyManagementService.deleteRmEpsTopologyManagementByIds(ids)); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/RmResourceGroupController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/RmResourceGroupController.java new file mode 100644 index 0000000..f8e428f --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/RmResourceGroupController.java @@ -0,0 +1,103 @@ +package com.ruoyi.system.controller; + +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageDomain; +import com.ruoyi.common.core.web.page.TableDataInfo; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.system.domain.RmResourceGroup; +import com.ruoyi.system.service.IRmResourceGroupService; +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 2025-08-12 + */ +@RestController +@RequestMapping("/group") +public class RmResourceGroupController extends BaseController +{ + @Autowired + private IRmResourceGroupService rmResourceGroupService; + + /** + * 查询资源分组列表 + */ + @RequiresPermissions("system:group:list") + @PostMapping("/list") + public TableDataInfo list(@RequestBody RmResourceGroup rmResourceGroup) + { + PageDomain pageDomain = new PageDomain(); + pageDomain.setPageNum(rmResourceGroup.getPageNum()); + pageDomain.setPageSize(rmResourceGroup.getPageSize()); + startPage(pageDomain); + List list = rmResourceGroupService.selectRmResourceGroupList(rmResourceGroup); + return getDataTable(list); + } + + /** + * 导出资源分组列表 + */ + @RequiresPermissions("system:group:export") + @Log(title = "资源分组", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, RmResourceGroup rmResourceGroup) + { + List list = rmResourceGroupService.selectRmResourceGroupList(rmResourceGroup); + ExcelUtil util = new ExcelUtil(RmResourceGroup.class); + util.showColumn(rmResourceGroup.getProperties()); + util.exportExcel(response, list, "资源分组数据"); + } + + /** + * 获取资源分组详细信息 + */ + @RequiresPermissions("system:group:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(rmResourceGroupService.selectRmResourceGroupById(id)); + } + + /** + * 新增资源分组 + */ + @RequiresPermissions("system:group:add") + @Log(title = "资源分组", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody RmResourceGroup rmResourceGroup) + { + return toAjax(rmResourceGroupService.insertRmResourceGroup(rmResourceGroup)); + } + + /** + * 修改资源分组 + */ + @RequiresPermissions("system:group:edit") + @Log(title = "资源分组", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody RmResourceGroup rmResourceGroup) + { + return toAjax(rmResourceGroupService.updateRmResourceGroup(rmResourceGroup)); + } + + /** + * 删除资源分组 + */ + @RequiresPermissions("system:group:remove") + @Log(title = "资源分组", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(rmResourceGroupService.deleteRmResourceGroupByIds(ids)); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/RmResourceRegistrationController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/RmResourceRegistrationController.java index e8e6349..8288f81 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/RmResourceRegistrationController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/RmResourceRegistrationController.java @@ -1,25 +1,21 @@ package com.ruoyi.system.controller; -import java.util.List; -import javax.servlet.http.HttpServletResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.web.page.PageDomain; +import com.ruoyi.common.core.web.page.TableDataInfo; import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.common.security.annotation.RequiresPermissions; import com.ruoyi.system.domain.RmResourceRegistration; import com.ruoyi.system.service.IRmResourceRegistrationService; -import com.ruoyi.common.core.web.controller.BaseController; -import com.ruoyi.common.core.web.domain.AjaxResult; -import com.ruoyi.common.core.utils.poi.ExcelUtil; -import com.ruoyi.common.core.web.page.TableDataInfo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; /** * 资源注册Controller @@ -38,10 +34,13 @@ public class RmResourceRegistrationController extends BaseController * 查询资源注册列表 */ @RequiresPermissions("system:registration:list") - @GetMapping("/list") - public TableDataInfo list(RmResourceRegistration rmResourceRegistration) + @PostMapping("/list") + public TableDataInfo list(@RequestBody RmResourceRegistration rmResourceRegistration) { - startPage(); + PageDomain pageDomain = new PageDomain(); + pageDomain.setPageNum(rmResourceRegistration.getPageNum()); + pageDomain.setPageSize(rmResourceRegistration.getPageSize()); + startPage(pageDomain); List list = rmResourceRegistrationService.selectRmResourceRegistrationList(rmResourceRegistration); return getDataTable(list); } @@ -55,7 +54,16 @@ public class RmResourceRegistrationController extends BaseController public void export(HttpServletResponse response, RmResourceRegistration rmResourceRegistration) { List list = rmResourceRegistrationService.selectRmResourceRegistrationList(rmResourceRegistration); + for (RmResourceRegistration resourceRegistration : list) { + // 根据端口类型导出端口名称 + if("1".equals(resourceRegistration.getResourcePort())){ + resourceRegistration.setResourcePort("162(SNMP)"); + }else{ + resourceRegistration.setResourcePort(resourceRegistration.getOtherPortName()); + } + } ExcelUtil util = new ExcelUtil(RmResourceRegistration.class); + util.showColumn(rmResourceRegistration.getProperties()); util.exportExcel(response, list, "资源注册数据"); } @@ -77,7 +85,11 @@ public class RmResourceRegistrationController extends BaseController @PostMapping public AjaxResult add(@RequestBody RmResourceRegistration rmResourceRegistration) { - return toAjax(rmResourceRegistrationService.insertRmResourceRegistration(rmResourceRegistration)); + int rows = rmResourceRegistrationService.insertRmResourceRegistration(rmResourceRegistration); + if(-1==rows){ + return AjaxResult.error(500,"硬件SN不可重复"); + } + return toAjax(rows); } /** @@ -92,13 +104,37 @@ public class RmResourceRegistrationController extends BaseController } /** - * 删除资源注册 + * 资源注册-注册 */ - @RequiresPermissions("system:registration:remove") - @Log(title = "资源注册", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) + @RequiresPermissions("system:registration:edit") + @Log(title = "资源注册-注册", businessType = BusinessType.UPDATE) + @PostMapping("/register") + public AjaxResult register(@RequestBody RmResourceRegistration rmResourceRegistration) { - return toAjax(rmResourceRegistrationService.deleteRmResourceRegistrationByIds(ids)); + return toAjax(rmResourceRegistrationService.register(rmResourceRegistration)); } + + /** + * 查询所有资源名称(包含设备使用) + * @return 资源注册集合 + */ + @RequiresPermissions("system:group:list") + @GetMapping("/selectAllResourceName") + public List selectAllResourceName() + { + List list = rmResourceRegistrationService.selectAllResourceName(); + return list; + } + /** + * 查询所有资源名称 + * @return 资源注册集合 + */ + @RequiresPermissions("system:group:list") + @PostMapping("/selectAllResourceNameByType") + public List selectAllResourceNameByType(@RequestBody RmResourceRegistration rmResourceRegistration) + { + List list = rmResourceRegistrationService.selectAllResourceNameByType(rmResourceRegistration); + return list; + } + } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsBusiness.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsBusiness.java new file mode 100644 index 0000000..490cd7c --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsBusiness.java @@ -0,0 +1,70 @@ +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 业务信息对象 eps_business + * + * @author gyt + * @date 2025-08-18 + */ +public class EpsBusiness extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 业务代码(12位唯一标识) */ + private String id; + + /** 业务名称 */ + @Excel(name = "业务名称") + private String businessName; + + /** 业务描述 */ + private String description; + + public void setId(String id) + { + this.id = id; + } + + public String getId() + { + return id; + } + + public void setBusinessName(String businessName) + { + this.businessName = businessName; + } + + public String getBusinessName() + { + return businessName; + } + + public void setDescription(String description) + { + this.description = description; + } + + public String getDescription() + { + return description; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("businessName", getBusinessName()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .append("createBy", getCreateBy()) + .append("updateBy", getUpdateBy()) + .append("description", getDescription()) + .toString(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsInitialTrafficData.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsInitialTrafficData.java new file mode 100644 index 0000000..685db36 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsInitialTrafficData.java @@ -0,0 +1,66 @@ +package com.ruoyi.system.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * EPS初始流量数据实体类 + * 用于存储设备的接收和发送流量数据 + * 支持按时间自动分表存储(每月分成3个表) + */ +@Data +public class EpsInitialTrafficData { + /** 主键ID */ + private Long id; + + /** + * 动态表名 + * 格式:eps_traffic_[年]_[月]_[日期范围] + * 示例:eps_traffic_2023_08_1_10 + */ + private String tableName; + + /** 流量统计开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime startTime; + + /** 流量统计结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime endTime; + + /** 接收流量(单位:MB) */ + private Double receiveTraffic; + + /** 发送流量(单位:MB) */ + private Double sendTraffic; + + /** 设备序列号 */ + private String deviceSn; + /** 流量端口 */ + private String trafficPort; + /** 业务代码 */ + private String businesId; + + /** 数据创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; + + /** 备用字段1 */ + private String remark1; + + /** 备用字段2 */ + private String remark2; + + /** 备用字段3 */ + private String remark3; + + /** 备用字段4 */ + private String remark4; + /** 批量插入集合 **/ + private List dataList; + + +} \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsMethodChangeRecord.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsMethodChangeRecord.java new file mode 100644 index 0000000..2411fde --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsMethodChangeRecord.java @@ -0,0 +1,100 @@ +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 收益方式修改记录对象 eps_method_change_record + * + * @author gyt + * @date 2025-08-15 + */ +public class EpsMethodChangeRecord extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 记录ID */ + private Long id; + + /** 节点名称 */ + @Excel(name = "节点名称") + private String nodeName; + + /** 修改内容 */ + @Excel(name = "修改内容") + private String changeContent; + + /** 硬件SN */ + @Excel(name = "硬件SN") + private String hardwareSn; + + /** 创建人 */ + @Excel(name = "修改人") + private String creatBy; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setNodeName(String nodeName) + { + this.nodeName = nodeName; + } + + public String getNodeName() + { + return nodeName; + } + + public void setChangeContent(String changeContent) + { + this.changeContent = changeContent; + } + + public String getChangeContent() + { + return changeContent; + } + + public void setHardwareSn(String hardwareSn) + { + this.hardwareSn = hardwareSn; + } + + public String getHardwareSn() + { + return hardwareSn; + } + + public void setCreatBy(String creatBy) + { + this.creatBy = creatBy; + } + + public String getCreatBy() + { + return creatBy; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("nodeName", getNodeName()) + .append("changeContent", getChangeContent()) + .append("hardwareSn", getHardwareSn()) + .append("createTime", getCreateTime()) + .append("creatBy", getCreatBy()) + .append("updateTime", getUpdateTime()) + .append("updateBy", getUpdateBy()) + .toString(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsNodeBandwidth.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsNodeBandwidth.java new file mode 100644 index 0000000..95b263e --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsNodeBandwidth.java @@ -0,0 +1,405 @@ +package com.ruoyi.system.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.Date; + +/** + * 节点带宽信息对象 eps_node_bandwidth + * + * @author gyt + * @date 2025-08-12 + */ +public class EpsNodeBandwidth extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 节点名称 */ + @Excel(name = "节点名称") + private String nodeName; + + /** 硬件SN */ + @Excel(name = "硬件SN") + private String hardwareSn; + /** 带宽值类型 + * 1-95带宽值Mbps/日 + * 2-95带宽值Mbps/月 + * 3-包端带宽值Mbps/日 + * 4-月均日95值Mbps + * 5-有效-95带宽值Mbps/日 + * 6-有效-95带宽值Mbps/月 + * 7-有效-月均日95值 + * */ + private String bandwidthType; + + /** 带宽值结果 */ + private BigDecimal bandwidthResult; + + /** 95带宽值Mbps/日 */ + @Excel(name = "95带宽值Mbps/日") + private BigDecimal bandwidth95Daily; + + /** 95带宽值Mbps/月 */ + @Excel(name = "95带宽值Mbps/月") + private BigDecimal bandwidth95Monthly; + + /** 月均日95值 */ + @Excel(name = "月均日95值") + private BigDecimal avgMonthlyBandwidth95; + + /** 包端带宽值Mbps/日 */ + @Excel(name = "包端带宽值Mbps/日") + private BigDecimal packageBandwidthDaily; + + /** 有效-95带宽值Mbps/日 */ + @Excel(name = "有效-95带宽值Mbps/日") + private BigDecimal effectiveBandwidth95Daily; + + /** 有效-95带宽值Mbps/月 */ + @Excel(name = "有效-95带宽值Mbps/月") + private BigDecimal effectiveBandwidth95Monthly; + + /** 有效-月均95值 */ + @Excel(name = "有效-月均95值") + private BigDecimal effectiveAvgMonthlyBandwidth95; + + /** 设备业务客户id */ + @Excel(name = "设备业务客户id") + private String customerId; + + /** 设备业务客户名称 */ + @Excel(name = "设备业务客户名称") + private String customerName; + + /** 业务号 */ + @Excel(name = "业务号") + private String serviceNumber; + + /** 上联交换机 */ + @Excel(name = "上联交换机") + private String uplinkSwitch; + + /** 创建人id */ + @Excel(name = "创建人id") + private Long creatorId; + + /** 创建人名称 */ + @Excel(name = "创建人名称") + private String creatorName; + + /** remark1 */ + @Excel(name = "remark1") + private String remark1; + + /** 接口名称 */ + @Excel(name = "接口名称") + private String interfaceName; + + /** 资源类型(1服务器,2交换机) */ + @Excel(name = "资源类型") + private String resourceType; + + /** 接口连接设备类型(1服务器,2机房出口) */ + @Excel(name = "接口连接设备类型") + private String interfaceLinkDeviceType; + /** 业务名称 */ + @Excel(name = "业务名称") + private String businessName; + + /** 业务代码 */ + @Excel(name = "业务代码") + private String businessId; + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + private Date createTime; + /** 开始时间 */ + private String startTime; + /** 结束时间 */ + private String endTime; + /** 月份 */ + @JsonFormat(pattern = "yyyy-MM") + private LocalDate monthTime; + + @Override + public Date getCreateTime() { + return createTime; + } + + @Override + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public LocalDate getMonthTime() { + return monthTime; + } + + public void setMonthTime(LocalDate monthTime) { + this.monthTime = monthTime; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + + public String getBusinessName() { + return businessName; + } + + public void setBusinessName(String businessName) { + this.businessName = businessName; + } + + public String getBusinessId() { + return businessId; + } + + public void setBusinessId(String businessId) { + this.businessId = businessId; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public String getInterfaceLinkDeviceType() { + return interfaceLinkDeviceType; + } + + public void setInterfaceLinkDeviceType(String interfaceLinkDeviceType) { + this.interfaceLinkDeviceType = interfaceLinkDeviceType; + } + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setNodeName(String nodeName) + { + this.nodeName = nodeName; + } + + public String getNodeName() + { + return nodeName; + } + + public void setHardwareSn(String hardwareSn) + { + this.hardwareSn = hardwareSn; + } + + public String getHardwareSn() + { + return hardwareSn; + } + + public void setBandwidth95Daily(BigDecimal bandwidth95Daily) + { + this.bandwidth95Daily = bandwidth95Daily; + } + + public BigDecimal getBandwidth95Daily() + { + return bandwidth95Daily; + } + + public void setBandwidth95Monthly(BigDecimal bandwidth95Monthly) + { + this.bandwidth95Monthly = bandwidth95Monthly; + } + + public BigDecimal getBandwidth95Monthly() + { + return bandwidth95Monthly; + } + + public void setPackageBandwidthDaily(BigDecimal packageBandwidthDaily) + { + this.packageBandwidthDaily = packageBandwidthDaily; + } + + public BigDecimal getPackageBandwidthDaily() + { + return packageBandwidthDaily; + } + + public void setCustomerId(String customerId) + { + this.customerId = customerId; + } + + public String getCustomerId() + { + return customerId; + } + + public void setCustomerName(String customerName) + { + this.customerName = customerName; + } + + public String getCustomerName() + { + return customerName; + } + + public void setServiceNumber(String serviceNumber) + { + this.serviceNumber = serviceNumber; + } + + public String getServiceNumber() + { + return serviceNumber; + } + + public void setUplinkSwitch(String uplinkSwitch) + { + this.uplinkSwitch = uplinkSwitch; + } + + public String getUplinkSwitch() + { + return uplinkSwitch; + } + + public void setCreatorId(Long creatorId) + { + this.creatorId = creatorId; + } + + public Long getCreatorId() + { + return creatorId; + } + + public void setCreatorName(String creatorName) + { + this.creatorName = creatorName; + } + + public String getCreatorName() + { + return creatorName; + } + + public void setRemark1(String remark1) + { + this.remark1 = remark1; + } + + public String getRemark1() + { + return remark1; + } + + public String getInterfaceName() { + return interfaceName; + } + + public void setInterfaceName(String interfaceName) { + this.interfaceName = interfaceName; + } + + public String getBandwidthType() { + return bandwidthType; + } + + public void setBandwidthType(String bandwidthType) { + this.bandwidthType = bandwidthType; + } + + public BigDecimal getBandwidthResult() { + return bandwidthResult; + } + + public void setBandwidthResult(BigDecimal bandwidthResult) { + this.bandwidthResult = bandwidthResult; + } + + public BigDecimal getAvgMonthlyBandwidth95() { + return avgMonthlyBandwidth95; + } + + public void setAvgMonthlyBandwidth95(BigDecimal avgMonthlyBandwidth95) { + this.avgMonthlyBandwidth95 = avgMonthlyBandwidth95; + } + + public BigDecimal getEffectiveBandwidth95Daily() { + return effectiveBandwidth95Daily; + } + + public void setEffectiveBandwidth95Daily(BigDecimal effectiveBandwidth95Daily) { + this.effectiveBandwidth95Daily = effectiveBandwidth95Daily; + } + + public BigDecimal getEffectiveBandwidth95Monthly() { + return effectiveBandwidth95Monthly; + } + + public void setEffectiveBandwidth95Monthly(BigDecimal effectiveBandwidth95Monthly) { + this.effectiveBandwidth95Monthly = effectiveBandwidth95Monthly; + } + + public BigDecimal getEffectiveAvgMonthlyBandwidth95() { + return effectiveAvgMonthlyBandwidth95; + } + + public void setEffectiveAvgMonthlyBandwidth95(BigDecimal effectiveAvgMonthlyBandwidth95) { + this.effectiveAvgMonthlyBandwidth95 = effectiveAvgMonthlyBandwidth95; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("nodeName", getNodeName()) + .append("hardwareSn", getHardwareSn()) + .append("bandwidth95Daily", getBandwidth95Daily()) + .append("bandwidth95Monthly", getBandwidth95Monthly()) + .append("packageBandwidthDaily", getPackageBandwidthDaily()) + .append("customerId", getCustomerId()) + .append("customerName", getCustomerName()) + .append("serviceNumber", getServiceNumber()) + .append("uplinkSwitch", getUplinkSwitch()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .append("creatorId", getCreatorId()) + .append("creatorName", getCreatorName()) + .append("remark1", getRemark1()) + .append("interfaceName", getInterfaceName()) + .toString(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsServerRevenueConfig.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsServerRevenueConfig.java new file mode 100644 index 0000000..0f6fc79 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsServerRevenueConfig.java @@ -0,0 +1,177 @@ +package com.ruoyi.system.domain; + +import java.math.BigDecimal; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 服务器收益方式配置对象 eps_server_revenue_config + * + * @author gyt + * @date 2025-08-19 + */ +public class EpsServerRevenueConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 唯一标识ID */ + private Long id; + + /** 节点名称 */ + @Excel(name = "节点名称") + private String nodeName; + + /** 收益方式(1.流量,2包端) */ + @Excel(name = "收益方式(1.流量,2包端)") + private String revenueMethod; + + /** 硬件SN */ + @Excel(name = "硬件SN") + private String hardwareSn; + + /** 流量网口 */ + @Excel(name = "流量网口") + private String trafficPort; + + /** 95带宽值(Mbps) */ + @Excel(name = "95带宽值(Mbps)") + private BigDecimal bandwidth95; + + /** 包端带宽值 */ + @Excel(name = "包端带宽值") + private BigDecimal packageBandwidth; + + /** 业务名称 */ + @Excel(name = "业务名称") + private String businessName; + + /** 业务代码(12位) */ + @Excel(name = "业务代码(12位)") + private String businessCode; + + /** 注册状态 */ + @Excel(name = "注册状态") + private String registrationStatus; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setNodeName(String nodeName) + { + this.nodeName = nodeName; + } + + public String getNodeName() + { + return nodeName; + } + + public void setRevenueMethod(String revenueMethod) + { + this.revenueMethod = revenueMethod; + } + + public String getRevenueMethod() + { + return revenueMethod; + } + + public void setHardwareSn(String hardwareSn) + { + this.hardwareSn = hardwareSn; + } + + public String getHardwareSn() + { + return hardwareSn; + } + + public void setTrafficPort(String trafficPort) + { + this.trafficPort = trafficPort; + } + + public String getTrafficPort() + { + return trafficPort; + } + + public void setBandwidth95(BigDecimal bandwidth95) + { + this.bandwidth95 = bandwidth95; + } + + public BigDecimal getBandwidth95() + { + return bandwidth95; + } + + public void setPackageBandwidth(BigDecimal packageBandwidth) + { + this.packageBandwidth = packageBandwidth; + } + + public BigDecimal getPackageBandwidth() + { + return packageBandwidth; + } + + public void setBusinessName(String businessName) + { + this.businessName = businessName; + } + + public String getBusinessName() + { + return businessName; + } + + public void setBusinessCode(String businessCode) + { + this.businessCode = businessCode; + } + + public String getBusinessCode() + { + return businessCode; + } + + public void setRegistrationStatus(String registrationStatus) + { + this.registrationStatus = registrationStatus; + } + + public String getRegistrationStatus() + { + return registrationStatus; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("nodeName", getNodeName()) + .append("revenueMethod", getRevenueMethod()) + .append("hardwareSn", getHardwareSn()) + .append("trafficPort", getTrafficPort()) + .append("bandwidth95", getBandwidth95()) + .append("packageBandwidth", getPackageBandwidth()) + .append("updateTime", getUpdateTime()) + .append("businessName", getBusinessName()) + .append("businessCode", getBusinessCode()) + .append("registrationStatus", getRegistrationStatus()) + .append("createBy", getCreateBy()) + .append("updateBy", getUpdateBy()) + .append("createTime", getCreateTime()) + .toString(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsTrafficData.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsTrafficData.java new file mode 100644 index 0000000..cd1dce2 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/EpsTrafficData.java @@ -0,0 +1,216 @@ +package com.ruoyi.system.domain; + +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; + +/** + * 流量相关数据对象 eps_traffic_data + * + * @author gyt + * @date 2025-08-12 + */ +public class EpsTrafficData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 硬件SN */ + @Excel(name = "硬件SN") + private String hardwareSn; + + /** 节点名称 */ + @Excel(name = "节点名称") + private String nodeName; + + /** 收益方式 */ + @Excel(name = "收益方式") + private String revenueMethod; + + /** 流量端口 */ + @Excel(name = "流量端口") + private String trafficPort; + + /** 发送流量值(bytes) */ + @Excel(name = "发送流量值", readConverterExp = "b=ytes") + private Long txBytes; + + /** 接收流量值(bytes) */ + @Excel(name = "接收流量值", readConverterExp = "b=ytes") + private Long rxBytes; + + /** 包端带宽值(Mbps) */ + @Excel(name = "包端带宽值", readConverterExp = "M=bps") + private BigDecimal packageBandwidth; + + /** 创建人id */ + @Excel(name = "创建人id") + private Long creatorId; + + /** 创建人名称 */ + @Excel(name = "创建人名称") + private String creatorName; + + /** 修改人id */ + @Excel(name = "修改人id") + private Long updaterId; + + /** 修改人名称 */ + @Excel(name = "修改人名称") + private String updaterName; + /** 业务名称 */ + private String businessName; + + public String getBusinessName() { + return businessName; + } + + public void setBusinessName(String businessName) { + this.businessName = businessName; + } + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setHardwareSn(String hardwareSn) + { + this.hardwareSn = hardwareSn; + } + + public String getHardwareSn() + { + return hardwareSn; + } + + public void setNodeName(String nodeName) + { + this.nodeName = nodeName; + } + + public String getNodeName() + { + return nodeName; + } + + public void setRevenueMethod(String revenueMethod) + { + this.revenueMethod = revenueMethod; + } + + public String getRevenueMethod() + { + return revenueMethod; + } + + public void setTrafficPort(String trafficPort) + { + this.trafficPort = trafficPort; + } + + public String getTrafficPort() + { + return trafficPort; + } + + public void setTxBytes(Long txBytes) + { + this.txBytes = txBytes; + } + + public Long getTxBytes() + { + return txBytes; + } + + public void setRxBytes(Long rxBytes) + { + this.rxBytes = rxBytes; + } + + public Long getRxBytes() + { + return rxBytes; + } + + public void setPackageBandwidth(BigDecimal packageBandwidth) + { + this.packageBandwidth = packageBandwidth; + } + + public BigDecimal getPackageBandwidth() + { + return packageBandwidth; + } + + public void setCreatorId(Long creatorId) + { + this.creatorId = creatorId; + } + + public Long getCreatorId() + { + return creatorId; + } + + public void setCreatorName(String creatorName) + { + this.creatorName = creatorName; + } + + public String getCreatorName() + { + return creatorName; + } + + public void setUpdaterId(Long updaterId) + { + this.updaterId = updaterId; + } + + public Long getUpdaterId() + { + return updaterId; + } + + public void setUpdaterName(String updaterName) + { + this.updaterName = updaterName; + } + + public String getUpdaterName() + { + return updaterName; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("hardwareSn", getHardwareSn()) + .append("nodeName", getNodeName()) + .append("revenueMethod", getRevenueMethod()) + .append("trafficPort", getTrafficPort()) + .append("txBytes", getTxBytes()) + .append("rxBytes", getRxBytes()) + .append("packageBandwidth", getPackageBandwidth()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .append("creatorId", getCreatorId()) + .append("creatorName", getCreatorName()) + .append("updaterId", getUpdaterId()) + .append("updaterName", getUpdaterName()) + .toString(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/KnowledgeBase.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/KnowledgeBase.java new file mode 100644 index 0000000..1bcf53d --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/KnowledgeBase.java @@ -0,0 +1,99 @@ +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 知识库对象 knowledge_base + * + * @author gyt + * @date 2025-08-15 + */ +public class KnowledgeBase extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 标题 */ + @Excel(name = "标题") + private String title; + + /** 问题类型 */ + @Excel(name = "问题类型") + private String issueType; + + /** 解决方案 */ + @Excel(name = "解决方案") + private String solution; + + /** 创建人 */ + private String creatBy; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setTitle(String title) + { + this.title = title; + } + + public String getTitle() + { + return title; + } + + public void setIssueType(String issueType) + { + this.issueType = issueType; + } + + public String getIssueType() + { + return issueType; + } + + public void setSolution(String solution) + { + this.solution = solution; + } + + public String getSolution() + { + return solution; + } + + public void setCreatBy(String creatBy) + { + this.creatBy = creatBy; + } + + public String getCreatBy() + { + return creatBy; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("title", getTitle()) + .append("issueType", getIssueType()) + .append("solution", getSolution()) + .append("createTime", getCreateTime()) + .append("creatBy", getCreatBy()) + .append("updateTime", getUpdateTime()) + .append("updateBy", getUpdateBy()) + .toString(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/MtmMonitoringTemplate.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/MtmMonitoringTemplate.java new file mode 100644 index 0000000..69e927f --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/MtmMonitoringTemplate.java @@ -0,0 +1,204 @@ +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 监控模板管理对象 mtm_monitoring_template + * + * @author gyt + * @date 2025-08-12 + */ +public class MtmMonitoringTemplate extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 模板名称 */ + @Excel(name = "模板名称") + private String templateName; + + /** 描述 */ + @Excel(name = "描述") + private String description; + + /** 项类型 */ + @Excel(name = "项类型") + private String itemType; + + /** 包含资源 */ + @Excel(name = "包含资源") + private String includedResources; + + /** 发现项类型 */ + @Excel(name = "发现项类型") + private String discoveryItemType; + + /** 项名 */ + @Excel(name = "项名") + private String itemName; + + /** 项描述 */ + @Excel(name = "项描述") + private String itemDescription; + + /** 创建人id */ + @Excel(name = "创建人id") + private Long creatorId; + + /** 创建人名称 */ + @Excel(name = "创建人名称") + private String creatorName; + + /** 修改人id */ + @Excel(name = "修改人id") + private Long updaterId; + + /** 修改人名称 */ + @Excel(name = "修改人名称") + private String updaterName; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setTemplateName(String templateName) + { + this.templateName = templateName; + } + + public String getTemplateName() + { + return templateName; + } + + public void setDescription(String description) + { + this.description = description; + } + + public String getDescription() + { + return description; + } + + public void setItemType(String itemType) + { + this.itemType = itemType; + } + + public String getItemType() + { + return itemType; + } + + public void setIncludedResources(String includedResources) + { + this.includedResources = includedResources; + } + + public String getIncludedResources() + { + return includedResources; + } + + public void setDiscoveryItemType(String discoveryItemType) + { + this.discoveryItemType = discoveryItemType; + } + + public String getDiscoveryItemType() + { + return discoveryItemType; + } + + public void setItemName(String itemName) + { + this.itemName = itemName; + } + + public String getItemName() + { + return itemName; + } + + public void setItemDescription(String itemDescription) + { + this.itemDescription = itemDescription; + } + + public String getItemDescription() + { + return itemDescription; + } + + public void setCreatorId(Long creatorId) + { + this.creatorId = creatorId; + } + + public Long getCreatorId() + { + return creatorId; + } + + public void setCreatorName(String creatorName) + { + this.creatorName = creatorName; + } + + public String getCreatorName() + { + return creatorName; + } + + public void setUpdaterId(Long updaterId) + { + this.updaterId = updaterId; + } + + public Long getUpdaterId() + { + return updaterId; + } + + public void setUpdaterName(String updaterName) + { + this.updaterName = updaterName; + } + + public String getUpdaterName() + { + return updaterName; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("templateName", getTemplateName()) + .append("description", getDescription()) + .append("itemType", getItemType()) + .append("includedResources", getIncludedResources()) + .append("discoveryItemType", getDiscoveryItemType()) + .append("itemName", getItemName()) + .append("itemDescription", getItemDescription()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .append("creatorId", getCreatorId()) + .append("creatorName", getCreatorName()) + .append("updaterId", getUpdaterId()) + .append("updaterName", getUpdaterName()) + .toString(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/RmEpsTopologyManagement.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/RmEpsTopologyManagement.java new file mode 100644 index 0000000..5c3c266 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/RmEpsTopologyManagement.java @@ -0,0 +1,236 @@ +package com.ruoyi.system.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; + +/** + * 拓扑管理对象 rm_eps_topology_management + * + * @author gyt + * @date 2025-08-12 + */ +public class RmEpsTopologyManagement extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 交换机名称 */ + @Excel(name = "交换机名称") + private String switchName; + + /** 交换机硬件SN */ + @Excel(name = "交换机硬件SN") + private String switchSn; + + /** 接口名称 */ + @Excel(name = "接口名称") + private String interfaceName; + + /** 接口连接设备类型 */ + @Excel(name = "接口连接设备类型",readConverterExp = "1=服务器,2=机房出口") + private String connectedDeviceType; + + /** 服务器名称 */ + @Excel(name = "服务器名称") + private String serverName; + + /** 服务器硬件SN */ + @Excel(name = "服务器硬件SN") + private String serverSn; + + /** 服务器网口 */ + @Excel(name = "服务器网口") + private String serverPort; + + /** 创建时间 */ + @Excel(name = "创建时间",dateFormat = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** 修改时间 */ + @Excel(name = "修改时间",dateFormat = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + + /** 创建人id */ + private Long creatorId; + + /** 创建人名称 */ + private String creatorName; + + /** 修改人id */ + private Long updaterId; + + /** 修改人名称 */ + private String updaterName; + + + @Override + public Date getCreateTime() { + return createTime; + } + + @Override + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public Date getUpdateTime() { + return updateTime; + } + + @Override + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setSwitchName(String switchName) + { + this.switchName = switchName; + } + + public String getSwitchName() + { + return switchName; + } + + public void setSwitchSn(String switchSn) + { + this.switchSn = switchSn; + } + + public String getSwitchSn() + { + return switchSn; + } + + public void setInterfaceName(String interfaceName) + { + this.interfaceName = interfaceName; + } + + public String getInterfaceName() + { + return interfaceName; + } + + public void setConnectedDeviceType(String connectedDeviceType) + { + this.connectedDeviceType = connectedDeviceType; + } + + public String getConnectedDeviceType() + { + return connectedDeviceType; + } + + public void setServerName(String serverName) + { + this.serverName = serverName; + } + + public String getServerName() + { + return serverName; + } + + public void setServerSn(String serverSn) + { + this.serverSn = serverSn; + } + + public String getServerSn() + { + return serverSn; + } + + public void setServerPort(String serverPort) + { + this.serverPort = serverPort; + } + + public String getServerPort() + { + return serverPort; + } + + public void setCreatorId(Long creatorId) + { + this.creatorId = creatorId; + } + + public Long getCreatorId() + { + return creatorId; + } + + public void setCreatorName(String creatorName) + { + this.creatorName = creatorName; + } + + public String getCreatorName() + { + return creatorName; + } + + public void setUpdaterId(Long updaterId) + { + this.updaterId = updaterId; + } + + public Long getUpdaterId() + { + return updaterId; + } + + public void setUpdaterName(String updaterName) + { + this.updaterName = updaterName; + } + + public String getUpdaterName() + { + return updaterName; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("switchName", getSwitchName()) + .append("switchSn", getSwitchSn()) + .append("interfaceName", getInterfaceName()) + .append("connectedDeviceType", getConnectedDeviceType()) + .append("serverName", getServerName()) + .append("serverSn", getServerSn()) + .append("serverPort", getServerPort()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .append("creatorId", getCreatorId()) + .append("creatorName", getCreatorName()) + .append("updaterId", getUpdaterId()) + .append("updaterName", getUpdaterName()) + .toString(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/RmResourceGroup.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/RmResourceGroup.java new file mode 100644 index 0000000..ae099b2 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/RmResourceGroup.java @@ -0,0 +1,173 @@ +package com.ruoyi.system.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; + +/** + * 资源分组对象 rm_resource_group + * + * @author gyt + * @date 2025-08-12 + */ +public class RmResourceGroup extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 组名 */ + @Excel(name = "组名") + private String groupName; + + /** 描述 */ + @Excel(name = "描述") + private String description; + + /** 包含设备 */ + @Excel(name = "包含设备") + private String includedDevices; + + /** 创建时间 */ + @Excel(name = "创建时间",dateFormat = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + /** 修改时间 */ + @Excel(name = "修改时间",dateFormat = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + /** 创建人id */ + private Long creatorId; + + /** 创建人名称 */ + private String creatorName; + + /** 修改人id */ + private Long updaterId; + + /** 修改人名称 */ + private String updaterName; + + @Override + public Date getCreateTime() { + return createTime; + } + + @Override + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public Date getUpdateTime() { + return updateTime; + } + + @Override + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setGroupName(String groupName) + { + this.groupName = groupName; + } + + public String getGroupName() + { + return groupName; + } + + public void setDescription(String description) + { + this.description = description; + } + + public String getDescription() + { + return description; + } + + public void setIncludedDevices(String includedDevices) + { + this.includedDevices = includedDevices; + } + + public String getIncludedDevices() + { + return includedDevices; + } + + public void setCreatorId(Long creatorId) + { + this.creatorId = creatorId; + } + + public Long getCreatorId() + { + return creatorId; + } + + public void setCreatorName(String creatorName) + { + this.creatorName = creatorName; + } + + public String getCreatorName() + { + return creatorName; + } + + public void setUpdaterId(Long updaterId) + { + this.updaterId = updaterId; + } + + public Long getUpdaterId() + { + return updaterId; + } + + public void setUpdaterName(String updaterName) + { + this.updaterName = updaterName; + } + + public String getUpdaterName() + { + return updaterName; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("groupName", getGroupName()) + .append("description", getDescription()) + .append("includedDevices", getIncludedDevices()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .append("creatorId", getCreatorId()) + .append("creatorName", getCreatorName()) + .append("updaterId", getUpdaterId()) + .append("updaterName", getUpdaterName()) + .toString(); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/RmResourceRegistration.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/RmResourceRegistration.java index b119c48..f10fce2 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/RmResourceRegistration.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/RmResourceRegistration.java @@ -24,7 +24,7 @@ public class RmResourceRegistration extends BaseEntity /** 资源类型 * 1 服务器,2 交换机*/ - @Excel(name = "资源类型") + @Excel(name = "资源类型",readConverterExp = "1=服务器,2=交换机") private String resourceType; /** 资源名称 */ @@ -39,38 +39,44 @@ public class RmResourceRegistration extends BaseEntity @Excel(name = "端口") private String resourcePort; + /**其他端口名称 */ + private String otherPortName; + /** 协议 1.TCP,2.UDP */ - @Excel(name = "协议") + @Excel(name = "协议",readConverterExp = "1=TCP,2=UDP") private String protocol; /** 版本(1.SNMPv2,2.SNMPv3) */ - @Excel(name = "版本") + @Excel(name = "版本",readConverterExp = "1=SNMPv2,2=SNMPv3") private String resourceVersion; /** 读写权限(1.RW,2.ReadOnly) */ - @Excel(name = "读写权限") + @Excel(name = "读写权限",readConverterExp = "1=RW,2=ReadOnly") private String rwPermission; /** 安全级别(1.authPriv、2.authNoPriv,3.noAuthNoPriv) */ - @Excel(name = "安全级别") + @Excel(name = "安全级别",readConverterExp = "1=authPriv,2=authNoPriv,3=noAuthNoPriv") private String securityLevel; /** 加密方式 1.md5,2.SHA */ - @Excel(name = "加密方式") + @Excel(name = "加密方式",readConverterExp = "1=MD5,2=SHA") private String encryption; - /** 密码 */ + /** 用户名 */ + @Excel(name = "用户名") + private String resourceUserName; + /** 密码 */ @Excel(name = "密码") private String resourcePwd; - /** 注册状态 0-未注册,1-未注册 */ - @Excel(name = "注册状态") + /** 注册状态 0-未注册,1-已注册 */ + @Excel(name = "注册状态",readConverterExp = "0=未注册,1=已注册") private String registrationStatus; /** 在线状态 0-离线,1-在线 */ - @Excel(name = "在线状态") + @Excel(name = "在线状态",readConverterExp = "0=离线,1=在线") private String onlineStatus; /** 描述 */ @@ -100,7 +106,15 @@ public class RmResourceRegistration extends BaseEntity /** 修改人名称 */ private String updaterName; - public void setId(Long id) + public String getOtherPortName() { + return otherPortName; + } + + public void setOtherPortName(String otherPortName) { + this.otherPortName = otherPortName; + } + + public void setId(Long id) { this.id = id; } @@ -320,9 +334,15 @@ public class RmResourceRegistration extends BaseEntity return updaterName; } + public String getResourceUserName() { + return resourceUserName; + } + public void setResourceUserName(String resourceUserName) { + this.resourceUserName = resourceUserName; + } - @Override + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) .append("id", getId()) @@ -331,12 +351,14 @@ public class RmResourceRegistration extends BaseEntity .append("resourceName", getResourceName()) .append("ipAddress", getIpAddress()) .append("resourcePort", getResourcePort()) + .append("otherPortName", getOtherPortName()) .append("protocol", getProtocol()) .append("resourceVersion", getResourceVersion()) .append("rwPermission", getRwPermission()) .append("securityLevel", getSecurityLevel()) .append("encryption", getEncryption()) .append("resourcePwd", getResourcePwd()) + .append("resourceUserName", getResourceName()) .append("registrationStatus", getRegistrationStatus()) .append("onlineStatus", getOnlineStatus()) .append("description", getDescription()) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsBusinessMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsBusinessMapper.java new file mode 100644 index 0000000..b592288 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsBusinessMapper.java @@ -0,0 +1,69 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.EpsBusiness; + +import java.util.List; + +/** + * 业务信息Mapper接口 + * + * @author gyt + * @date 2025-08-18 + */ +public interface EpsBusinessMapper +{ + /** + * 查询业务信息 + * + * @param id 业务信息主键 + * @return 业务信息 + */ + public EpsBusiness selectEpsBusinessById(String id); + + /** + * 查询业务信息列表 + * + * @param epsBusiness 业务信息 + * @return 业务信息集合 + */ + public List selectEpsBusinessList(EpsBusiness epsBusiness); + + /** + * 新增业务信息 + * + * @param epsBusiness 业务信息 + * @return 结果 + */ + public int insertEpsBusiness(EpsBusiness epsBusiness); + + /** + * 修改业务信息 + * + * @param epsBusiness 业务信息 + * @return 结果 + */ + public int updateEpsBusiness(EpsBusiness epsBusiness); + + /** + * 删除业务信息 + * + * @param id 业务信息主键 + * @return 结果 + */ + public int deleteEpsBusinessById(String id); + + /** + * 批量删除业务信息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEpsBusinessByIds(String[] ids); + + /** + * 验证业务名称是否存在 + * @param epsBusiness + * @return + */ + Integer countByBusinessName(EpsBusiness epsBusiness); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsInitialTrafficDataMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsInitialTrafficDataMapper.java new file mode 100644 index 0000000..6fbf2f9 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsInitialTrafficDataMapper.java @@ -0,0 +1,37 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.EpsInitialTrafficData; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface EpsInitialTrafficDataMapper { + /** + * 创建指定名称的EPS流量表 + * @param tableName 表名 + */ + void createEpsTrafficTable(@Param("tableName") String tableName); + /** + * 创建指定名称的EPS流量初始表 + * @param tableName 表名 + */ + void createEpsInitialTrafficTable(@Param("tableName") String tableName); + /** + * 单条插入数据 + * @param data 流量数据 + */ + void insert(EpsInitialTrafficData data); + + /** + * 批量插入数据 + * @param epsInitialTrafficData 流量数据实体类 + */ + void batchInsert(EpsInitialTrafficData epsInitialTrafficData); + + /** + * 条件查询 + * @param condition 查询条件实体 + * @return 流量数据列表 + */ + List selectByCondition(EpsInitialTrafficData condition); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsMethodChangeRecordMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsMethodChangeRecordMapper.java new file mode 100644 index 0000000..4f1fbd8 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsMethodChangeRecordMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.EpsMethodChangeRecord; + +/** + * 收益方式修改记录Mapper接口 + * + * @author gyt + * @date 2025-08-15 + */ +public interface EpsMethodChangeRecordMapper +{ + /** + * 查询收益方式修改记录 + * + * @param id 收益方式修改记录主键 + * @return 收益方式修改记录 + */ + public EpsMethodChangeRecord selectEpsMethodChangeRecordById(Long id); + + /** + * 查询收益方式修改记录列表 + * + * @param epsMethodChangeRecord 收益方式修改记录 + * @return 收益方式修改记录集合 + */ + public List selectEpsMethodChangeRecordList(EpsMethodChangeRecord epsMethodChangeRecord); + + /** + * 新增收益方式修改记录 + * + * @param epsMethodChangeRecord 收益方式修改记录 + * @return 结果 + */ + public int insertEpsMethodChangeRecord(EpsMethodChangeRecord epsMethodChangeRecord); + + /** + * 修改收益方式修改记录 + * + * @param epsMethodChangeRecord 收益方式修改记录 + * @return 结果 + */ + public int updateEpsMethodChangeRecord(EpsMethodChangeRecord epsMethodChangeRecord); + + /** + * 删除收益方式修改记录 + * + * @param id 收益方式修改记录主键 + * @return 结果 + */ + public int deleteEpsMethodChangeRecordById(Long id); + + /** + * 批量删除收益方式修改记录 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEpsMethodChangeRecordByIds(Long[] ids); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsNodeBandwidthMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsNodeBandwidthMapper.java new file mode 100644 index 0000000..9d0c097 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsNodeBandwidthMapper.java @@ -0,0 +1,84 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.EpsNodeBandwidth; + +import java.util.List; + +/** + * 节点带宽信息Mapper接口 + * + * @author gyt + * @date 2025-08-12 + */ +public interface EpsNodeBandwidthMapper +{ + /** + * 查询节点带宽信息 + * + * @param id 节点带宽信息主键 + * @return 节点带宽信息 + */ + public EpsNodeBandwidth selectEpsNodeBandwidthById(Long id); + + /** + * 查询节点带宽信息列表 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 节点带宽信息集合 + */ + public List selectEpsNodeBandwidthList(EpsNodeBandwidth epsNodeBandwidth); + + /** + * 新增节点带宽信息 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 结果 + */ + public int insertEpsNodeBandwidth(EpsNodeBandwidth epsNodeBandwidth); + + /** + * 修改节点带宽信息 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 结果 + */ + public int updateEpsNodeBandwidth(EpsNodeBandwidth epsNodeBandwidth); + + /** + * 删除节点带宽信息 + * + * @param id 节点带宽信息主键 + * @return 结果 + */ + public int deleteEpsNodeBandwidthById(Long id); + + /** + * 批量删除节点带宽信息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEpsNodeBandwidthByIds(Long[] ids); + + /** + * 计算月均日95值 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 节点带宽信息 + */ + public EpsNodeBandwidth calculateAvg(EpsNodeBandwidth epsNodeBandwidth); + /** + * 月均日95值-相关数据 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 节点带宽信息 + */ + public List getAvgDetailMsg(EpsNodeBandwidth epsNodeBandwidth); + /** + * 查询月均日95值是否存在 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 节点带宽信息 + */ + public int countByAvgMsg(EpsNodeBandwidth epsNodeBandwidth); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsServerRevenueConfigMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsServerRevenueConfigMapper.java new file mode 100644 index 0000000..6e00da2 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsServerRevenueConfigMapper.java @@ -0,0 +1,71 @@ +package com.ruoyi.system.mapper; + +import com.ruoyi.system.domain.EpsServerRevenueConfig; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +/** + * 服务器收益方式配置Mapper接口 + * + * @author gyt + * @date 2025-08-19 + */ +public interface EpsServerRevenueConfigMapper +{ + /** + * 查询服务器收益方式配置 + * + * @param id 服务器收益方式配置主键 + * @return 服务器收益方式配置 + */ + public EpsServerRevenueConfig selectEpsServerRevenueConfigById(Long id); + + /** + * 查询服务器收益方式配置列表 + * + * @param epsServerRevenueConfig 服务器收益方式配置 + * @return 服务器收益方式配置集合 + */ + public List selectEpsServerRevenueConfigList(EpsServerRevenueConfig epsServerRevenueConfig); + + /** + * 新增服务器收益方式配置 + * + * @param epsServerRevenueConfig 服务器收益方式配置 + * @return 结果 + */ + public int insertEpsServerRevenueConfig(EpsServerRevenueConfig epsServerRevenueConfig); + + /** + * 修改服务器收益方式配置 + * + * @param epsServerRevenueConfig 服务器收益方式配置 + * @return 结果 + */ + public int updateEpsServerRevenueConfig(EpsServerRevenueConfig epsServerRevenueConfig); + + /** + * 删除服务器收益方式配置 + * + * @param id 服务器收益方式配置主键 + * @return 结果 + */ + public int deleteEpsServerRevenueConfigById(Long id); + + /** + * 批量删除服务器收益方式配置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEpsServerRevenueConfigByIds(Long[] ids); + + /** + * 查询该数据是否存在 + * + * @param hardwareSn 服务器sn + * @return 数据条数 + */ + public int countBySn(@Param("hardwareSn") String hardwareSn); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsTrafficDataMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsTrafficDataMapper.java new file mode 100644 index 0000000..2086259 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/EpsTrafficDataMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.EpsTrafficData; + +/** + * 流量相关数据Mapper接口 + * + * @author gyt + * @date 2025-08-12 + */ +public interface EpsTrafficDataMapper +{ + /** + * 查询流量相关数据 + * + * @param id 流量相关数据主键 + * @return 流量相关数据 + */ + public EpsTrafficData selectEpsTrafficDataById(Long id); + + /** + * 查询流量相关数据列表 + * + * @param epsTrafficData 流量相关数据 + * @return 流量相关数据集合 + */ + public List selectEpsTrafficDataList(EpsTrafficData epsTrafficData); + + /** + * 新增流量相关数据 + * + * @param epsTrafficData 流量相关数据 + * @return 结果 + */ + public int insertEpsTrafficData(EpsTrafficData epsTrafficData); + + /** + * 修改流量相关数据 + * + * @param epsTrafficData 流量相关数据 + * @return 结果 + */ + public int updateEpsTrafficData(EpsTrafficData epsTrafficData); + + /** + * 删除流量相关数据 + * + * @param id 流量相关数据主键 + * @return 结果 + */ + public int deleteEpsTrafficDataById(Long id); + + /** + * 批量删除流量相关数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEpsTrafficDataByIds(Long[] ids); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/KnowledgeBaseMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/KnowledgeBaseMapper.java new file mode 100644 index 0000000..d9df47f --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/KnowledgeBaseMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.KnowledgeBase; + +/** + * 知识库Mapper接口 + * + * @author gyt + * @date 2025-08-15 + */ +public interface KnowledgeBaseMapper +{ + /** + * 查询知识库 + * + * @param id 知识库主键 + * @return 知识库 + */ + public KnowledgeBase selectKnowledgeBaseById(Long id); + + /** + * 查询知识库列表 + * + * @param knowledgeBase 知识库 + * @return 知识库集合 + */ + public List selectKnowledgeBaseList(KnowledgeBase knowledgeBase); + + /** + * 新增知识库 + * + * @param knowledgeBase 知识库 + * @return 结果 + */ + public int insertKnowledgeBase(KnowledgeBase knowledgeBase); + + /** + * 修改知识库 + * + * @param knowledgeBase 知识库 + * @return 结果 + */ + public int updateKnowledgeBase(KnowledgeBase knowledgeBase); + + /** + * 删除知识库 + * + * @param id 知识库主键 + * @return 结果 + */ + public int deleteKnowledgeBaseById(Long id); + + /** + * 批量删除知识库 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteKnowledgeBaseByIds(Long[] ids); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/MtmMonitoringTemplateMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/MtmMonitoringTemplateMapper.java new file mode 100644 index 0000000..df0c047 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/MtmMonitoringTemplateMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.MtmMonitoringTemplate; + +/** + * 监控模板管理Mapper接口 + * + * @author gyt + * @date 2025-08-12 + */ +public interface MtmMonitoringTemplateMapper +{ + /** + * 查询监控模板管理 + * + * @param id 监控模板管理主键 + * @return 监控模板管理 + */ + public MtmMonitoringTemplate selectMtmMonitoringTemplateById(Long id); + + /** + * 查询监控模板管理列表 + * + * @param mtmMonitoringTemplate 监控模板管理 + * @return 监控模板管理集合 + */ + public List selectMtmMonitoringTemplateList(MtmMonitoringTemplate mtmMonitoringTemplate); + + /** + * 新增监控模板管理 + * + * @param mtmMonitoringTemplate 监控模板管理 + * @return 结果 + */ + public int insertMtmMonitoringTemplate(MtmMonitoringTemplate mtmMonitoringTemplate); + + /** + * 修改监控模板管理 + * + * @param mtmMonitoringTemplate 监控模板管理 + * @return 结果 + */ + public int updateMtmMonitoringTemplate(MtmMonitoringTemplate mtmMonitoringTemplate); + + /** + * 删除监控模板管理 + * + * @param id 监控模板管理主键 + * @return 结果 + */ + public int deleteMtmMonitoringTemplateById(Long id); + + /** + * 批量删除监控模板管理 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMtmMonitoringTemplateByIds(Long[] ids); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmEpsTopologyManagementMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmEpsTopologyManagementMapper.java new file mode 100644 index 0000000..05256fd --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmEpsTopologyManagementMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.RmEpsTopologyManagement; + +/** + * 拓扑管理Mapper接口 + * + * @author gyt + * @date 2025-08-12 + */ +public interface RmEpsTopologyManagementMapper +{ + /** + * 查询拓扑管理 + * + * @param id 拓扑管理主键 + * @return 拓扑管理 + */ + public RmEpsTopologyManagement selectRmEpsTopologyManagementById(Long id); + + /** + * 查询拓扑管理列表 + * + * @param rmEpsTopologyManagement 拓扑管理 + * @return 拓扑管理集合 + */ + public List selectRmEpsTopologyManagementList(RmEpsTopologyManagement rmEpsTopologyManagement); + + /** + * 新增拓扑管理 + * + * @param rmEpsTopologyManagement 拓扑管理 + * @return 结果 + */ + public int insertRmEpsTopologyManagement(RmEpsTopologyManagement rmEpsTopologyManagement); + + /** + * 修改拓扑管理 + * + * @param rmEpsTopologyManagement 拓扑管理 + * @return 结果 + */ + public int updateRmEpsTopologyManagement(RmEpsTopologyManagement rmEpsTopologyManagement); + + /** + * 删除拓扑管理 + * + * @param id 拓扑管理主键 + * @return 结果 + */ + public int deleteRmEpsTopologyManagementById(Long id); + + /** + * 批量删除拓扑管理 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteRmEpsTopologyManagementByIds(Long[] ids); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmResourceGroupMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmResourceGroupMapper.java new file mode 100644 index 0000000..c0a6c3d --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmResourceGroupMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.RmResourceGroup; + +/** + * 资源分组Mapper接口 + * + * @author gyt + * @date 2025-08-12 + */ +public interface RmResourceGroupMapper +{ + /** + * 查询资源分组 + * + * @param id 资源分组主键 + * @return 资源分组 + */ + public RmResourceGroup selectRmResourceGroupById(Long id); + + /** + * 查询资源分组列表 + * + * @param rmResourceGroup 资源分组 + * @return 资源分组集合 + */ + public List selectRmResourceGroupList(RmResourceGroup rmResourceGroup); + + /** + * 新增资源分组 + * + * @param rmResourceGroup 资源分组 + * @return 结果 + */ + public int insertRmResourceGroup(RmResourceGroup rmResourceGroup); + + /** + * 修改资源分组 + * + * @param rmResourceGroup 资源分组 + * @return 结果 + */ + public int updateRmResourceGroup(RmResourceGroup rmResourceGroup); + + /** + * 删除资源分组 + * + * @param id 资源分组主键 + * @return 结果 + */ + public int deleteRmResourceGroupById(Long id); + + /** + * 批量删除资源分组 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteRmResourceGroupByIds(Long[] ids); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmResourceRegistrationMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmResourceRegistrationMapper.java index 4b12020..14a9fc1 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmResourceRegistrationMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RmResourceRegistrationMapper.java @@ -1,8 +1,10 @@ package com.ruoyi.system.mapper; -import java.util.List; import com.ruoyi.system.domain.RmResourceRegistration; +import java.util.List; +import java.util.Map; + /** * 资源注册Mapper接口 * @@ -58,4 +60,21 @@ public interface RmResourceRegistrationMapper * @return 结果 */ public int deleteRmResourceRegistrationByIds(Long[] ids); + + /** + * 查询所有资源名称([包含设备]功能使用) + * @return 资源注册集合 + */ + public List selectAllResourceName(); + /** + * 查询是否有此设备 + * @param hardwareSn 资源sn + * @return 结果 + */ + public int countBySn(String hardwareSn); + /** + * 查询所有资源名称 + * @return 资源注册集合 + */ + public List selectAllResourceNameByType(RmResourceRegistration resourceRegistration); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/EpsInitialTrafficDataService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/EpsInitialTrafficDataService.java new file mode 100644 index 0000000..199dd88 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/EpsInitialTrafficDataService.java @@ -0,0 +1,37 @@ +package com.ruoyi.system.service; + +import com.ruoyi.system.domain.EpsInitialTrafficData; + +import java.util.List; + +/** + * EPS表创建服务接口 + * 定义定时创建分表的契约 + */ +public interface EpsInitialTrafficDataService { + + /** + * 创建下个月的三张分表 + * 每月25日0点自动执行 + */ + void createNextMonthTables(); + /** + * 保存单条流量数据 + * @param data 流量数据 + */ + void save(EpsInitialTrafficData data); + + /** + * 批量保存流量数据 + * @param dataList 流量数据列表 + */ + void saveBatch(EpsInitialTrafficData dataList); + + /** + * 查询流量数据 + * @param queryParam 查询参数实体 + * @return 流量数据列表 + */ + List query(EpsInitialTrafficData queryParam); + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsBusinessService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsBusinessService.java new file mode 100644 index 0000000..a8ce2ed --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsBusinessService.java @@ -0,0 +1,69 @@ +package com.ruoyi.system.service; + +import com.ruoyi.system.domain.EpsBusiness; + +import java.util.List; + +/** + * 业务信息Service接口 + * + * @author gyt + * @date 2025-08-18 + */ +public interface IEpsBusinessService +{ + /** + * 查询业务信息 + * + * @param id 业务信息主键 + * @return 业务信息 + */ + public EpsBusiness selectEpsBusinessById(String id); + + /** + * 查询业务信息列表 + * + * @param epsBusiness 业务信息 + * @return 业务信息集合 + */ + public List selectEpsBusinessList(EpsBusiness epsBusiness); + + /** + * 新增业务信息 + * + * @param epsBusiness 业务信息 + * @return 结果 + */ + public int insertEpsBusiness(EpsBusiness epsBusiness); + + /** + * 修改业务信息 + * + * @param epsBusiness 业务信息 + * @return 结果 + */ + public int updateEpsBusiness(EpsBusiness epsBusiness); + + /** + * 批量删除业务信息 + * + * @param ids 需要删除的业务信息主键集合 + * @return 结果 + */ + public int deleteEpsBusinessByIds(String[] ids); + + /** + * 删除业务信息信息 + * + * @param id 业务信息主键 + * @return 结果 + */ + public int deleteEpsBusinessById(String id); + + /** + * 验证 业务名称是否存在 + * @param epsBusiness + * @return + */ + Integer countByBusinessName(EpsBusiness epsBusiness); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsMethodChangeRecordService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsMethodChangeRecordService.java new file mode 100644 index 0000000..aeeede2 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsMethodChangeRecordService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.EpsMethodChangeRecord; + +/** + * 收益方式修改记录Service接口 + * + * @author gyt + * @date 2025-08-15 + */ +public interface IEpsMethodChangeRecordService +{ + /** + * 查询收益方式修改记录 + * + * @param id 收益方式修改记录主键 + * @return 收益方式修改记录 + */ + public EpsMethodChangeRecord selectEpsMethodChangeRecordById(Long id); + + /** + * 查询收益方式修改记录列表 + * + * @param epsMethodChangeRecord 收益方式修改记录 + * @return 收益方式修改记录集合 + */ + public List selectEpsMethodChangeRecordList(EpsMethodChangeRecord epsMethodChangeRecord); + + /** + * 新增收益方式修改记录 + * + * @param epsMethodChangeRecord 收益方式修改记录 + * @return 结果 + */ + public int insertEpsMethodChangeRecord(EpsMethodChangeRecord epsMethodChangeRecord); + + /** + * 修改收益方式修改记录 + * + * @param epsMethodChangeRecord 收益方式修改记录 + * @return 结果 + */ + public int updateEpsMethodChangeRecord(EpsMethodChangeRecord epsMethodChangeRecord); + + /** + * 批量删除收益方式修改记录 + * + * @param ids 需要删除的收益方式修改记录主键集合 + * @return 结果 + */ + public int deleteEpsMethodChangeRecordByIds(Long[] ids); + + /** + * 删除收益方式修改记录信息 + * + * @param id 收益方式修改记录主键 + * @return 结果 + */ + public int deleteEpsMethodChangeRecordById(Long id); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsNodeBandwidthService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsNodeBandwidthService.java new file mode 100644 index 0000000..62112e1 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsNodeBandwidthService.java @@ -0,0 +1,80 @@ +package com.ruoyi.system.service; + +import com.ruoyi.system.domain.EpsInitialTrafficData; +import com.ruoyi.system.domain.EpsNodeBandwidth; + +import java.util.List; + +/** + * 节点带宽信息Service接口 + * + * @author gyt + * @date 2025-08-12 + */ +public interface IEpsNodeBandwidthService +{ + /** + * 查询节点带宽信息 + * + * @param id 节点带宽信息主键 + * @return 节点带宽信息 + */ + public EpsNodeBandwidth selectEpsNodeBandwidthById(Long id); + + /** + * 相关数据 + * @param id + * @return + */ + public List relatedData(Long id); + + /** + * 查询节点带宽信息列表 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 节点带宽信息集合 + */ + public List selectEpsNodeBandwidthList(EpsNodeBandwidth epsNodeBandwidth); + + /** + * 新增节点带宽信息 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 结果 + */ + public int insertEpsNodeBandwidth(EpsNodeBandwidth epsNodeBandwidth); + + /** + * 修改节点带宽信息 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 结果 + */ + public int updateEpsNodeBandwidth(EpsNodeBandwidth epsNodeBandwidth); + + /** + * 批量删除节点带宽信息 + * + * @param ids 需要删除的节点带宽信息主键集合 + * @return 结果 + */ + public int deleteEpsNodeBandwidthByIds(Long[] ids); + + /** + * 删除节点带宽信息信息 + * + * @param id 节点带宽信息主键 + * @return 结果 + */ + public int deleteEpsNodeBandwidthById(Long id); + + /** + * 计算月均日95值 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 结果 + */ + public int calculateAvg(EpsNodeBandwidth epsNodeBandwidth); + + List getAvgDetailMsg(Long id); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsServerRevenueConfigService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsServerRevenueConfigService.java new file mode 100644 index 0000000..b27bb38 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsServerRevenueConfigService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.EpsServerRevenueConfig; + +/** + * 服务器收益方式配置Service接口 + * + * @author gyt + * @date 2025-08-19 + */ +public interface IEpsServerRevenueConfigService +{ + /** + * 查询服务器收益方式配置 + * + * @param id 服务器收益方式配置主键 + * @return 服务器收益方式配置 + */ + public EpsServerRevenueConfig selectEpsServerRevenueConfigById(Long id); + + /** + * 查询服务器收益方式配置列表 + * + * @param epsServerRevenueConfig 服务器收益方式配置 + * @return 服务器收益方式配置集合 + */ + public List selectEpsServerRevenueConfigList(EpsServerRevenueConfig epsServerRevenueConfig); + + /** + * 新增服务器收益方式配置 + * + * @param epsServerRevenueConfig 服务器收益方式配置 + * @return 结果 + */ + public int insertEpsServerRevenueConfig(EpsServerRevenueConfig epsServerRevenueConfig); + + /** + * 修改服务器收益方式配置 + * + * @param epsServerRevenueConfig 服务器收益方式配置 + * @return 结果 + */ + public int updateEpsServerRevenueConfig(EpsServerRevenueConfig epsServerRevenueConfig); + + /** + * 批量删除服务器收益方式配置 + * + * @param ids 需要删除的服务器收益方式配置主键集合 + * @return 结果 + */ + public int deleteEpsServerRevenueConfigByIds(Long[] ids); + + /** + * 删除服务器收益方式配置信息 + * + * @param id 服务器收益方式配置主键 + * @return 结果 + */ + public int deleteEpsServerRevenueConfigById(Long id); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsTrafficDataService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsTrafficDataService.java new file mode 100644 index 0000000..59f81e0 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IEpsTrafficDataService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.EpsTrafficData; + +/** + * 流量相关数据Service接口 + * + * @author gyt + * @date 2025-08-12 + */ +public interface IEpsTrafficDataService +{ + /** + * 查询流量相关数据 + * + * @param id 流量相关数据主键 + * @return 流量相关数据 + */ + public EpsTrafficData selectEpsTrafficDataById(Long id); + + /** + * 查询流量相关数据列表 + * + * @param epsTrafficData 流量相关数据 + * @return 流量相关数据集合 + */ + public List selectEpsTrafficDataList(EpsTrafficData epsTrafficData); + + /** + * 新增流量相关数据 + * + * @param epsTrafficData 流量相关数据 + * @return 结果 + */ + public int insertEpsTrafficData(EpsTrafficData epsTrafficData); + + /** + * 修改流量相关数据 + * + * @param epsTrafficData 流量相关数据 + * @return 结果 + */ + public int updateEpsTrafficData(EpsTrafficData epsTrafficData); + + /** + * 批量删除流量相关数据 + * + * @param ids 需要删除的流量相关数据主键集合 + * @return 结果 + */ + public int deleteEpsTrafficDataByIds(Long[] ids); + + /** + * 删除流量相关数据信息 + * + * @param id 流量相关数据主键 + * @return 结果 + */ + public int deleteEpsTrafficDataById(Long id); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IKnowledgeBaseService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IKnowledgeBaseService.java new file mode 100644 index 0000000..ac2395c --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IKnowledgeBaseService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.KnowledgeBase; + +/** + * 知识库Service接口 + * + * @author gyt + * @date 2025-08-15 + */ +public interface IKnowledgeBaseService +{ + /** + * 查询知识库 + * + * @param id 知识库主键 + * @return 知识库 + */ + public KnowledgeBase selectKnowledgeBaseById(Long id); + + /** + * 查询知识库列表 + * + * @param knowledgeBase 知识库 + * @return 知识库集合 + */ + public List selectKnowledgeBaseList(KnowledgeBase knowledgeBase); + + /** + * 新增知识库 + * + * @param knowledgeBase 知识库 + * @return 结果 + */ + public int insertKnowledgeBase(KnowledgeBase knowledgeBase); + + /** + * 修改知识库 + * + * @param knowledgeBase 知识库 + * @return 结果 + */ + public int updateKnowledgeBase(KnowledgeBase knowledgeBase); + + /** + * 批量删除知识库 + * + * @param ids 需要删除的知识库主键集合 + * @return 结果 + */ + public int deleteKnowledgeBaseByIds(Long[] ids); + + /** + * 删除知识库信息 + * + * @param id 知识库主键 + * @return 结果 + */ + public int deleteKnowledgeBaseById(Long id); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IMtmMonitoringTemplateService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IMtmMonitoringTemplateService.java new file mode 100644 index 0000000..fc60094 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IMtmMonitoringTemplateService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.MtmMonitoringTemplate; + +/** + * 监控模板管理Service接口 + * + * @author gyt + * @date 2025-08-12 + */ +public interface IMtmMonitoringTemplateService +{ + /** + * 查询监控模板管理 + * + * @param id 监控模板管理主键 + * @return 监控模板管理 + */ + public MtmMonitoringTemplate selectMtmMonitoringTemplateById(Long id); + + /** + * 查询监控模板管理列表 + * + * @param mtmMonitoringTemplate 监控模板管理 + * @return 监控模板管理集合 + */ + public List selectMtmMonitoringTemplateList(MtmMonitoringTemplate mtmMonitoringTemplate); + + /** + * 新增监控模板管理 + * + * @param mtmMonitoringTemplate 监控模板管理 + * @return 结果 + */ + public int insertMtmMonitoringTemplate(MtmMonitoringTemplate mtmMonitoringTemplate); + + /** + * 修改监控模板管理 + * + * @param mtmMonitoringTemplate 监控模板管理 + * @return 结果 + */ + public int updateMtmMonitoringTemplate(MtmMonitoringTemplate mtmMonitoringTemplate); + + /** + * 批量删除监控模板管理 + * + * @param ids 需要删除的监控模板管理主键集合 + * @return 结果 + */ + public int deleteMtmMonitoringTemplateByIds(Long[] ids); + + /** + * 删除监控模板管理信息 + * + * @param id 监控模板管理主键 + * @return 结果 + */ + public int deleteMtmMonitoringTemplateById(Long id); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IRmEpsTopologyManagementService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IRmEpsTopologyManagementService.java new file mode 100644 index 0000000..d46fa23 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IRmEpsTopologyManagementService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.RmEpsTopologyManagement; + +/** + * 拓扑管理Service接口 + * + * @author gyt + * @date 2025-08-12 + */ +public interface IRmEpsTopologyManagementService +{ + /** + * 查询拓扑管理 + * + * @param id 拓扑管理主键 + * @return 拓扑管理 + */ + public RmEpsTopologyManagement selectRmEpsTopologyManagementById(Long id); + + /** + * 查询拓扑管理列表 + * + * @param rmEpsTopologyManagement 拓扑管理 + * @return 拓扑管理集合 + */ + public List selectRmEpsTopologyManagementList(RmEpsTopologyManagement rmEpsTopologyManagement); + + /** + * 新增拓扑管理 + * + * @param rmEpsTopologyManagement 拓扑管理 + * @return 结果 + */ + public int insertRmEpsTopologyManagement(RmEpsTopologyManagement rmEpsTopologyManagement); + + /** + * 修改拓扑管理 + * + * @param rmEpsTopologyManagement 拓扑管理 + * @return 结果 + */ + public int updateRmEpsTopologyManagement(RmEpsTopologyManagement rmEpsTopologyManagement); + + /** + * 批量删除拓扑管理 + * + * @param ids 需要删除的拓扑管理主键集合 + * @return 结果 + */ + public int deleteRmEpsTopologyManagementByIds(Long[] ids); + + /** + * 删除拓扑管理信息 + * + * @param id 拓扑管理主键 + * @return 结果 + */ + public int deleteRmEpsTopologyManagementById(Long id); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IRmResourceGroupService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IRmResourceGroupService.java new file mode 100644 index 0000000..72bcc36 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IRmResourceGroupService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.RmResourceGroup; + +/** + * 资源分组Service接口 + * + * @author gyt + * @date 2025-08-12 + */ +public interface IRmResourceGroupService +{ + /** + * 查询资源分组 + * + * @param id 资源分组主键 + * @return 资源分组 + */ + public RmResourceGroup selectRmResourceGroupById(Long id); + + /** + * 查询资源分组列表 + * + * @param rmResourceGroup 资源分组 + * @return 资源分组集合 + */ + public List selectRmResourceGroupList(RmResourceGroup rmResourceGroup); + + /** + * 新增资源分组 + * + * @param rmResourceGroup 资源分组 + * @return 结果 + */ + public int insertRmResourceGroup(RmResourceGroup rmResourceGroup); + + /** + * 修改资源分组 + * + * @param rmResourceGroup 资源分组 + * @return 结果 + */ + public int updateRmResourceGroup(RmResourceGroup rmResourceGroup); + + /** + * 批量删除资源分组 + * + * @param ids 需要删除的资源分组主键集合 + * @return 结果 + */ + public int deleteRmResourceGroupByIds(Long[] ids); + + /** + * 删除资源分组信息 + * + * @param id 资源分组主键 + * @return 结果 + */ + public int deleteRmResourceGroupById(Long id); +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IRmResourceRegistrationService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IRmResourceRegistrationService.java index 367c144..6c517a8 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IRmResourceRegistrationService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/IRmResourceRegistrationService.java @@ -1,8 +1,10 @@ package com.ruoyi.system.service; -import java.util.List; import com.ruoyi.system.domain.RmResourceRegistration; +import java.util.List; +import java.util.Map; + /** * 资源注册Service接口 * @@ -43,6 +45,13 @@ public interface IRmResourceRegistrationService */ public int updateRmResourceRegistration(RmResourceRegistration rmResourceRegistration); + /** + * 资源注册-注册 + * @param rmResourceRegistration + * @return + */ + public int register(RmResourceRegistration rmResourceRegistration); + /** * 批量删除资源注册 * @@ -58,4 +67,16 @@ public interface IRmResourceRegistrationService * @return 结果 */ public int deleteRmResourceRegistrationById(Long id); + + /** + * 查询所有资源名称(包含设备使用) + * @return 资源注册集合 + */ + public List selectAllResourceName(); + /** + * 查询所有资源名称 + * @return 资源注册集合 + */ + public List selectAllResourceNameByType(RmResourceRegistration resourceRegistration); + } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsBusinessServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsBusinessServiceImpl.java new file mode 100644 index 0000000..18f1649 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsBusinessServiceImpl.java @@ -0,0 +1,119 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.system.domain.EpsBusiness; +import com.ruoyi.system.mapper.EpsBusinessMapper; +import com.ruoyi.system.service.IEpsBusinessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 业务信息Service业务层处理 + * + * @author gyt + * @date 2025-08-18 + */ +@Service +public class EpsBusinessServiceImpl implements IEpsBusinessService +{ + @Autowired + private EpsBusinessMapper epsBusinessMapper; + + /** + * 查询业务信息 + * + * @param id 业务信息主键 + * @return 业务信息 + */ + @Override + public EpsBusiness selectEpsBusinessById(String id) + { + return epsBusinessMapper.selectEpsBusinessById(id); + } + + /** + * 查询业务信息列表 + * + * @param epsBusiness 业务信息 + * @return 业务信息 + */ + @Override + public List selectEpsBusinessList(EpsBusiness epsBusiness) + { + return epsBusinessMapper.selectEpsBusinessList(epsBusiness); + } + + /** + * 新增业务信息 + * + * @param epsBusiness 业务信息 + * @return 结果 + */ + @Override + public int insertEpsBusiness(EpsBusiness epsBusiness) + { + epsBusiness.setCreateTime(DateUtils.getNowDate()); + // 查询业务名称是否存在 + Integer exits = epsBusinessMapper.countByBusinessName(epsBusiness); + if(exits>0){ + return -1; + } + return epsBusinessMapper.insertEpsBusiness(epsBusiness); + } + + /** + * 修改业务信息 + * + * @param epsBusiness 业务信息 + * @return 结果 + */ + @Override + public int updateEpsBusiness(EpsBusiness epsBusiness) + { + epsBusiness.setUpdateTime(DateUtils.getNowDate()); + // 查询业务名称是否存在 + Integer exits = epsBusinessMapper.countByBusinessName(epsBusiness); + if(exits>0){ + return -1; + } + return epsBusinessMapper.updateEpsBusiness(epsBusiness); + } + + /** + * 批量删除业务信息 + * + * @param ids 需要删除的业务信息主键 + * @return 结果 + */ + @Override + public int deleteEpsBusinessByIds(String[] ids) + { + return epsBusinessMapper.deleteEpsBusinessByIds(ids); + } + + /** + * 删除业务信息信息 + * + * @param id 业务信息主键 + * @return 结果 + */ + @Override + public int deleteEpsBusinessById(String id) + { + return epsBusinessMapper.deleteEpsBusinessById(id); + } + + /** + * 验证业务名称是否存在 + * @param epsBusiness + * @return + */ + @Override + public Integer countByBusinessName(EpsBusiness epsBusiness) { + // 查询业务名称是否存在 + Integer rows = epsBusinessMapper.countByBusinessName(epsBusiness); + return rows; + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsInitialTrafficDataServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsInitialTrafficDataServiceImpl.java new file mode 100644 index 0000000..200e67f --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsInitialTrafficDataServiceImpl.java @@ -0,0 +1,164 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.system.domain.EpsInitialTrafficData; +import com.ruoyi.system.mapper.EpsInitialTrafficDataMapper; +import com.ruoyi.system.service.EpsInitialTrafficDataService; +import com.ruoyi.system.util.TableRouterUtil; +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.Transactional; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +@Service +@Slf4j +public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataService { + + + @Autowired + private EpsInitialTrafficDataMapper epsInitialTrafficDataMapper; + @Override + public void createNextMonthTables() { + LocalDate nextMonth = LocalDate.now().plusMonths(1); +// LocalDate nextMonth = LocalDate.now(); + int year = nextMonth.getYear(); + int month = nextMonth.getMonthValue(); + + // 创建流量详情表 + createTrafficDetailsTable(year, month); + // 创建流量初始表 + createTrafficStatsTable(year, month); + } + + private void createTrafficDetailsTable(int year, int month) { + createRangeTables(year, month, "eps_traffic_details", (tableName) -> { + epsInitialTrafficDataMapper.createEpsTrafficTable(tableName); + }); + } + + private void createTrafficStatsTable(int year, int month) { + createRangeTables(year, month, "initial_bandwidth_traffic", (tableName) -> { + epsInitialTrafficDataMapper.createEpsInitialTrafficTable(tableName); + }); + } + + + /** + * 通用创建表方法 + * @param year 年份 + * @param month 月份 + * @param tablePrefix 表前缀 + * @param creator 表创建函数 + */ + private void createRangeTables(int year, int month, String tablePrefix, Consumer creator) { + String[] ranges = {"1_10", "11_20", "21_31"}; + + for (String range : ranges) { + String tableName = String.format("%s_%d_%02d_%s", tablePrefix, year, month, range); + try { + creator.accept(tableName); + log.info("成功创建表: {}", tableName); + } catch (Exception e) { + log.error("创建表失败: {}", tableName, e); + } + } + } + /** + * 保存单条数据到对应分表 + * @param data 流量数据 + */ + @Override + @Transactional + public void save(EpsInitialTrafficData data) { + if (data.getCreateTime() == null) { + data.setCreateTime(LocalDateTime.now()); + } + data.setTableName(TableRouterUtil.getTableName(data.getCreateTime())); + epsInitialTrafficDataMapper.insert(data); + } + + /** + * 批量保存数据到对应分表 + * @param epsInitialTrafficData 流量数据表 + */ + @Override + @Transactional + public void saveBatch(EpsInitialTrafficData epsInitialTrafficData) { + if (epsInitialTrafficData == null) { + return; + } + List dataList = epsInitialTrafficData.getDataList(); + if (dataList.isEmpty()){ + return; + } + // 按表名分组批量插入 + Map> groupedData = dataList.stream() + .map(data -> { + try { + EpsInitialTrafficData processed = new EpsInitialTrafficData(); + BeanUtils.copyProperties(data,processed); + if (data.getCreateTime() == null) { + data.setCreateTime(LocalDateTime.now()); + } + processed.setTableName(TableRouterUtil.getTableName(data.getCreateTime())); + return processed; + } catch (Exception e){ + log.error("数据处理失败",e.getMessage()); + return null; + } + }).collect(Collectors.groupingBy( + EpsInitialTrafficData::getTableName, + LinkedHashMap::new, // 保持插入顺序 + Collectors.toList())); + + groupedData.forEach((tableName, list) -> { + try { + EpsInitialTrafficData data = new EpsInitialTrafficData(); + BeanUtils.copyProperties(epsInitialTrafficData,data); + data.setTableName(tableName); + data.setDataList(list); + epsInitialTrafficDataMapper.batchInsert(data); + } catch (Exception e) { + log.error("表{}插入失败", tableName, e); + throw new RuntimeException("批量插入失败", e); + } + }); + } + /** + * 查询流量数据 + */ + @Override + public List query(EpsInitialTrafficData queryParam) { + // 参数校验 +// if (StringUtils.isBlank(queryParam.getDeviceSn())) { +// throw new IllegalArgumentException("设备序列号不能为空"); +// } + + // 获取涉及的表名 + Set tableNames = TableRouterUtil.getTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime()); + + // 并行查询各表 + return tableNames.parallelStream() + .flatMap(tableName -> { + EpsInitialTrafficData condition = new EpsInitialTrafficData(); + condition.setTableName(tableName); + condition.setDeviceSn(queryParam.getDeviceSn()); + condition.setStartTime(queryParam.getStartTime()); + condition.setEndTime(queryParam.getEndTime()); + condition.setReceiveTraffic(queryParam.getReceiveTraffic()); + condition.setSendTraffic(queryParam.getSendTraffic()); + return epsInitialTrafficDataMapper.selectByCondition(condition).stream(); + }) + .collect(Collectors.toList()); + } + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsMethodChangeRecordServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsMethodChangeRecordServiceImpl.java new file mode 100644 index 0000000..a18a2e9 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsMethodChangeRecordServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; +import com.ruoyi.common.core.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.EpsMethodChangeRecordMapper; +import com.ruoyi.system.domain.EpsMethodChangeRecord; +import com.ruoyi.system.service.IEpsMethodChangeRecordService; + +/** + * 收益方式修改记录Service业务层处理 + * + * @author gyt + * @date 2025-08-15 + */ +@Service +public class EpsMethodChangeRecordServiceImpl implements IEpsMethodChangeRecordService +{ + @Autowired + private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper; + + /** + * 查询收益方式修改记录 + * + * @param id 收益方式修改记录主键 + * @return 收益方式修改记录 + */ + @Override + public EpsMethodChangeRecord selectEpsMethodChangeRecordById(Long id) + { + return epsMethodChangeRecordMapper.selectEpsMethodChangeRecordById(id); + } + + /** + * 查询收益方式修改记录列表 + * + * @param epsMethodChangeRecord 收益方式修改记录 + * @return 收益方式修改记录 + */ + @Override + public List selectEpsMethodChangeRecordList(EpsMethodChangeRecord epsMethodChangeRecord) + { + return epsMethodChangeRecordMapper.selectEpsMethodChangeRecordList(epsMethodChangeRecord); + } + + /** + * 新增收益方式修改记录 + * + * @param epsMethodChangeRecord 收益方式修改记录 + * @return 结果 + */ + @Override + public int insertEpsMethodChangeRecord(EpsMethodChangeRecord epsMethodChangeRecord) + { + epsMethodChangeRecord.setCreateTime(DateUtils.getNowDate()); + return epsMethodChangeRecordMapper.insertEpsMethodChangeRecord(epsMethodChangeRecord); + } + + /** + * 修改收益方式修改记录 + * + * @param epsMethodChangeRecord 收益方式修改记录 + * @return 结果 + */ + @Override + public int updateEpsMethodChangeRecord(EpsMethodChangeRecord epsMethodChangeRecord) + { + epsMethodChangeRecord.setUpdateTime(DateUtils.getNowDate()); + return epsMethodChangeRecordMapper.updateEpsMethodChangeRecord(epsMethodChangeRecord); + } + + /** + * 批量删除收益方式修改记录 + * + * @param ids 需要删除的收益方式修改记录主键 + * @return 结果 + */ + @Override + public int deleteEpsMethodChangeRecordByIds(Long[] ids) + { + return epsMethodChangeRecordMapper.deleteEpsMethodChangeRecordByIds(ids); + } + + /** + * 删除收益方式修改记录信息 + * + * @param id 收益方式修改记录主键 + * @return 结果 + */ + @Override + public int deleteEpsMethodChangeRecordById(Long id) + { + return epsMethodChangeRecordMapper.deleteEpsMethodChangeRecordById(id); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsNodeBandwidthServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsNodeBandwidthServiceImpl.java new file mode 100644 index 0000000..bfe10f2 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsNodeBandwidthServiceImpl.java @@ -0,0 +1,212 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.system.domain.EpsInitialTrafficData; +import com.ruoyi.system.domain.EpsNodeBandwidth; +import com.ruoyi.system.mapper.EpsNodeBandwidthMapper; +import com.ruoyi.system.service.EpsInitialTrafficDataService; +import com.ruoyi.system.service.IEpsNodeBandwidthService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.webjars.NotFoundException; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.*; +import java.util.Date; +import java.util.List; + +/** + * 节点带宽信息Service业务层处理 + * + * @author gyt + * @date 2025-08-12 + */ +@Service +public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService +{ + @Autowired + private EpsNodeBandwidthMapper epsNodeBandwidthMapper; + @Autowired + private EpsInitialTrafficDataService epsInitialTrafficDataService; + + /** + * 查询节点带宽信息 + * + * @param id 节点带宽信息主键 + * @return 节点带宽信息 + */ + @Override + public EpsNodeBandwidth selectEpsNodeBandwidthById(Long id) + { + return epsNodeBandwidthMapper.selectEpsNodeBandwidthById(id); + } + + /** + * 查询节点带宽信息 + * + * @param id 节点带宽信息主键 + * @return 节点带宽信息 + */ + @Override + public List relatedData(Long id) + { + // 1. 根据ID查询服务器信息 + EpsNodeBandwidth epsNodeBandwidth = epsNodeBandwidthMapper.selectEpsNodeBandwidthById(id); + if (epsNodeBandwidth == null) { + throw new NotFoundException("未找到ID为" + id + "的服务器信息"); + } + + // 2. 设置查询条件 + EpsInitialTrafficData queryParams = new EpsInitialTrafficData(); + queryParams.setDeviceSn(epsNodeBandwidth.getHardwareSn()); + + // 3. 根据带宽类型设置时间范围 + LocalDateTime createTime = dateToLocalDateTime(epsNodeBandwidth.getCreateTime()); + setTimeRangeByBandwidthType(queryParams, epsNodeBandwidth.getBandwidthType(), createTime); + + // 4. 查询并返回数据 + return epsInitialTrafficDataService.query(queryParams); + } + /** + * 查询节点带宽信息列表 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 节点带宽信息 + */ + @Override + public List selectEpsNodeBandwidthList(EpsNodeBandwidth epsNodeBandwidth) + { + return epsNodeBandwidthMapper.selectEpsNodeBandwidthList(epsNodeBandwidth); + } + + /** + * 新增节点带宽信息 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 结果 + */ + @Override + public int insertEpsNodeBandwidth(EpsNodeBandwidth epsNodeBandwidth) + { + epsNodeBandwidth.setCreateTime(DateUtils.getNowDate()); + return epsNodeBandwidthMapper.insertEpsNodeBandwidth(epsNodeBandwidth); + } + + /** + * 修改节点带宽信息 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 结果 + */ + @Override + public int updateEpsNodeBandwidth(EpsNodeBandwidth epsNodeBandwidth) + { + epsNodeBandwidth.setUpdateTime(DateUtils.getNowDate()); + return epsNodeBandwidthMapper.updateEpsNodeBandwidth(epsNodeBandwidth); + } + + /** + * 批量删除节点带宽信息 + * + * @param ids 需要删除的节点带宽信息主键 + * @return 结果 + */ + @Override + public int deleteEpsNodeBandwidthByIds(Long[] ids) + { + return epsNodeBandwidthMapper.deleteEpsNodeBandwidthByIds(ids); + } + + /** + * 删除节点带宽信息信息 + * + * @param id 节点带宽信息主键 + * @return 结果 + */ + @Override + public int deleteEpsNodeBandwidthById(Long id) + { + return epsNodeBandwidthMapper.deleteEpsNodeBandwidthById(id); + } + + /** + * 计算月均日95值 + * + * @param epsNodeBandwidth 节点带宽信息 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int calculateAvg(EpsNodeBandwidth epsNodeBandwidth) { + // 验证是否已经存在记录 + List existingRecords = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(epsNodeBandwidth); + + EpsNodeBandwidth calculatedData = epsNodeBandwidthMapper.calculateAvg(epsNodeBandwidth); + // 日95值总和 + BigDecimal sum95Daily = calculatedData.getBandwidth95Daily(); + // 日有效95值总和 + BigDecimal sumEffectiveBandwidth95Daily = calculatedData.getEffectiveBandwidth95Daily(); + // 计算当月天数并求平均值 + LocalDate monthTime = epsNodeBandwidth.getMonthTime(); + int daysInMonth = YearMonth.from(monthTime).lengthOfMonth(); + // 月均日95值 + BigDecimal avgMonthlyBandwidth95 = daysInMonth == 0 ? BigDecimal.ZERO : + sum95Daily.divide(BigDecimal.valueOf(daysInMonth), 2, RoundingMode.HALF_UP); + epsNodeBandwidth.setAvgMonthlyBandwidth95(avgMonthlyBandwidth95); + // 有效-月均日95值 + BigDecimal effectiveAvgMonthlyBandwidth95 = daysInMonth == 0 ? BigDecimal.ZERO : + sumEffectiveBandwidth95Daily.divide(BigDecimal.valueOf(daysInMonth), 2, RoundingMode.HALF_UP); + epsNodeBandwidth.setEffectiveAvgMonthlyBandwidth95(effectiveAvgMonthlyBandwidth95); + + // 根据是否存在记录执行更新或插入操作 + return existingRecords.isEmpty() ? + epsNodeBandwidthMapper.insertEpsNodeBandwidth(epsNodeBandwidth) : + epsNodeBandwidthMapper.updateEpsNodeBandwidth(epsNodeBandwidth); + } + + @Override + public List getAvgDetailMsg(Long id) { + // 1. 根据ID查询服务器信息 + EpsNodeBandwidth epsNodeBandwidth = epsNodeBandwidthMapper.selectEpsNodeBandwidthById(id); + if (epsNodeBandwidth == null) { + throw new NotFoundException("未找到ID为" + id + "的服务器信息"); + } + return epsNodeBandwidthMapper.getAvgDetailMsg(epsNodeBandwidth); + } + + /** + * Date 类型 转为 LocalDateTime 类型 + * @param date + * @return + */ + public static LocalDateTime dateToLocalDateTime(Date date) { + return date.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDateTime(); + } + /** + * 根据带宽类型设置时间范围 + */ + private void setTimeRangeByBandwidthType(EpsInitialTrafficData data, String bandwidthType, LocalDateTime baseTime) { + switch (bandwidthType) { + case "1": + case "3": + case "5": // 日带宽 + data.setStartTime(baseTime.with(LocalTime.MIN)); // 00:00:00 + data.setEndTime(baseTime.with(LocalTime.MAX).withNano(0)); // 23:59:59 + break; + case "2": + case "4": + case "6": + case "7": // 月带宽 + YearMonth month = YearMonth.from(baseTime); + data.setStartTime(month.atDay(1).atStartOfDay()); // 当月第一天 00:00:00 + data.setEndTime(month.atEndOfMonth().atTime(23, 59, 59)); // 当月最后一天 23:59:59 + break; + default: + throw new IllegalArgumentException("不支持的带宽类型: " + bandwidthType); + } + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsServerRevenueConfigServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsServerRevenueConfigServiceImpl.java new file mode 100644 index 0000000..ecfc6d7 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsServerRevenueConfigServiceImpl.java @@ -0,0 +1,147 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.system.domain.EpsMethodChangeRecord; +import com.ruoyi.system.domain.EpsServerRevenueConfig; +import com.ruoyi.system.mapper.EpsServerRevenueConfigMapper; +import com.ruoyi.system.service.IEpsServerRevenueConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 服务器收益方式配置Service业务层处理 + * + * @author gyt + * @date 2025-08-19 + */ +@Service +public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfigService +{ + @Autowired + private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper; + + /** + * 查询服务器收益方式配置 + * + * @param id 服务器收益方式配置主键 + * @return 服务器收益方式配置 + */ + @Override + public EpsServerRevenueConfig selectEpsServerRevenueConfigById(Long id) + { + return epsServerRevenueConfigMapper.selectEpsServerRevenueConfigById(id); + } + + /** + * 查询服务器收益方式配置列表 + * + * @param epsServerRevenueConfig 服务器收益方式配置 + * @return 服务器收益方式配置 + */ + @Override + public List selectEpsServerRevenueConfigList(EpsServerRevenueConfig epsServerRevenueConfig) + { + return epsServerRevenueConfigMapper.selectEpsServerRevenueConfigList(epsServerRevenueConfig); + } + + /** + * 新增服务器收益方式配置 + * + * @param epsServerRevenueConfig 服务器收益方式配置 + * @return 结果 + */ + @Override + public int insertEpsServerRevenueConfig(EpsServerRevenueConfig epsServerRevenueConfig) + { + epsServerRevenueConfig.setCreateTime(DateUtils.getNowDate()); + return epsServerRevenueConfigMapper.insertEpsServerRevenueConfig(epsServerRevenueConfig); + } + + /** + * 修改服务器收益方式配置 + * + * @param epsServerRevenueConfig 服务器收益方式配置 + * @return 结果 + */ + @Override + public int updateEpsServerRevenueConfig(EpsServerRevenueConfig epsServerRevenueConfig) + { + epsServerRevenueConfig.setUpdateTime(DateUtils.getNowDate()); + //原来的收益方式 + EpsServerRevenueConfig serverRevenueConfig = epsServerRevenueConfigMapper.selectEpsServerRevenueConfigById(epsServerRevenueConfig.getId()); + String revenueMethod = getMethodName(serverRevenueConfig.getRevenueMethod()); + //现在的收益方式 + String nowRevenueMethod = getMethodName(epsServerRevenueConfig.getRevenueMethod()); + // 修改条数 + int rows = epsServerRevenueConfigMapper.updateEpsServerRevenueConfig(epsServerRevenueConfig); + if(rows>=0){ + EpsMethodChangeRecord epsMethodChangeRecord = new EpsMethodChangeRecord(); + // 节点名称 + epsMethodChangeRecord.setNodeName(epsServerRevenueConfig.getNodeName()); + // 硬件sn + epsMethodChangeRecord.setHardwareSn(epsServerRevenueConfig.getHardwareSn()); + // 修改时间 + epsMethodChangeRecord.setCreateTime(DateUtils.getNowDate()); + // 修改人 + epsMethodChangeRecord.setCreatBy(SecurityUtils.getUsername()); + // 修改内容 + String content = ""; + if("流量".equals(nowRevenueMethod)){ + // 修改内容 + content = "收益方式变为【"+nowRevenueMethod+"】,流量网口设置为"+epsServerRevenueConfig.getTrafficPort()+ + ",业务为"+epsServerRevenueConfig.getBusinessName(); + } + if("包端".equals(nowRevenueMethod)){ + // 修改内容 + content = "收益方式变为【"+nowRevenueMethod+"】,流量网口设置为"+epsServerRevenueConfig.getTrafficPort()+ + ",带宽值设置为"+epsServerRevenueConfig.getPackageBandwidth()+"Mbps,"+"业务为"+epsServerRevenueConfig.getBusinessName(); + } + epsMethodChangeRecord.setChangeContent(content); + // 添加操作记录 + epsServerRevenueConfigMapper.insertEpsServerRevenueConfig(epsServerRevenueConfig); + } + return rows; + } + + /** + * 批量删除服务器收益方式配置 + * + * @param ids 需要删除的服务器收益方式配置主键 + * @return 结果 + */ + @Override + public int deleteEpsServerRevenueConfigByIds(Long[] ids) + { + return epsServerRevenueConfigMapper.deleteEpsServerRevenueConfigByIds(ids); + } + + /** + * 删除服务器收益方式配置信息 + * + * @param id 服务器收益方式配置主键 + * @return 结果 + */ + @Override + public int deleteEpsServerRevenueConfigById(Long id) + { + return epsServerRevenueConfigMapper.deleteEpsServerRevenueConfigById(id); + } + /** + * 把收益方式转化为文字 + * @param method + * @return + */ + public String getMethodName(String method){ + String revenueMethod = ""; + if("1".equals(method)){ + revenueMethod = "流量"; + } + if("2".equals(method)){ + revenueMethod = "包端"; + } + return revenueMethod; + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsTrafficDataServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsTrafficDataServiceImpl.java new file mode 100644 index 0000000..fa33e39 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/EpsTrafficDataServiceImpl.java @@ -0,0 +1,118 @@ +package com.ruoyi.system.service.impl; + +import com.ruoyi.common.core.utils.DateUtils; +import com.ruoyi.system.domain.EpsTrafficData; +import com.ruoyi.system.mapper.EpsMethodChangeRecordMapper; +import com.ruoyi.system.mapper.EpsTrafficDataMapper; +import com.ruoyi.system.service.IEpsTrafficDataService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 流量相关数据Service业务层处理 + * + * @author gyt + * @date 2025-08-12 + */ +@Service +public class EpsTrafficDataServiceImpl implements IEpsTrafficDataService +{ + @Autowired + private EpsTrafficDataMapper epsTrafficDataMapper; + @Autowired + private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper; + + /** + * 查询流量相关数据 + * + * @param id 流量相关数据主键 + * @return 流量相关数据 + */ + @Override + public EpsTrafficData selectEpsTrafficDataById(Long id) + { + return epsTrafficDataMapper.selectEpsTrafficDataById(id); + } + + /** + * 查询流量相关数据列表 + * + * @param epsTrafficData 流量相关数据 + * @return 流量相关数据 + */ + @Override + public List selectEpsTrafficDataList(EpsTrafficData epsTrafficData) + { + return epsTrafficDataMapper.selectEpsTrafficDataList(epsTrafficData); + } + + /** + * 新增流量相关数据 + * + * @param epsTrafficData 流量相关数据 + * @return 结果 + */ + @Override + public int insertEpsTrafficData(EpsTrafficData epsTrafficData) + { + epsTrafficData.setCreateTime(DateUtils.getNowDate()); + return epsTrafficDataMapper.insertEpsTrafficData(epsTrafficData); + } + + /** + * 修改流量相关数据 + * + * @param epsTrafficData 流量相关数据 + * @return 结果 + */ + @Override + public int updateEpsTrafficData(EpsTrafficData epsTrafficData) + { + epsTrafficData.setUpdateTime(DateUtils.getNowDate()); + // 修改条数 + int rows = epsTrafficDataMapper.updateEpsTrafficData(epsTrafficData); + return rows; + } + + /** + * 批量删除流量相关数据 + * + * @param ids 需要删除的流量相关数据主键 + * @return 结果 + */ + @Override + public int deleteEpsTrafficDataByIds(Long[] ids) + { + return epsTrafficDataMapper.deleteEpsTrafficDataByIds(ids); + } + + /** + * 删除流量相关数据信息 + * + * @param id 流量相关数据主键 + * @return 结果 + */ + @Override + public int deleteEpsTrafficDataById(Long id) + { + return epsTrafficDataMapper.deleteEpsTrafficDataById(id); + } + + /** + * 把收益方式转化为文字 + * @param method + * @return + */ + public String getMethodName(String method){ + String revenueMethod = ""; + if("1".equals(method)){ + revenueMethod = "流量"; + } + if("2".equals(method)){ + revenueMethod = "包端"; + } + return revenueMethod; + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/KnowledgeBaseServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/KnowledgeBaseServiceImpl.java new file mode 100644 index 0000000..eb6944d --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/KnowledgeBaseServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; +import com.ruoyi.common.core.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.KnowledgeBaseMapper; +import com.ruoyi.system.domain.KnowledgeBase; +import com.ruoyi.system.service.IKnowledgeBaseService; + +/** + * 知识库Service业务层处理 + * + * @author gyt + * @date 2025-08-15 + */ +@Service +public class KnowledgeBaseServiceImpl implements IKnowledgeBaseService +{ + @Autowired + private KnowledgeBaseMapper knowledgeBaseMapper; + + /** + * 查询知识库 + * + * @param id 知识库主键 + * @return 知识库 + */ + @Override + public KnowledgeBase selectKnowledgeBaseById(Long id) + { + return knowledgeBaseMapper.selectKnowledgeBaseById(id); + } + + /** + * 查询知识库列表 + * + * @param knowledgeBase 知识库 + * @return 知识库 + */ + @Override + public List selectKnowledgeBaseList(KnowledgeBase knowledgeBase) + { + return knowledgeBaseMapper.selectKnowledgeBaseList(knowledgeBase); + } + + /** + * 新增知识库 + * + * @param knowledgeBase 知识库 + * @return 结果 + */ + @Override + public int insertKnowledgeBase(KnowledgeBase knowledgeBase) + { + knowledgeBase.setCreateTime(DateUtils.getNowDate()); + return knowledgeBaseMapper.insertKnowledgeBase(knowledgeBase); + } + + /** + * 修改知识库 + * + * @param knowledgeBase 知识库 + * @return 结果 + */ + @Override + public int updateKnowledgeBase(KnowledgeBase knowledgeBase) + { + knowledgeBase.setUpdateTime(DateUtils.getNowDate()); + return knowledgeBaseMapper.updateKnowledgeBase(knowledgeBase); + } + + /** + * 批量删除知识库 + * + * @param ids 需要删除的知识库主键 + * @return 结果 + */ + @Override + public int deleteKnowledgeBaseByIds(Long[] ids) + { + return knowledgeBaseMapper.deleteKnowledgeBaseByIds(ids); + } + + /** + * 删除知识库信息 + * + * @param id 知识库主键 + * @return 结果 + */ + @Override + public int deleteKnowledgeBaseById(Long id) + { + return knowledgeBaseMapper.deleteKnowledgeBaseById(id); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MtmMonitoringTemplateServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MtmMonitoringTemplateServiceImpl.java new file mode 100644 index 0000000..a2d81b9 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MtmMonitoringTemplateServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; +import com.ruoyi.common.core.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.MtmMonitoringTemplateMapper; +import com.ruoyi.system.domain.MtmMonitoringTemplate; +import com.ruoyi.system.service.IMtmMonitoringTemplateService; + +/** + * 监控模板管理Service业务层处理 + * + * @author gyt + * @date 2025-08-12 + */ +@Service +public class MtmMonitoringTemplateServiceImpl implements IMtmMonitoringTemplateService +{ + @Autowired + private MtmMonitoringTemplateMapper mtmMonitoringTemplateMapper; + + /** + * 查询监控模板管理 + * + * @param id 监控模板管理主键 + * @return 监控模板管理 + */ + @Override + public MtmMonitoringTemplate selectMtmMonitoringTemplateById(Long id) + { + return mtmMonitoringTemplateMapper.selectMtmMonitoringTemplateById(id); + } + + /** + * 查询监控模板管理列表 + * + * @param mtmMonitoringTemplate 监控模板管理 + * @return 监控模板管理 + */ + @Override + public List selectMtmMonitoringTemplateList(MtmMonitoringTemplate mtmMonitoringTemplate) + { + return mtmMonitoringTemplateMapper.selectMtmMonitoringTemplateList(mtmMonitoringTemplate); + } + + /** + * 新增监控模板管理 + * + * @param mtmMonitoringTemplate 监控模板管理 + * @return 结果 + */ + @Override + public int insertMtmMonitoringTemplate(MtmMonitoringTemplate mtmMonitoringTemplate) + { + mtmMonitoringTemplate.setCreateTime(DateUtils.getNowDate()); + return mtmMonitoringTemplateMapper.insertMtmMonitoringTemplate(mtmMonitoringTemplate); + } + + /** + * 修改监控模板管理 + * + * @param mtmMonitoringTemplate 监控模板管理 + * @return 结果 + */ + @Override + public int updateMtmMonitoringTemplate(MtmMonitoringTemplate mtmMonitoringTemplate) + { + mtmMonitoringTemplate.setUpdateTime(DateUtils.getNowDate()); + return mtmMonitoringTemplateMapper.updateMtmMonitoringTemplate(mtmMonitoringTemplate); + } + + /** + * 批量删除监控模板管理 + * + * @param ids 需要删除的监控模板管理主键 + * @return 结果 + */ + @Override + public int deleteMtmMonitoringTemplateByIds(Long[] ids) + { + return mtmMonitoringTemplateMapper.deleteMtmMonitoringTemplateByIds(ids); + } + + /** + * 删除监控模板管理信息 + * + * @param id 监控模板管理主键 + * @return 结果 + */ + @Override + public int deleteMtmMonitoringTemplateById(Long id) + { + return mtmMonitoringTemplateMapper.deleteMtmMonitoringTemplateById(id); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmEpsTopologyManagementServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmEpsTopologyManagementServiceImpl.java new file mode 100644 index 0000000..e3f0da4 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmEpsTopologyManagementServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; +import com.ruoyi.common.core.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.RmEpsTopologyManagementMapper; +import com.ruoyi.system.domain.RmEpsTopologyManagement; +import com.ruoyi.system.service.IRmEpsTopologyManagementService; + +/** + * 拓扑管理Service业务层处理 + * + * @author gyt + * @date 2025-08-12 + */ +@Service +public class RmEpsTopologyManagementServiceImpl implements IRmEpsTopologyManagementService +{ + @Autowired + private RmEpsTopologyManagementMapper rmEpsTopologyManagementMapper; + + /** + * 查询拓扑管理 + * + * @param id 拓扑管理主键 + * @return 拓扑管理 + */ + @Override + public RmEpsTopologyManagement selectRmEpsTopologyManagementById(Long id) + { + return rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementById(id); + } + + /** + * 查询拓扑管理列表 + * + * @param rmEpsTopologyManagement 拓扑管理 + * @return 拓扑管理 + */ + @Override + public List selectRmEpsTopologyManagementList(RmEpsTopologyManagement rmEpsTopologyManagement) + { + return rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(rmEpsTopologyManagement); + } + + /** + * 新增拓扑管理 + * + * @param rmEpsTopologyManagement 拓扑管理 + * @return 结果 + */ + @Override + public int insertRmEpsTopologyManagement(RmEpsTopologyManagement rmEpsTopologyManagement) + { + rmEpsTopologyManagement.setCreateTime(DateUtils.getNowDate()); + return rmEpsTopologyManagementMapper.insertRmEpsTopologyManagement(rmEpsTopologyManagement); + } + + /** + * 修改拓扑管理 + * + * @param rmEpsTopologyManagement 拓扑管理 + * @return 结果 + */ + @Override + public int updateRmEpsTopologyManagement(RmEpsTopologyManagement rmEpsTopologyManagement) + { + rmEpsTopologyManagement.setUpdateTime(DateUtils.getNowDate()); + return rmEpsTopologyManagementMapper.updateRmEpsTopologyManagement(rmEpsTopologyManagement); + } + + /** + * 批量删除拓扑管理 + * + * @param ids 需要删除的拓扑管理主键 + * @return 结果 + */ + @Override + public int deleteRmEpsTopologyManagementByIds(Long[] ids) + { + return rmEpsTopologyManagementMapper.deleteRmEpsTopologyManagementByIds(ids); + } + + /** + * 删除拓扑管理信息 + * + * @param id 拓扑管理主键 + * @return 结果 + */ + @Override + public int deleteRmEpsTopologyManagementById(Long id) + { + return rmEpsTopologyManagementMapper.deleteRmEpsTopologyManagementById(id); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmResourceGroupServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmResourceGroupServiceImpl.java new file mode 100644 index 0000000..61a27a0 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmResourceGroupServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; +import com.ruoyi.common.core.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.RmResourceGroupMapper; +import com.ruoyi.system.domain.RmResourceGroup; +import com.ruoyi.system.service.IRmResourceGroupService; + +/** + * 资源分组Service业务层处理 + * + * @author gyt + * @date 2025-08-12 + */ +@Service +public class RmResourceGroupServiceImpl implements IRmResourceGroupService +{ + @Autowired + private RmResourceGroupMapper rmResourceGroupMapper; + + /** + * 查询资源分组 + * + * @param id 资源分组主键 + * @return 资源分组 + */ + @Override + public RmResourceGroup selectRmResourceGroupById(Long id) + { + return rmResourceGroupMapper.selectRmResourceGroupById(id); + } + + /** + * 查询资源分组列表 + * + * @param rmResourceGroup 资源分组 + * @return 资源分组 + */ + @Override + public List selectRmResourceGroupList(RmResourceGroup rmResourceGroup) + { + return rmResourceGroupMapper.selectRmResourceGroupList(rmResourceGroup); + } + + /** + * 新增资源分组 + * + * @param rmResourceGroup 资源分组 + * @return 结果 + */ + @Override + public int insertRmResourceGroup(RmResourceGroup rmResourceGroup) + { + rmResourceGroup.setCreateTime(DateUtils.getNowDate()); + return rmResourceGroupMapper.insertRmResourceGroup(rmResourceGroup); + } + + /** + * 修改资源分组 + * + * @param rmResourceGroup 资源分组 + * @return 结果 + */ + @Override + public int updateRmResourceGroup(RmResourceGroup rmResourceGroup) + { + rmResourceGroup.setUpdateTime(DateUtils.getNowDate()); + return rmResourceGroupMapper.updateRmResourceGroup(rmResourceGroup); + } + + /** + * 批量删除资源分组 + * + * @param ids 需要删除的资源分组主键 + * @return 结果 + */ + @Override + public int deleteRmResourceGroupByIds(Long[] ids) + { + return rmResourceGroupMapper.deleteRmResourceGroupByIds(ids); + } + + /** + * 删除资源分组信息 + * + * @param id 资源分组主键 + * @return 结果 + */ + @Override + public int deleteRmResourceGroupById(Long id) + { + return rmResourceGroupMapper.deleteRmResourceGroupById(id); + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmResourceRegistrationServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmResourceRegistrationServiceImpl.java index 8181288..061ece0 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmResourceRegistrationServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RmResourceRegistrationServiceImpl.java @@ -1,14 +1,17 @@ package com.ruoyi.system.service.impl; -import java.util.List; import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.security.utils.SecurityUtils; -import com.ruoyi.system.mapper.SysDictDataMapper; +import com.ruoyi.system.domain.EpsServerRevenueConfig; +import com.ruoyi.system.domain.RmResourceRegistration; +import com.ruoyi.system.mapper.EpsServerRevenueConfigMapper; +import com.ruoyi.system.mapper.RmResourceRegistrationMapper; +import com.ruoyi.system.service.IRmResourceRegistrationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.ruoyi.system.mapper.RmResourceRegistrationMapper; -import com.ruoyi.system.domain.RmResourceRegistration; -import com.ruoyi.system.service.IRmResourceRegistrationService; + +import java.util.List; +import java.util.Map; /** * 资源注册Service业务层处理 @@ -22,7 +25,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio @Autowired private RmResourceRegistrationMapper rmResourceRegistrationMapper; @Autowired - private SysDictDataMapper sysDictDataMapper; + private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper; /** * 查询资源注册 @@ -61,6 +64,11 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio rmResourceRegistration.setCreatorId(SecurityUtils.getUserId()); rmResourceRegistration.setCreatorName(SecurityUtils.getUsername()); rmResourceRegistration.setCreateTime(DateUtils.getNowDate()); + // 查询此硬件sn是否已存在 + int exits = rmResourceRegistrationMapper.countBySn(rmResourceRegistration.getHardwareSn()); + if(exits>0){ + return -1; + } return rmResourceRegistrationMapper.insertRmResourceRegistration(rmResourceRegistration); } @@ -76,9 +84,63 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio rmResourceRegistration.setUpdateTime(DateUtils.getNowDate()); rmResourceRegistration.setUpdaterId(SecurityUtils.getUserId()); rmResourceRegistration.setUpdaterName(SecurityUtils.getUsername()); + // 禁止修改sn序列号 + rmResourceRegistration.setHardwareSn(null); + // 已注册状态修改--仅可修改资源名称,描述 + if ("1".equals(rmResourceRegistration.getRegistrationStatus())){ + // 拿到需要修改的id + Long id = rmResourceRegistration.getId(); + // 拿到需要修改的资源名称 + String resourceName = rmResourceRegistration.getResourceName(); + // 拿到需要修改的描述 + String description = rmResourceRegistration.getDescription(); + // 初始化 + rmResourceRegistration = new RmResourceRegistration(); + // id赋值 + rmResourceRegistration.setId(id); + // 可修改资源名称 + rmResourceRegistration.setResourceName(resourceName); + // 可修改描述 + rmResourceRegistration.setDescription(description); + + } return rmResourceRegistrationMapper.updateRmResourceRegistration(rmResourceRegistration); } + /** + * 资源注册-注册 + * + * @param rmResourceRegistration 资源注册 + * @return 结果 + */ + @Override + public int register(RmResourceRegistration rmResourceRegistration) + { + rmResourceRegistration.setUpdateTime(DateUtils.getNowDate()); + rmResourceRegistration.setUpdaterId(SecurityUtils.getUserId()); + rmResourceRegistration.setUpdaterName(SecurityUtils.getUsername()); + if("1".equals(rmResourceRegistration.getResourceType())){ + // 注册服务器 添加到服务器收益配置表 + EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig(); + epsServerRevenueConfig.setHardwareSn(rmResourceRegistration.getHardwareSn()); + epsServerRevenueConfig.setNodeName(rmResourceRegistration.getResourceName()); + epsServerRevenueConfig.setCreateTime(DateUtils.getNowDate()); + // 新增前判断是否存在 + int exits = epsServerRevenueConfigMapper.countBySn(epsServerRevenueConfig.getHardwareSn()); + if(exits>0){ + // 存在 修改 + epsServerRevenueConfigMapper.updateEpsServerRevenueConfig(epsServerRevenueConfig); + }else{ + // 不存在 新增 + epsServerRevenueConfigMapper.insertEpsServerRevenueConfig(epsServerRevenueConfig); + } + } + // 仅注册 + RmResourceRegistration resourceRegistration = new RmResourceRegistration(); + resourceRegistration.setId(rmResourceRegistration.getId()); + resourceRegistration.setRegistrationStatus(rmResourceRegistration.getRegistrationStatus()); + return rmResourceRegistrationMapper.updateRmResourceRegistration(resourceRegistration); + } /** * 批量删除资源注册 * @@ -102,4 +164,15 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio { return rmResourceRegistrationMapper.deleteRmResourceRegistrationById(id); } + @Override + public List selectAllResourceName() + { + return rmResourceRegistrationMapper.selectAllResourceName(); + } + @Override + public List selectAllResourceNameByType(RmResourceRegistration resourceRegistration) + { + return rmResourceRegistrationMapper.selectAllResourceNameByType(resourceRegistration); + } + } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/util/TableRouterUtil.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/util/TableRouterUtil.java new file mode 100644 index 0000000..fcd1793 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/util/TableRouterUtil.java @@ -0,0 +1,87 @@ +package com.ruoyi.system.util; + + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.LinkedHashSet; +import java.util.Set; + +/** + * 获取表明util + */ +public class TableRouterUtil { + + // 表名前缀 + private static final String TABLE_PREFIX = "eps_initial_traffic"; + + // 日期格式 + private static final DateTimeFormatter YEAR_MONTH_FORMAT = + DateTimeFormatter.ofPattern("yyyy_MM"); + + /** + * 根据创建时间获取表名 + * @param createTime 记录创建时间 + * @return 对应的分表名称 + * @throws IllegalArgumentException 如果createTime为null + * + * 示例: + * 2023-08-05 14:30:00 → eps_initial_traffic_2023_08_1_10 + * 2023-08-15 09:15:00 → eps_initial_traffic_2023_08_11_20 + * 2023-08-25 18:45:00 → eps_initial_traffic_2023_08_21_31 + */ + public static String getTableName(LocalDateTime createTime) { + if (createTime == null) { + throw new IllegalArgumentException("创建时间不能为null"); + } + + String yearMonth = createTime.format(YEAR_MONTH_FORMAT); + int day = createTime.getDayOfMonth(); + + return String.format("%s_%s_%s", + TABLE_PREFIX, + yearMonth, + getDayRange(day)); + } + + /** + * 获取时间范围内涉及的所有表名 + * @param startTime 开始时间(包含) + * @param endTime 结束时间(包含) + * @return 按时间顺序排列的表名集合 + */ + public static Set getTableNamesBetween(LocalDateTime startTime, LocalDateTime endTime) { + validateTimeRange(startTime, endTime); + + Set tableNames = new LinkedHashSet<>(); + LocalDateTime current = startTime.withHour(0).withMinute(0).withSecond(0); + + while (!current.isAfter(endTime)) { + tableNames.add(getTableName(current)); + current = current.plusDays(1); + } + + return tableNames; + } + + + // 获取日期区间 + private static String getDayRange(int day) { + if (day < 1 || day > 31) { + throw new IllegalArgumentException("日期必须在1-31之间"); + } + + if (day <= 10) return "1_10"; + if (day <= 20) return "11_20"; + return "21_31"; + } + + // 验证时间范围 + private static void validateTimeRange(LocalDateTime start, LocalDateTime end) { + if (start == null || end == null) { + throw new IllegalArgumentException("时间范围参数不能为null"); + } + if (start.isAfter(end)) { + throw new IllegalArgumentException("开始时间不能晚于结束时间"); + } + } +} diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsBusinessMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsBusinessMapper.xml new file mode 100644 index 0000000..d7ac33c --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsBusinessMapper.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + select id, business_name, create_time, update_time, create_by, update_by, description from eps_business + + + + + + + + insert into eps_business + + id, + business_name, + create_time, + update_time, + create_by, + update_by, + description, + + + #{id}, + #{businessName}, + #{createTime}, + #{updateTime}, + #{createBy}, + #{updateBy}, + #{description}, + + + + + update eps_business + + business_name = #{businessName}, + create_time = #{createTime}, + update_time = #{updateTime}, + create_by = #{createBy}, + update_by = #{updateBy}, + description = #{description}, + + where id = #{id} + + + + delete from eps_business where id = #{id} + + + + delete from eps_business where id in + + #{id} + + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsInitialTrafficDataMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsInitialTrafficDataMapper.xml new file mode 100644 index 0000000..19a06f8 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsInitialTrafficDataMapper.xml @@ -0,0 +1,128 @@ + + + + + + CREATE TABLE IF NOT EXISTS ${tableName} ( + id BIGINT(20) COMMENT '唯一标识ID', + interface_name VARCHAR(50) COMMENT '接口名称', + mac_address VARCHAR(17) COMMENT 'MAC地址', + operation_status VARCHAR(20) COMMENT '运行状态', + interface_type VARCHAR(30) COMMENT '接口类型', + ipv4_address VARCHAR(15) COMMENT 'IPv4地址', + inbound_packet_loss DECIMAL(5,2) COMMENT '入站丢包率(%)', + outbound_packet_loss DECIMAL(5,2) COMMENT '出站丢包率(%)', + receive_bandwidth DECIMAL(10,2) COMMENT '接收带宽(Mbps)', + send_bandwidth DECIMAL(10,2) COMMENT '发送带宽(Mbps)', + business_id varchar(12) COMMENT '业务代码', + business_name varchar(50) COMMENT '业务名称', + service_sn varchar(50) COMMENT '服务器SN', + node_name varchar(50) COMMENT '服务器名称', + revenue_method varchar(50) COMMENT '收益方式(1.流量,2包端)', + package_bandwidth DECIMAL(10,2) COMMENT '包端带宽值', + create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + create_by VARCHAR(50) COMMENT '创建人', + update_by VARCHAR(50) COMMENT '修改人', + PRIMARY KEY (id), + INDEX idx_name_time (interface_name,create_time), + INDEX idx_revenue_method (revenue_method), + INDEX idx_service_sn (service_sn) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='EPS设备流量初始数据表'; + + + CREATE TABLE IF NOT EXISTS ${tableName} ( + id BIGINT(20) COMMENT '唯一标识ID', + interface_name VARCHAR(50) COMMENT '接口名称', + mac_address VARCHAR(17) COMMENT 'MAC地址', + operation_status VARCHAR(20) COMMENT '运行状态', + interface_type VARCHAR(30) COMMENT '接口类型', + ipv4_address VARCHAR(15) COMMENT 'IPv4地址', + inbound_packet_loss DECIMAL(5,2) COMMENT '入站丢包率(%)', + outbound_packet_loss DECIMAL(5,2) COMMENT '出站丢包率(%)', + receive_bandwidth DECIMAL(10,2) COMMENT '接收带宽(Mbps)', + send_bandwidth DECIMAL(10,2) COMMENT '发送带宽(Mbps)', + create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + create_by VARCHAR(50) COMMENT '创建人', + update_by VARCHAR(50) COMMENT '修改人', + PRIMARY KEY (id), + INDEX idx_name_time (interface_name,create_time) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='初始带宽流量表'; + + + + INSERT INTO ${tableName} ( + receive_traffic, + send_traffic, + device_sn, + business_id, + traffic_port, + create_time, + remark1, remark2, remark3, remark4 + ) VALUES ( + #{receiveTraffic}, + #{sendTraffic}, + #{deviceSn}, + #{businessId}, + #{trafficPort}, + #{createTime}, + #{remark1}, #{remark2}, + #{remark3}, #{remark4} + ) + + + + + INSERT INTO ${tableName} ( + receive_traffic, + send_traffic, + device_sn, + business_id, + traffic_port, + create_time, + remark1, remark2, remark3, remark4 + ) VALUES + + ( + #{data.receiveTraffic}, + #{data.sendTraffic}, + #{data.deviceSn}, + #{data.businessId}, + #{data.trafficPort}, + #{data.createTime}, + #{data.remark1}, #{data.remark2}, + #{data.remark3}, #{data.remark4} + ) + + + + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsMethodChangeRecordMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsMethodChangeRecordMapper.xml new file mode 100644 index 0000000..ca8e619 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsMethodChangeRecordMapper.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + select id, node_name, change_content, hardware_sn, create_time, creat_by, update_time, update_by from eps_method_change_record + + + + + + + + insert into eps_method_change_record + + id, + node_name, + change_content, + hardware_sn, + create_time, + creat_by, + update_time, + update_by, + + + #{id}, + #{nodeName}, + #{changeContent}, + #{hardwareSn}, + #{createTime}, + #{creatBy}, + #{updateTime}, + #{updateBy}, + + + + + update eps_method_change_record + + node_name = #{nodeName}, + change_content = #{changeContent}, + hardware_sn = #{hardwareSn}, + create_time = #{createTime}, + creat_by = #{creatBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, + + where id = #{id} + + + + delete from eps_method_change_record where id = #{id} + + + + delete from eps_method_change_record where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsNodeBandwidthMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsNodeBandwidthMapper.xml new file mode 100644 index 0000000..97d035a --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsNodeBandwidthMapper.xml @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, node_name, hardware_sn, bandwidth_type, bandwidth_result, bandwidth_95_daily, bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, customer_id, customer_name, service_number, uplink_switch, create_time, update_time, creator_id, creator_name, remark1, interface_name, resource_type, interface_link_device_type, effective_bandwidth_95_daily, effective_bandwidth_95_monthly, effective_avg_monthly_bandwidth_95, business_name, business_id from eps_node_bandwidth + + + + + + + + insert into eps_node_bandwidth + + node_name, + hardware_sn, + bandwidth_type, + bandwidth_result, + bandwidth_95_daily, + bandwidth_95_monthly, + avg_monthly_bandwidth_95, + package_bandwidth_daily, + customer_id, + customer_name, + service_number, + uplink_switch, + create_time, + update_time, + creator_id, + creator_name, + remark1, + interface_name, + resource_type, + interface_link_device_type, + effective_bandwidth_95_daily, + effective_bandwidth_95_monthly, + effective_avg_monthly_bandwidth_95, + business_name, + business_id, + + + #{nodeName}, + #{hardwareSn}, + #{bandwidthType}, + #{bandwidthResult}, + #{bandwidth95Daily}, + #{bandwidth95Monthly}, + #{avgMonthlyBandwidth95}, + #{packageBandwidthDaily}, + #{customerId}, + #{customerName}, + #{serviceNumber}, + #{uplinkSwitch}, + #{createTime}, + #{updateTime}, + #{creatorId}, + #{creatorName}, + #{remark1}, + #{interfaceName}, + #{resourceType}, + #{interfaceLinkDeviceType}, + #{effectiveBandwidth95Daily}, + #{effectiveBandwidth95Monthly}, + #{effectiveAvgMonthlyBandwidth95}, + #{businessName}, + #{businessId}, + + + + + update eps_node_bandwidth + + node_name = #{nodeName}, + hardware_sn = #{hardwareSn}, + bandwidth_type = #{bandwidthType}, + bandwidth_result = #{bandwidthResult}, + bandwidth_95_daily = #{bandwidth95Daily}, + bandwidth_95_monthly = #{bandwidth95Monthly}, + avg_monthly_bandwidth_95 = #{avgMonthlyBandwidth95}, + package_bandwidth_daily = #{packageBandwidthDaily}, + customer_id = #{customerId}, + customer_name = #{customerName}, + service_number = #{serviceNumber}, + uplink_switch = #{uplinkSwitch}, + create_time = #{createTime}, + update_time = #{updateTime}, + creator_id = #{creatorId}, + creator_name = #{creatorName}, + remark1 = #{remark1}, + interface_name = #{interfaceName}, + resource_type = #{resourceType}, + interface_link_device_type = #{interfaceLinkDeviceType}, + effective_bandwidth_95_daily = #{effectiveBandwidth95Daily}, + effective_bandwidth_95_monthly = #{effectiveBandwidth95Monthly}, + effective_avg_monthly_bandwidth_95 = #{effectiveAvgMonthlyBandwidth95}, + business_name = #{businessName}, + business_id = #{businessId}, + + where id = #{id} + + + + delete from eps_node_bandwidth where id = #{id} + + + + delete from eps_node_bandwidth where id in + + #{id} + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsServerRevenueConfigMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsServerRevenueConfigMapper.xml new file mode 100644 index 0000000..dd96363 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsServerRevenueConfigMapper.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, node_name, revenue_method, hardware_sn, traffic_port, bandwidth_95, package_bandwidth, update_time, business_name, business_code, registration_status, create_by, update_by, create_time from eps_server_revenue_config + + + + + + + + + + insert into eps_server_revenue_config + + id, + node_name, + revenue_method, + hardware_sn, + traffic_port, + bandwidth_95, + package_bandwidth, + update_time, + business_name, + business_code, + registration_status, + create_by, + update_by, + create_time, + + + #{id}, + #{nodeName}, + #{revenueMethod}, + #{hardwareSn}, + #{trafficPort}, + #{bandwidth95}, + #{packageBandwidth}, + #{updateTime}, + #{businessName}, + #{businessCode}, + #{registrationStatus}, + #{createBy}, + #{updateBy}, + #{createTime}, + + + + + update eps_server_revenue_config + + node_name = #{nodeName}, + revenue_method = #{revenueMethod}, + hardware_sn = #{hardwareSn}, + traffic_port = #{trafficPort}, + bandwidth_95 = #{bandwidth95}, + package_bandwidth = #{packageBandwidth}, + update_time = #{updateTime}, + business_name = #{businessName}, + business_code = #{businessCode}, + registration_status = #{registrationStatus}, + create_by = #{createBy}, + update_by = #{updateBy}, + create_time = #{createTime}, + + where id = #{id} + + + + delete from eps_server_revenue_config where id = #{id} + + + + delete from eps_server_revenue_config where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsTrafficDataMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsTrafficDataMapper.xml new file mode 100644 index 0000000..6b2a91c --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/EpsTrafficDataMapper.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, hardware_sn, node_name, revenue_method, traffic_port, tx_bytes, rx_bytes, package_bandwidth, create_time, update_time, creator_id, creator_name, updater_id, updater_name from eps_traffic_data + + + + + + + + insert into eps_traffic_data + + hardware_sn, + node_name, + revenue_method, + traffic_port, + tx_bytes, + rx_bytes, + package_bandwidth, + create_time, + update_time, + creator_id, + creator_name, + updater_id, + updater_name, + + + #{hardwareSn}, + #{nodeName}, + #{revenueMethod}, + #{trafficPort}, + #{txBytes}, + #{rxBytes}, + #{packageBandwidth}, + #{createTime}, + #{updateTime}, + #{creatorId}, + #{creatorName}, + #{updaterId}, + #{updaterName}, + + + + + update eps_traffic_data + + hardware_sn = #{hardwareSn}, + node_name = #{nodeName}, + revenue_method = #{revenueMethod}, + traffic_port = #{trafficPort}, + tx_bytes = #{txBytes}, + rx_bytes = #{rxBytes}, + package_bandwidth = #{packageBandwidth}, + create_time = #{createTime}, + update_time = #{updateTime}, + creator_id = #{creatorId}, + creator_name = #{creatorName}, + updater_id = #{updaterId}, + updater_name = #{updaterName}, + + where id = #{id} + + + + delete from eps_traffic_data where id = #{id} + + + + delete from eps_traffic_data where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/KnowledgeBaseMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/KnowledgeBaseMapper.xml new file mode 100644 index 0000000..6c3bc8d --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/KnowledgeBaseMapper.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + select id, title, issue_type, solution, create_time, creat_by, update_time, update_by from knowledge_base + + + + + + + + insert into knowledge_base + + title, + issue_type, + solution, + create_time, + creat_by, + update_time, + update_by, + + + #{title}, + #{issueType}, + #{solution}, + #{createTime}, + #{creatBy}, + #{updateTime}, + #{updateBy}, + + + + + update knowledge_base + + title = #{title}, + issue_type = #{issueType}, + solution = #{solution}, + create_time = #{createTime}, + creat_by = #{creatBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, + + where id = #{id} + + + + delete from knowledge_base where id = #{id} + + + + delete from knowledge_base where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/MtmMonitoringTemplateMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/MtmMonitoringTemplateMapper.xml new file mode 100644 index 0000000..5396bfe --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/MtmMonitoringTemplateMapper.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, template_name, description, item_type, included_resources, discovery_item_type, item_name, item_description, create_time, update_time, creator_id, creator_name, updater_id, updater_name from mtm_monitoring_template + + + + + + + + insert into mtm_monitoring_template + + template_name, + description, + item_type, + included_resources, + discovery_item_type, + item_name, + item_description, + create_time, + update_time, + creator_id, + creator_name, + updater_id, + updater_name, + + + #{templateName}, + #{description}, + #{itemType}, + #{includedResources}, + #{discoveryItemType}, + #{itemName}, + #{itemDescription}, + #{createTime}, + #{updateTime}, + #{creatorId}, + #{creatorName}, + #{updaterId}, + #{updaterName}, + + + + + update mtm_monitoring_template + + template_name = #{templateName}, + description = #{description}, + item_type = #{itemType}, + included_resources = #{includedResources}, + discovery_item_type = #{discoveryItemType}, + item_name = #{itemName}, + item_description = #{itemDescription}, + create_time = #{createTime}, + update_time = #{updateTime}, + creator_id = #{creatorId}, + creator_name = #{creatorName}, + updater_id = #{updaterId}, + updater_name = #{updaterName}, + + where id = #{id} + + + + delete from mtm_monitoring_template where id = #{id} + + + + delete from mtm_monitoring_template where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/RmEpsTopologyManagementMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/RmEpsTopologyManagementMapper.xml new file mode 100644 index 0000000..a11429d --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/RmEpsTopologyManagementMapper.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, switch_name, switch_sn, interface_name, connected_device_type, server_name, server_sn, server_port, create_time, update_time, creator_id, creator_name, updater_id, updater_name from rm_eps_topology_management + + + + + + + + insert into rm_eps_topology_management + + switch_name, + switch_sn, + interface_name, + connected_device_type, + server_name, + server_sn, + server_port, + create_time, + update_time, + creator_id, + creator_name, + updater_id, + updater_name, + + + #{switchName}, + #{switchSn}, + #{interfaceName}, + #{connectedDeviceType}, + #{serverName}, + #{serverSn}, + #{serverPort}, + #{createTime}, + #{updateTime}, + #{creatorId}, + #{creatorName}, + #{updaterId}, + #{updaterName}, + + + + + update rm_eps_topology_management + + switch_name = #{switchName}, + switch_sn = #{switchSn}, + interface_name = #{interfaceName}, + connected_device_type = #{connectedDeviceType}, + server_name = #{serverName}, + server_sn = #{serverSn}, + server_port = #{serverPort}, + create_time = #{createTime}, + update_time = #{updateTime}, + creator_id = #{creatorId}, + creator_name = #{creatorName}, + updater_id = #{updaterId}, + updater_name = #{updaterName}, + + where id = #{id} + + + + delete from rm_eps_topology_management where id = #{id} + + + + delete from rm_eps_topology_management where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/RmResourceGroupMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/RmResourceGroupMapper.xml new file mode 100644 index 0000000..8f34579 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/RmResourceGroupMapper.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + select id, group_name, description, included_devices, create_time, update_time, creator_id, creator_name, updater_id, updater_name from rm_resource_group + + + + + + + + insert into rm_resource_group + + group_name, + description, + included_devices, + create_time, + update_time, + creator_id, + creator_name, + updater_id, + updater_name, + + + #{groupName}, + #{description}, + #{includedDevices}, + #{createTime}, + #{updateTime}, + #{creatorId}, + #{creatorName}, + #{updaterId}, + #{updaterName}, + + + + + update rm_resource_group + + group_name = #{groupName}, + description = #{description}, + included_devices = #{includedDevices}, + create_time = #{createTime}, + update_time = #{updateTime}, + creator_id = #{creatorId}, + creator_name = #{creatorName}, + updater_id = #{updaterId}, + updater_name = #{updaterName}, + + where id = #{id} + + + + delete from rm_resource_group where id = #{id} + + + + delete from rm_resource_group where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/RmResourceRegistrationMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/RmResourceRegistrationMapper.xml index 3bb9d38..2b0ada7 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/RmResourceRegistrationMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/RmResourceRegistrationMapper.xml @@ -11,11 +11,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -32,7 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, hardware_sn, resource_type, resource_name, ip_address, resource_port, protocol, resource_version, rw_permission, security_level, encryption, resource_pwd, registration_status, online_status, description, customer_id, customer_name, service_number, create_time, update_time, creator_id, creator_name, updater_id, updater_name from rm_resource_registration + select id, hardware_sn, resource_type, resource_name, ip_address, resource_port, other_port_name, protocol, resource_version, rw_permission, security_level, encryption, resource_user_name,resource_pwd, registration_status, online_status, description, customer_id, customer_name, service_number, create_time, update_time, creator_id, creator_name, updater_id, updater_name from rm_resource_registration + insert into rm_resource_registration @@ -75,11 +83,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" resource_name, ip_address, resource_port, + other_port_name, protocol, resource_version, rw_permission, security_level, encryption, + resource_user_name, resource_pwd, registration_status, online_status, @@ -100,11 +110,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{resourceName}, #{ipAddress}, #{resourcePort}, + #{otherPortName}, #{protocol}, #{resourceVersion}, #{rwPermission}, #{securityLevel}, #{encryption}, + #{resourceUserName}, #{resourcePwd}, #{registrationStatus}, #{onlineStatus}, @@ -129,11 +141,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" resource_name = #{resourceName}, ip_address = #{ipAddress}, resource_port = #{resourcePort}, + other_port_name = #{otherPortName}, protocol = #{protocol}, resource_version = #{resourceVersion}, rw_permission = #{rwPermission}, security_level = #{securityLevel}, encryption = #{encryption}, + resource_user_name = #{resourceUserName}, resource_pwd = #{resourcePwd}, registration_status = #{registrationStatus}, online_status = #{onlineStatus}, @@ -161,4 +175,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + + + \ No newline at end of file diff --git a/ruoyi-rocketmq/pom.xml b/ruoyi-rocketmq/pom.xml new file mode 100644 index 0000000..3eefe21 --- /dev/null +++ b/ruoyi-rocketmq/pom.xml @@ -0,0 +1,152 @@ + + + + ruoyi + com.ruoyi + 3.6.6 + + 4.0.0 + + ruoyi-rocketmq + + + + + org.apache.rocketmq + rocketmq-client + 4.9.0 + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + com.alibaba.nacos + nacos-client + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + com.mysql + mysql-connector-j + + + + + com.ruoyi + ruoyi-common-log + + + + + com.ruoyi + ruoyi-common-swagger + + + + + com.ruoyi + ruoyi-common-security + + + org.projectlombok + lombok + + + + + org.yaml + snakeyaml + 1.28 + + + + + org.springframework.boot + spring-boot-starter-web + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + src/main/resources + true + + + + + \ No newline at end of file diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/RocketMQApplication.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/RocketMQApplication.java new file mode 100644 index 0000000..1d565ab --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/RocketMQApplication.java @@ -0,0 +1,25 @@ +package com.ruoyi.rocketmq; + +import com.ruoyi.common.security.annotation.EnableCustomConfig; +import com.ruoyi.common.security.annotation.EnableRyFeignClients; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableAsync; + +/** + * 平台管理模块 + * + * @author ruoyi + */ +@EnableCustomConfig +@EnableRyFeignClients +@SpringBootApplication +@EnableAsync +public class RocketMQApplication +{ + public static void main(String[] args) + { + SpringApplication.run(RocketMQApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ RocketMQ模块启动成功 ლ(´ڡ`ლ)゙"); + } +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/config/ConsumerConfig.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/config/ConsumerConfig.java new file mode 100644 index 0000000..ba7e14c --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/config/ConsumerConfig.java @@ -0,0 +1,75 @@ +package com.ruoyi.rocketmq.config; + +import com.ruoyi.rocketmq.enums.MessageCodeEnum; +import com.ruoyi.rocketmq.enums.MessageTopic; +import com.ruoyi.rocketmq.model.ConsumerMode; +import com.ruoyi.rocketmq.consumer.RocketMsgListener; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.common.consumer.ConsumeFromWhere; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +/** + * 消费者配置 + */ +@RefreshScope +@Configuration +@Slf4j +public class ConsumerConfig { + + @Autowired + private ConsumerMode consumerMode; + + @Bean + public DefaultMQPushConsumer getRocketMQConsumer() { + //构建客户端连接 + DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(consumerMode.getGroupName()); + // + consumer.setNamesrvAddr(consumerMode.getNamesrvAddr()); + consumer.setConsumeThreadMin(consumerMode.getConsumeThreadMin()); + consumer.setConsumeThreadMax(consumerMode.getConsumeThreadMax()); + consumer.registerMessageListener(new RocketMsgListener()); + /** + * 1. CONSUME_FROM_LAST_OFFSET:第一次启动从队列最后位置消费,后续再启动接着上次消费的进度开始消费 + * 2. CONSUME_FROM_FIRST_OFFSET:第一次启动从队列初始位置消费,后续再启动接着上次消费的进度开始消费 + * 3. CONSUME_FROM_TIMESTAMP:第一次启动从指定时间点位置消费,后续再启动接着上次消费的进度开始消费 + * 以上所说的第一次启动是指从来没有消费过的消费者,如果该消费者消费过,那么会在broker端记录该消费者的消费位置,如果该消费者挂了再启动,那么自动从上次消费的进度开始 + */ + consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET); + /** + * CLUSTERING (集群模式) :默认模式,同一个ConsumerGroup(groupName相同)每个consumer只消费所订阅消息的一部分内容,同一个ConsumerGroup里所有的Consumer消息加起来才是所 + * 订阅topic整体,从而达到负载均衡的目的 + * BROADCASTING (广播模式) :同一个ConsumerGroup每个consumer都消费到所订阅topic所有消息,也就是一个消费会被多次分发,被多个consumer消费。 + * 需要注意的是,在广播模式下,每个Consumer都会独立地处理相同的消息副本。这可能会导致一些潜在的问题,例如消息重复处理或者资源浪费。因此,在使用广播模式时,请确保消息的处理逻辑是幂等的,并仔细考虑系统资源的消耗。 + */ + // consumer.setMessageModel(MessageModel.BROADCASTING); + + consumer.setVipChannelEnabled(false); + consumer.setConsumeMessageBatchMaxSize(consumerMode.getConsumeMessageBatchMaxSize()); + try { + /** + * 订阅topic,可以对指定消息进行过滤,例如:"TopicTest","tagl||tag2||tag3",*或null表示topic所有消息 + * 由于官方并没有给直接订阅全部消息示例 所以使用list列表循环订阅所有topic + */ + // 获取所有topic列表 + MessageTopic messageTopic = new MessageTopic(); + List allTopics = messageTopic.RocketMQTopicList(); + //订阅所有topic + for (String topic : allTopics) { + consumer.subscribe(topic,"*"); + } + consumer.start(); + log.info("消费者初始化成功:{}", consumer); + } catch (MQClientException e) { + e.printStackTrace(); + log.error("消费者初始化失败:{}",e.getMessage()); + } + return consumer; + } +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/config/ProducerConfig.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/config/ProducerConfig.java new file mode 100644 index 0000000..233520f --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/config/ProducerConfig.java @@ -0,0 +1,56 @@ +package com.ruoyi.rocketmq.config; + +import com.ruoyi.rocketmq.model.ProducerMode; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + + +/** + * mq搭建地址连接 + * 生产者初者连接信息 具体看nacos配置 + */ +@Configuration +@Slf4j +public class ProducerConfig { + + /** + * 远程调用连接信息 + */ + public static DefaultMQProducer producer; + + /** + * 连接客户端信息配置 具体看nacos配置 + */ + @Autowired + private ProducerMode producerMode; + + @Bean + public DefaultMQProducer getRocketMQProducer() { + producer = new DefaultMQProducer(producerMode.getGroupName()); + producer.setNamesrvAddr(producerMode.getNamesrvAddr()); + //如果需要同一个jvm中不同的producer往不同的mq集群发送消息,需要设置不同的instanceName + if(producerMode.getMaxMessageSize()!=null){ + producer.setMaxMessageSize(producerMode.getMaxMessageSize()); + } + if(producerMode.getSendMsgTimeout()!=null){ + producer.setSendMsgTimeout(producerMode.getSendMsgTimeout()); + } + //如果发送消息失败,设置重试次数,默认为2次 + if(producerMode.getRetryTimesWhenSendFailed()!=null){ + producer.setRetryTimesWhenSendFailed(producerMode.getRetryTimesWhenSendFailed()); + } + producer.setVipChannelEnabled(false); + try { + producer.start(); + log.info("生产者初始化成功:{}",producer.toString()); + } catch (MQClientException e) { + log.error("生产者初始化失败:{}",e.getMessage()); + } + return producer; + } + +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/consumer/RocketMsgListener.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/consumer/RocketMsgListener.java new file mode 100644 index 0000000..f120fd6 --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/consumer/RocketMsgListener.java @@ -0,0 +1,87 @@ +package com.ruoyi.rocketmq.consumer; + +import com.ruoyi.rocketmq.enums.MessageCodeEnum; +import com.ruoyi.rocketmq.producer.ConsumeException; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import org.apache.rocketmq.common.message.MessageExt; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.io.UnsupportedEncodingException; +import java.util.List; + +/** + * 消息监听 + */ +@Slf4j +@Component +public class RocketMsgListener implements MessageListenerConcurrently { + + /** + * 消费消息 + * @param list msgs.size() >= 1 + * DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here + * 这里只设置为1,当设置为多个时,list中只要有一条消息消费失败,就会整体重试 + * @param consumeConcurrentlyContext 上下文信息 + * @return 消费状态 成功(CONSUME_SUCCESS)或者 重试 (RECONSUME_LATER) + */ + @Override + public ConsumeConcurrentlyStatus consumeMessage(List list, ConsumeConcurrentlyContext consumeConcurrentlyContext) { + try{ + //消息不等于空情况 + if (!CollectionUtils.isEmpty(list)) { + //获取topic + for (MessageExt messageExt : list) { + // 解析消息内容 + String body = new String(messageExt.getBody()); + log.info("接受到的消息为:{}", body); + String tags = messageExt.getTags(); + String topic = messageExt.getTopic(); + String msgId = messageExt.getMsgId(); + String keys = messageExt.getKeys(); + int reConsume = messageExt.getReconsumeTimes(); + // 消息已经重试了3次,如果不需要再次消费,则返回成功 + if (reConsume == 3) { + // TODO 补偿信息 + log.error("消息消费三次失败,消息内容:{}", body); + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;//根据业务返回是否正常 + } + // 根据不同的topic处理不同的业务 这里以订单消息为例子 + if (MessageCodeEnum.ORDER_MESSAGE_TOPIC.getCode().equals(topic)) { + if (MessageCodeEnum.ORDER_TIMEOUT_TAG.getCode().equals(tags)) { + //处理你的业务 + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;//业务处理成功 + } else { + log.info("未匹配到Tag【{}】" + tags); + } + } + } + } + // 消息消费失败 + //broker会根据设置的messageDelayLevel发起重试,默认16次 + return ConsumeConcurrentlyStatus.RECONSUME_LATER; + } catch (Exception e) { + // 调用 handleException 方法处理异常并返回处理结果 + return handleException(e); + } + } + + /** + * 异常处理 + * + * @param e 捕获的异常 + * @return 消息消费结果 + */ + private static ConsumeConcurrentlyStatus handleException(final Exception e) { + Class exceptionClass = e.getClass(); + if (exceptionClass.equals(UnsupportedEncodingException.class)) { + log.error(e.getMessage()); + } else if (exceptionClass.equals(ConsumeException.class)) { + log.error(e.getMessage()); + } + return ConsumeConcurrentlyStatus.RECONSUME_LATER; + } +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/consumer/RocketMsgTransactionListenerImpl.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/consumer/RocketMsgTransactionListenerImpl.java new file mode 100644 index 0000000..b2399b9 --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/consumer/RocketMsgTransactionListenerImpl.java @@ -0,0 +1,30 @@ +package com.ruoyi.rocketmq.consumer; + +import org.apache.rocketmq.client.producer.LocalTransactionState; +import org.apache.rocketmq.client.producer.TransactionListener; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.common.message.MessageExt; + +/** + * 事物消息监听 + */ +public class RocketMsgTransactionListenerImpl implements TransactionListener { + + @Override + public LocalTransactionState executeLocalTransaction(Message msg, Object arg) { + // 在这里执行本地事务,比如数据库操作等 + // 如果本地事务执行成功,返回 COMMIT_MESSAGE + // 如果本地事务执行失败,返回 ROLLBACK_MESSAGE + // 如果本地事务执行中,可以返回 UNKNOW,RocketMQ 将会检查事务状态,并根据状态处理消息 + return LocalTransactionState.COMMIT_MESSAGE; // 根据实际情况返回对应的状态 + } + + @Override + public LocalTransactionState checkLocalTransaction(MessageExt msg) { + // 检查本地事务状态,如果本地事务执行成功,返回 COMMIT_MESSAGE + // 如果本地事务执行失败,返回 ROLLBACK_MESSAGE + // 如果本地事务仍在执行中,返回 UNKNOW,RocketMQ 将会继续检查事务状态 + return LocalTransactionState.COMMIT_MESSAGE; // 根据实际情况返回对应的状态 + } + +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/controller/InitialBandwidthTrafficController.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/controller/InitialBandwidthTrafficController.java new file mode 100644 index 0000000..0bda01b --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/controller/InitialBandwidthTrafficController.java @@ -0,0 +1,105 @@ +package com.ruoyi.rocketmq.controller; + +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.rocketmq.domain.InitialBandwidthTraffic; +import com.ruoyi.rocketmq.service.IInitialBandwidthTrafficService; +import com.ruoyi.common.core.web.controller.BaseController; +import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.core.utils.poi.ExcelUtil; +import com.ruoyi.common.core.web.page.TableDataInfo; + +/** + * 初始带宽流量Controller + * + * @author gyt + * @date 2025-08-20 + */ +@RestController +@RequestMapping("/traffic") +public class InitialBandwidthTrafficController extends BaseController +{ + @Autowired + private IInitialBandwidthTrafficService initialBandwidthTrafficService; + + /** + * 查询初始带宽流量列表 + */ + @RequiresPermissions("rocketmq:traffic:list") + @GetMapping("/list") + public TableDataInfo list(InitialBandwidthTraffic initialBandwidthTraffic) + { + startPage(); + List list = initialBandwidthTrafficService.selectInitialBandwidthTrafficList(initialBandwidthTraffic); + return getDataTable(list); + } + + /** + * 导出初始带宽流量列表 + */ + @RequiresPermissions("rocketmq:traffic:export") + @Log(title = "初始带宽流量", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, InitialBandwidthTraffic initialBandwidthTraffic) + { + List list = initialBandwidthTrafficService.selectInitialBandwidthTrafficList(initialBandwidthTraffic); + ExcelUtil util = new ExcelUtil(InitialBandwidthTraffic.class); + util.exportExcel(response, list, "初始带宽流量数据"); + } + + /** + * 获取初始带宽流量详细信息 + */ + @RequiresPermissions("rocketmq:traffic:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(initialBandwidthTrafficService.selectInitialBandwidthTrafficById(id)); + } + + /** + * 新增初始带宽流量 + */ + @RequiresPermissions("rocketmq:traffic:add") + @Log(title = "初始带宽流量", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody InitialBandwidthTraffic initialBandwidthTraffic) + { + return toAjax(initialBandwidthTrafficService.insertInitialBandwidthTraffic(initialBandwidthTraffic)); + } + + /** + * 修改初始带宽流量 + */ + @RequiresPermissions("rocketmq:traffic:edit") + @Log(title = "初始带宽流量", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody InitialBandwidthTraffic initialBandwidthTraffic) + { + return toAjax(initialBandwidthTrafficService.updateInitialBandwidthTraffic(initialBandwidthTraffic)); + } + + /** + * 删除初始带宽流量 + */ + @RequiresPermissions("rocketmq:traffic:remove") + @Log(title = "初始带宽流量", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(initialBandwidthTrafficService.deleteInitialBandwidthTrafficByIds(ids)); + } +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/controller/RocketMqController.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/controller/RocketMqController.java new file mode 100644 index 0000000..6d3ed81 --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/controller/RocketMqController.java @@ -0,0 +1,137 @@ +package com.ruoyi.rocketmq.controller; + + +import com.ruoyi.rocketmq.producer.MessageProducer; +import org.apache.rocketmq.client.producer.SendResult; +import org.apache.rocketmq.common.message.Message; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 消息测试类Controller + */ +@RestController +@RequestMapping("/api/rocketMessage") +public class RocketMqController { + + + + /** + * 发送同步消息 + */ + @PostMapping("/sendSynchronizeMessage") + private Map sendSynchronizeMessage(){ + MessageProducer messageProducer = new MessageProducer(); + //调用MessageProducer配置好的消息方法 + SendResult sendResult = messageProducer.sendSynchronizeMessage("order-message","order_message_tag","title","content"); + Map result = new HashMap<>(); + result.put("data",sendResult); + return result; + } + + + + /** + * 发送单向消息 + */ + @PostMapping("/sendOnewayMessage") + private Map sendOnewayMessage(@RequestParam("topic") String topic,@RequestParam("tag") String tag,@RequestParam("key") String key,@RequestParam("value") String value){ + MessageProducer messageProducer = new MessageProducer(); + //调用MessageProducer配置好的消息方法 topic需要你根据你们业务定制相应的 + messageProducer.sendOnewayMessage("order-message","order_timeout_tag","title","content"); + Map result = new HashMap<>(); + result.put("msg","发送成功"); + result.put("code",200); + return result; + } + + + /** + * 批量发送消息 + */ + @PostMapping("/sendBatchMessage") + private Map sendBatchMessage(){ + // 根据实际需求创建消息列表并返回 + List messages = new ArrayList<>(); + // 添加消息到列表 + messages.add(new Message("order-message", "order_timeout_tag", "Message 1".getBytes())); + messages.add(new Message("order-message", "order_timeout_tag", "Message 2".getBytes())); + messages.add(new Message("order-message", "order_timeout_tag", "Message 3".getBytes())); + MessageProducer messageProducer = new MessageProducer(); + //调用MessageProducer配置好的消息方法 topic需要你根据你们业务定制相应的 + SendResult sendResult = messageProducer.sendBatchMessage(messages); + Map result = new HashMap<>(); + result.put("data",sendResult); + return result; + } + + + /** + * 发送事物消息 + */ + @PostMapping("/sendThingMessage") + private Map sendThingMessage(@RequestParam("topic") String topic,@RequestParam("tag") String tag,@RequestParam("key") String key,@RequestParam("value") String value){ + MessageProducer messageProducer = new MessageProducer(); + //调用MessageProducer配置好的消息方法 topic需要你根据你们业务定制相应的 + SendResult sendResult = messageProducer.sendThingMessage("order-message","order_timeout_tag","title","content"); + Map result = new HashMap<>(); + result.put("data",sendResult); + return result; + } + + + /** + * 发送有序的消息 + */ + @PostMapping("/sendOrderlyMessage") + private Map sendOrderlyMessage(){ + // 根据实际需求创建消息列表并返回 + List messages = new ArrayList<>(); + // 添加消息到列表 + messages.add(new Message("order-message", "order_timeout_tag", "Message 1".getBytes())); + messages.add(new Message("order-message", "order_timeout_tag", "Message 2".getBytes())); + messages.add(new Message("order-message", "order_timeout_tag", "Message 3".getBytes())); + Integer messageQueueNumber = 3; + MessageProducer messageProducer = new MessageProducer(); + //调用MessageProducer配置好的消息方法 topic需要你根据你们业务定制相应的 + SendResult sendResult = messageProducer.sendOrderlyMessage(messages,messageQueueNumber); + Map result = new HashMap<>(); + result.put("data",sendResult); + return result; + } + + /** + * 发送延迟消息 + */ + @PostMapping("/sendDelayMessage") + private Map sendDelayMessage(@RequestParam("topic") String topic,@RequestParam("tag") String tag,@RequestParam("key") String key,@RequestParam("value") String value){ + MessageProducer messageProducer = new MessageProducer(); + //调用MessageProducer配置好的消息方法 topic需要你根据你们业务定制相应的 + SendResult sendResult = messageProducer.sendDelayMessage("order-message","order_timeout_tag","title","content"); + Map result = new HashMap<>(); + result.put("data",sendResult); + return result; + } + + + /** + * 发送异步的消息 + */ + @PostMapping("/sendAsyncProducerMessage") + private Map sendAsyncProducerMessage(@RequestParam("topic") String topic,@RequestParam("tag") String tag,@RequestParam("key") String key,@RequestParam("value") String value){ + MessageProducer messageProducer = new MessageProducer(); + //调用MessageProducer配置好的消息方法 topic需要你根据你们业务定制相应的 + SendResult sendResult = messageProducer.sendAsyncProducerMessage("order-message","order_timeout_tag","title","content"); + Map result = new HashMap<>(); + result.put("data",sendResult); + return result; + } + +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/domain/InitialBandwidthTraffic.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/domain/InitialBandwidthTraffic.java new file mode 100644 index 0000000..a7d3354 --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/domain/InitialBandwidthTraffic.java @@ -0,0 +1,177 @@ +package com.ruoyi.rocketmq.domain; + +import java.math.BigDecimal; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.core.annotation.Excel; +import com.ruoyi.common.core.web.domain.BaseEntity; + +/** + * 初始带宽流量对象 initial_bandwidth_traffic + * + * @author gyt + * @date 2025-08-20 + */ +public class InitialBandwidthTraffic extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 唯一标识ID */ + private Long id; + + /** 接口名称 */ + @Excel(name = "接口名称") + private String interfaceName; + + /** MAC地址 */ + @Excel(name = "MAC地址") + private String macAddress; + + /** 运行状态 */ + @Excel(name = "运行状态") + private String operationStatus; + + /** 接口类型 */ + @Excel(name = "接口类型") + private String interfaceType; + + /** IPv4地址 */ + @Excel(name = "IPv4地址") + private String ipv4Address; + + /** 入站丢包率(%) */ + @Excel(name = "入站丢包率(%)") + private BigDecimal inboundPacketLoss; + + /** 出站丢包率(%) */ + @Excel(name = "出站丢包率(%)") + private BigDecimal outboundPacketLoss; + + /** 接收带宽(Mbps) */ + @Excel(name = "接收带宽(Mbps)") + private BigDecimal receiveBandwidth; + + /** 发送带宽(Mbps) */ + @Excel(name = "发送带宽(Mbps)") + private BigDecimal sendBandwidth; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setInterfaceName(String interfaceName) + { + this.interfaceName = interfaceName; + } + + public String getInterfaceName() + { + return interfaceName; + } + + public void setMacAddress(String macAddress) + { + this.macAddress = macAddress; + } + + public String getMacAddress() + { + return macAddress; + } + + public void setOperationStatus(String operationStatus) + { + this.operationStatus = operationStatus; + } + + public String getOperationStatus() + { + return operationStatus; + } + + public void setInterfaceType(String interfaceType) + { + this.interfaceType = interfaceType; + } + + public String getInterfaceType() + { + return interfaceType; + } + + public void setIpv4Address(String ipv4Address) + { + this.ipv4Address = ipv4Address; + } + + public String getIpv4Address() + { + return ipv4Address; + } + + public void setInboundPacketLoss(BigDecimal inboundPacketLoss) + { + this.inboundPacketLoss = inboundPacketLoss; + } + + public BigDecimal getInboundPacketLoss() + { + return inboundPacketLoss; + } + + public void setOutboundPacketLoss(BigDecimal outboundPacketLoss) + { + this.outboundPacketLoss = outboundPacketLoss; + } + + public BigDecimal getOutboundPacketLoss() + { + return outboundPacketLoss; + } + + public void setReceiveBandwidth(BigDecimal receiveBandwidth) + { + this.receiveBandwidth = receiveBandwidth; + } + + public BigDecimal getReceiveBandwidth() + { + return receiveBandwidth; + } + + public void setSendBandwidth(BigDecimal sendBandwidth) + { + this.sendBandwidth = sendBandwidth; + } + + public BigDecimal getSendBandwidth() + { + return sendBandwidth; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("interfaceName", getInterfaceName()) + .append("macAddress", getMacAddress()) + .append("operationStatus", getOperationStatus()) + .append("interfaceType", getInterfaceType()) + .append("ipv4Address", getIpv4Address()) + .append("inboundPacketLoss", getInboundPacketLoss()) + .append("outboundPacketLoss", getOutboundPacketLoss()) + .append("receiveBandwidth", getReceiveBandwidth()) + .append("sendBandwidth", getSendBandwidth()) + .append("createTime", getCreateTime()) + .append("updateTime", getUpdateTime()) + .append("createBy", getCreateBy()) + .append("updateBy", getUpdateBy()) + .toString(); + } +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/enums/MessageCodeEnum.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/enums/MessageCodeEnum.java new file mode 100644 index 0000000..3e038ec --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/enums/MessageCodeEnum.java @@ -0,0 +1,55 @@ +package com.ruoyi.rocketmq.enums; + + +import lombok.Getter; + +/** + * 用于传递topic和 tag + * 也用于接收消息后判断不同的消息处理不同的业务 + */ +@Getter +public enum MessageCodeEnum { + + /** + * 系统消息 + */ + NOTE_MESSAGE_TOPIC("system-message","系统消息服务模块topic名称"), + /** + * 用户消息 + */ + USER_MESSAGE_TOPIC("user-message","用户消息服务模块topic名称"), + + /** + * 订单消息 + */ + ORDER_MESSAGE_TOPIC("order-message","订单消息服务模块topic名称"), + + /** + * 用户消息tag + */ + USER_MESSAGE_TAG("user_message_tag","用户消息推送"), + + /** + * 系统消息tag + */ + NOTE_MESSAGE_TAG("system_message_tag","系统消息推送"), + + /** + * 订单消息 + */ + ORDER_MESSAGE_TAG("order_message_tag","订单消息推送"), + + /** + * 订单处理编号 + */ + ORDER_TIMEOUT_TAG("order_timeout_tag","订单超时处理"); + + private final String code; + private final String msg; + + MessageCodeEnum(String code, String msg){ + this.code = code; + this.msg = msg; + } + +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/enums/MessageTopic.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/enums/MessageTopic.java new file mode 100644 index 0000000..fe1ea39 --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/enums/MessageTopic.java @@ -0,0 +1,24 @@ +package com.ruoyi.rocketmq.enums; + + +import java.util.ArrayList; +import java.util.List; + +/** + * 定义topic列表 + */ +public class MessageTopic { + + //在这里添加topic 用于批量订阅 + public List RocketMQTopicList(){ + List getTopicLists=new ArrayList<>(); + //系统消息 + getTopicLists.add("system-message"); + //用户消息 + getTopicLists.add("user-message"); + //订单消息 + getTopicLists.add("order-message"); + return getTopicLists; + } + +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/mapper/InitialBandwidthTrafficMapper.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/mapper/InitialBandwidthTrafficMapper.java new file mode 100644 index 0000000..87937e7 --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/mapper/InitialBandwidthTrafficMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.rocketmq.mapper; + +import java.util.List; +import com.ruoyi.rocketmq.domain.InitialBandwidthTraffic; + +/** + * 初始带宽流量Mapper接口 + * + * @author gyt + * @date 2025-08-20 + */ +public interface InitialBandwidthTrafficMapper +{ + /** + * 查询初始带宽流量 + * + * @param id 初始带宽流量主键 + * @return 初始带宽流量 + */ + public InitialBandwidthTraffic selectInitialBandwidthTrafficById(Long id); + + /** + * 查询初始带宽流量列表 + * + * @param initialBandwidthTraffic 初始带宽流量 + * @return 初始带宽流量集合 + */ + public List selectInitialBandwidthTrafficList(InitialBandwidthTraffic initialBandwidthTraffic); + + /** + * 新增初始带宽流量 + * + * @param initialBandwidthTraffic 初始带宽流量 + * @return 结果 + */ + public int insertInitialBandwidthTraffic(InitialBandwidthTraffic initialBandwidthTraffic); + + /** + * 修改初始带宽流量 + * + * @param initialBandwidthTraffic 初始带宽流量 + * @return 结果 + */ + public int updateInitialBandwidthTraffic(InitialBandwidthTraffic initialBandwidthTraffic); + + /** + * 删除初始带宽流量 + * + * @param id 初始带宽流量主键 + * @return 结果 + */ + public int deleteInitialBandwidthTrafficById(Long id); + + /** + * 批量删除初始带宽流量 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteInitialBandwidthTrafficByIds(Long[] ids); +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/model/ConsumerMode.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/model/ConsumerMode.java new file mode 100644 index 0000000..6b67cce --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/model/ConsumerMode.java @@ -0,0 +1,26 @@ +package com.ruoyi.rocketmq.model; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +/** + * 消费者初始化 + * 消费者连接信息 具体看nacos配置 + */ +@Data +@Configuration +@Component +public class ConsumerMode { + @Value("${suning.rocketmq.namesrvAddr}") + private String namesrvAddr; + @Value("${suning.rocketmq.conumer.groupName}") + private String groupName ; + @Value("${suning.rocketmq.conumer.consumeThreadMin}") + private int consumeThreadMin; + @Value("${suning.rocketmq.conumer.consumeThreadMax}") + private int consumeThreadMax; + @Value("${suning.rocketmq.conumer.consumeMessageBatchMaxSize}") + private int consumeMessageBatchMaxSize; +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/model/ProducerMode.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/model/ProducerMode.java new file mode 100644 index 0000000..e65cf99 --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/model/ProducerMode.java @@ -0,0 +1,25 @@ +package com.ruoyi.rocketmq.model; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.Configuration; + +/** + * 生产者初始化 + */ +@RefreshScope +@Data +@Configuration +public class ProducerMode { + @Value("${suning.rocketmq.producer.groupName}") + private String groupName; + @Value("${suning.rocketmq.namesrvAddr}") + private String namesrvAddr; + @Value("${suning.rocketmq.producer.maxMessageSize}") + private Integer maxMessageSize; + @Value("${suning.rocketmq.producer.sendMsgTimeout}") + private Integer sendMsgTimeout; + @Value("${suning.rocketmq.producer.retryTimesWhenSendFailed}") + private Integer retryTimesWhenSendFailed; +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/producer/ConsumeException.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/producer/ConsumeException.java new file mode 100644 index 0000000..825f900 --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/producer/ConsumeException.java @@ -0,0 +1,23 @@ +package com.ruoyi.rocketmq.producer; + +/** + * @author 影子 + * 用于捕捉异常非受检异常(unchecked exception) + * RuntimeException 和其子类的异常在编译时不需要进行强制性的异常处理,可以选择在运行时进行捕获和处理 + * 可选择使用 + */ +public class ConsumeException extends RuntimeException{ + private static final long serialVersionUID = 4093867789628938836L; + + public ConsumeException(String message) { + super(message); + } + + public ConsumeException(Throwable cause) { + super(cause); + } + + public ConsumeException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/producer/MessageProducer.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/producer/MessageProducer.java new file mode 100644 index 0000000..3156f69 --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/producer/MessageProducer.java @@ -0,0 +1,224 @@ +package com.ruoyi.rocketmq.producer; + +import com.alibaba.fastjson.JSON; +import com.ruoyi.rocketmq.consumer.RocketMsgTransactionListenerImpl; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.client.exception.MQBrokerException; +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.SendCallback; +import org.apache.rocketmq.client.producer.SendResult; +import org.apache.rocketmq.client.producer.TransactionMQProducer; +import org.apache.rocketmq.client.producer.TransactionSendResult; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.remoting.common.RemotingHelper; +import org.apache.rocketmq.remoting.exception.RemotingException; + +import java.io.UnsupportedEncodingException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import static com.ruoyi.rocketmq.config.ProducerConfig.producer; + +/** + * 消息发送 + */ +@Slf4j +public class MessageProducer { + + + /** + * 同步发送消息 + * @param topic 主题 + * @param tag 标签 + * @param key 自定义的key,根据业务来定 + * @param value 消息的内容 + * 通过调用 send() 方法发送消息,阻塞等待服务器响应。 + */ + public SendResult sendSynchronizeMessage(String topic, String tag, String key, String value){ + String body = "topic:【"+topic+"】, tag:【"+tag+"】, key:【"+key+"】, value:【"+value+"】"; + try { + Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET)); + System.out.println("生产者发送消息:"+ JSON.toJSONString(value)); + SendResult result = producer.send(msg); + return result; + } catch (UnsupportedEncodingException e) { + log.error("消息初始化失败!body:{}",body); + + } catch (MQClientException | InterruptedException | RemotingException | MQBrokerException e) { + log.error("消息发送失败! body:{}",body); + } + return null; + } + + /** + * 单向发送消息 + * @param topic 主题 + * @param tag 标签 + * @param key 自定义的key,根据业务来定 + * @param value 消息的内容 + * 单向发送:通过调用 sendOneway() 方法发送消息,不关心发送结果,适用于对可靠性要求不高的场景。 + */ + public void sendOnewayMessage(String topic, String tag, String key, String value){ + String body = "topic:【"+topic+"】, tag:【"+tag+"】, key:【"+key+"】, value:【"+value+"】"; + try { + Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET)); + System.out.println("生产者发送消息:"+ JSON.toJSONString(value)); + producer.sendOneway(msg); + } catch (UnsupportedEncodingException e) { + log.error("消息初始化失败!body:{}",body); + + } catch (MQClientException | InterruptedException | RemotingException e) { + log.error("消息发送失败! body:{}",body); + } + } + + + /** + * 批量发送消息 + * @param messages 消息列表 + * 批量发送:通过调用 send() 方法并传入多条消息,实现批量发送消息。 + */ + public SendResult sendBatchMessage(List messages){ + String body = messages.toString(); + try { + System.out.println("生产者发送消息:"+ messages); + // 发送批量消息 + SendResult sendResult = producer.send(messages); + return sendResult; + } catch (MQClientException | InterruptedException | RemotingException e) { + log.error("消息发送失败! body:{}",body); + } catch (MQBrokerException e) { + throw new RuntimeException(e); + } + return null; + } + + + /** + * 事务消息发送 + * @param topic 主题 + * @param tag 标签 + * @param key 自定义的key,根据业务来定 + * @param value 消息的内容 + * 事务消息发送:通过使用事务监听器实现本地事务执行和消息发送的一致性。 + */ + public SendResult sendThingMessage(String topic, String tag, String key, String value){ + String body = "topic:【"+topic+"】, tag:【"+tag+"】, key:【"+key+"】, value:【"+value+"】"; + try { + // 实例化事务生产者 + TransactionMQProducer transactionMQProducer = new TransactionMQProducer(producer.getProducerGroup()); + transactionMQProducer.setNamesrvAddr(producer.getNamesrvAddr()); + // 设置事务监听器 + transactionMQProducer.setTransactionListener(new RocketMsgTransactionListenerImpl()); + Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET)); + System.out.println("生产者发送消息:"+ JSON.toJSONString(value)); + // 发送事务消息 + TransactionSendResult sendResult = transactionMQProducer.sendMessageInTransaction(msg, null); + return sendResult; + } catch (UnsupportedEncodingException e) { + log.error("消息初始化失败!body:{}",body); + + } catch (MQClientException e) { + log.error("消息发送失败! body:{}",body); + } + return null; + } + + + /** + * 发送有序的消息 + * @param messagesList Message集合 + * @param messageQueueNumber 消息队列数量,根据实际情况设定 + * 顺序发送: messageQueueNumber 表示消息的业务标识,可以根据具体需求进行设置来保证消息按顺序发送。 + */ + public SendResult sendOrderlyMessage(List messagesList, Integer messageQueueNumber) { + SendResult result = null; + for (Message message : messagesList) { + try { + result = producer.send(message, (list, msg, arg) -> { + Integer queueNumber = (Integer) arg; + //int queueIndex = queueNumber % list.size(); + return list.get(queueNumber); + }, messageQueueNumber);//根据编号取模,选择消息队列 + } catch (MQClientException | RemotingException | MQBrokerException | InterruptedException e) { + log.error("发送有序消息失败"); + return result; + } + } + return result; + } + + /** + * 发送延迟消息 + * @param topic 主题 + * @param tag 标签 + * @param key 自定义的key,根据业务来定 + * @param value 消息的内容 + * 延迟发送:通过设置延迟级别来实现延迟发送消息。 + */ + public SendResult sendDelayMessage(String topic, String tag, String key, String value) + { + SendResult result = null; + try + { + Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET)); + //设置消息延迟级别,我这里设置5,对应就是延时一分钟 + // "1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h" + msg.setDelayTimeLevel(4); + // 发送消息到一个Broker + result = producer.send(msg); + // 通过sendResult返回消息是否成功送达 + log.info("发送延迟消息结果:======sendResult:{}", result); + DateFormat format =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + log.info("发送时间:{}", format.format(new Date())); + return result; + } + catch (Exception e) + { + e.printStackTrace(); + log.error("延迟消息队列推送消息异常:{},推送内容:{}", e.getMessage(), result); + } + return result; + } + /** + * 发送异步的消息 + * @param topic 主题 + * @param tag 标签 + * @param key 自定义的key,根据业务来定 + * @param value 消息的内容 + * 通过调用 send() 方法,并传入一个 SendCallback 对象,在发送消息的同时可以继续处理其他逻辑,消息发送结果通过回调函数通知。 + */ + public SendResult sendAsyncProducerMessage(String topic, String tag, String key, String value){ + + try { + //创建一个消息实例,指定主题、标签和消息体。 + Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET)); + System.out.println("生产者发送消息:"+ JSON.toJSONString(value)); + producer.send(msg,new SendCallback() { + // 异步回调的处理 + @Override + public void onSuccess(SendResult sendResult) { + System.out.printf("%-10d 异步发送消息成功 %s %n", msg, sendResult.getMsgId()); + } + @Override + public void onException(Throwable e) { + System.out.printf("%-10d 异步发送消息失败 %s %n", msg, e); + e.printStackTrace(); + } + }); + } catch (MQClientException e) { + e.printStackTrace(); + } catch (RemotingException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + return null; + } + +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/service/IInitialBandwidthTrafficService.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/service/IInitialBandwidthTrafficService.java new file mode 100644 index 0000000..0571727 --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/service/IInitialBandwidthTrafficService.java @@ -0,0 +1,61 @@ +package com.ruoyi.rocketmq.service; + +import java.util.List; +import com.ruoyi.rocketmq.domain.InitialBandwidthTraffic; + +/** + * 初始带宽流量Service接口 + * + * @author gyt + * @date 2025-08-20 + */ +public interface IInitialBandwidthTrafficService +{ + /** + * 查询初始带宽流量 + * + * @param id 初始带宽流量主键 + * @return 初始带宽流量 + */ + public InitialBandwidthTraffic selectInitialBandwidthTrafficById(Long id); + + /** + * 查询初始带宽流量列表 + * + * @param initialBandwidthTraffic 初始带宽流量 + * @return 初始带宽流量集合 + */ + public List selectInitialBandwidthTrafficList(InitialBandwidthTraffic initialBandwidthTraffic); + + /** + * 新增初始带宽流量 + * + * @param initialBandwidthTraffic 初始带宽流量 + * @return 结果 + */ + public int insertInitialBandwidthTraffic(InitialBandwidthTraffic initialBandwidthTraffic); + + /** + * 修改初始带宽流量 + * + * @param initialBandwidthTraffic 初始带宽流量 + * @return 结果 + */ + public int updateInitialBandwidthTraffic(InitialBandwidthTraffic initialBandwidthTraffic); + + /** + * 批量删除初始带宽流量 + * + * @param ids 需要删除的初始带宽流量主键集合 + * @return 结果 + */ + public int deleteInitialBandwidthTrafficByIds(Long[] ids); + + /** + * 删除初始带宽流量信息 + * + * @param id 初始带宽流量主键 + * @return 结果 + */ + public int deleteInitialBandwidthTrafficById(Long id); +} diff --git a/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/service/impl/InitialBandwidthTrafficServiceImpl.java b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/service/impl/InitialBandwidthTrafficServiceImpl.java new file mode 100644 index 0000000..dad8cf0 --- /dev/null +++ b/ruoyi-rocketmq/src/main/java/com/ruoyi/rocketmq/service/impl/InitialBandwidthTrafficServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.rocketmq.service.impl; + +import java.util.List; +import com.ruoyi.common.core.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.rocketmq.mapper.InitialBandwidthTrafficMapper; +import com.ruoyi.rocketmq.domain.InitialBandwidthTraffic; +import com.ruoyi.rocketmq.service.IInitialBandwidthTrafficService; + +/** + * 初始带宽流量Service业务层处理 + * + * @author gyt + * @date 2025-08-20 + */ +@Service +public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTrafficService +{ + @Autowired + private InitialBandwidthTrafficMapper initialBandwidthTrafficMapper; + + /** + * 查询初始带宽流量 + * + * @param id 初始带宽流量主键 + * @return 初始带宽流量 + */ + @Override + public InitialBandwidthTraffic selectInitialBandwidthTrafficById(Long id) + { + return initialBandwidthTrafficMapper.selectInitialBandwidthTrafficById(id); + } + + /** + * 查询初始带宽流量列表 + * + * @param initialBandwidthTraffic 初始带宽流量 + * @return 初始带宽流量 + */ + @Override + public List selectInitialBandwidthTrafficList(InitialBandwidthTraffic initialBandwidthTraffic) + { + return initialBandwidthTrafficMapper.selectInitialBandwidthTrafficList(initialBandwidthTraffic); + } + + /** + * 新增初始带宽流量 + * + * @param initialBandwidthTraffic 初始带宽流量 + * @return 结果 + */ + @Override + public int insertInitialBandwidthTraffic(InitialBandwidthTraffic initialBandwidthTraffic) + { + initialBandwidthTraffic.setCreateTime(DateUtils.getNowDate()); + return initialBandwidthTrafficMapper.insertInitialBandwidthTraffic(initialBandwidthTraffic); + } + + /** + * 修改初始带宽流量 + * + * @param initialBandwidthTraffic 初始带宽流量 + * @return 结果 + */ + @Override + public int updateInitialBandwidthTraffic(InitialBandwidthTraffic initialBandwidthTraffic) + { + initialBandwidthTraffic.setUpdateTime(DateUtils.getNowDate()); + return initialBandwidthTrafficMapper.updateInitialBandwidthTraffic(initialBandwidthTraffic); + } + + /** + * 批量删除初始带宽流量 + * + * @param ids 需要删除的初始带宽流量主键 + * @return 结果 + */ + @Override + public int deleteInitialBandwidthTrafficByIds(Long[] ids) + { + return initialBandwidthTrafficMapper.deleteInitialBandwidthTrafficByIds(ids); + } + + /** + * 删除初始带宽流量信息 + * + * @param id 初始带宽流量主键 + * @return 结果 + */ + @Override + public int deleteInitialBandwidthTrafficById(Long id) + { + return initialBandwidthTrafficMapper.deleteInitialBandwidthTrafficById(id); + } +} diff --git a/ruoyi-rocketmq/src/main/resources/bootstrap.yml b/ruoyi-rocketmq/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..2abf4f3 --- /dev/null +++ b/ruoyi-rocketmq/src/main/resources/bootstrap.yml @@ -0,0 +1,35 @@ +# Tomcat +server: + port: 9207 + +# Spring +spring: + application: + # 应用名称 + name: ruoyi-rocketmq + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 127.0.0.1:8848 + config: + # 配置中心地址 + server-addr: 127.0.0.1:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + + redisson: + singleServerConfig: + address: redis://localhost:6379 +logging: + level: + com.ruoyi.app.mapper: DEBUG + + + diff --git a/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialBandwidthTrafficMapper.xml b/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialBandwidthTrafficMapper.xml new file mode 100644 index 0000000..732ddcc --- /dev/null +++ b/ruoyi-rocketmq/src/main/resources/mapper/rocketmq/InitialBandwidthTrafficMapper.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, interface_name, mac_address, operation_status, interface_type, ipv4_address, inbound_packet_loss, outbound_packet_loss, receive_bandwidth, send_bandwidth, create_time, update_time, create_by, update_by from initial_bandwidth_traffic + + + + + + + + insert into initial_bandwidth_traffic + + id, + interface_name, + mac_address, + operation_status, + interface_type, + ipv4_address, + inbound_packet_loss, + outbound_packet_loss, + receive_bandwidth, + send_bandwidth, + create_time, + update_time, + create_by, + update_by, + + + #{id}, + #{interfaceName}, + #{macAddress}, + #{operationStatus}, + #{interfaceType}, + #{ipv4Address}, + #{inboundPacketLoss}, + #{outboundPacketLoss}, + #{receiveBandwidth}, + #{sendBandwidth}, + #{createTime}, + #{updateTime}, + #{createBy}, + #{updateBy}, + + + + + update initial_bandwidth_traffic + + interface_name = #{interfaceName}, + mac_address = #{macAddress}, + operation_status = #{operationStatus}, + interface_type = #{interfaceType}, + ipv4_address = #{ipv4Address}, + inbound_packet_loss = #{inboundPacketLoss}, + outbound_packet_loss = #{outboundPacketLoss}, + receive_bandwidth = #{receiveBandwidth}, + send_bandwidth = #{sendBandwidth}, + create_time = #{createTime}, + update_time = #{updateTime}, + create_by = #{createBy}, + update_by = #{updateBy}, + + where id = #{id} + + + + delete from initial_bandwidth_traffic where id = #{id} + + + + delete from initial_bandwidth_traffic where id in + + #{id} + + + + \ No newline at end of file diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/RocketMQApplication.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/RocketMQApplication.java new file mode 100644 index 0000000..4ec745a --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/RocketMQApplication.java @@ -0,0 +1,25 @@ +package com.ruoyi.testrocketmq; + +import com.ruoyi.common.security.annotation.EnableCustomConfig; +import com.ruoyi.common.security.annotation.EnableRyFeignClients; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableAsync; + +/** + * 平台管理模块 + * + * @author ruoyi + */ +@EnableCustomConfig +@EnableRyFeignClients +@SpringBootApplication +@EnableAsync +public class RocketMQApplication +{ + public static void main(String[] args) + { + SpringApplication.run(RocketMQApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ RocketMQ模块启动成功 ლ(´ڡ`ლ)゙"); + } +} diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/config/ConsumerConfig.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/config/ConsumerConfig.java new file mode 100644 index 0000000..38ebbae --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/config/ConsumerConfig.java @@ -0,0 +1,64 @@ +package com.ruoyi.testrocketmq.config; + +import com.ruoyi.testrocketmq.consumer.RocketMsgListener; +import com.ruoyi.testrocketmq.enums.MessageCodeEnum; +import com.ruoyi.testrocketmq.model.ConsumerMode; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.common.consumer.ConsumeFromWhere; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * 消费者配置 + */ +@RefreshScope +@Configuration +@Slf4j +public class ConsumerConfig { + @Autowired + private ConsumerMode consumerMode; + + @Bean + public DefaultMQPushConsumer getRocketMQConsumer() throws MQClientException { +// ConsumerMode consumerMode = new ConsumerMode(); + DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(consumerMode.getGroupName()); + consumer.setNamesrvAddr(consumerMode.getNamesrvAddr()); + consumer.setConsumeThreadMin(consumerMode.getConsumeThreadMin()); + consumer.setConsumeThreadMax(consumerMode.getConsumeThreadMax()); + consumer.registerMessageListener(new RocketMsgListener()); + /** + * 1. CONSUME_FROM_LAST_OFFSET:第一次启动从队列最后位置消费,后续再启动接着上次消费的进度开始消费 + * 2. CONSUME_FROM_FIRST_OFFSET:第一次启动从队列初始位置消费,后续再启动接着上次消费的进度开始消费 + * 3. CONSUME_FROM_TIMESTAMP:第一次启动从指定时间点位置消费,后续再启动接着上次消费的进度开始消费 + * 以上所说的第一次启动是指从来没有消费过的消费者,如果该消费者消费过,那么会在broker端记录该消费者的消费位置,如果该消费者挂了再启动,那么自动从上次消费的进度开始 + */ + consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET); + /** + * CLUSTERING (集群模式) :默认模式,同一个ConsumerGroup(groupName相同)每个consumer只消费所订阅消息的一部分内容,同一个ConsumerGroup里所有的Consumer消息加起来才是所 + * 订阅topic整体,从而达到负载均衡的目的 + * BROADCASTING (广播模式) :同一个ConsumerGroup每个consumer都消费到所订阅topic所有消息,也就是一个消费会被多次分发,被多个consumer消费。 + * + */ + // consumer.setMessageModel(MessageModel.BROADCASTING); + + consumer.setVipChannelEnabled(false); + consumer.setConsumeMessageBatchMaxSize(consumerMode.getConsumeMessageBatchMaxSize()); + try { + /** + * 订阅topic,可以对指定消息进行过滤,例如:"TopicTest","tagl||tag2||tag3",*或null表示topic所有消息 + */ + consumer.subscribe(MessageCodeEnum.ORDER_MESSAGE.getCode(),"*"); + consumer.subscribe(MessageCodeEnum.USER_MESSAGE.getCode(),"*"); + consumer.start(); + log.info("消费者初始化成功:{}", consumer.toString()); + } catch (MQClientException e) { + e.printStackTrace(); + log.error("消费者初始化失败:{}",e.getMessage()); + } + return consumer; + } +} diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/config/MessageConfig.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/config/MessageConfig.java new file mode 100644 index 0000000..1d4b56e --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/config/MessageConfig.java @@ -0,0 +1,27 @@ +package com.ruoyi.testrocketmq.config; + +/** + * @author yz + */ +public class MessageConfig { + private Class messageClass; + private boolean orderlyMessage; + + public Class getMessageClass() { + return messageClass; + } + + public void setMessageClass(Class messageClass) { + this.messageClass = messageClass; + } + + public boolean isOrderlyMessage() { + return orderlyMessage; + } + + public void setOrderlyMessage(boolean orderlyMessage) { + this.orderlyMessage = orderlyMessage; + } + + +} diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/config/ProducerConfig.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/config/ProducerConfig.java new file mode 100644 index 0000000..b55917e --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/config/ProducerConfig.java @@ -0,0 +1,48 @@ +package com.ruoyi.testrocketmq.config; + +import com.ruoyi.testrocketmq.model.ProducerMode; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.DefaultMQProducer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + + +@Configuration +@Slf4j +public class ProducerConfig { + + public static DefaultMQProducer producer; + + @Autowired + private ProducerMode producerMode; + + + + @Bean + public DefaultMQProducer getRocketMQProducer() { + producer = new DefaultMQProducer(producerMode.getGroupName()); + producer.setNamesrvAddr(producerMode.getNamesrvAddr()); + //如果需要同一个jvm中不同的producer往不同的mq集群发送消息,需要设置不同的instanceName + if(producerMode.getMaxMessageSize()!=null){ + producer.setMaxMessageSize(producerMode.getMaxMessageSize()); + } + if(producerMode.getSendMsgTimeout()!=null){ + producer.setSendMsgTimeout(producerMode.getSendMsgTimeout()); + } + //如果发送消息失败,设置重试次数,默认为2次 + if(producerMode.getRetryTimesWhenSendFailed()!=null){ + producer.setRetryTimesWhenSendFailed(producerMode.getRetryTimesWhenSendFailed()); + } + producer.setVipChannelEnabled(false); + try { + producer.start(); + log.info("生产者初始化成功:{}",producer.toString()); + } catch (MQClientException e) { + log.error("生产者初始化失败:{}",e.getMessage()); + } + return producer; + } + +} diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/consumer/RocketMsgListener.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/consumer/RocketMsgListener.java new file mode 100644 index 0000000..88d2b05 --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/consumer/RocketMsgListener.java @@ -0,0 +1,100 @@ +package com.ruoyi.testrocketmq.consumer; + +import com.ruoyi.testrocketmq.enums.MessageCodeEnum; +import com.ruoyi.testrocketmq.producer.ConsumeException; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import org.apache.rocketmq.common.message.MessageExt; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.io.UnsupportedEncodingException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + * 消息监听 + */ +@Slf4j +@Component +public class RocketMsgListener implements MessageListenerConcurrently { + + /** + * 消费消息 + * + * @param list msgs.size() >= 1 + * DefaultMQPushConsumer.consumeMessageBatchMaxSize=1,you can modify here + * 这里只设置为1,当设置为多个时,list中只要有一条消息消费失败,就会整体重试 + * @param consumeConcurrentlyContext 上下文信息 + * @return 消费状态 成功(CONSUME_SUCCESS)或者 重试 (RECONSUME_LATER) + */ + @Override + public ConsumeConcurrentlyStatus consumeMessage(List list, ConsumeConcurrentlyContext consumeConcurrentlyContext) { + + if (!CollectionUtils.isEmpty(list)) { + for (MessageExt messageExt : list) { + // 消息内容 + String body = new String(messageExt.getBody()); + log.info("接受到的消息为:{}", body); + String tags = messageExt.getTags(); + String topic = messageExt.getTopic(); + String msgId = messageExt.getMsgId(); + String keys = messageExt.getKeys(); + int reConsume = messageExt.getReconsumeTimes(); + // 消息已经重试了3次,如果不需要再次消费,则返回成功 + if (reConsume == 3) { + // TODO 补偿信息 + //smsLogService.insertLog(topic, tags, msgId, keys, body, "【" + EnumUtil.getStrMsgByCode(tags, TagsCodeEnum.class) + "】消费失败"); + log.error("消息重试超过3次,消费失败!"); + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } + // 订单超时处理 + if (MessageCodeEnum.ORDER_MESSAGE.getCode().equals(topic)) { + if (MessageCodeEnum.ORDER_TIMEOUT_TAG.getCode().equals(tags)) { +// //获取订单 +// DealUserOrder dealUserOrder = pcRemoteDealUserOrderService.selectDealUserOrderByOrderNumber(keys); +// if (dealUserOrder != null) { +// //订单状态超时未支付关闭订单 处理 +// if (dealUserOrder.getStatus().equals("1")) { +// DealUserOrder dealUserOrders = new DealUserOrder(); +// dealUserOrders.setOrderId(dealUserOrder.getOrderId()); +// dealUserOrders.setStatus("4"); +// pcRemoteDealUserOrderService.updateDealUserOrder(dealUserOrders); +// return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; +// } +// log.info("Order does not exist."); +// } + log.info("Consumption success:" + body); + DateFormat format =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + log.info("Consumption time:{}", format.format(new Date())); + } else { + log.info("未匹配到Tag【{}】" + tags); + } + } + } + } + // 消息消费成功 + //ConsumeConcurrentlyStatus.RECONSUME_LATER broker会根据设置的messageDelayLevel发起重试,默认16次 + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } + + /** + * 异常处理 + * + * @param e 捕获的异常 + * @return 消息消费结果 + */ + private static ConsumeConcurrentlyStatus handleException(final Exception e) { + Class exceptionClass = e.getClass(); + if (exceptionClass.equals(UnsupportedEncodingException.class)) { + log.error(e.getMessage()); + } else if (exceptionClass.equals(ConsumeException.class)) { + log.error(e.getMessage()); + } + return ConsumeConcurrentlyStatus.RECONSUME_LATER; + } +} diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/enums/MessageCodeEnum.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/enums/MessageCodeEnum.java new file mode 100644 index 0000000..e6ff8c4 --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/enums/MessageCodeEnum.java @@ -0,0 +1,60 @@ +package com.ruoyi.testrocketmq.enums; + + +import lombok.Getter; + +@Getter +public enum MessageCodeEnum { + /** + * 消息模块主题 + */ + MESSAGE_TOPIC("elink-message","消息服务模块topic名称"), + /** + * 系统消息 + */ + NOTE_MESSAGE("system-message","系统消息服务模块topic名称"), + /** + * 用户消息 + */ + USER_MESSAGE("user-message","用户消息服务模块topic名称"), + + /** + * 订单消息 + */ + ORDER_MESSAGE("order-message","订单消息服务模块topic名称"), + + /** + * 平台编号 + */ + USER_MESSAGE_TAG("user_message_tag","用户消息推送"), + NOTE_MESSAGE_TAG("system_message_tag","系统消息推送"), + ORDER_MESSAGE_TAG("order_message_tag","订单消息推送"), + + /** + * 订单处理编号 + */ + //订单超时处理 + ORDER_TIMEOUT_TAG("order_timeout_tag","订单超时处理"); + + + private final String code; + private final String msg; + + MessageCodeEnum(String code, String msg){ + this.code = code; + this.msg = msg; + } + + public static String valuesOfType(String code) { + String value = ""; + for (MessageCodeEnum e : MessageCodeEnum.values()) { + if (code.equals(e.code)) { + value = e.msg; + } + + } + return value; + } + + +} diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/model/ConsumerMode.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/model/ConsumerMode.java new file mode 100644 index 0000000..e66738a --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/model/ConsumerMode.java @@ -0,0 +1,22 @@ +package com.ruoyi.testrocketmq.model; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +@Data +@Configuration +@Component +public class ConsumerMode { + @Value("${suning.rocketmq.namesrvAddr}") + private String namesrvAddr; + @Value("${suning.rocketmq.conumer.groupName}") + private String groupName ; + @Value("${suning.rocketmq.conumer.consumeThreadMin}") + private int consumeThreadMin; + @Value("${suning.rocketmq.conumer.consumeThreadMax}") + private int consumeThreadMax; + @Value("${suning.rocketmq.conumer.consumeMessageBatchMaxSize}") + private int consumeMessageBatchMaxSize; +} diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/model/ProducerMode.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/model/ProducerMode.java new file mode 100644 index 0000000..0cd4060 --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/model/ProducerMode.java @@ -0,0 +1,25 @@ +package com.ruoyi.testrocketmq.model; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.Configuration; + +/** + * 生产者初始化 + */ +@RefreshScope +@Data +@Configuration +public class ProducerMode { + @Value("${suning.rocketmq.producer.groupName}") + private String groupName; + @Value("${suning.rocketmq.namesrvAddr}") + private String namesrvAddr; + @Value("${suning.rocketmq.producer.maxMessageSize}") + private Integer maxMessageSize; + @Value("${suning.rocketmq.producer.sendMsgTimeout}") + private Integer sendMsgTimeout; + @Value("${suning.rocketmq.producer.retryTimesWhenSendFailed}") + private Integer retryTimesWhenSendFailed; +} diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/AsyncProducer.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/AsyncProducer.java new file mode 100644 index 0000000..86ed05c --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/AsyncProducer.java @@ -0,0 +1,47 @@ +package com.ruoyi.testrocketmq.producer; + +import com.ruoyi.testrocketmq.config.ProducerConfig; +import org.springframework.beans.factory.annotation.Autowired; + +public class AsyncProducer { + + @Autowired + private ProducerConfig producerConfig; + + /** + * 发送异步的消息 + * @param topic 主题 + * @param tag 标签 + * @param key 自定义的key,根据业务来定 + * @param value 消息的内容 + * @return org.apache.rocketmq.client.producer.SendResult + */ +// public SendResult sendAsyncProducerMessage(String topic, String tag, String key, String value) throws UnsupportedEncodingException { +// +// try { +// DefaultMQProducer defaultMQProducer = producerConfig.producer; +// //Create a message instance, specifying topic, tag and message body. +// Message msg = new Message(topic, tag, key,value.getBytes(RemotingHelper.DEFAULT_CHARSET)); +// defaultMQProducer.send(msg, new SendCallback() { +// // 异步回调的处理 +// @Override +// public void onSuccess(SendResult sendResult) { +// System.out.printf("%-10d 异步发送消息成功 %s %n", msg, sendResult.getMsgId()); +// } +// +// @Override +// public void onException(Throwable e) { +// System.out.printf("%-10d 异步发送消息失败 %s %n", msg, e); +// e.printStackTrace(); +// } +// }); +// } catch (MQClientException e) { +// e.printStackTrace(); +// } catch (RemotingException e) { +// e.printStackTrace(); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// return null; +// } +} diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/ConsumeException.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/ConsumeException.java new file mode 100644 index 0000000..82d4314 --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/ConsumeException.java @@ -0,0 +1,20 @@ +package com.ruoyi.testrocketmq.producer; + +/** + * @author 影子 + */ +public class ConsumeException extends RuntimeException{ + private static final long serialVersionUID = 4093867789628938836L; + + public ConsumeException(String message) { + super(message); + } + + public ConsumeException(Throwable cause) { + super(cause); + } + + public ConsumeException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/MessageContext.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/MessageContext.java new file mode 100644 index 0000000..fa6afbe --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/MessageContext.java @@ -0,0 +1,34 @@ +package com.ruoyi.testrocketmq.producer; + + + +import lombok.Data; +import lombok.ToString; +import org.apache.rocketmq.common.message.MessageExt; +import org.apache.rocketmq.common.message.MessageQueue; + +/** + * 消费时,当前所消费的消息的上下文信息 + * + * @author jolly + */ +@ToString +@Data +public final class MessageContext { + + /** + * 所消费消息所在的消息队列 + * + * @see MessageQueue + */ + private MessageQueue messageQueue; + + /** + * 所消费的消息的扩展属性 + * + * @see MessageExt + */ + private MessageExt messageExt; + + +} diff --git a/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/MessageProducer.java b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/MessageProducer.java new file mode 100644 index 0000000..7450530 --- /dev/null +++ b/ruoyi-rocketmq/src/test/java/com/ruoyi/testrocketmq/producer/MessageProducer.java @@ -0,0 +1,110 @@ +package com.ruoyi.testrocketmq.producer; + +import com.alibaba.fastjson.JSON; +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.client.exception.MQBrokerException; +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.client.producer.SendResult; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.remoting.common.RemotingHelper; +import org.apache.rocketmq.remoting.exception.RemotingException; + +import java.io.UnsupportedEncodingException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import static com.ruoyi.rocketmq.config.ProducerConfig.producer; + +/** + * 消息发送 + */ +@Slf4j +public class MessageProducer { + + + /** + * 同步发送消息 + * @param topic 主题 + * @param tag 标签 + * @param key 自定义的key,根据业务来定 + * @param value 消息的内容 + * @return org.apache.rocketmq.client.producer.SendResult + */ + public SendResult sendSynchronizeMessage(String topic, String tag, String key, String value){ + String body = "topic:【"+topic+"】, tag:【"+tag+"】, key:【"+key+"】, value:【"+value+"】"; + try { + Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET)); + System.out.println("生产者发送消息:"+ JSON.toJSONString(value)); + SendResult result = producer.send(msg); + return result; + } catch (UnsupportedEncodingException e) { + log.error("消息初始化失败!body:{}",body); + + } catch (MQClientException | InterruptedException | RemotingException | MQBrokerException e) { + log.error("消息发送失败! body:{}",body); + } + return null; + } + + + + /** + * 发送有序的消息 + * @param messagesList Message集合 + * @param messageQueueNumber 消息队列编号 + * @return org.apache.rocketmq.client.producer.SendResult + */ + public SendResult sendOrderlyMessage(List messagesList, int messageQueueNumber) { + SendResult result = null; + for (Message message : messagesList) { + try { +// DefaultMQProducer defaultMQProducer = ProducerConfig.producer.send(message); +// System.out.println(defaultMQProducer); + result = producer.send(message, (list, msg, arg) -> { + Integer queueNumber = (Integer) arg; + return list.get(queueNumber); + }, messageQueueNumber); + } catch (MQClientException | RemotingException | MQBrokerException | InterruptedException e) { + log.error("发送有序消息失败"); + return result; + } + } + return result; + } + + /** + * 推送延迟消息 + * @param topic + * @param tag + * @param key + * @return boolean + */ + public SendResult sendDelayMessage(String topic, String tag, String key, String value) + { + SendResult result = null; + try + { + Message msg = new Message(topic,tag,key, value.getBytes(RemotingHelper.DEFAULT_CHARSET)); + //设置消息延迟级别,我这里设置5,对应就是延时一分钟 + // "1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h" + msg.setDelayTimeLevel(4); + // 发送消息到一个Broker + result = producer.send(msg); + // 通过sendResult返回消息是否成功送达 + log.info("发送延迟消息结果:======sendResult:{}", result); + DateFormat format =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + log.info("发送时间:{}", format.format(new Date())); + return result; + } + catch (Exception e) + { + e.printStackTrace(); + log.error("延迟消息队列推送消息异常:{},推送内容:{}", e.getMessage(), result); + } + return result; + } + + +}