fix:近6个月统计涉密网络统计

pg_adapter
wangxy 6 months ago
parent b5e58808da
commit 0c12619c3d

@ -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);
}
}

@ -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);
}

@ -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);
}

@ -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);
}
}

@ -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 &gt;= #{minDayTime}
AND t.net_date &lt;= #{maxDayTime}
</select>
</mapper>
Loading…
Cancel
Save