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

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

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

@ -264,4 +264,5 @@ public interface IHwDeviceService {
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.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<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.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<HwDevice> 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<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);
}
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<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("latestData", latestDataMaps);
return returnObj;

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

@ -332,7 +332,7 @@
<select id="selectBeaconDeviceBySceneId" parameterType="Long" resultType="int">
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
</select>
<select id="selectMonitorUnit" parameterType="Long" resultMap="HwMonitorUnitResult">
select * from hw_monitor_unit where monitor_unit_id = (

Loading…
Cancel
Save