From 0c12619c3d83093353c29a8954f04da95ce7ba2b Mon Sep 17 00:00:00 2001 From: wangxy <1481820854@qq.com> Date: Wed, 9 Oct 2024 14:18:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=BF=916=E4=B8=AA=E6=9C=88=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=B6=89=E5=AF=86=E7=BD=91=E7=BB=9C=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/count/SysNetworknumController.java | 43 +++++++++++++++++++ .../system/mapper/TdPropertyNetMapper.java | 3 ++ .../system/service/ITdPropertyNetService.java | 4 ++ .../impl/TdPropertyNetServiceImpl.java | 7 +++ .../mapper/system/TdPropertyNetMapper.xml | 8 +++- 5 files changed, 63 insertions(+), 2 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysNetworknumController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysNetworknumController.java index 1be680c..e7f1009 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysNetworknumController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/count/SysNetworknumController.java @@ -1,5 +1,6 @@ package com.ruoyi.web.controller.system.count; +import cn.hutool.core.text.StrPool; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; @@ -7,9 +8,11 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.ObtainLastSixMonthsUtil; import com.ruoyi.system.domain.TdPropertyInfo; import com.ruoyi.system.domain.TdPropertyNet; import com.ruoyi.system.domain.TdPropertyNetinfo; +import com.ruoyi.system.domain.count.PropertyManagerDTO; import com.ruoyi.system.service.ISysDictDataService; import com.ruoyi.system.service.ITdPropertyNetService; import com.ruoyi.system.service.ITdPropertyNetinfoService; @@ -19,7 +22,10 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; +import java.time.LocalDate; +import java.time.ZoneId; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; @@ -132,4 +138,41 @@ public class SysNetworknumController extends BaseController { return AjaxResult.success(obj); } + + /** + * + *近6个月统计涉密网络统计 + * @return + */ + @PostMapping("/countNetMonth") + @ResponseBody + public AjaxResult countNetMonth() { + List recentlySixMonth = ObtainLastSixMonthsUtil.getRecentlySixMonth(); + List yAxisData = new ArrayList<>(); + recentlySixMonth.forEach(month -> { + // 获取指定月份的最大日期 + String lastDayOfMonth = ObtainLastSixMonthsUtil.getLastDayOfMonth(month); + // 获取指定天的最大时间 + Date date = Date.from(LocalDate.parse(lastDayOfMonth).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()); + Date maxDayTime = ObtainLastSixMonthsUtil.getEndOfDay(date); + // 获取最小时间 + date = Date.from(LocalDate.parse(month.concat(StrPool.DASHED).concat("01")).atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()); + Date minDayTime = ObtainLastSixMonthsUtil.getStartOfDay(date); + AtomicReference yAxis = new AtomicReference<>(0L); + PropertyManagerDTO tdPropertyManager = new PropertyManagerDTO(); + tdPropertyManager.setMinDayTime(minDayTime); + tdPropertyManager.setMaxDayTime(maxDayTime); + Integer count = tdPropertyNetService.countMessageMonth(tdPropertyManager); + if(Objects.isNull(count)){ + count = 0; + } + yAxis.set(Long.valueOf(count)); + yAxisData.add(yAxis.get()); + }); + JSONObject obj = new JSONObject(); + obj.put("xAxisData", recentlySixMonth.toArray()); + obj.put("yAxisData", yAxisData); + return AjaxResult.success(obj); + } + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TdPropertyNetMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TdPropertyNetMapper.java index 522d923..2bff9be 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TdPropertyNetMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TdPropertyNetMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.system.mapper; import java.util.List; import com.ruoyi.system.domain.TdPropertyNet; +import com.ruoyi.system.domain.count.PropertyManagerDTO; /** * 涉密网络设备Mapper接口 @@ -61,4 +62,6 @@ public interface TdPropertyNetMapper public Integer selectCountMi(String netMiji); + + public Integer countMessageMonth(PropertyManagerDTO propertyManagerDTO); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITdPropertyNetService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITdPropertyNetService.java index 1e9291d..96178c6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITdPropertyNetService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITdPropertyNetService.java @@ -2,6 +2,7 @@ package com.ruoyi.system.service; import java.util.List; import com.ruoyi.system.domain.TdPropertyNet; +import com.ruoyi.system.domain.count.PropertyManagerDTO; /** * 涉密网络设备Service接口 @@ -61,4 +62,7 @@ public interface ITdPropertyNetService public Integer selectCountMi(String netMiji); + + + public Integer countMessageMonth(PropertyManagerDTO propertyManagerDTO); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TdPropertyNetServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TdPropertyNetServiceImpl.java index 8ad9ead..388a790 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TdPropertyNetServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TdPropertyNetServiceImpl.java @@ -1,6 +1,8 @@ package com.ruoyi.system.service.impl; import java.util.List; + +import com.ruoyi.system.domain.count.PropertyManagerDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.TdPropertyNetMapper; @@ -96,4 +98,9 @@ public class TdPropertyNetServiceImpl implements ITdPropertyNetService public Integer selectCountMi(String netMiji) { return tdPropertyNetMapper.selectCountMi(netMiji); } + + @Override + public Integer countMessageMonth(PropertyManagerDTO propertyManagerDTO) { + return tdPropertyNetMapper.countMessageMonth(propertyManagerDTO); + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/TdPropertyNetMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TdPropertyNetMapper.xml index 7a5f98a..b39c0ed 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TdPropertyNetMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TdPropertyNetMapper.xml @@ -104,8 +104,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - + \ No newline at end of file