From ed5ca585b1bbb1233231b29cfbd6efd99935a442 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Fri, 16 Jun 2023 17:59:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=8F=B0=E7=AB=99?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=AE=A1=E7=90=86=E6=A0=91=E5=BD=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=84=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=B7=B1=E6=8B=B7=E8=B4=9D?= =?UTF-8?q?=E9=9B=86=E5=90=88=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/StationOperationServiceImpl.java | 166 +++++++++++------- 1 file changed, 99 insertions(+), 67 deletions(-) diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/StationOperationServiceImpl.java b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/StationOperationServiceImpl.java index 7758dfd7..af537ba2 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/StationOperationServiceImpl.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/modules/service/impl/StationOperationServiceImpl.java @@ -23,9 +23,11 @@ import org.jeecg.modules.system.entity.GardsNuclearfacility; import org.jeecg.modules.system.entity.GardsStations; import org.jeecg.modules.mapper.StationOperationMapper; import org.jeecg.modules.service.IStationOperationService; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.io.*; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; @@ -206,83 +208,113 @@ public class StationOperationServiceImpl extends ServiceImpl stationInfoMap = (HashMap) redisUtil.get("stationInfoMap"); - //查询全部核设施信息 - HashMap nuclearFacilityMap = (HashMap) redisUtil.get("nuclearFacilityMap"); - if (CollectionUtils.isNotEmpty(nuclearFacilityMap)){ - //声明一个集合存储转换经纬度后的核设施数据 - List nuclearPoints = new ArrayList<>(); - for (Map.Entry nuclearFacilityInfo:nuclearFacilityMap.entrySet()) { - GardsNuclearfacility facilityInfoValue = nuclearFacilityInfo.getValue(); - Point point = new Point(); - point.setNuclearFacilityId(String.valueOf(facilityInfoValue.getFacilityId())); - point.setNuclearFacilityName(facilityInfoValue.getFacilityName()); - if (StringUtils.isNotBlank(facilityInfoValue.getLongitude())){ - String pointValue = PointUtil.calculate(facilityInfoValue.getLongitude()); - facilityInfoValue.setLatitude(pointValue); - point.setLat(pointValue); + try { + if (CollectionUtils.isNotEmpty(stationIds)){ + //查询全部台站信息 + HashMap stationInfoMap = (HashMap) redisUtil.get("stationInfoMap"); + //查询全部核设施信息 + HashMap nuclearFacilityMap = (HashMap) redisUtil.get("nuclearFacilityMap"); + if (CollectionUtils.isNotEmpty(nuclearFacilityMap)){ + //声明一个集合存储转换经纬度后的核设施数据 + List nuclearPoints = new ArrayList<>(); + for (Map.Entry nuclearFacilityInfo:nuclearFacilityMap.entrySet()) { + GardsNuclearfacility facilityInfoValue = nuclearFacilityInfo.getValue(); + Point point = new Point(); + point.setNuclearFacilityId(String.valueOf(facilityInfoValue.getFacilityId())); + point.setNuclearFacilityName(facilityInfoValue.getFacilityName()); + if (StringUtils.isNotBlank(facilityInfoValue.getLongitude())){ + String pointValue = PointUtil.calculate(facilityInfoValue.getLongitude()); + facilityInfoValue.setLatitude(pointValue); + point.setLat(pointValue); + } + if (StringUtils.isNotBlank(facilityInfoValue.getLatitude())){ + String pointValue = PointUtil.calculate(facilityInfoValue.getLatitude()); + facilityInfoValue.setLongitude(pointValue); + point.setLon(pointValue); + } + nuclearPoints.add(point); } - if (StringUtils.isNotBlank(facilityInfoValue.getLatitude())){ - String pointValue = PointUtil.calculate(facilityInfoValue.getLatitude()); - facilityInfoValue.setLongitude(pointValue); - point.setLon(pointValue); + for (String stationId:stationIds) { + GardsStations point = (GardsStations)stationInfoMap.get(stationId); + stationsList.add(point); + //声明一个数组存储对应的核设施经纬度信息 + List nuclearFacilityPoints = deepCopy(nuclearPoints); + //获取当前查询的台站名称 + String stationName = point.getStationCode(); + //获取当前查询的经度 即 圆心位置经度信息 + Double longitudeD = point.getLon(); + //获取当前查询的纬度 即 圆心位置纬度信息 + Double latitudeD = point.getLat(); + if (Objects.isNull(longitudeD)) { + result.error500("请传入经度"); + } + if (Objects.isNull(latitudeD)) { + result.error500("请传入纬度"); + } + if (!(longitudeD >= -180 && longitudeD <= 180)) { + result.error500("经度不合法"); + } + if (!(latitudeD >= -85.05112878 && latitudeD <= 85.05112878)) { + result.error500("纬度不合法"); + } + // 1.获取外接正方形 + Rectangle rectangle = getRectangle(radius, longitudeD, latitudeD); + // 2.获取位置在正方形内的所有设备 判断核设施的经纬度是否为空 不为空 判断经纬度是否在正方形的最大最小范围内 如果在则过滤出来继续使用否则弃用 + nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item-> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) && + (Double.valueOf(item.getLon())>=rectangle.getMinX() && Double.valueOf(item.getLon())<= rectangle.getMaxX()) + && (Double.valueOf(item.getLat())>=rectangle.getMinY() && Double.valueOf(item.getLat())<= rectangle.getMaxY())).collect(Collectors.toList()); + //遍历在正方形范围内的数据 根据点的经纬度信息以及圆心的经纬度信息 计算出两者之间的距离 与 半径进行比较 <=半径则说明点在范围内,否则点超出半径范围 + nuclearFacilityPoints = nuclearFacilityPoints.stream() + .filter(equ -> getDistance(Double.valueOf(equ.getLon()), Double.valueOf(equ.getLat()), longitudeD, latitudeD) <= radius).collect(Collectors.toList()); + //在范围内的点信息 计算点与圆心间的半径距离返回信息 + for (Point p:nuclearFacilityPoints) { + stationsList.add(nuclearFacilityMap.get(p.getNuclearFacilityId())); + //计算点与圆心间的距离信息 + double radiusR = getDistance(Double.valueOf(p.getLon()), Double.valueOf(p.getLat()), longitudeD, latitudeD); + p.setRadius(String.valueOf(radiusR)); + p.setStationName(stationName); + } + if (CollectionUtils.isNotEmpty(nuclearFacilityPoints)){ + resultList.add(nuclearFacilityPoints); + } } - nuclearPoints.add(point); + map.put("GIS", stationsList.stream().distinct().collect(Collectors.toList())); + map.put("table", resultList); } - for (String stationId:stationIds) { - GardsStations point = (GardsStations)stationInfoMap.get(stationId); - stationsList.add(point); - //声明一个数组存储对应的核设施经纬度信息 - List nuclearFacilityPoints = new ArrayList<>(); - nuclearFacilityPoints.addAll(nuclearPoints); - //获取当前查询的台站名称 - String stationName = point.getStationCode(); - //获取当前查询的经度 即 圆心位置经度信息 - Double longitudeD = point.getLon(); - //获取当前查询的纬度 即 圆心位置纬度信息 - Double latitudeD = point.getLat(); - if (Objects.isNull(longitudeD)) { - result.error500("请传入经度"); - } - if (Objects.isNull(latitudeD)) { - result.error500("请传入纬度"); - } - if (!(longitudeD >= -180 && longitudeD <= 180)) { - result.error500("经度不合法"); - } - if (!(latitudeD >= -85.05112878 && latitudeD <= 85.05112878)) { - result.error500("纬度不合法"); - } - // 1.获取外接正方形 - Rectangle rectangle = getRectangle(radius, longitudeD, latitudeD); - // 2.获取位置在正方形内的所有设备 判断核设施的经纬度是否为空 不为空 判断经纬度是否在正方形的最大最小范围内 如果在则过滤出来继续使用否则弃用 - nuclearFacilityPoints = nuclearFacilityPoints.stream().filter(item-> StringUtils.isNotBlank(item.getLon()) && StringUtils.isNotBlank(item.getLat()) && - (Double.valueOf(item.getLon())>=rectangle.getMinX() && Double.valueOf(item.getLon())<= rectangle.getMaxX()) - && (Double.valueOf(item.getLat())>=rectangle.getMinY() && Double.valueOf(item.getLat())<= rectangle.getMaxY())).collect(Collectors.toList()); - //遍历在正方形范围内的数据 根据点的经纬度信息以及圆心的经纬度信息 计算出两者之间的距离 与 半径进行比较 <=半径则说明点在范围内,否则点超出半径范围 - nuclearFacilityPoints = nuclearFacilityPoints.stream() - .filter(equ -> getDistance(Double.valueOf(equ.getLon()), Double.valueOf(equ.getLat()), longitudeD, latitudeD) <= radius).collect(Collectors.toList()); - //在范围内的点信息 计算点与圆心间的半径距离返回信息 - for (Point p:nuclearFacilityPoints) { - stationsList.add(nuclearFacilityMap.get(p.getNuclearFacilityId())); - //计算点与圆心间的距离信息 - double radiusR = getDistance(Double.valueOf(p.getLon()), Double.valueOf(p.getLat()), longitudeD, latitudeD); - p.setRadius(String.valueOf(radiusR)); - p.setStationName(stationName); - } - resultList.add(nuclearFacilityPoints); - } - map.put("GIS", stationsList.stream().distinct().collect(Collectors.toList())); - map.put("table", resultList); } + } catch (IOException e) { + throw new RuntimeException(e); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); } result.setSuccess(true); result.setResult(map); return result; } + /** + * 通过序列化的方式对list进行深复制 + * + * @param src + * @param + * @return + * @throws IOException + * @throws ClassNotFoundException + */ + public static List deepCopy(List src) throws IOException, ClassNotFoundException { + + ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(byteOut); + out.writeObject(src); + + ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray()); + ObjectInputStream in = new ObjectInputStream(byteIn); + + @SuppressWarnings("unchecked") + List dest = (List) in.readObject(); + return dest; + } + @Override public Result getDataReceivingStatus(List stationIds) { Result result = new Result(); From fa2366b8aa4e54560f5fc01f293fcf683fa1189d Mon Sep 17 00:00:00 2001 From: nieziyan Date: Fri, 16 Jun 2023 20:12:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=EF=BC=9A=E4=BE=9D=E8=B5=96=E8=A1=A5?= =?UTF-8?q?=E5=85=A8=20update=EF=BC=9A=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AlarmLogController.java | 8 +-- .../jeecg/modules/mapper/AlarmLogMapper.java | 4 +- .../modules/mapper/xml/AlarmLogMapper.xml | 55 +++++++------------ .../service/impl/AlarmLogServiceImpl.java | 45 ++++++++++----- .../java/org/jeecg/modules/vo/AlarmVo.java | 2 + .../system/controller/LoginController.java | 7 ++- .../jeecg-abnormal-alarm-start/pom.xml | 8 ++- .../jeecg-log-manage-start/pom.xml | 5 ++ .../jeecg-station-operation-start/pom.xml | 5 ++ .../jeecg-web-statistics-start/pom.xml | 5 ++ 10 files changed, 83 insertions(+), 61 deletions(-) diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/controller/AlarmLogController.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/controller/AlarmLogController.java index a6f0f6be..16ed0341 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/controller/AlarmLogController.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/controller/AlarmLogController.java @@ -16,20 +16,20 @@ public class AlarmLogController { @Autowired private IAlarmLogService alarmLogService; @ApiOperation("报警日志量总览-柱状图") - @GetMapping("viewAll") + @PostMapping("viewAll") public Result viewAll(@RequestBody AlarmVo alarmVo){ return alarmLogService.viewAll(alarmVo); } @ApiOperation("分页查询报警日志信息") - @GetMapping("findPage") + @PostMapping("findPage") public Result findPage(@RequestBody AlarmVo alarmVo){ return alarmLogService.findPage(alarmVo); } @ApiOperation("各类型报警量统计-饼图") - @GetMapping("typeAlarms") + @PostMapping("typeAlarms") public Result typeAlarms(@RequestBody AlarmVo alarmVo){ return alarmLogService.typeAlarms(alarmVo); } @ApiOperation("报警规则top5-柱状图") - @GetMapping("ruleTop") + @PostMapping("ruleTop") public Result ruleTop5(@RequestBody AlarmVo alarmVo){ return alarmLogService.ruleTop5(alarmVo); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/AlarmLogMapper.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/AlarmLogMapper.java index 602bd02f..4be954c9 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/AlarmLogMapper.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/AlarmLogMapper.java @@ -13,9 +13,7 @@ import java.util.Map; public interface AlarmLogMapper extends BaseMapper { - List oneDay(Map params); - - List oneMoreDay(Map params); + List rangeDay(Map params); List findPage(Map params); List typeAlarms(Map params); diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/AlarmLogMapper.xml b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/AlarmLogMapper.xml index ceca8246..64f9b6b2 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/AlarmLogMapper.xml +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/mapper/xml/AlarmLogMapper.xml @@ -1,6 +1,24 @@ + - - \ No newline at end of file diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AlarmLogServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AlarmLogServiceImpl.java index cc2719ed..d6f15fad 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AlarmLogServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/AlarmLogServiceImpl.java @@ -1,6 +1,7 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -37,11 +38,26 @@ public class AlarmLogServiceImpl extends ServiceImpl i public Result viewAll(AlarmVo alarmVo) { String startDate = alarmVo.getStartDate(); String endDate = alarmVo.getEndDate(); + // 拼接日期为合理的日期+时间范围 + alarmVo.setStartDate(startDate + " 00:00:00"); + alarmVo.setEndDate(endDate + " 23:59:59"); + // 定义返回结果 + Set xData = new HashSet<>(); + Collection YData = new ArrayList<>(); + Map result = new HashMap<>(); + // 转换参数 数据查询 Map params = BeanUtil.beanToMap(alarmVo); - List allDate; - /* 选择日期为同一天 按照小时划分 0-23小时 */ + List allDate = baseMapper.rangeDay(params); + // 查询数据为空则直接返回空集合 + if (CollUtil.isEmpty(allDate)){ + result.put("xData",xData); + result.put("yData",YData); + return Result.OK(result); + } + // 分情况处理 1.按小时统计 2.按天统计 + + /* 1.选择日期为同一天 按照小时划分 0-23小时 */ if (startDate.equals(endDate)){ - allDate = baseMapper.oneDay(params); Map> groupTime = allDate.stream() .sorted(Comparator.comparing(Date::getHours)) .collect(Collectors.groupingBy(Date::getHours)); @@ -55,17 +71,14 @@ public class AlarmLogServiceImpl extends ServiceImpl i } } // 返回x轴和y轴数据 - Set xData = statistic.keySet(); - Collection YData = statistic.values(); - Map result = new HashMap<>(); + xData = statistic.keySet(); + YData = statistic.values(); result.put("xData",xData); result.put("yData",YData); return Result.OK(result); } - /* 选择日期不是同一天 按照天划分(可以跨月选择,但不包括跨年) */ + /* 2.选择日期不是同一天 按照天划分(可以跨月选择,但不包括跨年) */ else { - allDate = baseMapper.oneMoreDay(params); - Map statistic = new HashMap<>(); // 通过mounth分组 Map> groupMounth = allDate.stream() @@ -102,16 +115,16 @@ public class AlarmLogServiceImpl extends ServiceImpl i return dateStr; }) .collect(Collectors.toList()); - // 将startDate和endDate中没有预警信息的day设置为0 + // startDate和endDate范围内无报警信息 + // 的日期(哪一天),将其报警数量设置为0 for (String dateStr : allDateStr) { if (!allDateStr.contains(dateStr)){ statistic.put(dateStr,0); } } // 返回x轴和y轴数据 - Set xData = statistic.keySet(); - Collection YData = statistic.values(); - Map result = new HashMap<>(); + xData = statistic.keySet(); + YData = statistic.values(); result.put("xData",xData); result.put("yData",YData); return Result.OK(result); @@ -134,8 +147,10 @@ public class AlarmLogServiceImpl extends ServiceImpl i List alarmHistories = baseMapper.findPage(params); // 当前页数据 page.setRecords(alarmHistories); - // 数据总条数 - page.setTotal(this.count()); + // 获取数据总条数(经过查询条件过滤后的) + params.put("pageFlag","noPage"); + Integer total = baseMapper.findPage(params).size(); + page.setTotal(total); return Result.OK(page); } diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/vo/AlarmVo.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/vo/AlarmVo.java index c3e3a8ed..6101023e 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/vo/AlarmVo.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/vo/AlarmVo.java @@ -11,4 +11,6 @@ public class AlarmVo extends QueryRequest implements Serializable { private String startDate; private String endDate; private Integer pageStart; + // 标记:根据条件查询但不进行分页 + private String pageFlag; } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/LoginController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/LoginController.java index e9a5febc..15c22bb9 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/LoginController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/LoginController.java @@ -88,7 +88,8 @@ public class LoginController { //update-begin--Author:scott Date:20190805 for:暂时注释掉密码加密逻辑,有点问题 //update-begin-author:taoyan date:20190828 for:校验验证码 - String captcha = sysLoginModel.getCaptcha(); + + /* String captcha = sysLoginModel.getCaptcha(); if(captcha==null){ result.error500("验证码无效"); return result; @@ -107,7 +108,7 @@ public class LoginController { // 改成特殊的code 便于前端判断 result.setCode(HttpStatus.PRECONDITION_FAILED.value()); return result; - } + }*/ //update-end-author:taoyan date:20190828 for:校验验证码 //1. 校验用户是否有效 @@ -135,7 +136,7 @@ public class LoginController { //用户登录信息 userInfo(sysUser, result); //update-begin--Author:liusq Date:20210126 for:登录成功,删除redis中的验证码 - redisUtil.del(realKey); + //redisUtil.del(realKey); //update-begin--Author:liusq Date:20210126 for:登录成功,删除redis中的验证码 redisUtil.del(CommonConstant.LOGIN_FAIL + username); LoginUser loginUser = new LoginUser(); diff --git a/jeecg-server-cloud/jeecg-abnormal-alarm-start/pom.xml b/jeecg-server-cloud/jeecg-abnormal-alarm-start/pom.xml index 122699d8..fd53e604 100644 --- a/jeecg-server-cloud/jeecg-abnormal-alarm-start/pom.xml +++ b/jeecg-server-cloud/jeecg-abnormal-alarm-start/pom.xml @@ -12,8 +12,12 @@ jeecg-abnormal-alarm-start - - + + + org.jeecgframework.boot + jeecg-system-cloud-api + + org.jeecgframework.boot jeecg-module-abnormal-alarm diff --git a/jeecg-server-cloud/jeecg-log-manage-start/pom.xml b/jeecg-server-cloud/jeecg-log-manage-start/pom.xml index 3b61cf75..1ad7845d 100644 --- a/jeecg-server-cloud/jeecg-log-manage-start/pom.xml +++ b/jeecg-server-cloud/jeecg-log-manage-start/pom.xml @@ -12,6 +12,11 @@ jeecg-log-manage-start + + + org.jeecgframework.boot + jeecg-system-cloud-api + org.jeecgframework.boot jeecg-module-log-manage diff --git a/jeecg-server-cloud/jeecg-station-operation-start/pom.xml b/jeecg-server-cloud/jeecg-station-operation-start/pom.xml index a928046c..76b20966 100644 --- a/jeecg-server-cloud/jeecg-station-operation-start/pom.xml +++ b/jeecg-server-cloud/jeecg-station-operation-start/pom.xml @@ -12,6 +12,11 @@ jeecg-station-operation-start + + + org.jeecgframework.boot + jeecg-system-cloud-api + org.jeecgframework.boot jeecg-module-station-operation diff --git a/jeecg-server-cloud/jeecg-web-statistics-start/pom.xml b/jeecg-server-cloud/jeecg-web-statistics-start/pom.xml index f2c7f6dd..1c19ef8d 100644 --- a/jeecg-server-cloud/jeecg-web-statistics-start/pom.xml +++ b/jeecg-server-cloud/jeecg-web-statistics-start/pom.xml @@ -12,6 +12,11 @@ jeecg-web-statistics-start + + + org.jeecgframework.boot + jeecg-system-cloud-api + org.jeecgframework.boot jeecg-module-web-statistics