实时95值计算功能、优化服务器收益功能
This commit is contained in:
		@@ -95,8 +95,8 @@ public class SpeedUtils {
 | 
				
			|||||||
                totalOutSpeedBit = totalOutSpeedBit.add(outSpeedBit);
 | 
					                totalOutSpeedBit = totalOutSpeedBit.add(outSpeedBit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // 转换为Gb并更新最大值
 | 
					                // 转换为Gb并更新最大值
 | 
				
			||||||
                BigDecimal inSpeedGb = inSpeedBit.divide(GB_DIVISOR, 10, RoundingMode.HALF_UP);
 | 
					                BigDecimal inSpeedGb = inSpeedBit.divide(GB_DIVISOR, 0, RoundingMode.HALF_UP);
 | 
				
			||||||
                BigDecimal outSpeedGb = outSpeedBit.divide(GB_DIVISOR, 10, RoundingMode.HALF_UP);
 | 
					                BigDecimal outSpeedGb = outSpeedBit.divide(GB_DIVISOR, 0, RoundingMode.HALF_UP);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                maxInSpeedGb = maxInSpeedGb.max(inSpeedGb);
 | 
					                maxInSpeedGb = maxInSpeedGb.max(inSpeedGb);
 | 
				
			||||||
                maxOutSpeedGb = maxOutSpeedGb.max(outSpeedGb);
 | 
					                maxOutSpeedGb = maxOutSpeedGb.max(outSpeedGb);
 | 
				
			||||||
@@ -111,9 +111,9 @@ public class SpeedUtils {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // 计算Gb平均值
 | 
					        // 计算Gb平均值
 | 
				
			||||||
        BigDecimal size = new BigDecimal(list.size());
 | 
					        BigDecimal size = new BigDecimal(list.size());
 | 
				
			||||||
        BigDecimal avgInSpeedGb = totalInSpeedBit.divide(GB_DIVISOR, 10, RoundingMode.HALF_UP)
 | 
					        BigDecimal avgInSpeedGb = totalInSpeedBit.divide(GB_DIVISOR, 0, RoundingMode.HALF_UP)
 | 
				
			||||||
                .divide(size, 2, RoundingMode.HALF_UP);
 | 
					                .divide(size, 2, RoundingMode.HALF_UP);
 | 
				
			||||||
        BigDecimal avgOutSpeedGb = totalOutSpeedBit.divide(GB_DIVISOR, 10, RoundingMode.HALF_UP)
 | 
					        BigDecimal avgOutSpeedGb = totalOutSpeedBit.divide(GB_DIVISOR, 0, RoundingMode.HALF_UP)
 | 
				
			||||||
                .divide(size, 2, RoundingMode.HALF_UP);
 | 
					                .divide(size, 2, RoundingMode.HALF_UP);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 基于平均值的较大值确定推荐单位
 | 
					        // 基于平均值的较大值确定推荐单位
 | 
				
			||||||
@@ -201,6 +201,177 @@ public class SpeedUtils {
 | 
				
			|||||||
            recommendedUnit = "Kb";
 | 
					            recommendedUnit = "Kb";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return recommendedUnit;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 计算String类型(存储数字)的速度统计结果
 | 
				
			||||||
 | 
					     * @param list 数据列表
 | 
				
			||||||
 | 
					     * @param inSpeedField 输入速度字段名
 | 
				
			||||||
 | 
					     * @param outSpeedField 输出速度字段名
 | 
				
			||||||
 | 
					     * @return SpeedResult 速度统计结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static SpeedResult calculateWithStringTraffic(List<?> list,
 | 
				
			||||||
 | 
					                                                         String inSpeedField, String outSpeedField)
 | 
				
			||||||
 | 
					            throws NoSuchFieldException, IllegalAccessException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (list == null || list.isEmpty()) {
 | 
				
			||||||
 | 
					            return new SpeedResult(
 | 
				
			||||||
 | 
					                    BigDecimal.ZERO, BigDecimal.ZERO,
 | 
				
			||||||
 | 
					                    BigDecimal.ZERO, BigDecimal.ZERO,
 | 
				
			||||||
 | 
					                    BigDecimal.ZERO, BigDecimal.ZERO,
 | 
				
			||||||
 | 
					                    "bit"
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        BigDecimal totalInSpeedBit = BigDecimal.ZERO;
 | 
				
			||||||
 | 
					        BigDecimal totalOutSpeedBit = BigDecimal.ZERO;
 | 
				
			||||||
 | 
					        BigDecimal maxInSpeedGb = BigDecimal.ZERO;
 | 
				
			||||||
 | 
					        BigDecimal maxOutSpeedGb = BigDecimal.ZERO;
 | 
				
			||||||
 | 
					        BigDecimal lastInSpeedGb = BigDecimal.ZERO;
 | 
				
			||||||
 | 
					        BigDecimal lastOutSpeedGb = BigDecimal.ZERO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        final BigDecimal GB_DIVISOR = new BigDecimal("1000000000");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 计算总和(bit)和Gb值
 | 
				
			||||||
 | 
					        for (Object obj : list) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                java.lang.reflect.Field inField = obj.getClass().getDeclaredField(inSpeedField);
 | 
				
			||||||
 | 
					                java.lang.reflect.Field outField = obj.getClass().getDeclaredField(outSpeedField);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                inField.setAccessible(true);
 | 
				
			||||||
 | 
					                outField.setAccessible(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 处理String类型的数字值
 | 
				
			||||||
 | 
					                String inSpeedStr = (String) inField.get(obj);
 | 
				
			||||||
 | 
					                String outSpeedStr = (String) outField.get(obj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                BigDecimal inSpeedBit = convertStringToBigDecimal(inSpeedStr);
 | 
				
			||||||
 | 
					                BigDecimal outSpeedBit = convertStringToBigDecimal(outSpeedStr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 累加bit值(用于计算平均值)
 | 
				
			||||||
 | 
					                totalInSpeedBit = totalInSpeedBit.add(inSpeedBit);
 | 
				
			||||||
 | 
					                totalOutSpeedBit = totalOutSpeedBit.add(outSpeedBit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 转换为Gb并更新最大值
 | 
				
			||||||
 | 
					                BigDecimal inSpeedGb = inSpeedBit.divide(GB_DIVISOR, 2, RoundingMode.HALF_UP);
 | 
				
			||||||
 | 
					                BigDecimal outSpeedGb = outSpeedBit.divide(GB_DIVISOR, 2, RoundingMode.HALF_UP);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                maxInSpeedGb = maxInSpeedGb.max(inSpeedGb);
 | 
				
			||||||
 | 
					                maxOutSpeedGb = maxOutSpeedGb.max(outSpeedGb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 记录最后一个值
 | 
				
			||||||
 | 
					                lastInSpeedGb = inSpeedGb;
 | 
				
			||||||
 | 
					                lastOutSpeedGb = outSpeedGb;
 | 
				
			||||||
 | 
					            } catch (Exception e) {
 | 
				
			||||||
 | 
					                throw new RuntimeException("无法获取或转换速度字段值", e);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 计算Gb平均值
 | 
				
			||||||
 | 
					        BigDecimal size = new BigDecimal(list.size());
 | 
				
			||||||
 | 
					        BigDecimal avgInSpeedGb = totalInSpeedBit.divide(GB_DIVISOR, 2, RoundingMode.HALF_UP)
 | 
				
			||||||
 | 
					                .divide(size, 2, RoundingMode.HALF_UP);
 | 
				
			||||||
 | 
					        BigDecimal avgOutSpeedGb = totalOutSpeedBit.divide(GB_DIVISOR, 2, RoundingMode.HALF_UP)
 | 
				
			||||||
 | 
					                .divide(size, 2, RoundingMode.HALF_UP);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 基于平均值的较大值确定推荐单位
 | 
				
			||||||
 | 
					        BigDecimal maxAvgBit = avgInSpeedGb.compareTo(avgOutSpeedGb) > 0 ?
 | 
				
			||||||
 | 
					                avgInSpeedGb.multiply(GB_DIVISOR) :
 | 
				
			||||||
 | 
					                avgOutSpeedGb.multiply(GB_DIVISOR);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        String recommendedUnit;
 | 
				
			||||||
 | 
					        if (maxAvgBit.compareTo(new BigDecimal("1000000000")) >= 0) {
 | 
				
			||||||
 | 
					            recommendedUnit = "Gb";
 | 
				
			||||||
 | 
					        } else if (maxAvgBit.compareTo(new BigDecimal("1000000")) >= 0) {
 | 
				
			||||||
 | 
					            recommendedUnit = "Mb";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            recommendedUnit = "Kb";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return new SpeedResult(
 | 
				
			||||||
 | 
					                avgInSpeedGb, avgOutSpeedGb,
 | 
				
			||||||
 | 
					                maxInSpeedGb, maxOutSpeedGb,
 | 
				
			||||||
 | 
					                lastInSpeedGb, lastOutSpeedGb,
 | 
				
			||||||
 | 
					                recommendedUnit
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 将String类型的数字转换为BigDecimal
 | 
				
			||||||
 | 
					     * @param numberStr 数字字符串
 | 
				
			||||||
 | 
					     * @return BigDecimal值,转换失败返回0
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private static BigDecimal convertStringToBigDecimal(String numberStr) {
 | 
				
			||||||
 | 
					        if (numberStr == null || numberStr.trim().isEmpty()) {
 | 
				
			||||||
 | 
					            return BigDecimal.ZERO;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            return new BigDecimal(numberStr.trim());
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            return BigDecimal.ZERO;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 仅计算String类型(存储数字)的推荐单位
 | 
				
			||||||
 | 
					     * @param list 数据列表
 | 
				
			||||||
 | 
					     * @param inSpeedField 输入速度字段名
 | 
				
			||||||
 | 
					     * @param outSpeedField 输出速度字段名
 | 
				
			||||||
 | 
					     * @return 推荐单位
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static String calculateUnitWithStringTraffic(List<?> list,
 | 
				
			||||||
 | 
					                                                        String inSpeedField, String outSpeedField)
 | 
				
			||||||
 | 
					            throws NoSuchFieldException, IllegalAccessException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (list == null || list.isEmpty()) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        BigDecimal totalInSpeedBit = BigDecimal.ZERO;
 | 
				
			||||||
 | 
					        BigDecimal totalOutSpeedBit = BigDecimal.ZERO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 计算总和(bit)
 | 
				
			||||||
 | 
					        for (Object obj : list) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                java.lang.reflect.Field inField = obj.getClass().getDeclaredField(inSpeedField);
 | 
				
			||||||
 | 
					                java.lang.reflect.Field outField = obj.getClass().getDeclaredField(outSpeedField);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                inField.setAccessible(true);
 | 
				
			||||||
 | 
					                outField.setAccessible(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 处理String类型的数字值
 | 
				
			||||||
 | 
					                String inSpeedStr = (String) inField.get(obj);
 | 
				
			||||||
 | 
					                String outSpeedStr = (String) outField.get(obj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                BigDecimal inSpeedBit = convertStringToBigDecimal(inSpeedStr);
 | 
				
			||||||
 | 
					                BigDecimal outSpeedBit = convertStringToBigDecimal(outSpeedStr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                totalInSpeedBit = totalInSpeedBit.add(inSpeedBit);
 | 
				
			||||||
 | 
					                totalOutSpeedBit = totalOutSpeedBit.add(outSpeedBit);
 | 
				
			||||||
 | 
					            } catch (Exception e) {
 | 
				
			||||||
 | 
					                throw new RuntimeException("无法获取或转换速度字段值", e);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 计算平均值
 | 
				
			||||||
 | 
					        BigDecimal size = new BigDecimal(list.size());
 | 
				
			||||||
 | 
					        BigDecimal avgInSpeedBit = totalInSpeedBit.divide(size, 2, RoundingMode.HALF_UP);
 | 
				
			||||||
 | 
					        BigDecimal avgOutSpeedBit = totalOutSpeedBit.divide(size, 2, RoundingMode.HALF_UP);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 基于平均值的较大值确定推荐单位
 | 
				
			||||||
 | 
					        BigDecimal maxAvgBit = avgInSpeedBit.compareTo(avgOutSpeedBit) > 0 ?
 | 
				
			||||||
 | 
					                avgInSpeedBit : avgOutSpeedBit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        String recommendedUnit;
 | 
				
			||||||
 | 
					        if (maxAvgBit.compareTo(new BigDecimal("1000000000")) >= 0) {
 | 
				
			||||||
 | 
					            recommendedUnit = "Gb";
 | 
				
			||||||
 | 
					        } else if (maxAvgBit.compareTo(new BigDecimal("1000000")) >= 0) {
 | 
				
			||||||
 | 
					            recommendedUnit = "Mb";
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            recommendedUnit = "Kb";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return recommendedUnit;
 | 
					        return recommendedUnit;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,147 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.system.controller;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.github.pagehelper.PageInfo;
 | 
				
			||||||
 | 
					import com.ruoyi.common.core.utils.poi.ExcelUtil;
 | 
				
			||||||
 | 
					import com.ruoyi.common.core.web.controller.BaseController;
 | 
				
			||||||
 | 
					import com.ruoyi.common.core.web.domain.AjaxResult;
 | 
				
			||||||
 | 
					import com.ruoyi.common.core.web.page.PageDomain;
 | 
				
			||||||
 | 
					import com.ruoyi.common.core.web.page.TableDataInfo;
 | 
				
			||||||
 | 
					import com.ruoyi.common.log.annotation.Log;
 | 
				
			||||||
 | 
					import com.ruoyi.common.log.enums.BusinessType;
 | 
				
			||||||
 | 
					import com.ruoyi.common.security.annotation.RequiresPermissions;
 | 
				
			||||||
 | 
					import com.ruoyi.system.domain.EpsTaskStatistics;
 | 
				
			||||||
 | 
					import com.ruoyi.system.service.IEpsTaskStatisticsService;
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 业务95值计算任务Controller
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author gyt
 | 
				
			||||||
 | 
					 * @date 2025-10-29
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@RestController
 | 
				
			||||||
 | 
					@RequestMapping("/taskStatistics")
 | 
				
			||||||
 | 
					public class EpsTaskStatisticsController extends BaseController
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    @Autowired
 | 
				
			||||||
 | 
					    private IEpsTaskStatisticsService epsTaskStatisticsService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 查询业务95值计算任务列表
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @RequiresPermissions("system:taskStatistics:list")
 | 
				
			||||||
 | 
					    @PostMapping("/list")
 | 
				
			||||||
 | 
					    public TableDataInfo list(@RequestBody EpsTaskStatistics epsTaskStatistics)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        PageDomain pageDomain = new PageDomain();
 | 
				
			||||||
 | 
					        pageDomain.setPageNum(epsTaskStatistics.getPageNum());
 | 
				
			||||||
 | 
					        pageDomain.setPageSize(epsTaskStatistics.getPageSize());
 | 
				
			||||||
 | 
					        startPage(pageDomain);
 | 
				
			||||||
 | 
					        List<EpsTaskStatistics> list = epsTaskStatisticsService.selectEpsTaskStatisticsList(epsTaskStatistics);
 | 
				
			||||||
 | 
					        return getDataTable(list);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 导出业务95值计算任务列表
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @RequiresPermissions("system:taskStatistics:export")
 | 
				
			||||||
 | 
					    @Log(title = "业务95值计算任务", businessType = BusinessType.EXPORT)
 | 
				
			||||||
 | 
					    @PostMapping("/export")
 | 
				
			||||||
 | 
					    public void export(HttpServletResponse response, EpsTaskStatistics epsTaskStatistics)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        List<EpsTaskStatistics> list = epsTaskStatisticsService.selectEpsTaskStatisticsList(epsTaskStatistics);
 | 
				
			||||||
 | 
					        ExcelUtil<EpsTaskStatistics> util = new ExcelUtil<EpsTaskStatistics>(EpsTaskStatistics.class);
 | 
				
			||||||
 | 
					        util.showColumn(epsTaskStatistics.getProperties());
 | 
				
			||||||
 | 
					        util.exportExcel(response, list, "业务95值计算任务数据");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 获取业务95值计算任务详细信息
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @RequiresPermissions("system:taskStatistics:query")
 | 
				
			||||||
 | 
					    @GetMapping(value = "/{id}")
 | 
				
			||||||
 | 
					    public AjaxResult getInfo(@PathVariable("id") Long id)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return success(epsTaskStatisticsService.selectEpsTaskStatisticsById(id));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 新增业务95值计算任务
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @RequiresPermissions("system:taskStatistics:add")
 | 
				
			||||||
 | 
					    @Log(title = "业务95值计算任务", businessType = BusinessType.INSERT)
 | 
				
			||||||
 | 
					    @PostMapping
 | 
				
			||||||
 | 
					    public AjaxResult add(@RequestBody EpsTaskStatistics epsTaskStatistics)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return toAjax(epsTaskStatisticsService.insertEpsTaskStatistics(epsTaskStatistics));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 修改业务95值计算任务
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @RequiresPermissions("system:taskStatistics:edit")
 | 
				
			||||||
 | 
					    @Log(title = "业务95值计算任务", businessType = BusinessType.UPDATE)
 | 
				
			||||||
 | 
					    @PutMapping
 | 
				
			||||||
 | 
					    public AjaxResult edit(@RequestBody EpsTaskStatistics epsTaskStatistics)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return toAjax(epsTaskStatisticsService.updateEpsTaskStatistics(epsTaskStatistics));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 删除业务95值计算任务
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @RequiresPermissions("system:taskStatistics:remove")
 | 
				
			||||||
 | 
					    @Log(title = "业务95值计算任务", businessType = BusinessType.DELETE)
 | 
				
			||||||
 | 
						@DeleteMapping("/{ids}")
 | 
				
			||||||
 | 
					    public AjaxResult remove(@PathVariable Long[] ids)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return toAjax(epsTaskStatisticsService.deleteEpsTaskStatisticsByIds(ids));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 相关数据查询
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @RequiresPermissions("system:taskStatistics:list")
 | 
				
			||||||
 | 
					    @PostMapping("/getRelateData")
 | 
				
			||||||
 | 
					    public TableDataInfo getRelateData(@RequestBody EpsTaskStatistics epsTaskStatistics)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        PageInfo<?> list = epsTaskStatisticsService.getRelateData(epsTaskStatistics);
 | 
				
			||||||
 | 
					        return getDataTable(list.getList(), list.getTotal());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 修改相关数据
 | 
				
			||||||
 | 
					     * @param epsTaskStatistics
 | 
				
			||||||
 | 
					     * @return
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @RequiresPermissions("system:taskStatistics:edit")
 | 
				
			||||||
 | 
					    @PostMapping("/updateRelateData")
 | 
				
			||||||
 | 
					    public AjaxResult updateRelateData(@RequestBody EpsTaskStatistics epsTaskStatistics)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        int rows = epsTaskStatisticsService.updateRelateData(epsTaskStatistics);
 | 
				
			||||||
 | 
					        return toAjax(rows);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 重新计算
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @RequiresPermissions("system:taskStatistics:list")
 | 
				
			||||||
 | 
					    @PostMapping("/recaculate")
 | 
				
			||||||
 | 
					    public AjaxResult recaculate(@RequestBody EpsTaskStatistics epsTaskStatistics)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        int rows = epsTaskStatisticsService.recaculate(epsTaskStatistics);
 | 
				
			||||||
 | 
					        return toAjax(rows);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 图形查看
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @RequiresPermissions("system:taskStatistics:list")
 | 
				
			||||||
 | 
					    @PostMapping("/getRraphicalMsg")
 | 
				
			||||||
 | 
					    public AjaxResult getRraphicalMsg(@RequestBody EpsTaskStatistics epsTaskStatistics)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Map echartsMap = epsTaskStatisticsService.getRraphicalMsg(epsTaskStatistics);
 | 
				
			||||||
 | 
					        return success(echartsMap);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -112,6 +112,10 @@ public class EpsInitialTrafficData extends BaseEntity {
 | 
				
			|||||||
    private String dayOrMonth;
 | 
					    private String dayOrMonth;
 | 
				
			||||||
    /** 金山流量 */
 | 
					    /** 金山流量 */
 | 
				
			||||||
    private String machineFlow;
 | 
					    private String machineFlow;
 | 
				
			||||||
 | 
					    /** 包含设备 */
 | 
				
			||||||
 | 
					    private String clientIds;
 | 
				
			||||||
 | 
					    /** 是否95值 */
 | 
				
			||||||
 | 
					    private boolean flag95 = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,73 @@
 | 
				
			|||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 业务95值计算任务对象 eps_task_statistics
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * @author gyt
 | 
				
			||||||
 | 
					 * @date 2025-10-29
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Data
 | 
				
			||||||
 | 
					public class EpsTaskStatistics extends BaseEntity
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    private static final long serialVersionUID = 1L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 主键ID */
 | 
				
			||||||
 | 
					    private Long id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 任务名称 */
 | 
				
			||||||
 | 
					    @Excel(name = "任务名称")
 | 
				
			||||||
 | 
					    private String taskName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 业务名称 */
 | 
				
			||||||
 | 
					    @Excel(name = "业务名称")
 | 
				
			||||||
 | 
					    private String businessName;
 | 
				
			||||||
 | 
					    /** 业务代码 */
 | 
				
			||||||
 | 
					    private String businessCode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 开始时间 */
 | 
				
			||||||
 | 
					    @Excel(name = "开始时间")
 | 
				
			||||||
 | 
					    private String startTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 结束时间 */
 | 
				
			||||||
 | 
					    @Excel(name = "结束时间")
 | 
				
			||||||
 | 
					    private String endTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 95值 */
 | 
				
			||||||
 | 
					    @Excel(name = "95值")
 | 
				
			||||||
 | 
					    private BigDecimal percentile95;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 月均日95值 */
 | 
				
			||||||
 | 
					    @Excel(name = "月均日95值")
 | 
				
			||||||
 | 
					    private BigDecimal monthlyAvgPercentile95;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 资源类型 */
 | 
				
			||||||
 | 
					    @Excel(name = "资源类型")
 | 
				
			||||||
 | 
					    private String resourceType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 包含资源 */
 | 
				
			||||||
 | 
					    @Excel(name = "包含资源")
 | 
				
			||||||
 | 
					    private String includedResources;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 计算类型 */
 | 
				
			||||||
 | 
					    @Excel(name = "计算类型")
 | 
				
			||||||
 | 
					    private String calculationType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 计算模式 */
 | 
				
			||||||
 | 
					    @Excel(name = "计算模式")
 | 
				
			||||||
 | 
					    private String calculationMode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** 任务状态(1-计算中,2-计算完成) */
 | 
				
			||||||
 | 
					    @Excel(name = "任务状态(1-计算中,2-计算完成)")
 | 
				
			||||||
 | 
					    private String taskStatus;
 | 
				
			||||||
 | 
					    /** 需要修改的流量值 */
 | 
				
			||||||
 | 
					    private BigDecimal needSpeed;
 | 
				
			||||||
 | 
					    /** 需要修改的值对应的时间 */
 | 
				
			||||||
 | 
					    private String needTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -112,4 +112,8 @@ public class InitialSwitchInfoDetails extends BaseEntity
 | 
				
			|||||||
    private String ifIndex;
 | 
					    private String ifIndex;
 | 
				
			||||||
    /** 计算方式 */
 | 
					    /** 计算方式 */
 | 
				
			||||||
    public String calculationMode;
 | 
					    public String calculationMode;
 | 
				
			||||||
 | 
					    /** 包含资源 */
 | 
				
			||||||
 | 
					    public String clientIds;
 | 
				
			||||||
 | 
					    /** 是否95值 */
 | 
				
			||||||
 | 
					    private boolean flag95 = false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,4 +47,6 @@ public interface EpsInitialTrafficDataMapper {
 | 
				
			|||||||
     * @return
 | 
					     * @return
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    int updateMachineTraffic(EpsInitialTrafficData epsInitialTrafficData);
 | 
					    int updateMachineTraffic(EpsInitialTrafficData epsInitialTrafficData);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    List<EpsInitialTrafficData> getTrafficListByClientIds(EpsInitialTrafficData condition);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,61 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.system.mapper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import com.ruoyi.system.domain.EpsTaskStatistics;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 业务95值计算任务Mapper接口
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * @author gyt
 | 
				
			||||||
 | 
					 * @date 2025-10-29
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public interface EpsTaskStatisticsMapper 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 查询业务95值计算任务
 | 
				
			||||||
 | 
					     * 
 | 
				
			||||||
 | 
					     * @param id 业务95值计算任务主键
 | 
				
			||||||
 | 
					     * @return 业务95值计算任务
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public EpsTaskStatistics selectEpsTaskStatisticsById(Long id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 查询业务95值计算任务列表
 | 
				
			||||||
 | 
					     * 
 | 
				
			||||||
 | 
					     * @param epsTaskStatistics 业务95值计算任务
 | 
				
			||||||
 | 
					     * @return 业务95值计算任务集合
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public List<EpsTaskStatistics> selectEpsTaskStatisticsList(EpsTaskStatistics epsTaskStatistics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 新增业务95值计算任务
 | 
				
			||||||
 | 
					     * 
 | 
				
			||||||
 | 
					     * @param epsTaskStatistics 业务95值计算任务
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public int insertEpsTaskStatistics(EpsTaskStatistics epsTaskStatistics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 修改业务95值计算任务
 | 
				
			||||||
 | 
					     * 
 | 
				
			||||||
 | 
					     * @param epsTaskStatistics 业务95值计算任务
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public int updateEpsTaskStatistics(EpsTaskStatistics epsTaskStatistics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 删除业务95值计算任务
 | 
				
			||||||
 | 
					     * 
 | 
				
			||||||
 | 
					     * @param id 业务95值计算任务主键
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public int deleteEpsTaskStatisticsById(Long id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 批量删除业务95值计算任务
 | 
				
			||||||
 | 
					     * 
 | 
				
			||||||
 | 
					     * @param ids 需要删除的数据主键集合
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public int deleteEpsTaskStatisticsByIds(Long[] ids);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -28,6 +28,8 @@ public interface InitialSwitchInfoDetailsMapper
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public List<InitialSwitchInfoDetails> selectInitialSwitchInfoDetailsList(InitialSwitchInfoDetails initialSwitchInfoDetails);
 | 
					    public List<InitialSwitchInfoDetails> selectInitialSwitchInfoDetailsList(InitialSwitchInfoDetails initialSwitchInfoDetails);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public List<InitialSwitchInfoDetails> getswitchDetailList(InitialSwitchInfoDetails initialSwitchInfoDetails);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 新增交换机监控信息
 | 
					     * 新增交换机监控信息
 | 
				
			||||||
     * 
 | 
					     * 
 | 
				
			||||||
@@ -73,4 +75,11 @@ public interface InitialSwitchInfoDetailsMapper
 | 
				
			|||||||
     * @return
 | 
					     * @return
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    List<InitialSwitchInfoDetails> getAllSwitchInfoMsg(InitialSwitchInfoDetails initialSwitchInfoDetails);
 | 
					    List<InitialSwitchInfoDetails> getAllSwitchInfoMsg(InitialSwitchInfoDetails initialSwitchInfoDetails);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 计算业务95值
 | 
				
			||||||
 | 
					     * @param queryParam
 | 
				
			||||||
 | 
					     * @return
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    List<InitialSwitchInfoDetails> sumSwitchTrafficByclientIds(InitialSwitchInfoDetails queryParam);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,6 +37,13 @@ public interface EpsInitialTrafficDataService {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    List<EpsInitialTrafficData> query(EpsInitialTrafficData queryParam);
 | 
					    List<EpsInitialTrafficData> query(EpsInitialTrafficData queryParam);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 查询多台设备的流量数据
 | 
				
			||||||
 | 
					     * @param queryParam
 | 
				
			||||||
 | 
					     * @return
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    List<EpsInitialTrafficData> getTrafficListByClientIds(EpsInitialTrafficData queryParam);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 查询初始流量信息
 | 
					     * 查询初始流量信息
 | 
				
			||||||
     * @param queryParam 查询参数实体
 | 
					     * @param queryParam 查询参数实体
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,72 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.system.service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.github.pagehelper.PageInfo;
 | 
				
			||||||
 | 
					import com.ruoyi.system.domain.EpsTaskStatistics;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 业务95值计算任务Service接口
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author gyt
 | 
				
			||||||
 | 
					 * @date 2025-10-29
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public interface IEpsTaskStatisticsService
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 查询业务95值计算任务
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param id 业务95值计算任务主键
 | 
				
			||||||
 | 
					     * @return 业务95值计算任务
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public EpsTaskStatistics selectEpsTaskStatisticsById(Long id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 查询业务95值计算任务列表
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param epsTaskStatistics 业务95值计算任务
 | 
				
			||||||
 | 
					     * @return 业务95值计算任务集合
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public List<EpsTaskStatistics> selectEpsTaskStatisticsList(EpsTaskStatistics epsTaskStatistics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 新增业务95值计算任务
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param epsTaskStatistics 业务95值计算任务
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public int insertEpsTaskStatistics(EpsTaskStatistics epsTaskStatistics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 修改业务95值计算任务
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param epsTaskStatistics 业务95值计算任务
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public int updateEpsTaskStatistics(EpsTaskStatistics epsTaskStatistics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 批量删除业务95值计算任务
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param ids 需要删除的业务95值计算任务主键集合
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public int deleteEpsTaskStatisticsByIds(Long[] ids);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 删除业务95值计算任务信息
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param id 业务95值计算任务主键
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public int deleteEpsTaskStatisticsById(Long id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PageInfo<?> getRelateData(EpsTaskStatistics epsTaskStatistics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int updateRelateData(EpsTaskStatistics epsTaskStatistics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int recaculate(EpsTaskStatistics epsTaskStatistics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Map getRraphicalMsg(EpsTaskStatistics epsTaskStatistics);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -194,6 +194,32 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
 | 
				
			|||||||
                .collect(Collectors.toList());
 | 
					                .collect(Collectors.toList());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 查询多台设备的流量数据
 | 
				
			||||||
 | 
					     * @param queryParam
 | 
				
			||||||
 | 
					     * @return
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<EpsInitialTrafficData> getTrafficListByClientIds(EpsInitialTrafficData queryParam) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 获取涉及的表名
 | 
				
			||||||
 | 
					        Set<String> tableNames = TableRouterUtil.getTableNamesBetween(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.setBusinessId(queryParam.getBusinessId());
 | 
				
			||||||
 | 
					                    condition.setBusinessName(queryParam.getBusinessName());
 | 
				
			||||||
 | 
					                    condition.setClientIds(queryParam.getClientIds());
 | 
				
			||||||
 | 
					                    return epsInitialTrafficDataMapper.getTrafficListByClientIds(condition).stream();
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                .collect(Collectors.toList());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public List<EpsInitialTrafficData> getAllTraficMsg(EpsInitialTrafficData queryParam) {
 | 
					    public List<EpsInitialTrafficData> getAllTraficMsg(EpsInitialTrafficData queryParam) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -223,8 +249,9 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
 | 
				
			|||||||
        List<AllInterfaceName> snList = allInterfaceNameMapper.getAllDeviceSn(new AllInterfaceName());
 | 
					        List<AllInterfaceName> snList = allInterfaceNameMapper.getAllDeviceSn(new AllInterfaceName());
 | 
				
			||||||
        // 遍历处理每个设备
 | 
					        // 遍历处理每个设备
 | 
				
			||||||
        snList.forEach(interfaceName -> {
 | 
					        snList.forEach(interfaceName -> {
 | 
				
			||||||
            queryParam.setServiceSn(interfaceName.getDeviceSn());
 | 
					            queryParam.setClientId(interfaceName.getClientId());
 | 
				
			||||||
            processDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
 | 
					            queryParam.setName(interfaceName.getInterfaceName());
 | 
				
			||||||
 | 
					            calculateChangedDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -412,33 +439,6 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
 | 
				
			|||||||
        return dataList;
 | 
					        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());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 计算有业务变更设备的带宽
 | 
					     * 计算有业务变更设备的带宽
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -447,7 +447,8 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
 | 
				
			|||||||
                                                 String dailyEndTime, String calculationMode) {
 | 
					                                                 String dailyEndTime, String calculationMode) {
 | 
				
			||||||
        // 1. 获取业务变更记录(按时间降序)
 | 
					        // 1. 获取业务变更记录(按时间降序)
 | 
				
			||||||
        EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
 | 
					        EpsMethodChangeRecord changeQuery = new EpsMethodChangeRecord();
 | 
				
			||||||
        changeQuery.setHardwareSn(queryParam.getServiceSn());
 | 
					        changeQuery.setClientId(queryParam.getClientId());
 | 
				
			||||||
 | 
					        changeQuery.setTrafficPort(queryParam.getName());
 | 
				
			||||||
        changeQuery.setStartTime(dailyStartTime);
 | 
					        changeQuery.setStartTime(dailyStartTime);
 | 
				
			||||||
        changeQuery.setEndTime(dailyEndTime);
 | 
					        changeQuery.setEndTime(dailyEndTime);
 | 
				
			||||||
        List<EpsMethodChangeRecord> records = epsMethodChangeRecordMapper
 | 
					        List<EpsMethodChangeRecord> records = epsMethodChangeRecordMapper
 | 
				
			||||||
@@ -583,6 +584,7 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
 | 
				
			|||||||
        EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
 | 
					        EpsNodeBandwidth bandwidth = new EpsNodeBandwidth();
 | 
				
			||||||
        bandwidth.setClientId(data.getClientId());
 | 
					        bandwidth.setClientId(data.getClientId());
 | 
				
			||||||
        bandwidth.setHardwareSn(data.getServiceSn());
 | 
					        bandwidth.setHardwareSn(data.getServiceSn());
 | 
				
			||||||
 | 
					        bandwidth.setInterfaceName(data.getName());
 | 
				
			||||||
        bandwidth.setCalculationMode(calculationMode);
 | 
					        bandwidth.setCalculationMode(calculationMode);
 | 
				
			||||||
        bandwidth.setNodeName(data.getNodeName());
 | 
					        bandwidth.setNodeName(data.getNodeName());
 | 
				
			||||||
        bandwidth.setBusinessId(data.getBusinessId());
 | 
					        bandwidth.setBusinessId(data.getBusinessId());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,6 @@ import com.github.pagehelper.PageInfo;
 | 
				
			|||||||
import com.ruoyi.common.core.utils.DateUtils;
 | 
					import com.ruoyi.common.core.utils.DateUtils;
 | 
				
			||||||
import com.ruoyi.common.core.web.page.PageDomain;
 | 
					import com.ruoyi.common.core.web.page.PageDomain;
 | 
				
			||||||
import com.ruoyi.system.domain.EpsInitialTrafficData;
 | 
					import com.ruoyi.system.domain.EpsInitialTrafficData;
 | 
				
			||||||
import com.ruoyi.system.domain.EpsMethodChangeRecord;
 | 
					 | 
				
			||||||
import com.ruoyi.system.domain.EpsNodeBandwidth;
 | 
					import com.ruoyi.system.domain.EpsNodeBandwidth;
 | 
				
			||||||
import com.ruoyi.system.mapper.EpsMethodChangeRecordMapper;
 | 
					import com.ruoyi.system.mapper.EpsMethodChangeRecordMapper;
 | 
				
			||||||
import com.ruoyi.system.mapper.EpsNodeBandwidthMapper;
 | 
					import com.ruoyi.system.mapper.EpsNodeBandwidthMapper;
 | 
				
			||||||
@@ -180,15 +179,6 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
 | 
				
			|||||||
            if (epsNodeBandwidth == null) {
 | 
					            if (epsNodeBandwidth == null) {
 | 
				
			||||||
                log.warn("参数为空,无法计算月均日95值");
 | 
					                log.warn("参数为空,无法计算月均日95值");
 | 
				
			||||||
                return 0;
 | 
					                return 0;
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            EpsMethodChangeRecord query = new EpsMethodChangeRecord();
 | 
					 | 
				
			||||||
            query.setClientId(epsNodeBandwidth.getClientId());
 | 
					 | 
				
			||||||
            query.setTrafficPort(epsNodeBandwidth.getInterfaceName());
 | 
					 | 
				
			||||||
            query.setBusinessName(epsNodeBandwidth.getBusinessName());
 | 
					 | 
				
			||||||
            query.setBusinessCode(epsNodeBandwidth.getBusinessId());
 | 
					 | 
				
			||||||
            List<EpsMethodChangeRecord> records = epsMethodChangeRecordMapper.selectEpsMethodChangeRecordList(query);
 | 
					 | 
				
			||||||
            if(!records.isEmpty()){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            // 3. 获取计算数据(防止空指针)
 | 
					            // 3. 获取计算数据(防止空指针)
 | 
				
			||||||
            EpsNodeBandwidth calculatedData = epsNodeBandwidthMapper.calculateAvg(epsNodeBandwidth);
 | 
					            EpsNodeBandwidth calculatedData = epsNodeBandwidthMapper.calculateAvg(epsNodeBandwidth);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,405 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.system.service.impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.github.pagehelper.PageInfo;
 | 
				
			||||||
 | 
					import com.ruoyi.common.core.utils.DateUtils;
 | 
				
			||||||
 | 
					import com.ruoyi.common.core.utils.EchartsDataUtils;
 | 
				
			||||||
 | 
					import com.ruoyi.common.core.utils.SpeedUtils;
 | 
				
			||||||
 | 
					import com.ruoyi.common.core.utils.StringUtils;
 | 
				
			||||||
 | 
					import com.ruoyi.system.domain.EpsInitialTrafficData;
 | 
				
			||||||
 | 
					import com.ruoyi.system.domain.EpsNodeBandwidth;
 | 
				
			||||||
 | 
					import com.ruoyi.system.domain.EpsTaskStatistics;
 | 
				
			||||||
 | 
					import com.ruoyi.system.domain.InitialSwitchInfoDetails;
 | 
				
			||||||
 | 
					import com.ruoyi.system.mapper.EpsNodeBandwidthMapper;
 | 
				
			||||||
 | 
					import com.ruoyi.system.mapper.EpsTaskStatisticsMapper;
 | 
				
			||||||
 | 
					import com.ruoyi.system.mapper.InitialSwitchInfoDetailsMapper;
 | 
				
			||||||
 | 
					import com.ruoyi.system.service.EpsInitialTrafficDataService;
 | 
				
			||||||
 | 
					import com.ruoyi.system.service.IEpsTaskStatisticsService;
 | 
				
			||||||
 | 
					import com.ruoyi.system.service.IInitialSwitchInfoDetailsService;
 | 
				
			||||||
 | 
					import com.ruoyi.system.util.CalculateUtil;
 | 
				
			||||||
 | 
					import com.ruoyi.system.util.TrafficRedisHashUtil;
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
 | 
					import java.math.RoundingMode;
 | 
				
			||||||
 | 
					import java.time.LocalDate;
 | 
				
			||||||
 | 
					import java.time.YearMonth;
 | 
				
			||||||
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					import java.util.function.Function;
 | 
				
			||||||
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 业务95值计算任务Service业务层处理
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author gyt
 | 
				
			||||||
 | 
					 * @date 2025-10-29
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@Service
 | 
				
			||||||
 | 
					public class EpsTaskStatisticsServiceImpl implements IEpsTaskStatisticsService
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    @Autowired
 | 
				
			||||||
 | 
					    private EpsTaskStatisticsMapper epsTaskStatisticsMapper;
 | 
				
			||||||
 | 
					    @Autowired
 | 
				
			||||||
 | 
					    private EpsInitialTrafficDataService epsInitialTrafficDataService;
 | 
				
			||||||
 | 
					    @Autowired
 | 
				
			||||||
 | 
					    private EpsNodeBandwidthMapper epsNodeBandwidthMapper;
 | 
				
			||||||
 | 
					    @Autowired
 | 
				
			||||||
 | 
					    private IInitialSwitchInfoDetailsService initialSwitchInfoDetailsService;
 | 
				
			||||||
 | 
					    @Autowired
 | 
				
			||||||
 | 
					    private InitialSwitchInfoDetailsMapper initialSwitchInfoDetailsMapper;
 | 
				
			||||||
 | 
					    @Autowired
 | 
				
			||||||
 | 
					    private TrafficRedisHashUtil trafficRedisHashUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 查询业务95值计算任务
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param id 业务95值计算任务主键
 | 
				
			||||||
 | 
					     * @return 业务95值计算任务
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public EpsTaskStatistics selectEpsTaskStatisticsById(Long id)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return epsTaskStatisticsMapper.selectEpsTaskStatisticsById(id);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 查询业务95值计算任务列表
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param epsTaskStatistics 业务95值计算任务
 | 
				
			||||||
 | 
					     * @return 业务95值计算任务
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<EpsTaskStatistics> selectEpsTaskStatisticsList(EpsTaskStatistics epsTaskStatistics)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return epsTaskStatisticsMapper.selectEpsTaskStatisticsList(epsTaskStatistics);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 新增业务95值计算任务
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param epsTaskStatistics 业务95值计算任务
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int insertEpsTaskStatistics(EpsTaskStatistics epsTaskStatistics)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        epsTaskStatistics.setCreateTime(DateUtils.getNowDate());
 | 
				
			||||||
 | 
					        epsTaskStatisticsMapper.insertEpsTaskStatistics(epsTaskStatistics);
 | 
				
			||||||
 | 
					        // 开始计算
 | 
				
			||||||
 | 
					        if(StringUtils.equals(epsTaskStatistics.getResourceType(), "1")){
 | 
				
			||||||
 | 
					            if(StringUtils.equals(epsTaskStatistics.getCalculationType(), "1")){
 | 
				
			||||||
 | 
					                EpsInitialTrafficData queryParam = new EpsInitialTrafficData();
 | 
				
			||||||
 | 
					                queryParam.setStartTime(epsTaskStatistics.getStartTime());
 | 
				
			||||||
 | 
					                queryParam.setEndTime(epsTaskStatistics.getEndTime());
 | 
				
			||||||
 | 
					                queryParam.setBusinessId(epsTaskStatistics.getBusinessCode());
 | 
				
			||||||
 | 
					                queryParam.setClientIds(epsTaskStatistics.getIncludedResources());
 | 
				
			||||||
 | 
					                List<EpsInitialTrafficData> dataList = epsInitialTrafficDataService.getTrafficListByClientIds(queryParam);
 | 
				
			||||||
 | 
					                if(!dataList.isEmpty()){
 | 
				
			||||||
 | 
					                    // 存储数据到redis缓存
 | 
				
			||||||
 | 
					                    trafficRedisHashUtil.addItemToHash(epsTaskStatistics.getId().toString(), dataList);
 | 
				
			||||||
 | 
					                    // 计算95数据
 | 
				
			||||||
 | 
					                    processServer95Data(dataList, epsTaskStatistics);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }else{
 | 
				
			||||||
 | 
					                processAvg95Data(epsTaskStatistics);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }else{
 | 
				
			||||||
 | 
					            if(StringUtils.equals(epsTaskStatistics.getCalculationType(), "1")){
 | 
				
			||||||
 | 
					                InitialSwitchInfoDetails queryParam = new InitialSwitchInfoDetails();
 | 
				
			||||||
 | 
					                queryParam.setStartTime(epsTaskStatistics.getStartTime());
 | 
				
			||||||
 | 
					                queryParam.setEndTime(epsTaskStatistics.getEndTime());
 | 
				
			||||||
 | 
					                queryParam.setBusinessCode(epsTaskStatistics.getBusinessCode());
 | 
				
			||||||
 | 
					                queryParam.setClientIds(epsTaskStatistics.getIncludedResources());
 | 
				
			||||||
 | 
					                List<InitialSwitchInfoDetails> dataList = initialSwitchInfoDetailsMapper
 | 
				
			||||||
 | 
					                        .sumSwitchTrafficByclientIds(queryParam);
 | 
				
			||||||
 | 
					                if(!dataList.isEmpty()){
 | 
				
			||||||
 | 
					                    trafficRedisHashUtil.addItemToHash(epsTaskStatistics.getId().toString(), dataList);
 | 
				
			||||||
 | 
					                    processSwitch95Data(dataList, epsTaskStatistics);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }else{
 | 
				
			||||||
 | 
					                processAvg95Data(epsTaskStatistics);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void processServer95Data(List<EpsInitialTrafficData> dataList, EpsTaskStatistics epsTaskStatistics){
 | 
				
			||||||
 | 
					        if(!dataList.isEmpty()){
 | 
				
			||||||
 | 
					            // 1. 提取并转换带宽值
 | 
				
			||||||
 | 
					            List<BigDecimal> speedsInMbps = dataList.stream()
 | 
				
			||||||
 | 
					                    .map(data -> CalculateUtil.parseSpeedToMbps(data.getOutSpeed(), epsTaskStatistics.getCalculationMode()))
 | 
				
			||||||
 | 
					                    .sorted()
 | 
				
			||||||
 | 
					                    .collect(Collectors.toList());
 | 
				
			||||||
 | 
					            // 计算95百分位
 | 
				
			||||||
 | 
					            BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 保存计算结果
 | 
				
			||||||
 | 
					            EpsTaskStatistics updateData = new EpsTaskStatistics();
 | 
				
			||||||
 | 
					            updateData.setId(epsTaskStatistics.getId());
 | 
				
			||||||
 | 
					            updateData.setTaskStatus("2");
 | 
				
			||||||
 | 
					            updateData.setPercentile95(percentile95.setScale(0, RoundingMode.HALF_UP));
 | 
				
			||||||
 | 
					            updateData.setUpdateTime(DateUtils.getNowDate());
 | 
				
			||||||
 | 
					            epsTaskStatisticsMapper.updateEpsTaskStatistics(updateData);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    public void processSwitch95Data(List<InitialSwitchInfoDetails> dataList, EpsTaskStatistics epsTaskStatistics){
 | 
				
			||||||
 | 
					        if(!dataList.isEmpty()){
 | 
				
			||||||
 | 
					            // 1. 提取并转换带宽值
 | 
				
			||||||
 | 
					            List<BigDecimal> speedsInMbps = dataList.stream()
 | 
				
			||||||
 | 
					                    .map(data -> {
 | 
				
			||||||
 | 
					                        // 根据 interfaceDeviceType 选择 inSpeed 或 outSpeed
 | 
				
			||||||
 | 
					                        String speed = data.getMaxSpeed() != null ? data.getMaxSpeed().toString() : BigDecimal.ZERO.toString();
 | 
				
			||||||
 | 
					                        // 如果 speed 是纯数字,补充单位 "B/S"(Bytes/s)
 | 
				
			||||||
 | 
					                        if (speed.matches("^\\d+(\\.\\d+)?$")) {
 | 
				
			||||||
 | 
					                            speed += " B/S";
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        return CalculateUtil.parseSpeedToMbps(speed, epsTaskStatistics.getCalculationMode());
 | 
				
			||||||
 | 
					                    })
 | 
				
			||||||
 | 
					                    .sorted()
 | 
				
			||||||
 | 
					                    .collect(Collectors.toList());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 2. 计算95百分位
 | 
				
			||||||
 | 
					            BigDecimal percentile95 = CalculateUtil.calculatePercentile(speedsInMbps, 0.95);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 保存计算结果
 | 
				
			||||||
 | 
					            EpsTaskStatistics updateData = new EpsTaskStatistics();
 | 
				
			||||||
 | 
					            updateData.setId(epsTaskStatistics.getId());
 | 
				
			||||||
 | 
					            updateData.setTaskStatus("2");
 | 
				
			||||||
 | 
					            updateData.setPercentile95(percentile95.setScale(0, RoundingMode.HALF_UP));
 | 
				
			||||||
 | 
					            updateData.setUpdateTime(DateUtils.getNowDate());
 | 
				
			||||||
 | 
					            epsTaskStatisticsMapper.updateEpsTaskStatistics(updateData);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void processAvg95Data(EpsTaskStatistics epsTaskStatistics) {
 | 
				
			||||||
 | 
					        EpsNodeBandwidth epsNodeBandwidth = new EpsNodeBandwidth();
 | 
				
			||||||
 | 
					        epsNodeBandwidth.setMonthTime(epsTaskStatistics.getStartTime());
 | 
				
			||||||
 | 
					        epsNodeBandwidth.setBusinessId(epsTaskStatistics.getBusinessCode());
 | 
				
			||||||
 | 
					        EpsNodeBandwidth calculatedData = epsNodeBandwidthMapper.calculateAvg(epsNodeBandwidth);
 | 
				
			||||||
 | 
					        if (calculatedData != null) {
 | 
				
			||||||
 | 
					            BigDecimal sum95Daily = Optional.ofNullable(calculatedData.getBandwidth95Daily()).orElse(BigDecimal.ZERO);
 | 
				
			||||||
 | 
					            LocalDate monthTime = null;
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                String monthStr = epsNodeBandwidth.getMonthTime() == null
 | 
				
			||||||
 | 
					                        ? epsNodeBandwidth.getStartTime().substring(0, 7)
 | 
				
			||||||
 | 
					                        : epsNodeBandwidth.getMonthTime();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                YearMonth yearMonth = YearMonth.parse(monthStr);
 | 
				
			||||||
 | 
					                monthTime = yearMonth.atDay(1); // 转换为当月第一天
 | 
				
			||||||
 | 
					            } catch (Exception e) {
 | 
				
			||||||
 | 
					                System.err.println("月份格式错误:" + e.getMessage());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int daysInMonth = YearMonth.from(monthTime).lengthOfMonth();
 | 
				
			||||||
 | 
					            if (daysInMonth == 0) {
 | 
				
			||||||
 | 
					                System.err.println("当月天数为0,月份: " + epsNodeBandwidth.getMonthTime() == null
 | 
				
			||||||
 | 
					                        ? epsNodeBandwidth.getStartTime() : epsNodeBandwidth.getMonthTime());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            // 月均日95值
 | 
				
			||||||
 | 
					            BigDecimal avgMonthly = sum95Daily.divide(BigDecimal.valueOf(daysInMonth), 0, RoundingMode.HALF_UP);
 | 
				
			||||||
 | 
					            // 保存计算结果
 | 
				
			||||||
 | 
					            EpsTaskStatistics updateData = new EpsTaskStatistics();
 | 
				
			||||||
 | 
					            updateData.setId(epsTaskStatistics.getId());
 | 
				
			||||||
 | 
					            updateData.setTaskStatus("2");
 | 
				
			||||||
 | 
					            updateData.setMonthlyAvgPercentile95(avgMonthly);
 | 
				
			||||||
 | 
					            updateData.setUpdateTime(DateUtils.getNowDate());
 | 
				
			||||||
 | 
					            epsTaskStatisticsMapper.updateEpsTaskStatistics(updateData);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 修改业务95值计算任务
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param epsTaskStatistics 业务95值计算任务
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int updateEpsTaskStatistics(EpsTaskStatistics epsTaskStatistics)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        epsTaskStatistics.setUpdateTime(DateUtils.getNowDate());
 | 
				
			||||||
 | 
					        return epsTaskStatisticsMapper.updateEpsTaskStatistics(epsTaskStatistics);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 批量删除业务95值计算任务
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param ids 需要删除的业务95值计算任务主键
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int deleteEpsTaskStatisticsByIds(Long[] ids)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return epsTaskStatisticsMapper.deleteEpsTaskStatisticsByIds(ids);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 删除业务95值计算任务信息
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param id 业务95值计算任务主键
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int deleteEpsTaskStatisticsById(Long id)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return epsTaskStatisticsMapper.deleteEpsTaskStatisticsById(id);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public PageInfo<?> getRelateData(EpsTaskStatistics epsTaskStatistics) {
 | 
				
			||||||
 | 
					        // 分页参数
 | 
				
			||||||
 | 
					        Integer pageNum = epsTaskStatistics.getPageNum();
 | 
				
			||||||
 | 
					        Integer pageSize = epsTaskStatistics.getPageSize();
 | 
				
			||||||
 | 
					        // 查询任务详情
 | 
				
			||||||
 | 
					        Long taskId = epsTaskStatistics.getId();
 | 
				
			||||||
 | 
					        EpsTaskStatistics taskMsg = epsTaskStatisticsMapper.selectEpsTaskStatisticsById(taskId);
 | 
				
			||||||
 | 
					        if(StringUtils.equals("1", taskMsg.getResourceType())){
 | 
				
			||||||
 | 
					            List<EpsInitialTrafficData> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), EpsInitialTrafficData.class);
 | 
				
			||||||
 | 
					            int index = CalculateUtil.calculate95Index(list, 0.05);
 | 
				
			||||||
 | 
					            list.get(index).setFlag95(true);
 | 
				
			||||||
 | 
					            List<EpsInitialTrafficData> pageList = list.stream()
 | 
				
			||||||
 | 
					                    .skip((long) (pageNum - 1) * pageSize)
 | 
				
			||||||
 | 
					                    .limit(pageSize)
 | 
				
			||||||
 | 
					                    .collect(Collectors.toList());
 | 
				
			||||||
 | 
					            for (EpsInitialTrafficData epsInitialTrafficData : pageList) {
 | 
				
			||||||
 | 
					                epsInitialTrafficData.setBusinessId(taskMsg.getBusinessCode());
 | 
				
			||||||
 | 
					                epsInitialTrafficData.setClientId(taskMsg.getIncludedResources());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            PageInfo<EpsInitialTrafficData> pageInfo = new PageInfo<>();
 | 
				
			||||||
 | 
					            pageInfo.setPageNum(pageNum);
 | 
				
			||||||
 | 
					            pageInfo.setPageSize(pageSize);
 | 
				
			||||||
 | 
					            pageInfo.setTotal(list.size());
 | 
				
			||||||
 | 
					            pageInfo.setList(pageList);
 | 
				
			||||||
 | 
					            return pageInfo;
 | 
				
			||||||
 | 
					        }else{
 | 
				
			||||||
 | 
					            List<InitialSwitchInfoDetails> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), InitialSwitchInfoDetails.class);
 | 
				
			||||||
 | 
					            int index = CalculateUtil.calculate95Index(list, 0.05);
 | 
				
			||||||
 | 
					            list.get(index).setFlag95(true);
 | 
				
			||||||
 | 
					            List<InitialSwitchInfoDetails> pageList = list.stream()
 | 
				
			||||||
 | 
					                    .skip((long) (pageNum - 1) * pageSize)
 | 
				
			||||||
 | 
					                    .limit(pageSize)
 | 
				
			||||||
 | 
					                    .collect(Collectors.toList());
 | 
				
			||||||
 | 
					            for (InitialSwitchInfoDetails initialSwitchInfoDetails : pageList) {
 | 
				
			||||||
 | 
					                initialSwitchInfoDetails.setName(taskMsg.getIncludedResources());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            PageInfo<InitialSwitchInfoDetails> pageInfo = new PageInfo<>();
 | 
				
			||||||
 | 
					            pageInfo.setPageNum(pageNum);
 | 
				
			||||||
 | 
					            pageInfo.setPageSize(pageSize);
 | 
				
			||||||
 | 
					            pageInfo.setTotal(list.size());
 | 
				
			||||||
 | 
					            pageInfo.setList(pageList);
 | 
				
			||||||
 | 
					            return pageInfo;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int updateRelateData(EpsTaskStatistics epsTaskStatistics) {
 | 
				
			||||||
 | 
					        // 查询任务详情
 | 
				
			||||||
 | 
					        Long taskId = epsTaskStatistics.getId();
 | 
				
			||||||
 | 
					        EpsTaskStatistics taskMsg = epsTaskStatisticsMapper.selectEpsTaskStatisticsById(taskId);
 | 
				
			||||||
 | 
					        if(StringUtils.equals("1", taskMsg.getResourceType())){
 | 
				
			||||||
 | 
					            EpsInitialTrafficData epsInitialTrafficData = new EpsInitialTrafficData();
 | 
				
			||||||
 | 
					            epsInitialTrafficData.setOutSpeed(epsTaskStatistics.getNeedSpeed().toString());
 | 
				
			||||||
 | 
					            epsInitialTrafficData.setCreateTime(DateUtils.parseDate(epsTaskStatistics.getNeedTime()));
 | 
				
			||||||
 | 
					            trafficRedisHashUtil.updateItemInHash(taskId.toString(), epsInitialTrafficData,
 | 
				
			||||||
 | 
					                    item -> {
 | 
				
			||||||
 | 
					                        Object createTime = trafficRedisHashUtil.getCreateTimeFromObject(item);
 | 
				
			||||||
 | 
					                        return createTime != null && createTime.toString().equals(epsTaskStatistics.getNeedTime().toString());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					        }else{
 | 
				
			||||||
 | 
					            InitialSwitchInfoDetails initialSwitchInfoDetails = new InitialSwitchInfoDetails();
 | 
				
			||||||
 | 
					            initialSwitchInfoDetails.setMaxSpeed(epsTaskStatistics.getNeedSpeed());
 | 
				
			||||||
 | 
					            initialSwitchInfoDetails.setCreateTime(DateUtils.parseDate(epsTaskStatistics.getNeedTime()));
 | 
				
			||||||
 | 
					            trafficRedisHashUtil.updateItemInHash(taskId.toString(), initialSwitchInfoDetails,
 | 
				
			||||||
 | 
					                    item -> {
 | 
				
			||||||
 | 
					                        Object createTime = trafficRedisHashUtil.getCreateTimeFromObject(item);
 | 
				
			||||||
 | 
					                        return createTime != null && createTime.toString().equals(epsTaskStatistics.getNeedTime().toString());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int recaculate(EpsTaskStatistics epsTaskStatistics) {
 | 
				
			||||||
 | 
					        // 查询任务详情
 | 
				
			||||||
 | 
					        Long taskId = epsTaskStatistics.getId();
 | 
				
			||||||
 | 
					        EpsTaskStatistics taskMsg = epsTaskStatisticsMapper.selectEpsTaskStatisticsById(taskId);
 | 
				
			||||||
 | 
					        // 任务状态改为计算中
 | 
				
			||||||
 | 
					        EpsTaskStatistics updateParam = new EpsTaskStatistics();
 | 
				
			||||||
 | 
					        updateParam.setId(taskId);
 | 
				
			||||||
 | 
					        updateParam.setTaskStatus("1");
 | 
				
			||||||
 | 
					        epsTaskStatisticsMapper.updateEpsTaskStatistics(updateParam);
 | 
				
			||||||
 | 
					        // 开始计算
 | 
				
			||||||
 | 
					        if(StringUtils.equals("1", taskMsg.getResourceType())){
 | 
				
			||||||
 | 
					            List<EpsInitialTrafficData> dataList = trafficRedisHashUtil.getListFromHash(taskId.toString(), EpsInitialTrafficData.class);
 | 
				
			||||||
 | 
					            if(StringUtils.equals(epsTaskStatistics.getCalculationType(), "1")){
 | 
				
			||||||
 | 
					                processServer95Data(dataList, epsTaskStatistics);
 | 
				
			||||||
 | 
					            }else{
 | 
				
			||||||
 | 
					                processAvg95Data(epsTaskStatistics);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }else{
 | 
				
			||||||
 | 
					            List<InitialSwitchInfoDetails> dataList = trafficRedisHashUtil.getListFromHash(taskId.toString(), InitialSwitchInfoDetails.class);
 | 
				
			||||||
 | 
					            if(StringUtils.equals(epsTaskStatistics.getCalculationType(), "1")){
 | 
				
			||||||
 | 
					                processSwitch95Data(dataList, epsTaskStatistics);
 | 
				
			||||||
 | 
					            }else{
 | 
				
			||||||
 | 
					                processAvg95Data(epsTaskStatistics);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return 1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Map getRraphicalMsg(EpsTaskStatistics epsTaskStatistics) {
 | 
				
			||||||
 | 
					        // 查询任务详情
 | 
				
			||||||
 | 
					        Long taskId = epsTaskStatistics.getId();
 | 
				
			||||||
 | 
					        EpsTaskStatistics taskMsg = epsTaskStatisticsMapper.selectEpsTaskStatisticsById(taskId);
 | 
				
			||||||
 | 
					        if(StringUtils.equals("1", taskMsg.getResourceType())){
 | 
				
			||||||
 | 
					            if(StringUtils.equals("1", taskMsg.getCalculationType())){
 | 
				
			||||||
 | 
					                List<EpsInitialTrafficData> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), EpsInitialTrafficData.class);
 | 
				
			||||||
 | 
					                if(!list.isEmpty()){
 | 
				
			||||||
 | 
					                    try{
 | 
				
			||||||
 | 
					                        SpeedUtils.SpeedResult result = SpeedUtils.calculateWithStringTraffic(list, "inSpeed", "outSpeed");
 | 
				
			||||||
 | 
					                        BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
 | 
				
			||||||
 | 
					                        Map<String, Function<EpsInitialTrafficData, ?>> extractors = new LinkedHashMap<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        extractors.put("netOutSpeedData", info ->
 | 
				
			||||||
 | 
					                                info != null && info.getOutSpeed() != null ?
 | 
				
			||||||
 | 
					                                        new BigDecimal(info.getOutSpeed()).divide(divisor, 0, RoundingMode.HALF_UP) :
 | 
				
			||||||
 | 
					                                        0);
 | 
				
			||||||
 | 
					                        Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, EpsInitialTrafficData::getCreateTime, extractors);
 | 
				
			||||||
 | 
					                        resultMap.put("other", result);
 | 
				
			||||||
 | 
					                        resultMap.put("percentile95", taskMsg.getPercentile95());
 | 
				
			||||||
 | 
					                        return resultMap;
 | 
				
			||||||
 | 
					                    }catch (Exception e){
 | 
				
			||||||
 | 
					                        System.err.println(e.getMessage());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }else{
 | 
				
			||||||
 | 
					            if(StringUtils.equals("1", taskMsg.getCalculationType())){
 | 
				
			||||||
 | 
					                List<InitialSwitchInfoDetails> list = trafficRedisHashUtil.getListFromHash(taskId.toString(), InitialSwitchInfoDetails.class);
 | 
				
			||||||
 | 
					                if(!list.isEmpty()){
 | 
				
			||||||
 | 
					                    try{
 | 
				
			||||||
 | 
					                        SpeedUtils.SpeedResult result = SpeedUtils.calculateWithAverageBasedUnit(list, "inSpeed", "outSpeed");
 | 
				
			||||||
 | 
					                        BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
 | 
				
			||||||
 | 
					                        Map<String, Function<InitialSwitchInfoDetails, ?>> extractors = new LinkedHashMap<>();
 | 
				
			||||||
 | 
					                        extractors.put("netInSpeedData", info ->
 | 
				
			||||||
 | 
					                                info != null && info.getInSpeed() != null ?
 | 
				
			||||||
 | 
					                                        info.getInSpeed().divide(divisor, 0, RoundingMode.HALF_UP) :
 | 
				
			||||||
 | 
					                                        0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        extractors.put("netOutSpeedData", info ->
 | 
				
			||||||
 | 
					                                info != null && info.getOutSpeed() != null ?
 | 
				
			||||||
 | 
					                                        info.getOutSpeed().divide(divisor, 0, RoundingMode.HALF_UP) :
 | 
				
			||||||
 | 
					                                        0);
 | 
				
			||||||
 | 
					                        Map<String, Object> resultMap = EchartsDataUtils.buildEchartsData(list, InitialSwitchInfoDetails::getCreateTime, extractors);
 | 
				
			||||||
 | 
					                        resultMap.put("other", result);
 | 
				
			||||||
 | 
					                        resultMap.put("percentile95", taskMsg.getPercentile95());
 | 
				
			||||||
 | 
					                        return resultMap;
 | 
				
			||||||
 | 
					                    }catch (Exception e){
 | 
				
			||||||
 | 
					                        System.err.println(e.getMessage());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return new HashMap();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -723,22 +723,31 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
 | 
				
			|||||||
            BeanUtils.copyProperties(initialSwitchInfoDetails, dailyQuery); // 复制原有属性
 | 
					            BeanUtils.copyProperties(initialSwitchInfoDetails, dailyQuery); // 复制原有属性
 | 
				
			||||||
            dailyQuery.setStartTime(dayStart);
 | 
					            dailyQuery.setStartTime(dayStart);
 | 
				
			||||||
            dailyQuery.setEndTime(dayEnd);
 | 
					            dailyQuery.setEndTime(dayEnd);
 | 
				
			||||||
            try {
 | 
					            // 根据clientId查询交换机接口名称
 | 
				
			||||||
                Map<String, Object> resultMap = switchNetSpeedEcharts(dailyQuery);
 | 
					            AllInterfaceName queryParam = new AllInterfaceName();
 | 
				
			||||||
                // 查询95值
 | 
					            queryParam.setSwitchIp(initialSwitchInfoDetails.getSwitchIp());
 | 
				
			||||||
                EpsNodeBandwidth query = new EpsNodeBandwidth();
 | 
					            queryParam.setClientId(initialSwitchInfoDetails.getClientId());
 | 
				
			||||||
                query.setBandwidthType("1");
 | 
					            List<AllInterfaceName> allInterfaceNames = allInterfaceNameMapper.selectAllInterfaceNameList(queryParam);
 | 
				
			||||||
                query.setCreateTime(DateUtils.parseDate(date));
 | 
					            for (AllInterfaceName allInterfaceName : allInterfaceNames) {
 | 
				
			||||||
                query.setCalculationMode(initialSwitchInfoDetails.getCalculationMode());
 | 
					                try {
 | 
				
			||||||
                query.setClientId(initialSwitchInfoDetails.getClientId());
 | 
					                    dailyQuery.setName(allInterfaceName.getInterfaceName());
 | 
				
			||||||
                List<EpsNodeBandwidth> epsNodeBandwidthList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(query);
 | 
					                    Map<String, Object> resultMap = switchNetSpeedEcharts(dailyQuery);
 | 
				
			||||||
                if(!epsNodeBandwidthList.isEmpty()){
 | 
					                    // 查询95值
 | 
				
			||||||
                    EpsNodeBandwidth nodeBandwidth = epsNodeBandwidthList.get(0);
 | 
					                    EpsNodeBandwidth query = new EpsNodeBandwidth();
 | 
				
			||||||
                    resultMap.put("95value", nodeBandwidth.getBandwidthResult());
 | 
					                    query.setBandwidthType("1");
 | 
				
			||||||
 | 
					                    query.setCreateTime(DateUtils.parseDate(date));
 | 
				
			||||||
 | 
					                    query.setCalculationMode(initialSwitchInfoDetails.getCalculationMode());
 | 
				
			||||||
 | 
					                    query.setClientId(initialSwitchInfoDetails.getClientId());
 | 
				
			||||||
 | 
					                    query.setInterfaceName(allInterfaceName.getInterfaceName());
 | 
				
			||||||
 | 
					                    List<EpsNodeBandwidth> epsNodeBandwidthList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(query);
 | 
				
			||||||
 | 
					                    if(!epsNodeBandwidthList.isEmpty()){
 | 
				
			||||||
 | 
					                        EpsNodeBandwidth nodeBandwidth = epsNodeBandwidthList.get(0);
 | 
				
			||||||
 | 
					                        resultMap.put("95value", nodeBandwidth.getBandwidthResult());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    resultList.add(resultMap);
 | 
				
			||||||
 | 
					                } catch (Exception e){
 | 
				
			||||||
 | 
					                    e.printStackTrace();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                resultList.add(resultMap);
 | 
					 | 
				
			||||||
            } catch (Exception e){
 | 
					 | 
				
			||||||
                e.printStackTrace();
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return resultList.isEmpty() ? new ArrayList<>() : resultList;
 | 
					        return resultList.isEmpty() ? new ArrayList<>() : resultList;
 | 
				
			||||||
@@ -795,7 +804,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
 | 
				
			|||||||
     * @return
 | 
					     * @return
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public Map<String, Object> switchNetSpeedEcharts(InitialSwitchInfoDetails initialSwitchInfoDetails) {
 | 
					    public Map<String, Object> switchNetSpeedEcharts(InitialSwitchInfoDetails initialSwitchInfoDetails) {
 | 
				
			||||||
        List<InitialSwitchInfoDetails> list = initialSwitchInfoDetailsMapper.selectInitialSwitchInfoDetailsList(initialSwitchInfoDetails);
 | 
					        List<InitialSwitchInfoDetails> list = initialSwitchInfoDetailsMapper.getswitchDetailList(initialSwitchInfoDetails);
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            SpeedUtils.SpeedResult result = SpeedUtils.calculateWithAverageBasedUnit(list, "inSpeed", "outSpeed");
 | 
					            SpeedUtils.SpeedResult result = SpeedUtils.calculateWithAverageBasedUnit(list, "inSpeed", "outSpeed");
 | 
				
			||||||
            BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
 | 
					            BigDecimal divisor = SpeedUtils.getDivisor(result.getRecommendedUnit());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -490,6 +490,10 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int innerAddRegist(RmRegisterMsgRemote registerMsg) {
 | 
					    public int innerAddRegist(RmRegisterMsgRemote registerMsg) {
 | 
				
			||||||
 | 
					        if(registerMsg.getClientId() == null) {
 | 
				
			||||||
 | 
					            log.error("注册失败:clientId为null");
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        // 解析mq接收的消息
 | 
					        // 解析mq接收的消息
 | 
				
			||||||
        // 时间戳转换
 | 
					        // 时间戳转换
 | 
				
			||||||
        long timestamp = registerMsg.getTimestamp();
 | 
					        long timestamp = registerMsg.getTimestamp();
 | 
				
			||||||
@@ -513,6 +517,8 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
 | 
				
			|||||||
                        insertData.setHardwareSn(registerMsg.getSn());
 | 
					                        insertData.setHardwareSn(registerMsg.getSn());
 | 
				
			||||||
                        insertData.setRegistrationStatus("1");
 | 
					                        insertData.setRegistrationStatus("1");
 | 
				
			||||||
                        insertData.setMultiPublicIpStatus("1");
 | 
					                        insertData.setMultiPublicIpStatus("1");
 | 
				
			||||||
 | 
					                        insertData.setHeartbeatCount(3);
 | 
				
			||||||
 | 
					                        insertData.setHeartbeatInterval(30);
 | 
				
			||||||
                        insertData.setResourceType("1");
 | 
					                        insertData.setResourceType("1");
 | 
				
			||||||
                        insertData.setCreateTime(createTime);
 | 
					                        insertData.setCreateTime(createTime);
 | 
				
			||||||
                        rmResourceRegistrationMapper.insertRmResourceRegistration(insertData);
 | 
					                        rmResourceRegistrationMapper.insertRmResourceRegistration(insertData);
 | 
				
			||||||
@@ -577,16 +583,30 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
 | 
				
			|||||||
        queryParam.setClientId(rmResourceRegistration.getClientId());
 | 
					        queryParam.setClientId(rmResourceRegistration.getClientId());
 | 
				
			||||||
        RmResourceRegistration exits = rmResourceRegistrationMapper.selectRegistMsgByClientId(queryParam);
 | 
					        RmResourceRegistration exits = rmResourceRegistrationMapper.selectRegistMsgByClientId(queryParam);
 | 
				
			||||||
        if(exits != null){
 | 
					        if(exits != null){
 | 
				
			||||||
            // 如果逻辑节点为空或者有变化 设置新节点
 | 
					            RmResourceRegistration updateData = new RmResourceRegistration();
 | 
				
			||||||
 | 
					            boolean needUpdate = false;
 | 
				
			||||||
 | 
					            // 如果上机时间为空 设置上机时间
 | 
				
			||||||
 | 
					            if(exits.getOnboardTime() == null){
 | 
				
			||||||
 | 
					                // 如果服务器已注册 增加节点标识
 | 
				
			||||||
 | 
					                updateData.setOnboardTime(DateUtils.getNowDate());
 | 
				
			||||||
 | 
					                needUpdate = true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            if(exits.getLogicalNodeId() == null ||
 | 
					            if(exits.getLogicalNodeId() == null ||
 | 
				
			||||||
                    !StringUtils.equals(rmResourceRegistration.getLogicalNodeId(),exits.getLogicalNodeId())){
 | 
					                    !StringUtils.equals(rmResourceRegistration.getLogicalNodeId(),exits.getLogicalNodeId())){
 | 
				
			||||||
                // 如果服务器已注册 增加节点标识
 | 
					                // 如果服务器已注册 增加节点标识
 | 
				
			||||||
                RmResourceRegistration updateData = new RmResourceRegistration();
 | 
					 | 
				
			||||||
                updateData.setId(exits.getId());
 | 
					 | 
				
			||||||
                updateData.setLogicalNodeId(rmResourceRegistration.getLogicalNodeId());
 | 
					                updateData.setLogicalNodeId(rmResourceRegistration.getLogicalNodeId());
 | 
				
			||||||
                updateData.setOnboardTime(DateUtils.getNowDate());
 | 
					                needUpdate = true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(exits.getAgentVersion() == null ||
 | 
				
			||||||
 | 
					                    !StringUtils.equals(rmResourceRegistration.getAgentVersion(),exits.getAgentVersion())){
 | 
				
			||||||
 | 
					                // 如果服务器已注册 增加版本信息
 | 
				
			||||||
 | 
					                updateData.setAgentVersion(rmResourceRegistration.getAgentVersion());
 | 
				
			||||||
 | 
					                needUpdate = true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(needUpdate){
 | 
				
			||||||
 | 
					                updateData.setId(exits.getId());
 | 
				
			||||||
                rmResourceRegistrationMapper.updateRmResourceRegistration(updateData);
 | 
					                rmResourceRegistrationMapper.updateRmResourceRegistration(updateData);
 | 
				
			||||||
                log.info("设备:{},逻辑节点增加成功",rmResourceRegistration.getClientId());
 | 
					                log.info("设备:{},更新成功",rmResourceRegistration.getClientId());
 | 
				
			||||||
                return 1;
 | 
					                return 1;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -134,6 +134,19 @@ public class CalculateUtil {
 | 
				
			|||||||
        return sortedValues.get(position).setScale(2, RoundingMode.HALF_UP);
 | 
					        return sortedValues.get(position).setScale(2, RoundingMode.HALF_UP);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 计算95值位置 从大到小
 | 
				
			||||||
 | 
					     * @param sortedValues
 | 
				
			||||||
 | 
					     * @param percentile
 | 
				
			||||||
 | 
					     * @return
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static int calculate95Index(List<?> sortedValues, double percentile) {
 | 
				
			||||||
 | 
					        int total = sortedValues.size();
 | 
				
			||||||
 | 
					        int position = (int) Math.ceil(percentile * total) - 1;
 | 
				
			||||||
 | 
					        position = Math.max(0, Math.min(position, total - 1));
 | 
				
			||||||
 | 
					        return position;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 根据带宽类型设置时间范围(修复T分隔符问题)
 | 
					     * 根据带宽类型设置时间范围(修复T分隔符问题)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,329 @@
 | 
				
			|||||||
 | 
					package com.ruoyi.system.util;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
 | 
					import org.springframework.data.redis.core.RedisTemplate;
 | 
				
			||||||
 | 
					import org.springframework.stereotype.Component;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.Set;
 | 
				
			||||||
 | 
					import java.util.concurrent.TimeUnit;
 | 
				
			||||||
 | 
					import java.util.function.Predicate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Component
 | 
				
			||||||
 | 
					@SuppressWarnings("unchecked")
 | 
				
			||||||
 | 
					public class TrafficRedisHashUtil {
 | 
				
			||||||
 | 
					    private static final String TRAFFIC_DATA_HASH_KEY = "eps:traffic:hash";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Autowired
 | 
				
			||||||
 | 
					    private RedisTemplate<Object, Object> redisTemplate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 使用Hash结构存储,每个taskId对应一个列表(支持泛型)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> void saveListToHash(String taskId, List<T> dataList) {
 | 
				
			||||||
 | 
					        if (dataList == null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        String hashKey = generateHashKey(taskId);
 | 
				
			||||||
 | 
					        redisTemplate.opsForHash().put(TRAFFIC_DATA_HASH_KEY, hashKey, dataList);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 可选:设置过期时间
 | 
				
			||||||
 | 
					//        redisTemplate.expire(TRAFFIC_DATA_HASH_KEY, 1, TimeUnit.HOURS);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 从Hash获取数据(支持泛型)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> List<T> getListFromHash(String taskId, Class<T> clazz) {
 | 
				
			||||||
 | 
					        String hashKey = generateHashKey(taskId);
 | 
				
			||||||
 | 
					        Object result = redisTemplate.opsForHash().get(TRAFFIC_DATA_HASH_KEY, hashKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (result instanceof List) {
 | 
				
			||||||
 | 
					            return (List<T>) result;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 从Hash获取数据(不指定类型,返回原始List)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public List<?> getListFromHash(String taskId) {
 | 
				
			||||||
 | 
					        String hashKey = generateHashKey(taskId);
 | 
				
			||||||
 | 
					        Object result = redisTemplate.opsForHash().get(TRAFFIC_DATA_HASH_KEY, hashKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (result instanceof List) {
 | 
				
			||||||
 | 
					            return (List<?>) result;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 更新Hash中的特定项(通过createTime匹配)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> void updateItemInHash(String taskId, T updatedItem, Object createTime) {
 | 
				
			||||||
 | 
					        List<T> dataList = (List<T>) getListFromHash(taskId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dataList != null) {
 | 
				
			||||||
 | 
					            for (int i = 0; i < dataList.size(); i++) {
 | 
				
			||||||
 | 
					                T item = dataList.get(i);
 | 
				
			||||||
 | 
					                Object itemCreateTime = getCreateTimeFromObject(item);
 | 
				
			||||||
 | 
					                if (itemCreateTime != null && itemCreateTime.equals(createTime)) {
 | 
				
			||||||
 | 
					                    dataList.set(i, updatedItem);
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            saveListToHash(taskId, dataList);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 更新Hash中的特定项(使用自定义匹配器)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> void updateItemInHash(String taskId, T updatedItem, Predicate<T> matcher) {
 | 
				
			||||||
 | 
					        List<T> dataList = (List<T>) getListFromHash(taskId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dataList != null) {
 | 
				
			||||||
 | 
					            for (int i = 0; i < dataList.size(); i++) {
 | 
				
			||||||
 | 
					                if (matcher.test(dataList.get(i))) {
 | 
				
			||||||
 | 
					                    dataList.set(i, updatedItem);
 | 
				
			||||||
 | 
					                    break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            saveListToHash(taskId, dataList);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 添加新数据项到指定taskId的列表
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> void addItemToHash(String taskId, T newItem) {
 | 
				
			||||||
 | 
					        List<T> dataList = (List<T>) getListFromHash(taskId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dataList == null) {
 | 
				
			||||||
 | 
					            dataList = new ArrayList<>();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        dataList.add(newItem);
 | 
				
			||||||
 | 
					        saveListToHash(taskId, dataList);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 从指定taskId的列表中删除数据项(通过createTime匹配)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> void deleteItemFromHash(String taskId, Object createTime) {
 | 
				
			||||||
 | 
					        List<T> dataList = (List<T>) getListFromHash(taskId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dataList != null) {
 | 
				
			||||||
 | 
					            dataList.removeIf(item -> {
 | 
				
			||||||
 | 
					                Object itemCreateTime = getCreateTimeFromObject(item);
 | 
				
			||||||
 | 
					                return itemCreateTime != null && itemCreateTime.equals(createTime);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            saveListToHash(taskId, dataList);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 从指定taskId的列表中删除数据项(使用自定义匹配器)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> void deleteItemFromHash(String taskId, Predicate<T> matcher) {
 | 
				
			||||||
 | 
					        List<T> dataList = (List<T>) getListFromHash(taskId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dataList != null) {
 | 
				
			||||||
 | 
					            dataList.removeIf(matcher);
 | 
				
			||||||
 | 
					            saveListToHash(taskId, dataList);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 根据createTime范围删除数据项
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> void deleteItemsByCreateTimeRange(String taskId, Object startTime, Object endTime) {
 | 
				
			||||||
 | 
					        List<T> dataList = (List<T>) getListFromHash(taskId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dataList != null) {
 | 
				
			||||||
 | 
					            dataList.removeIf(item -> {
 | 
				
			||||||
 | 
					                Object itemCreateTime = getCreateTimeFromObject(item);
 | 
				
			||||||
 | 
					                if (itemCreateTime == null) return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // 假设createTime是可比较的类型(如Date、Long、LocalDateTime等)
 | 
				
			||||||
 | 
					                if (itemCreateTime instanceof Comparable) {
 | 
				
			||||||
 | 
					                    Comparable<Object> time = (Comparable<Object>) itemCreateTime;
 | 
				
			||||||
 | 
					                    return time.compareTo(startTime) >= 0 && time.compareTo(endTime) <= 0;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            saveListToHash(taskId, dataList);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 根据createTime查找数据项
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> T findItemByCreateTime(String taskId, Object createTime) {
 | 
				
			||||||
 | 
					        List<T> dataList = (List<T>) getListFromHash(taskId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dataList != null) {
 | 
				
			||||||
 | 
					            for (T item : dataList) {
 | 
				
			||||||
 | 
					                Object itemCreateTime = getCreateTimeFromObject(item);
 | 
				
			||||||
 | 
					                if (itemCreateTime != null && itemCreateTime.equals(createTime)) {
 | 
				
			||||||
 | 
					                    return item;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 根据createTime范围查找数据项
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> List<T> findItemsByCreateTimeRange(String taskId, Object startTime, Object endTime) {
 | 
				
			||||||
 | 
					        List<T> dataList = (List<T>) getListFromHash(taskId);
 | 
				
			||||||
 | 
					        List<T> result = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dataList != null) {
 | 
				
			||||||
 | 
					            for (T item : dataList) {
 | 
				
			||||||
 | 
					                Object itemCreateTime = getCreateTimeFromObject(item);
 | 
				
			||||||
 | 
					                if (itemCreateTime != null && itemCreateTime instanceof Comparable) {
 | 
				
			||||||
 | 
					                    Comparable<Object> time = (Comparable<Object>) itemCreateTime;
 | 
				
			||||||
 | 
					                    if (time.compareTo(startTime) >= 0 && time.compareTo(endTime) <= 0) {
 | 
				
			||||||
 | 
					                        result.add(item);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return result;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 获取最早的createTime数据项
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> T getEarliestItem(String taskId) {
 | 
				
			||||||
 | 
					        List<T> dataList = (List<T>) getListFromHash(taskId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dataList == null || dataList.isEmpty()) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        T earliestItem = dataList.get(0);
 | 
				
			||||||
 | 
					        Object earliestTime = getCreateTimeFromObject(earliestItem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 1; i < dataList.size(); i++) {
 | 
				
			||||||
 | 
					            T currentItem = dataList.get(i);
 | 
				
			||||||
 | 
					            Object currentTime = getCreateTimeFromObject(currentItem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (currentTime instanceof Comparable && earliestTime instanceof Comparable) {
 | 
				
			||||||
 | 
					                Comparable<Object> currentComparable = (Comparable<Object>) currentTime;
 | 
				
			||||||
 | 
					                Comparable<Object> earliestComparable = (Comparable<Object>) earliestTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (currentComparable.compareTo(earliestComparable) < 0) {
 | 
				
			||||||
 | 
					                    earliestItem = currentItem;
 | 
				
			||||||
 | 
					                    earliestTime = currentTime;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return earliestItem;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 获取最晚的createTime数据项
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> T getLatestItem(String taskId) {
 | 
				
			||||||
 | 
					        List<T> dataList = (List<T>) getListFromHash(taskId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (dataList == null || dataList.isEmpty()) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        T latestItem = dataList.get(0);
 | 
				
			||||||
 | 
					        Object latestTime = getCreateTimeFromObject(latestItem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 1; i < dataList.size(); i++) {
 | 
				
			||||||
 | 
					            T currentItem = dataList.get(i);
 | 
				
			||||||
 | 
					            Object currentTime = getCreateTimeFromObject(currentItem);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (currentTime instanceof Comparable && latestTime instanceof Comparable) {
 | 
				
			||||||
 | 
					                Comparable<Object> currentComparable = (Comparable<Object>) currentTime;
 | 
				
			||||||
 | 
					                Comparable<Object> latestComparable = (Comparable<Object>) latestTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (currentComparable.compareTo(latestComparable) > 0) {
 | 
				
			||||||
 | 
					                    latestItem = currentItem;
 | 
				
			||||||
 | 
					                    latestTime = currentTime;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return latestItem;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 删除整个taskId对应的缓存
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void deleteTaskData(String taskId) {
 | 
				
			||||||
 | 
					        String hashKey = generateHashKey(taskId);
 | 
				
			||||||
 | 
					        redisTemplate.opsForHash().delete(TRAFFIC_DATA_HASH_KEY, hashKey);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 检查taskId是否存在缓存
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public boolean hasTaskData(String taskId) {
 | 
				
			||||||
 | 
					        String hashKey = generateHashKey(taskId);
 | 
				
			||||||
 | 
					        return redisTemplate.opsForHash().hasKey(TRAFFIC_DATA_HASH_KEY, hashKey);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 获取所有已缓存的taskId列表
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public Set<Object> getAllCachedTaskIds() {
 | 
				
			||||||
 | 
					        return redisTemplate.opsForHash().keys(TRAFFIC_DATA_HASH_KEY);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 设置整个Hash的过期时间
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void setExpire(long timeout, TimeUnit unit) {
 | 
				
			||||||
 | 
					        redisTemplate.expire(TRAFFIC_DATA_HASH_KEY, timeout, unit);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 获取Hash中所有数据的总数
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public long getTotalSize() {
 | 
				
			||||||
 | 
					        return redisTemplate.opsForHash().size(TRAFFIC_DATA_HASH_KEY);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 从对象中提取createTime字段值
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public <T> Object getCreateTimeFromObject(T item) {
 | 
				
			||||||
 | 
					        if (item == null) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            // 尝试通过反射获取createTime字段
 | 
				
			||||||
 | 
					            java.lang.reflect.Field createTimeField = item.getClass().getDeclaredField("createTime");
 | 
				
			||||||
 | 
					            createTimeField.setAccessible(true);
 | 
				
			||||||
 | 
					            return createTimeField.get(item);
 | 
				
			||||||
 | 
					        } catch (NoSuchFieldException e) {
 | 
				
			||||||
 | 
					            // 如果字段名不是createTime,尝试常见的时间字段名
 | 
				
			||||||
 | 
					            String[] timeFieldNames = {"createTime", "create_time", "createdTime", "timestamp", "createAt"};
 | 
				
			||||||
 | 
					            for (String fieldName : timeFieldNames) {
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    java.lang.reflect.Field timeField = item.getClass().getDeclaredField(fieldName);
 | 
				
			||||||
 | 
					                    timeField.setAccessible(true);
 | 
				
			||||||
 | 
					                    return timeField.get(item);
 | 
				
			||||||
 | 
					                } catch (Exception ex) {
 | 
				
			||||||
 | 
					                    // 继续尝试下一个字段名
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String generateHashKey(String taskId) {
 | 
				
			||||||
 | 
					        return "task:" + taskId;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -198,13 +198,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    <select id="getAllDeviceSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
 | 
					    <select id="getAllDeviceSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
 | 
				
			||||||
        SELECT
 | 
					        SELECT
 | 
				
			||||||
            device_sn AS deviceSn
 | 
					            client_id AS clientId, interface_name interfaceName
 | 
				
			||||||
        FROM
 | 
					        FROM
 | 
				
			||||||
            all_interface_name
 | 
					            all_interface_name
 | 
				
			||||||
        <where>
 | 
					        <where>
 | 
				
			||||||
            and resource_type = '1' and device_sn != ''
 | 
					            and resource_type = '1' and interface_name != ''
 | 
				
			||||||
        </where>
 | 
					        </where>
 | 
				
			||||||
            group by device_sn
 | 
					            group by interface_name
 | 
				
			||||||
    </select>
 | 
					    </select>
 | 
				
			||||||
    <select id="getAllSwitchSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
 | 
					    <select id="getAllSwitchSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
 | 
				
			||||||
        SELECT
 | 
					        SELECT
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -248,4 +248,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
				
			|||||||
    <update id="updateMachineTraffic" parameterType="EpsInitialTrafficData">
 | 
					    <update id="updateMachineTraffic" parameterType="EpsInitialTrafficData">
 | 
				
			||||||
        update ${tableName} set machine_flow=#{machineFlow} where client_id=#{clientId} and create_time=#{createTime}
 | 
					        update ${tableName} set machine_flow=#{machineFlow} where client_id=#{clientId} and create_time=#{createTime}
 | 
				
			||||||
    </update>
 | 
					    </update>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <select id="getTrafficListByClientIds" resultType="EpsInitialTrafficData">
 | 
				
			||||||
 | 
					        SELECT
 | 
				
			||||||
 | 
					        sum(ifnull(out_speed,0)) AS outSpeed,
 | 
				
			||||||
 | 
					        create_time AS createTime
 | 
				
			||||||
 | 
					        FROM ${tableName}
 | 
				
			||||||
 | 
					        <where>
 | 
				
			||||||
 | 
					            <if test="businessId != '' and businessId != null">
 | 
				
			||||||
 | 
					                and business_id = #{businessId}
 | 
				
			||||||
 | 
					            </if>
 | 
				
			||||||
 | 
					            <if test="startTime != null">
 | 
				
			||||||
 | 
					                and create_time >= #{startTime}
 | 
				
			||||||
 | 
					            </if>
 | 
				
			||||||
 | 
					            <if test="endTime != null">
 | 
				
			||||||
 | 
					                and create_time <= #{endTime}
 | 
				
			||||||
 | 
					            </if>
 | 
				
			||||||
 | 
					            <if test="clientIds != '' and clientIds != null">
 | 
				
			||||||
 | 
					                and client_id in
 | 
				
			||||||
 | 
					                <foreach collection="clientIds.split(',')" item="clientId" open="(" separator="," close=")">
 | 
				
			||||||
 | 
					                    #{clientId}
 | 
				
			||||||
 | 
					                </foreach>
 | 
				
			||||||
 | 
					            </if>
 | 
				
			||||||
 | 
					        </where>
 | 
				
			||||||
 | 
					        group by create_time
 | 
				
			||||||
 | 
					        ORDER BY out_speed desc
 | 
				
			||||||
 | 
					    </select>
 | 
				
			||||||
</mapper>
 | 
					</mapper>
 | 
				
			||||||
@@ -0,0 +1,127 @@
 | 
				
			|||||||
 | 
					<?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.EpsTaskStatisticsMapper">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <resultMap type="EpsTaskStatistics" id="EpsTaskStatisticsResult">
 | 
				
			||||||
 | 
					        <result property="id"    column="id"    />
 | 
				
			||||||
 | 
					        <result property="taskName"    column="task_name"    />
 | 
				
			||||||
 | 
					        <result property="businessCode"    column="business_code"    />
 | 
				
			||||||
 | 
					        <result property="businessName"    column="business_name"    />
 | 
				
			||||||
 | 
					        <result property="startTime"    column="start_time"    />
 | 
				
			||||||
 | 
					        <result property="endTime"    column="end_time"    />
 | 
				
			||||||
 | 
					        <result property="percentile95"    column="percentile_95"    />
 | 
				
			||||||
 | 
					        <result property="monthlyAvgPercentile95"    column="monthly_avg_percentile_95"    />
 | 
				
			||||||
 | 
					        <result property="resourceType"    column="resource_type"    />
 | 
				
			||||||
 | 
					        <result property="includedResources"    column="included_resources"    />
 | 
				
			||||||
 | 
					        <result property="calculationType"    column="calculation_type"    />
 | 
				
			||||||
 | 
					        <result property="calculationMode"    column="calculation_mode"    />
 | 
				
			||||||
 | 
					        <result property="taskStatus"    column="task_status"    />
 | 
				
			||||||
 | 
					        <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="selectEpsTaskStatisticsVo">
 | 
				
			||||||
 | 
					        select id, task_name, business_code, business_name, start_time, end_time, percentile_95, monthly_avg_percentile_95, resource_type, included_resources, calculation_type, calculation_mode, task_status, create_time, update_time, create_by, update_by from eps_task_statistics
 | 
				
			||||||
 | 
					    </sql>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <select id="selectEpsTaskStatisticsList" parameterType="EpsTaskStatistics" resultMap="EpsTaskStatisticsResult">
 | 
				
			||||||
 | 
					        <include refid="selectEpsTaskStatisticsVo"/>
 | 
				
			||||||
 | 
					        <where>
 | 
				
			||||||
 | 
					            <if test="taskName != null  and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</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 startTime != ''"> and start_time = #{startTime}</if>
 | 
				
			||||||
 | 
					            <if test="endTime != null  and endTime != ''"> and end_time = #{endTime}</if>
 | 
				
			||||||
 | 
					            <if test="percentile95 != null "> and percentile_95 = #{percentile95}</if>
 | 
				
			||||||
 | 
					            <if test="monthlyAvgPercentile95 != null "> and monthly_avg_percentile_95 = #{monthlyAvgPercentile95}</if>
 | 
				
			||||||
 | 
					            <if test="resourceType != null  and resourceType != ''"> and resource_type = #{resourceType}</if>
 | 
				
			||||||
 | 
					            <if test="includedResources != null  and includedResources != ''"> and included_resources = #{includedResources}</if>
 | 
				
			||||||
 | 
					            <if test="calculationType != null  and calculationType != ''"> and calculation_type = #{calculationType}</if>
 | 
				
			||||||
 | 
					            <if test="calculationMode != null  and calculationMode != ''"> and calculation_mode = #{calculationMode}</if>
 | 
				
			||||||
 | 
					            <if test="taskStatus != null  and taskStatus != ''"> and task_status = #{taskStatus}</if>
 | 
				
			||||||
 | 
					        </where>
 | 
				
			||||||
 | 
					    </select>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <select id="selectEpsTaskStatisticsById" parameterType="Long" resultMap="EpsTaskStatisticsResult">
 | 
				
			||||||
 | 
					        <include refid="selectEpsTaskStatisticsVo"/>
 | 
				
			||||||
 | 
					        where id = #{id}
 | 
				
			||||||
 | 
					    </select>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <insert id="insertEpsTaskStatistics" parameterType="EpsTaskStatistics" useGeneratedKeys="true" keyProperty="id">
 | 
				
			||||||
 | 
					        insert into eps_task_statistics
 | 
				
			||||||
 | 
					        <trim prefix="(" suffix=")" suffixOverrides=",">
 | 
				
			||||||
 | 
					            <if test="taskName != null and taskName != ''">task_name,</if>
 | 
				
			||||||
 | 
					            <if test="businessCode != null">business_code,</if>
 | 
				
			||||||
 | 
					            <if test="businessName != null and businessName != ''">business_name,</if>
 | 
				
			||||||
 | 
					            <if test="startTime != null">start_time,</if>
 | 
				
			||||||
 | 
					            <if test="endTime != null">end_time,</if>
 | 
				
			||||||
 | 
					            <if test="percentile95 != null">percentile_95,</if>
 | 
				
			||||||
 | 
					            <if test="monthlyAvgPercentile95 != null">monthly_avg_percentile_95,</if>
 | 
				
			||||||
 | 
					            <if test="resourceType != null">resource_type,</if>
 | 
				
			||||||
 | 
					            <if test="includedResources != null">included_resources,</if>
 | 
				
			||||||
 | 
					            <if test="calculationType != null">calculation_type,</if>
 | 
				
			||||||
 | 
					            <if test="calculationMode != null">calculation_mode,</if>
 | 
				
			||||||
 | 
					            <if test="taskStatus != null and taskStatus != ''">task_status,</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="taskName != null and taskName != ''">#{taskName},</if>
 | 
				
			||||||
 | 
					            <if test="businessCode != null">#{businessCode},</if>
 | 
				
			||||||
 | 
					            <if test="businessName != null and businessName != ''">#{businessName},</if>
 | 
				
			||||||
 | 
					            <if test="startTime != null">#{startTime},</if>
 | 
				
			||||||
 | 
					            <if test="endTime != null">#{endTime},</if>
 | 
				
			||||||
 | 
					            <if test="percentile95 != null">#{percentile95},</if>
 | 
				
			||||||
 | 
					            <if test="monthlyAvgPercentile95 != null">#{monthlyAvgPercentile95},</if>
 | 
				
			||||||
 | 
					            <if test="resourceType != null">#{resourceType},</if>
 | 
				
			||||||
 | 
					            <if test="includedResources != null">#{includedResources},</if>
 | 
				
			||||||
 | 
					            <if test="calculationType != null">#{calculationType},</if>
 | 
				
			||||||
 | 
					            <if test="calculationMode != null">#{calculationMode},</if>
 | 
				
			||||||
 | 
					            <if test="taskStatus != null and taskStatus != ''">#{taskStatus},</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="updateEpsTaskStatistics" parameterType="EpsTaskStatistics">
 | 
				
			||||||
 | 
					        update eps_task_statistics
 | 
				
			||||||
 | 
					        <trim prefix="SET" suffixOverrides=",">
 | 
				
			||||||
 | 
					            <if test="taskName != null and taskName != ''">task_name = #{taskName},</if>
 | 
				
			||||||
 | 
					            <if test="businessCode != null">business_code = #{businessCode},</if>
 | 
				
			||||||
 | 
					            <if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
 | 
				
			||||||
 | 
					            <if test="startTime != null">start_time = #{startTime},</if>
 | 
				
			||||||
 | 
					            <if test="endTime != null">end_time = #{endTime},</if>
 | 
				
			||||||
 | 
					            <if test="percentile95 != null">percentile_95 = #{percentile95},</if>
 | 
				
			||||||
 | 
					            <if test="monthlyAvgPercentile95 != null">monthly_avg_percentile_95 = #{monthlyAvgPercentile95},</if>
 | 
				
			||||||
 | 
					            <if test="resourceType != null">resource_type = #{resourceType},</if>
 | 
				
			||||||
 | 
					            <if test="includedResources != null">included_resources = #{includedResources},</if>
 | 
				
			||||||
 | 
					            <if test="calculationType != null">calculation_type = #{calculationType},</if>
 | 
				
			||||||
 | 
					            <if test="calculationMode != null">calculation_mode = #{calculationMode},</if>
 | 
				
			||||||
 | 
					            <if test="taskStatus != null and taskStatus != ''">task_status = #{taskStatus},</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="deleteEpsTaskStatisticsById" parameterType="Long">
 | 
				
			||||||
 | 
					        delete from eps_task_statistics where id = #{id}
 | 
				
			||||||
 | 
					    </delete>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <delete id="deleteEpsTaskStatisticsByIds" parameterType="String">
 | 
				
			||||||
 | 
					        delete from eps_task_statistics where id in
 | 
				
			||||||
 | 
					        <foreach item="id" collection="array" open="(" separator="," close=")">
 | 
				
			||||||
 | 
					            #{id}
 | 
				
			||||||
 | 
					        </foreach>
 | 
				
			||||||
 | 
					    </delete>
 | 
				
			||||||
 | 
					</mapper>
 | 
				
			||||||
@@ -298,4 +298,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 | 
				
			|||||||
            )
 | 
					            )
 | 
				
			||||||
        </foreach>
 | 
					        </foreach>
 | 
				
			||||||
    </insert>
 | 
					    </insert>
 | 
				
			||||||
 | 
					    <select id="getswitchDetailList" parameterType="InitialSwitchInfoDetails" resultType="InitialSwitchInfoDetails">
 | 
				
			||||||
 | 
					        select in_speed inSpeed, out_speed outSpeed, create_time createTime from initial_switch_info_details
 | 
				
			||||||
 | 
					        <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 >= #{startTime}
 | 
				
			||||||
 | 
					            </if>
 | 
				
			||||||
 | 
					            <if test="endTime != null">
 | 
				
			||||||
 | 
					                and create_time <= #{endTime}
 | 
				
			||||||
 | 
					            </if>
 | 
				
			||||||
 | 
					        </where>
 | 
				
			||||||
 | 
					    </select>
 | 
				
			||||||
 | 
					    <select id="sumSwitchTrafficByclientIds" parameterType="InitialSwitchInfoDetails" resultType="InitialSwitchInfoDetails">
 | 
				
			||||||
 | 
					        select sum(ifnull(in_speed,0)) AS inSpeed,
 | 
				
			||||||
 | 
					        sum(ifnull(out_speed,0)) AS outSpeed,
 | 
				
			||||||
 | 
					        sum(ifnull(max_speed,0)) AS maxSpeed,
 | 
				
			||||||
 | 
					        create_time createTime from initial_switch_info_details
 | 
				
			||||||
 | 
					        <where>
 | 
				
			||||||
 | 
					            <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 >= #{startTime}
 | 
				
			||||||
 | 
					            </if>
 | 
				
			||||||
 | 
					            <if test="endTime != null">
 | 
				
			||||||
 | 
					                and create_time <= #{endTime}
 | 
				
			||||||
 | 
					            </if>
 | 
				
			||||||
 | 
					            <if test="clientIds != '' and clientIds != null">
 | 
				
			||||||
 | 
					                and client_id in
 | 
				
			||||||
 | 
					                <foreach collection="clientIds.split(',')" item="clientId" open="(" separator="," close=")">
 | 
				
			||||||
 | 
					                    #{clientId}
 | 
				
			||||||
 | 
					                </foreach>
 | 
				
			||||||
 | 
					            </if>
 | 
				
			||||||
 | 
					        </where>
 | 
				
			||||||
 | 
					        group by create_time
 | 
				
			||||||
 | 
					        ORDER BY max_speed desc
 | 
				
			||||||
 | 
					    </select>
 | 
				
			||||||
</mapper>
 | 
					</mapper>
 | 
				
			||||||
@@ -128,6 +128,7 @@ public class DeviceMessageHandler {
 | 
				
			|||||||
        registerHandler(MsgEnum.心跳上报.getValue(), this::handleHeartbeatMessage);
 | 
					        registerHandler(MsgEnum.心跳上报.getValue(), this::handleHeartbeatMessage);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * agent更新响应
 | 
					     * agent更新响应
 | 
				
			||||||
     * @param message
 | 
					     * @param message
 | 
				
			||||||
@@ -475,6 +476,13 @@ public class DeviceMessageHandler {
 | 
				
			|||||||
    private void handleSwitchNetMessage(CollectDataVo switchDataVo, String clientId) {
 | 
					    private void handleSwitchNetMessage(CollectDataVo switchDataVo, String clientId) {
 | 
				
			||||||
        List<InitialSwitchInfo> switchInfos = SwitchJsonDataParser.parseJsonData(switchDataVo.getValue(), InitialSwitchInfo.class);
 | 
					        List<InitialSwitchInfo> switchInfos = SwitchJsonDataParser.parseJsonData(switchDataVo.getValue(), InitialSwitchInfo.class);
 | 
				
			||||||
        if(!switchInfos.isEmpty()){
 | 
					        if(!switchInfos.isEmpty()){
 | 
				
			||||||
 | 
					            // 根据clientId查询交换机ip
 | 
				
			||||||
 | 
					            RmResourceRegistrationRemote queryParam = new RmResourceRegistrationRemote();
 | 
				
			||||||
 | 
					            queryParam.setHardwareSn(clientId);
 | 
				
			||||||
 | 
					            R<RmResourceRegistrationRemote> registMsgR = remoteRevenueConfigService.getListByHardwareSn(queryParam, SecurityConstants.INNER);
 | 
				
			||||||
 | 
					            if(registMsgR != null){
 | 
				
			||||||
 | 
					                RmResourceRegistrationRemote registMsg = registMsgR.getData();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            // 时间戳转换
 | 
					            // 时间戳转换
 | 
				
			||||||
            long timestamp = switchDataVo.getTimestamp();
 | 
					            long timestamp = switchDataVo.getTimestamp();
 | 
				
			||||||
            long millis = timestamp * 1000;
 | 
					            long millis = timestamp * 1000;
 | 
				
			||||||
@@ -500,6 +508,9 @@ public class DeviceMessageHandler {
 | 
				
			|||||||
                switchInfos.forEach(switchInfo -> {
 | 
					                switchInfos.forEach(switchInfo -> {
 | 
				
			||||||
                    switchInfo.setClientId(clientId);
 | 
					                    switchInfo.setClientId(clientId);
 | 
				
			||||||
                    switchInfo.setCreateTime(createTime);
 | 
					                    switchInfo.setCreateTime(createTime);
 | 
				
			||||||
 | 
					                    if(registMsgR != null && registMsgR.getData()!=null && registMsgR.getData().getSnmpCollectAddr()!=null){
 | 
				
			||||||
 | 
					                        switchInfo.setSwitchIp(registMsgR.getData().getSnmpCollectAddr());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    InitialSwitchInfoTemp tempInfo = tempMap.get(switchInfo.getName());
 | 
					                    InitialSwitchInfoTemp tempInfo = tempMap.get(switchInfo.getName());
 | 
				
			||||||
                    if (tempInfo != null) {
 | 
					                    if (tempInfo != null) {
 | 
				
			||||||
                        // 计算inSpeed
 | 
					                        // 计算inSpeed
 | 
				
			||||||
@@ -523,6 +534,9 @@ public class DeviceMessageHandler {
 | 
				
			|||||||
                switchInfos.forEach(switchInfo -> {
 | 
					                switchInfos.forEach(switchInfo -> {
 | 
				
			||||||
                    switchInfo.setClientId(clientId);
 | 
					                    switchInfo.setClientId(clientId);
 | 
				
			||||||
                    switchInfo.setCreateTime(createTime);
 | 
					                    switchInfo.setCreateTime(createTime);
 | 
				
			||||||
 | 
					                    if(registMsgR != null && registMsgR.getData()!=null && registMsgR.getData().getSnmpCollectAddr()!=null){
 | 
				
			||||||
 | 
					                        switchInfo.setSwitchIp(registMsgR.getData().getSnmpCollectAddr());
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            // 清空临时表对应switch信息
 | 
					            // 清空临时表对应switch信息
 | 
				
			||||||
@@ -723,9 +737,7 @@ public class DeviceMessageHandler {
 | 
				
			|||||||
        log.info("开启更新资源状态========");
 | 
					        log.info("开启更新资源状态========");
 | 
				
			||||||
        RmResourceRegistrationRemote rmResourceRegistrationRemote = new RmResourceRegistrationRemote();
 | 
					        RmResourceRegistrationRemote rmResourceRegistrationRemote = new RmResourceRegistrationRemote();
 | 
				
			||||||
        rmResourceRegistrationRemote.setOnlineStatus(status);
 | 
					        rmResourceRegistrationRemote.setOnlineStatus(status);
 | 
				
			||||||
        if("0".equals(status)){
 | 
					        rmResourceRegistrationRemote.setRegistrationStatus(status);
 | 
				
			||||||
            rmResourceRegistrationRemote.setRegistrationStatus(status);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        rmResourceRegistrationRemote.setHardwareSn(clientId);
 | 
					        rmResourceRegistrationRemote.setHardwareSn(clientId);
 | 
				
			||||||
        remoteRevenueConfigService.updateStatusByResource(rmResourceRegistrationRemote, SecurityConstants.INNER);
 | 
					        remoteRevenueConfigService.updateStatusByResource(rmResourceRegistrationRemote, SecurityConstants.INNER);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user