源数据表+入库逻辑+计算95带宽值/日
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.system.config;
|
||||
|
||||
import com.ruoyi.system.domain.EpsInitialTrafficData;
|
||||
import com.ruoyi.system.domain.InitialSwitchInfoDetails;
|
||||
import com.ruoyi.system.service.EpsInitialTrafficDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -17,10 +19,18 @@ public class TableScheduleConfig {
|
||||
private EpsInitialTrafficDataService epsInitialTrafficDataService;
|
||||
|
||||
// 每月25号创建下月表
|
||||
@Scheduled(cron = "0 0 0 25 * ?")
|
||||
@Scheduled(cron = "0 0 0 26 * ?")
|
||||
// @Scheduled(initialDelay = 5000, fixedDelay = Long.MAX_VALUE)
|
||||
public void createNextMonthTables() {
|
||||
epsInitialTrafficDataService.createNextMonthTables();
|
||||
}
|
||||
|
||||
// 每天12点执行 计算95带宽值/日
|
||||
@Scheduled(cron = "0 0 0 * * ?", zone = "Asia/Shanghai")
|
||||
public void calculate95BandwidthDaily() {
|
||||
EpsInitialTrafficData queryParam = new EpsInitialTrafficData();
|
||||
epsInitialTrafficDataService.calculate95BandwidthDaily(queryParam);
|
||||
InitialSwitchInfoDetails initialSwitchInfoDetails = new InitialSwitchInfoDetails();
|
||||
epsInitialTrafficDataService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.system.domain.AllInterfaceName;
|
||||
import com.ruoyi.system.service.IAllInterfaceNameService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 所有接口名称Controller
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-08-25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/interfaceName")
|
||||
public class AllInterfaceNameController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IAllInterfaceNameService allInterfaceNameService;
|
||||
|
||||
/**
|
||||
* 查询所有接口名称列表
|
||||
*/
|
||||
@RequiresPermissions("system:interfaceName:list")
|
||||
@PostMapping("/getAllNames")
|
||||
public List<AllInterfaceName> list(@RequestBody AllInterfaceName allInterfaceName)
|
||||
{
|
||||
List<AllInterfaceName> list = allInterfaceNameService.selectAllInterfaceNameList(allInterfaceName);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -75,7 +75,6 @@ public class EpsServerRevenueConfigController extends BaseController
|
||||
/**
|
||||
* 流量相关数据入库
|
||||
*/
|
||||
@Log(title = "流量相关数据入库", businessType = BusinessType.EXPORT)
|
||||
@InnerAuth
|
||||
@PostMapping("/autoSaveServiceTrafficData")
|
||||
public R<String> autoSaveServiceTrafficData(@RequestBody EpsServerRevenueConfig epsServerRevenueConfig)
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
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.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.InitialSwitchInfoDetails;
|
||||
import com.ruoyi.system.service.IInitialSwitchInfoDetailsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交换机监控信息Controller
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-08-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/switchInfoDetails")
|
||||
public class InitialSwitchInfoDetailsController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IInitialSwitchInfoDetailsService initialSwitchInfoDetailsService;
|
||||
|
||||
/**
|
||||
* 查询交换机监控信息列表
|
||||
*/
|
||||
@RequiresPermissions("system:switchInfoDetails:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(InitialSwitchInfoDetails initialSwitchInfoDetails)
|
||||
{
|
||||
startPage();
|
||||
List<InitialSwitchInfoDetails> list = initialSwitchInfoDetailsService.selectInitialSwitchInfoDetailsList(initialSwitchInfoDetails);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出交换机监控信息列表
|
||||
*/
|
||||
@RequiresPermissions("system:switchInfoDetails:export")
|
||||
@Log(title = "交换机监控信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, InitialSwitchInfoDetails initialSwitchInfoDetails)
|
||||
{
|
||||
List<InitialSwitchInfoDetails> list = initialSwitchInfoDetailsService.selectInitialSwitchInfoDetailsList(initialSwitchInfoDetails);
|
||||
ExcelUtil<InitialSwitchInfoDetails> util = new ExcelUtil<InitialSwitchInfoDetails>(InitialSwitchInfoDetails.class);
|
||||
util.exportExcel(response, list, "交换机监控信息数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取交换机监控信息详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:switchInfoDetails:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(initialSwitchInfoDetailsService.selectInitialSwitchInfoDetailsById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增交换机监控信息
|
||||
*/
|
||||
@RequiresPermissions("system:switchInfoDetails:add")
|
||||
@Log(title = "交换机监控信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody InitialSwitchInfoDetails initialSwitchInfoDetails)
|
||||
{
|
||||
return toAjax(initialSwitchInfoDetailsService.insertInitialSwitchInfoDetails(initialSwitchInfoDetails));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改交换机监控信息
|
||||
*/
|
||||
@RequiresPermissions("system:switchInfoDetails:edit")
|
||||
@Log(title = "交换机监控信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody InitialSwitchInfoDetails initialSwitchInfoDetails)
|
||||
{
|
||||
return toAjax(initialSwitchInfoDetailsService.updateInitialSwitchInfoDetails(initialSwitchInfoDetails));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除交换机监控信息
|
||||
*/
|
||||
@RequiresPermissions("system:switchInfoDetails:remove")
|
||||
@Log(title = "交换机监控信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(initialSwitchInfoDetailsService.deleteInitialSwitchInfoDetailsByIds(ids));
|
||||
}
|
||||
/**
|
||||
* 交换机流量相关数据入库
|
||||
*/
|
||||
@InnerAuth
|
||||
@PostMapping("/autoSaveSwitchTraffic")
|
||||
public R<String> autoSaveSwitchTraffic(@RequestBody InitialSwitchInfoDetails initialSwitchInfoDetails)
|
||||
{
|
||||
return initialSwitchInfoDetailsService.autoSaveSwitchTraffic(initialSwitchInfoDetails);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 所有接口名称对象 all_interface_name
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-08-25
|
||||
*/
|
||||
@Data
|
||||
public class AllInterfaceName extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 客户端唯一标识 */
|
||||
@Excel(name = "客户端唯一标识")
|
||||
private String clientId;
|
||||
|
||||
/** 接口名称 */
|
||||
@Excel(name = "接口名称")
|
||||
private String interfaceName;
|
||||
|
||||
/** 设备序列号 */
|
||||
@Excel(name = "设备序列号")
|
||||
private String deviceSn;
|
||||
|
||||
/** 节点名称 */
|
||||
@Excel(name = "节点名称")
|
||||
private String nodeName;
|
||||
|
||||
/** 业务代码 */
|
||||
@Excel(name = "业务代码")
|
||||
private String businessCode;
|
||||
|
||||
/** 业务名称 */
|
||||
@Excel(name = "业务名称")
|
||||
private String businessName;
|
||||
|
||||
/** 资源类型 */
|
||||
@Excel(name = "资源类型")
|
||||
private String resourceType;
|
||||
|
||||
/** 交换机名称 */
|
||||
@Excel(name = "交换机名称")
|
||||
private String switchName;
|
||||
|
||||
/** 接口连接设备类型 */
|
||||
@Excel(name = "接口连接设备类型")
|
||||
private String interfaceDeviceType;
|
||||
|
||||
/** 服务器网口 */
|
||||
@Excel(name = "服务器网口")
|
||||
private String serverPort;
|
||||
|
||||
/** 交换机硬件SN */
|
||||
@Excel(name = "交换机硬件SN")
|
||||
private String switchSn;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.ruoyi.system.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_switch_info_details
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-08-26
|
||||
*/
|
||||
@Data
|
||||
public class InitialSwitchInfoDetails extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 自增主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 客户端ID */
|
||||
@Excel(name = "客户端ID")
|
||||
private String clientId;
|
||||
|
||||
/** 网络接口名称(如eth0、ens33等) */
|
||||
@Excel(name = "网络接口名称(如eth0、ens33等)")
|
||||
private String name;
|
||||
|
||||
/** 接收流量(字节) */
|
||||
@Excel(name = "接收流量(字节)")
|
||||
private BigDecimal inBytes;
|
||||
|
||||
/** 发送流量(字节) */
|
||||
@Excel(name = "发送流量(字节)")
|
||||
private BigDecimal outBytes;
|
||||
|
||||
/** 接口状态(up/down等) */
|
||||
@Excel(name = "接口状态(up/down等)")
|
||||
private String status;
|
||||
|
||||
/** 接口类型(ethernet/wireless等) */
|
||||
@Excel(name = "接口类型(ethernet/wireless等)")
|
||||
private String type;
|
||||
|
||||
/** 接收流量(bytes/s) */
|
||||
@Excel(name = "接收流量", readConverterExp = "b=ytes/s")
|
||||
private BigDecimal inSpeed;
|
||||
|
||||
/** 发送流量(bytes/s) */
|
||||
@Excel(name = "发送流量", readConverterExp = "b=ytes/s")
|
||||
private BigDecimal outSpeed;
|
||||
|
||||
/** 交换机名称 */
|
||||
@Excel(name = "交换机名称")
|
||||
private String switchName;
|
||||
|
||||
/** 接口连接设备类型 */
|
||||
@Excel(name = "接口连接设备类型")
|
||||
private String interfaceDeviceType;
|
||||
|
||||
/** 服务器名称 */
|
||||
@Excel(name = "服务器名称")
|
||||
private String serverName;
|
||||
|
||||
/** 服务器网口 */
|
||||
@Excel(name = "服务器网口")
|
||||
private String serverPort;
|
||||
|
||||
/** 服务器硬件SN */
|
||||
@Excel(name = "服务器硬件SN")
|
||||
private String serverSn;
|
||||
|
||||
/** 交换机硬件SN */
|
||||
@Excel(name = "交换机硬件SN")
|
||||
private String switchSn;
|
||||
/** 数据集合 */
|
||||
private List<InitialSwitchInfoDetails> dataList;
|
||||
|
||||
private String startTime;
|
||||
|
||||
private String endTime;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.system.domain.AllInterfaceName;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 所有接口名称Mapper接口
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-08-25
|
||||
*/
|
||||
public interface AllInterfaceNameMapper
|
||||
{
|
||||
/**
|
||||
* 查询所有接口名称
|
||||
*
|
||||
* @param id 所有接口名称主键
|
||||
* @return 所有接口名称
|
||||
*/
|
||||
public AllInterfaceName selectAllInterfaceNameById(Long id);
|
||||
|
||||
/**
|
||||
* 查询所有接口名称列表
|
||||
*
|
||||
* @param allInterfaceName 所有接口名称
|
||||
* @return 所有接口名称集合
|
||||
*/
|
||||
public List<AllInterfaceName> selectAllInterfaceNameList(AllInterfaceName allInterfaceName);
|
||||
|
||||
/**
|
||||
* 新增所有接口名称
|
||||
*
|
||||
* @param allInterfaceName 所有接口名称
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAllInterfaceName(AllInterfaceName allInterfaceName);
|
||||
|
||||
/**
|
||||
* 修改所有接口名称
|
||||
*
|
||||
* @param allInterfaceName 所有接口名称
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAllInterfaceName(AllInterfaceName allInterfaceName);
|
||||
|
||||
/**
|
||||
* 删除所有接口名称
|
||||
*
|
||||
* @param id 所有接口名称主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAllInterfaceNameById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除所有接口名称
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAllInterfaceNameByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 根据接口名称查询表中是否存在信息
|
||||
* @param names
|
||||
* @return
|
||||
*/
|
||||
List<AllInterfaceName> selectByNames(Set<String> names);
|
||||
|
||||
/**
|
||||
* 批量插入接口名称
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
int batchInsert(@Param("list") List<AllInterfaceName> list);
|
||||
/**
|
||||
* 查询所有服务器sn
|
||||
* @param interfaceName
|
||||
* @return
|
||||
*/
|
||||
List<AllInterfaceName> getAllDeviceSn(AllInterfaceName interfaceName);
|
||||
/**
|
||||
* 查询所有交换机sn
|
||||
* @param interfaceName
|
||||
* @return
|
||||
*/
|
||||
List<AllInterfaceName> getAllSwitchSn(AllInterfaceName interfaceName);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.system.domain.InitialSwitchInfoDetails;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交换机监控信息Mapper接口
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-08-26
|
||||
*/
|
||||
public interface InitialSwitchInfoDetailsMapper
|
||||
{
|
||||
/**
|
||||
* 查询交换机监控信息
|
||||
*
|
||||
* @param id 交换机监控信息主键
|
||||
* @return 交换机监控信息
|
||||
*/
|
||||
public InitialSwitchInfoDetails selectInitialSwitchInfoDetailsById(Long id);
|
||||
|
||||
/**
|
||||
* 查询交换机监控信息列表
|
||||
*
|
||||
* @param initialSwitchInfoDetails 交换机监控信息
|
||||
* @return 交换机监控信息集合
|
||||
*/
|
||||
public List<InitialSwitchInfoDetails> selectInitialSwitchInfoDetailsList(InitialSwitchInfoDetails initialSwitchInfoDetails);
|
||||
|
||||
/**
|
||||
* 新增交换机监控信息
|
||||
*
|
||||
* @param initialSwitchInfoDetails 交换机监控信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertInitialSwitchInfoDetails(InitialSwitchInfoDetails initialSwitchInfoDetails);
|
||||
|
||||
/**
|
||||
* 修改交换机监控信息
|
||||
*
|
||||
* @param initialSwitchInfoDetails 交换机监控信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateInitialSwitchInfoDetails(InitialSwitchInfoDetails initialSwitchInfoDetails);
|
||||
|
||||
/**
|
||||
* 删除交换机监控信息
|
||||
*
|
||||
* @param id 交换机监控信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteInitialSwitchInfoDetailsById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除交换机监控信息
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteInitialSwitchInfoDetailsByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 批量新增交换机流量业务数据
|
||||
* @param initialSwitchInfoDetails
|
||||
* @return
|
||||
*/
|
||||
int saveBatchSwitchTraffic(InitialSwitchInfoDetails initialSwitchInfoDetails);
|
||||
|
||||
/**
|
||||
* 查询交换机信息
|
||||
* @param initialSwitchInfoDetails
|
||||
* @return
|
||||
*/
|
||||
List<InitialSwitchInfoDetails> getAllSwitchInfoMsg(InitialSwitchInfoDetails initialSwitchInfoDetails);
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.RmEpsTopologyManagement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 拓扑管理Mapper接口
|
||||
*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.system.domain.EpsInitialTrafficData;
|
||||
import com.ruoyi.system.domain.InitialSwitchInfoDetails;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -39,5 +40,17 @@ public interface EpsInitialTrafficDataService {
|
||||
* @return 初始流量数据列表
|
||||
*/
|
||||
List<EpsInitialTrafficData> getAllTraficMsg(EpsInitialTrafficData queryParam);
|
||||
/**
|
||||
* 计算95带宽值
|
||||
* @param queryParam 查询参数实体
|
||||
* @return 流量数据列表
|
||||
*/
|
||||
void calculate95BandwidthDaily(EpsInitialTrafficData queryParam);
|
||||
/**
|
||||
* 计算交换机95带宽值
|
||||
* @param queryParam 查询参数实体
|
||||
* @return 流量数据列表
|
||||
*/
|
||||
void calculateSwitch95BandwidthDaily(InitialSwitchInfoDetails queryParam);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.system.domain.AllInterfaceName;
|
||||
|
||||
/**
|
||||
* 所有接口名称Service接口
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-08-25
|
||||
*/
|
||||
public interface IAllInterfaceNameService
|
||||
{
|
||||
/**
|
||||
* 查询所有接口名称
|
||||
*
|
||||
* @param id 所有接口名称主键
|
||||
* @return 所有接口名称
|
||||
*/
|
||||
public AllInterfaceName selectAllInterfaceNameById(Long id);
|
||||
|
||||
/**
|
||||
* 查询所有接口名称列表
|
||||
*
|
||||
* @param allInterfaceName 所有接口名称
|
||||
* @return 所有接口名称集合
|
||||
*/
|
||||
public List<AllInterfaceName> selectAllInterfaceNameList(AllInterfaceName allInterfaceName);
|
||||
|
||||
/**
|
||||
* 新增所有接口名称
|
||||
*
|
||||
* @param allInterfaceName 所有接口名称
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAllInterfaceName(AllInterfaceName allInterfaceName);
|
||||
|
||||
/**
|
||||
* 修改所有接口名称
|
||||
*
|
||||
* @param allInterfaceName 所有接口名称
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAllInterfaceName(AllInterfaceName allInterfaceName);
|
||||
|
||||
/**
|
||||
* 批量删除所有接口名称
|
||||
*
|
||||
* @param ids 需要删除的所有接口名称主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAllInterfaceNameByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除所有接口名称信息
|
||||
*
|
||||
* @param id 所有接口名称主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAllInterfaceNameById(Long id);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.system.domain.InitialSwitchInfoDetails;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 交换机监控信息Service接口
|
||||
*
|
||||
* @author gyt
|
||||
* @date 2025-08-26
|
||||
*/
|
||||
public interface IInitialSwitchInfoDetailsService
|
||||
{
|
||||
/**
|
||||
* 查询交换机监控信息
|
||||
*
|
||||
* @param id 交换机监控信息主键
|
||||
* @return 交换机监控信息
|
||||
*/
|
||||
public InitialSwitchInfoDetails selectInitialSwitchInfoDetailsById(Long id);
|
||||
|
||||
/**
|
||||
* 查询交换机监控信息列表
|
||||
*
|
||||
* @param initialSwitchInfoDetails 交换机监控信息
|
||||
* @return 交换机监控信息集合
|
||||
*/
|
||||
public List<InitialSwitchInfoDetails> selectInitialSwitchInfoDetailsList(InitialSwitchInfoDetails initialSwitchInfoDetails);
|
||||
|
||||
/**
|
||||
* 新增交换机监控信息
|
||||
*
|
||||
* @param initialSwitchInfoDetails 交换机监控信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertInitialSwitchInfoDetails(InitialSwitchInfoDetails initialSwitchInfoDetails);
|
||||
|
||||
/**
|
||||
* 修改交换机监控信息
|
||||
*
|
||||
* @param initialSwitchInfoDetails 交换机监控信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateInitialSwitchInfoDetails(InitialSwitchInfoDetails initialSwitchInfoDetails);
|
||||
|
||||
/**
|
||||
* 批量删除交换机监控信息
|
||||
*
|
||||
* @param ids 需要删除的交换机监控信息主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteInitialSwitchInfoDetailsByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除交换机监控信息信息
|
||||
*
|
||||
* @param id 交换机监控信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteInitialSwitchInfoDetailsById(Long id);
|
||||
/**
|
||||
* 保存交换机流量信息
|
||||
* @param initialSwitchInfoDetails
|
||||
*/
|
||||
R<String> autoSaveSwitchTraffic(InitialSwitchInfoDetails initialSwitchInfoDetails);
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.AllInterfaceNameMapper;
|
||||
import com.ruoyi.system.domain.AllInterfaceName;
|
||||
import com.ruoyi.system.service.IAllInterfaceNameService;
|
||||
|
||||
/**
|
||||
* 所有接口名称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);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,14 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.system.domain.AllInterfaceName;
|
||||
import com.ruoyi.system.domain.EpsInitialTrafficData;
|
||||
import com.ruoyi.system.domain.EpsNodeBandwidth;
|
||||
import com.ruoyi.system.domain.InitialSwitchInfoDetails;
|
||||
import com.ruoyi.system.mapper.AllInterfaceNameMapper;
|
||||
import com.ruoyi.system.mapper.EpsInitialTrafficDataMapper;
|
||||
import com.ruoyi.system.mapper.EpsNodeBandwidthMapper;
|
||||
import com.ruoyi.system.mapper.InitialSwitchInfoDetailsMapper;
|
||||
import com.ruoyi.system.service.EpsInitialTrafficDataService;
|
||||
import com.ruoyi.system.util.TableRouterUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -10,13 +17,15 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -24,8 +33,15 @@ import java.util.stream.Collectors;
|
||||
public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataService {
|
||||
|
||||
|
||||
private static final Pattern SPEED_PATTERN = Pattern.compile("(\\d+\\.?\\d*)\\s*(\\S*)");
|
||||
@Autowired
|
||||
private EpsInitialTrafficDataMapper epsInitialTrafficDataMapper;
|
||||
@Autowired
|
||||
private EpsNodeBandwidthMapper epsNodeBandwidthMapper;
|
||||
@Autowired
|
||||
private AllInterfaceNameMapper allInterfaceNameMapper;
|
||||
@Autowired
|
||||
private InitialSwitchInfoDetailsMapper initialSwitchInfoDetailsMapper;
|
||||
@Override
|
||||
public void createNextMonthTables() {
|
||||
LocalDate nextMonth = LocalDate.now().plusMonths(1);
|
||||
@@ -168,7 +184,6 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
|
||||
// 获取涉及的表名
|
||||
Set<String> tableNames = TableRouterUtil.getTableNamesBetweenInitial(queryParam.getStartTime(), queryParam.getEndTime());
|
||||
log.error("initial表名:{}",tableNames);
|
||||
// 并行查询各表
|
||||
return tableNames.parallelStream()
|
||||
.flatMap(tableName -> {
|
||||
@@ -182,4 +197,174 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate95BandwidthDaily(EpsInitialTrafficData queryParam) {
|
||||
Date now = DateUtils.getNowDate();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.HOUR_OF_DAY, -24);
|
||||
Date startDate = calendar.getTime();
|
||||
// 格式化时间
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String startTime = sdf.format(startDate);
|
||||
String endTime = sdf.format(now);
|
||||
queryParam.setStartTime(startTime);
|
||||
queryParam.setEndTime(endTime);
|
||||
queryParam.setRevenueMethod("1");
|
||||
// 查询所有的服务器sn
|
||||
AllInterfaceName allInterfaceName = new AllInterfaceName();
|
||||
List<AllInterfaceName> snList = allInterfaceNameMapper.getAllDeviceSn(allInterfaceName);
|
||||
for (AllInterfaceName interfaceName : snList) {
|
||||
queryParam.setServiceSn(interfaceName.getDeviceSn());
|
||||
// 查询原始数据
|
||||
List<EpsInitialTrafficData> dataList = query(queryParam);
|
||||
if(!dataList.isEmpty()){
|
||||
// 1. 提取 outSpeed 并转换为 Mbps
|
||||
List<BigDecimal> speedsInMbps = dataList.stream()
|
||||
.map(data -> parseSpeedToMbps(data.getOutSpeed()))
|
||||
.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);
|
||||
// 落入带宽计算结果表
|
||||
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
|
||||
bandwidth.setHardwareSn(epsInitialTrafficData.getServiceSn());
|
||||
bandwidth.setNodeName(epsInitialTrafficData.getNodeName());
|
||||
bandwidth.setBusinessId(epsInitialTrafficData.getBusinessId());
|
||||
bandwidth.setBusinessName(epsInitialTrafficData.getBusinessName());
|
||||
bandwidth.setResourceType("1");
|
||||
bandwidth.setBandwidthType("1");
|
||||
bandwidth.setBandwidthResult(dailyResult);
|
||||
bandwidth.setBandwidth95Daily(dailyResult);
|
||||
bandwidth.setCreateTime(startDate);
|
||||
epsNodeBandwidthMapper.insertEpsNodeBandwidth(bandwidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void calculateSwitch95BandwidthDaily(InitialSwitchInfoDetails queryParam) {
|
||||
Date now = DateUtils.getNowDate();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.HOUR_OF_DAY, -24);
|
||||
Date startDate = calendar.getTime();
|
||||
// 格式化时间
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String startTime = sdf.format(startDate);
|
||||
String endTime = sdf.format(now);
|
||||
queryParam.setStartTime(startTime);
|
||||
queryParam.setEndTime(endTime);
|
||||
// 查询所有的服务器sn
|
||||
AllInterfaceName allInterfaceName = new AllInterfaceName();
|
||||
List<AllInterfaceName> switchSnList = allInterfaceNameMapper.getAllSwitchSn(allInterfaceName);
|
||||
for (AllInterfaceName interfaceName : switchSnList) {
|
||||
queryParam.setSwitchSn(interfaceName.getSwitchSn());
|
||||
// 查询原始数据
|
||||
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper.selectInitialSwitchInfoDetailsList(queryParam);
|
||||
if(!dataList.isEmpty()){
|
||||
// 1. 提取 outSpeed 并转换为 Mbps
|
||||
List<BigDecimal> speedsInMbps = dataList.stream()
|
||||
.map(data -> {
|
||||
// 根据 type 选择 inSpeed 或 outSpeed
|
||||
String speed = ("1".equals(data.getInterfaceDeviceType())) ? data.getInSpeed()+"" : data.getOutSpeed()+"";
|
||||
// 如果 speed 是纯数字,补充单位 "B/S"(Bytes/s)
|
||||
if (speed.matches("^\\d+(\\.\\d+)?$")) {
|
||||
speed += " B/S";
|
||||
}
|
||||
return parseSpeedToMbps(speed);
|
||||
})
|
||||
.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);
|
||||
// 服务器信息
|
||||
InitialSwitchInfoDetails initialSwitchInfoDetails = dataList.get(0);
|
||||
// 落入带宽计算结果表
|
||||
EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
|
||||
bandwidth.setHardwareSn(initialSwitchInfoDetails.getServerSn());
|
||||
bandwidth.setNodeName(initialSwitchInfoDetails.getServerName());
|
||||
bandwidth.setResourceType("2");
|
||||
bandwidth.setBandwidthType("1");
|
||||
bandwidth.setBandwidthResult(dailyResult);
|
||||
bandwidth.setBandwidth95Daily(dailyResult);
|
||||
bandwidth.setCreateTime(startDate);
|
||||
epsNodeBandwidthMapper.insertEpsNodeBandwidth(bandwidth);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位换算
|
||||
* @param speedWithUnit
|
||||
* @return
|
||||
*/
|
||||
private static BigDecimal parseSpeedToMbps(String speedWithUnit) {
|
||||
if (speedWithUnit == null || speedWithUnit.trim().isEmpty()) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
Matcher matcher = SPEED_PATTERN.matcher(speedWithUnit.trim());
|
||||
if (!matcher.find()) {
|
||||
throw new IllegalArgumentException("Invalid speed format: " + speedWithUnit);
|
||||
}
|
||||
|
||||
BigDecimal value = new BigDecimal(matcher.group(1));
|
||||
String unit = matcher.group(2).toUpperCase();
|
||||
|
||||
// 处理纯数字(单位为空)
|
||||
if (unit.isEmpty()) {
|
||||
unit = "B/S"; // 默认单位: Bytes/s
|
||||
}
|
||||
|
||||
// 单位换算逻辑(保持不变)
|
||||
switch (unit) {
|
||||
case "B/S":
|
||||
return value.multiply(new BigDecimal("0.000008"));
|
||||
case "KBPS":
|
||||
case "KB/S":
|
||||
return value.divide(new BigDecimal("1000"), 10, RoundingMode.HALF_UP);
|
||||
case "MBPS":
|
||||
case "MB/S":
|
||||
return value;
|
||||
case "GBPS":
|
||||
case "GB/S":
|
||||
return value.multiply(new BigDecimal("1000"));
|
||||
case "TBPS":
|
||||
case "TB/S":
|
||||
return value.multiply(new BigDecimal("1000000"));
|
||||
case "KIB/S":
|
||||
return value.multiply(new BigDecimal("0.008192"));
|
||||
case "MIB/S":
|
||||
return value.multiply(new BigDecimal("8.388608"));
|
||||
case "GIB/S":
|
||||
return value.multiply(new BigDecimal("8589.934592"));
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown speed unit: " + unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,14 @@ 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;
|
||||
@@ -16,6 +20,8 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 服务器收益方式配置Service业务层处理
|
||||
@@ -31,6 +37,10 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
|
||||
private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper;
|
||||
@Autowired
|
||||
private EpsInitialTrafficDataService epsInitialTrafficDataService;
|
||||
@Autowired
|
||||
private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper;
|
||||
@Autowired
|
||||
private AllInterfaceNameMapper allInterfaceNameMapper;
|
||||
|
||||
/**
|
||||
* 查询服务器收益方式配置
|
||||
@@ -119,7 +129,7 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
|
||||
}
|
||||
changeRecord.setChangeContent(content);
|
||||
// 添加操作记录
|
||||
epsServerRevenueConfigMapper.insertEpsServerRevenueConfig(epsServerRevenueConfig);
|
||||
epsMethodChangeRecordMapper.insertEpsMethodChangeRecord(changeRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,6 +185,8 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
|
||||
try {
|
||||
epsInitialTrafficDataService.saveBatch(epsInitialTrafficData);
|
||||
log.info("流量数据批量入库成功,数据量:{}", batchList.size());
|
||||
// 接口名称保存
|
||||
processInterfaceNames(batchList);
|
||||
return R.ok("数据保存成功");
|
||||
} catch (Exception e) {
|
||||
log.error("流量数据入库失败,数据量:{},错误原因:{}",
|
||||
@@ -182,6 +194,48 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
|
||||
return R.fail("数据保存失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 批量处理接口名称
|
||||
*/
|
||||
private void processInterfaceNames(List<EpsInitialTrafficData> trafficDataList) {
|
||||
// 收集所有需要检查的接口名称
|
||||
Set<String> interfaceNames = trafficDataList.stream()
|
||||
.map(EpsInitialTrafficData::getName)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (interfaceNames.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 批量查询已存在的接口名称
|
||||
List<AllInterfaceName> existingNames = allInterfaceNameMapper.selectByNames(interfaceNames);
|
||||
Set<String> existingNameSet = existingNames.stream()
|
||||
.map(AllInterfaceName::getInterfaceName)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 筛选出需要新增的接口名称
|
||||
List<AllInterfaceName> newNames = trafficDataList.stream()
|
||||
.filter(data -> !existingNameSet.contains(data.getName()))
|
||||
.map(data -> {
|
||||
AllInterfaceName name = new AllInterfaceName();
|
||||
name.setInterfaceName(data.getName());
|
||||
name.setClientId(data.getClientId());
|
||||
name.setResourceType("1");
|
||||
name.setDeviceSn(data.getServiceSn());
|
||||
name.setNodeName(data.getNodeName());
|
||||
name.setBusinessCode(data.getBusinessId());
|
||||
name.setBusinessName(data.getBusinessName());
|
||||
return name;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 批量插入新接口名称
|
||||
if (!newNames.isEmpty()) {
|
||||
allInterfaceNameMapper.batchInsert(newNames);
|
||||
log.info("接口名称表-新增接口名称数量:{}", newNames.size());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 批量删除服务器收益方式配置
|
||||
*
|
||||
@@ -220,4 +274,5 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
|
||||
}
|
||||
return revenueMethod;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
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.AllInterfaceName;
|
||||
import com.ruoyi.system.domain.InitialSwitchInfoDetails;
|
||||
import com.ruoyi.system.domain.RmEpsTopologyManagement;
|
||||
import com.ruoyi.system.mapper.AllInterfaceNameMapper;
|
||||
import com.ruoyi.system.mapper.InitialSwitchInfoDetailsMapper;
|
||||
import com.ruoyi.system.mapper.RmEpsTopologyManagementMapper;
|
||||
import com.ruoyi.system.service.IInitialSwitchInfoDetailsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 查询交换机监控信息
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public R<String> autoSaveSwitchTraffic(InitialSwitchInfoDetails initialSwitchInfoDetails) {
|
||||
// 查询初始流量数据
|
||||
List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper.getAllSwitchInfoMsg(initialSwitchInfoDetails);
|
||||
List<InitialSwitchInfoDetails> batchList = new ArrayList<>();
|
||||
if(!dataList.isEmpty()){
|
||||
for (InitialSwitchInfoDetails details : dataList) {
|
||||
// 根据接口名称查询交换机信息
|
||||
String interfaceName = details.getName();
|
||||
RmEpsTopologyManagement rmEpsTopologyManagement = new RmEpsTopologyManagement();
|
||||
rmEpsTopologyManagement.setInterfaceName(interfaceName);
|
||||
List<RmEpsTopologyManagement> managements = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(rmEpsTopologyManagement);
|
||||
// 赋值
|
||||
if(!managements.isEmpty()){
|
||||
RmEpsTopologyManagement management = managements.get(0);
|
||||
details.setSwitchSn(management.getSwitchSn());
|
||||
details.setSwitchName(management.getSwitchName());
|
||||
details.setInterfaceDeviceType(management.getConnectedDeviceType());
|
||||
details.setServerName(management.getServerName());
|
||||
details.setServerPort(management.getServerPort());
|
||||
}
|
||||
// id自增
|
||||
details.setId(null);
|
||||
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) {
|
||||
// 收集所有需要检查的接口名称
|
||||
Set<String> interfaceNames = initialSwitchInfoDetails.stream()
|
||||
.map(InitialSwitchInfoDetails::getName)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (interfaceNames.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 批量查询已存在的接口名称
|
||||
List<AllInterfaceName> existingNames = allInterfaceNameMapper.selectByNames(interfaceNames);
|
||||
Set<String> existingNameSet = existingNames.stream()
|
||||
.map(AllInterfaceName::getInterfaceName)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 筛选出需要新增的接口名称
|
||||
List<AllInterfaceName> newNames = initialSwitchInfoDetails.stream()
|
||||
.filter(data -> !existingNameSet.contains(data.getName()))
|
||||
.map(data -> {
|
||||
AllInterfaceName name = new AllInterfaceName();
|
||||
name.setInterfaceName(data.getName());
|
||||
name.setClientId(data.getClientId());
|
||||
name.setResourceType("2");
|
||||
name.setDeviceSn(data.getServerSn());
|
||||
name.setNodeName(data.getServerName());
|
||||
name.setServerPort(data.getServerPort());
|
||||
name.setInterfaceDeviceType(data.getInterfaceDeviceType());
|
||||
name.setSwitchName(data.getSwitchName());
|
||||
name.setSwitchSn(data.getSwitchSn());
|
||||
return name;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 批量插入新接口名称
|
||||
if (!newNames.isEmpty()) {
|
||||
allInterfaceNameMapper.batchInsert(newNames);
|
||||
log.info("接口名称表-新增交换机接口名称数量:{}", newNames.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.system.domain.RmEpsTopologyManagement;
|
||||
import com.ruoyi.system.mapper.RmEpsTopologyManagementMapper;
|
||||
import com.ruoyi.system.service.IRmEpsTopologyManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.RmEpsTopologyManagementMapper;
|
||||
import com.ruoyi.system.domain.RmEpsTopologyManagement;
|
||||
import com.ruoyi.system.service.IRmEpsTopologyManagementService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 拓扑管理Service业务层处理
|
||||
@@ -15,11 +16,10 @@ import com.ruoyi.system.service.IRmEpsTopologyManagementService;
|
||||
* @date 2025-08-12
|
||||
*/
|
||||
@Service
|
||||
public class RmEpsTopologyManagementServiceImpl implements IRmEpsTopologyManagementService
|
||||
public class RmEpsTopologyManagementServiceImpl implements IRmEpsTopologyManagementService
|
||||
{
|
||||
@Autowired
|
||||
private RmEpsTopologyManagementMapper rmEpsTopologyManagementMapper;
|
||||
|
||||
/**
|
||||
* 查询拓扑管理
|
||||
*
|
||||
@@ -93,4 +93,5 @@ public class RmEpsTopologyManagementServiceImpl implements IRmEpsTopologyManagem
|
||||
{
|
||||
return rmEpsTopologyManagementMapper.deleteRmEpsTopologyManagementById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
<?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.AllInterfaceNameMapper">
|
||||
|
||||
<resultMap type="AllInterfaceName" id="AllInterfaceNameResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="clientId" column="client_id" />
|
||||
<result property="interfaceName" column="interface_name" />
|
||||
<result property="deviceSn" column="device_sn" />
|
||||
<result property="nodeName" column="node_name" />
|
||||
<result property="businessCode" column="business_code" />
|
||||
<result property="businessName" column="business_name" />
|
||||
<result property="resourceType" column="resource_type" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAllInterfaceNameVo">
|
||||
select id, client_id, interface_name, device_sn, node_name, business_code, business_name, resource_type, switch_name, interface_device_type, server_port, switch_sn, create_time, update_time, create_by, update_by from all_interface_name
|
||||
</sql>
|
||||
|
||||
<select id="selectAllInterfaceNameList" parameterType="AllInterfaceName" resultMap="AllInterfaceNameResult">
|
||||
<include refid="selectAllInterfaceNameVo"/>
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
|
||||
<if test="interfaceName != null and interfaceName != ''"> and interface_name like concat('%', #{interfaceName}, '%')</if>
|
||||
<if test="deviceSn != null and deviceSn != ''"> and device_sn = #{deviceSn}</if>
|
||||
<if test="nodeName != null and nodeName != ''"> and node_name like concat('%', #{nodeName}, '%')</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="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAllInterfaceNameById" parameterType="Long" resultMap="AllInterfaceNameResult">
|
||||
<include refid="selectAllInterfaceNameVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertAllInterfaceName" parameterType="AllInterfaceName" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into all_interface_name
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null and clientId != ''">client_id,</if>
|
||||
<if test="interfaceName != null and interfaceName != ''">interface_name,</if>
|
||||
<if test="deviceSn != null and deviceSn != ''">device_sn,</if>
|
||||
<if test="nodeName != null">node_name,</if>
|
||||
<if test="businessCode != null">business_code,</if>
|
||||
<if test="businessName != null">business_name,</if>
|
||||
<if test="resourceType != null">resource_type,</if>
|
||||
<if test="switchName != null">switch_name,</if>
|
||||
<if test="interfaceDeviceType != null">interface_device_type,</if>
|
||||
<if test="serverPort != null">server_port,</if>
|
||||
<if test="switchSn != null">switch_sn,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="clientId != null and clientId != ''">#{clientId},</if>
|
||||
<if test="interfaceName != null and interfaceName != ''">#{interfaceName},</if>
|
||||
<if test="deviceSn != null and deviceSn != ''">#{deviceSn},</if>
|
||||
<if test="nodeName != null">#{nodeName},</if>
|
||||
<if test="businessCode != null">#{businessCode},</if>
|
||||
<if test="businessName != null">#{businessName},</if>
|
||||
<if test="resourceType != null">#{resourceType},</if>
|
||||
<if test="switchName != null">#{switchName},</if>
|
||||
<if test="interfaceDeviceType != null">#{interfaceDeviceType},</if>
|
||||
<if test="serverPort != null">#{serverPort},</if>
|
||||
<if test="switchSn != null">#{switchSn},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateAllInterfaceName" parameterType="AllInterfaceName">
|
||||
update all_interface_name
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="clientId != null and clientId != ''">client_id = #{clientId},</if>
|
||||
<if test="interfaceName != null and interfaceName != ''">interface_name = #{interfaceName},</if>
|
||||
<if test="deviceSn != null and deviceSn != ''">device_sn = #{deviceSn},</if>
|
||||
<if test="nodeName != null">node_name = #{nodeName},</if>
|
||||
<if test="businessCode != null">business_code = #{businessCode},</if>
|
||||
<if test="businessName != null">business_name = #{businessName},</if>
|
||||
<if test="resourceType != null">resource_type = #{resourceType},</if>
|
||||
<if test="switchName != null">switch_name = #{switchName},</if>
|
||||
<if test="interfaceDeviceType != null">interface_device_type = #{interfaceDeviceType},</if>
|
||||
<if test="serverPort != null">server_port = #{serverPort},</if>
|
||||
<if test="switchSn != null">switch_sn = #{switchSn},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAllInterfaceNameById" parameterType="Long">
|
||||
delete from all_interface_name where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAllInterfaceNameByIds" parameterType="String">
|
||||
delete from all_interface_name where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<!-- 根据接口名称批量查询 -->
|
||||
<select id="selectByNames" parameterType="java.lang.String" resultType="AllInterfaceName">
|
||||
SELECT
|
||||
id,
|
||||
interface_name AS interfaceName,
|
||||
client_id AS clientId,
|
||||
resource_type AS resourceType,
|
||||
device_sn AS deviceSn,
|
||||
node_name AS nodeName,
|
||||
business_code AS businessCode,
|
||||
business_name AS businessName,
|
||||
switch_name AS switchName,
|
||||
interface_device_type AS interfaceDeviceType,
|
||||
server_port AS serverPort,
|
||||
switch_sn AS switchSn
|
||||
FROM
|
||||
all_interface_name
|
||||
WHERE
|
||||
interface_name IN
|
||||
<foreach collection="collection" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 批量插入接口名称 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO all_interface_name
|
||||
(
|
||||
interface_name,
|
||||
client_id,
|
||||
resource_type,
|
||||
device_sn,
|
||||
node_name,
|
||||
business_code,
|
||||
business_name,
|
||||
switch_name, interface_device_type, server_port, switch_sn,
|
||||
create_time,
|
||||
update_time
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.interfaceName},
|
||||
#{item.clientId},
|
||||
#{item.resourceType},
|
||||
#{item.deviceSn},
|
||||
#{item.nodeName},
|
||||
#{item.businessCode},
|
||||
#{item.businessName},
|
||||
#{item.switchName}, #{item.interfaceDeviceType}, #{item.serverPort}, #{item.switchSn},
|
||||
NOW(),
|
||||
NOW()
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 检查接口名称是否存在 -->
|
||||
<select id="getAllDeviceSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
|
||||
SELECT
|
||||
device_sn AS deviceSn
|
||||
FROM
|
||||
all_interface_name
|
||||
<where>
|
||||
and resource_type = '1' and device_sn != ''
|
||||
</where>
|
||||
group by device_sn
|
||||
</select>
|
||||
<!-- 检查交换机接口名称是否存在 -->
|
||||
<select id="getAllSwitchSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
|
||||
SELECT
|
||||
switch_sn AS switchSn
|
||||
FROM
|
||||
all_interface_name
|
||||
<where>
|
||||
and resource_type = '2' and switch_sn != ''
|
||||
</where>
|
||||
group by switch_sn
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -184,6 +184,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="endTime != null">
|
||||
and create_time <= #{endTime}
|
||||
</if>
|
||||
<if test="revenueMethod != null">
|
||||
and revenue_method = #{revenueMethod}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
ORDER BY create_time desc
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
<?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="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" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectInitialSwitchInfoDetailsVo">
|
||||
select id, client_id, name, in_bytes, out_bytes, status, type, in_speed, out_speed, create_by, update_by, create_time, update_time, switch_name, interface_device_type, server_name, server_port, server_sn, switch_sn 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 like concat('%', #{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="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>
|
||||
</where>
|
||||
</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="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>
|
||||
</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="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>
|
||||
</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="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>
|
||||
</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,
|
||||
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 >= #{startTime}</if>
|
||||
<if test="endTime != null and endTime != ''"> and create_time <= #{endTime}</if>
|
||||
</where>
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
<insert id="saveBatchSwitchTraffic" parameterType="InitialSwitchInfoDetails">
|
||||
INSERT INTO initial_switch_info_details
|
||||
(
|
||||
client_id,
|
||||
name,
|
||||
in_bytes,
|
||||
out_bytes,
|
||||
status,
|
||||
type,
|
||||
in_speed,
|
||||
out_speed,
|
||||
switch_name,
|
||||
interface_device_type,
|
||||
server_name,
|
||||
server_port,
|
||||
server_sn,
|
||||
switch_sn,
|
||||
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.switchName},
|
||||
#{item.interfaceDeviceType},
|
||||
#{item.serverName},
|
||||
#{item.serverPort},
|
||||
#{item.serverSn},
|
||||
#{item.switchSn},
|
||||
#{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>
|
||||
@@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<where>
|
||||
<if test="switchName != null and switchName != ''"> and switch_name like concat('%', #{switchName}, '%')</if>
|
||||
<if test="switchSn != null and switchSn != ''"> and switch_sn = #{switchSn}</if>
|
||||
<if test="interfaceName != null and interfaceName != ''"> and interface_name like concat('%', #{interfaceName}, '%')</if>
|
||||
<if test="interfaceName != null and interfaceName != ''"> and interface_name= #{interfaceName}</if>
|
||||
<if test="connectedDeviceType != null and connectedDeviceType != ''"> and connected_device_type = #{connectedDeviceType}</if>
|
||||
<if test="serverName != null and serverName != ''"> and server_name like concat('%', #{serverName}, '%')</if>
|
||||
<if test="serverSn != null and serverSn != ''"> and server_sn = #{serverSn}</if>
|
||||
|
||||
Reference in New Issue
Block a user