153 Commits
Author SHA1 Message Date
Your Name 94ad6d1f5a 流量数据的查询依然不稳定 完全重写绕开IP和MAC的变更问题 2026-08-10 21:18:12 +08:00
Your Name afdeb7116d 流量数据的关联由mac改成ip 因为mac是虚拟的重启后会变 不稳定 2026-08-07 14:34:13 +08:00
Your Name 92571fed91 使用先查后改解决批量插入在并发时的死锁问题;
设备95值保存失败的原因是数据库mac_address字段长度不足,改为500后正常保存。
2026-07-27 10:53:21 +08:00
Your Name 368121b938 修复部分设备注册时networklist为null导致的失败问题 2026-07-27 10:50:32 +08:00
gaoyutao c918523a7a 增加服务器分配负责人功能 2026-04-07 17:36:39 +08:00
gaoyutao 4d39627d96 增加可选服务器所属交换机功能。 2026-04-03 09:39:43 +08:00
gaoyutao feaa0b4b97 1、交换机管理增加下架接口。
2、流量图改为有ipv6展示,没有就不展示。
2026-04-01 17:46:23 +08:00
gaoyutao 4839ea178b 区分配置文件、修复通知报错问题 2026-03-30 17:59:06 +08:00
gaoyutao 011a93585c 优化省市运营商信息处理。 2026-03-25 17:55:37 +08:00
gaoyutao 20d0af6dbd 业务流量对齐x轴 2026-03-24 13:05:54 +08:00
gaoyutao 8ed47cd95e 修复业务流量与时间轴错位问题。 2026-03-20 17:56:19 +08:00
gaoyutao fcd392ec10 1、优化ipv6判断.
2、优化业务流量数据统计。
2026-03-19 17:56:32 +08:00
gaoyutao 2e3b2af397 1、新增业务进程与名称对应表。
2、新增业务流量查询逻辑。
2026-03-18 18:06:11 +08:00
gaoyutao fb27c1c0e0 优化业务流量存储 2026-03-17 17:59:08 +08:00
gaoyutao 00b2230773 1、agent批量更新限制10台设备。 2026-03-13 17:58:45 +08:00
gaoyutao 268c0f319d 优化ping丢包率告警 2026-03-12 18:04:43 +08:00
gaoyutao 03a77cc741 增加ping丢包率告警 2026-03-11 17:55:42 +08:00
gaoyutao cffcb2efd3 saas平台联调agent存储业务流量。
优化ip存储,未探测到,保留上次结果。
2026-03-10 17:50:48 +08:00
gaoyutao d4902a488d 1、优化告警信息展示。
2、搜索栏增加备注搜索模糊查询。
2026-03-09 18:11:17 +08:00
gaoyutao bbb50ba56f 新增业务流量入库方法。
增加自动创建业务流量分表方法
2026-03-06 17:58:08 +08:00
gaoyutao 03f9609e28 修复个别机器出省流量统计失败问题。
增加日95利用率排序
2026-03-03 17:44:52 +08:00
gaoyutao a1552e34b4 补充磁盘自动建表字段 2026-03-02 17:58:47 +08:00
gaoyutao 67a627054b 流量补全消费者改为缓存排序处理,保证顺序。 2026-02-28 18:01:30 +08:00
gaoyutao 00fffd0aef 优化内存详细逻辑。 2026-02-27 17:50:43 +08:00
gaoyutao 05c67476e6 优化历史消息处理 2026-02-26 17:59:05 +08:00
gaoyutao 9fdafe542d 增加内存详细处理、优化历史消息处理 2026-02-26 14:07:37 +08:00
gaoyutao 00d574fb5f 新建公告用户表 2026-02-12 17:53:21 +08:00
gaoyutao 3c1edfcd2e 1、优化服务器管理列表ip分页展示。
2、集成rustfs SDK。
3、测试交换机数据IoTDB入库。
2026-02-11 18:02:55 +08:00
gaoyutao 8cc321bf14 1、增加对象存储初始模块
2、优化出省流量统计展示。
2026-02-10 18:19:22 +08:00
gaoyutao 5b28479625 1、优化服务器管理列表运营商、省、ip展示。
2、服务器管理列表搜索条件增加子网卡ip筛选。
2026-02-09 13:45:12 +08:00
gaoyutao 0fdce6b13b 处理磁盘健康数据 2026-02-06 17:11:00 +08:00
gaoyutao 60db343cb0 1、适配cpu信息表、容器信息表、挂载点信息表分表。
2、agent增加采集磁盘健康状态。
3、优化磁盘上报数据处理。
2026-02-05 18:04:34 +08:00
gaoyutao 0fb6a33f2e 增加出省流量占比过高告警 2026-02-05 11:17:21 +08:00
gaoyutao 5dd9004081 1、优化tcpdump解析速度。
2、补充tcpdump晚8点默认策略下发。
3、服务器管理列表增加出省流量占比列。
2026-02-04 17:41:00 +08:00
gaoyutao f8e0ab1b2a 1、内存利用率图标增加内存已用字段。
2、ping丢包率虚拟网卡模式累加。
2026-02-03 18:46:51 +08:00
gaoyutao 180c522ca3 增加历史消息消费接口 2026-02-03 14:07:55 +08:00
gaoyutao 180986ba16 修复磁盘NPE 2026-01-30 21:21:48 +08:00
gaoyutao f75a49474a 出省流量统计增加立即执行、增加占比总计、不同运营商也统计.
磁盘统计HDD改为所有磁盘、速率单位改为 MB/s、流量图开始时间修正。
流量95值收益优化
2026-01-30 19:17:00 +08:00
gaoyutao 9809ae673c 优化95值计算 2026-01-30 10:14:11 +08:00
gaoyutao 1dab9b1cf4 优化agent本地存储流量数据处理 2026-01-29 12:00:05 +08:00
gaoyutao 29a30b1f52 补充单位转化方法 2026-01-28 09:46:54 +08:00
gaoyutao 589c80fa6f 挂载点数据增加已用存储空间字段 2026-01-27 19:08:16 +08:00
gaoyutao 3ef0aacf0c 优化95值计算相关数据查看 2026-01-27 11:27:55 +08:00
gaoyutao 5dd1b90acb 1、修复虚拟网卡收益计算、流量图默认单位不正确问题。
2、联调告警阈值配置接口。
3、优化挂载点数据展示。
2026-01-26 18:52:52 +08:00
gaoyutao edddf77b6a 优化告警内容 2026-01-23 19:18:08 +08:00
gaoyutao 5564b03ed2 开发监控看板组管理CRUD
设计告警阈值配置功能
2026-01-23 18:39:20 +08:00
gaoyutao 493ecba0ba 1、优化agent本地存储流量文件删除逻辑。
2、开发tcpdump探测策略下发接口。
3、开发tcpdump探测接口。
4、开发出省流量计算统计接口。
2026-01-22 18:00:17 +08:00
gaoyutao fe0225012f 开发tcpdump策略表CRUD 2026-01-21 18:15:30 +08:00
gaoyutao b384aa8db5 开发tcpdump策略表CRUD 2026-01-21 18:11:14 +08:00
gaoyutao 31cf6dbb04 增加流量重试入库功能 2026-01-20 18:04:23 +08:00
gaoyutao 14a750a736 1、所有流量表新增字段ping丢包率。
2、开发ping丢包率图形接口。
2026-01-19 18:17:23 +08:00
gaoyutao 4ed1a66466 增加cpu温度处理 2026-01-16 18:11:16 +08:00
gaoyutao d62fe4b99a 1、增加磁盘HDD类型已用空间图形接口。
2、增加磁盘HDD类型总空间字段计算。
3、增加硬盘设备监控列表接口。
2026-01-16 15:10:31 +08:00
gaoyutao f39aa887c8 磁盘数据表分表,适配磁盘数据名称存储表。
磁盘相关功能
2026-01-15 18:14:17 +08:00
gaoyutao c921a83d27 磁盘表分表,增加磁盘名称存储CRUD 2026-01-15 10:27:40 +08:00
gaoyutao ac406d88fe 修复pppoe配置界面异常bug 2026-01-13 18:43:56 +08:00
gaoyutao 2b2f70a910 修复昨日95值没计算bug。 2026-01-13 10:05:54 +08:00
gaoyutao 5c9ae4fba4 pppoe配置增加5个字段。 2026-01-12 18:27:57 +08:00
gaoyutao 14b0e39d5b 优化详情升级到最新 2026-01-09 19:18:21 +08:00
gaoyutao 52090c6f37 优化平台ppoe和非平台ppoe配置方式的虚拟网卡上报带宽值处理.
优化pppoe虚拟网卡处理逻辑
2026-01-09 18:04:13 +08:00
gaoyutao f5f5a97744 优化pppoe数据处理
流量图改为只保留有ipv4的流量网卡流量。
流量图增加显示对应的ipv4。
2026-01-08 18:24:05 +08:00
gaoyutao d7432bc53f 补充注解 2026-01-08 09:34:57 +08:00
gaoyutao ea6caa0211 优化网卡名称变更处理
增加非saas平台拨号数据处理
优化详情信息
2026-01-07 19:20:01 +08:00
gaoyutao 86d7385c15 FRPC运行状态在服务器离线时改为未运行
时序数据库入库测试
网卡名称同步修改
2026-01-06 19:29:41 +08:00
gaoyutao a2659d0c6b 交换机数据采集唯一标识改为clientId。
优化收益计算
2026-01-05 18:32:49 +08:00
gaoyutao 2593c58741 服务器系统其他信息数据表分表。
交换机光模块信息数据表分表。
2026-01-04 18:10:13 +08:00
gaoyutao 4651da4fe4 开发庭与科技详情相关接口。
优化PppoE查询接口。
2025-12-31 17:59:33 +08:00
gaoyutao 08680bb46a 单网卡总流量、ipv4流量、ipv6流量合并到一个图
pppoe状态上报增加
2025-12-30 18:23:09 +08:00
gaoyutao 6e2ca8ac53 增加服务器下架处理,
服务器详情增加agent最新版本、cpu核数、内存字段。
开发pppoe主表及子表CRUD
2025-12-29 18:25:32 +08:00
gaoyutao c852fbd506 优化敏感词 2025-12-29 10:05:24 +08:00
gaoyutao 16a28f798b 优化敏感词、作者改为tongran 2025-12-26 19:00:41 +08:00
gaoyutao 30373bbb1e 交换机管理图形监控只展示端口为up的。
优化frp信息上报
2025-12-24 19:55:47 +08:00
gaoyutao 5eda46802e 开发frpc接口、增加网卡绑定触发逻辑。 2025-12-23 18:55:27 +08:00
gaoyutao 1af9d3fbc5 1、修复昨日95值不显示问题。
2、开发frpc端口自动分配功能。
2025-12-22 18:51:48 +08:00
gaoyutao 4e7a30ed61 增加取消告警闪烁功能 2025-12-19 18:45:15 +08:00
gaoyutao 5ab1b6e8a4 v1.3初始化 2025-12-18 16:45:31 +08:00
gaoyutao 92cf598941 修复列表管理网卡信息不显示问题。
修复多网卡图形监控异常问题。
2025-12-18 15:28:25 +08:00
gaoyutao 343028ade5 1、优化子网卡流量图形展示。
2、优化接口名称存储逻辑,减少死锁。
3、增加cpu利用率内存利用率字段。
2025-12-17 18:18:19 +08:00
gaoyutao 597b5dad01 修复服务器、交换机月收益不展示95值问题。 2025-12-16 20:59:40 +08:00
gaoyutao e818c0319e 修复图形x轴时间跨界问题、交换机月收益不展示95值问题。
ipv4 ipv6增加子网卡统计
2025-12-16 17:56:49 +08:00
gaoyutao 6d3b5201e0 增加存储子网卡信息、修复子网卡流量递增问题
子网卡流量图合并
2025-12-15 19:50:44 +08:00
gaoyutao 9a81408ada 更改业务IP绑定、静态路由添加逻辑。
拓扑管理对端交换机名称处理
2025-12-12 15:43:16 +08:00
gaoyutao f3bdfbc6bf 1、定位并解决收益未自动生成问题。
2、优化服务器列表筛选条件查询速度。
2025-12-11 19:18:59 +08:00
gaoyutao 2eaf62ea82 优化服务器列表查询速度、筛选条件bug修复。
ipv4、ipv6初始流量处理。
增加日志排查收益未自动生成问题。
2025-12-10 18:32:07 +08:00
gaoyutao 13e51c11e1 权限控制优化 2025-12-09 19:25:51 +08:00
gaoyutao 1f133e8c05 权限控制增加
优化ipv4、ipv6流量展示
2025-12-08 19:23:53 +08:00
gaoyutao cd8cafaf3f 优化服务器管理详情 2025-12-05 20:00:38 +08:00
gaoyutao cbf017a8e2 优化排序和查询速度 2025-12-05 19:46:35 +08:00
gaoyutao 802e668d9a 相关接口增加ipv4、ipv6出入流量字段。
服务器管理列表新增字段和排序。
优化监控看板流量统计。
2025-12-05 18:59:02 +08:00
gaoyutao 9dee067a87 服务器流量增加ipv4、ipv6协议区分 2025-12-04 18:26:48 +08:00
gaoyutao a5b5f5b08d 1、mtr探测设备增加并发限制。
2、开发防火墙策略区分ipv4和ipv6。
3、脚本执行策略下发时间优化。
2025-12-03 19:18:12 +08:00
gaoyutao a40a6f344e 优化执行结果查看分页 2025-12-02 18:41:18 +08:00
gaoyutao 7d26d2fb3b 优化mtr探测策略、增加ipv6相关字段 2025-12-01 18:15:46 +08:00
gaoyutao ed6c0a4c80 优化mtr探测策略 2025-11-28 18:44:20 +08:00
gaoyutao 2f8fd79de5 优化mtr探测策略
告警日志增加业务名称、告警推送是否成功字段
2025-11-27 18:36:33 +08:00
gaoyutao 31e1f7f8dc 修复网卡信息有变动saas平台未及时更新、脚本策略下发未返回结果bug。
优化mtr探测策略
2025-11-26 18:13:26 +08:00
gaoyutao afbf1eead0 服务器管理添加标签功能。
优化mtr探测结果存储。
2025-11-25 18:18:51 +08:00
gaoyutao a0b0b57110 初始化README 2025-11-24 16:27:05 +08:00
gaoyutao de49404116 初始化v1.2 2025-11-24 16:19:09 +08:00
gaoyutao c0f51ef007 优化交换机分表、新增丢包率clientId记录 2025-11-24 14:00:49 +08:00
gaoyutao c6e778c74e 交换机流量数据表改为分表 2025-11-21 18:32:03 +08:00
gaoyutao be2d123902 优化mtr探测策略下发 2025-11-21 13:24:57 +08:00
gaoyutao 3391b949c8 测试环境配置、新增mtr探测丢包率结果存储方法 2025-11-20 18:10:17 +08:00
gaoyutao 947d60f788 优化图形补0、null机制,优化监控看板接口
mtr监控策略相关接口
2025-11-19 18:38:35 +08:00
gaoyutao 54fafb90bd 优化服务器管理搜索、监控看板优化 2025-11-19 11:31:43 +08:00
gaoyutao 12ca2b2066 补充mtragent管理初版 2025-11-18 18:22:03 +08:00
gaoyutao c91504912b 优化查看脚本执行结果、mtragent管理初版 2025-11-18 18:21:04 +08:00
gaoyutao bd65b27605 优化监控看板、初始化mtr模块 2025-11-17 18:06:37 +08:00
gaoyutao 68e042d9fc 优化告警日志 2025-11-14 18:50:58 +08:00
gaoyutao 1adc72032a 优化执行结果根据失败关键字筛选
优化告警日志
监控看板概览功能
2025-11-14 18:48:27 +08:00
gaoyutao d9bd70860c 脚本管理页面增加字段、执行结果根据失败关键字筛选
优化菜单点击方法、优化心跳处理
2025-11-13 18:08:05 +08:00
gaoyutao 50d817091e 优化告警日志、消息推送 2025-11-13 13:02:58 +08:00
gaoyutao 2910280746 优化交换机监控策略、交换机管理分页查询 2025-11-13 10:28:17 +08:00
gaoyutao 4da0c86ca4 告警日志、推送消息接口、图形监控排序优化
监控看板相关接口、单点击计数接口开发
2025-11-12 18:05:09 +08:00
gaoyutao 70e943269a 设计消息推送数据表、开发消息推送相关逻辑方法。 2025-11-11 18:03:50 +08:00
gaoyutao 5c3b6df591 优化实时95值计算流量科学计数法、服务器底层流量所有业务网卡流量求和 2025-11-11 10:55:21 +08:00
gaoyutao 80533dc1a3 导出优化、告警日志方法增加 2025-11-10 18:17:59 +08:00
gaoyutao 4137028deb agent更新按最后一次更新时间排序、服务器管理多条件分页查询优化、服务器底层流量科学计数法优化 2025-11-10 12:00:50 +08:00
gaoyutao 4d1503e988 底层bit流量不保留小数、服务器监控策略clientId换行分割 2025-11-07 18:19:51 +08:00
gaoyutao a5b304c809 补0变为补null、单位最小Kb、服务器在线状态优化 2025-11-07 15:27:37 +08:00
gaoyutao ce95462d74 监控项详情展示优化 2025-11-07 10:21:44 +08:00
gaoyutao 7190df25f7 挂载点详情优化。 2025-11-06 18:39:41 +08:00
gaoyutao c4b380437f 优化图形分析根据可选时间补0逻辑、优化流量图形单位可选功能。 2025-11-06 18:09:29 +08:00
gaoyutao 5e5330a924 增加计算服务器平均流量方法、优化95值自动计算方法 2025-11-06 13:47:29 +08:00
gaoyutao b0868dfe2d 优化常用单位、交换机心跳上报优化、agent更新列表优化 2025-11-05 18:04:06 +08:00
gaoyutao d0ac03ffbf 优化常用单位、用户自定义列保存优化、业务流量库优化 2025-11-05 14:48:02 +08:00
gaoyutao e9970b94a9 优化图形分析单位、服务器流量业务表逻辑 2025-11-05 13:02:51 +08:00
gaoyutao 1dc32ec24e 单位换算保留两位小数 2025-11-04 19:27:17 +08:00
gaoyutao 84e003893d 增加计算单位可选方法.
优化图形分析根据可选时间补0逻辑,完成度70%。
优化业务自定义95值计算功能修改相关数据方法。
2025-11-04 19:11:07 +08:00
gaoyutao fe1763386a 优化95值计算单位、实际流量保留两位小数 2025-11-04 13:46:05 +08:00
gaoyutao b38cd83ee1 优化心跳监测 2025-11-04 10:31:44 +08:00
gaoyutao d1db8a5865 增加日志控制、优化金山95值自动计算方法 2025-11-03 18:51:00 +08:00
gaoyutao 841dd84a99 优化交换机心跳监测功能 2025-11-03 14:26:14 +08:00
gaoyutao 07baaf07b0 增加交换机心跳、优化用户自定义列表功能 2025-11-03 13:29:47 +08:00
gaoyutao 01c51b39fe 优化实时95值计算功能、服务器收益功能、用户自定义列展示、交换机基础数据采集 2025-10-31 21:46:17 +08:00
gaoyutao c0f057d7ed 优化实时95值计算功能、服务器收益功能、用户自定义列展示 2025-10-30 21:20:46 +08:00
gaoyutao 15ecd5caaf 实时95值计算功能、优化服务器收益功能 2025-10-29 18:35:44 +08:00
gaoyutao 8c439013e1 交换机收益图形分析、服务器注册优化 2025-10-28 18:51:08 +08:00
gaoyutao 46bf4c4114 获取最新策略增加路由信息方法、交换机带宽收益 2025-10-27 18:16:47 +08:00
gaoyutao 36362e2236 优化交换机数据采集、脚本策略、agent更新优化、注册增加路由信息 2025-10-24 18:55:21 +08:00
gaoyutao 37eff51e48 服务器注册 agent更新 2025-10-24 09:34:32 +08:00
gaoyutao 31d8114c05 增加agent联调,获取最新策略应答功能 2025-10-22 17:54:46 +08:00
gaoyutao 4fdaadee65 服务器自动注册 2025-10-21 18:28:18 +08:00
gaoyutao 52728eba49 snmp采集工具优化,采集数据入库优化。 2025-10-20 18:17:44 +08:00
gaoyutao b0e63880fc 服务器注册接口、snmp采集工具优化、其他bug修复 2025-10-17 18:56:32 +08:00
gaoyutao b3f16d2c8f 交换机监控策略bug修复 2025-10-16 19:05:46 +08:00
gaoyutao c6937eb44b 交换机监控策略、snmp工具 2025-10-16 18:37:33 +08:00
gaoyutao 3019f65515 服务器注册图形监控监控项接口开发 2025-10-15 18:22:16 +08:00
gaoyutao 87824abb77 拓扑管理字段新增,交换机管理接口优化、网卡信息接口新增 2025-10-14 18:17:31 +08:00
gaoyutao 7da5e19cfa 业务脚本管理、业务下发管理、相关数据分页优化 2025-10-13 18:43:04 +08:00
gaoyutao 054b0f1272 交换机管理,图形监控,策略 2025-10-11 17:54:17 +08:00
gaoyutao 6ffdf8d355 金山云服务API调用并入库,交换机管理功能新增 2025-10-10 18:17:53 +08:00
gaoyutao 7b5c782079 底层流量数据改为bit,测试金山云服务器API,准备1.1分支 2025-10-09 17:38:24 +08:00
1139 changed files with 58848 additions and 13636 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 若依
Copyright (c) 2020 彤然
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+23 -125
View File
@@ -1,129 +1,27 @@
<p align="center">
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-b99b286755aef70355a7084753f89cdb7c9.png">
</p>
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.6.6</h1>
<h4 align="center">基于 Vue/Element UI 和 Spring Boot/Spring Cloud & Alibaba 前后端分离的分布式微服务架构</h4>
<p align="center">
<a href="https://gitee.com/y_project/RuoYi-Cloud/stargazers"><img src="https://gitee.com/y_project/RuoYi-Cloud/badge/star.svg?theme=dark"></a>
<a href="https://gitee.com/y_project/RuoYi-Cloud"><img src="https://img.shields.io/badge/RuoYi-v3.6.6-brightgreen.svg"></a>
<a href="https://gitee.com/y_project/RuoYi-Cloud/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
</p>
## 平台简介
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
* 采用前后端分离的模式,微服务版本前端(基于 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue))。
* 后端采用Spring Boot、Spring Cloud & Alibaba。
* 注册中心、配置中心选型Nacos,权限认证使用Redis。
* 流量控制框架选型Sentinel,分布式事务选型Seata。
* 提供了技术栈([Vue3](https://v3.cn.vuejs.org) [Element Plus](https://element-plus.org/zh-CN) [Vite](https://cn.vitejs.dev))版本[RuoYi-Cloud-Vue3](https://gitcode.com/yangzongzhuan/RuoYi-Cloud-Vue3),保持同步更新。
* 如需不分离应用,请移步 [RuoYi](https://gitee.com/y_project/RuoYi),如需分离应用,请移步 [RuoYi-Vue](https://gitee.com/y_project/RuoYi-Vue)
* 阿里云优惠券:[点我进入](http://aly.ruoyi.vip),腾讯云优惠券:[点我进入](http://txy.ruoyi.vip)&nbsp;&nbsp;
## 系统模块
~~~
com.ruoyi
├── ruoyi-ui // 前端框架 [80]
├── ruoyi-gateway // 网关模块 [8080]
├── ruoyi-auth // 认证中心 [9200]
├── ruoyi-api // 接口模块
│ └── ruoyi-api-system // 系统接口
├── ruoyi-common // 通用模块
│ └── ruoyi-common-core // 核心模块
│ └── ruoyi-common-datascope // 权限范围
│ └── ruoyi-common-datasource // 多数据源
│ └── ruoyi-common-log // 日志记录
│ └── ruoyi-common-redis // 缓存服务
│ └── ruoyi-common-seata // 分布式事务
│ └── ruoyi-common-security // 安全模块
│ └── ruoyi-common-sensitive // 数据脱敏
│ └── ruoyi-common-swagger // 系统接口
├── ruoyi-modules // 业务模块
│ └── ruoyi-system // 系统模块 [9201]
│ └── ruoyi-gen // 代码生成 [9202]
│ └── ruoyi-job // 定时任务 [9203]
│ └── ruoyi-file // 文件服务 [9300]
├── ruoyi-visual // 图形化管理模块
│ └── ruoyi-visual-monitor // 监控中心 [9100]
com.tongran
├── tongran-ui // 前端框架 [80]
├── tongran-gateway // 网关模块 [8080]
├── tongran-auth // 认证中心 [9200]
├── tongran-api // 接口模块
│ └── tongran-api-system // 系统接口
├── tongran-common // 通用模块
│ └── tongran-common-core // 核心模块
│ └── tongran-common-datascope // 权限范围
│ └── tongran-common-datasource // 多数据源
│ └── tongran-common-log // 日志记录
│ └── tongran-common-redis // 缓存服务
│ └── tongran-common-seata // 分布式事务
│ └── tongran-common-security // 安全模块
│ └── tongran-common-sensitive // 数据脱敏
│ └── tongran-common-swagger // 系统接口
├── tongran-modules // 业务模块
│ └── tongran-system // 系统模块 [9201]
│ └── tongran-gen // 代码生成 [9202]
│ └── tongran-job // 定时任务 [9203]
│ └── tongran-file // 文件服务 [9300]
├── tongran-visual // 图形化管理模块
│ └── tongran-visual-monitor // 监控中心 [9100]
├──pom.xml // 公共依赖
~~~
## 架构图
<img src="https://oscimg.oschina.net/oscnet/up-82e9722ecb846786405a904bafcf19f73f3.png"/>
## 内置功能
1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
3. 岗位管理:配置系统用户所属担任职务。
4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
7. 参数管理:对系统动态配置常用参数。
8. 通知公告:系统通知公告信息发布维护。
9. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
10. 登录日志:系统登录日志记录查询包含登录异常。
11. 在线用户:当前系统中活跃用户状态监控。
12. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。
13. 代码生成:前后端代码的生成(java、html、xml、sql)支持CRUD下载 。
14. 系统接口:根据业务代码自动生成相关的api接口文档。
15. 服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。
16. 在线构建器:拖动表单元素生成相应的HTML代码。
17. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。
## 在线体验
- admin/admin123
- 陆陆续续收到一些打赏,为了更好的体验已用于演示服务器升级。谢谢各位小伙伴。
演示地址:http://ruoyi.vip
文档地址:http://doc.ruoyi.vip
## 演示图
<table>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/cd1f90be5f2684f4560c9519c0f2a232ee8.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/1cbcf0e6f257c7d3a063c0e3f2ff989e4b3.jpg"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-8074972883b5ba0622e13246738ebba237a.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-9f88719cdfca9af2e58b352a20e23d43b12.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-39bf2584ec3a529b0d5a3b70d15c9b37646.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-4148b24f58660a9dc347761e4cf6162f28f.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-b2d62ceb95d2dd9b3fbe157bb70d26001e9.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-d67451d308b7a79ad6819723396f7c3d77a.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/5e8c387724954459291aafd5eb52b456f53.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/644e78da53c2e92a95dfda4f76e6d117c4b.jpg"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-8370a0d02977eebf6dbf854c8450293c937.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-49003ed83f60f633e7153609a53a2b644f7.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-d4fe726319ece268d4746602c39cffc0621.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-c195234bbcd30be6927f037a6755e6ab69c.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-ece3fd37a3d4bb75a3926e905a3c5629055.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-92ffb7f3835855cff100fa0f754a6be0d99.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-ff9e3066561574aca73005c5730c6a41f15.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-5e4daac0bb59612c5038448acbcef235e3a.png"/></td>
</tr>
</table>
## 若依微服务交流群
QQ群: [![加入QQ群](https://img.shields.io/badge/已满-42799195-blue.svg)](https://jq.qq.com/?_wv=1027&k=yqInfq0S) [![加入QQ群](https://img.shields.io/badge/已满-170157040-blue.svg)](https://jq.qq.com/?_wv=1027&k=Oy1mb3p8) [![加入QQ群](https://img.shields.io/badge/已满-130643120-blue.svg)](https://jq.qq.com/?_wv=1027&k=rvxkJtXK) [![加入QQ群](https://img.shields.io/badge/已满-225920371-blue.svg)](https://jq.qq.com/?_wv=1027&k=0Ck3PvTe) [![加入QQ群](https://img.shields.io/badge/已满-201705537-blue.svg)](https://jq.qq.com/?_wv=1027&k=FnHHP4TT) [![加入QQ群](https://img.shields.io/badge/已满-236543183-blue.svg)](https://jq.qq.com/?_wv=1027&k=qdT1Ojpz) [![加入QQ群](https://img.shields.io/badge/已满-213618602-blue.svg)](https://jq.qq.com/?_wv=1027&k=nw3OiyXs) [![加入QQ群](https://img.shields.io/badge/已满-148794840-blue.svg)](https://jq.qq.com/?_wv=1027&k=kiU5WDls) [![加入QQ群](https://img.shields.io/badge/已满-118752664-blue.svg)](https://jq.qq.com/?_wv=1027&k=MtBy6YfT) [![加入QQ群](https://img.shields.io/badge/已满-101038945-blue.svg)](https://jq.qq.com/?_wv=1027&k=FqImHgH2) [![加入QQ群](https://img.shields.io/badge/已满-128355254-blue.svg)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=G4jZ4EtdT50PhnMBudTnEwgonxkXOscJ&authKey=FkGHYfoTKlGE6wHdKdjH9bVoOgQjtLP9WM%2Fj7pqGY1msoqw9uxDiBo39E2mLgzYg&noverify=0&group_code=128355254) [![加入QQ群](https://img.shields.io/badge/已满-179219821-blue.svg)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=irnwcXhbLOQEv1g-TwGifjNTA_f4wZiA&authKey=4bpzEwhcUY%2FvsPDHvzYn6xfoS%2FtOArvZ%2BGXzfr7O0%2FEqLfkKA%2BuCDXlzHIFg8t93&noverify=0&group_code=179219821) [![加入QQ群](https://img.shields.io/badge/已满-158753145-blue.svg)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=lx1uEdEDuxeM7rUvF3qmlFdqKqdJ5Z-R&authKey=rgyPW9yhhh4IIURKVFa6NgP3qiqH04WAzrJ0trsgkr3pjzm6sKIOGyA58oOjoj%2FJ&noverify=0&group_code=158753145) [![加入QQ群](https://img.shields.io/badge/112869560-blue.svg)](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=Kuaw0Xdlw2Nlgn6s8h9elzuquHGxGObD&authKey=cSrQcWQ%2BzQZAFFrwxaR%2BbzcumX4WRduZnd1O6JO1dlclQMiu%2BKwxAy8t2JfNp67V&noverify=0&group_code=112869560) 点击按钮入群。
+3 -3
View File
@@ -1,14 +1,14 @@
@echo off
echo.
echo [信息] 使用Jar命令运行Auth工程。
echo [Ϣ] ʹJarAuth̡
echo.
cd %~dp0
cd ../ruoyi-auth/target
cd ../tongran-auth/target
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-auth.jar
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar tongran-auth.jar
cd bin
pause
+3 -3
View File
@@ -1,14 +1,14 @@
@echo off
echo.
echo [信息] 使用Jar命令运行Gateway工程。
echo [Ϣ] ʹJarGateway̡
echo.
cd %~dp0
cd ../ruoyi-gateway/target
cd ../tongran-gateway/target
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-gateway.jar
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar tongran-gateway.jar
cd bin
pause
+3 -3
View File
@@ -1,14 +1,14 @@
@echo off
echo.
echo [信息] 使用Jar命令运行Modules-File工程。
echo [Ϣ] ʹJarModules-File̡
echo.
cd %~dp0
cd ../ruoyi-modules/ruoyi-file/target
cd ../tongran-modules/tongran-file/target
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-modules-file.jar
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar tongran-modules-file.jar
cd bin
pause
+3 -3
View File
@@ -1,14 +1,14 @@
@echo off
echo.
echo [信息] 使用Jar命令运行Modules-Gen工程。
echo [Ϣ] ʹJarModules-Gen̡
echo.
cd %~dp0
cd ../ruoyi-modules/ruoyi-gen/target
cd ../tongran-modules/tongran-gen/target
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-modules-gen.jar
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar tongran-modules-gen.jar
cd bin
pause
+3 -3
View File
@@ -1,14 +1,14 @@
@echo off
echo.
echo [信息] 使用Jar命令运行Modules-Job工程。
echo [Ϣ] ʹJarModules-Job̡
echo.
cd %~dp0
cd ../ruoyi-modules/ruoyi-job/target
cd ../tongran-modules/tongran-job/target
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-modules-job.jar
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar tongran-modules-job.jar
cd bin
pause
+3 -3
View File
@@ -1,14 +1,14 @@
@echo off
echo.
echo [信息] 使用Jar命令运行Modules-System工程。
echo [Ϣ] ʹJarModules-System̡
echo.
cd %~dp0
cd ../ruoyi-modules/ruoyi-system/target
cd ../tongran-modules/tongran-system/target
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-modules-system.jar
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar tongran-modules-system.jar
cd bin
pause
+3 -3
View File
@@ -1,14 +1,14 @@
@echo off
echo.
echo [信息] 使用Jar命令运行Monitor工程。
echo [Ϣ] ʹJarMonitor̡
echo.
cd %~dp0
cd ../ruoyi-visual/ruoyi-monitor/target
cd ../tongran-visual/tongran-monitor/target
set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-visual-monitor.jar
java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar tongran-visual-monitor.jar
cd bin
pause
-41
View File
@@ -1,41 +0,0 @@
#!/bin/sh
# 复制项目的文件到对应docker路径,便于一键生成镜像。
usage() {
echo "Usage: sh copy.sh"
exit 1
}
# copy sql
echo "begin copy sql "
cp ../sql/ry_20250523.sql ./mysql/db
cp ../sql/ry_config_20250224.sql ./mysql/db
# copy html
echo "begin copy html "
cp -r ../ruoyi-ui/dist/** ./nginx/html/dist
# copy jar
echo "begin copy ruoyi-gateway "
cp ../ruoyi-gateway/target/ruoyi-gateway.jar ./ruoyi/gateway/jar
echo "begin copy ruoyi-auth "
cp ../ruoyi-auth/target/ruoyi-auth.jar ./ruoyi/auth/jar
echo "begin copy ruoyi-visual "
cp ../ruoyi-visual/ruoyi-monitor/target/ruoyi-visual-monitor.jar ./ruoyi/visual/monitor/jar
echo "begin copy ruoyi-modules-system "
cp ../ruoyi-modules/ruoyi-system/target/ruoyi-modules-system.jar ./ruoyi/modules/system/jar
echo "begin copy ruoyi-modules-file "
cp ../ruoyi-modules/ruoyi-file/target/ruoyi-modules-file.jar ./ruoyi/modules/file/jar
echo "begin copy ruoyi-modules-job "
cp ../ruoyi-modules/ruoyi-job/target/ruoyi-modules-job.jar ./ruoyi/modules/job/jar
echo "begin copy ruoyi-modules-gen "
cp ../ruoyi-modules/ruoyi-gen/target/ruoyi-modules-gen.jar ./ruoyi/modules/gen/jar
-67
View File
@@ -1,67 +0,0 @@
#!/bin/sh
# 使用说明,用来提示输入参数
usage() {
echo "Usage: sh 执行脚本.sh [port|base|modules|stop|rm]"
exit 1
}
# 开启所需端口
port(){
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --add-port=8848/tcp --permanent
firewall-cmd --add-port=9848/tcp --permanent
firewall-cmd --add-port=9849/tcp --permanent
firewall-cmd --add-port=6379/tcp --permanent
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --add-port=9100/tcp --permanent
firewall-cmd --add-port=9200/tcp --permanent
firewall-cmd --add-port=9201/tcp --permanent
firewall-cmd --add-port=9202/tcp --permanent
firewall-cmd --add-port=9203/tcp --permanent
firewall-cmd --add-port=9300/tcp --permanent
service firewalld restart
}
# 启动基础环境(必须)
base(){
docker-compose up -d ruoyi-mysql ruoyi-redis ruoyi-nacos
}
# 启动程序模块(必须)
modules(){
docker-compose up -d ruoyi-nginx ruoyi-gateway ruoyi-auth ruoyi-modules-system
}
# 关闭所有环境/模块
stop(){
docker-compose stop
}
# 删除所有环境/模块
rm(){
docker-compose rm
}
# 根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"port")
port
;;
"base")
base
;;
"modules")
modules
;;
"stop")
stop
;;
"rm")
rm
;;
*)
usage
;;
esac
-140
View File
@@ -1,140 +0,0 @@
version : '3.8'
services:
ruoyi-nacos:
container_name: ruoyi-nacos
image: nacos/nacos-server
build:
context: ./nacos
environment:
- MODE=standalone
volumes:
- ./nacos/logs/:/home/nacos/logs
- ./nacos/conf/application.properties:/home/nacos/conf/application.properties
ports:
- "8848:8848"
- "9848:9848"
- "9849:9849"
depends_on:
- ruoyi-mysql
ruoyi-mysql:
container_name: ruoyi-mysql
image: mysql:5.7
build:
context: ./mysql
ports:
- "3306:3306"
volumes:
- ./mysql/conf:/etc/mysql/conf.d
- ./mysql/logs:/logs
- ./mysql/data:/var/lib/mysql
command: [
'mysqld',
'--innodb-buffer-pool-size=80M',
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci',
'--default-time-zone=+8:00',
'--lower-case-table-names=1'
]
environment:
MYSQL_DATABASE: 'ry-cloud'
MYSQL_ROOT_PASSWORD: password
ruoyi-redis:
container_name: ruoyi-redis
image: redis
build:
context: ./redis
ports:
- "6379:6379"
volumes:
- ./redis/conf/redis.conf:/home/ruoyi/redis/redis.conf
- ./redis/data:/data
command: redis-server /home/ruoyi/redis/redis.conf
ruoyi-nginx:
container_name: ruoyi-nginx
image: nginx
build:
context: ./nginx
ports:
- "80:80"
volumes:
- ./nginx/html/dist:/home/ruoyi/projects/ruoyi-ui
- ./nginx/conf/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/logs:/var/log/nginx
- ./nginx/conf.d:/etc/nginx/conf.d
depends_on:
- ruoyi-gateway
links:
- ruoyi-gateway
ruoyi-gateway:
container_name: ruoyi-gateway
build:
context: ./ruoyi/gateway
dockerfile: dockerfile
ports:
- "8080:8080"
depends_on:
- ruoyi-redis
links:
- ruoyi-redis
ruoyi-auth:
container_name: ruoyi-auth
build:
context: ./ruoyi/auth
dockerfile: dockerfile
ports:
- "9200:9200"
depends_on:
- ruoyi-redis
links:
- ruoyi-redis
ruoyi-modules-system:
container_name: ruoyi-modules-system
build:
context: ./ruoyi/modules/system
dockerfile: dockerfile
ports:
- "9201:9201"
depends_on:
- ruoyi-redis
- ruoyi-mysql
links:
- ruoyi-redis
- ruoyi-mysql
ruoyi-modules-gen:
container_name: ruoyi-modules-gen
build:
context: ./ruoyi/modules/gen
dockerfile: dockerfile
ports:
- "9202:9202"
depends_on:
- ruoyi-mysql
links:
- ruoyi-mysql
ruoyi-modules-job:
container_name: ruoyi-modules-job
build:
context: ./ruoyi/modules/job
dockerfile: dockerfile
ports:
- "9203:9203"
depends_on:
- ruoyi-mysql
links:
- ruoyi-mysql
ruoyi-modules-file:
container_name: ruoyi-modules-file
build:
context: ./ruoyi/modules/file
dockerfile: dockerfile
ports:
- "9300:9300"
volumes:
- ./ruoyi/uploadPath:/home/ruoyi/uploadPath
ruoyi-visual-monitor:
container_name: ruoyi-visual-monitor
build:
context: ./ruoyi/visual/monitor
dockerfile: dockerfile
ports:
- "9100:9100"
-1
View File
@@ -1 +0,0 @@
存放sql目录下的所有脚本,用于docker自动执行。
-7
View File
@@ -1,7 +0,0 @@
# 基础镜像
FROM mysql:5.7
# author
MAINTAINER ruoyi
# 执行sql脚本
ADD ./db/*.sql /docker-entrypoint-initdb.d/
-32
View File
@@ -1,32 +0,0 @@
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://ruoyi-mysql:3306/ry-config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user=root
db.password=123456
nacos.naming.empty-service.auto-clean=true
nacos.naming.empty-service.clean.initial-delay-ms=50000
nacos.naming.empty-service.clean.period-time-ms=30000
management.endpoints.web.exposure.include=*
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
server.tomcat.basedir=/home/ruoyi/nacos/tomcat/logs
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
nacos.core.auth.system.type=nacos
nacos.core.auth.enabled=false
nacos.core.auth.default.token.expire.seconds=18000
nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
nacos.core.auth.caching.enabled=true
nacos.core.auth.enable.userAgentAuthWhite=false
nacos.core.auth.server.identity.key=serverIdentity
nacos.core.auth.server.identity.value=security
nacos.istio.mcp.server.enabled=false
-7
View File
@@ -1,7 +0,0 @@
# 基础镜像
FROM nacos/nacos-server
# author
MAINTAINER ruoyi
# 复制conf文件到路径
COPY ./conf/application.properties /home/nacos/conf/application.properties
-41
View File
@@ -1,41 +0,0 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /home/ruoyi/projects/ruoyi-ui;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /prod-api/{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://ruoyi-gateway:8080/;
}
# 避免actuator暴露
if ($uri ~ "/actuator") {
return 403;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
-15
View File
@@ -1,15 +0,0 @@
# 基础镜像
FROM nginx
# author
MAINTAINER ruoyi
# 挂载目录
VOLUME /home/ruoyi/projects/ruoyi-ui
# 创建目录
RUN mkdir -p /home/ruoyi/projects/ruoyi-ui
# 指定路径
WORKDIR /home/ruoyi/projects/ruoyi-ui
# 复制conf文件到路径
COPY ./conf/nginx.conf /etc/nginx/nginx.conf
# 复制html文件到路径
COPY ./html/dist /home/ruoyi/projects/ruoyi-ui
-1
View File
@@ -1 +0,0 @@
# requirepass 123456
-13
View File
@@ -1,13 +0,0 @@
# 基础镜像
FROM redis
# author
MAINTAINER ruoyi
# 挂载目录
VOLUME /home/ruoyi/redis
# 创建目录
RUN mkdir -p /home/ruoyi/redis
# 指定路径
WORKDIR /home/ruoyi/redis
# 复制conf文件到路径
COPY ./conf/redis.conf /home/ruoyi/redis/redis.conf
-15
View File
@@ -1,15 +0,0 @@
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER ruoyi
# 挂载目录
VOLUME /home/ruoyi
# 创建目录
RUN mkdir -p /home/ruoyi
# 指定路径
WORKDIR /home/ruoyi
# 复制jar文件到路径
COPY ./jar/ruoyi-auth.jar /home/ruoyi/ruoyi-auth.jar
# 启动认证服务
ENTRYPOINT ["java","-jar","ruoyi-auth.jar"]
-1
View File
@@ -1 +0,0 @@
存放认证中心打包好的jar文件,用于docker启动应用。
-15
View File
@@ -1,15 +0,0 @@
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER ruoyi
# 挂载目录
VOLUME /home/ruoyi
# 创建目录
RUN mkdir -p /home/ruoyi
# 指定路径
WORKDIR /home/ruoyi
# 复制jar文件到路径
COPY ./jar/ruoyi-gateway.jar /home/ruoyi/ruoyi-gateway.jar
# 启动网关服务
ENTRYPOINT ["java","-jar","ruoyi-gateway.jar"]
-1
View File
@@ -1 +0,0 @@
存放网关模块打包好的jar文件,用于docker启动应用。
-15
View File
@@ -1,15 +0,0 @@
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER ruoyi
# 挂载目录
VOLUME /home/ruoyi
# 创建目录
RUN mkdir -p /home/ruoyi
# 指定路径
WORKDIR /home/ruoyi
# 复制jar文件到路径
COPY ./jar/ruoyi-modules-file.jar /home/ruoyi/ruoyi-modules-file.jar
# 启动文件服务
ENTRYPOINT ["java","-jar","ruoyi-modules-file.jar"]
-1
View File
@@ -1 +0,0 @@
存放文件服务打包好的jar文件,用于docker启动应用。
-15
View File
@@ -1,15 +0,0 @@
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER ruoyi
# 挂载目录
VOLUME /home/ruoyi
# 创建目录
RUN mkdir -p /home/ruoyi
# 指定路径
WORKDIR /home/ruoyi
# 复制jar文件到路径
COPY ./jar/ruoyi-modules-gen.jar /home/ruoyi/ruoyi-modules-gen.jar
# 启动代码生成服务
ENTRYPOINT ["java","-jar","ruoyi-modules-gen.jar"]
-1
View File
@@ -1 +0,0 @@
存放代码生成打包好的jar文件,用于docker启动应用。
-15
View File
@@ -1,15 +0,0 @@
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER ruoyi
# 挂载目录
VOLUME /home/ruoyi
# 创建目录
RUN mkdir -p /home/ruoyi
# 指定路径
WORKDIR /home/ruoyi
# 复制jar文件到路径
COPY ./jar/ruoyi-modules-job.jar /home/ruoyi/ruoyi-modules-job.jar
# 启动定时任务服务
ENTRYPOINT ["java","-jar","ruoyi-modules-job.jar"]
-1
View File
@@ -1 +0,0 @@
存放定时任务打包好的jar文件,用于docker启动应用。
-15
View File
@@ -1,15 +0,0 @@
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER ruoyi
# 挂载目录
VOLUME /home/ruoyi
# 创建目录
RUN mkdir -p /home/ruoyi
# 指定路径
WORKDIR /home/ruoyi
# 复制jar文件到路径
COPY ./jar/ruoyi-modules-system.jar /home/ruoyi/ruoyi-modules-system.jar
# 启动系统服务
ENTRYPOINT ["java","-jar","ruoyi-modules-system.jar"]
@@ -1 +0,0 @@
存放系统模块打包好的jar文件,用于docker启动应用。
-15
View File
@@ -1,15 +0,0 @@
# 基础镜像
FROM openjdk:8-jre
# author
MAINTAINER ruoyi
# 挂载目录
VOLUME /home/ruoyi
# 创建目录
RUN mkdir -p /home/ruoyi
# 指定路径
WORKDIR /home/ruoyi
# 复制jar文件到路径
COPY ./jar/ruoyi-visual-monitor.jar /home/ruoyi/ruoyi-visual-monitor.jar
# 启动系统服务
ENTRYPOINT ["java","-jar","ruoyi-visual-monitor.jar"]
@@ -1 +0,0 @@
存放监控中心打包好的jar文件,用于docker启动应用。
+42 -43
View File
@@ -4,16 +4,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi</artifactId>
<groupId>com.tongran</groupId>
<artifactId>tongran</artifactId>
<version>3.6.6</version>
<name>ruoyi</name>
<url>http://www.ruoyi.vip</url>
<description>若依微服务系统</description>
<name>tongran</name>
<description>彤然微服务系统</description>
<properties>
<ruoyi.version>3.6.6</ruoyi.version>
<tongran.version>3.6.6</tongran.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
@@ -184,85 +183,85 @@
<!-- 核心模块 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-core</artifactId>
<version>${ruoyi.version}</version>
<groupId>com.tongran</groupId>
<artifactId>tongran-common-core</artifactId>
<version>${tongran.version}</version>
</dependency>
<!-- 接口模块 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-swagger</artifactId>
<version>${ruoyi.version}</version>
<groupId>com.tongran</groupId>
<artifactId>tongran-common-swagger</artifactId>
<version>${tongran.version}</version>
</dependency>
<!-- 安全模块 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-security</artifactId>
<version>${ruoyi.version}</version>
<groupId>com.tongran</groupId>
<artifactId>tongran-common-security</artifactId>
<version>${tongran.version}</version>
</dependency>
<!-- 数据脱敏 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-sensitive</artifactId>
<version>${ruoyi.version}</version>
<groupId>com.tongran</groupId>
<artifactId>tongran-common-sensitive</artifactId>
<version>${tongran.version}</version>
</dependency>
<!-- 权限范围 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datascope</artifactId>
<version>${ruoyi.version}</version>
<groupId>com.tongran</groupId>
<artifactId>tongran-common-datascope</artifactId>
<version>${tongran.version}</version>
</dependency>
<!-- 多数据源 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datasource</artifactId>
<version>${ruoyi.version}</version>
<groupId>com.tongran</groupId>
<artifactId>tongran-common-datasource</artifactId>
<version>${tongran.version}</version>
</dependency>
<!-- 分布式事务 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-seata</artifactId>
<version>${ruoyi.version}</version>
<groupId>com.tongran</groupId>
<artifactId>tongran-common-seata</artifactId>
<version>${tongran.version}</version>
</dependency>
<!-- 日志记录 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-log</artifactId>
<version>${ruoyi.version}</version>
<groupId>com.tongran</groupId>
<artifactId>tongran-common-log</artifactId>
<version>${tongran.version}</version>
</dependency>
<!-- 缓存服务 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-redis</artifactId>
<version>${ruoyi.version}</version>
<groupId>com.tongran</groupId>
<artifactId>tongran-common-redis</artifactId>
<version>${tongran.version}</version>
</dependency>
<!-- 系统接口 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-api-system</artifactId>
<version>${ruoyi.version}</version>
<groupId>com.tongran</groupId>
<artifactId>tongran-api-system</artifactId>
<version>${tongran.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>ruoyi-auth</module>
<module>ruoyi-gateway</module>
<module>ruoyi-visual</module>
<module>ruoyi-modules</module>
<module>ruoyi-rocketmq</module>
<module>ruoyi-api</module>
<module>ruoyi-common</module>
<module>tongran-auth</module>
<module>tongran-gateway</module>
<module>tongran-visual</module>
<module>tongran-modules</module>
<module>tongran-rocketmq</module>
<module>tongran-api</module>
<module>tongran-common</module>
</modules>
<packaging>pom</packaging>
@@ -1,45 +0,0 @@
package com.ruoyi.system.api;
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.RmAlarmRecordRemote;
import com.ruoyi.system.api.factory.RemoteRocketMqFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@FeignClient(contextId = "remoteRocketMqService", value = ServiceNameConstants.ROCKETMQ_SERVICE, fallbackFactory = RemoteRocketMqFallbackFactory.class)
public interface RemoteRocketMqService {
/**
* 发送异步消息
* @param topic
* @param tag
* @param key
* @param value
* @param source
* @return
*/
@PostMapping("/api/rocketMessage/sendAsyncProducerMessage")
public R<Map> sendAsyncProducerMessage(@RequestParam("topic") String topic, @RequestParam("tag") String tag, @RequestParam("key") String key, @RequestParam("value") String value, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
* 查询告警记录
*
* @param rmAlarmRecordRemote
* @param source
* @return
*/
@PostMapping("/alarmRecord/getAlarmList")
public R<List<RmAlarmRecordRemote>> getAlarmList(@RequestBody RmAlarmRecordRemote rmAlarmRecordRemote, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
* 资源告警处理情况
* @param source
* @return
*/
@GetMapping("/alarmRecord/alarmHandlingStatus")
public R<Map> alarmHandlingStatus(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
@@ -1,50 +0,0 @@
package com.ruoyi.system.api.factory;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteRocketMqService;
import com.ruoyi.system.api.domain.RmAlarmRecordRemote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 用户服务降级处理
*
* @author ruoyi
*/
@Component
public class RemoteRocketMqFallbackFactory implements FallbackFactory<RemoteRocketMqService>
{
private static final Logger log = LoggerFactory.getLogger(RemoteRocketMqFallbackFactory.class);
@Override
public RemoteRocketMqService create(Throwable throwable)
{
log.error("rocketMq服务调用失败:{}", throwable.getMessage());
return new RemoteRocketMqService()
{
@Override
public R<Map> sendAsyncProducerMessage(String topic, String tag, String key, String value, String source) {
Map<String, Object> errorMap = new HashMap<>();
errorMap.put("msg", "生产者发送消息失败");
errorMap.put("error", throwable.getMessage());
return R.fail(errorMap);
}
@Override
public R<List<RmAlarmRecordRemote>> getAlarmList(RmAlarmRecordRemote rmAlarmRecordRemote, String source) {
return R.fail(throwable.getMessage());
}
@Override
public R<Map> alarmHandlingStatus(String source) {
return R.fail(throwable.getMessage());
}
};
}
}
@@ -1,5 +0,0 @@
com.ruoyi.system.api.factory.RemoteUserFallbackFactory
com.ruoyi.system.api.factory.RemoteLogFallbackFactory
com.ruoyi.system.api.factory.RemoteFileFallbackFactory
com.ruoyi.system.api.factory.RemoteRevenueConfigFallbackFactory
com.ruoyi.system.api.factory.RemoteRocketMqFallbackFactory
@@ -1,31 +0,0 @@
package com.ruoyi.auth;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
/**
* 认证授权中心
*
* @author ruoyi
*/
@EnableRyFeignClients
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
public class RuoYiAuthApplication
{
public static void main(String[] args)
{
SpringApplication.run(RuoYiAuthApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 认证授权中心启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}
-10
View File
@@ -1,10 +0,0 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ _ _
(_) | | | |
_ __ _ _ ___ _ _ _ ______ __ _ _ _ | |_ | |__
| '__|| | | | / _ \ | | | || ||______| / _` || | | || __|| '_ \
| | | |_| || (_) || |_| || | | (_| || |_| || |_ | | | |
|_| \__,_| \___/ \__, ||_| \__,_| \__,_| \__||_| |_|
__/ |
|___/
@@ -1,31 +0,0 @@
# Tomcat
server:
port: 9200
# Spring
spring:
application:
# 应用名称
name: ruoyi-auth
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
# 服务注册地址
# server-addr: 172.16.15.103:8848
# username: ${spring.cloud.nacos.config.username}
# password: ${spring.cloud.nacos.config.password}
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
# server-addr: 172.16.15.103:8848
# username: nacos
# password: nacos
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
-30
View File
@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi</artifactId>
<version>3.6.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<modules>
<module>ruoyi-common-log</module>
<module>ruoyi-common-core</module>
<module>ruoyi-common-redis</module>
<module>ruoyi-common-seata</module>
<module>ruoyi-common-swagger</module>
<module>ruoyi-common-security</module>
<module>ruoyi-common-sensitive</module>
<module>ruoyi-common-datascope</module>
<module>ruoyi-common-datasource</module>
</modules>
<artifactId>ruoyi-common</artifactId>
<packaging>pom</packaging>
<description>
ruoyi-common通用模块
</description>
</project>
@@ -1,29 +0,0 @@
package com.ruoyi.common.core.constant;
/**
* 服务名称
*
* @author ruoyi
*/
public class ServiceNameConstants
{
/**
* 认证服务的serviceid
*/
public static final String AUTH_SERVICE = "ruoyi-auth";
/**
* 系统模块的serviceid
*/
public static final String SYSTEM_SERVICE = "ruoyi-system";
/**
* 文件服务的serviceid
*/
public static final String FILE_SERVICE = "ruoyi-file";
/**
* rocketMq的serviceid
*/
public static final String ROCKETMQ_SERVICE = "ruoyi-rocketmq";
}
@@ -1 +0,0 @@
com.ruoyi.common.datascope.aspect.DataScopeAspect
@@ -1,2 +0,0 @@
com.ruoyi.common.log.service.AsyncLogService
com.ruoyi.common.log.aspect.LogAspect
@@ -1,2 +0,0 @@
com.ruoyi.common.redis.configure.RedisConfig
com.ruoyi.common.redis.service.RedisService
@@ -1,89 +0,0 @@
package com.ruoyi.common.security.aspect;
import java.lang.reflect.Method;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import com.ruoyi.common.security.annotation.RequiresLogin;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.security.annotation.RequiresRoles;
import com.ruoyi.common.security.auth.AuthUtil;
/**
* 基于 Spring Aop 的注解鉴权
*
* @author kong
*/
@Aspect
@Component
public class PreAuthorizeAspect
{
/**
* 构建
*/
public PreAuthorizeAspect()
{
}
/**
* 定义AOP签名 (切入所有使用鉴权注解的方法)
*/
public static final String POINTCUT_SIGN = " @annotation(com.ruoyi.common.security.annotation.RequiresLogin) || "
+ "@annotation(com.ruoyi.common.security.annotation.RequiresPermissions) || "
+ "@annotation(com.ruoyi.common.security.annotation.RequiresRoles)";
/**
* 声明AOP签名
*/
@Pointcut(POINTCUT_SIGN)
public void pointcut()
{
}
/**
* 环绕切入
*
* @param joinPoint 切面对象
* @return 底层方法执行后的返回值
* @throws Throwable 底层方法抛出的异常
*/
@Around("pointcut()")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable
{
// 注解鉴权
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
checkMethodAnnotation(signature.getMethod());
// 执行原有逻辑
return joinPoint.proceed();
}
/**
* 对一个Method对象进行注解检查
*/
public void checkMethodAnnotation(Method method)
{
// 校验 @RequiresLogin 注解
RequiresLogin requiresLogin = method.getAnnotation(RequiresLogin.class);
if (requiresLogin != null)
{
AuthUtil.checkLogin();
}
// 校验 @RequiresRoles 注解
RequiresRoles requiresRoles = method.getAnnotation(RequiresRoles.class);
if (requiresRoles != null)
{
AuthUtil.checkRole(requiresRoles);
}
// 校验 @RequiresPermissions 注解
RequiresPermissions requiresPermissions = method.getAnnotation(RequiresPermissions.class);
if (requiresPermissions != null)
{
AuthUtil.checkPermi(requiresPermissions);
}
}
}
@@ -1,5 +0,0 @@
com.ruoyi.common.security.config.WebMvcConfig
com.ruoyi.common.security.service.TokenService
com.ruoyi.common.security.aspect.PreAuthorizeAspect
com.ruoyi.common.security.aspect.InnerAuthAspect
com.ruoyi.common.security.handler.GlobalExceptionHandler
@@ -1 +0,0 @@
com.ruoyi.common.swagger.config.SpringDocAutoConfiguration
@@ -1,29 +0,0 @@
package com.ruoyi.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
* 网关启动程序
*
* @author ruoyi
*/
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
public class RuoYiGatewayApplication
{
public static void main(String[] args)
{
SpringApplication.run(RuoYiGatewayApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 若依网关启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}
@@ -1,10 +0,0 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ _
(_) | |
_ __ _ _ ___ _ _ _ ______ __ _ __ _ | |_ ___ __ __ __ _ _ _
| '__|| | | | / _ \ | | | || ||______| / _` | / _` || __| / _ \\ \ /\ / / / _` || | | |
| | | |_| || (_) || |_| || | | (_| || (_| || |_ | __/ \ V V / | (_| || |_| |
|_| \__,_| \___/ \__, ||_| \__, | \__,_| \__| \___| \_/\_/ \__,_| \__, |
__/ | __/ | __/ |
|___/ |___/ |___/
@@ -1,29 +0,0 @@
package com.ruoyi.file;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
* 文件服务
*
* @author ruoyi
*/
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
public class RuoYiFileApplication
{
public static void main(String[] args)
{
SpringApplication.run(RuoYiFileApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 文件服务模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}
@@ -1,10 +0,0 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ __ _ _
(_) / _|(_)| |
_ __ _ _ ___ _ _ _ ______ | |_ _ | | ___
| '__|| | | | / _ \ | | | || ||______|| _|| || | / _ \
| | | |_| || (_) || |_| || | | | | || || __/
|_| \__,_| \___/ \__, ||_| |_| |_||_| \___|
__/ |
|___/
@@ -1,32 +0,0 @@
package com.ruoyi.gen;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
/**
* 代码生成
*
* @author ruoyi
*/
@EnableCustomConfig
@EnableRyFeignClients
@SpringBootApplication
public class RuoYiGenApplication
{
public static void main(String[] args)
{
SpringApplication.run(RuoYiGenApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 代码生成模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}
@@ -1,10 +0,0 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_
(_)
_ __ _ _ ___ _ _ _ ______ __ _ ___ _ __
| '__|| | | | / _ \ | | | || ||______| / _` | / _ \| '_ \
| | | |_| || (_) || |_| || | | (_| || __/| | | |
|_| \__,_| \___/ \__, ||_| \__, | \___||_| |_|
__/ | __/ |
|___/ |___/
@@ -1,32 +0,0 @@
package com.ruoyi.job;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
/**
* 定时任务
*
* @author ruoyi
*/
@EnableCustomConfig
@EnableRyFeignClients
@SpringBootApplication
public class RuoYiJobApplication
{
public static void main(String[] args)
{
SpringApplication.run(RuoYiJobApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 定时任务模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}
@@ -1,10 +0,0 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ _ _
(_) (_) | |
_ __ _ _ ___ _ _ _ ______ _ ___ | |__
| '__|| | | | / _ \ | | | || ||______| | | / _ \ | '_ \
| | | |_| || (_) || |_| || | | || (_) || |_) |
|_| \__,_| \___/ \__, ||_| | | \___/ |_.__/
__/ | _/ |
|___/ |__/
@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/ruoyi-job" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>
@@ -1,32 +0,0 @@
package com.ruoyi.system;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
/**
* 系统模块
*
* @author ruoyi
*/
@EnableCustomConfig
@EnableRyFeignClients
@SpringBootApplication
public class RuoYiSystemApplication
{
public static void main(String[] args)
{
SpringApplication.run(RuoYiSystemApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 系统模块启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}
@@ -1,415 +0,0 @@
package com.ruoyi.system.config;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.*;
import lombok.extern.slf4j.Slf4j;
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;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
* 自动生成数据表
*/
@Configuration
@EnableScheduling
@Slf4j
public class TableScheduleConfig {
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@Autowired
private EpsInitialTrafficDataService epsInitialTrafficDataService;
@Autowired
private IInitialSwitchInfoDetailsService initialSwitchInfoDetailsService;
@Autowired
private IEpsNodeBandwidthService epsNodeBandwidthService;
@Autowired
private IAllInterfaceNameService allInterfaceNameService;
@Autowired
private IEpsServerRevenueConfigService epsServerRevenueConfigService;
@Autowired
private IRmEpsTopologyManagementService rmEpsTopologyManagementService;
@Autowired
private IEpsMethodChangeRecordService epsMethodChangeRecordService;
// 每月25号创建下月表
@Scheduled(cron = "0 0 0 25 * ?")
// @Scheduled(initialDelay = 5000, fixedDelay = Long.MAX_VALUE)
public void createNextMonthTables() {
epsInitialTrafficDataService.createNextMonthTables();
}
// 每天0点执行 计算95带宽值/日
@Scheduled(cron = "0 4 0 * * ?", zone = "Asia/Shanghai")
public void calculate95BandwidthDaily() {
// 获取昨天的日期范围(北京时间)
LocalDate yesterday = LocalDate.now(ZoneId.of("Asia/Shanghai")).minusDays(1);
String dailyStartTime = yesterday.atStartOfDay().format(TIME_FORMAT); // 00:00:00
String dailyEndTime = yesterday.atTime(23, 59, 59).format(TIME_FORMAT); // 23:59:59
// 日
String dayOrMonth = "1";
// 95带宽值/日
EpsInitialTrafficData queryParam = new EpsInitialTrafficData();
queryParam.setDayOrMonth(dayOrMonth);
InitialSwitchInfoDetails initialSwitchInfoDetails = new InitialSwitchInfoDetails();
initialSwitchInfoDetails.setDayOrMonth(dayOrMonth);
// 顺序执行链
CompletableFuture.runAsync(() -> executeWithLog("业务带宽1000",
() -> epsInitialTrafficDataService.calculateBusiness95BandwidthDaily(queryParam, dailyStartTime, dailyEndTime, "1000")))
.thenRun(() -> executeWithLog("业务带宽1024",
() -> epsInitialTrafficDataService.calculateBusiness95BandwidthDaily(queryParam, dailyStartTime, dailyEndTime, "1024")))
.thenRun(() -> executeWithLog("交换机带宽1000",
() -> initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails, dailyStartTime, dailyEndTime, "1000")))
.thenRun(() -> executeWithLog("交换机带宽1024",
() -> initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails, dailyStartTime, dailyEndTime, "1024")));
}
// 每月1号0点执行 计算95带宽值/月
@Scheduled(cron = "0 3 0 1 * ?", zone = "Asia/Shanghai")
public void calculateMonthlyBandwidthTasks() {
// 获取上个月的日期范围
LocalDate lastMonth = LocalDate.now(ZoneId.of("Asia/Shanghai")).minusMonths(1);
LocalDate firstDayOfMonth = lastMonth.withDayOfMonth(1);
LocalDate lastDayOfMonth = lastMonth.withDayOfMonth(lastMonth.lengthOfMonth());
String monthlyStartTime = firstDayOfMonth.atStartOfDay().format(TIME_FORMAT);
String monthlyEndTime = lastDayOfMonth.atTime(23, 59, 59).format(TIME_FORMAT);
// 链式顺序执行(无额外日志封装)
CompletableFuture.runAsync(() -> calculateServerMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1000"))
.thenRun(() -> calculateServerMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1024"))
.thenRun(() -> calculateSwitchMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1000"))
.thenRun(() -> calculateSwitchMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1024"))
.thenRun(() -> calculateServerAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1000"))
.thenRun(() -> calculateServerAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1024"))
.thenRun(() -> calculateSwitchAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1000"))
.thenRun(() -> calculateSwitchAvgMonthlyBandwidth(monthlyStartTime, monthlyEndTime, "1024"))
.exceptionally(e -> {
log.error("月度带宽计算链执行异常", e); // 仅保留最终异常捕获
return null;
});
}
/**
* 执行任务日志
*/
private void executeWithLog(String taskName, Runnable task) {
log.info("开始执行: {}", taskName);
try {
task.run();
} catch (Exception e) {
log.error("{} 执行失败", taskName, e);
throw e; // 可选:是否终止后续任务
}
log.info("{} 执行完成", taskName);
}
/**
* 计算服务器月95带宽值
*/
private void calculateServerMonthlyBandwidth(String monthlyStartTime, String monthlyEndTime, String calculationMode) {
log.info("开始计算服务器月95带宽值...");
try {
String dayOrMonth = "2";
EpsInitialTrafficData queryParam = new EpsInitialTrafficData();
queryParam.setDayOrMonth(dayOrMonth);
epsInitialTrafficDataService.calculateBusiness95BandwidthDaily(queryParam, monthlyStartTime, monthlyEndTime, calculationMode);
log.info("服务器月95带宽值计算完成");
} catch (Exception e) {
log.error("计算服务器月95带宽值失败", e);
}
}
/**
* 计算交换机月95带宽值
*/
private void calculateSwitchMonthlyBandwidth(String monthlyStartTime, String monthlyEndTime, String calculationMode) {
log.info("开始计算交换机月95带宽值...");
try {
String dayOrMonth = "2";
InitialSwitchInfoDetails queryParam = new InitialSwitchInfoDetails();
queryParam.setDayOrMonth(dayOrMonth);
initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(queryParam, monthlyStartTime, monthlyEndTime, calculationMode);
log.info("交换机月95带宽值计算完成");
} catch (Exception e) {
log.error("计算交换机月95带宽值失败", e);
}
}
/**
* 计算服务器月平均95带宽值
*/
private void calculateServerAvgMonthlyBandwidth(String monthlyStartTime, String monthlyEndTime, String calculationMode) {
log.info("开始计算服务器月平均95带宽值...");
try {
EpsNodeBandwidth epsNodeBandwidth = new EpsNodeBandwidth();
epsNodeBandwidth.setStartTime(monthlyStartTime);
epsNodeBandwidth.setEndTime(monthlyEndTime);
List<AllInterfaceName> snList = allInterfaceNameService.getAllDeviceSn(new AllInterfaceName());
for (AllInterfaceName allInterfaceName : snList) {
processServerAvgBandwidth(epsNodeBandwidth, allInterfaceName, calculationMode);
}
log.info("服务器月平均95带宽值计算完成");
} catch (Exception e) {
log.error("计算服务器月平均95带宽值失败", e);
}
}
/**
* 处理单个服务器的平均带宽计算
*/
private void processServerAvgBandwidth(EpsNodeBandwidth epsNodeBandwidth, AllInterfaceName allInterfaceName, String calculationMode) {
final String deviceSn = allInterfaceName.getDeviceSn();
try {
// 1. 设置基础设备信息
epsNodeBandwidth.setHardwareSn(deviceSn);
// 2. 查询服务器配置
EpsServerRevenueConfig queryConfig = new EpsServerRevenueConfig();
queryConfig.setHardwareSn(deviceSn);
List<EpsServerRevenueConfig> configList = epsServerRevenueConfigService.selectEpsServerRevenueConfigList(queryConfig);
EpsServerRevenueConfig serverConfig = configList.isEmpty() ? new EpsServerRevenueConfig() : configList.get(0);
epsNodeBandwidth.setNodeName(serverConfig.getNodeName());
// 3. 检查是否需要处理业务变更
boolean shouldProcessChange = serverConfig.getUpdateTime() != null
&& epsNodeBandwidth.getStartTime() != null
&& epsNodeBandwidth.getStartTime().length() >= 10
&& "1".equals(serverConfig.getChanged())
&& DateUtils.parseDateToStr("yyyy-MM", serverConfig.getUpdateTime())
.equals(epsNodeBandwidth.getStartTime().substring(0, 7));
// 4. 处理业务变更情况
if (shouldProcessChange) {
// 查询业务变更记录
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
changeQuery.setHardwareSn(deviceSn);
changeQuery.setStartTime(epsNodeBandwidth.getStartTime());
changeQuery.setEndTime(epsNodeBandwidth.getEndTime());
List<EpsMethodChangeRecord> records = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(changeQuery);
// 按businessCode分组处理(修复null key问题)
if (!records.isEmpty()) {
Map<String, List<EpsMethodChangeRecord>> groupedRecords = records.stream()
.filter(record -> record.getBusinessCode() != null) // 过滤掉businessCode为null的记录
.collect(Collectors.groupingBy(EpsMethodChangeRecord::getBusinessCode));
// 处理每个业务分组
for (Map.Entry<String, List<EpsMethodChangeRecord>> entry : groupedRecords.entrySet()) {
String businessCode = entry.getKey();
// 取第一个有效业务名称(同businessCode的业务名称应该相同)
String businessName = entry.getValue().stream()
.filter(r -> r.getBusinessName() != null)
.findFirst()
.map(EpsMethodChangeRecord::getBusinessName)
.orElse("未知业务");
// 创建业务带宽对象
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
bandwidthWithBiz.setHardwareSn(deviceSn);
bandwidthWithBiz.setCalculationMode(calculationMode);
bandwidthWithBiz.setNodeName(serverConfig.getNodeName());
bandwidthWithBiz.setStartTime(epsNodeBandwidth.getStartTime());
bandwidthWithBiz.setEndTime(epsNodeBandwidth.getEndTime());
bandwidthWithBiz.setBusinessId(businessCode);
bandwidthWithBiz.setBusinessName(businessName);
bandwidthWithBiz.setResourceType("1");
// 执行计算
epsNodeBandwidthService.calculateAvg(bandwidthWithBiz);
}
// 处理businessCode为null的记录(如果有)
List<EpsMethodChangeRecord> nullBusinessRecords = records.stream()
.filter(record -> record.getBusinessCode() == null)
.collect(Collectors.toList());
if (!nullBusinessRecords.isEmpty()) {
log.warn("服务器 {} 有 {} 条记录的businessCode为null", deviceSn, nullBusinessRecords.size());
// 可以选择记录日志或进行其他处理
}
return; // 业务变更处理完成后直接返回
}
}
// 5. 处理正常情况(无业务变更或无需处理变更)
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
normalBandwidth.setHardwareSn(deviceSn);
normalBandwidth.setCalculationMode(calculationMode);
normalBandwidth.setNodeName(serverConfig.getNodeName());
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
normalBandwidth.setBusinessId(serverConfig.getBusinessCode());
normalBandwidth.setBusinessName(serverConfig.getBusinessName());
normalBandwidth.setResourceType("1");
epsNodeBandwidthService.calculateAvg(normalBandwidth);
} catch (Exception e) {
log.error("处理服务器 {} 平均带宽失败", deviceSn, e);
}
}
/**
* 计算交换机月平均95带宽值
*/
private void calculateSwitchAvgMonthlyBandwidth(String monthlyStartTime, String monthlyEndTime, String calculationMode) {
log.info("开始计算交换机月平均95带宽值...");
try {
EpsNodeBandwidth epsNodeBandwidth = new EpsNodeBandwidth();
epsNodeBandwidth.setStartTime(monthlyStartTime);
epsNodeBandwidth.setEndTime(monthlyEndTime);
List<AllInterfaceName> switchSnList = allInterfaceNameService.getAllSwitchSn(new AllInterfaceName());
for (AllInterfaceName switchSnMsg : switchSnList) {
processSwitchAvgBandwidth(epsNodeBandwidth, switchSnMsg, calculationMode);
}
log.info("交换机月平均95带宽值计算完成");
} catch (Exception e) {
log.error("计算交换机月平均95带宽值失败", e);
}
}
/**
* 处理单个交换机的平均带宽计算
*/
private void processSwitchAvgBandwidth(EpsNodeBandwidth epsNodeBandwidth, AllInterfaceName switchSnMsg, String calculationMode) {
final String switchSn = switchSnMsg.getSwitchSn();
try {
// 1. 查询交换机拓扑信息
RmEpsTopologyManagement managementQuery = new RmEpsTopologyManagement();
managementQuery.setSwitchSn(switchSn);
List<RmEpsTopologyManagement> topologyList = rmEpsTopologyManagementService.selectRmEpsTopologyManagementList(managementQuery);
// 2. 设置基础信息
RmEpsTopologyManagement topology = topologyList.isEmpty() ? new RmEpsTopologyManagement() : topologyList.get(0);
epsNodeBandwidth.setSwitchSn(switchSn);
epsNodeBandwidth.setInterfaceName(topology.getInterfaceName());
// 3. 判断连接设备类型
boolean isServerConnected = "1".equals(topology.getConnectedDeviceType());
// 4. 处理服务器连接的情况
if (isServerConnected && topology.getServerSn() != null) {
String serverSn = topology.getServerSn();
epsNodeBandwidth.setHardwareSn(serverSn);
// 查询服务器配置
EpsServerRevenueConfig queryConfig = new EpsServerRevenueConfig();
queryConfig.setHardwareSn(serverSn);
List<EpsServerRevenueConfig> configList = epsServerRevenueConfigService.selectEpsServerRevenueConfigList(queryConfig);
EpsServerRevenueConfig serverConfig = configList.isEmpty() ? new EpsServerRevenueConfig() : configList.get(0);
epsNodeBandwidth.setNodeName(serverConfig.getNodeName());
// 检查是否需要处理业务变更
boolean shouldProcessChange = serverConfig.getUpdateTime() != null
&& epsNodeBandwidth.getStartTime() != null
&& epsNodeBandwidth.getStartTime().length() >= 10
&& "1".equals(serverConfig.getChanged())
&& DateUtils.parseDateToStr("yyyy-MM", serverConfig.getUpdateTime())
.equals(epsNodeBandwidth.getStartTime().substring(0, 7));
if(shouldProcessChange){
// 查询业务变更记录
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
changeQuery.setHardwareSn(serverSn);
changeQuery.setStartTime(epsNodeBandwidth.getStartTime());
changeQuery.setEndTime(epsNodeBandwidth.getEndTime());
List<EpsMethodChangeRecord> records = epsMethodChangeRecordService.selectEpsMethodChangeRecordList(changeQuery);
// 按businessCode分组处理
if (!records.isEmpty()) {
Map<String, List<EpsMethodChangeRecord>> groupedRecords = records.stream()
.filter(record -> record.getBusinessCode() != null) // 过滤掉businessCode为null的记录
.collect(Collectors.groupingBy(EpsMethodChangeRecord::getBusinessCode));
// 处理每个业务分组
for (Map.Entry<String, List<EpsMethodChangeRecord>> entry : groupedRecords.entrySet()) {
String businessCode = entry.getKey();
List<EpsMethodChangeRecord> businessRecords = entry.getValue();
// 取第一个有效业务名称
String businessName = businessRecords.stream()
.filter(r -> r.getBusinessName() != null)
.findFirst()
.map(EpsMethodChangeRecord::getBusinessName)
.orElse("未知业务");
// 创建业务带宽对象
EpsNodeBandwidth bandwidthWithBiz = new EpsNodeBandwidth();
bandwidthWithBiz.setSwitchSn(switchSn);
bandwidthWithBiz.setCalculationMode(calculationMode);
bandwidthWithBiz.setInterfaceName(topology.getInterfaceName());
bandwidthWithBiz.setHardwareSn(serverSn);
bandwidthWithBiz.setNodeName(topology.getServerName());
bandwidthWithBiz.setUplinkSwitch(topology.getSwitchName());
bandwidthWithBiz.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
bandwidthWithBiz.setStartTime(epsNodeBandwidth.getStartTime());
bandwidthWithBiz.setEndTime(epsNodeBandwidth.getEndTime());
bandwidthWithBiz.setBusinessId(businessCode);
bandwidthWithBiz.setBusinessName(businessName);
bandwidthWithBiz.setResourceType("2");
// 执行计算
epsNodeBandwidthService.calculateAvg(bandwidthWithBiz);
}
// 处理businessCode为null的记录(如果有)
List<EpsMethodChangeRecord> nullBusinessRecords = records.stream()
.filter(record -> record.getBusinessCode() == null)
.collect(Collectors.toList());
if (!nullBusinessRecords.isEmpty()) {
log.warn("交换机 {} 有 {} 条记录的businessCode为null", switchSn, nullBusinessRecords.size());
// 可以选择记录日志或进行其他处理
}
return; // 业务变更处理完成后直接返回
}
}else{
// 5. 处理普通情况(无变更记录)
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
normalBandwidth.setSwitchSn(switchSn);
normalBandwidth.setCalculationMode(calculationMode);
normalBandwidth.setInterfaceName(topology.getInterfaceName());
normalBandwidth.setHardwareSn(topology.getServerSn());
normalBandwidth.setNodeName(topology.getServerName());
normalBandwidth.setUplinkSwitch(topology.getSwitchName());
normalBandwidth.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
normalBandwidth.setBusinessId(serverConfig.getBusinessCode());
normalBandwidth.setBusinessName(serverConfig.getBusinessName());
normalBandwidth.setResourceType("2");
epsNodeBandwidthService.calculateAvg(normalBandwidth);
}
}
// 5. 处理机房出口情况
EpsNodeBandwidth normalBandwidth = new EpsNodeBandwidth();
normalBandwidth.setSwitchSn(switchSn);
normalBandwidth.setCalculationMode(calculationMode);
normalBandwidth.setInterfaceName(topology.getInterfaceName());
normalBandwidth.setInterfaceLinkDeviceType(topology.getConnectedDeviceType());
normalBandwidth.setStartTime(epsNodeBandwidth.getStartTime());
normalBandwidth.setEndTime(epsNodeBandwidth.getEndTime());
normalBandwidth.setResourceType("2");
epsNodeBandwidthService.calculateAvg(normalBandwidth);
} catch (Exception e) {
log.error("处理交换机 {} 平均带宽失败", switchSn, e);
}
}
}
@@ -1,169 +0,0 @@
package com.ruoyi.system.controller;
import com.ruoyi.common.core.domain.R;
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.InnerAuth;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.RmResourceRegistration;
import com.ruoyi.system.service.IRmResourceRegistrationService;
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
*
* @author gyt
* @date 2025-08-12
*/
@RestController
@RequestMapping("/registration")
public class RmResourceRegistrationController extends BaseController
{
@Autowired
private IRmResourceRegistrationService rmResourceRegistrationService;
/**
* 查询资源注册列表
*/
@RequiresPermissions("system:registration:list")
@PostMapping("/list")
public TableDataInfo list(@RequestBody RmResourceRegistration rmResourceRegistration)
{
PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(rmResourceRegistration.getPageNum());
pageDomain.setPageSize(rmResourceRegistration.getPageSize());
startPage(pageDomain);
List<RmResourceRegistration> list = rmResourceRegistrationService.selectRmResourceRegistrationList(rmResourceRegistration);
return getDataTable(list);
}
/**
* 导出资源注册列表
*/
@RequiresPermissions("system:registration:export")
@Log(title = "资源注册", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, @RequestBody RmResourceRegistration rmResourceRegistration)
{
List<RmResourceRegistration> list = rmResourceRegistrationService.selectRmResourceRegistrationList(rmResourceRegistration);
ExcelUtil<RmResourceRegistration> util = new ExcelUtil<RmResourceRegistration>(RmResourceRegistration.class);
util.showColumn(rmResourceRegistration.getProperties());
util.exportExcel(response, list, "资源注册数据");
}
/**
* 获取资源注册详细信息
*/
@RequiresPermissions("system:registration:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(rmResourceRegistrationService.selectRmResourceRegistrationById(id));
}
/**
* 新增资源注册
*/
@RequiresPermissions("system:registration:add")
@Log(title = "资源注册", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody RmResourceRegistration rmResourceRegistration)
{
int rows = rmResourceRegistrationService.insertRmResourceRegistration(rmResourceRegistration);
if(-1==rows){
return AjaxResult.error(500,"硬件SN不可重复");
}
return toAjax(rows);
}
/**
* 修改资源注册
*/
@RequiresPermissions("system:registration:edit")
@Log(title = "资源注册", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody RmResourceRegistration rmResourceRegistration)
{
return toAjax(rmResourceRegistrationService.updateRmResourceRegistration(rmResourceRegistration));
}
/**
* 资源注册-注册
*/
@RequiresPermissions("system:registration:edit")
@Log(title = "资源注册-注册", businessType = BusinessType.UPDATE)
@PostMapping("/register")
public AjaxResult register(@RequestBody RmResourceRegistration rmResourceRegistration)
{
return toAjax(rmResourceRegistrationService.register(rmResourceRegistration));
}
/**
* 查询所有资源名称(包含设备使用)
* @return 资源注册集合
*/
@RequiresPermissions("system:group:list")
@GetMapping("/selectAllResourceName")
public List<Map> selectAllResourceName()
{
List<Map> list = rmResourceRegistrationService.selectAllResourceName();
return list;
}
/**
* 查询所有资源名称
* @return 资源注册集合
*/
@RequiresPermissions("system:group:list")
@PostMapping("/selectAllResourceNameByType")
public List<Map> selectAllResourceNameByType(@RequestBody RmResourceRegistration rmResourceRegistration)
{
List<Map> list = rmResourceRegistrationService.selectAllResourceNameByType(rmResourceRegistration);
return list;
}
/**
* 检测到服务器离线,修改状态为离线
* @param rmResourceRegistration
* @return
*/
@InnerAuth
@PostMapping("/updateStatusByResource")
public R<String> updateStatusByResource(@RequestBody RmResourceRegistration rmResourceRegistration)
{
R<String> rows = rmResourceRegistrationService.updateStatusByResource(rmResourceRegistration);
return rows;
}
/**
* 根据id查询资源信息
* @param ids
* @return
*/
@PostMapping("/getRegistrationByIds")
public R<List<RmResourceRegistration>> getRegistrationByIds(@RequestBody String[] ids)
{
List<RmResourceRegistration> list = rmResourceRegistrationService.getRegistrationByIds(ids);
return R.ok(list);
}
/**
* 查询资源注册列表
*/
@InnerAuth
@PostMapping("/getListByHardwareSn")
public R<RmResourceRegistration> getListByHardwareSn(@RequestBody RmResourceRegistration rmResourceRegistration)
{
List<RmResourceRegistration> list = rmResourceRegistrationService.selectRmResourceRegistrationList(rmResourceRegistration);
return R.ok(list.get(0));
}
}
@@ -1,133 +0,0 @@
package com.ruoyi.system.domain;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import lombok.Data;
/**
* 资源注册对象 rm_resource_registration
*
* @author gyt
* @date 2025-08-12
*/
@Data
public class RmResourceRegistration extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** id */
private Long id;
/** 硬件SN */
@Excel(name = "硬件SN")
private String hardwareSn;
/** 资源类型
* 1 服务器,2 交换机*/
@Excel(name = "资源类型",readConverterExp = "1=服务器,2=交换机")
private String resourceType;
/** 资源名称 */
@Excel(name = "资源名称")
private String resourceName;
/** IP地址 */
@Excel(name = "IP地址")
private String ipAddress;
/** 端口1.162(SNMP),2.其他 */
@Excel(name = "端口")
private String resourcePort;
/**其他端口名称 */
private String otherPortName;
/** agent版本 */
@Excel(name = "agent版本")
private String agentVersion;
/** 协议 1.TCP,2.UDP */
@Excel(name = "协议",readConverterExp = "1=TCP,2=UDP")
private String protocol;
/** SNMP探测 0=否,1=是 */
@Excel(name = "",readConverterExp = "0=否,1=是")
private String snmpDetect;
/** 版本(1.SNMPv2,2.SNMPv3) */
@Excel(name = "SNMP版本",readConverterExp = "1=华为SNMPv2c,2=华为SNMPv3")
private String resourceVersion;
/** 读写权限(1.RW,2.ReadOnly) */
@Excel(name = "读写权限",readConverterExp = "1=只读,2=可读可写")
private String rwPermission;
/** 团体名称 */
@Excel(name = "团体名称")
private String teamName;
/** SNMP采集地址 */
@Excel(name = "SNMP采集地址")
private String snmpCollectAddr;
/** SNMP采集端口 */
@Excel(name = "SNMP采集端口")
private String snmpCollectPort;
/** 安全级别(1.authPriv、2.authNoPriv3.noAuthNoPriv) */
@Excel(name = "安全级别",readConverterExp = "1=authPriv,2=authNoPriv,3=noAuthNoPriv")
private String securityLevel;
/** 加密方式 1.md5,2.SHA */
@Excel(name = "加密方式",readConverterExp = "1=MD5,2=SHA")
private String encryption;
/** 用户名 */
@Excel(name = "用户名")
private String resourceUserName;
/** 密码 */
@Excel(name = "密码")
private String resourcePwd;
/** 注册状态 0-未注册,1-已注册 */
@Excel(name = "注册状态",readConverterExp = "0=未注册,1=已注册")
private String registrationStatus;
/** 在线状态 0-离线,1-在线 */
@Excel(name = "在线状态",readConverterExp = "0=离线,1=在线")
private String onlineStatus;
@Excel(name = "交换机在线状态",readConverterExp = "0=离线,1=在线")
private String switchOnlineStatus;
/** 描述 */
@Excel(name = "描述")
private String description;
/** 设备业务客户id */
private Long customerId;
/** 设备业务客户名称 */
@Excel(name = "设备业务客户")
private String customerName;
/** 业务号 */
@Excel(name = "业务号")
private String serviceNumber;
/** 创建人id */
private Long creatorId;
/** 创建人名称 */
private String creatorName;
/** 修改人id */
private Long updaterId;
/** 修改人名称 */
private String updaterName;
/** 监控项 */
private String monitorItems;
/** 自动发现项 */
private String discoveryRules;
/** 查询名称 */
private String queryName;
}
@@ -1,102 +0,0 @@
package com.ruoyi.system.domain;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.web.domain.BaseEntity;
import com.ruoyi.common.core.xss.Xss;
/**
* 通知公告表 sys_notice
*
* @author ruoyi
*/
public class SysNotice extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 公告ID */
private Long noticeId;
/** 公告标题 */
private String noticeTitle;
/** 公告类型(1通知 2公告) */
private String noticeType;
/** 公告内容 */
private String noticeContent;
/** 公告状态(0正常 1关闭) */
private String status;
public Long getNoticeId()
{
return noticeId;
}
public void setNoticeId(Long noticeId)
{
this.noticeId = noticeId;
}
public void setNoticeTitle(String noticeTitle)
{
this.noticeTitle = noticeTitle;
}
@Xss(message = "公告标题不能包含脚本字符")
@NotBlank(message = "公告标题不能为空")
@Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
public String getNoticeTitle()
{
return noticeTitle;
}
public void setNoticeType(String noticeType)
{
this.noticeType = noticeType;
}
public String getNoticeType()
{
return noticeType;
}
public void setNoticeContent(String noticeContent)
{
this.noticeContent = noticeContent;
}
public String getNoticeContent()
{
return noticeContent;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("noticeId", getNoticeId())
.append("noticeTitle", getNoticeTitle())
.append("noticeType", getNoticeType())
.append("noticeContent", getNoticeContent())
.append("status", getStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
@@ -1,44 +0,0 @@
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<EpsInitialTrafficData> selectByCondition(EpsInitialTrafficData condition);
/**
* 查询初始流量信息
* @param condition 查询条件实体
* @return 初始流量数据列表
*/
List<EpsInitialTrafficData> getAllTraficMsg(EpsInitialTrafficData condition);
}
@@ -1,89 +0,0 @@
package com.ruoyi.system.mapper;
import com.ruoyi.system.domain.RmResourceRegistration;
import java.util.List;
import java.util.Map;
/**
* 资源注册Mapper接口
*
* @author gyt
* @date 2025-08-12
*/
public interface RmResourceRegistrationMapper
{
/**
* 查询资源注册
*
* @param id 资源注册主键
* @return 资源注册
*/
public RmResourceRegistration selectRmResourceRegistrationById(Long id);
/**
* 查询资源注册列表
*
* @param rmResourceRegistration 资源注册
* @return 资源注册集合
*/
public List<RmResourceRegistration> selectRmResourceRegistrationList(RmResourceRegistration rmResourceRegistration);
/**
* 新增资源注册
*
* @param rmResourceRegistration 资源注册
* @return 结果
*/
public int insertRmResourceRegistration(RmResourceRegistration rmResourceRegistration);
/**
* 修改资源注册
*
* @param rmResourceRegistration 资源注册
* @return 结果
*/
public int updateRmResourceRegistration(RmResourceRegistration rmResourceRegistration);
/**
* 删除资源注册
*
* @param id 资源注册主键
* @return 结果
*/
public int deleteRmResourceRegistrationById(Long id);
/**
* 批量删除资源注册
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteRmResourceRegistrationByIds(Long[] ids);
/**
* 查询所有资源名称([包含设备]功能使用)
* @return 资源注册集合
*/
public List<Map> selectAllResourceName();
/**
* 查询是否有此设备
* @param hardwareSn 资源sn
* @return 结果
*/
public int countBySn(String hardwareSn);
/**
* 查询所有资源名称
* @return 资源注册集合
*/
public List<Map> selectAllResourceNameByType(RmResourceRegistration resourceRegistration);
/**
* 检测到服务器离线,修改状态为离线
* @param rmResourceRegistration
* @return
*/
Integer updateStatusByResource(RmResourceRegistration rmResourceRegistration);
List<RmResourceRegistration> getRegistrationByIds(String[] ids);
}
@@ -1,93 +0,0 @@
package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.domain.RmResourceRegistration;
import java.util.List;
import java.util.Map;
/**
* 资源注册Service接口
*
* @author gyt
* @date 2025-08-12
*/
public interface IRmResourceRegistrationService
{
/**
* 查询资源注册
*
* @param id 资源注册主键
* @return 资源注册
*/
public RmResourceRegistration selectRmResourceRegistrationById(Long id);
/**
* 查询资源注册列表
*
* @param rmResourceRegistration 资源注册
* @return 资源注册集合
*/
public List<RmResourceRegistration> selectRmResourceRegistrationList(RmResourceRegistration rmResourceRegistration);
/**
* 新增资源注册
*
* @param rmResourceRegistration 资源注册
* @return 结果
*/
public int insertRmResourceRegistration(RmResourceRegistration rmResourceRegistration);
/**
* 修改资源注册
*
* @param rmResourceRegistration 资源注册
* @return 结果
*/
public int updateRmResourceRegistration(RmResourceRegistration rmResourceRegistration);
/**
* 资源注册-注册
* @param rmResourceRegistration
* @return
*/
public int register(RmResourceRegistration rmResourceRegistration);
/**
* 批量删除资源注册
*
* @param ids 需要删除的资源注册主键集合
* @return 结果
*/
public int deleteRmResourceRegistrationByIds(Long[] ids);
/**
* 删除资源注册信息
*
* @param id 资源注册主键
* @return 结果
*/
public int deleteRmResourceRegistrationById(Long id);
/**
* 查询所有资源名称(包含设备使用)
* @return 资源注册集合
*/
public List<Map> selectAllResourceName();
/**
* 查询所有资源名称
* @return 资源注册集合
*/
public List<Map> selectAllResourceNameByType(RmResourceRegistration resourceRegistration);
/**
* 检测到服务器离线,修改状态为离线
* @param rmResourceRegistration
* @return
*/
R<String> updateStatusByResource(RmResourceRegistration rmResourceRegistration);
AjaxResult getServerOnlineRate();
List<RmResourceRegistration> getRegistrationByIds(String[] ids);
}
@@ -1,106 +0,0 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.domain.AllInterfaceName;
import com.ruoyi.system.mapper.AllInterfaceNameMapper;
import com.ruoyi.system.service.IAllInterfaceNameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 所有接口名称Service业务层处理
*
* @author gyt
* @date 2025-08-25
*/
@Service
public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService
{
@Autowired
private AllInterfaceNameMapper allInterfaceNameMapper;
/**
* 查询所有接口名称
*
* @param id 所有接口名称主键
* @return 所有接口名称
*/
@Override
public AllInterfaceName selectAllInterfaceNameById(Long id)
{
return allInterfaceNameMapper.selectAllInterfaceNameById(id);
}
/**
* 查询所有接口名称列表
*
* @param allInterfaceName 所有接口名称
* @return 所有接口名称
*/
@Override
public List<AllInterfaceName> selectAllInterfaceNameList(AllInterfaceName allInterfaceName)
{
return allInterfaceNameMapper.selectAllInterfaceNameList(allInterfaceName);
}
/**
* 新增所有接口名称
*
* @param allInterfaceName 所有接口名称
* @return 结果
*/
@Override
public int insertAllInterfaceName(AllInterfaceName allInterfaceName)
{
allInterfaceName.setCreateTime(DateUtils.getNowDate());
return allInterfaceNameMapper.insertAllInterfaceName(allInterfaceName);
}
/**
* 修改所有接口名称
*
* @param allInterfaceName 所有接口名称
* @return 结果
*/
@Override
public int updateAllInterfaceName(AllInterfaceName allInterfaceName)
{
allInterfaceName.setUpdateTime(DateUtils.getNowDate());
return allInterfaceNameMapper.updateAllInterfaceName(allInterfaceName);
}
/**
* 批量删除所有接口名称
*
* @param ids 需要删除的所有接口名称主键
* @return 结果
*/
@Override
public int deleteAllInterfaceNameByIds(Long[] ids)
{
return allInterfaceNameMapper.deleteAllInterfaceNameByIds(ids);
}
/**
* 删除所有接口名称信息
*
* @param id 所有接口名称主键
* @return 结果
*/
@Override
public int deleteAllInterfaceNameById(Long id)
{
return allInterfaceNameMapper.deleteAllInterfaceNameById(id);
}
@Override
public List<AllInterfaceName> getAllDeviceSn(AllInterfaceName interfaceName) {
return allInterfaceNameMapper.getAllDeviceSn(interfaceName);
}
@Override
public List<AllInterfaceName> getAllSwitchSn(AllInterfaceName allInterfaceName){
return allInterfaceNameMapper.getAllSwitchSn(allInterfaceName);
}
}
@@ -1,615 +0,0 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.EpsInitialTrafficDataService;
import com.ruoyi.system.util.CalculateUtil;
import com.ruoyi.system.util.DateUtil;
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.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@Service
@Slf4j
public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataService {
@Autowired
private EpsInitialTrafficDataMapper epsInitialTrafficDataMapper;
@Autowired
private EpsNodeBandwidthMapper epsNodeBandwidthMapper;
@Autowired
private AllInterfaceNameMapper allInterfaceNameMapper;
@Autowired
private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper;
@Autowired
private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper;
@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<String> 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(DateUtils.getNowDate());
}
data.setTableName(TableRouterUtil.getTableName(DateUtil.dateToLocalDateTime(data.getCreateTime())));
epsInitialTrafficDataMapper.insert(data);
}
/**
* 批量保存数据到对应分表
* @param epsInitialTrafficData 流量数据表
*/
@Override
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
public void saveBatch(EpsInitialTrafficData epsInitialTrafficData) {
if (epsInitialTrafficData == null || epsInitialTrafficData.getDataList().isEmpty()) {
return;
}
// 内存去重(基于唯一键)
List<EpsInitialTrafficData> distinctList = epsInitialTrafficData.getDataList().stream()
.filter(Objects::nonNull)
.map(data -> {
EpsInitialTrafficData processed = new EpsInitialTrafficData();
BeanUtils.copyProperties(data, processed);
if (data.getCreateTime() == null) {
processed.setCreateTime(DateUtils.getNowDate());
}
return processed;
})
.collect(Collectors.collectingAndThen(
// 使用TreeSet按唯一键去重
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(
d -> String.join("|",
d.getClientId(),
d.getMac(),
d.getName(),
d.getCreateTime().toString()
)
))),
ArrayList::new
));
// 按表名分组
Map<String, List<EpsInitialTrafficData>> groupedData = distinctList.stream()
.map(data -> {
data.setTableName(TableRouterUtil.getTableName(
data.getCreateTime().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime()
));
return data;
})
.collect(Collectors.groupingBy(
EpsInitialTrafficData::getTableName,
LinkedHashMap::new,
Collectors.toList()
));
// 分表插入(带冲突降级)
groupedData.forEach((tableName, list) -> {
try {
EpsInitialTrafficData batchData = new EpsInitialTrafficData();
BeanUtils.copyProperties(epsInitialTrafficData, batchData);
batchData.setTableName(tableName);
batchData.setDataList(list);
// 优先尝试批量插入
epsInitialTrafficDataMapper.batchInsert(batchData);
} catch (Exception e) {
log.error("表 {} 插入失败", tableName, e);
throw new RuntimeException("数据入库失败", e);
}
});
}
/**
* 查询流量数据
*/
@Override
public List<EpsInitialTrafficData> query(EpsInitialTrafficData queryParam) {
// 参数校验
// if (StringUtils.isBlank(queryParam.getDeviceSn())) {
// throw new IllegalArgumentException("设备序列号不能为空");
// }
// 获取涉及的表名
Set<String> tableNames = TableRouterUtil.getTableNamesBetween(queryParam.getStartTime(), queryParam.getEndTime());
// 并行查询各表
return tableNames.parallelStream()
.flatMap(tableName -> {
EpsInitialTrafficData condition = new EpsInitialTrafficData();
condition.setTableName(tableName);
condition.setServiceSn(queryParam.getServiceSn());
condition.setStartTime(queryParam.getStartTime());
condition.setEndTime(queryParam.getEndTime());
condition.setBusinessId(queryParam.getBusinessId());
condition.setBusinessName(queryParam.getBusinessName());
return epsInitialTrafficDataMapper.selectByCondition(condition).stream();
})
.collect(Collectors.toList());
}
@Override
public List<EpsInitialTrafficData> getAllTraficMsg(EpsInitialTrafficData queryParam) {
// 获取涉及的表名
Set<String> tableNames = TableRouterUtil.getTableNamesBetweenInitial(queryParam.getStartTime(), queryParam.getEndTime());
// 并行查询各表
return tableNames.parallelStream()
.flatMap(tableName -> {
EpsInitialTrafficData condition = new EpsInitialTrafficData();
condition.setTableName(tableName);
condition.setStartTime(queryParam.getStartTime());
condition.setEndTime(queryParam.getEndTime());
condition.setName(queryParam.getName());
return epsInitialTrafficDataMapper.getAllTraficMsg(condition).stream();
})
.collect(Collectors.toList());
}
/**
* 计算95带宽值/日
* @param queryParam
*/
@Override
public void calculateBusiness95BandwidthDaily(EpsInitialTrafficData queryParam,
String dailyStartTime, String dailyEndTime, String calculationMode) {
// 获取所有设备SN列表
List<AllInterfaceName> snList = allInterfaceNameMapper.getAllDeviceSn(new AllInterfaceName());
// 遍历处理每个设备
snList.forEach(interfaceName -> {
queryParam.setServiceSn(interfaceName.getDeviceSn());
processDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
});
}
/**
* 重新计算服务器95带宽值
* @param epsNodeBandwidth 95带宽值收益详情
* @param dailyStartTime 开始时间
* @param dailyEndTime 结束时间
*/
@Override
public void recalculateServer95Bandwidth(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime, String dailyEndTime, String calculationMode ) {
EpsInitialTrafficData epsInitialTrafficData = new EpsInitialTrafficData();
epsInitialTrafficData.setStartTime(dailyStartTime);
epsInitialTrafficData.setEndTime(dailyEndTime);
epsInitialTrafficData.setServiceSn(epsNodeBandwidth.getHardwareSn());
epsInitialTrafficData.setNodeName(epsNodeBandwidth.getNodeName());
epsInitialTrafficData.setBusinessName(epsNodeBandwidth.getBusinessName());
epsInitialTrafficData.setBusinessId(epsNodeBandwidth.getBusinessId());
List<EpsInitialTrafficData> dataList = query(epsInitialTrafficData);
if(!dataList.isEmpty()){
// 1. 提取并转换带宽值
List<BigDecimal> speedsInMbps = dataList.stream()
.map(data -> CalculateUtil.parseSpeedToMbps(data.getOutSpeed(), calculationMode))
.sorted()
.collect(Collectors.toList());
// 2. 计算95百分位
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
// 3. 保存结果
EpsInitialTrafficData initialTrafficData = dataList.get(0);
initialTrafficData.setResourceType("1");
initialTrafficData.setBandwidthType(epsNodeBandwidth.getBandwidthType());
saveBandwidthResult(initialTrafficData, percentile95, dailyStartTime, calculationMode);
}
}
/**
* 计算服务器流量使用率(处理带单位的数据)
* @return 包含总带宽、发送带宽和发送占比的Map
*/
@Override
public Map<String, Object> trafficRateByServer() {
Map<String, Object> resultMap = new HashMap<>(3);
// 初始化默认值
resultMap.put("outSpeedTotal", BigDecimal.ZERO);
resultMap.put("speedTotal", BigDecimal.ZERO);
resultMap.put("outSpeedRate", BigDecimal.ZERO);
// 获取近5分钟的流量数据
List<EpsInitialTrafficData> dataList = getTrafficData();
if (CollectionUtils.isEmpty(dataList)) {
return resultMap;
}
BigDecimal total = BigDecimal.ZERO;
BigDecimal outTotal = BigDecimal.ZERO;
boolean hasValidData = false;
// 计算总带宽和发送带宽
for (EpsInitialTrafficData data : dataList) {
// 处理发送带宽(假设outSpeed已经是标准单位)
try {
BigDecimal outSpeed = CalculateUtil.parseSpeedToMbps(data.getOutSpeed(), "1000");
outTotal = outTotal.add(outSpeed);
} catch (Exception e) {
log.warn("Invalid outSpeed value: {}", data.getOutSpeed());
continue;
}
// 处理总带宽(带单位的值如"10000Mb/s"
String speedWithUnit = data.getSpeed();
if (speedWithUnit != null && !"Unknown!".equalsIgnoreCase(speedWithUnit)) {
try {
// 移除单位部分(如"Mb/s"
String numericPart = speedWithUnit.replaceAll("[^0-9.]", "");
BigDecimal speedValue = new BigDecimal(numericPart);
total = total.add(speedValue);
hasValidData = true;
} catch (NumberFormatException e) {
log.warn("Invalid speed value format: {}", speedWithUnit);
}
}
}
// 存储计算结果
resultMap.put("outSpeedTotal", outTotal.setScale(2, RoundingMode.HALF_UP));
resultMap.put("speedTotal", total.setScale(2, RoundingMode.HALF_UP));
// 计算发送带宽占比(只有存在有效数据时才计算)
if (hasValidData && total.compareTo(BigDecimal.ZERO) != 0) {
BigDecimal outSpeedRate = outTotal.divide(total, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
resultMap.put("outSpeedRate", outSpeedRate);
}
return resultMap;
}
/**
* 当前在线服务器发送带宽总流量
* @return
*/
@Override
public BigDecimal sumTrafficByServer() {
// 总带宽
BigDecimal total = BigDecimal.ZERO;
// 近5分钟的带宽明细
List<EpsInitialTrafficData> dataList = getTrafficData();
if(!dataList.isEmpty()){
for (EpsInitialTrafficData initialTrafficData : dataList) {
// 服务器发送带宽流量
BigDecimal outSpeed = CalculateUtil.parseSpeedToMbps(initialTrafficData.getOutSpeed(), "1000");
total = total.add(outSpeed);
}
}
return total.setScale(0, RoundingMode.HALF_UP);
}
/**
* 提取公共方法
* @return
*/
private List<EpsInitialTrafficData> getTrafficData(){
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 结束时间
LocalDateTime endTime = now.minusSeconds(1);
// 开始时间
LocalDateTime startTime = now.minusMinutes(5);
// 定义日期时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 格式化为字符串
String dailyStartTime = startTime.format(formatter);
String dailyEndTime = endTime.format(formatter);
EpsInitialTrafficData epsInitialTrafficData = new EpsInitialTrafficData();
epsInitialTrafficData.setStartTime(dailyStartTime);
epsInitialTrafficData.setEndTime(dailyEndTime);
List<EpsInitialTrafficData> dataList = query(epsInitialTrafficData);
return dataList;
}
/**
* 处理单个设备的带宽计算
*/
private void processDeviceBandwidth(EpsInitialTrafficData queryParam,
String dailyStartTime,
String dailyEndTime, String calculationMode) {
// 1. 检查设备是否有业务变更
EpsServerRevenueConfig revenueConfig = new EpsServerRevenueConfig();
revenueConfig.setHardwareSn(queryParam.getServiceSn());
List<EpsServerRevenueConfig> changedList = epsServerRevenueConfigMapper
.selectEpsServerRevenueConfigList(revenueConfig);
// 2. 根据业务变更情况选择计算方式
if (hasTrafficMethodChanged(changedList)) {
calculateChangedDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
} else {
calculateNormalDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
}
}
/**
* 判断是否为流量型业务变更
*/
private boolean hasTrafficMethodChanged(List<EpsServerRevenueConfig> changedList) {
return !changedList.isEmpty() &&
"1".equals(changedList.get(0).getChanged()) &&
"1".equals(changedList.get(0).getRevenueMethod());
}
/**
* 计算有业务变更设备的带宽
*/
private void calculateChangedDeviceBandwidth(EpsInitialTrafficData queryParam,
String dailyStartTime,
String dailyEndTime, String calculationMode) {
// 1. 获取业务变更记录(按时间降序)
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
changeQuery.setHardwareSn(queryParam.getServiceSn());
changeQuery.setStartTime(dailyStartTime);
changeQuery.setEndTime(dailyEndTime);
List<EpsMethodChangeRecord> records = epsMethodChangeRecordMapper
.selectEpsMethodChangeRecordList(changeQuery);
if (!records.isEmpty()) {
// 2. 确保按时间降序排列
records.sort((r1, r2) -> r2.getCreateTime().compareTo(r1.getCreateTime()));
// 3. 计算各时间段95值
calculateTimeSegments95(queryParam, records, dailyStartTime, dailyEndTime, calculationMode);
}else{
calculateNormalDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
}
}
/**
* 计算无业务变更设备的带宽
*/
private void calculateNormalDeviceBandwidth(EpsInitialTrafficData queryParam,
String dailyStartTime,
String dailyEndTime, String calculationMode) {
queryParam.setStartTime(dailyStartTime);
queryParam.setEndTime(dailyEndTime);
List<EpsInitialTrafficData> dataList = query(queryParam);
if (!dataList.isEmpty()) {
calculateAndSave95Bandwidth(dataList, dailyStartTime, queryParam.getDayOrMonth(), calculationMode);
}
}
/**
* 计算并保存95带宽值
*/
private void calculateAndSave95Bandwidth(List<EpsInitialTrafficData> dataList, String dateTime, String dayOrMonth, String calculationMode) {
boolean eff = false;
if(!dataList.isEmpty()){
if(dataList.size()<288){
eff = true;
}
// 1. 提取并转换带宽值
List<BigDecimal> speedsInMbps = dataList.stream()
.map(data -> CalculateUtil.parseSpeedToMbps(data.getOutSpeed(), calculationMode))
.sorted()
.collect(Collectors.toList());
// 2. 计算95百分位
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
// 3. 保存结果
EpsInitialTrafficData epsInitialTrafficData = dataList.get(0);
epsInitialTrafficData.setResourceType("1");
if("2".equals(epsInitialTrafficData.getRevenueMethod())){
percentile95 = epsInitialTrafficData.getPackageBandwidth();
epsInitialTrafficData.setBandwidthType("3");
}else {
if("1".equals(dayOrMonth)){
if(eff){
epsInitialTrafficData.setBandwidthType("5");
}else {
epsInitialTrafficData.setBandwidthType("1");
}
}
if("2".equals(dayOrMonth)){
if(eff){
epsInitialTrafficData.setBandwidthType("6");
}else {
epsInitialTrafficData.setBandwidthType("2");
}
}
}
saveBandwidthResult(epsInitialTrafficData, percentile95, dateTime, calculationMode);
}
}
/**
* 计算设备各时间段的95带宽值
*/
private void calculateTimeSegments95(EpsInitialTrafficData queryParam,
List<EpsMethodChangeRecord> records,
String dailyStartTime,
String dailyEndTime, String calculationMode) {
// 1. 处理变更时间段(从最新到最早)
String endTime = records.get(0).getCreateTime() + "";
for (int i = 1; i < records.size(); i++) {
String startTime = records.get(i).getCreateTime() + "";
calculateSegment95(queryParam, startTime, endTime, calculationMode);
endTime = startTime; // 移动时间窗口
}
// 2. 处理最早变更前的时间段(昨天00:00:00 ~ 最早变更时间)
String earliestChangeTime = records.get(records.size()-1).getCreateTime() + "";
calculateSegment95(queryParam, dailyStartTime, earliestChangeTime, calculationMode);
// 3. 处理最后变更后的时间段(最新变更时间 ~ 昨天23:59:59)
calculateSegment95(queryParam, endTime, dailyEndTime, calculationMode);
}
/**
* 计算单个时间段的95带宽值
*/
private void calculateSegment95(EpsInitialTrafficData queryParam, String startTime, String endTime, String calculationMode) {
queryParam.setStartTime(startTime);
queryParam.setEndTime(endTime);
List<EpsInitialTrafficData> dataList = query(queryParam);
if (!dataList.isEmpty()) {
calculate95BandwidthDaily(dataList, startTime, queryParam.getDayOrMonth(), calculationMode);
}
}
/**
* 计算日95带宽值
* @param dataList
*/
private void calculate95BandwidthDaily(List<EpsInitialTrafficData> dataList, String startTime, String dayOrMonth, String calculationMode){
// 1. 提取 outSpeed 并转换为 Mbps
List<BigDecimal> speedsInMbps = dataList.stream()
.map(data -> CalculateUtil.parseSpeedToMbps(data.getOutSpeed(), calculationMode))
.sorted()
.collect(Collectors.toList());
// 2. 计算 95% 位置(向上取整)
int total = speedsInMbps.size();
int position = (int) Math.ceil(0.95 * total) - 1; // 转换为 0-based 索引
if (position < 0){
position = 0;
}
if (position >= total){
position = total - 1;
}
// 3. 获取 95 值并四舍五入到两位小数
BigDecimal percentile95 = speedsInMbps.get(position);
BigDecimal dailyResult = percentile95.setScale(2, RoundingMode.HALF_UP);
// 服务器信息
EpsInitialTrafficData epsInitialTrafficData = dataList.get(0);
epsInitialTrafficData.setResourceType("1");
if("2".equals(epsInitialTrafficData.getRevenueMethod())){
dailyResult = epsInitialTrafficData.getPackageBandwidth();
epsInitialTrafficData.setBandwidthType("3");
}else{
if(CalculateUtil.isEff(dataList)){
if("1".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("5");
}
if("2".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("6");
}
}else {
if("1".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("1");
}
if("2".equals(dayOrMonth)){
epsInitialTrafficData.setBandwidthType("2");
}
}
}
saveBandwidthResult(epsInitialTrafficData, dailyResult, startTime, calculationMode);
}
/**
* 保存带宽结果
*/
private void saveBandwidthResult(EpsInitialTrafficData data,
BigDecimal result,
String dateTime, String calculationMode) {
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
bandwidth.setHardwareSn(data.getServiceSn());
bandwidth.setCalculationMode(calculationMode);
bandwidth.setNodeName(data.getNodeName());
bandwidth.setBusinessId(data.getBusinessId());
bandwidth.setBusinessName(data.getBusinessName());
bandwidth.setResourceType(data.getResourceType());
bandwidth.setBandwidthType(data.getBandwidthType());
bandwidth.setCreateTime(DateUtils.parseDate(dateTime));
// 查询此条数据是否存在
List<EpsNodeBandwidth> exitsList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(bandwidth);
bandwidth.setBandwidthResult(result);
switch (data.getBandwidthType()){
case "1":
bandwidth.setBandwidth95Daily(result);
break;
case "2":
bandwidth.setBandwidth95Monthly(result);
break;
case "3":
bandwidth.setPackageBandwidthDaily(result);
break;
case "4":
bandwidth.setAvgMonthlyBandwidth95(result);
break;
case "5":
bandwidth.setEffectiveBandwidth95Daily(result);
break;
case "6":
bandwidth.setEffectiveBandwidth95Monthly(result);
break;
case "7":
bandwidth.setEffectiveAvgMonthlyBandwidth95(result);
break;
default:
throw new IllegalArgumentException("Unknown bandwidthType: " + data.getBandwidthType());
}
if(!exitsList.isEmpty()){
bandwidth.setUpdateTime(DateUtils.getNowDate());
bandwidth.setId(exitsList.get(0).getId());
epsNodeBandwidthMapper.updateEpsNodeBandwidth(bandwidth);
}else{
bandwidth.setUpdateTime(DateUtils.getNowDate());
epsNodeBandwidthMapper.insertEpsNodeBandwidth(bandwidth);
}
}
}
@@ -1,385 +0,0 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.domain.AllInterfaceName;
import com.ruoyi.system.domain.EpsInitialTrafficData;
import com.ruoyi.system.domain.EpsMethodChangeRecord;
import com.ruoyi.system.domain.EpsServerRevenueConfig;
import com.ruoyi.system.mapper.AllInterfaceNameMapper;
import com.ruoyi.system.mapper.EpsMethodChangeRecordMapper;
import com.ruoyi.system.mapper.EpsServerRevenueConfigMapper;
import com.ruoyi.system.service.EpsInitialTrafficDataService;
import com.ruoyi.system.service.IEpsServerRevenueConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
/**
* 服务器收益方式配置Service业务层处理
*
* @author gyt
* @date 2025-08-19
*/
@Service
@Slf4j
public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfigService
{
@Autowired
private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper;
@Autowired
private EpsInitialTrafficDataService epsInitialTrafficDataService;
@Autowired
private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper;
@Autowired
private AllInterfaceNameMapper allInterfaceNameMapper;
/**
* 查询服务器收益方式配置
*
* @param id 服务器收益方式配置主键
* @return 服务器收益方式配置
*/
@Override
public EpsServerRevenueConfig selectEpsServerRevenueConfigById(Long id)
{
return epsServerRevenueConfigMapper.selectEpsServerRevenueConfigById(id);
}
/**
* 查询服务器收益方式配置列表
*
* @param epsServerRevenueConfig 服务器收益方式配置
* @return 服务器收益方式配置
*/
@Override
public List<EpsServerRevenueConfig> 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());
if(serverRevenueConfig.getBusinessCode() != null){
if(!serverRevenueConfig.getBusinessCode().equals(epsServerRevenueConfig.getBusinessCode())){
epsServerRevenueConfig.setChanged("1");
}
}
// 修改条数
int rows = epsServerRevenueConfigMapper.updateEpsServerRevenueConfig(epsServerRevenueConfig);
if(rows>=0){
// 添加操作记录
addRecord(epsServerRevenueConfig);
// 添加包端数据到相关数据表
saveServiceTrafficData(epsServerRevenueConfig);
}
return rows;
}
/**
* 添加服务器配置操作记录
*/
private void addRecord(EpsServerRevenueConfig epsServerRevenueConfig) {
String nowRevenueMethod = getMethodName(epsServerRevenueConfig.getRevenueMethod());
EpsMethodChangeRecord changeRecord = new EpsMethodChangeRecord();
// 设置基本信息
changeRecord.setNodeName(epsServerRevenueConfig.getNodeName());
changeRecord.setHardwareSn(epsServerRevenueConfig.getHardwareSn());
changeRecord.setCreateTime(DateUtils.getNowDate());
changeRecord.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();
}
changeRecord.setChangeContent(content);
changeRecord.setBusinessCode(epsServerRevenueConfig.getBusinessCode());
changeRecord.setBusinessName(epsServerRevenueConfig.getBusinessName());
changeRecord.setRevenueMethod(epsServerRevenueConfig.getRevenueMethod());
changeRecord.setPackageBandwidth(epsServerRevenueConfig.getPackageBandwidth());
changeRecord.setTrafficPort(epsServerRevenueConfig.getTrafficPort());
// 添加操作记录
epsMethodChangeRecordMapper.insertEpsMethodChangeRecord(changeRecord);
}
/**
* 保存流量信息
* @param epsServerRevenueConfig
*/
private void saveServiceTrafficData(EpsServerRevenueConfig epsServerRevenueConfig) {
// 初始流量数据
EpsInitialTrafficData epsInitialTrafficData = new EpsInitialTrafficData();
epsInitialTrafficData.setServiceSn(epsServerRevenueConfig.getHardwareSn());
epsInitialTrafficData.setBusinessId(epsServerRevenueConfig.getBusinessCode());
epsInitialTrafficData.setBusinessName(epsServerRevenueConfig.getBusinessName());
epsInitialTrafficData.setName(epsServerRevenueConfig.getTrafficPort());
epsInitialTrafficData.setPackageBandwidth(epsServerRevenueConfig.getPackageBandwidth());
epsInitialTrafficData.setRevenueMethod(epsServerRevenueConfig.getRevenueMethod());
epsInitialTrafficData.setNodeName(epsServerRevenueConfig.getNodeName());
epsInitialTrafficData.setStartTime(epsServerRevenueConfig.getCreateTime() + "");
epsInitialTrafficData.setEndTime(epsServerRevenueConfig.getCreateTime() + "");
epsInitialTrafficDataService.save(epsInitialTrafficData);
}
/**
* 保存流量信息
* @param epsServerRevenueConfig
*/
@Override
public R<String> autoSaveServiceTrafficData(EpsServerRevenueConfig epsServerRevenueConfig) {
// 查询初始流量数据
EpsInitialTrafficData epsInitialTrafficData = new EpsInitialTrafficData();
epsInitialTrafficData.setStartTime(epsServerRevenueConfig.getStartTime());
epsInitialTrafficData.setEndTime(epsServerRevenueConfig.getEndTime());
List<EpsInitialTrafficData> dataList = epsInitialTrafficDataService.getAllTraficMsg(epsInitialTrafficData);
List<EpsInitialTrafficData> batchList = new ArrayList<>();
for (EpsInitialTrafficData initialTrafficData : dataList) {
// 根据clientId查询节点名称
Map nodeMsg = epsServerRevenueConfigMapper.getNodeMsgBySn(initialTrafficData.getClientId());
// 赋值
if(nodeMsg != null){
initialTrafficData.setServiceSn(getNullableString(nodeMsg, "hardwareSn"));
initialTrafficData.setNodeName(getNullableString(nodeMsg, "resourceName"));
initialTrafficData.setRevenueMethod(getNullableString(nodeMsg, "revenueMethod"));
initialTrafficData.setBusinessId(getNullableString(nodeMsg, "businessCode"));
initialTrafficData.setBusinessName(getNullableString(nodeMsg, "businessName"));
if("2".equals(nodeMsg.get("revenueMethod") + "")
&& nodeMsg.containsKey("packageBandwidth")){
Object bandwidth = nodeMsg.get("packageBandwidth");
if (bandwidth instanceof BigDecimal) {
initialTrafficData.setPackageBandwidth((BigDecimal) bandwidth);
}
}
}
// id自增
initialTrafficData.setId(null);
batchList.add(initialTrafficData);
}
epsInitialTrafficData.setDataList(batchList);
// 流量相关数据入库
try {
epsInitialTrafficDataService.saveBatch(epsInitialTrafficData);
log.info("流量数据批量入库成功,数据量:{}", batchList.size());
// 接口名称保存
processInterfaceNames(batchList);
return R.ok("数据保存成功");
} catch (Exception e) {
log.error("流量数据入库失败,数据量:{},错误原因:{}",
batchList.size(), e.getMessage(), e);
return R.fail("数据保存失败:" + e.getMessage());
}
}
/**
* 当前在线服务器的流量相关的业务数
* @return
*/
@Override
public Integer countBusinessByTraffic() {
return epsServerRevenueConfigMapper.countBusinessByTraffic();
}
/**
* 当日业务的在线设备数量统计TOP5
* @return
*/
@Override
public List<Map> countDeviceNumTop5() {
return epsServerRevenueConfigMapper.countDeviceNumTop5();
}
private static String getNullableString(Map<String, Object> map, String key) {
Object value = map.get(key);
return value != null ? value.toString() : null;
}
private String getCompositeKey(String clientId, String interfaceName) {
return clientId + "|" + interfaceName;
}
/**
* 批量处理接口名称
*/
private void processInterfaceNames(List<EpsInitialTrafficData> trafficDataList) {
// 分类处理:新增列表 vs 更新列表
List<AllInterfaceName> namesToInsert = new ArrayList<>();
List<AllInterfaceName> namesToUpdate = new ArrayList<>();
// 用于去重的临时集合,防止同一批数据中的重复
Set<String> processedKeys = new HashSet<>();
trafficDataList.forEach(data -> {
String name = data.getName();
String ip = data.getMac();
String clientId = data.getClientId();
if (StringUtils.isBlank(name) || StringUtils.isBlank(ip) || StringUtils.isBlank(clientId)) {
return;
}
// 生成唯一键,防止同一批数据中的重复处理
String uniqueKey = name + "|" + clientId + "|" + ip;
if (processedKeys.contains(uniqueKey)) {
return;
}
processedKeys.add(uniqueKey);
// 构造新记录
AllInterfaceName newRecord = new AllInterfaceName();
newRecord.setInterfaceName(name);
newRecord.setClientId(data.getClientId());
newRecord.setResourceType("1");
newRecord.setDeviceSn(data.getServiceSn());
newRecord.setNodeName(data.getNodeName());
newRecord.setBusinessCode(data.getBusinessId());
newRecord.setBusinessName(data.getBusinessName());
newRecord.setServerIp(data.getMac());
List<AllInterfaceName> existingNames = allInterfaceNameMapper.selectByNames(newRecord);
if (!existingNames.isEmpty()) {
for (AllInterfaceName existingName : existingNames) {
if (isRecordChanged(existingName, newRecord)) {
newRecord.setId(existingName.getId());
newRecord.setUpdateTime(DateUtils.getNowDate());
// 检查是否已经存在于更新列表中
boolean alreadyInUpdateList = namesToUpdate.stream()
.anyMatch(item -> item.getId() != null && item.getId().equals(existingName.getId()));
if (!alreadyInUpdateList) {
namesToUpdate.add(newRecord);
}
}
}
} else {
newRecord.setCreateTime(DateUtils.getNowDate());
newRecord.setUpdateTime(DateUtils.getNowDate());
// 检查namesToInsert中是否已有相同记录
boolean alreadyInInsertList = namesToInsert.stream()
.anyMatch(item -> item.getInterfaceName().equals(name)
&& item.getClientId().equals(clientId)
&& item.getServerIp().equals(ip));
if (!alreadyInInsertList) {
namesToInsert.add(newRecord);
}
}
});
// 批量操作数据库
if (!namesToInsert.isEmpty()) {
try {
allInterfaceNameMapper.batchInsert(namesToInsert);
log.info("新增接口名称数量:{}", namesToInsert.size());
} catch (DuplicateKeyException e) {
// 如果批量插入出现重复,转为逐条插入(带异常处理)
log.warn("批量插入出现重复,转为逐条处理");
namesToInsert.forEach(record -> {
try {
allInterfaceNameMapper.insertAllInterfaceName(record);
} catch (DuplicateKeyException ex) {
// 重复记录转为更新
AllInterfaceName query = new AllInterfaceName();
query.setInterfaceName(record.getInterfaceName());
query.setClientId(record.getClientId());
query.setServerIp(record.getServerIp());
List<AllInterfaceName> existing = allInterfaceNameMapper.selectByNames(query);
if (!existing.isEmpty()) {
record.setId(existing.get(0).getId());
allInterfaceNameMapper.updateAllInterfaceName(record);
}
}
});
}
}
if (!namesToUpdate.isEmpty()) {
allInterfaceNameMapper.batchUpdate(namesToUpdate);
log.info("更新接口名称数量:{}", namesToUpdate.size());
}
}
// 辅助方法:检查记录是否有变化
private boolean isRecordChanged(AllInterfaceName oldRecord, AllInterfaceName newRecord) {
return !Objects.equals(oldRecord.getDeviceSn(), newRecord.getDeviceSn()) ||
!Objects.equals(oldRecord.getNodeName(), newRecord.getNodeName()) ||
!Objects.equals(oldRecord.getBusinessCode(), newRecord.getBusinessCode()) ||
!Objects.equals(oldRecord.getBusinessName(), newRecord.getBusinessName()) ||
!Objects.equals(oldRecord.getServerIp(), newRecord.getServerIp());
}
/**
* 批量删除服务器收益方式配置
*
* @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;
}
}
@@ -1,703 +0,0 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.IInitialSwitchInfoDetailsService;
import com.ruoyi.system.util.CalculateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 交换机监控信息Service业务层处理
*
* @author gyt
* @date 2025-08-26
*/
@Service
@Slf4j
public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDetailsService
{
@Autowired
private InitialSwitchInfoDetailsMapper initialSwitchInfoDetailsMapper;
@Autowired
private RmEpsTopologyManagementMapper rmEpsTopologyManagementMapper;
@Autowired
private AllInterfaceNameMapper allInterfaceNameMapper;
@Autowired
private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper;
@Autowired
private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper;
@Autowired
private EpsNodeBandwidthMapper epsNodeBandwidthMapper;
/**
* 查询交换机监控信息
*
* @param id 交换机监控信息主键
* @return 交换机监控信息
*/
@Override
public InitialSwitchInfoDetails selectInitialSwitchInfoDetailsById(Long id)
{
return initialSwitchInfoDetailsMapper.selectInitialSwitchInfoDetailsById(id);
}
/**
* 查询交换机监控信息列表
*
* @param initialSwitchInfoDetails 交换机监控信息
* @return 交换机监控信息
*/
@Override
public List<InitialSwitchInfoDetails> selectInitialSwitchInfoDetailsList(InitialSwitchInfoDetails initialSwitchInfoDetails)
{
return initialSwitchInfoDetailsMapper.selectInitialSwitchInfoDetailsList(initialSwitchInfoDetails);
}
/**
* 新增交换机监控信息
*
* @param initialSwitchInfoDetails 交换机监控信息
* @return 结果
*/
@Override
public int insertInitialSwitchInfoDetails(InitialSwitchInfoDetails initialSwitchInfoDetails)
{
initialSwitchInfoDetails.setCreateTime(DateUtils.getNowDate());
return initialSwitchInfoDetailsMapper.insertInitialSwitchInfoDetails(initialSwitchInfoDetails);
}
/**
* 修改交换机监控信息
*
* @param initialSwitchInfoDetails 交换机监控信息
* @return 结果
*/
@Override
public int updateInitialSwitchInfoDetails(InitialSwitchInfoDetails initialSwitchInfoDetails)
{
initialSwitchInfoDetails.setUpdateTime(DateUtils.getNowDate());
return initialSwitchInfoDetailsMapper.updateInitialSwitchInfoDetails(initialSwitchInfoDetails);
}
/**
* 批量删除交换机监控信息
*
* @param ids 需要删除的交换机监控信息主键
* @return 结果
*/
@Override
public int deleteInitialSwitchInfoDetailsByIds(Long[] ids)
{
return initialSwitchInfoDetailsMapper.deleteInitialSwitchInfoDetailsByIds(ids);
}
/**
* 删除交换机监控信息信息
*
* @param id 交换机监控信息主键
* @return 结果
*/
@Override
public int deleteInitialSwitchInfoDetailsById(Long id)
{
return initialSwitchInfoDetailsMapper.deleteInitialSwitchInfoDetailsById(id);
}
/**
* 保存交换机流量信息
* @param initialSwitchInfoDetails
*/
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
public R<String> autoSaveSwitchTraffic(InitialSwitchInfoDetails initialSwitchInfoDetails) {
// 查询初始流量数据
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper.getAllSwitchInfoMsg(initialSwitchInfoDetails);
List<InitialSwitchInfoDetails> batchList = new ArrayList<>();
if(!dataList.isEmpty()){
for (InitialSwitchInfoDetails details : dataList) {
// id自增
details.setId(null);
// 根据接口名称查询交换机信息
String interfaceName = details.getName();
String switchSn = details.getSwitchSn();
RmEpsTopologyManagement rmEpsTopologyManagement = new RmEpsTopologyManagement();
rmEpsTopologyManagement.setInterfaceName(interfaceName);
rmEpsTopologyManagement.setSwitchSn(switchSn);
List<RmEpsTopologyManagement> managements = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(rmEpsTopologyManagement);
// 赋值
if(!managements.isEmpty()){
for (RmEpsTopologyManagement management : managements) {
if("1".equals(management.getConnectedDeviceType())){
details.setOutSpeed(null);
}else{
details.setInSpeed(null);
}
details.setSwitchSn(management.getSwitchSn());
details.setSwitchName(management.getSwitchName());
details.setInterfaceDeviceType(management.getConnectedDeviceType());
details.setServerName(management.getServerName());
details.setServerPort(management.getServerPort());
details.setServerSn(management.getServerSn());
// 根据服务器sn查询业务
if(management.getServerSn() != null){
EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig();
epsServerRevenueConfig.setHardwareSn(management.getServerSn());
List<EpsServerRevenueConfig> businessList = epsServerRevenueConfigMapper.selectEpsServerRevenueConfigList(epsServerRevenueConfig);
if(!businessList.isEmpty()){
EpsServerRevenueConfig revenueConfig = businessList.get(0);
details.setBusinessName(revenueConfig.getBusinessName());
details.setBusinessCode(revenueConfig.getBusinessCode());
}
}else {
details.setBusinessCode(null);
details.setBusinessName(null);
}
batchList.add(details);
}
}else{
batchList.add(details);
}
}
}
initialSwitchInfoDetails.setDataList(batchList);
if(batchList.isEmpty()){
return R.fail("交换机流量数据为空");
}else{
// 流量相关数据入库
try {
initialSwitchInfoDetailsMapper.saveBatchSwitchTraffic(initialSwitchInfoDetails);
log.info("交换机流量数据批量入库成功,数据量:{}", batchList.size());
// 接口名称保存
processSwitchInterfaceNames(batchList);
return R.ok("数据保存成功");
} catch (Exception e) {
log.error("交换机流量数据入库失败,数据量:{},错误原因:{}",
batchList.size(), e.getMessage(), e);
return R.fail("数据保存失败:" + e.getMessage());
}
}
}
/**
* 批量处理接口名称
*/
private void processSwitchInterfaceNames(List<InitialSwitchInfoDetails> initialSwitchInfoDetails) {
// 分类处理:新增列表 vs 更新列表
List<AllInterfaceName> namesToInsert = new ArrayList<>();
List<AllInterfaceName> namesToUpdate = new ArrayList<>();
initialSwitchInfoDetails.forEach(data -> {
String name = data.getName();
String ip = data.getSwitchIp();
String clientId = data.getClientId();
if (StringUtils.isBlank(name) || StringUtils.isBlank(ip) || StringUtils.isBlank(clientId)) {
return;
}
AllInterfaceName record = new AllInterfaceName();
record.setInterfaceName(name);
record.setClientId(data.getClientId());
record.setResourceType("2");
record.setDeviceSn(data.getServerSn());
record.setNodeName(data.getServerName());
record.setServerPort(data.getServerPort());
record.setInterfaceDeviceType(data.getInterfaceDeviceType());
record.setSwitchName(data.getSwitchName());
record.setSwitchSn(data.getSwitchSn());
record.setSwitchIp(data.getSwitchIp());
List<AllInterfaceName> existingNames = allInterfaceNameMapper.selectByNames(record);
// 根据服务器sn查询业务
if(data.getServerSn() != null){
EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig();
epsServerRevenueConfig.setHardwareSn(data.getServerSn());
List<EpsServerRevenueConfig> businessList = epsServerRevenueConfigMapper.selectEpsServerRevenueConfigList(epsServerRevenueConfig);
if(!businessList.isEmpty()){
EpsServerRevenueConfig revenueConfig = businessList.get(0);
record.setBusinessName(revenueConfig.getBusinessName());
record.setBusinessCode(revenueConfig.getBusinessCode());
}
}else {
record.setBusinessCode(null);
record.setBusinessName(null);
}
// 判断是否需要更新
if (!existingNames.isEmpty()) {
for (AllInterfaceName existingName : existingNames) {
if(isRecordChanged(existingName,record)){
record.setId(existingName.getId()); // 保留原ID
// 检查是否已经存在于更新列表中
boolean alreadyInUpdateList = namesToUpdate.stream()
.anyMatch(item -> item.getId() != null && item.getId().equals(existingName.getId()));
if (!alreadyInUpdateList) {
namesToUpdate.add(record);
}
}
}
} else {
// 检查namesToInsert中是否已有相同记录
boolean alreadyInInsertList = namesToInsert.stream()
.anyMatch(item -> item.getInterfaceName().equals(name)
&& item.getClientId().equals(clientId)
&& item.getSwitchIp().equals(ip));
if (!alreadyInInsertList) {
namesToInsert.add(record);
}
}
});
// 批量操作数据库
if (!namesToInsert.isEmpty()) {
try {
allInterfaceNameMapper.batchInsert(namesToInsert);
log.info("新增接口名称数量:{}", namesToInsert.size());
} catch (DuplicateKeyException e) {
// 如果批量插入出现重复,转为逐条插入(带异常处理)
log.warn("批量插入出现重复,转为逐条处理");
namesToInsert.forEach(record -> {
try {
allInterfaceNameMapper.insertAllInterfaceName(record);
} catch (DuplicateKeyException ex) {
// 重复记录转为更新
AllInterfaceName query = new AllInterfaceName();
query.setInterfaceName(record.getInterfaceName());
query.setClientId(record.getClientId());
query.setServerIp(record.getServerIp());
List<AllInterfaceName> existing = allInterfaceNameMapper.selectByNames(query);
if (!existing.isEmpty()) {
record.setId(existing.get(0).getId());
allInterfaceNameMapper.updateAllInterfaceName(record);
}
}
});
}
}
if (!namesToUpdate.isEmpty()) {
allInterfaceNameMapper.batchUpdate(namesToUpdate);
log.info("更新接口名称数量:{}", namesToUpdate.size());
}
}
// 辅助方法:检查记录是否有变化
private boolean isRecordChanged(AllInterfaceName oldRecord, AllInterfaceName newRecord) {
return !Objects.equals(oldRecord.getDeviceSn(), newRecord.getDeviceSn()) ||
!Objects.equals(oldRecord.getNodeName(), newRecord.getNodeName()) ||
!Objects.equals(oldRecord.getServerPort(), newRecord.getServerPort()) ||
!Objects.equals(oldRecord.getInterfaceDeviceType(), newRecord.getInterfaceDeviceType()) ||
!Objects.equals(oldRecord.getSwitchName(), newRecord.getSwitchName()) ||
!Objects.equals(oldRecord.getBusinessCode(), newRecord.getBusinessCode()) ||
!Objects.equals(oldRecord.getBusinessName(), newRecord.getBusinessName()) ||
!Objects.equals(oldRecord.getSwitchSn(), newRecord.getSwitchSn()) ||
!Objects.equals(oldRecord.getSwitchIp(), newRecord.getSwitchIp());
}
public void calculateSwitch95BandwidthDaily(InitialSwitchInfoDetails queryParam, String dailyStartTime,
String dailyEndTime, String calculationMode) {
// 查询所有的交换机SN列表
AllInterfaceName allInterfaceName = new AllInterfaceName();
List<AllInterfaceName> switchSnList = allInterfaceNameMapper.getAllSwitchSn(allInterfaceName);
// 遍历处理每个交换机
switchSnList.forEach(interfaceName -> {
queryParam.setSwitchSn(interfaceName.getSwitchSn());
queryParam.setSwitchIp(interfaceName.getSwitchIp());
processSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
});
}
/**
* 重新计算交换机95带宽值
* @param epsNodeBandwidth 95带宽值收益详情
* @param dailyStartTime 开始时间
* @param dailyEndTime 结束时间
*/
@Override
public void recalculateSwitch95Bandwidth(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime,
String dailyEndTime, String calculationMode) {
InitialSwitchInfoDetails switchInfoDetails = new InitialSwitchInfoDetails();
switchInfoDetails.setStartTime(dailyStartTime);
switchInfoDetails.setEndTime(dailyEndTime);
switchInfoDetails.setSwitchSn(epsNodeBandwidth.getSwitchSn());
switchInfoDetails.setSwitchName(epsNodeBandwidth.getUplinkSwitch());
switchInfoDetails.setServerSn(epsNodeBandwidth.getHardwareSn());
switchInfoDetails.setInterfaceDeviceType(epsNodeBandwidth.getInterfaceLinkDeviceType());
switchInfoDetails.setName(epsNodeBandwidth.getInterfaceName());
switchInfoDetails.setBusinessCode(epsNodeBandwidth.getBusinessId());
switchInfoDetails.setBusinessName(epsNodeBandwidth.getBusinessName());
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
.selectInitialSwitchInfoDetailsList(switchInfoDetails);
if(!dataList.isEmpty()){
// 1. 提取并转换带宽值
List<BigDecimal> speedsInMbps = dataList.stream()
.map(data -> {
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
String speed = "1".equals(data.getInterfaceDeviceType())
? (data.getInSpeed() != null ? data.getInSpeed().toString() : BigDecimal.ZERO.toString())
: (data.getOutSpeed() != null ? data.getOutSpeed().toString() : BigDecimal.ZERO.toString());
// 如果 speed 是纯数字,补充单位 "B/S"Bytes/s
if (speed.matches("^\\d+(\\.\\d+)?$")) {
speed += " B/S";
}
return CalculateUtil.parseSpeedToMbps(speed, calculationMode);
})
.sorted()
.collect(Collectors.toList());
// 2. 计算95百分位
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
// 3. 保存结果
InitialSwitchInfoDetails switchInfo = dataList.get(0);
switchInfo.setResourceType("2");
switchInfo.setBandwidthType(epsNodeBandwidth.getBandwidthType());
saveSwitchBandwidthResult(switchInfo, percentile95, dailyStartTime, calculationMode);
}
}
/**
* 交换机相关数据
* @param epsNodeBandwidth
* @param dailyStartTime
* @param dailyEndTime
* @return
*/
@Override
public List<InitialSwitchInfoDetails> getRelevantSwitch(EpsNodeBandwidth epsNodeBandwidth, String dailyStartTime, String dailyEndTime) {
InitialSwitchInfoDetails switchInfoDetails = new InitialSwitchInfoDetails();
switchInfoDetails.setStartTime(dailyStartTime);
switchInfoDetails.setEndTime(dailyEndTime);
switchInfoDetails.setSwitchSn(epsNodeBandwidth.getSwitchSn());
switchInfoDetails.setSwitchName(epsNodeBandwidth.getUplinkSwitch());
switchInfoDetails.setServerSn(epsNodeBandwidth.getHardwareSn());
switchInfoDetails.setInterfaceDeviceType(epsNodeBandwidth.getInterfaceLinkDeviceType());
switchInfoDetails.setName(epsNodeBandwidth.getInterfaceName());
switchInfoDetails.setBusinessCode(epsNodeBandwidth.getBusinessId());
switchInfoDetails.setBusinessName(epsNodeBandwidth.getBusinessName());
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
.selectInitialSwitchInfoDetailsList(switchInfoDetails);
return dataList;
}
@Override
public BigDecimal sumTrafficBySwitch() {
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 结束时间
LocalDateTime endTime = now.minusSeconds(1);
// 开始时间
LocalDateTime startTime = now.minusMinutes(5);
// 定义日期时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 格式化为字符串
String dailyStartTime = startTime.format(formatter);
String dailyEndTime = endTime.format(formatter);
BigDecimal total = BigDecimal.ZERO;
InitialSwitchInfoDetails switchInfoDetails = new InitialSwitchInfoDetails();
switchInfoDetails.setStartTime(dailyStartTime);
switchInfoDetails.setEndTime(dailyEndTime);
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
.selectInitialSwitchInfoDetailsList(switchInfoDetails);
if(!dataList.isEmpty()){
for (InitialSwitchInfoDetails initialSwitchInfoDetails : dataList) {
// 交换机接收带宽流量
String speed = initialSwitchInfoDetails.getInSpeed() != null ? initialSwitchInfoDetails.getInSpeed().toString() : BigDecimal.ZERO.toString();
// 如果 speed 是纯数字,补充单位 "B/S"Bytes/s
if (speed.matches("^\\d+(\\.\\d+)?$")) {
speed += " B/S";
}
BigDecimal inSpeed = CalculateUtil.parseSpeedToMbps(speed, "1000");
total = total.add(inSpeed);
}
}
return total.setScale(0, RoundingMode.HALF_UP);
}
/**
* 处理单个交换机的带宽计算
*/
private void processSwitchBandwidth(InitialSwitchInfoDetails queryParam,
String dailyStartTime,
String dailyEndTime, String calculationMode) {
// 根据交换机sn查询连接的服务器sn
RmEpsTopologyManagement management = new RmEpsTopologyManagement();
management.setSwitchSn(queryParam.getSwitchSn());
management.setSwitchIpAddress(queryParam.getSwitchIp());
List<RmEpsTopologyManagement> serverSnList = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(management);
if(!serverSnList.isEmpty()){
for (RmEpsTopologyManagement rmEpsTopologyManagement : serverSnList) {
queryParam.setName(rmEpsTopologyManagement.getInterfaceName());
if("1".equals(rmEpsTopologyManagement.getConnectedDeviceType())){
queryParam.setServerSn(rmEpsTopologyManagement.getServerSn());
// 检查交换机连接的服务器是否有业务变更(如果有相关配置)
EpsServerRevenueConfig revenueConfig = new EpsServerRevenueConfig();
revenueConfig.setHardwareSn(rmEpsTopologyManagement.getServerSn());
List<EpsServerRevenueConfig> changedList = epsServerRevenueConfigMapper
.selectEpsServerRevenueConfigList(revenueConfig);
// 根据业务变更情况选择计算方式
if (hasTrafficMethodChanged(changedList)) {
calculateChangedSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
} else {
calculateNormalSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
}
}
if("2".equals(rmEpsTopologyManagement.getConnectedDeviceType())){
queryParam.setServerSn(null);
calculateNormalSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
}
}
}
}
/**
* 判断是否为流量型业务变更
*/
private boolean hasTrafficMethodChanged(List<EpsServerRevenueConfig> changedList) {
return !changedList.isEmpty() &&
"1".equals(changedList.get(0).getChanged()) &&
"1".equals(changedList.get(0).getRevenueMethod());
}
/**
* 计算有业务变更交换机的带宽
*/
private void calculateChangedSwitchBandwidth(InitialSwitchInfoDetails queryParam,
String dailyStartTime,
String dailyEndTime, String calculationMode) {
// 获取业务变更记录(按时间降序)
EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
changeQuery.setHardwareSn(queryParam.getServerSn());
changeQuery.setStartTime(dailyStartTime);
changeQuery.setEndTime(dailyEndTime);
List<EpsMethodChangeRecord> records = epsMethodChangeRecordMapper
.selectEpsMethodChangeRecordList(changeQuery);
if (!records.isEmpty()) {
// 确保按时间降序排列
records.sort((r1, r2) -> r2.getCreateTime().compareTo(r1.getCreateTime()));
// 计算各时间段95值
calculateSwitchTimeSegments95(queryParam, records, dailyStartTime, dailyEndTime, calculationMode);
}else {
calculateNormalSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
}
}
/**
* 计算无业务变更交换机的带宽
*/
private void calculateNormalSwitchBandwidth(InitialSwitchInfoDetails queryParam,
String dailyStartTime,
String dailyEndTime, String calculationMode) {
queryParam.setStartTime(dailyStartTime);
queryParam.setEndTime(dailyEndTime);
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
.selectInitialSwitchInfoDetailsList(queryParam);
if (!dataList.isEmpty()) {
calculateAndSaveSwitch95Bandwidth(dataList, dailyStartTime, queryParam.getDayOrMonth(), calculationMode);
}
}
/**
* 计算并保存交换机95带宽值
*/
private void calculateAndSaveSwitch95Bandwidth(List<InitialSwitchInfoDetails> dataList, String dateTime,
String dayOrMonth, String calculationMode) {
boolean eff = false;
if(!dataList.isEmpty()){
if(dataList.size()<288){
eff = true;
}
// 1. 提取并转换带宽值
List<BigDecimal> speedsInMbps = dataList.stream()
.map(data -> {
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
String speed = "1".equals(data.getInterfaceDeviceType())
? (data.getInSpeed() != null ? data.getInSpeed().toString() : BigDecimal.ZERO.toString())
: (data.getOutSpeed() != null ? data.getOutSpeed().toString() : BigDecimal.ZERO.toString());
// 如果 speed 是纯数字,补充单位 "B/S"Bytes/s
if (speed.matches("^\\d+(\\.\\d+)?$")) {
speed += " B/S";
}
return CalculateUtil.parseSpeedToMbps(speed, calculationMode);
})
.sorted()
.collect(Collectors.toList());
// 2. 计算95百分位
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
// 3. 保存结果
InitialSwitchInfoDetails switchInfo = dataList.get(0);
switchInfo.setResourceType("2");
if("1".equals(dayOrMonth)){
if(eff){
switchInfo.setBandwidthType("5");
}else{
switchInfo.setBandwidthType("1");
}
}
if("2".equals(dayOrMonth)){
if(eff){
switchInfo.setBandwidthType("6");
}else{
switchInfo.setBandwidthType("2");
}
}
saveSwitchBandwidthResult(switchInfo, percentile95, dateTime, calculationMode);
}
}
/**
* 计算交换机各时间段的95带宽值
*/
private void calculateSwitchTimeSegments95(InitialSwitchInfoDetails queryParam,
List<EpsMethodChangeRecord> records,
String dailyStartTime,
String dailyEndTime, String calculationMode) {
// 1. 处理变更时间段(从最新到最早)
String endTime = records.get(0).getCreateTime() + "";
for (int i = 1; i < records.size(); i++) {
String startTime = records.get(i).getCreateTime() + "";
calculateSwitchSegment95(queryParam, startTime, endTime, calculationMode);
endTime = startTime; // 移动时间窗口
}
// 2. 处理最早变更前的时间段(昨天00:00:00 ~ 最早变更时间)
String earliestChangeTime = records.get(records.size()-1).getCreateTime() + "";
calculateSwitchSegment95(queryParam, dailyStartTime, earliestChangeTime, calculationMode);
// 3. 处理最后变更后的时间段(最新变更时间 ~ 昨天23:59:59)
calculateSwitchSegment95(queryParam, endTime, dailyEndTime, calculationMode);
}
/**
* 计算交换机单个时间段的95带宽值
*/
private void calculateSwitchSegment95(InitialSwitchInfoDetails queryParam, String startTime, String endTime, String calculationMode) {
queryParam.setStartTime(startTime);
queryParam.setEndTime(endTime);
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
.selectInitialSwitchInfoDetailsList(queryParam);
if (!dataList.isEmpty()) {
calculateSwitch95BandwidthDaily(dataList, startTime, queryParam.getDayOrMonth(), calculationMode);
}
}
/**
* 计算交换机日95带宽值
*/
private void calculateSwitch95BandwidthDaily(List<InitialSwitchInfoDetails> dataList,
String startTime, String dayOrMonth, String calculationMode) {
// 1. 提取并转换带宽值
List<BigDecimal> speedsInMbps = dataList.stream()
.map(data -> {
// 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
String speed = "1".equals(data.getInterfaceDeviceType())
? (data.getInSpeed() != null ? data.getInSpeed().toString() : BigDecimal.ZERO.toString())
: (data.getOutSpeed() != null ? data.getOutSpeed().toString() : BigDecimal.ZERO.toString());
if (speed.matches("^\\d+(\\.\\d+)?$")) {
speed += " B/S";
}
return CalculateUtil.parseSpeedToMbps(speed, calculationMode);
})
.sorted()
.collect(Collectors.toList());
// 2. 计算95百分位
BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
BigDecimal dailyResult = percentile95.setScale(2, RoundingMode.HALF_UP);
// 3. 保存结果
InitialSwitchInfoDetails switchInfo = dataList.get(0);
switchInfo.setResourceType("2");
if(CalculateUtil.isEff(dataList)){
if("1".equals(dayOrMonth)){
switchInfo.setBandwidthType("5");
}
if("2".equals(dayOrMonth)){
switchInfo.setBandwidthType("6");
}
}else {
if("1".equals(dayOrMonth)){
switchInfo.setBandwidthType("1");
}
if("2".equals(dayOrMonth)){
switchInfo.setBandwidthType("2");
}
}
saveSwitchBandwidthResult(switchInfo, dailyResult, startTime, calculationMode);
}
/**
* 保存交换机带宽结果
*/
private void saveSwitchBandwidthResult(InitialSwitchInfoDetails data,
BigDecimal result,
String dateTime, String calculationMode) {
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
bandwidth.setBusinessName(data.getBusinessName());
bandwidth.setBusinessId(data.getBusinessCode());
bandwidth.setHardwareSn(data.getServerSn());
bandwidth.setCalculationMode(calculationMode);
bandwidth.setSwitchSn(data.getSwitchSn());
bandwidth.setNodeName(data.getServerName());
bandwidth.setUplinkSwitch(data.getSwitchName());
bandwidth.setInterfaceName(data.getName());
bandwidth.setResourceType(data.getResourceType());
bandwidth.setBandwidthType(data.getBandwidthType());
bandwidth.setInterfaceLinkDeviceType(data.getInterfaceDeviceType());
bandwidth.setCreateTime(DateUtils.parseDate(dateTime));
// 查询此条数据是否存在
List<EpsNodeBandwidth> exitsList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(bandwidth);
bandwidth.setBandwidthResult(result);
switch (data.getBandwidthType()){
case "1":
bandwidth.setBandwidth95Daily(result);
break;
case "2":
bandwidth.setBandwidth95Monthly(result);
break;
case "3":
bandwidth.setPackageBandwidthDaily(result);
break;
case "4":
bandwidth.setAvgMonthlyBandwidth95(result);
break;
case "5":
bandwidth.setEffectiveBandwidth95Daily(result);
break;
case "6":
bandwidth.setEffectiveBandwidth95Monthly(result);
break;
case "7":
bandwidth.setEffectiveAvgMonthlyBandwidth95(result);
break;
default:
throw new IllegalArgumentException("Unknown bandwidthType: " + data.getBandwidthType());
}
if(!exitsList.isEmpty()){
bandwidth.setUpdateTime(DateUtils.getNowDate());
bandwidth.setId(exitsList.get(0).getId());
epsNodeBandwidthMapper.updateEpsNodeBandwidth(bandwidth);
}else{
bandwidth.setUpdateTime(DateUtils.getNowDate());
epsNodeBandwidthMapper.insertEpsNodeBandwidth(bandwidth);
}
}
}
@@ -1,354 +0,0 @@
package com.ruoyi.system.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.enums.MsgEnum;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.RemoteRocketMqService;
import com.ruoyi.system.domain.EpsNodeBandwidth;
import com.ruoyi.system.domain.EpsServerRevenueConfig;
import com.ruoyi.system.domain.RmEpsTopologyManagement;
import com.ruoyi.system.domain.RmResourceRegistration;
import com.ruoyi.system.domain.vo.MessageVo;
import com.ruoyi.system.domain.vo.ResourceVo;
import com.ruoyi.system.mapper.EpsNodeBandwidthMapper;
import com.ruoyi.system.mapper.EpsServerRevenueConfigMapper;
import com.ruoyi.system.mapper.RmEpsTopologyManagementMapper;
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 java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 资源注册Service业务层处理
*
* @author gyt
* @date 2025-08-12
*/
@Service
public class RmResourceRegistrationServiceImpl implements IRmResourceRegistrationService
{
@Autowired
private RmResourceRegistrationMapper rmResourceRegistrationMapper;
@Autowired
private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper;
@Autowired
private RmEpsTopologyManagementMapper rmEpsTopologyManagementMapper;
@Autowired
private EpsNodeBandwidthMapper epsNodeBandwidthMapper;
@Autowired
private RemoteRocketMqService remoteRocketMqService;
/**
* 查询资源注册
*
* @param id 资源注册主键
* @return 资源注册
*/
@Override
public RmResourceRegistration selectRmResourceRegistrationById(Long id)
{
return rmResourceRegistrationMapper.selectRmResourceRegistrationById(id);
}
/**
* 查询资源注册列表
*
* @param rmResourceRegistration 资源注册
* @return 资源注册
*/
@Override
public List<RmResourceRegistration> selectRmResourceRegistrationList(RmResourceRegistration rmResourceRegistration)
{
List<RmResourceRegistration> rmResourceRegistrationList = rmResourceRegistrationMapper.selectRmResourceRegistrationList(rmResourceRegistration);
return rmResourceRegistrationList;
}
/**
* 新增资源注册
*
* @param rmResourceRegistration 资源注册
* @return 结果
*/
@Override
public int insertRmResourceRegistration(RmResourceRegistration rmResourceRegistration)
{
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);
}
/**
* 修改资源注册
*
* @param rmResourceRegistration 资源注册
* @return 结果
*/
@Override
public int updateRmResourceRegistration(RmResourceRegistration rmResourceRegistration)
{
rmResourceRegistration.setUpdateTime(DateUtils.getNowDate());
rmResourceRegistration.setUpdaterId(SecurityUtils.getUserId());
rmResourceRegistration.setUpdaterName(SecurityUtils.getUsername());
// 拿到需要修改的id
Long id = rmResourceRegistration.getId();
// 根据id查询sn信息
RmResourceRegistration resourceRegistration = rmResourceRegistrationMapper.selectRmResourceRegistrationById(id);
String hardwareSn = resourceRegistration.getHardwareSn();
String newResourceName = rmResourceRegistration.getResourceName();
// 如果资源名称有修改,同步修改其他表的资源名称
if (!resourceRegistration.getResourceName().equals(newResourceName)) {
// 公共的更新对象创建
RmEpsTopologyManagement rmEpsTopologyManagement = new RmEpsTopologyManagement();
EpsNodeBandwidth epsNodeBandwidth = new EpsNodeBandwidth();
switch (resourceRegistration.getResourceType()) {
case "1": // 服务器类型
// 更新拓扑管理配置
rmEpsTopologyManagement.setServerSn(hardwareSn);
rmEpsTopologyManagement.setServerName(newResourceName);
rmEpsTopologyManagementMapper.updateRmEpsTopologyManagementByServerSn(rmEpsTopologyManagement);
// 更新服务器收益配置表
EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig();
epsServerRevenueConfig.setHardwareSn(hardwareSn);
epsServerRevenueConfig.setNodeName(newResourceName);
epsServerRevenueConfigMapper.updateEpsServerRevenueConfigByServerSn(epsServerRevenueConfig);
// 更新95收益信息表
epsNodeBandwidth.setHardwareSn(hardwareSn);
epsNodeBandwidth.setNodeName(newResourceName);
epsNodeBandwidthMapper.updateEpsNodeBandwidthByServerSn(epsNodeBandwidth);
break;
case "2": // 交换机类型
// 更新拓扑管理配置
rmEpsTopologyManagement.setSwitchSn(hardwareSn);
rmEpsTopologyManagement.setSwitchName(newResourceName);
rmEpsTopologyManagementMapper.updateRmEpsTopologyManagementBySwitchSn(rmEpsTopologyManagement);
// 更新95收益信息表
epsNodeBandwidth.setSwitchSn(hardwareSn);
epsNodeBandwidth.setUplinkSwitch(newResourceName);
epsNodeBandwidthMapper.updateEpsNodeBandwidthBySwitchSn(epsNodeBandwidth);
break;
}
}
// 禁止修改sn序列号
rmResourceRegistration.setHardwareSn(null);
// 已注册状态修改--仅可修改资源名称,描述
if ("1".equals(rmResourceRegistration.getRegistrationStatus())){
// 拿到需要修改的资源名称
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())) {
handleServerRegistration(rmResourceRegistration);
}
// 发送消息通知
sendRegistrationMessage(rmResourceRegistration);
// 更新注册状态
return updateRegistrationStatus(rmResourceRegistration);
}
/**
* 处理服务器资源注册
*/
private void handleServerRegistration(RmResourceRegistration registration) {
EpsServerRevenueConfig config = new EpsServerRevenueConfig();
config.setHardwareSn(registration.getHardwareSn());
config.setNodeName(registration.getResourceName());
config.setCreateTime(DateUtils.getNowDate());
config.setRegistrationStatus(registration.getRegistrationStatus());
config.setServerIp(registration.getIpAddress());
EpsServerRevenueConfig existing = epsServerRevenueConfigMapper.countBySn(config.getHardwareSn());
if (existing != null) {
config.setId(existing.getId());
epsServerRevenueConfigMapper.updateEpsServerRevenueConfig(config);
} else {
epsServerRevenueConfigMapper.insertEpsServerRevenueConfig(config);
}
}
/**
* 发送注册/断开连接消息
*/
private void sendRegistrationMessage(RmResourceRegistration registration) {
String messageType = "1".equals(registration.getRegistrationStatus()) ? MsgEnum.注册.getValue() : MsgEnum.断开.getValue();
ResourceVo resourceVo = createResourceVo(registration);
MessageVo messageVo = new MessageVo();
messageVo.setClientId(registration.getHardwareSn());
messageVo.setDataType(messageType);
messageVo.setData(JSONObject.toJSONString(resourceVo));
remoteRocketMqService.sendAsyncProducerMessage(
"tongran_agent_down", "", "", JSONObject.toJSONString(messageVo), SecurityConstants.INNER);
}
/**
* 创建资源VO对象
*/
private ResourceVo createResourceVo(RmResourceRegistration registration) {
ResourceVo resourceVo = new ResourceVo();
resourceVo.setClientIp(registration.getIpAddress());
resourceVo.setClientPort(Integer.valueOf(registration.getResourcePort()));
if (!"1".equals(registration.getResourceType())) {
if("1".equals(registration.getSnmpDetect())){
Map<String, String> switchMap = new HashMap<>();
switchMap.put("community", registration.getTeamName());
switchMap.put("ip", registration.getSnmpCollectAddr());
switchMap.put("port", registration.getSnmpCollectPort());
resourceVo.setSwitchBoard(JSONObject.toJSONString(switchMap));
}
}
return resourceVo;
}
/**
* 更新注册状态
*/
private int updateRegistrationStatus(RmResourceRegistration registration) {
RmResourceRegistration updateParam = new RmResourceRegistration();
updateParam.setId(registration.getId());
updateParam.setRegistrationStatus(registration.getRegistrationStatus());
return rmResourceRegistrationMapper.updateRmResourceRegistration(updateParam);
}
/**
* 批量删除资源注册
*
* @param ids 需要删除的资源注册主键
* @return 结果
*/
@Override
public int deleteRmResourceRegistrationByIds(Long[] ids)
{
return rmResourceRegistrationMapper.deleteRmResourceRegistrationByIds(ids);
}
/**
* 删除资源注册信息
*
* @param id 资源注册主键
* @return 结果
*/
@Override
public int deleteRmResourceRegistrationById(Long id)
{
return rmResourceRegistrationMapper.deleteRmResourceRegistrationById(id);
}
@Override
public List<Map> selectAllResourceName()
{
return rmResourceRegistrationMapper.selectAllResourceName();
}
@Override
public List<Map> selectAllResourceNameByType(RmResourceRegistration resourceRegistration)
{
return rmResourceRegistrationMapper.selectAllResourceNameByType(resourceRegistration);
}
/**
* 检测到服务器离线,修改状态为离线
* @param rmResourceRegistration
* @return
*/
@Override
public R<String> updateStatusByResource(RmResourceRegistration rmResourceRegistration) {
rmResourceRegistrationMapper.updateStatusByResource(rmResourceRegistration);
return R.ok("状态修改成功");
}
/**
* 服务器在线率
* @return
*/
@Override
public AjaxResult getServerOnlineRate() {
// 查询所有符合条件的资源
RmResourceRegistration queryParam = new RmResourceRegistration();
queryParam.setResourceType("1");
List<RmResourceRegistration> resourceList = rmResourceRegistrationMapper.selectRmResourceRegistrationList(queryParam);
// 计算在线数量和总数
int totalCount = resourceList.size();
if (totalCount == 0) {
return AjaxResult.error("没有找到符合条件的资源");
}
int onlineCount = (int) resourceList.stream()
.filter(resource -> "1".equals(resource.getOnlineStatus()))
.count();
int offlineCount = (int) resourceList.stream()
.filter(resource -> "0".equals(resource.getOnlineStatus()))
.count();
// 计算在线率
BigDecimal onlineRate = BigDecimal.valueOf(onlineCount)
.divide(BigDecimal.valueOf(totalCount), 0, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
// 返回结果
return AjaxResult.success()
.put("onlineCount", onlineCount)
.put("offlineCount", offlineCount)
.put("total", totalCount)
.put("onlineRate", onlineRate);
}
/**
* 根据id查询资源注册信息
* @param ids
* @return
*/
@Override
public List<RmResourceRegistration> getRegistrationByIds(String[] ids) {
return rmResourceRegistrationMapper.getRegistrationByIds(ids);
}
}
@@ -1,10 +0,0 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}
_ _
(_) | |
_ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___
| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \
| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | |
|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_|
__/ | __/ |
|___/ |___/
@@ -1,31 +0,0 @@
# Tomcat
server:
port: 9201
# Spring
spring:
application:
# 应用名称
name: ruoyi-system
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
# 服务注册地址
# server-addr: 172.16.15.103:8848
# username: ${spring.cloud.nacos.config.username}
# password: ${spring.cloud.nacos.config.password}
config:
server-addr: 127.0.0.1:8848
# 配置中心地址
# server-addr: 172.16.15.103:8848
# username: nacos
# password: nacos
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/ruoyi-system" />
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
</root>
</configuration>
@@ -1,246 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.EpsInitialTrafficDataMapper">
<update id="createEpsTrafficTable">
CREATE TABLE IF NOT EXISTS ${tableName} (
id BIGINT(20) AUTO_INCREMENT COMMENT '唯一标识ID',
`name` VARCHAR(100) COMMENT '接口名称',
`mac` VARCHAR(50) COMMENT 'MAC地址',
`status` VARCHAR(20) COMMENT '运行状态',
`type` VARCHAR(30) COMMENT '接口类型',
ipV4 VARCHAR(20) COMMENT 'IPv4地址',
`in_dropped` DECIMAL(20,2) COMMENT '入站丢包率(%)',
`out_dropped` DECIMAL(20,2) COMMENT '出站丢包率(%)',
`in_speed` varchar(50) COMMENT '接收带宽(Mbps)',
`out_speed` varchar(50) COMMENT '发送带宽(Mbps)',
`speed` varchar(100) COMMENT '协商速度',
`duplex` varchar(100) COMMENT '工作模式',
business_id varchar(50) COMMENT '业务代码',
business_name varchar(200) COMMENT '业务名称',
service_sn varchar(64) COMMENT '服务器SN',
node_name varchar(200) COMMENT '服务器名称',
revenue_method varchar(10) COMMENT '收益方式(1.流量,2包端)',
package_bandwidth DECIMAL(10,2) COMMENT '包端带宽值',
create_time DATETIME COMMENT '创建时间',
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
create_by VARCHAR(50) COMMENT '创建人',
update_by VARCHAR(50) COMMENT '修改人',
client_id VARCHAR(255) COMMENT '设备唯一标识',
PRIMARY KEY (id),
UNIQUE KEY uk_client_mac_name_time (client_id, mac, name, create_time),
INDEX idx_name_time (`name`,create_time),
INDEX idx_revenue_method (revenue_method),
INDEX idx_service_sn (service_sn)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='EPS设备流量初始数据表';
</update>
<update id="createEpsInitialTrafficTable">
CREATE TABLE IF NOT EXISTS ${tableName} (
id BIGINT(20) AUTO_INCREMENT COMMENT '唯一标识ID',
`name` VARCHAR(100) COMMENT '接口名称',
`mac` VARCHAR(20) COMMENT 'MAC地址',
`status` VARCHAR(20) COMMENT '运行状态',
`type` VARCHAR(30) COMMENT '接口类型',
ipV4 VARCHAR(20) COMMENT 'IPv4地址',
`in_dropped` DECIMAL(20,2) COMMENT '入站丢包率(%)',
`out_dropped` DECIMAL(20,2) COMMENT '出站丢包率(%)',
`in_speed` VARCHAR(50) COMMENT '接收带宽(Mbps)',
`out_speed` VARCHAR(50) COMMENT '发送带宽(Mbps)',
`speed` varchar(100) COMMENT '协商速度',
`duplex` varchar(100) COMMENT '工作模式',
create_time DATETIME COMMENT '创建时间',
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
create_by VARCHAR(50) COMMENT '创建人',
update_by VARCHAR(50) COMMENT '修改人',
client_id VARCHAR(255) COMMENT '设备唯一标识',
PRIMARY KEY (id),
UNIQUE KEY uk_client_mac_name_time (client_id, mac, name, create_time),
INDEX idx_name_time (`name`,create_time)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='初始带宽流量表';
</update>
<!-- 单条插入语句 -->
<insert id="insert">
INSERT INTO ${tableName} (
`name`,
`mac`,
`status`,
`type`,
ipV4,
`in_dropped`,
`out_dropped`,
`in_speed`,
`out_speed`,
`speed`,
`duplex`,
business_id,
business_name,
service_sn,
node_name,
revenue_method,
package_bandwidth,
create_by,
update_by,
client_id
) VALUES (
#{name},
#{mac},
#{status},
#{type},
#{ipV4},
#{inDropped},
#{outDropped},
#{inSpeed},
#{outSpeed},
#{speed},
#{duplex},
#{businessId},
#{businessName},
#{serviceSn},
#{nodeName},
#{revenueMethod},
#{packageBandwidth},
#{createBy},
#{updateBy},
#{clientId}
)
</insert>
<!-- 批量插入语句 -->
<insert id="batchInsert">
INSERT IGNORE INTO ${tableName} (
id,
`name`,
`mac`,
`status`,
`type`,
ipV4,
`in_dropped`,
`out_dropped`,
`in_speed`,
`out_speed`,
`speed`,
`duplex`,
business_id,
business_name,
service_sn,
node_name,
revenue_method,
package_bandwidth,
create_time,
update_time,
create_by,
update_by,
client_id
) VALUES
<foreach collection="dataList" item="data" separator=",">
(
#{data.id,jdbcType=BIGINT},
#{data.name,jdbcType=VARCHAR},
#{data.mac,jdbcType=VARCHAR},
#{data.status,jdbcType=VARCHAR},
#{data.type,jdbcType=VARCHAR},
#{data.ipV4,jdbcType=VARCHAR},
#{data.inDropped,jdbcType=DECIMAL},
#{data.outDropped,jdbcType=DECIMAL},
#{data.inSpeed,jdbcType=VARCHAR},
#{data.outSpeed,jdbcType=VARCHAR},
#{data.speed,jdbcType=VARCHAR},
#{data.duplex,jdbcType=VARCHAR},
#{data.businessId,jdbcType=VARCHAR},
#{data.businessName,jdbcType=VARCHAR},
#{data.serviceSn,jdbcType=VARCHAR},
#{data.nodeName,jdbcType=VARCHAR},
#{data.revenueMethod,jdbcType=VARCHAR},
#{data.packageBandwidth,jdbcType=DECIMAL},
#{data.createTime,jdbcType=TIMESTAMP},
#{data.updateTime,jdbcType=TIMESTAMP},
#{data.createBy,jdbcType=VARCHAR},
#{data.updateBy,jdbcType=VARCHAR},
#{data.clientId,jdbcType=VARCHAR}
)
</foreach>
</insert>
<!-- 条件查询 -->
<select id="selectByCondition" resultType="EpsInitialTrafficData">
SELECT
id,
`name` AS name,
`mac` AS mac,
`status` AS status,
`type` AS type,
`ipV4` AS ipV4,
`in_dropped` AS inDropped,
`out_dropped` AS outDropped,
`in_speed` AS inSpeed,
`out_speed` AS outSpeed,
`speed` AS speed,
`duplex` AS duplex,
business_id AS businessId,
business_name AS businessName,
service_sn AS serviceSn,
node_name AS nodeName,
revenue_method AS revenueMethod,
package_bandwidth AS packageBandwidth,
create_time AS createTime,
update_time AS updateTime,
create_by AS createBy,
update_by AS updateBy,
client_id AS clientId
FROM ${tableName}
<where>
<if test="serviceSn != '' and serviceSn != null">
and service_sn = #{serviceSn}
</if>
<if test="businessId != '' and businessId != null">
and business_id = #{businessId}
</if>
<if test="startTime != null">
and create_time &gt;= #{startTime}
</if>
<if test="endTime != null">
and create_time &lt;= #{endTime}
</if>
<if test="revenueMethod != null">
and revenue_method = #{revenueMethod}
</if>
</where>
ORDER BY create_time desc
</select>
<!-- 条件查询 -->
<select id="getAllTraficMsg" resultType="EpsInitialTrafficData">
SELECT
id,
`name` AS name,
`mac` AS mac,
`status` AS status,
`type` AS type,
`ipV4` AS ipV4,
`in_dropped` AS inDropped,
`out_dropped` AS outDropped,
`in_speed` AS inSpeed,
`out_speed` AS outSpeed,
`speed` AS speed,
`duplex` AS duplex,
create_time AS createTime,
update_time AS updateTime,
create_by AS createBy,
update_by AS updateBy,
client_id AS clientId
FROM ${tableName}
<where>
<if test="startTime != null">
and create_time &gt;= #{startTime}
</if>
<if test="endTime != null">
and create_time &lt;= #{endTime}
</if>
</where>
ORDER BY create_time desc
</select>
</mapper>
@@ -1,294 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.InitialSwitchInfoDetailsMapper">
<resultMap type="InitialSwitchInfoDetails" id="InitialSwitchInfoDetailsResult">
<result property="id" column="id" />
<result property="clientId" column="client_id" />
<result property="name" column="name" />
<result property="inBytes" column="in_bytes" />
<result property="outBytes" column="out_bytes" />
<result property="status" column="status" />
<result property="type" column="type" />
<result property="inSpeed" column="in_speed" />
<result property="outSpeed" column="out_speed" />
<result property="switchIp" column="switch_ip" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="switchName" column="switch_name" />
<result property="interfaceDeviceType" column="interface_device_type" />
<result property="serverName" column="server_name" />
<result property="serverPort" column="server_port" />
<result property="serverSn" column="server_sn" />
<result property="switchSn" column="switch_sn" />
<result property="businessCode" column="business_code" />
<result property="businessName" column="business_name" />
<result property="ifSpeed" column="if_speed" />
<result property="ifInDiscards" column="if_in_discards" />
<result property="ifOutDiscards" column="if_out_discards" />
<result property="ifInErrors" column="if_in_errors" />
<result property="ifOutErrors" column="if_out_errors" />
<result property="ifIndex" column="if_index" />
</resultMap>
<sql id="selectInitialSwitchInfoDetailsVo">
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, switch_ip, create_by, update_by, create_time, update_time, switch_name, interface_device_type, server_name, server_port, server_sn, switch_sn, business_code, business_name, if_speed, if_in_discards, if_out_discards, if_in_errors, if_out_errors, if_index from initial_switch_info_details
</sql>
<select id="selectInitialSwitchInfoDetailsList" parameterType="InitialSwitchInfoDetails" resultMap="InitialSwitchInfoDetailsResult">
<include refid="selectInitialSwitchInfoDetailsVo"/>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="name != null and name != ''"> and name = #{name}</if>
<if test="inBytes != null "> and in_bytes = #{inBytes}</if>
<if test="outBytes != null "> and out_bytes = #{outBytes}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="inSpeed != null "> and in_speed = #{inSpeed}</if>
<if test="outSpeed != null "> and out_speed = #{outSpeed}</if>
<if test="switchIp != null and switchIp != ''"> and switch_ip = #{switchIp}</if>
<if test="switchName != null and switchName != ''"> and switch_name like concat('%', #{switchName}, '%')</if>
<if test="interfaceDeviceType != null and interfaceDeviceType != ''"> and interface_device_type = #{interfaceDeviceType}</if>
<if test="serverName != null and serverName != ''"> and server_name like concat('%', #{serverName}, '%')</if>
<if test="serverPort != null and serverPort != ''"> and server_port = #{serverPort}</if>
<if test="serverSn != null and serverSn != ''"> and server_sn = #{serverSn}</if>
<if test="switchSn != null and switchSn != ''"> and switch_sn = #{switchSn}</if>
<if test="businessCode != null and businessCode != ''"> and business_code = #{businessCode}</if>
<if test="businessName != null and businessName != ''"> and business_name like concat('%', #{businessName}, '%')</if>
<if test="startTime != null">
and create_time &gt;= #{startTime}
</if>
<if test="endTime != null">
and create_time &lt;= #{endTime}
</if>
</where>
order by create_time desc
</select>
<select id="selectInitialSwitchInfoDetailsById" parameterType="Long" resultMap="InitialSwitchInfoDetailsResult">
<include refid="selectInitialSwitchInfoDetailsVo"/>
where id = #{id}
</select>
<insert id="insertInitialSwitchInfoDetails" parameterType="InitialSwitchInfoDetails" useGeneratedKeys="true" keyProperty="id">
insert into initial_switch_info_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">client_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="inBytes != null">in_bytes,</if>
<if test="outBytes != null">out_bytes,</if>
<if test="status != null">status,</if>
<if test="type != null">type,</if>
<if test="inSpeed != null">in_speed,</if>
<if test="outSpeed != null">out_speed,</if>
<if test="switchIp != null">switch_ip,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="switchName != null">switch_name,</if>
<if test="interfaceDeviceType != null">interface_device_type,</if>
<if test="serverName != null">server_name,</if>
<if test="serverPort != null">server_port,</if>
<if test="serverSn != null">server_sn,</if>
<if test="switchSn != null">switch_sn,</if>
<if test="businessCode != null">business_code,</if>
<if test="businessName != null">business_name,</if>
<if test="ifSpeed != null">if_speed,</if>
<if test="ifInDiscards != null">if_in_discards,</if>
<if test="ifOutDiscards != null">if_out_discards,</if>
<if test="ifInErrors != null">if_in_errors,</if>
<if test="ifOutErrors != null">if_out_errors,</if>
<if test="ifIndex != null and ifIndex != ''">if_index,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="clientId != null and clientId != ''">#{clientId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="inBytes != null">#{inBytes},</if>
<if test="outBytes != null">#{outBytes},</if>
<if test="status != null">#{status},</if>
<if test="type != null">#{type},</if>
<if test="inSpeed != null">#{inSpeed},</if>
<if test="outSpeed != null">#{outSpeed},</if>
<if test="switchIp != null">#{switchIp},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="switchName != null">#{switchName},</if>
<if test="interfaceDeviceType != null">#{interfaceDeviceType},</if>
<if test="serverName != null">#{serverName},</if>
<if test="serverPort != null">#{serverPort},</if>
<if test="serverSn != null">#{serverSn},</if>
<if test="switchSn != null">#{switchSn},</if>
<if test="businessCode != null">#{businessCode},</if>
<if test="businessName != null">#{businessName},</if>
<if test="ifSpeed != null">#{ifSpeed},</if>
<if test="ifInDiscards != null">#{ifInDiscards},</if>
<if test="ifOutDiscards != null">#{ifOutDiscards},</if>
<if test="ifInErrors != null">#{ifInErrors},</if>
<if test="ifOutErrors != null">#{ifOutErrors},</if>
<if test="ifIndex != null and ifIndex != ''">#{ifIndex},</if>
</trim>
</insert>
<update id="updateInitialSwitchInfoDetails" parameterType="InitialSwitchInfoDetails">
update initial_switch_info_details
<trim prefix="SET" suffixOverrides=",">
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="inBytes != null">in_bytes = #{inBytes},</if>
<if test="outBytes != null">out_bytes = #{outBytes},</if>
<if test="status != null">status = #{status},</if>
<if test="type != null">type = #{type},</if>
<if test="inSpeed != null">in_speed = #{inSpeed},</if>
<if test="outSpeed != null">out_speed = #{outSpeed},</if>
<if test="switchIp != null">switch_ip = #{switchIp},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="switchName != null">switch_name = #{switchName},</if>
<if test="interfaceDeviceType != null">interface_device_type = #{interfaceDeviceType},</if>
<if test="serverName != null">server_name = #{serverName},</if>
<if test="serverPort != null">server_port = #{serverPort},</if>
<if test="serverSn != null">server_sn = #{serverSn},</if>
<if test="switchSn != null">switch_sn = #{switchSn},</if>
<if test="businessCode != null">business_code = #{businessCode},</if>
<if test="businessName != null">business_name = #{businessName},</if>
<if test="ifSpeed != null">if_speed = #{ifSpeed},</if>
<if test="ifInDiscards != null">if_in_discards = #{ifInDiscards},</if>
<if test="ifOutDiscards != null">if_out_discards = #{ifOutDiscards},</if>
<if test="ifInErrors != null">if_in_errors = #{ifInErrors},</if>
<if test="ifOutErrors != null">if_out_errors = #{ifOutErrors},</if>
<if test="ifIndex != null and ifIndex != ''">if_index = #{ifIndex},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteInitialSwitchInfoDetailsById" parameterType="Long">
delete from initial_switch_info_details where id = #{id}
</delete>
<delete id="deleteInitialSwitchInfoDetailsByIds" parameterType="String">
delete from initial_switch_info_details where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 查询交换机信息-->
<select id="getAllSwitchInfoMsg" parameterType="InitialSwitchInfoDetails" resultType="InitialSwitchInfoDetails">
SELECT
id,
client_id AS clientId,
`name`,
in_bytes AS inBytes,
out_bytes AS outBytes,
status,
`type`,
in_speed AS inSpeed,
out_speed AS outSpeed,
switch_ip AS switchIp,
if_index AS ifIndex,
if_speed AS ifSpeed,
if_in_discards AS ifInDiscards,
if_out_discards AS ifOutDiscards,
if_in_errors AS ifInErrors,
if_out_errors AS ifOutErrors,
create_by AS createBy,
update_by AS updateBy,
create_time AS createTime,
update_time AS updateTime
FROM
initial_switch_info
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="startTime != null and startTime != ''"> and create_time &gt;= #{startTime}</if>
<if test="endTime != null and endTime != ''"> and create_time &lt;= #{endTime}</if>
</where>
ORDER BY create_time DESC
</select>
<insert id="saveBatchSwitchTraffic" parameterType="InitialSwitchInfoDetails">
INSERT IGNORE INTO initial_switch_info_details
(
client_id,
`name`,
in_bytes,
out_bytes,
status,
`type`,
in_speed,
out_speed,
switch_ip,
if_index,
if_speed,
if_in_discards,
if_out_discards,
if_in_errors,
if_out_errors,
switch_name,
interface_device_type,
`server_name`,
server_port,
server_sn,
switch_sn,
business_code,
business_name,
create_by,
update_by,
create_time,
update_time
)
VALUES
<foreach collection="dataList" item="item" separator=",">
(
#{item.clientId},
#{item.name},
#{item.inBytes},
#{item.outBytes},
#{item.status},
#{item.type},
#{item.inSpeed},
#{item.outSpeed},
#{item.switchIp},
#{item.ifIndex},
#{item.ifSpeed},
#{item.ifInDiscards},
#{item.ifOutDiscards},
#{item.ifInErrors},
#{item.ifOutErrors},
#{item.switchName},
#{item.interfaceDeviceType},
#{item.serverName},
#{item.serverPort},
#{item.serverSn},
#{item.switchSn},
#{item.businessCode},
#{item.businessName},
#{item.createBy},
#{item.updateBy},
<choose>
<when test="item.createTime != null">
#{item.createTime}
</when>
<otherwise>
NOW()
</otherwise>
</choose>,
<choose>
<when test="item.updateTime != null">
#{item.updateTime}
</when>
<otherwise>
NOW()
</otherwise>
</choose>
)
</foreach>
</insert>
</mapper>
@@ -1,292 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.RmResourceRegistrationMapper">
<resultMap type="RmResourceRegistration" id="RmResourceRegistrationResult">
<result property="id" column="id" />
<result property="hardwareSn" column="hardware_sn" />
<result property="resourceType" column="resource_type" />
<result property="resourceName" column="resource_name" />
<result property="ipAddress" column="ip_address" />
<result property="resourcePort" column="resource_port" />
<result property="otherPortName" column="other_port_name" />
<result property="agentVersion" column="agent_version" />
<result property="protocol" column="protocol" />
<result property="resourceVersion" column="resource_version" />
<result property="rwPermission" column="rw_permission" />
<result property="snmpDetect" column="snmp_detect" />
<result property="teamName" column="team_name" />
<result property="snmpCollectAddr" column="snmp_collect_addr" />
<result property="snmpCollectPort" column="snmp_collect_port" />
<result property="securityLevel" column="security_level" />
<result property="encryption" column="encryption" />
<result property="resourceUserName" column="resource_user_name" />
<result property="resourcePwd" column="resource_pwd" />
<result property="registrationStatus" column="registration_status" />
<result property="onlineStatus" column="online_status" />
<result property="switchOnlineStatus" column="switch_online_status" />
<result property="description" column="description" />
<result property="customerId" column="customer_id" />
<result property="customerName" column="customer_name" />
<result property="serviceNumber" column="service_number" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="creatorId" column="creator_id" />
<result property="creatorName" column="creator_name" />
<result property="updaterId" column="updater_id" />
<result property="updaterName" column="updater_name" />
</resultMap>
<sql id="selectRmResourceRegistrationVo">
select id, hardware_sn, resource_type, resource_name, ip_address, resource_port, other_port_name, agent_version, protocol, resource_version, rw_permission, snmp_detect, team_name, snmp_collect_addr, snmp_collect_port, security_level, encryption, resource_user_name, resource_pwd, registration_status, online_status, switch_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
</sql>
<select id="selectRmResourceRegistrationList" parameterType="RmResourceRegistration" resultMap="RmResourceRegistrationResult">
<include refid="selectRmResourceRegistrationVo"/>
<where>
<if test="hardwareSn != null and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
<if test="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
<if test="resourceName != null and resourceName != ''"> and resource_name like concat('%', #{resourceName}, '%')</if>
<if test="ipAddress != null and ipAddress != ''"> and ip_address = #{ipAddress}</if>
<if test="resourcePort != null and resourcePort != ''"> and resource_port = #{resourcePort}</if>
<if test="otherPortName != null and otherPortName != ''"> and other_port_name like concat('%', #{otherPortName}, '%')</if>
<if test="agentVersion != null and agentVersion != ''"> and agent_version = #{agentVersion}</if>
<if test="protocol != null and protocol != ''"> and protocol = #{protocol}</if>
<if test="resourceVersion != null and resourceVersion != ''"> and resource_version = #{resourceVersion}</if>
<if test="rwPermission != null and rwPermission != ''"> and rw_permission = #{rwPermission}</if>
<if test="snmpDetect != null and snmpDetect != ''"> and snmp_detect = #{snmpDetect}</if>
<if test="teamName != null and teamName != ''"> and team_name like concat('%', #{teamName}, '%')</if>
<if test="snmpCollectAddr != null and snmpCollectAddr != ''"> and snmp_collect_addr = #{snmpCollectAddr}</if>
<if test="snmpCollectPort != null "> and snmp_collect_port = #{snmpCollectPort}</if>
<if test="securityLevel != null and securityLevel != ''"> and security_level = #{securityLevel}</if>
<if test="encryption != null and encryption != ''"> and encryption = #{encryption}</if>
<if test="resourceUserName != null and resourceUserName != ''"> and resource_user_name like concat('%', #{resourceUserName}, '%')</if>
<if test="resourcePwd != null and resourcePwd != ''"> and resource_pwd = #{resourcePwd}</if>
<if test="registrationStatus != null and registrationStatus != ''"> and registration_status = #{registrationStatus}</if>
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
<if test="switchOnlineStatus != null and switchOnlineStatus != ''"> and switch_online_status = #{switchOnlineStatus}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="customerId != null "> and customer_id = #{customerId}</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="serviceNumber != null and serviceNumber != ''"> and service_number = #{serviceNumber}</if>
<if test="creatorId != null "> and creator_id = #{creatorId}</if>
<if test="creatorName != null and creatorName != ''"> and creator_name like concat('%', #{creatorName}, '%')</if>
<if test="updaterId != null "> and updater_id = #{updaterId}</if>
<if test="updaterName != null and updaterName != ''"> and updater_name like concat('%', #{updaterName}, '%')</if>
<if test="queryName != null and queryName != ''"> and (hardware_sn = #{queryName} or resource_name like concat('%', #{queryName}, '%')) </if>
</where>
order by create_time desc
</select>
<select id="selectRmResourceRegistrationById" parameterType="Long" resultMap="RmResourceRegistrationResult">
<include refid="selectRmResourceRegistrationVo"/>
where id = #{id}
</select>
<insert id="insertRmResourceRegistration" parameterType="RmResourceRegistration" useGeneratedKeys="true" keyProperty="id">
insert into rm_resource_registration
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="hardwareSn != null">hardware_sn,</if>
<if test="resourceType != null">resource_type,</if>
<if test="resourceName != null">resource_name,</if>
<if test="ipAddress != null">ip_address,</if>
<if test="resourcePort != null">resource_port,</if>
<if test="otherPortName != null">other_port_name,</if>
<if test="agentVersion != null">agent_version,</if>
<if test="protocol != null">protocol,</if>
<if test="resourceVersion != null">resource_version,</if>
<if test="rwPermission != null">rw_permission,</if>
<if test="snmpDetect != null">snmp_detect,</if>
<if test="teamName != null">team_name,</if>
<if test="snmpCollectAddr != null">snmp_collect_addr,</if>
<if test="snmpCollectPort != null">snmp_collect_port,</if>
<if test="securityLevel != null">security_level,</if>
<if test="encryption != null">encryption,</if>
<if test="resourceUserName != null">resource_user_name,</if>
<if test="resourcePwd != null">resource_pwd,</if>
<if test="registrationStatus != null">registration_status,</if>
<if test="onlineStatus != null">online_status,</if>
<if test="switchOnlineStatus != null">switch_online_status,</if>
<if test="description != null">description,</if>
<if test="customerId != null">customer_id,</if>
<if test="customerName != null">customer_name,</if>
<if test="serviceNumber != null">service_number,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="creatorId != null">creator_id,</if>
<if test="creatorName != null">creator_name,</if>
<if test="updaterId != null">updater_id,</if>
<if test="updaterName != null">updater_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="hardwareSn != null">#{hardwareSn},</if>
<if test="resourceType != null">#{resourceType},</if>
<if test="resourceName != null">#{resourceName},</if>
<if test="ipAddress != null">#{ipAddress},</if>
<if test="resourcePort != null">#{resourcePort},</if>
<if test="otherPortName != null">#{otherPortName},</if>
<if test="agentVersion != null">#{agentVersion},</if>
<if test="protocol != null">#{protocol},</if>
<if test="resourceVersion != null">#{resourceVersion},</if>
<if test="rwPermission != null">#{rwPermission},</if>
<if test="snmpDetect != null">#{snmpDetect},</if>
<if test="teamName != null">#{teamName},</if>
<if test="snmpCollectAddr != null">#{snmpCollectAddr},</if>
<if test="snmpCollectPort != null">#{snmpCollectPort},</if>
<if test="securityLevel != null">#{securityLevel},</if>
<if test="encryption != null">#{encryption},</if>
<if test="resourceUserName != null">#{resourceUserName},</if>
<if test="resourcePwd != null">#{resourcePwd},</if>
<if test="registrationStatus != null">#{registrationStatus},</if>
<if test="onlineStatus != null">#{onlineStatus},</if>
<if test="switchOnlineStatus != null">#{switchOnlineStatus},</if>
<if test="description != null">#{description},</if>
<if test="customerId != null">#{customerId},</if>
<if test="customerName != null">#{customerName},</if>
<if test="serviceNumber != null">#{serviceNumber},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="creatorId != null">#{creatorId},</if>
<if test="creatorName != null">#{creatorName},</if>
<if test="updaterId != null">#{updaterId},</if>
<if test="updaterName != null">#{updaterName},</if>
</trim>
</insert>
<update id="updateRmResourceRegistration" parameterType="RmResourceRegistration">
update rm_resource_registration
<trim prefix="SET" suffixOverrides=",">
<if test="hardwareSn != null">hardware_sn = #{hardwareSn},</if>
<if test="resourceType != null">resource_type = #{resourceType},</if>
<if test="resourceName != null">resource_name = #{resourceName},</if>
<if test="ipAddress != null">ip_address = #{ipAddress},</if>
<if test="resourcePort != null">resource_port = #{resourcePort},</if>
<if test="otherPortName != null">other_port_name = #{otherPortName},</if>
<if test="agentVersion != null">agent_version = #{agentVersion},</if>
<if test="protocol != null">protocol = #{protocol},</if>
<if test="resourceVersion != null">resource_version = #{resourceVersion},</if>
<if test="rwPermission != null">rw_permission = #{rwPermission},</if>
<if test="snmpDetect != null">snmp_detect = #{snmpDetect},</if>
<if test="teamName != null">team_name = #{teamName},</if>
<if test="snmpCollectAddr != null">snmp_collect_addr = #{snmpCollectAddr},</if>
<if test="snmpCollectPort != null">snmp_collect_port = #{snmpCollectPort},</if>
<if test="securityLevel != null">security_level = #{securityLevel},</if>
<if test="encryption != null">encryption = #{encryption},</if>
<if test="resourceUserName != null">resource_user_name = #{resourceUserName},</if>
<if test="resourcePwd != null">resource_pwd = #{resourcePwd},</if>
<if test="registrationStatus != null">registration_status = #{registrationStatus},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="switchOnlineStatus != null">switch_online_status = #{switchOnlineStatus},</if>
<if test="description != null">description = #{description},</if>
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="customerName != null">customer_name = #{customerName},</if>
<if test="serviceNumber != null">service_number = #{serviceNumber},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="creatorId != null">creator_id = #{creatorId},</if>
<if test="creatorName != null">creator_name = #{creatorName},</if>
<if test="updaterId != null">updater_id = #{updaterId},</if>
<if test="updaterName != null">updater_name = #{updaterName},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteRmResourceRegistrationById" parameterType="Long">
delete from rm_resource_registration where id = #{id}
</delete>
<delete id="deleteRmResourceRegistrationByIds" parameterType="String">
delete from rm_resource_registration where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- 查询所有资源名称(包含设备使用)-->
<select id="selectAllResourceName" resultType="java.util.Map">
select id id,resource_name resourceName from rm_resource_registration
<where>
and registration_status = 1
</where>
group by id
</select>
<!-- 查询所有资源名称-->
<select id="selectAllResourceNameByType" parameterType="RmResourceRegistration" resultType="java.util.Map">
select resource_name resourceName,ip_address ipAddress,hardware_sn hardwareSn from rm_resource_registration
<where>
and registration_status = 1
<if test="hardwareSn != null and hardwareSn != ''"> and hardware_sn = #{hardwareSn}</if>
<if test="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
<if test="resourceName != null and resourceName != ''"> and resource_name like concat('%', #{resourceName}, '%')</if>
<if test="ipAddress != null and ipAddress != ''"> and ip_address = #{ipAddress}</if>
<if test="resourcePort != null and resourcePort != ''"> and resource_port = #{resourcePort}</if>
<if test="otherPortName != null and otherPortName != ''"> and other_port_name = #{otherPortName}</if>
<if test="protocol != null and protocol != ''"> and protocol = #{protocol}</if>
<if test="resourceVersion != null and resourceVersion != ''"> and resource_version = #{resourceVersion}</if>
<if test="rwPermission != null and rwPermission != ''"> and rw_permission = #{rwPermission}</if>
<if test="securityLevel != null and securityLevel != ''"> and security_level = #{securityLevel}</if>
<if test="encryption != null and encryption != ''"> and encryption = #{encryption}</if>
<if test="resourceUserName != null and resourceUserName != ''"> and resource_user_name = #{resourceUserName}</if>
<if test="resourcePwd != null and resourcePwd != ''"> and resource_pwd = #{resourcePwd}</if>
<if test="registrationStatus != null and registrationStatus != ''"> and registration_status = #{registrationStatus}</if>
<if test="onlineStatus != null and onlineStatus != ''"> and online_status = #{onlineStatus}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="customerId != null "> and customer_id = #{customerId}</if>
<if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
<if test="serviceNumber != null and serviceNumber != ''"> and service_number = #{serviceNumber}</if>
<if test="creatorId != null "> and creator_id = #{creatorId}</if>
<if test="creatorName != null and creatorName != ''"> and creator_name like concat('%', #{creatorName}, '%')</if>
<if test="updaterId != null "> and updater_id = #{updaterId}</if>
<if test="updaterName != null and updaterName != ''"> and updater_name like concat('%', #{updaterName}, '%')</if>
</where>
group by resource_name
</select>
<select id="countBySn" parameterType="String">
select count(1) from rm_resource_registration
where hardware_sn = #{hardwareSn}
</select>
<update id="updateStatusByResource" parameterType="RmResourceRegistration">
update rm_resource_registration
<trim prefix="SET" suffixOverrides=",">
<if test="resourceType != null">resource_type = #{resourceType},</if>
<if test="resourceName != null">resource_name = #{resourceName},</if>
<if test="ipAddress != null">ip_address = #{ipAddress},</if>
<if test="resourcePort != null">resource_port = #{resourcePort},</if>
<if test="otherPortName != null">other_port_name = #{otherPortName},</if>
<if test="agentVersion != null">agent_version = #{agentVersion},</if>
<if test="protocol != null">protocol = #{protocol},</if>
<if test="resourceVersion != null">resource_version = #{resourceVersion},</if>
<if test="rwPermission != null">rw_permission = #{rwPermission},</if>
<if test="snmpDetect != null">snmp_detect = #{snmpDetect},</if>
<if test="teamName != null">team_name = #{teamName},</if>
<if test="snmpCollectAddr != null">snmp_collect_addr = #{snmpCollectAddr},</if>
<if test="snmpCollectPort != null">snmp_collect_port = #{snmpCollectPort},</if>
<if test="securityLevel != null">security_level = #{securityLevel},</if>
<if test="encryption != null">encryption = #{encryption},</if>
<if test="resourceUserName != null">resource_user_name = #{resourceUserName},</if>
<if test="resourcePwd != null">resource_pwd = #{resourcePwd},</if>
<if test="registrationStatus != null">registration_status = #{registrationStatus},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="switchOnlineStatus != null">switch_online_status = #{switchOnlineStatus},</if>
<if test="description != null">description = #{description},</if>
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="customerName != null">customer_name = #{customerName},</if>
<if test="serviceNumber != null">service_number = #{serviceNumber},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="creatorId != null">creator_id = #{creatorId},</if>
<if test="creatorName != null">creator_name = #{creatorName},</if>
<if test="updaterId != null">updater_id = #{updaterId},</if>
<if test="updaterName != null">updater_name = #{updaterName},</if>
</trim>
where hardware_sn = #{hardwareSn}
</update>
<select id="getRegistrationByIds" parameterType="String" resultMap="RmResourceRegistrationResult">
<include refid="selectRmResourceRegistrationVo"/>
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>
@@ -1,89 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysNoticeMapper">
<resultMap type="SysNotice" id="SysNoticeResult">
<result property="noticeId" column="notice_id" />
<result property="noticeTitle" column="notice_title" />
<result property="noticeType" column="notice_type" />
<result property="noticeContent" column="notice_content" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectNoticeVo">
select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark
from sys_notice
</sql>
<select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeResult">
<include refid="selectNoticeVo"/>
where notice_id = #{noticeId}
</select>
<select id="selectNoticeList" parameterType="SysNotice" resultMap="SysNoticeResult">
<include refid="selectNoticeVo"/>
<where>
<if test="noticeTitle != null and noticeTitle != ''">
AND notice_title like concat('%', #{noticeTitle}, '%')
</if>
<if test="noticeType != null and noticeType != ''">
AND notice_type = #{noticeType}
</if>
<if test="createBy != null and createBy != ''">
AND create_by like concat('%', #{createBy}, '%')
</if>
</where>
</select>
<insert id="insertNotice" parameterType="SysNotice">
insert into sys_notice (
<if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
<if test="noticeType != null and noticeType != '' ">notice_type, </if>
<if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
<if test="status != null and status != '' ">status, </if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle}, </if>
<if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
<if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
<if test="status != null and status != ''">#{status}, </if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateNotice" parameterType="SysNotice">
update sys_notice
<set>
<if test="noticeTitle != null and noticeTitle != ''">notice_title = #{noticeTitle}, </if>
<if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if>
<if test="noticeContent != null">notice_content = #{noticeContent}, </if>
<if test="status != null and status != ''">status = #{status}, </if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where notice_id = #{noticeId}
</update>
<delete id="deleteNoticeById" parameterType="Long">
delete from sys_notice where notice_id = #{noticeId}
</delete>
<delete id="deleteNoticeByIds" parameterType="Long">
delete from sys_notice where notice_id in
<foreach item="noticeId" collection="array" open="(" separator="," close=")">
#{noticeId}
</foreach>
</delete>
</mapper>
@@ -1,105 +0,0 @@
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.InitialSystemOtherCollectData;
import com.ruoyi.rocketmq.service.IInitialSystemOtherCollectDataService;
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-09-23
*/
@RestController
@RequestMapping("/systemOtherCollectData")
public class InitialSystemOtherCollectDataController extends BaseController
{
@Autowired
private IInitialSystemOtherCollectDataService initialSystemOtherCollectDataService;
/**
* 查询交换机系统其他信息采集数据列表
*/
@RequiresPermissions("rocketmq:systemOtherCollectData:list")
@GetMapping("/list")
public TableDataInfo list(InitialSystemOtherCollectData initialSystemOtherCollectData)
{
startPage();
List<InitialSystemOtherCollectData> list = initialSystemOtherCollectDataService.selectInitialSystemOtherCollectDataList(initialSystemOtherCollectData);
return getDataTable(list);
}
/**
* 导出交换机系统其他信息采集数据列表
*/
@RequiresPermissions("rocketmq:systemOtherCollectData:export")
@Log(title = "交换机系统其他信息采集数据", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, InitialSystemOtherCollectData initialSystemOtherCollectData)
{
List<InitialSystemOtherCollectData> list = initialSystemOtherCollectDataService.selectInitialSystemOtherCollectDataList(initialSystemOtherCollectData);
ExcelUtil<InitialSystemOtherCollectData> util = new ExcelUtil<InitialSystemOtherCollectData>(InitialSystemOtherCollectData.class);
util.exportExcel(response, list, "交换机系统其他信息采集数据数据");
}
/**
* 获取交换机系统其他信息采集数据详细信息
*/
@RequiresPermissions("rocketmq:systemOtherCollectData:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(initialSystemOtherCollectDataService.selectInitialSystemOtherCollectDataById(id));
}
/**
* 新增交换机系统其他信息采集数据
*/
@RequiresPermissions("rocketmq:systemOtherCollectData:add")
@Log(title = "交换机系统其他信息采集数据", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody InitialSystemOtherCollectData initialSystemOtherCollectData)
{
return toAjax(initialSystemOtherCollectDataService.insertInitialSystemOtherCollectData(initialSystemOtherCollectData));
}
/**
* 修改交换机系统其他信息采集数据
*/
@RequiresPermissions("rocketmq:systemOtherCollectData:edit")
@Log(title = "交换机系统其他信息采集数据", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody InitialSystemOtherCollectData initialSystemOtherCollectData)
{
return toAjax(initialSystemOtherCollectDataService.updateInitialSystemOtherCollectData(initialSystemOtherCollectData));
}
/**
* 删除交换机系统其他信息采集数据
*/
@RequiresPermissions("rocketmq:systemOtherCollectData:remove")
@Log(title = "交换机系统其他信息采集数据", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(initialSystemOtherCollectDataService.deleteInitialSystemOtherCollectDataByIds(ids));
}
}
@@ -1,36 +0,0 @@
package com.ruoyi.rocketmq.controller;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.rocketmq.domain.RmResourceRemote;
import com.ruoyi.rocketmq.service.IRmResourceRemoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 资源远程管理Controller
*
* @author gyt
* @date 2025-09-15
*/
@RestController
@RequestMapping("/remote")
public class RmResourceRemoteController extends BaseController
{
@Autowired
private IRmResourceRemoteService rmResourceRemoteService;
/**
* 获取资源远程管理详细信息
*/
@RequiresPermissions("rocketmq:remote:query")
@PostMapping(value = "/getScriptResultBySn")
public AjaxResult getScriptResultBySn(@RequestBody RmResourceRemote rmResourceRemote)
{
return success(rmResourceRemoteService.getScriptResultBySn(rmResourceRemote));
}
}
@@ -1,76 +0,0 @@
package com.ruoyi.rocketmq.domain;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 初始带宽流量对象 initial_bandwidth_traffic
*
* @author gyt
* @date 2025-08-20
*/
@Data
public class InitialBandwidthTraffic extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 唯一标识ID */
private Long id;
/** 表名 */
private String tableName;
/** 接口名称 */
@Excel(name = "接口名称")
private String name;
/** MAC地址 */
@Excel(name = "MAC地址")
private String mac;
/** 运行状态 */
@Excel(name = "运行状态")
private String status;
/** 接口类型 */
@Excel(name = "接口类型")
private String type;
/** IPv4地址 */
@Excel(name = "IPv4地址")
private String ipV4;
/** 入站丢包率(%) */
@Excel(name = "入站丢包率(%)")
private BigDecimal inDropped;
/** 出站丢包率(%) */
@Excel(name = "出站丢包率(%)")
private BigDecimal outDropped;
/** 接收带宽(Mbps) */
@Excel(name = "接收带宽(Mbps)")
private String inSpeed;
/** 发送带宽(Mbps) */
@Excel(name = "发送带宽(Mbps)")
private String outSpeed;
/** 设备唯一标识 */
@Excel(name = "设备唯一标识")
private String clientId;
/** 初始带宽流量集合 */
private List<InitialBandwidthTraffic> list;
/** 工作模式 */
private String duplex;
/** 协商速度 */
private String speed;
/** 开始时间 */
private String startTime;
/** 结束时间 */
private String endTime;
}
@@ -1,133 +0,0 @@
package com.ruoyi.rocketmq.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;
/**
* 挂载点监控信息对象 initial_mount_point_info
*
* @author gyt
* @date 2025-08-25
*/
public class InitialMountPointInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 自增主键ID */
private Long id;
/** 客户端ID */
@Excel(name = "客户端ID")
private String clientId;
/** 挂载点路径(如"/"、"/data"等) */
@Excel(name = "挂载点路径")
private String mount;
/** 文件系统类型(如ext4、xfs、ntfs等) */
@Excel(name = "文件系统类型")
private String vfsType;
/** 可用空间(字节) */
@Excel(name = "可用空间")
private Long vfsFree;
/** 总空间(字节) */
@Excel(name = "总空间")
private Long vfsTotal;
/** 空间利用率(%) */
@Excel(name = "空间利用率")
private BigDecimal vfsUtil;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setClientId(String clientId)
{
this.clientId = clientId;
}
public String getClientId()
{
return clientId;
}
public void setMount(String mount)
{
this.mount = mount;
}
public String getMount()
{
return mount;
}
public void setVfsType(String vfsType)
{
this.vfsType = vfsType;
}
public String getVfsType()
{
return vfsType;
}
public void setVfsFree(Long vfsFree)
{
this.vfsFree = vfsFree;
}
public Long getVfsFree()
{
return vfsFree;
}
public void setVfsTotal(Long vfsTotal)
{
this.vfsTotal = vfsTotal;
}
public Long getVfsTotal()
{
return vfsTotal;
}
public void setVfsUtil(BigDecimal vfsUtil)
{
this.vfsUtil = vfsUtil;
}
public BigDecimal getVfsUtil()
{
return vfsUtil;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("clientId", getClientId())
.append("mount", getMount())
.append("vfsType", getVfsType())
.append("vfsFree", getVfsFree())
.append("vfsTotal", getVfsTotal())
.append("vfsUtil", getVfsUtil())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.toString();
}
}
@@ -1,147 +0,0 @@
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;
/**
* MPU信息对象 initial_switch_mpu_info
*
* @author gyt
* @date 2025-09-22
*/
public class InitialSwitchMpuInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** MPU索引 */
@Excel(name = "MPU索引")
private String mpuEntIndex;
/** MPU名称 */
@Excel(name = "MPU名称")
private String mpuName;
/** MPU的CPU使用率(%) */
@Excel(name = "MPU的CPU使用率(%)")
private BigDecimal mpuEntityCpuUsage;
/** MPU的内存使用率(%) */
@Excel(name = "MPU的内存使用率(%)")
private BigDecimal mpuEntityMemUsage;
/** MPU的操作系统 */
@Excel(name = "MPU的操作系统")
private String mpuPhysicalSoftwareRev;
/** MPU的温度(℃) */
@Excel(name = "MPU的温度(℃)")
private BigDecimal mpuEntityTemperature;
/** 客户端ID */
@Excel(name = "客户端ID")
private String clientId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setMpuEntIndex(String mpuEntIndex)
{
this.mpuEntIndex = mpuEntIndex;
}
public String getMpuEntIndex()
{
return mpuEntIndex;
}
public void setMpuName(String mpuName)
{
this.mpuName = mpuName;
}
public String getMpuName()
{
return mpuName;
}
public void setMpuEntityCpuUsage(BigDecimal mpuEntityCpuUsage)
{
this.mpuEntityCpuUsage = mpuEntityCpuUsage;
}
public BigDecimal getMpuEntityCpuUsage()
{
return mpuEntityCpuUsage;
}
public void setMpuEntityMemUsage(BigDecimal mpuEntityMemUsage)
{
this.mpuEntityMemUsage = mpuEntityMemUsage;
}
public BigDecimal getMpuEntityMemUsage()
{
return mpuEntityMemUsage;
}
public void setMpuPhysicalSoftwareRev(String mpuPhysicalSoftwareRev)
{
this.mpuPhysicalSoftwareRev = mpuPhysicalSoftwareRev;
}
public String getMpuPhysicalSoftwareRev()
{
return mpuPhysicalSoftwareRev;
}
public void setMpuEntityTemperature(BigDecimal mpuEntityTemperature)
{
this.mpuEntityTemperature = mpuEntityTemperature;
}
public BigDecimal getMpuEntityTemperature()
{
return mpuEntityTemperature;
}
public void setClientId(String clientId)
{
this.clientId = clientId;
}
public String getClientId()
{
return clientId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("mpuEntIndex", getMpuEntIndex())
.append("mpuName", getMpuName())
.append("mpuEntityCpuUsage", getMpuEntityCpuUsage())
.append("mpuEntityMemUsage", getMpuEntityMemUsage())
.append("mpuPhysicalSoftwareRev", getMpuPhysicalSoftwareRev())
.append("mpuEntityTemperature", getMpuEntityTemperature())
.append("clientId", getClientId())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.toString();
}
}
@@ -1,147 +0,0 @@
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_switch_optical_module
*
* @author gyt
* @date 2025-09-22
*/
public class InitialSwitchOpticalModule extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 光模块端口索引 */
@Excel(name = "光模块端口索引")
private String fiberEntIndex;
/** 光模块端口名称 */
@Excel(name = "光模块端口名称")
private String fiberPortName;
/** 光模块发送光衰阈值(dBm) */
@Excel(name = "光模块发送光衰阈值(dBm)")
private BigDecimal hwEntityOpticalTxLowThreshold;
/** 光模块接收光衰阈值(dBm) */
@Excel(name = "光模块接收光衰阈值(dBm)")
private BigDecimal hwEntityOpticalRxLowThreshold;
/** 光模块接收功率(dBm) */
@Excel(name = "光模块接收功率(dBm)")
private BigDecimal hwEntityOpticalRxPower;
/** 光模块发送功率(dBm) */
@Excel(name = "光模块发送功率(dBm)")
private BigDecimal hwEntityOpticalTxPower;
/** 客户端ID */
@Excel(name = "客户端ID")
private String clientId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setFiberEntIndex(String fiberEntIndex)
{
this.fiberEntIndex = fiberEntIndex;
}
public String getFiberEntIndex()
{
return fiberEntIndex;
}
public void setFiberPortName(String fiberPortName)
{
this.fiberPortName = fiberPortName;
}
public String getFiberPortName()
{
return fiberPortName;
}
public void setHwEntityOpticalTxLowThreshold(BigDecimal hwEntityOpticalTxLowThreshold)
{
this.hwEntityOpticalTxLowThreshold = hwEntityOpticalTxLowThreshold;
}
public BigDecimal getHwEntityOpticalTxLowThreshold()
{
return hwEntityOpticalTxLowThreshold;
}
public void setHwEntityOpticalRxLowThreshold(BigDecimal hwEntityOpticalRxLowThreshold)
{
this.hwEntityOpticalRxLowThreshold = hwEntityOpticalRxLowThreshold;
}
public BigDecimal getHwEntityOpticalRxLowThreshold()
{
return hwEntityOpticalRxLowThreshold;
}
public void setHwEntityOpticalRxPower(BigDecimal hwEntityOpticalRxPower)
{
this.hwEntityOpticalRxPower = hwEntityOpticalRxPower;
}
public BigDecimal getHwEntityOpticalRxPower()
{
return hwEntityOpticalRxPower;
}
public void setHwEntityOpticalTxPower(BigDecimal hwEntityOpticalTxPower)
{
this.hwEntityOpticalTxPower = hwEntityOpticalTxPower;
}
public BigDecimal getHwEntityOpticalTxPower()
{
return hwEntityOpticalTxPower;
}
public void setClientId(String clientId)
{
this.clientId = clientId;
}
public String getClientId()
{
return clientId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("fiberEntIndex", getFiberEntIndex())
.append("fiberPortName", getFiberPortName())
.append("hwEntityOpticalTxLowThreshold", getHwEntityOpticalTxLowThreshold())
.append("hwEntityOpticalRxLowThreshold", getHwEntityOpticalRxLowThreshold())
.append("hwEntityOpticalRxPower", getHwEntityOpticalRxPower())
.append("hwEntityOpticalTxPower", getHwEntityOpticalTxPower())
.append("clientId", getClientId())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.toString();
}
}
@@ -1,131 +0,0 @@
package com.ruoyi.rocketmq.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;
/**
* 电源信息对象 initial_switch_power_supply
*
* @author gyt
* @date 2025-09-22
*/
public class InitialSwitchPowerSupply extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 电源索引 */
@Excel(name = "电源索引")
private String pwrEntIndex;
/** 电源名称 */
@Excel(name = "电源名称")
private String pwrName;
/** 电源状态 */
@Excel(name = "电源状态")
private String pwrEntityPwrState;
/** 电源电流(mA) */
@Excel(name = "电源电流(mA)")
private Long pwrEntityPwrCurrent;
/** 电源电压(mV) */
@Excel(name = "电源电压(mV)")
private Long pwrEntityPwrVoltage;
/** 客户端ID */
@Excel(name = "客户端ID")
private String clientId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setPwrEntIndex(String pwrEntIndex)
{
this.pwrEntIndex = pwrEntIndex;
}
public String getPwrEntIndex()
{
return pwrEntIndex;
}
public void setPwrName(String pwrName)
{
this.pwrName = pwrName;
}
public String getPwrName()
{
return pwrName;
}
public void setPwrEntityPwrState(String pwrEntityPwrState)
{
this.pwrEntityPwrState = pwrEntityPwrState;
}
public String getPwrEntityPwrState()
{
return pwrEntityPwrState;
}
public void setPwrEntityPwrCurrent(Long pwrEntityPwrCurrent)
{
this.pwrEntityPwrCurrent = pwrEntityPwrCurrent;
}
public Long getPwrEntityPwrCurrent()
{
return pwrEntityPwrCurrent;
}
public void setPwrEntityPwrVoltage(Long pwrEntityPwrVoltage)
{
this.pwrEntityPwrVoltage = pwrEntityPwrVoltage;
}
public Long getPwrEntityPwrVoltage()
{
return pwrEntityPwrVoltage;
}
public void setClientId(String clientId)
{
this.clientId = clientId;
}
public String getClientId()
{
return clientId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("pwrEntIndex", getPwrEntIndex())
.append("pwrName", getPwrName())
.append("pwrEntityPwrState", getPwrEntityPwrState())
.append("pwrEntityPwrCurrent", getPwrEntityPwrCurrent())
.append("pwrEntityPwrVoltage", getPwrEntityPwrVoltage())
.append("clientId", getClientId())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.toString();
}
}
@@ -1,149 +0,0 @@
package com.ruoyi.rocketmq.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
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;
/**
* 告警记录对象 rm_alarm_record
*
* @author gyt
* @date 2025-09-12
*/
public class RmAlarmRecord extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 客户端ID/设备ID */
@Excel(name = "客户端ID/设备ID")
private String clientId;
/** 资源名称 */
@Excel(name = "资源名称")
private String resourceName;
/** 源IP地址 */
@Excel(name = "源IP地址")
private String sourceIp;
/** 告警发生时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "告警发生时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date occurTime;
/** 告警详细内容 */
@Excel(name = "告警详细内容")
private String content;
/** 重复告警次数 */
@Excel(name = "重复告警次数")
private Long repeatCount;
/** 状态:0-未处理,1-已处理 */
@Excel(name = "状态:0-未处理,1-已处理")
private String status;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setClientId(String clientId)
{
this.clientId = clientId;
}
public String getClientId()
{
return clientId;
}
public void setResourceName(String resourceName)
{
this.resourceName = resourceName;
}
public String getResourceName()
{
return resourceName;
}
public void setSourceIp(String sourceIp)
{
this.sourceIp = sourceIp;
}
public String getSourceIp()
{
return sourceIp;
}
public void setOccurTime(Date occurTime)
{
this.occurTime = occurTime;
}
public Date getOccurTime()
{
return occurTime;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setRepeatCount(Long repeatCount)
{
this.repeatCount = repeatCount;
}
public Long getRepeatCount()
{
return repeatCount;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("clientId", getClientId())
.append("resourceName", getResourceName())
.append("sourceIp", getSourceIp())
.append("occurTime", getOccurTime())
.append("content", getContent())
.append("repeatCount", getRepeatCount())
.append("status", getStatus())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.toString();
}
}
@@ -1,24 +0,0 @@
package com.ruoyi.rocketmq.domain.vo;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
public class SwitchOidVo {
private Map<String, String> netOID;
private Map<String, String> moduleOID;
private Map<String, String> mpuOID;
private Map<String, String> pwrOID;
private Map<String, String> fanOID;
private Map<String, String> otherOID;
/** 团体名 */
private String community;
/** ip地址 */
private String ip;
/** 端口 */
private Integer port;
/** 过滤值 */
private Map<String, List<String>> filters;
}
@@ -1,61 +0,0 @@
package com.ruoyi.rocketmq.service;
import java.util.List;
import com.ruoyi.rocketmq.domain.InitialSystemOtherCollectData;
/**
* 交换机系统其他信息采集数据Service接口
*
* @author gyt
* @date 2025-09-23
*/
public interface IInitialSystemOtherCollectDataService
{
/**
* 查询交换机系统其他信息采集数据
*
* @param id 交换机系统其他信息采集数据主键
* @return 交换机系统其他信息采集数据
*/
public InitialSystemOtherCollectData selectInitialSystemOtherCollectDataById(Long id);
/**
* 查询交换机系统其他信息采集数据列表
*
* @param initialSystemOtherCollectData 交换机系统其他信息采集数据
* @return 交换机系统其他信息采集数据集合
*/
public List<InitialSystemOtherCollectData> selectInitialSystemOtherCollectDataList(InitialSystemOtherCollectData initialSystemOtherCollectData);
/**
* 新增交换机系统其他信息采集数据
*
* @param initialSystemOtherCollectData 交换机系统其他信息采集数据
* @return 结果
*/
public int insertInitialSystemOtherCollectData(InitialSystemOtherCollectData initialSystemOtherCollectData);
/**
* 修改交换机系统其他信息采集数据
*
* @param initialSystemOtherCollectData 交换机系统其他信息采集数据
* @return 结果
*/
public int updateInitialSystemOtherCollectData(InitialSystemOtherCollectData initialSystemOtherCollectData);
/**
* 批量删除交换机系统其他信息采集数据
*
* @param ids 需要删除的交换机系统其他信息采集数据主键集合
* @return 结果
*/
public int deleteInitialSystemOtherCollectDataByIds(Long[] ids);
/**
* 删除交换机系统其他信息采集数据信息
*
* @param id 交换机系统其他信息采集数据主键
* @return 结果
*/
public int deleteInitialSystemOtherCollectDataById(Long id);
}
@@ -1,254 +0,0 @@
package com.ruoyi.rocketmq.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.rocketmq.domain.InitialBandwidthTraffic;
import com.ruoyi.rocketmq.mapper.InitialBandwidthTrafficMapper;
import com.ruoyi.rocketmq.service.IInitialBandwidthTrafficService;
import com.ruoyi.rocketmq.utils.EchartsDataUtils;
import com.ruoyi.rocketmq.utils.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.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 初始带宽流量Service业务层处理
*
* @author gyt
* @date 2025-08-20
*/
@Service
@Slf4j
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<InitialBandwidthTraffic> selectInitialBandwidthTrafficList(InitialBandwidthTraffic initialBandwidthTraffic)
{
return initialBandwidthTrafficMapper.selectInitialBandwidthTrafficList(initialBandwidthTraffic);
}
/**
* 新增初始带宽流量
*
* @param initialBandwidthTraffic 初始带宽流量
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
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);
}
/**
* 保存单条数据到对应分表
* @param data 流量数据
*/
@Override
@Transactional
public void save(InitialBandwidthTraffic data) {
if (data.getCreateTime() == null) {
data.setCreateTime(DateUtils.getNowDate());
}
Date date = data.getCreateTime();
LocalDateTime createTime = date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
data.setTableName(TableRouterUtil.getTableName(createTime));
initialBandwidthTrafficMapper.insert(data);
}
/**
* 保存多条数据到对应分表
* @param initialBandwidthTraffic 流量数据
*/
@Override
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
public void batchInsert(InitialBandwidthTraffic initialBandwidthTraffic) {
if (initialBandwidthTraffic == null) {
return;
}
List<InitialBandwidthTraffic> dataList = initialBandwidthTraffic.getList();
if (dataList.isEmpty()){
return;
}
// 按表名分组批量插入
Map<String, List<InitialBandwidthTraffic>> groupedData = dataList.stream()
.map(data -> {
try {
InitialBandwidthTraffic processed = new InitialBandwidthTraffic();
BeanUtils.copyProperties(data,processed);
if (data.getCreateTime() == null) {
data.setCreateTime(DateUtils.getNowDate());
}
LocalDateTime createTime = data.getCreateTime().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
processed.setTableName(TableRouterUtil.getTableName(createTime));
return processed;
} catch (Exception e){
log.error("数据处理失败",e.getMessage());
return null;
}
}).collect(Collectors.groupingBy(
InitialBandwidthTraffic::getTableName,
LinkedHashMap::new, // 保持插入顺序
Collectors.toList()));
groupedData.forEach((tableName, list) -> {
try {
InitialBandwidthTraffic data = new InitialBandwidthTraffic();
BeanUtils.copyProperties(initialBandwidthTraffic,data);
data.setTableName(tableName);
data.setList(list);
initialBandwidthTrafficMapper.batchInsert(data);
} catch (Exception e) {
log.error("表{}插入失败", tableName, e);
throw new RuntimeException("批量插入失败", e);
}
});
}
/**
* 网络接口基础信息
* @param initialBandwidthTraffic
* @return
*/
@Override
public InitialBandwidthTraffic getNetInterfaceDetailsMsg(InitialBandwidthTraffic initialBandwidthTraffic) {
if (initialBandwidthTraffic.getCreateTime() == null) {
initialBandwidthTraffic.setCreateTime(DateUtils.getNowDate());
}
LocalDateTime createTime = initialBandwidthTraffic.getCreateTime().toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
initialBandwidthTraffic.setTableName(TableRouterUtil.getTableName(createTime));
InitialBandwidthTraffic detailsMsg = initialBandwidthTrafficMapper.getNetInterfaceDetailsMsg(initialBandwidthTraffic);
return detailsMsg;
}
/**
* 分表查询需要的信息
* @param initialBandwidthTraffic
* @return
*/
public List<InitialBandwidthTraffic> getListByTableName(InitialBandwidthTraffic initialBandwidthTraffic){
// 获取涉及的表名
Set<String> tableNames = TableRouterUtil.getTableNamesBetween(initialBandwidthTraffic.getStartTime(), initialBandwidthTraffic.getEndTime());
// 并行查询各表
List<InitialBandwidthTraffic> list = tableNames.parallelStream()
.flatMap(tableName -> {
InitialBandwidthTraffic condition = new InitialBandwidthTraffic();
condition.setTableName(tableName);
condition.setStartTime(initialBandwidthTraffic.getStartTime());
condition.setEndTime(initialBandwidthTraffic.getEndTime());
return initialBandwidthTrafficMapper.getNetTrafficList(condition).stream();
})
.collect(Collectors.toList());
return list;
}
/**
* 查询eth0流量信息并封装为多折线ECharts图表数据
* @param initialBandwidthTraffic
* @return
*/
@Override
public Map<String, Object> netInterfaceTrafficEcharts(InitialBandwidthTraffic initialBandwidthTraffic) {
// 流量信息
List<InitialBandwidthTraffic> list = getListByTableName(initialBandwidthTraffic);
Map<String, Function<InitialBandwidthTraffic, ?>> extractors = new LinkedHashMap<>();
extractors.put("inSpeedData", info -> safeConvertToKB(info.getInSpeed()));
extractors.put("outSpeedData", info -> safeConvertToKB(info.getOutSpeed()));
return EchartsDataUtils.buildEchartsData(list, InitialBandwidthTraffic::getCreateTime, extractors);
}
// 安全转换方法(处理可能的NumberFormatException
private Double safeConvertToKB(String byteValue) {
try {
return byteValue == null ? 0.0 : Double.parseDouble(byteValue) / 1024.0;
} catch (NumberFormatException e) {
return 0.0; // 或根据业务需求返回null/抛出异常
}
}
/**
* 查询eth0流量信息丢包数并封装为折线ECharts图表数据
* @param initialBandwidthTraffic
* @return
*/
@Override
public Map<String, Object> netInterfaceDroppedEcharts(InitialBandwidthTraffic initialBandwidthTraffic) {
// 流量信息
List<InitialBandwidthTraffic> list = getListByTableName(initialBandwidthTraffic);
Map<String, Function<InitialBandwidthTraffic, ?>> extractors = new LinkedHashMap<>();
extractors.put("inDroppedData", info -> info.getInDropped());
extractors.put("outDroppedData", info -> info.getOutDropped());
return EchartsDataUtils.buildEchartsData(list, InitialBandwidthTraffic::getCreateTime, extractors);
}
}
@@ -1,163 +0,0 @@
package com.ruoyi.rocketmq.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.rocketmq.domain.InitialCpuInfo;
import com.ruoyi.rocketmq.mapper.InitialCpuInfoMapper;
import com.ruoyi.rocketmq.service.IInitialCpuInfoService;
import com.ruoyi.rocketmq.utils.EchartsDataUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import static com.ruoyi.rocketmq.utils.EchartsDataUtils.convertMicrosecondsToSeconds;
/**
* CPU监控信息Service业务层处理
*
* @author gyt
* @date 2025-08-25
*/
@Service
@Slf4j
public class InitialCpuInfoServiceImpl implements IInitialCpuInfoService
{
@Autowired
private InitialCpuInfoMapper initialCpuInfoMapper;
/**
* 查询CPU监控信息
*
* @param id CPU监控信息主键
* @return CPU监控信息
*/
@Override
public InitialCpuInfo selectInitialCpuInfoById(Long id)
{
return initialCpuInfoMapper.selectInitialCpuInfoById(id);
}
/**
* 查询CPU监控信息列表
*
* @param initialCpuInfo CPU监控信息
* @return CPU监控信息
*/
@Override
public List<InitialCpuInfo> selectInitialCpuInfoList(InitialCpuInfo initialCpuInfo)
{
return initialCpuInfoMapper.selectInitialCpuInfoList(initialCpuInfo);
}
/**
* 新增CPU监控信息
*
* @param initialCpuInfo CPU监控信息
* @return 结果
*/
@Override
public int insertInitialCpuInfo(InitialCpuInfo initialCpuInfo)
{
initialCpuInfo.setCreateTime(DateUtils.getNowDate());
return initialCpuInfoMapper.insertInitialCpuInfo(initialCpuInfo);
}
/**
* 修改CPU监控信息
*
* @param initialCpuInfo CPU监控信息
* @return 结果
*/
@Override
public int updateInitialCpuInfo(InitialCpuInfo initialCpuInfo)
{
initialCpuInfo.setUpdateTime(DateUtils.getNowDate());
return initialCpuInfoMapper.updateInitialCpuInfo(initialCpuInfo);
}
/**
* 批量删除CPU监控信息
*
* @param ids 需要删除的CPU监控信息主键
* @return 结果
*/
@Override
public int deleteInitialCpuInfoByIds(Long[] ids)
{
return initialCpuInfoMapper.deleteInitialCpuInfoByIds(ids);
}
/**
* 删除CPU监控信息信息
*
* @param id CPU监控信息主键
* @return 结果
*/
@Override
public int deleteInitialCpuInfoById(Long id)
{
return initialCpuInfoMapper.deleteInitialCpuInfoById(id);
}
/**
* 批量新增CPU监控信息信息
*
* @param list CPU监控信息信息集合
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
public int batchInsertInitialCpuInfo(List<InitialCpuInfo> list) {
try {
return initialCpuInfoMapper.batchInsertInitialCpuInfo(list);
}catch (Exception e){
log.error("批量插入CPU信息失败,失败数量:{}", list.size(), e);
throw new RuntimeException("批量保存失败",e);
}
}
/**
* cpu负载
* @param initialCpuInfo
* @return
*/
@Override
public Map<String, Object> cupLoadEcharts(InitialCpuInfo initialCpuInfo) {
// 查询原始CPU监控数据并按时间排序
List<InitialCpuInfo> list = initialCpuInfoMapper.selectInitialCpuInfoList(initialCpuInfo);
Map<String, Function<InitialCpuInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("load1Data", InitialCpuInfo::getAvg1);
extractors.put("load5Data", InitialCpuInfo::getAvg5);
extractors.put("load15Data", InitialCpuInfo::getAvg15);
extractors.put("utiData", InitialCpuInfo::getUti);
return EchartsDataUtils.buildEchartsData(list, InitialCpuInfo::getCreateTime, extractors);
}
/**
* cpu时间(s)
* @param initialCpuInfo
* @return
*/
@Override
public Map<String, Object> cpuTimeEcharts(InitialCpuInfo initialCpuInfo) {
List<InitialCpuInfo> list = initialCpuInfoMapper.selectInitialCpuInfoList(initialCpuInfo);
Map<String, Function<InitialCpuInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("normalData", info -> convertMicrosecondsToSeconds(info.getNormal()));
extractors.put("idleData", info -> convertMicrosecondsToSeconds(info.getIdle()));
extractors.put("iowaitData", InitialCpuInfo::getIowait);
extractors.put("systemData", info -> convertMicrosecondsToSeconds(info.getSystem()));
extractors.put("norespData", InitialCpuInfo::getNoresp);
extractors.put("userpData", info -> convertMicrosecondsToSeconds(info.getUser()));
return EchartsDataUtils.buildEchartsData(list,InitialCpuInfo::getCreateTime, extractors);
}
}
@@ -1,172 +0,0 @@
package com.ruoyi.rocketmq.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.rocketmq.domain.InitialDiskInfo;
import com.ruoyi.rocketmq.mapper.InitialDiskInfoMapper;
import com.ruoyi.rocketmq.service.IInitialDiskInfoService;
import com.ruoyi.rocketmq.utils.EchartsDataUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* 磁盘监控信息Service业务层处理
*
* @author gyt
* @date 2025-08-25
*/
@Service
@Slf4j
public class InitialDiskInfoServiceImpl implements IInitialDiskInfoService
{
@Autowired
private InitialDiskInfoMapper initialDiskInfoMapper;
/**
* 查询磁盘监控信息
*
* @param id 磁盘监控信息主键
* @return 磁盘监控信息
*/
@Override
public InitialDiskInfo selectInitialDiskInfoById(Long id)
{
return initialDiskInfoMapper.selectInitialDiskInfoById(id);
}
/**
* 查询磁盘监控信息列表
*
* @param initialDiskInfo 磁盘监控信息
* @return 磁盘监控信息
*/
@Override
public List<InitialDiskInfo> selectInitialDiskInfoList(InitialDiskInfo initialDiskInfo)
{
return initialDiskInfoMapper.selectInitialDiskInfoList(initialDiskInfo);
}
/**
* 新增磁盘监控信息
*
* @param initialDiskInfo 磁盘监控信息
* @return 结果
*/
@Override
public int insertInitialDiskInfo(InitialDiskInfo initialDiskInfo)
{
initialDiskInfo.setCreateTime(DateUtils.getNowDate());
return initialDiskInfoMapper.insertInitialDiskInfo(initialDiskInfo);
}
/**
* 修改磁盘监控信息
*
* @param initialDiskInfo 磁盘监控信息
* @return 结果
*/
@Override
public int updateInitialDiskInfo(InitialDiskInfo initialDiskInfo)
{
initialDiskInfo.setUpdateTime(DateUtils.getNowDate());
return initialDiskInfoMapper.updateInitialDiskInfo(initialDiskInfo);
}
/**
* 批量删除磁盘监控信息
*
* @param ids 需要删除的磁盘监控信息主键
* @return 结果
*/
@Override
public int deleteInitialDiskInfoByIds(Long[] ids)
{
return initialDiskInfoMapper.deleteInitialDiskInfoByIds(ids);
}
/**
* 删除磁盘监控信息信息
*
* @param id 磁盘监控信息主键
* @return 结果
*/
@Override
public int deleteInitialDiskInfoById(Long id)
{
return initialDiskInfoMapper.deleteInitialDiskInfoById(id);
}
/**
* 批量新增磁盘监控信息
*
* @param list 磁盘监控信息集合
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
public int batchInsertInitialDiskInfo(List<InitialDiskInfo> list) {
try {
return initialDiskInfoMapper.batchInsertInitialDiskInfo(list);
}catch (Exception e){
log.error("批量插入磁盘信息失败,失败数量:{}", list.size(), e);
throw new RuntimeException("批量保存失败",e);
}
}
/**
* 磁盘设备/dev/sda基础信息
* @param initialDiskInfo
* @return
*/
@Override
public InitialDiskInfo getDistDetailsMsg(InitialDiskInfo initialDiskInfo) {
return initialDiskInfoMapper.getDistDetailsMsgByClientId(initialDiskInfo);
}
/**
* /dev/sda读写速率(KB/s)
* @param initialDiskInfo
* @return
*/
@Override
public Map<String, Object> rwSpeedEcharts(InitialDiskInfo initialDiskInfo) {
initialDiskInfo.setName("/dev/sda");
List<InitialDiskInfo> list = initialDiskInfoMapper.selectInitialDiskInfoList(initialDiskInfo);
Map<String, Function<InitialDiskInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("readSpeedData", info -> info.getReadSpeed() / 1024.0);
extractors.put("writeSpeedData", info -> info.getWriteSpeed() / 1024.0);
return EchartsDataUtils.buildEchartsData(list, InitialDiskInfo::getCreateTime, extractors);
}
/**
* /dev/sda读写次数
* @param initialDiskInfo
* @return
*/
@Override
public Map<String, Object> rwTimesEcharts(InitialDiskInfo initialDiskInfo) {
initialDiskInfo.setName("/dev/sda");
List<InitialDiskInfo> list = initialDiskInfoMapper.selectInitialDiskInfoList(initialDiskInfo);
Map<String, Function<InitialDiskInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("readTimesData", info -> info.getReadTimes());
extractors.put("writeTimesData", info -> info.getWriteTimes());
return EchartsDataUtils.buildEchartsData(list, InitialDiskInfo::getCreateTime, extractors);
}
/**
* /dev/sda读写字节
* @param initialDiskInfo
* @return
*/
@Override
public Map<String, Object> rwBytesEcharts(InitialDiskInfo initialDiskInfo) {
initialDiskInfo.setName("/dev/sda");
List<InitialDiskInfo> list = initialDiskInfoMapper.selectInitialDiskInfoList(initialDiskInfo);
Map<String, Function<InitialDiskInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("readBytesData", info -> info.getReadBytes());
extractors.put("writeBytesData", info -> info.getWriteBytes());
return EchartsDataUtils.buildEchartsData(list, InitialDiskInfo::getCreateTime, extractors);
}
}
@@ -1,153 +0,0 @@
package com.ruoyi.rocketmq.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.rocketmq.domain.InitialMountPointInfo;
import com.ruoyi.rocketmq.mapper.InitialMountPointInfoMapper;
import com.ruoyi.rocketmq.service.IInitialMountPointInfoService;
import com.ruoyi.rocketmq.utils.EchartsDataUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* 挂载点监控信息Service业务层处理
*
* @author gyt
* @date 2025-08-25
*/
@Service
@Slf4j
public class InitialMountPointInfoServiceImpl implements IInitialMountPointInfoService
{
@Autowired
private InitialMountPointInfoMapper initialMountPointInfoMapper;
/**
* 查询挂载点监控信息
*
* @param id 挂载点监控信息主键
* @return 挂载点监控信息
*/
@Override
public InitialMountPointInfo selectInitialMountPointInfoById(Long id)
{
return initialMountPointInfoMapper.selectInitialMountPointInfoById(id);
}
/**
* 查询挂载点监控信息列表
*
* @param initialMountPointInfo 挂载点监控信息
* @return 挂载点监控信息
*/
@Override
public List<InitialMountPointInfo> selectInitialMountPointInfoList(InitialMountPointInfo initialMountPointInfo)
{
return initialMountPointInfoMapper.selectInitialMountPointInfoList(initialMountPointInfo);
}
/**
* 新增挂载点监控信息
*
* @param initialMountPointInfo 挂载点监控信息
* @return 结果
*/
@Override
public int insertInitialMountPointInfo(InitialMountPointInfo initialMountPointInfo)
{
initialMountPointInfo.setCreateTime(DateUtils.getNowDate());
return initialMountPointInfoMapper.insertInitialMountPointInfo(initialMountPointInfo);
}
/**
* 修改挂载点监控信息
*
* @param initialMountPointInfo 挂载点监控信息
* @return 结果
*/
@Override
public int updateInitialMountPointInfo(InitialMountPointInfo initialMountPointInfo)
{
initialMountPointInfo.setUpdateTime(DateUtils.getNowDate());
return initialMountPointInfoMapper.updateInitialMountPointInfo(initialMountPointInfo);
}
/**
* 批量删除挂载点监控信息
*
* @param ids 需要删除的挂载点监控信息主键
* @return 结果
*/
@Override
public int deleteInitialMountPointInfoByIds(Long[] ids)
{
return initialMountPointInfoMapper.deleteInitialMountPointInfoByIds(ids);
}
/**
* 删除挂载点监控信息信息
*
* @param id 挂载点监控信息主键
* @return 结果
*/
@Override
public int deleteInitialMountPointInfoById(Long id)
{
return initialMountPointInfoMapper.deleteInitialMountPointInfoById(id);
}
/**
* 批量新增挂载点监控信息
*
* @param list 挂载点监控信息集合
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
public int batchInsertInitialMountPointInfo(List<InitialMountPointInfo> list) {
try {
return initialMountPointInfoMapper.batchInsertInitialMountPointInfo(list);
}catch (Exception e){
log.error("批量插入挂载点信息失败,失败数量:{}", list.size(), e);
throw new RuntimeException("批量保存失败",e);
}
}
@Override
public InitialMountPointInfo pointDetailsMsg(InitialMountPointInfo initialMountPointInfo) {
return initialMountPointInfoMapper.pointDetailsMsg(initialMountPointInfo.getClientId());
}
/**
* 获取挂载点监控信息的空间图形
* @param initialMountPointInfo
* @return
*/
@Override
public Map<String, Object> spaceEcharts(InitialMountPointInfo initialMountPointInfo) {
List<InitialMountPointInfo> list = initialMountPointInfoMapper.selectInitialMountPointInfoList(initialMountPointInfo);
Map<String, Function<InitialMountPointInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("vfsFreeData", info -> info.getVfsFree() / 1024.0);
extractors.put("vfsTotalData", info -> info.getVfsTotal() / 1024.0);
return EchartsDataUtils.buildEchartsData(list,InitialMountPointInfo::getCreateTime, extractors);
}
/**
* 获取挂载文件/的空间利用率
* @param initialMountPointInfo
* @return
*/
@Override
public Map<String, Object> spaceRateEcharts(InitialMountPointInfo initialMountPointInfo) {
List<InitialMountPointInfo> list = initialMountPointInfoMapper.selectInitialMountPointInfoList(initialMountPointInfo);
Map<String, Function<InitialMountPointInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("vfsUtilData", InitialMountPointInfo::getVfsUtil);
return EchartsDataUtils.buildEchartsData(list,InitialMountPointInfo::getCreateTime, extractors);
}
}
@@ -1,147 +0,0 @@
package com.ruoyi.rocketmq.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.rocketmq.domain.InitialSwitchInfo;
import com.ruoyi.rocketmq.mapper.InitialSwitchInfoMapper;
import com.ruoyi.rocketmq.service.IInitialSwitchInfoService;
import com.ruoyi.rocketmq.utils.EchartsDataUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* 交换机流量监控信息Service业务层处理
*
* @author gyt
* @date 2025-08-25
*/
@Service
@Slf4j
public class InitialSwitchInfoServiceImpl implements IInitialSwitchInfoService
{
@Autowired
private InitialSwitchInfoMapper initialSwitchInfoMapper;
/**
* 查询交换机流量监控信息
*
* @param id 交换机流量监控信息主键
* @return 交换机流量监控信息
*/
@Override
public InitialSwitchInfo selectInitialSwitchInfoById(Long id)
{
return initialSwitchInfoMapper.selectInitialSwitchInfoById(id);
}
/**
* 查询交换机流量监控信息列表
*
* @param initialSwitchInfo 交换机流量监控信息
* @return 交换机流量监控信息
*/
@Override
public List<InitialSwitchInfo> selectInitialSwitchInfoList(InitialSwitchInfo initialSwitchInfo)
{
return initialSwitchInfoMapper.selectInitialSwitchInfoList(initialSwitchInfo);
}
/**
* 新增交换机流量监控信息
*
* @param initialSwitchInfo 交换机流量监控信息
* @return 结果
*/
@Override
public int insertInitialSwitchInfo(InitialSwitchInfo initialSwitchInfo)
{
initialSwitchInfo.setCreateTime(DateUtils.getNowDate());
return initialSwitchInfoMapper.insertInitialSwitchInfo(initialSwitchInfo);
}
/**
* 修改交换机流量监控信息
*
* @param initialSwitchInfo 交换机流量监控信息
* @return 结果
*/
@Override
public int updateInitialSwitchInfo(InitialSwitchInfo initialSwitchInfo)
{
initialSwitchInfo.setUpdateTime(DateUtils.getNowDate());
return initialSwitchInfoMapper.updateInitialSwitchInfo(initialSwitchInfo);
}
/**
* 批量删除交换机流量监控信息
*
* @param ids 需要删除的交换机流量监控信息主键
* @return 结果
*/
@Override
public int deleteInitialSwitchInfoByIds(Long[] ids)
{
return initialSwitchInfoMapper.deleteInitialSwitchInfoByIds(ids);
}
/**
* 删除交换机流量监控信息信息
*
* @param id 交换机流量监控信息主键
* @return 结果
*/
@Override
public int deleteInitialSwitchInfoById(Long id)
{
return initialSwitchInfoMapper.deleteInitialSwitchInfoById(id);
}
/**
* 批量新增交换机流量监控信息
*
* @param list 交换机流量监控信息集合
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
public int batchInsertInitialSwitchInfo(List<InitialSwitchInfo> list) {
try {
return initialSwitchInfoMapper.batchInsertInitialSwitchInfo(list);
}catch (Exception e){
log.error("批量插入交换机信息失败,失败数量:{}", list.size(), e);
throw new RuntimeException("批量保存失败",e);
}
}
/**
* 获取交换机网络端口的基础信息
* @param initialSwitchInfo
* @return
*/
@Override
public InitialSwitchInfo getSwitchNetDetailsMsg(InitialSwitchInfo initialSwitchInfo) {
return initialSwitchInfoMapper.getSwitchNetDetailsMsg(initialSwitchInfo);
}
/**
* 获取交换机网口网络速率
* @param initialSwitchInfo
* @return
*/
@Override
public Map<String, Object> switchNetSpeedEcharts(InitialSwitchInfo initialSwitchInfo) {
List<InitialSwitchInfo> list = initialSwitchInfoMapper.selectInitialSwitchInfoList(initialSwitchInfo);
Map<String, Function<InitialSwitchInfo, ?>> extractors = new LinkedHashMap<>();
extractors.put("netInSpeedData", info -> info.getInSpeed());
extractors.put("netOutSpeedData", info -> info.getOutSpeed());
return EchartsDataUtils.buildEchartsData(list, InitialSwitchInfo::getCreateTime, extractors);
}
}
@@ -1,106 +0,0 @@
package com.ruoyi.rocketmq.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.rocketmq.domain.InitialSwitchMpuInfo;
import com.ruoyi.rocketmq.mapper.InitialSwitchMpuInfoMapper;
import com.ruoyi.rocketmq.service.IInitialSwitchMpuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* MPU信息Service业务层处理
*
* @author gyt
* @date 2025-09-22
*/
@Service
public class InitialSwitchMpuInfoServiceImpl implements IInitialSwitchMpuInfoService
{
@Autowired
private InitialSwitchMpuInfoMapper initialSwitchMpuInfoMapper;
/**
* 查询MPU信息
*
* @param id MPU信息主键
* @return MPU信息
*/
@Override
public InitialSwitchMpuInfo selectInitialSwitchMpuInfoById(Long id)
{
return initialSwitchMpuInfoMapper.selectInitialSwitchMpuInfoById(id);
}
/**
* 查询MPU信息列表
*
* @param initialSwitchMpuInfo MPU信息
* @return MPU信息
*/
@Override
public List<InitialSwitchMpuInfo> selectInitialSwitchMpuInfoList(InitialSwitchMpuInfo initialSwitchMpuInfo)
{
return initialSwitchMpuInfoMapper.selectInitialSwitchMpuInfoList(initialSwitchMpuInfo);
}
/**
* 新增MPU信息
*
* @param initialSwitchMpuInfo MPU信息
* @return 结果
*/
@Override
public int insertInitialSwitchMpuInfo(InitialSwitchMpuInfo initialSwitchMpuInfo)
{
return initialSwitchMpuInfoMapper.insertInitialSwitchMpuInfo(initialSwitchMpuInfo);
}
/**
* 修改MPU信息
*
* @param initialSwitchMpuInfo MPU信息
* @return 结果
*/
@Override
public int updateInitialSwitchMpuInfo(InitialSwitchMpuInfo initialSwitchMpuInfo)
{
initialSwitchMpuInfo.setUpdateTime(DateUtils.getNowDate());
return initialSwitchMpuInfoMapper.updateInitialSwitchMpuInfo(initialSwitchMpuInfo);
}
/**
* 批量删除MPU信息
*
* @param ids 需要删除的MPU信息主键
* @return 结果
*/
@Override
public int deleteInitialSwitchMpuInfoByIds(Long[] ids)
{
return initialSwitchMpuInfoMapper.deleteInitialSwitchMpuInfoByIds(ids);
}
/**
* 删除MPU信息信息
*
* @param id MPU信息主键
* @return 结果
*/
@Override
public int deleteInitialSwitchMpuInfoById(Long id)
{
return initialSwitchMpuInfoMapper.deleteInitialSwitchMpuInfoById(id);
}
/**
* 批量新增mpu信息
* @param list
* @return
*/
@Override
public int insertBatchInitialSwitchMpuInfo(List<InitialSwitchMpuInfo> list) {
return initialSwitchMpuInfoMapper.insertBatchInitialSwitchMpuInfo(list);
}
}
@@ -1,105 +0,0 @@
package com.ruoyi.rocketmq.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.rocketmq.domain.InitialSwitchOpticalModule;
import com.ruoyi.rocketmq.mapper.InitialSwitchOpticalModuleMapper;
import com.ruoyi.rocketmq.service.IInitialSwitchOpticalModuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 光模块信息Service业务层处理
*
* @author gyt
* @date 2025-09-22
*/
@Service
public class InitialSwitchOpticalModuleServiceImpl implements IInitialSwitchOpticalModuleService
{
@Autowired
private InitialSwitchOpticalModuleMapper initialSwitchOpticalModuleMapper;
/**
* 查询光模块信息
*
* @param id 光模块信息主键
* @return 光模块信息
*/
@Override
public InitialSwitchOpticalModule selectInitialSwitchOpticalModuleById(Long id)
{
return initialSwitchOpticalModuleMapper.selectInitialSwitchOpticalModuleById(id);
}
/**
* 查询光模块信息列表
*
* @param initialSwitchOpticalModule 光模块信息
* @return 光模块信息
*/
@Override
public List<InitialSwitchOpticalModule> selectInitialSwitchOpticalModuleList(InitialSwitchOpticalModule initialSwitchOpticalModule)
{
return initialSwitchOpticalModuleMapper.selectInitialSwitchOpticalModuleList(initialSwitchOpticalModule);
}
/**
* 新增光模块信息
*
* @param initialSwitchOpticalModule 光模块信息
* @return 结果
*/
@Override
public int insertInitialSwitchOpticalModule(InitialSwitchOpticalModule initialSwitchOpticalModule)
{
return initialSwitchOpticalModuleMapper.insertInitialSwitchOpticalModule(initialSwitchOpticalModule);
}
/**
* 修改光模块信息
*
* @param initialSwitchOpticalModule 光模块信息
* @return 结果
*/
@Override
public int updateInitialSwitchOpticalModule(InitialSwitchOpticalModule initialSwitchOpticalModule)
{
initialSwitchOpticalModule.setUpdateTime(DateUtils.getNowDate());
return initialSwitchOpticalModuleMapper.updateInitialSwitchOpticalModule(initialSwitchOpticalModule);
}
/**
* 批量删除光模块信息
*
* @param ids 需要删除的光模块信息主键
* @return 结果
*/
@Override
public int deleteInitialSwitchOpticalModuleByIds(Long[] ids)
{
return initialSwitchOpticalModuleMapper.deleteInitialSwitchOpticalModuleByIds(ids);
}
/**
* 删除光模块信息信息
*
* @param id 光模块信息主键
* @return 结果
*/
@Override
public int deleteInitialSwitchOpticalModuleById(Long id)
{
return initialSwitchOpticalModuleMapper.deleteInitialSwitchOpticalModuleById(id);
}
/**
* 批量新增光模块信息
* @param list
*/
@Override
public int batchInitialSwitchOpticalModule(List<InitialSwitchOpticalModule> list) {
return initialSwitchOpticalModuleMapper.batchInitialSwitchOpticalModule(list);
}
}
@@ -1,96 +0,0 @@
package com.ruoyi.rocketmq.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.rocketmq.domain.InitialSwitchOtherCollectData;
import com.ruoyi.rocketmq.mapper.InitialSwitchOtherCollectDataMapper;
import com.ruoyi.rocketmq.service.IInitialSwitchOtherCollectDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 交换机系统其他信息采集数据Service业务层处理
*
* @author gyt
* @date 2025-09-23
*/
@Service
public class InitialSwitchOtherCollectDataServiceImpl implements IInitialSwitchOtherCollectDataService
{
@Autowired
private InitialSwitchOtherCollectDataMapper initialSwitchOtherCollectDataMapper;
/**
* 查询交换机系统其他信息采集数据
*
* @param id 交换机系统其他信息采集数据主键
* @return 交换机系统其他信息采集数据
*/
@Override
public InitialSwitchOtherCollectData selectInitialSwitchOtherCollectDataById(Long id)
{
return initialSwitchOtherCollectDataMapper.selectInitialSwitchOtherCollectDataById(id);
}
/**
* 查询交换机系统其他信息采集数据列表
*
* @param initialSwitchOtherCollectData 交换机系统其他信息采集数据
* @return 交换机系统其他信息采集数据
*/
@Override
public List<InitialSwitchOtherCollectData> selectInitialSwitchOtherCollectDataList(InitialSwitchOtherCollectData initialSwitchOtherCollectData)
{
return initialSwitchOtherCollectDataMapper.selectInitialSwitchOtherCollectDataList(initialSwitchOtherCollectData);
}
/**
* 新增交换机系统其他信息采集数据
*
* @param initialSwitchOtherCollectData 交换机系统其他信息采集数据
* @return 结果
*/
@Override
public int insertInitialSwitchOtherCollectData(InitialSwitchOtherCollectData initialSwitchOtherCollectData)
{
return initialSwitchOtherCollectDataMapper.insertInitialSwitchOtherCollectData(initialSwitchOtherCollectData);
}
/**
* 修改交换机系统其他信息采集数据
*
* @param initialSwitchOtherCollectData 交换机系统其他信息采集数据
* @return 结果
*/
@Override
public int updateInitialSwitchOtherCollectData(InitialSwitchOtherCollectData initialSwitchOtherCollectData)
{
initialSwitchOtherCollectData.setUpdateTime(DateUtils.getNowDate());
return initialSwitchOtherCollectDataMapper.updateInitialSwitchOtherCollectData(initialSwitchOtherCollectData);
}
/**
* 批量删除交换机系统其他信息采集数据
*
* @param ids 需要删除的交换机系统其他信息采集数据主键
* @return 结果
*/
@Override
public int deleteInitialSwitchOtherCollectDataByIds(Long[] ids)
{
return initialSwitchOtherCollectDataMapper.deleteInitialSwitchOtherCollectDataByIds(ids);
}
/**
* 删除交换机系统其他信息采集数据信息
*
* @param id 交换机系统其他信息采集数据主键
* @return 结果
*/
@Override
public int deleteInitialSwitchOtherCollectDataById(Long id)
{
return initialSwitchOtherCollectDataMapper.deleteInitialSwitchOtherCollectDataById(id);
}
}
@@ -1,96 +0,0 @@
package com.ruoyi.rocketmq.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.rocketmq.domain.InitialSystemOtherCollectData;
import com.ruoyi.rocketmq.mapper.InitialSystemOtherCollectDataMapper;
import com.ruoyi.rocketmq.service.IInitialSystemOtherCollectDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 交换机系统其他信息采集数据Service业务层处理
*
* @author gyt
* @date 2025-09-23
*/
@Service
public class InitialSystemOtherCollectDataServiceImpl implements IInitialSystemOtherCollectDataService
{
@Autowired
private InitialSystemOtherCollectDataMapper initialSystemOtherCollectDataMapper;
/**
* 查询交换机系统其他信息采集数据
*
* @param id 交换机系统其他信息采集数据主键
* @return 交换机系统其他信息采集数据
*/
@Override
public InitialSystemOtherCollectData selectInitialSystemOtherCollectDataById(Long id)
{
return initialSystemOtherCollectDataMapper.selectInitialSystemOtherCollectDataById(id);
}
/**
* 查询交换机系统其他信息采集数据列表
*
* @param initialSystemOtherCollectData 交换机系统其他信息采集数据
* @return 交换机系统其他信息采集数据
*/
@Override
public List<InitialSystemOtherCollectData> selectInitialSystemOtherCollectDataList(InitialSystemOtherCollectData initialSystemOtherCollectData)
{
return initialSystemOtherCollectDataMapper.selectInitialSystemOtherCollectDataList(initialSystemOtherCollectData);
}
/**
* 新增交换机系统其他信息采集数据
*
* @param initialSystemOtherCollectData 交换机系统其他信息采集数据
* @return 结果
*/
@Override
public int insertInitialSystemOtherCollectData(InitialSystemOtherCollectData initialSystemOtherCollectData)
{
return initialSystemOtherCollectDataMapper.insertInitialSystemOtherCollectData(initialSystemOtherCollectData);
}
/**
* 修改交换机系统其他信息采集数据
*
* @param initialSystemOtherCollectData 交换机系统其他信息采集数据
* @return 结果
*/
@Override
public int updateInitialSystemOtherCollectData(InitialSystemOtherCollectData initialSystemOtherCollectData)
{
initialSystemOtherCollectData.setUpdateTime(DateUtils.getNowDate());
return initialSystemOtherCollectDataMapper.updateInitialSystemOtherCollectData(initialSystemOtherCollectData);
}
/**
* 批量删除交换机系统其他信息采集数据
*
* @param ids 需要删除的交换机系统其他信息采集数据主键
* @return 结果
*/
@Override
public int deleteInitialSystemOtherCollectDataByIds(Long[] ids)
{
return initialSystemOtherCollectDataMapper.deleteInitialSystemOtherCollectDataByIds(ids);
}
/**
* 删除交换机系统其他信息采集数据信息
*
* @param id 交换机系统其他信息采集数据主键
* @return 结果
*/
@Override
public int deleteInitialSystemOtherCollectDataById(Long id)
{
return initialSystemOtherCollectDataMapper.deleteInitialSystemOtherCollectDataById(id);
}
}
@@ -1,190 +0,0 @@
package com.ruoyi.rocketmq.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.enums.MsgEnum;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.rocketmq.domain.DeviceMessage;
import com.ruoyi.rocketmq.domain.RmAgentManagement;
import com.ruoyi.rocketmq.domain.vo.AgentUpdateVo;
import com.ruoyi.rocketmq.mapper.RmAgentManagementMapper;
import com.ruoyi.rocketmq.model.ProducerMode;
import com.ruoyi.rocketmq.producer.MessageProducer;
import com.ruoyi.rocketmq.service.IRmAgentManagementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* Agent管理Service业务层处理
*
* @author gyt
* @date 2025-09-15
*/
@Service
@Slf4j
public class RmAgentManagementServiceImpl implements IRmAgentManagementService
{
@Autowired
private RmAgentManagementMapper rmAgentManagementMapper;
@Value("${fileDictory.filePath}")
private String filePath;
// private static String COMMAND = "nohup /usr/local/tongran/deploy.sh restart > /dev/null 2>&1 &";
private static String COMMAND = "nohup /data/saas-income/houduan/tr-client-test/deploy.sh restart > /dev/null 2>&1 &";
@Autowired
private ProducerMode producerMode;
/**
* 查询Agent管理
*
* @param id Agent管理主键
* @return Agent管理
*/
@Override
public RmAgentManagement selectRmAgentManagementById(Long id)
{
return rmAgentManagementMapper.selectRmAgentManagementById(id);
}
/**
* 查询Agent管理列表
*
* @param rmAgentManagement Agent管理
* @return Agent管理
*/
@Override
public List<RmAgentManagement> selectRmAgentManagementList(RmAgentManagement rmAgentManagement)
{
return rmAgentManagementMapper.selectRmAgentManagementList(rmAgentManagement);
}
/**
* 新增Agent管理
*
* @param rmAgentManagement Agent管理
* @return 结果
*/
@Override
public int insertRmAgentManagement(RmAgentManagement rmAgentManagement)
{
rmAgentManagement.setCreateTime(DateUtils.getNowDate());
return rmAgentManagementMapper.insertRmAgentManagement(rmAgentManagement);
}
/**
* 修改Agent管理
*
* @param rmAgentManagement Agent管理
* @return 结果
*/
@Override
public int updateRmAgentManagement(RmAgentManagement rmAgentManagement)
{
rmAgentManagement.setUpdateTime(DateUtils.getNowDate());
processAgentUpdateData(rmAgentManagement);
return 1;
}
/**
* 保存最后更新结果
*
* @param rmAgentManagement Agent管理
* @return 结果
*/
public void updateRmAgentManagementByHardwareSn(RmAgentManagement rmAgentManagement){
rmAgentManagementMapper.updateRmAgentManagementBySn(rmAgentManagement);
}
/**
* 批量删除Agent管理
*
* @param ids 需要删除的Agent管理主键
* @return 结果
*/
@Override
public int deleteRmAgentManagementByIds(Long[] ids)
{
return rmAgentManagementMapper.deleteRmAgentManagementByIds(ids);
}
/**
* 删除Agent管理信息
*
* @param id Agent管理主键
* @return 结果
*/
@Override
public int deleteRmAgentManagementById(Long id)
{
return rmAgentManagementMapper.deleteRmAgentManagementById(id);
}
/**
* 配置更新策略
* @param rmAgentManagement
* @return
*/
@Override
public int addRmAgentManagement(RmAgentManagement rmAgentManagement) {
processAgentUpdateData(rmAgentManagement);
return 1;
}
/**
* 处理agen更新数据
* @param rmAgentManagement
*/
public void processAgentUpdateData(RmAgentManagement rmAgentManagement){
// 查询该资源是否已经配置
RmAgentManagement agentQueryParam = new RmAgentManagement();
agentQueryParam.setHardwareSn(rmAgentManagement.getHardwareSn());
List<RmAgentManagement> agentManagements = rmAgentManagementMapper.selectRmAgentManagementList(agentQueryParam);
if(!agentManagements.isEmpty()){
// 如果存在,修改
rmAgentManagement.setLastUpdateTime(DateUtils.getNowDate());
if("0".equals(rmAgentManagement.getMethod())){
rmAgentManagement.setScheduledUpdateTime(null);
}
rmAgentManagementMapper.updateRmAgentManagementBySn(rmAgentManagement);
}else{
// 如果不存在,添加
rmAgentManagement.setLastUpdateTime(DateUtils.getNowDate());
if("0".equals(rmAgentManagement.getMethod())){
rmAgentManagement.setScheduledUpdateTime(null);
}
rmAgentManagementMapper.insertRmAgentManagement(rmAgentManagement);
}
// 构建更新策略
AgentUpdateVo agentUpdateVo = new AgentUpdateVo();
agentUpdateVo.setFileUrl(rmAgentManagement.getFileUrl());
agentUpdateVo.setFilePath(filePath);
List<String> commandList = new ArrayList<>();
commandList.add(COMMAND);
agentUpdateVo.setCommands(JSONObject.toJSONString(commandList));
agentUpdateVo.setMethod(rmAgentManagement.getMethod());
if(rmAgentManagement.getMethod() == 1){
Date scheduledUpdateTime = rmAgentManagement.getScheduledUpdateTime();
long scheduledTime = scheduledUpdateTime.toInstant().getEpochSecond();
agentUpdateVo.setPolicyTime(scheduledTime);
}
try {
DeviceMessage deviceMessage = new DeviceMessage();
deviceMessage.setClientId(rmAgentManagement.getHardwareSn());
deviceMessage.setDataType(MsgEnum.Agent版本更新.getValue());
deviceMessage.setData(JSONObject.toJSONString(agentUpdateVo));
MessageProducer messageProducer = new MessageProducer();
messageProducer.sendAsyncProducerMessage(
producerMode.getAgentTopic(),
"",
"",
JSONObject.toJSONString(deviceMessage)
);
} catch (Exception e) {
log.error("发送设备配置失败,deviceId: {}", rmAgentManagement.getHardwareSn(), e);
}
}
}
@@ -1,143 +0,0 @@
package com.ruoyi.rocketmq.utils;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.rocketmq.domain.RmTemplateLinux;
import com.ruoyi.rocketmq.domain.RmTemplateSwitch;
import com.ruoyi.rocketmq.mapper.RmTemplateLinuxMapper;
import com.ruoyi.rocketmq.mapper.RmTemplateSwitchMapper;
import com.ruoyi.system.api.RemoteRevenueConfigService;
import com.ruoyi.system.api.domain.RmResourceGroupRemote;
import com.ruoyi.system.api.domain.RmResourceRegistrationRemote;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Component
public class DataProcessUtil {
@Autowired
private RmTemplateLinuxMapper rmTemplateLinuxMapper;
@Autowired
private RmTemplateSwitchMapper rmTemplateSwitchMapper;
@Autowired
private RemoteRevenueConfigService remoteRevenueConfigService;
/**
* 补充资源组信息
*/
public String getResourceGroupNameById(Long resourceGroupId) {
try {
R<RmResourceGroupRemote> resourceGroupResponse = remoteRevenueConfigService
.getResourceGroupMsgById(resourceGroupId, SecurityConstants.INNER);
if (resourceGroupResponse != null && resourceGroupResponse.getData() != null) {
return resourceGroupResponse.getData().getGroupName();
}
} catch (Exception e) {
log.error("获取资源组信息失败,resourceGroupId: {}", resourceGroupId, e);
}
return null;
}
/**
* 资源组信息
*/
public RmResourceGroupRemote getResourceMsgById(Long resourceGroupId) {
try {
R<RmResourceGroupRemote> resourceGroupResponse = remoteRevenueConfigService
.getResourceGroupMsgById(resourceGroupId, SecurityConstants.INNER);
if (resourceGroupResponse != null && resourceGroupResponse.getData() != null) {
return resourceGroupResponse.getData();
}
} catch (Exception e) {
log.error("获取资源信息失败,resourceGroupId: {}", resourceGroupId, e);
}
return null;
}
/**
* 处理Linux模板数据
*/
public void processLinuxTemplateData(Long templateId, Map<String, Object> result) {
RmTemplateLinux query = new RmTemplateLinux();
query.setTemplateId(templateId);
List<RmTemplateLinux> linuxItems = rmTemplateLinuxMapper.selectRmTemplateLinuxList(query);
if (!linuxItems.isEmpty()) {
Map<String, List<RmTemplateLinux>> linuxData = new HashMap<>();
linuxData.put("cpu", filterItemsByDataType(linuxItems, "CPU"));
linuxData.put("other", filterItemsByDataType(linuxItems, "OTHER"));
linuxData.put("vfs", filterItemsByDataType(linuxItems, "POINT"));
linuxData.put("net", filterItemsByDataType(linuxItems, "NET"));
linuxData.put("disk", filterItemsByDataType(linuxItems, "DISK"));
linuxData.put("docker", filterItemsByDataType(linuxItems, "DOCKER"));
result.put("linux", linuxData);
result.put("resourceType", "linux");
}
}
/**
* 处理Switch模板数据
*/
public void processSwitchTemplateData(Long templateId, Map<String, Object> result) {
RmTemplateSwitch query = new RmTemplateSwitch();
query.setTemplateId(templateId);
List<RmTemplateSwitch> switchItems = rmTemplateSwitchMapper.selectRmTemplateSwitchList(query);
if (!switchItems.isEmpty()) {
Map<String, List<RmTemplateSwitch>> switchData = new HashMap<>();
switchData.put("switchOther", filterItemsByDataType(switchItems, "SYSTEM"));
switchData.put("switchMpu", filterItemsByDataType(switchItems, "MPU"));
switchData.put("switchPwr", filterItemsByDataType(switchItems, "POWERSOURCE"));
switchData.put("switchNet", filterItemsByDataType(switchItems, "NETPORT"));
switchData.put("switchModule", filterItemsByDataType(switchItems, "LIGHTMODULE"));
switchData.put("switchFan", filterItemsByDataType(switchItems, "FAN"));
result.put("switch", switchData);
result.put("resourceType", "switch");
}
}
/**
* 通用过滤方法
*/
public static <T> List<T> filterItemsByDataType(List<T> items, String dataType) {
return items.stream()
.filter(item -> {
try {
Field dataTypeField = item.getClass().getDeclaredField("dataType");
dataTypeField.setAccessible(true);
return dataType.equals(dataTypeField.get(item));
} catch (Exception e) {
return false;
}
})
.collect(Collectors.toList());
}
/**
* 获取资源设备列表
*/
public List<RmResourceRegistrationRemote> getResourceDevices(Long resourceGroupId) {
R<RmResourceGroupRemote> groupResponse = remoteRevenueConfigService
.getResourceGroupMsgById(resourceGroupId, SecurityConstants.INNER);
if (groupResponse == null || groupResponse.getData() == null
|| StringUtils.isEmpty(groupResponse.getData().getIncludedDevicesId())) {
log.error("资源组信息不完整,resourceGroupId: {}", resourceGroupId);
return Collections.emptyList();
}
String[] deviceIds = groupResponse.getData().getIncludedDevicesId().split(",");
R<List<RmResourceRegistrationRemote>> devicesResponse = remoteRevenueConfigService
.getRegistrationByIds(deviceIds, SecurityConstants.INNER);
return devicesResponse != null ? devicesResponse.getData() : Collections.emptyList();
}
}

Some files were not shown because too many files have changed in this diff Show More