|
|
|
@ -3,6 +3,7 @@ package com.ruoyi.business.service.impl;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.alibaba.fastjson.parser.Feature;
|
|
|
|
|
import com.ruoyi.business.domain.*;
|
|
|
|
|
import com.ruoyi.business.domain.VO.*;
|
|
|
|
|
import com.ruoyi.business.mapper.*;
|
|
|
|
@ -19,17 +20,25 @@ import com.ruoyi.common.core.utils.DateUtils;
|
|
|
|
|
import com.ruoyi.common.core.utils.NumberUtils;
|
|
|
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
|
|
|
import com.ruoyi.common.datascope.annotation.DataScope;
|
|
|
|
|
import com.ruoyi.common.redis.service.RedisService;
|
|
|
|
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
|
|
|
|
import com.ruoyi.system.api.domain.SysUser;
|
|
|
|
|
import com.ruoyi.tdengine.api.RemoteTdEngineService;
|
|
|
|
|
import com.ruoyi.tdengine.api.domain.*;
|
|
|
|
|
import io.swagger.models.auth.In;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
|
|
|
|
import org.springframework.data.redis.cache.RedisCache;
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import sun.reflect.generics.tree.Tree;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -56,7 +65,12 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
|
private StringRedisTemplate redisTemplate;
|
|
|
|
|
@Autowired
|
|
|
|
|
private HwAlarmInfoMapper hwAlarmInfoMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private HwElectronicFenceMapper hwElectronicFenceMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private RedisService redisService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private HwFenceAreaMapper hwFenceAreaMapper;
|
|
|
|
|
/**
|
|
|
|
|
* 查询设备信息
|
|
|
|
|
*
|
|
|
|
@ -65,7 +79,6 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public HwDevice selectHwDeviceByDeviceId(Long deviceId) {
|
|
|
|
|
|
|
|
|
|
return hwDeviceMapper.selectHwDeviceByDeviceId(deviceId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1123,4 +1136,410 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
|
return hwDeviceMapper.selectUnallocatedList(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* 查询设备经纬度
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public List<BeaconDevice> selectDeviceLatitudeAndLongitude(Long sceneId) {
|
|
|
|
|
//根据场景查询下面的设备
|
|
|
|
|
HwDevice device = new HwDevice();
|
|
|
|
|
device.setSceneId(sceneId);
|
|
|
|
|
List<HwDevice> hwDevices = hwDeviceMapper.selectHwDeviceList(device);
|
|
|
|
|
Integer[] integers = hwMonitorUnitMapper.selectBeaconDeviceBySceneId(sceneId);
|
|
|
|
|
//调用tde查询每个设备的经纬度
|
|
|
|
|
if (integers.length!=0){
|
|
|
|
|
TdSelectDto tdSelectDto = new TdSelectDto();
|
|
|
|
|
tdSelectDto.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME);
|
|
|
|
|
TdField tdField = new TdField();
|
|
|
|
|
tdField.setFieldName("longitude");
|
|
|
|
|
TdField tdField1 = new TdField();
|
|
|
|
|
tdField1.setFieldName("latitude");
|
|
|
|
|
List<TdField> fields = new ArrayList<TdField>();
|
|
|
|
|
fields.add(tdField);
|
|
|
|
|
fields.add(tdField1);
|
|
|
|
|
tdSelectDto.setSchemaFieldValues(fields);
|
|
|
|
|
List<BeaconDevice> lists = new ArrayList<BeaconDevice>();
|
|
|
|
|
for (int i = 0;i<integers.length;i++){
|
|
|
|
|
tdSelectDto.setTableName(TdEngineConstants.DEFAULT_TABLE_NAME_PREFIX+integers[i]);
|
|
|
|
|
R<?> latestData = remoteTdEngineService.getLatestData(tdSelectDto, SecurityConstants.INNER);
|
|
|
|
|
Object data = latestData.getData();
|
|
|
|
|
String s = JSONObject.toJSONString(data);
|
|
|
|
|
if (latestData.getCode()!=500){
|
|
|
|
|
String substring = s.substring(1, s.length() - 1);
|
|
|
|
|
if (!substring.isEmpty()){
|
|
|
|
|
Map map = JSONObject.parseObject(substring, Map.class);
|
|
|
|
|
if (map.size()==2){
|
|
|
|
|
BeaconDevice beaconDevice = new BeaconDevice();
|
|
|
|
|
beaconDevice.setDeviceId(hwDevices.get(i).getDeviceId());
|
|
|
|
|
beaconDevice.setDeviceName(hwDevices.get(i).getDeviceName());
|
|
|
|
|
beaconDevice.setLatitude(Double.valueOf( map.get("latitude").toString()));
|
|
|
|
|
beaconDevice.setLongitude(Double.valueOf( map.get("longitude").toString()));
|
|
|
|
|
beaconDevice.setRemark(hwDevices.get(i).getRemark());
|
|
|
|
|
beaconDevice.setDeviceLocation(hwDevices.get(i).getDeviceLocation());
|
|
|
|
|
beaconDevice.setDeviceLocation("白银市");
|
|
|
|
|
beaconDevice.setDeviceModeId(hwDevices.get(i).getDeviceModeId());
|
|
|
|
|
lists.add(beaconDevice);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// System.out.println(lists);
|
|
|
|
|
return lists;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据设备id查询信标设备历史数据
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, Object>> selectBeaconDevicesHistory(Map map) {
|
|
|
|
|
TdHistorySelectDto tdHistorySelectDto = new TdHistorySelectDto();
|
|
|
|
|
tdHistorySelectDto.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME);
|
|
|
|
|
tdHistorySelectDto.setTableName(TdEngineConstants.DEFAULT_TABLE_NAME_PREFIX+map.get("deviceId"));
|
|
|
|
|
tdHistorySelectDto.setFirstFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
|
|
|
|
|
if (map.get("pageSize")!=null){
|
|
|
|
|
tdHistorySelectDto.setLimit(Integer.valueOf(map.get("pageSize").toString()));
|
|
|
|
|
}
|
|
|
|
|
if (map.get("pageSize")!=null&&map.get("pageNum")!=null){
|
|
|
|
|
tdHistorySelectDto.setOffset(Integer.valueOf(map.get("pageSize").toString())*(Integer.valueOf(map.get("pageNum").toString())-1));
|
|
|
|
|
}
|
|
|
|
|
tdHistorySelectDto.setOrderByFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
|
|
|
|
|
tdHistorySelectDto.setSort(TdEngineConstants.DEFAULT_ORDER_BY_MODE);
|
|
|
|
|
if (map.containsKey("startTime")&&map.get("startTime")!=null){
|
|
|
|
|
tdHistorySelectDto.setStartTime(Timestamp.valueOf(map.get("startTime").toString()).getTime());
|
|
|
|
|
}
|
|
|
|
|
if (map.containsKey("endTime")&&map.get("endTime")!=null){
|
|
|
|
|
tdHistorySelectDto.setEndTime(Timestamp.valueOf(map.get("endTime").toString()).getTime());
|
|
|
|
|
}
|
|
|
|
|
R<TdReturnDataVo> historyData = remoteTdEngineService.getHistoryData(tdHistorySelectDto, SecurityConstants.INNER);
|
|
|
|
|
System.out.println("查询历史数据"+map.get("deviceId"));
|
|
|
|
|
List<Map<String, Object>> dataList = historyData.getData().dataList;
|
|
|
|
|
for (int i = 0; i < dataList.size(); i++){
|
|
|
|
|
dataList.get(i).put("deviceId",map.get("deviceId"));
|
|
|
|
|
}
|
|
|
|
|
int count = historyData.getData().count;
|
|
|
|
|
Map<String, Object> map1 = new HashMap<>();
|
|
|
|
|
map1.put("total",count);
|
|
|
|
|
dataList.add(map1);
|
|
|
|
|
return dataList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据设备id查询其对应的监控单元
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public HwMonitorUnit selectMonitorUnit(Long deviceId) {
|
|
|
|
|
HwMonitorUnit hwMonitorUnit = hwMonitorUnitMapper.selectMonitorUnit(deviceId);
|
|
|
|
|
return hwMonitorUnit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 历史数据弹出框(多参数且可多选)
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, Object>> selectHistoryDevice(Map map) {
|
|
|
|
|
//1-趋势分析 2历史数据
|
|
|
|
|
//如果是趋势分析就删除分页
|
|
|
|
|
Long pageSize = 0l;
|
|
|
|
|
if (map.get("type")!=null){
|
|
|
|
|
if (map.get("type").toString().equals("1")){
|
|
|
|
|
map.remove("pageSize");
|
|
|
|
|
map.remove("pageNum");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
pageSize = Long.valueOf(map.get("pageSize").toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String deviceIds = map.get("deviceIds").toString();
|
|
|
|
|
String[] str = deviceIds.split(",");
|
|
|
|
|
map.replace("pageSize",pageSize/str.length);
|
|
|
|
|
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
|
|
|
|
Long total = 0l;
|
|
|
|
|
for (int i = 0; i < str.length; i++) {
|
|
|
|
|
map.put("deviceId",str[i]);
|
|
|
|
|
if (i== str.length-2){
|
|
|
|
|
map.replace("pageSize",pageSize%str.length);
|
|
|
|
|
}
|
|
|
|
|
if (map.get("prop")!=null){
|
|
|
|
|
//查询类型的字段名
|
|
|
|
|
String s = hwDeviceMapper.selectPropBydeviceIdAndFunctionName(Long.valueOf(map.get("deviceId").toString())
|
|
|
|
|
, map.get("prop").toString());
|
|
|
|
|
map.put("functionIdentifier",s);
|
|
|
|
|
}
|
|
|
|
|
List<Map<String, Object>> list1 = this.selectBeaconDevicesHistory(map);
|
|
|
|
|
total = total+Long.valueOf(list1.get(list1.size()-1).get("total").toString());
|
|
|
|
|
list1.remove(list1.size()-1);
|
|
|
|
|
List<Map<String, Object>> list2 = new ArrayList<Map<String, Object>>();
|
|
|
|
|
//在弹出框中进行对比时,对历史数据进行过滤,根据传入的传感器类型
|
|
|
|
|
|
|
|
|
|
if (map.get("functionIdentifier")!=null) {
|
|
|
|
|
for (int x = 0; x < list1.size(); x++) {
|
|
|
|
|
//查看数据中是否拥有所需要的数据,没有进入下一循环
|
|
|
|
|
if (list1.get(i).get(map.get("functionIdentifier").toString())==null){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> map2 = new HashMap<String, Object>();
|
|
|
|
|
//获取出需要的数据存入返回值中
|
|
|
|
|
map2.put("deviceId", list1.get(x).get("deviceId"));
|
|
|
|
|
map2.put("ts", list1.get(x).get("ts"));
|
|
|
|
|
map2.put("deviceName", list1.get(x).get("deviceName"));
|
|
|
|
|
map2.put("functionName", map.get("prop"));
|
|
|
|
|
map2.put("functionIdentifier",
|
|
|
|
|
list1.get(x).get(map.get("functionIdentifier").toString()));
|
|
|
|
|
list.add(map2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
list.addAll(list1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> mapName = new HashMap<String, Object>();
|
|
|
|
|
if (list.size()>0){
|
|
|
|
|
Set<String> strings = list.get(0).keySet();
|
|
|
|
|
List<String> list2 = new ArrayList<String>();
|
|
|
|
|
list2.addAll(strings);
|
|
|
|
|
for (int i = 0; i < list2.size(); i++) {
|
|
|
|
|
//查询类型的字段名
|
|
|
|
|
String s = hwDeviceMapper.selectFunctionNameByFunctionIdentifier(list2.get(i));
|
|
|
|
|
mapName.put(list2.get(i),s);
|
|
|
|
|
}
|
|
|
|
|
list.add(mapName);
|
|
|
|
|
}
|
|
|
|
|
if (map.get("type")!=null&&map.get("type").equals("1") ){
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
if (list.get(i).containsKey("valid")){
|
|
|
|
|
list.get(i).remove("valid");
|
|
|
|
|
}
|
|
|
|
|
if (list.get(i).containsKey("acc")){
|
|
|
|
|
list.get(i).remove("acc");
|
|
|
|
|
}
|
|
|
|
|
if (list.get(i).containsKey("version")){
|
|
|
|
|
list.get(i).remove("version");
|
|
|
|
|
}
|
|
|
|
|
if (list.get(i).containsKey("speed")){
|
|
|
|
|
list.get(i).remove("speed");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, Object> mapTotal = new HashMap<String, Object>();
|
|
|
|
|
mapTotal.put("total", total);
|
|
|
|
|
list.add(mapTotal);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 返回一级、二级、传感器
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public List<TreeDeviceVo> selectComparison() {
|
|
|
|
|
List<TreeDeviceVo> sceneMap = hwSceneMapper.selectHwSceneListReturnMap();
|
|
|
|
|
List<TreeDeviceVo> unitMap = hwMonitorUnitMapper.selectMonitorUnitReturnMap();
|
|
|
|
|
List<TreeDeviceVo> deviceMap = hwDeviceMapper.selectDeviceList();
|
|
|
|
|
for (int i = 0; i < unitMap.size(); i++) {
|
|
|
|
|
List<TreeDeviceVo> list = new ArrayList<TreeDeviceVo>();
|
|
|
|
|
for (int j = 0; j < deviceMap.size(); j++) {
|
|
|
|
|
if (unitMap.get(i).getVoId() == deviceMap.get(j).getParentId()) {
|
|
|
|
|
list.add(deviceMap.get(j));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
unitMap.get(i).setVoList(list);
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < sceneMap.size(); i++) {
|
|
|
|
|
List<TreeDeviceVo> list = new ArrayList<TreeDeviceVo>();
|
|
|
|
|
for (int j = 0; j < unitMap.size(); j++) {
|
|
|
|
|
if (sceneMap.get(i).getVoId().equals(unitMap.get(j).getParentId())) {
|
|
|
|
|
list.add(unitMap.get(j));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sceneMap.get(i).setVoList(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sceneMap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出excel
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, Object>> getExportDevice(Map map) {
|
|
|
|
|
map.remove("pageSize");
|
|
|
|
|
map.remove("pageNum");
|
|
|
|
|
String deviceIds = map.get("deviceIds").toString();
|
|
|
|
|
String[] str = deviceIds.split(",");
|
|
|
|
|
List<Map<String, Object>> exportList = new ArrayList<Map<String, Object>>();
|
|
|
|
|
for (int i = 0; i < str.length; i++) {
|
|
|
|
|
map.put("deviceId",str[i]);
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> list1 = this.selectBeaconDevicesHistory(map);
|
|
|
|
|
list1.remove(list1.size()-1);
|
|
|
|
|
exportList.addAll(list1);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return exportList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询租户下的所有信标设备下挂到监控单元
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public List<HwMonitorUnit> getDeviceByAreaId(Long tenantId) {
|
|
|
|
|
//如果是管理员,则不对租户进行过滤,即可以看到城市下所有租户的设备信息
|
|
|
|
|
if (tenantId==1l)
|
|
|
|
|
{
|
|
|
|
|
tenantId = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 逻辑
|
|
|
|
|
*先根据租户id查询所有的监控单元
|
|
|
|
|
* 再根据监控单元查出所有信标设备然后返回
|
|
|
|
|
* */
|
|
|
|
|
HwMonitorUnit hwMonitorUnit = new HwMonitorUnit();
|
|
|
|
|
hwMonitorUnit.setTenantId(tenantId);
|
|
|
|
|
List<HwMonitorUnit> unitList = hwMonitorUnitMapper.selectMonitorUnitListHavAreaId(tenantId);
|
|
|
|
|
for (int i = 0; i < unitList.size(); i++){
|
|
|
|
|
List<HwDevice> deviceList = this.getDeviceListInMonitorUnit(unitList.get(i).getMonitorUnitId());
|
|
|
|
|
unitList.get(i).setDevicesList(deviceList);
|
|
|
|
|
}
|
|
|
|
|
// List<TreeAreaVo> treeArea1 = hwDeviceMapper.getTreeArea(areaId);
|
|
|
|
|
// for (int i=0;i<treeArea1.size();i++){
|
|
|
|
|
// TreeAreaVo treeAreaVo = this.AreaRecursion(treeArea1.get(i),tenantId);
|
|
|
|
|
// treeArea.add(treeAreaVo);
|
|
|
|
|
// }
|
|
|
|
|
return unitList;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询电子围栏通过设备
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public List<HwElectronicFence> selectMonitorElectronic(Long deviceId) {
|
|
|
|
|
List<HwElectronicFence> hwElectronicFences = hwElectronicFenceMapper.selectMonitorElectronic(deviceId);
|
|
|
|
|
for (int i = 0; i < hwElectronicFences.size();i++){
|
|
|
|
|
HwFenceArea hwFenceArea = new HwFenceArea();
|
|
|
|
|
hwFenceArea.setElectronicFenceId(hwElectronicFences.get(i).getElectronicFenceId());
|
|
|
|
|
List<HwFenceArea> hwFenceAreaList = hwFenceAreaMapper.selectHwFenceAreaList(hwFenceArea);
|
|
|
|
|
hwElectronicFences.get(i).setHwFenceAreaList(hwFenceAreaList);
|
|
|
|
|
}
|
|
|
|
|
return hwElectronicFences;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询监控单元下的信标设备
|
|
|
|
|
public List<HwDevice> getDeviceListInMonitorUnit(Long monitorUnitId){
|
|
|
|
|
List<HwDevice> deviceListInMonitorUnit = hwDeviceMapper.getDeviceListInMonitorUnit(monitorUnitId);
|
|
|
|
|
Map<String, String> map = new HashMap<String, String>();
|
|
|
|
|
map.put("pageNum","1");
|
|
|
|
|
map.put("pageSize","1");
|
|
|
|
|
for (int i=0;i<deviceListInMonitorUnit.size();i++){
|
|
|
|
|
|
|
|
|
|
map.put("deviceId",deviceListInMonitorUnit.get(i).getDeviceId().toString());
|
|
|
|
|
//根据设备id查询该设备是否有报警信息
|
|
|
|
|
Integer integer = hwDeviceMapper.selectDeviceIfAlarm(Long.valueOf(map.get("deviceId")));
|
|
|
|
|
String ifAlarm = new String();
|
|
|
|
|
if (integer>0){
|
|
|
|
|
//正常
|
|
|
|
|
ifAlarm="1";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ifAlarm="0";
|
|
|
|
|
}
|
|
|
|
|
List<Map<String, Object>> list = this.selectBeaconDevicesHistory(map);
|
|
|
|
|
// list.remove(list.size()-1);
|
|
|
|
|
System.out.println(list);
|
|
|
|
|
for(int j=0;j<list.size();j++){
|
|
|
|
|
deviceListInMonitorUnit.get(i).setIfAlarm(ifAlarm);
|
|
|
|
|
// System.out.println(list.get(j).get("longitude"));
|
|
|
|
|
if (list.get(j).containsKey("longitude")){
|
|
|
|
|
System.out.println(deviceListInMonitorUnit.get(j).getDeviceId());
|
|
|
|
|
deviceListInMonitorUnit.get(i).setLongitude(Double.valueOf(list.get(j).get("longitude").toString()));
|
|
|
|
|
}
|
|
|
|
|
if (list.get(j).containsKey("latitude")){
|
|
|
|
|
deviceListInMonitorUnit.get(i).setLatitude(Double.valueOf(list.get(j).get("latitude").toString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return deviceListInMonitorUnit;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 导入excel
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public void insertRedis(JSONArray jsonArray,Long tenantId){
|
|
|
|
|
// redisTemplate.opsForValue().set("test",jsonArray.toJSONString());
|
|
|
|
|
if (redisService.hasKey("file"+tenantId)) {
|
|
|
|
|
redisService.deleteObject("file"+tenantId);
|
|
|
|
|
}
|
|
|
|
|
redisService.setCacheObject("file"+tenantId,jsonArray.toJSONString(),99999l, TimeUnit.DAYS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查看excel
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject selectRedisFile(Long tenantId){
|
|
|
|
|
Object o = redisService.getCacheObject("file" + tenantId);
|
|
|
|
|
JSONObject array = new JSONObject(true);
|
|
|
|
|
array.put("content",o.toString());
|
|
|
|
|
|
|
|
|
|
String s = o.toString();
|
|
|
|
|
String[] split = s.split("},\\{");
|
|
|
|
|
String s2 = split[0].substring(1) + "}";
|
|
|
|
|
Map<String, Object> map = JSON.parseObject(s2,LinkedHashMap.class, Feature.OrderedField);
|
|
|
|
|
Map<Long, String> linkedMap = new LinkedHashMap<Long, String>();
|
|
|
|
|
Long along = 1l;
|
|
|
|
|
for (String key : map.keySet()){
|
|
|
|
|
linkedMap.put(along, key);
|
|
|
|
|
along++;
|
|
|
|
|
}
|
|
|
|
|
array.put("Header",linkedMap);
|
|
|
|
|
return array;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据名字搜索信标设备
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public List<HwDevice> selectMonitorUnitAndDeviceByName(Map map) {
|
|
|
|
|
String name = map.get("name").toString();
|
|
|
|
|
HwMonitorUnit hwMonitorUnit= new HwMonitorUnit();
|
|
|
|
|
// System.out.println(name);
|
|
|
|
|
hwMonitorUnit.setMonitorUnitName(name);
|
|
|
|
|
List<HwMonitorUnit> monitorUnits = hwMonitorUnitMapper.selectHwMonitorUnitList(hwMonitorUnit);
|
|
|
|
|
HwDevice hwDevice = new HwDevice();
|
|
|
|
|
hwDevice.setDeviceName(name);
|
|
|
|
|
List<HwDevice> deviceList = hwDeviceMapper.selectHwDeviceList(hwDevice);
|
|
|
|
|
List<Long> stringList = new ArrayList<Long>();
|
|
|
|
|
for (int i = 0; i < deviceList.size(); i++){
|
|
|
|
|
HwMonitorUnit hwMonitorUnit1 = hwMonitorUnitMapper.selectMonitorUnit(deviceList.get(i).getDeviceId());
|
|
|
|
|
monitorUnits.add(hwMonitorUnit1);
|
|
|
|
|
}
|
|
|
|
|
List<HwMonitorUnit> collect = monitorUnits.stream().collect(Collectors.collectingAndThen(
|
|
|
|
|
Collectors.toCollection(()->new TreeSet<>(Comparator.comparing(HwMonitorUnit::getMonitorUnitId))
|
|
|
|
|
),ArrayList::new));
|
|
|
|
|
List<HwDevice> deviceListReturn = new ArrayList<HwDevice>();
|
|
|
|
|
for (int i = 0; i < collect.size(); i++){
|
|
|
|
|
deviceListReturn.addAll(this.getDeviceListInMonitorUnit(collect.get(i).getMonitorUnitId()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return deviceListReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|