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<String> recentlySixMonth = ObtainLastSixMonthsUtil.getRecentlySixMonth(); + List<Long> 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<Long> 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" <select id="selectCountMi" parameterType="String" resultType="Integer"> SELECT sum(terminal_num) as total FROM td_property_net where net_miji=#{netMiji} </select> - - + <select id="countMessageMonth" resultType="java.lang.Integer" parameterType="PropertyManagerDTO"> + SELECT COUNT(t.*) from td_property_net t RIGHT JOIN td_property_netinfo d + on t.net_id = d.net_id where + t.net_date >= #{minDayTime} + AND t.net_date <= #{maxDayTime} + </select> </mapper> \ No newline at end of file