From 24af04b9d52d61f8431b8bd6fe1f1c7f3acabb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E9=9B=AA=E4=BC=9F?= Date: Thu, 7 Nov 2024 13:54:49 +0800 Subject: [PATCH] =?UTF-8?q?business=E6=9C=8D=E5=8A=A1bug=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AE=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=9D=90=E6=A0=87=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IHwDeviceModeService.java | 2 + .../business/service/IHwDeviceService.java | 1 + .../service/impl/HwDeviceModeServiceImpl.java | 9 ++++ .../service/impl/HwDeviceServiceImpl.java | 52 +++++++++++++++++-- .../impl/HwMonitorPlatformServiceImpl.java | 5 ++ .../mapper/business/HwAlarmInfoMapper.xml | 1 + .../mapper/business/HwMonitorUnitMapper.xml | 2 +- 7 files changed, 67 insertions(+), 5 deletions(-) diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java index 0523311..2570515 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceModeService.java @@ -138,4 +138,6 @@ public interface IHwDeviceModeService List selectModel(Long sceneId); List getDeviceByModel(Long modelId); + + Map getDeviceLocation(Long deviceId); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceService.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceService.java index 4599534..fd8ed0b 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceService.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/IHwDeviceService.java @@ -264,4 +264,5 @@ public interface IHwDeviceService { ListselectMonitorUnitAndDeviceByName(Map map); + Map getDeviceLocation(Long deviceId); } diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java index 79b50f8..0eea3a2 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceModeServiceImpl.java @@ -24,6 +24,7 @@ import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.tdengine.api.RemoteTdEngineService; import com.ruoyi.tdengine.api.domain.TdField; +import com.ruoyi.tdengine.api.domain.TdSelectDto; import com.ruoyi.tdengine.api.domain.TdSuperTableVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -449,6 +450,14 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService { System.out.println(hwDeviceMapper.getDeviceByModel(modelId)); return hwDeviceMapper.getDeviceByModel(modelId); } + public Map getDeviceLocation(Long deviceId) { + TdSelectDto tdSelectDto = new TdSelectDto(); + tdSelectDto.setDatabaseName("db_hwsaas"); + tdSelectDto.setTableName("t_device_"+deviceId); + R> deviceLocation = remoteTdEngineService.getDeviceLocation(tdSelectDto, SecurityConstants.FROM_SOURCE); + Map data = deviceLocation.getData(); + return data; + } /** diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java index 8a8775a..7d17347 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwDeviceServiceImpl.java @@ -8,6 +8,7 @@ import com.ruoyi.business.domain.*; import com.ruoyi.business.domain.VO.*; import com.ruoyi.business.mapper.*; import com.ruoyi.business.service.IHwDeviceService; +import com.ruoyi.business.utils.GpsCoordinateUtils; import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.constant.HwDictConstants; import com.ruoyi.common.core.constant.SecurityConstants; @@ -76,6 +77,8 @@ public class HwDeviceServiceImpl implements IHwDeviceService { private RedisService redisService; @Autowired private HwFenceAreaMapper hwFenceAreaMapper; + public static final String SEPARATOR_UNDERLINE = "_"; + public static final String SEPARATOR_COMMA = ","; /** * 查询设备信息 * @@ -360,7 +363,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { @Override public int changeDeviceStatus(HwDevice hwDevice) { HwDevice dbDevice = hwDeviceMapper.selectHwDeviceByDeviceId(hwDevice.getDeviceId()); - if (dbDevice.getDeviceStatus().equals(HwDictConstants.DEVICE_STATUS_PUBLISH)) { + if (dbDevice.getDeviceStatus().equals(HwDictConstants.DEVICE_STATUS_PUBLISH) && !hwDevice.getDeviceStatus().equals("0")) { throw new ServiceException("已发布状态不能修改"); } hwDevice.setUpdateBy(SecurityUtils.getUsername()); @@ -1264,10 +1267,17 @@ public class HwDeviceServiceImpl implements IHwDeviceService { String tableName = tdSelectDto.getTableName(); int underscoreIndex = tableName.lastIndexOf('_'); int deviceId = Integer.parseInt(tableName.substring(underscoreIndex + 1)); - HwDevice hwDevice = hwDevices.stream().filter(x -> x.getDeviceId() == deviceId).findFirst().get(); - if(hwDevice == null){ + Optional first = hwDevices.stream().filter(x -> x.getDeviceId() == deviceId).findFirst(); + HwDevice hwDevice = new HwDevice(); + if (first.isPresent()){ + hwDevice = first.get(); + }else { continue; } +// HwDevice hwDevice = hwDevices.stream().filter(x -> x.getDeviceId() == deviceId).findFirst().get(); +// if(hwDevice == null){ +// continue; +// } BeaconDevice beaconDevice = new BeaconDevice(); beaconDevice.setDeviceId(hwDevice.getDeviceId()); @@ -1554,6 +1564,30 @@ public class HwDeviceServiceImpl implements IHwDeviceService { HwFenceArea hwFenceArea = new HwFenceArea(); hwFenceArea.setElectronicFenceId(hwElectronicFences.get(i).getElectronicFenceId()); List hwFenceAreaList = hwFenceAreaMapper.selectHwFenceAreaList(hwFenceArea); +// for (HwFenceArea fenceArea : hwFenceAreaList) { +// if (fenceArea.getAreaShapeFlag().equals("1")){ +// String[] points = fenceArea.getAreaRange().split("_"); +// StringBuilder areaRange = new StringBuilder(); +// for (String point : points) { +// areaRange.append(SEPARATOR_UNDERLINE); +// String[] location = point.split(","); +// double longitude = Double.parseDouble(location[0]); +// double latitude = Double.parseDouble(location[1]); +// double[] doubles = GpsCoordinateUtils.calWGS84toGCJ02(latitude, longitude); +// areaRange.append(doubles[1]).append(SEPARATOR_COMMA) +// .append(doubles[0]); +// } +// fenceArea.setAreaRange(areaRange.toString().replaceFirst(SEPARATOR_UNDERLINE, "")); +// } +// if (fenceArea.getAreaShapeFlag().equals("2")){ +// String areaRange = fenceArea.getAreaRange(); +// String[] points = areaRange.split(","); +// double longitude = Double.parseDouble(points[0]); +// double latitude = Double.parseDouble(points[1]); +// double[] doubles = GpsCoordinateUtils.calWGS84toGCJ02(latitude, longitude); +// fenceArea.setAreaRange(longitude+","+latitude+","+points[2]); +// } +// } hwElectronicFences.get(i).setHwFenceAreaList(hwFenceAreaList); } return hwElectronicFences; @@ -1575,7 +1609,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService { Long integer = hwDeviceMapper.selectDeviceIfAlarm(Long.valueOf(map.get("deviceId"))); String ifAlarm = new String(); if (integer>0){ - //正常 + //有未处理报警 ifAlarm="1"; } else { @@ -1643,6 +1677,16 @@ public class HwDeviceServiceImpl implements IHwDeviceService { } + @Override + public Map getDeviceLocation(Long deviceId) { + TdSelectDto tdSelectDto = new TdSelectDto(); + tdSelectDto.setDatabaseName("db_hwsaas"); + tdSelectDto.setTableName("t_device_"+deviceId); + R> deviceLocation = remoteTdEngineService.getDeviceLocation(tdSelectDto, SecurityConstants.INNER); + Map data = deviceLocation.getData(); + return data; + } + /** * 根据名字搜索信标设备 * */ diff --git a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorPlatformServiceImpl.java b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorPlatformServiceImpl.java index c6c2c8c..361ff79 100644 --- a/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorPlatformServiceImpl.java +++ b/ruoyi-modules/hw-business/src/main/java/com/ruoyi/business/service/impl/HwMonitorPlatformServiceImpl.java @@ -124,6 +124,11 @@ public class HwMonitorPlatformServiceImpl implements IHwMonitorPlatformService { } } + deviceDataColumnVos.remove(3); + DeviceDataColumnVo deviceDataColumnVo = deviceDataColumnVos.get(5); + DeviceDataColumnVo deviceDataColumnVo1 = deviceDataColumnVos.get(deviceDataColumnVos.size()-1); + deviceDataColumnVos.set(5,deviceDataColumnVo1); + deviceDataColumnVos.set(deviceDataColumnVos.size()-1,deviceDataColumnVo); returnObj.put("deviceDataColumns", deviceDataColumnVos); returnObj.put("latestData", latestDataMaps); return returnObj; diff --git a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml index 16d2c2a..298ce55 100644 --- a/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml +++ b/ruoyi-modules/hw-business/src/main/resources/mapper/business/HwAlarmInfoMapper.xml @@ -131,6 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select * from hw_device where device_mode_id = (select device_mode_id from hw_device_mode where gps_flag = 1 and scene_id = #{sceneId} -) and scene_id = #{sceneId} +) and scene_id = #{sceneId} and device_status != 9