business服务bug修改,新增根据设备获取坐标接口

breach-zhy
马雪伟 3 weeks ago
parent ece255f5ed
commit 24af04b9d5

@ -138,4 +138,6 @@ public interface IHwDeviceModeService
List<HwDeviceMode> selectModel(Long sceneId); List<HwDeviceMode> selectModel(Long sceneId);
List<HwDevice> getDeviceByModel(Long modelId); List<HwDevice> getDeviceByModel(Long modelId);
Map getDeviceLocation(Long deviceId);
} }

@ -264,4 +264,5 @@ public interface IHwDeviceService {
List<HwDevice>selectMonitorUnitAndDeviceByName(Map map); List<HwDevice>selectMonitorUnitAndDeviceByName(Map map);
Map getDeviceLocation(Long deviceId);
} }

@ -24,6 +24,7 @@ import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.system.api.model.LoginUser;
import com.ruoyi.tdengine.api.RemoteTdEngineService; import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.TdField; import com.ruoyi.tdengine.api.domain.TdField;
import com.ruoyi.tdengine.api.domain.TdSelectDto;
import com.ruoyi.tdengine.api.domain.TdSuperTableVo; import com.ruoyi.tdengine.api.domain.TdSuperTableVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -449,6 +450,14 @@ public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
System.out.println(hwDeviceMapper.getDeviceByModel(modelId)); System.out.println(hwDeviceMapper.getDeviceByModel(modelId));
return 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<Map<String, Object>> deviceLocation = remoteTdEngineService.getDeviceLocation(tdSelectDto, SecurityConstants.FROM_SOURCE);
Map<String, Object> data = deviceLocation.getData();
return data;
}
/** /**

@ -8,6 +8,7 @@ import com.ruoyi.business.domain.*;
import com.ruoyi.business.domain.VO.*; import com.ruoyi.business.domain.VO.*;
import com.ruoyi.business.mapper.*; import com.ruoyi.business.mapper.*;
import com.ruoyi.business.service.IHwDeviceService; 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.Constants;
import com.ruoyi.common.core.constant.HwDictConstants; import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.constant.SecurityConstants; import com.ruoyi.common.core.constant.SecurityConstants;
@ -76,6 +77,8 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
private RedisService redisService; private RedisService redisService;
@Autowired @Autowired
private HwFenceAreaMapper hwFenceAreaMapper; 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 @Override
public int changeDeviceStatus(HwDevice hwDevice) { public int changeDeviceStatus(HwDevice hwDevice) {
HwDevice dbDevice = hwDeviceMapper.selectHwDeviceByDeviceId(hwDevice.getDeviceId()); 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("已发布状态不能修改"); throw new ServiceException("已发布状态不能修改");
} }
hwDevice.setUpdateBy(SecurityUtils.getUsername()); hwDevice.setUpdateBy(SecurityUtils.getUsername());
@ -1264,10 +1267,17 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
String tableName = tdSelectDto.getTableName(); String tableName = tdSelectDto.getTableName();
int underscoreIndex = tableName.lastIndexOf('_'); int underscoreIndex = tableName.lastIndexOf('_');
int deviceId = Integer.parseInt(tableName.substring(underscoreIndex + 1)); int deviceId = Integer.parseInt(tableName.substring(underscoreIndex + 1));
HwDevice hwDevice = hwDevices.stream().filter(x -> x.getDeviceId() == deviceId).findFirst().get(); Optional<HwDevice> first = hwDevices.stream().filter(x -> x.getDeviceId() == deviceId).findFirst();
if(hwDevice == null){ HwDevice hwDevice = new HwDevice();
if (first.isPresent()){
hwDevice = first.get();
}else {
continue; continue;
} }
// HwDevice hwDevice = hwDevices.stream().filter(x -> x.getDeviceId() == deviceId).findFirst().get();
// if(hwDevice == null){
// continue;
// }
BeaconDevice beaconDevice = new BeaconDevice(); BeaconDevice beaconDevice = new BeaconDevice();
beaconDevice.setDeviceId(hwDevice.getDeviceId()); beaconDevice.setDeviceId(hwDevice.getDeviceId());
@ -1554,6 +1564,30 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
HwFenceArea hwFenceArea = new HwFenceArea(); HwFenceArea hwFenceArea = new HwFenceArea();
hwFenceArea.setElectronicFenceId(hwElectronicFences.get(i).getElectronicFenceId()); hwFenceArea.setElectronicFenceId(hwElectronicFences.get(i).getElectronicFenceId());
List<HwFenceArea> hwFenceAreaList = hwFenceAreaMapper.selectHwFenceAreaList(hwFenceArea); List<HwFenceArea> 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); hwElectronicFences.get(i).setHwFenceAreaList(hwFenceAreaList);
} }
return hwElectronicFences; return hwElectronicFences;
@ -1575,7 +1609,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
Long integer = hwDeviceMapper.selectDeviceIfAlarm(Long.valueOf(map.get("deviceId"))); Long integer = hwDeviceMapper.selectDeviceIfAlarm(Long.valueOf(map.get("deviceId")));
String ifAlarm = new String(); String ifAlarm = new String();
if (integer>0){ if (integer>0){
//正常 //有未处理报警
ifAlarm="1"; ifAlarm="1";
} }
else { 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<Map<String, Object>> deviceLocation = remoteTdEngineService.getDeviceLocation(tdSelectDto, SecurityConstants.INNER);
Map<String, Object> data = deviceLocation.getData();
return data;
}
/** /**
* *
* */ * */

@ -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("deviceDataColumns", deviceDataColumnVos);
returnObj.put("latestData", latestDataMaps); returnObj.put("latestData", latestDataMaps);
return returnObj; return returnObj;

@ -131,6 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectHwAlarmInfoList" parameterType="HwAlarmInfo" resultMap="HwAlarmInfoResult"> <select id="selectHwAlarmInfoList" parameterType="HwAlarmInfo" resultMap="HwAlarmInfoResult">
<include refid="selectHwAlarmInfoVo"/> <include refid="selectHwAlarmInfoVo"/>
<where> <where>
hai.handle_status = '0'
<if test="alarmInfoType != null and alarmInfoType != ''"> and alarm_info_type = #{alarmInfoType}</if> <if test="alarmInfoType != null and alarmInfoType != ''"> and alarm_info_type = #{alarmInfoType}</if>
<if test="alarmReleatedId != null "> and alarm_releated_id = #{alarmReleatedId}</if> <if test="alarmReleatedId != null "> and alarm_releated_id = #{alarmReleatedId}</if>
<if test="deviceId != null "> and device_id = #{deviceId}</if> <if test="deviceId != null "> and device_id = #{deviceId}</if>

@ -332,7 +332,7 @@
<select id="selectBeaconDeviceBySceneId" parameterType="Long" resultType="int"> <select id="selectBeaconDeviceBySceneId" parameterType="Long" resultType="int">
select * from hw_device where device_mode_id = select * from hw_device where device_mode_id =
(select device_mode_id from hw_device_mode where gps_flag = 1 and scene_id = #{sceneId} (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
</select> </select>
<select id="selectMonitorUnit" parameterType="Long" resultMap="HwMonitorUnitResult"> <select id="selectMonitorUnit" parameterType="Long" resultMap="HwMonitorUnitResult">
select * from hw_monitor_unit where monitor_unit_id = ( select * from hw_monitor_unit where monitor_unit_id = (

Loading…
Cancel
Save