大屏接口优化
This commit is contained in:
@ -0,0 +1,56 @@
|
||||
package org.dromara.bigscreen.config;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.dromara.bigscreen.listener.RedisMessageListener;
|
||||
import org.dromara.drone.service.IDroProjectDroneService;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.listener.PatternTopic;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private IDroProjectDroneService droProjectDroneService;
|
||||
|
||||
/**
|
||||
* 配置Redis消息监听容器
|
||||
*/
|
||||
@Bean
|
||||
public RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory,
|
||||
MessageListenerAdapter listenerAdapter) {
|
||||
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(connectionFactory);
|
||||
List<String> wrjKeys = droProjectDroneService.getTopicsByKeyPrefix();
|
||||
for (String key : wrjKeys) {
|
||||
// 订阅 wrj:8UUXN4P00A06NK 频道
|
||||
container.addMessageListener(listenerAdapter, new PatternTopic("wrj:"+key));
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置消息监听适配器,将消息转发给自定义的监听器
|
||||
*/
|
||||
@Bean
|
||||
public MessageListenerAdapter listenerAdapter(RedisMessageListener listener) {
|
||||
return new MessageListenerAdapter(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置StringRedisTemplate
|
||||
*/
|
||||
@Bean
|
||||
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory connectionFactory) {
|
||||
return new StringRedisTemplate(connectionFactory);
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,13 @@
|
||||
package org.dromara.bigscreen.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.bigscreen.domain.dto.WurenjiQueryReq;
|
||||
import org.dromara.bigscreen.domain.dto.Ys7DeviceUpdateReq;
|
||||
import org.dromara.bigscreen.domain.vo.ProjectImageProgressVo;
|
||||
import org.dromara.bigscreen.domain.vo.ProjectLandVo;
|
||||
@ -17,7 +20,9 @@ import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.drone.service.IDroProjectDroneService;
|
||||
import org.dromara.gps.domain.bo.GpsEquipmentBo;
|
||||
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
|
||||
import org.dromara.gps.service.IGpsEquipmentService;
|
||||
@ -48,6 +53,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -69,7 +75,6 @@ public class ProjectBigScreenController extends BaseController {
|
||||
|
||||
private final IBusLandBlockService busLandBlockService;
|
||||
|
||||
private final IGpsEquipmentService gpsEquipmentService;
|
||||
|
||||
private final IOthYs7DeviceService othYs7DeviceService;
|
||||
|
||||
@ -290,64 +295,7 @@ public class ProjectBigScreenController extends BaseController {
|
||||
@GetMapping("/getClientList/{projectId}")
|
||||
public R<List<Map<String, Object>>> getClientList(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long projectId) {
|
||||
List<GpsEquipmentSonVo> voList = gpsEquipmentService.getClientList(projectId);
|
||||
List<OthYs7Device> othYs7DeviceList = othYs7DeviceService.lambdaQuery()
|
||||
.eq(OthYs7Device::getProjectId, projectId)
|
||||
.list();
|
||||
List<Map<String, Object>> maps = new ArrayList<>();
|
||||
Map<String, Object> gpsMap = new HashMap<>();
|
||||
Map<String, Object> wrjMap = new HashMap<>();
|
||||
Map<String, Object> sxtMap = new HashMap<>();
|
||||
List<Map<String, Object>> gpsChildrenMap = new ArrayList<>();
|
||||
List<Map<String, Object>> wrjChildrenMap = new ArrayList<>();
|
||||
List<Map<String, Object>> sxtChildrenMap = new ArrayList<>();
|
||||
if (voList != null && !voList.isEmpty()) {
|
||||
for (GpsEquipmentSonVo item : voList) {
|
||||
Map<String, Object> gps = new HashMap<>();
|
||||
gps.put("id", item.getClientId());
|
||||
gps.put("label", item.getClientId());
|
||||
gps.put("name", item.getDeviceName());
|
||||
gps.put("type", "positioningDevice");
|
||||
gps.put("lat", item.getLocLatitude());
|
||||
gps.put("lng", item.getLocLongitude());
|
||||
gps.put("alt", item.getLocAltitude());
|
||||
gpsChildrenMap.add(gps);
|
||||
}
|
||||
}
|
||||
if (othYs7DeviceList != null && !othYs7DeviceList.isEmpty()) {
|
||||
for (OthYs7Device item : othYs7DeviceList) {
|
||||
Map<String, Object> sxt = new HashMap<>();
|
||||
sxt.put("id", item.getDeviceSerial());
|
||||
sxt.put("label", item.getDeviceSerial());
|
||||
sxt.put("name", item.getDeviceName());
|
||||
sxt.put("type", "shexiangtou");
|
||||
sxt.put("lat", item.getLatitude());
|
||||
sxt.put("lng", item.getLongitude());
|
||||
sxt.put("alt", item.getAltitude());
|
||||
sxt.put("detail", item.getDetail());
|
||||
sxtChildrenMap.add(sxt);
|
||||
}
|
||||
}
|
||||
// List<Map<String, Object>> maps1 = setSxt();
|
||||
List<Map<String, Object>> maps2 = setWrj();
|
||||
|
||||
gpsMap.put("id", 1);
|
||||
gpsMap.put("label", "定位设备");
|
||||
gpsMap.put("children", gpsChildrenMap);
|
||||
sxtMap.put("id", 2);
|
||||
sxtMap.put("label", "摄像头");
|
||||
sxtMap.put("children", sxtChildrenMap);
|
||||
// sxtMap.put("children", maps1);
|
||||
wrjMap.put("id", 3);
|
||||
wrjMap.put("label", "无人机");
|
||||
// wrjMap.put("children",wrjChildrenMap);
|
||||
wrjMap.put("children", maps2);
|
||||
|
||||
|
||||
maps.add(gpsMap);
|
||||
maps.add(wrjMap);
|
||||
maps.add(sxtMap);
|
||||
return R.ok(maps);
|
||||
return R.ok(projectBigScreenService.getClientList(projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -450,133 +398,4 @@ public class ProjectBigScreenController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
// public List<Map<String, Object>> setSxt() {
|
||||
// List<Map<String, Object>> sxtChildrenMap = new ArrayList<>();
|
||||
// HashMap<String, Object> map1 = new HashMap<>();
|
||||
// map1.put("id", "55");
|
||||
// map1.put("label", "那荷4号方阵-1");
|
||||
// map1.put("name", "22");
|
||||
// map1.put("type", "camera");
|
||||
// map1.put("lng", 107.111325);
|
||||
// map1.put("lat", 23.820919);
|
||||
// map1.put("alt", 0);
|
||||
// HashMap<String, Object> map2 = new HashMap<>();
|
||||
// map2.put("id", "56");
|
||||
// map2.put("label", "甫必 1号方阵");
|
||||
// map2.put("name", "23");
|
||||
// map2.put("type", "camera");
|
||||
// map2.put("lng", 107.091297);
|
||||
// map2.put("lat", 23.813567);
|
||||
// map2.put("alt", 0);
|
||||
// HashMap<String, Object> map3 = new HashMap<>();
|
||||
// map3.put("id", "57");
|
||||
// map3.put("label", "1222224");
|
||||
// map3.put("name", "24");
|
||||
// map3.put("type", "camera");
|
||||
// map3.put("lng", 107.085442);
|
||||
// map3.put("lat", 23.811958);
|
||||
// map3.put("alt", 0);
|
||||
// HashMap<String, Object> map4 = new HashMap<>();
|
||||
// map4.put("id", "58");
|
||||
// map4.put("label", "甫必2号方阵-1");
|
||||
// map4.put("name", "25");
|
||||
// map4.put("type", "camera");
|
||||
// map4.put("lng", 107.085181);
|
||||
// map4.put("lat", 23.810556);
|
||||
// map4.put("alt", 0);
|
||||
// HashMap<String, Object> map5 = new HashMap<>();
|
||||
// map5.put("id", "58");
|
||||
// map5.put("label", "甫必 4号方阵");
|
||||
// map5.put("name", "25");
|
||||
// map5.put("type", "camera");
|
||||
// map5.put("lng", 107.081747);
|
||||
// map5.put("lat", 23.808131);
|
||||
// map5.put("alt", 0);
|
||||
// HashMap<String, Object> map6 = new HashMap<>();
|
||||
// map6.put("id", "58");
|
||||
// map6.put("label", "甫必 7号方阵-1");
|
||||
// map6.put("name", "25");
|
||||
// map6.put("type", "camera");
|
||||
// map6.put("lng", 107.077922);
|
||||
// map6.put("lat", 23.798344);
|
||||
// map6.put("alt", 0);
|
||||
// HashMap<String, Object> map7 = new HashMap<>();
|
||||
// map7.put("id", "58");
|
||||
// map7.put("label", "68甫必6");
|
||||
// map7.put("name", "25");
|
||||
// map7.put("type", "camera");
|
||||
// map7.put("lng", 107.077333);
|
||||
// map7.put("lat", 23.797969);
|
||||
// map7.put("alt", 0);
|
||||
// HashMap<String, Object> map8 = new HashMap<>();
|
||||
// map8.put("id", "58");
|
||||
// map8.put("label", "甫必5号方阵");
|
||||
// map8.put("name", "25");
|
||||
// map8.put("type", "camera");
|
||||
// map8.put("lng", 107.075853);
|
||||
// map8.put("lat", 23.796711);
|
||||
// map8.put("alt", 0);
|
||||
// HashMap<String, Object> map9 = new HashMap<>();
|
||||
// map9.put("id", "58");
|
||||
// map9.put("label", "西牛2号方阵");
|
||||
// map9.put("name", "25");
|
||||
// map9.put("type", "camera");
|
||||
// map9.put("lng", 107.078942);
|
||||
// map9.put("lat", 23.789306);
|
||||
// map9.put("alt", 0);
|
||||
// HashMap<String, Object> map10 = new HashMap<>();
|
||||
// map10.put("id", "58");
|
||||
// map10.put("label", "福绿1号方阵");
|
||||
// map10.put("name", "25");
|
||||
// map10.put("type", "camera");
|
||||
// map10.put("lng", 107.090061);
|
||||
// map10.put("lat", 23.790411);
|
||||
// map10.put("alt", 0);
|
||||
// HashMap<String, Object> map11 = new HashMap<>();
|
||||
// map11.put("id", "58");
|
||||
// map11.put("label", "福绿6号方阵-2");
|
||||
// map11.put("name", "25");
|
||||
// map11.put("type", "camera");
|
||||
// map11.put("lng", 107.112883);
|
||||
// map11.put("lat", 23.771378);
|
||||
// map11.put("alt", 0);
|
||||
//
|
||||
// sxtChildrenMap.add(map1);
|
||||
// sxtChildrenMap.add(map2);
|
||||
// sxtChildrenMap.add(map3);
|
||||
// sxtChildrenMap.add(map4);
|
||||
// sxtChildrenMap.add(map5);
|
||||
// sxtChildrenMap.add(map6);
|
||||
// sxtChildrenMap.add(map7);
|
||||
// sxtChildrenMap.add(map8);
|
||||
// sxtChildrenMap.add(map9);
|
||||
// sxtChildrenMap.add(map10);
|
||||
// sxtChildrenMap.add(map11);
|
||||
//
|
||||
// return sxtChildrenMap;
|
||||
// }
|
||||
|
||||
public List<Map<String, Object>> setWrj() {
|
||||
List<Map<String, Object>> sxtChildrenMap = new ArrayList<>();
|
||||
HashMap<String, Object> map1 = new HashMap<>();
|
||||
map1.put("id", "65");
|
||||
map1.put("label", "田东无人机");
|
||||
map1.put("name", "32");
|
||||
map1.put("type", "drone");
|
||||
map1.put("lng", 107.12744694624267);
|
||||
map1.put("lat", 23.615965741917278);
|
||||
map1.put("alt", 0);
|
||||
// HashMap<String, Object> map2 = new HashMap<>();
|
||||
// map2.put("id", "66");
|
||||
// map2.put("label", "长顺无人机");
|
||||
// map2.put("name", "33");
|
||||
// map2.put("type", "drone");
|
||||
// map2.put("lng", 106.49142431645038);
|
||||
// map2.put("lat", 29.534472802500083);
|
||||
// map2.put("alt", 0);
|
||||
sxtChildrenMap.add(map1);
|
||||
// sxtChildrenMap.add(map2);
|
||||
|
||||
return sxtChildrenMap;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package org.dromara.bigscreen.domain.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
* @date 2025-09-09 15:16
|
||||
*/
|
||||
@Data
|
||||
public class WurenjiQueryReq {
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private String longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private String latitude;
|
||||
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package org.dromara.bigscreen.listener;
|
||||
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.dromara.common.websocket.dto.WebSocketMessageDto;
|
||||
import org.dromara.common.websocket.utils.WebSocketUtils;
|
||||
import org.dromara.drone.domain.DroProjectDrone;
|
||||
import org.dromara.drone.service.IDroProjectDroneService;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.connection.MessageListener;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Redis消息监听器,用于处理订阅频道收到的消息
|
||||
*/
|
||||
@Component
|
||||
public class RedisMessageListener implements MessageListener {
|
||||
|
||||
@Lazy
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private IDroProjectDroneService droProjectDroneService;
|
||||
|
||||
// 构造函数注入StringRedisTemplate
|
||||
public RedisMessageListener(StringRedisTemplate stringRedisTemplate) {
|
||||
this.stringRedisTemplate = stringRedisTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理接收到的消息
|
||||
* @param message 消息对象
|
||||
* @param pattern 订阅的模式
|
||||
*/
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
// 处理消息
|
||||
// System.out.println("返回:"+stringRedisTemplate.getStringSerializer().deserialize(message.getBody()));
|
||||
String gateway = JSONUtil.parseObj(stringRedisTemplate.getStringSerializer().deserialize(message.getBody())).getStr("gateway");
|
||||
stringRedisTemplate
|
||||
.opsForValue()
|
||||
.set("wrj:"+gateway
|
||||
, Objects.requireNonNull(stringRedisTemplate.getStringSerializer().deserialize(message.getBody())));
|
||||
DroProjectDrone droProjectDrone = droProjectDroneService.getBaseMapper().selectOne(new LambdaQueryWrapper<DroProjectDrone>().eq(DroProjectDrone::getDroneSn, gateway));
|
||||
String pushContent = buildPushMessage(gateway,stringRedisTemplate.getStringSerializer().deserialize(message.getBody()),droProjectDrone.getProjectId());
|
||||
// 发送给指定用户(equipment.getUserId())
|
||||
WebSocketMessageDto messageDto = new WebSocketMessageDto();
|
||||
messageDto.setMessage(pushContent);
|
||||
messageDto.setSessionKeys(Collections.singletonList(droProjectDrone.getProjectId()));
|
||||
WebSocketUtils.publishMessage(messageDto);
|
||||
|
||||
}
|
||||
private String buildPushMessage(String key, String message, Long projectId) {
|
||||
JSONObject messageObj = new JSONObject();
|
||||
messageObj.put("type", "wrj_DATA_UPDATE");
|
||||
messageObj.put("projectId",projectId);
|
||||
messageObj.put("clientId",key);
|
||||
// 位置信息
|
||||
JSONObject locationObj = new JSONObject();
|
||||
locationObj.put("latitude", JSONUtil.parseObj(message).getJSONObject("data").get("latitude")); // 纬度
|
||||
locationObj.put("longitude", JSONUtil.parseObj(message).getJSONObject("data").get("longitude")); // 经度
|
||||
messageObj.put("location", locationObj);
|
||||
return messageObj.toString();
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package org.dromara.bigscreen.service;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.bigscreen.domain.vo.ProjectImageProgressVo;
|
||||
import org.dromara.bigscreen.domain.vo.ProjectPeopleVo;
|
||||
import org.dromara.bigscreen.domain.vo.ProjectSafetyInspectionVo;
|
||||
@ -9,6 +10,7 @@ import org.dromara.project.domain.vo.project.BusProjectSafetyDayVo;
|
||||
import org.dromara.project.domain.vo.projectnews.BusProjectNewsVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lilemy
|
||||
@ -75,4 +77,6 @@ public interface ProjectBigScreenService {
|
||||
List<String> getList(Long projectId);
|
||||
|
||||
void setList(GpsEquipmentBo bo);
|
||||
|
||||
List<Map<String, Object>> getClientList(Long projectId);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package org.dromara.bigscreen.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -14,10 +15,17 @@ import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.common.utils.BigDecimalUtil;
|
||||
import org.dromara.common.websocket.dto.WebSocketMessageDto;
|
||||
import org.dromara.common.websocket.utils.WebSocketUtils;
|
||||
import org.dromara.contractor.domain.SubConstructionUser;
|
||||
import org.dromara.contractor.service.ISubConstructionUserService;
|
||||
import org.dromara.drone.service.IDroProjectDroneService;
|
||||
import org.dromara.gps.domain.bo.GpsEquipmentBo;
|
||||
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
|
||||
import org.dromara.gps.service.IGpsEquipmentService;
|
||||
import org.dromara.manager.weathermanager.vo.WeatherVo;
|
||||
import org.dromara.other.domain.OthYs7Device;
|
||||
import org.dromara.other.service.IOthYs7DeviceService;
|
||||
import org.dromara.progress.domain.PgsProgressCategory;
|
||||
import org.dromara.progress.domain.enums.PgsProgressUnitTypeEnum;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryService;
|
||||
@ -29,12 +37,19 @@ import org.dromara.project.domain.vo.projectnews.BusProjectNewsVo;
|
||||
import org.dromara.project.service.*;
|
||||
import org.dromara.safety.domain.HseRecognizeRecord;
|
||||
import org.dromara.safety.service.IHseRecognizeRecordService;
|
||||
import org.redisson.api.RTopic;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.api.listener.MessageListener;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -69,6 +84,17 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
|
||||
@Resource
|
||||
private IPgsProgressCategoryService progressCategoryService;
|
||||
|
||||
@Resource
|
||||
private IDroProjectDroneService droProjectDroneService;
|
||||
@Resource
|
||||
private IGpsEquipmentService gpsEquipmentService;
|
||||
@Resource
|
||||
private IOthYs7DeviceService othYs7DeviceService;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
/**
|
||||
* 获取项目天气
|
||||
*
|
||||
@ -393,4 +419,129 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
|
||||
}
|
||||
RedisUtils.setCacheObject("xmjdp:"+bo.getProjectId(), bo.getIdList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getClientList(Long projectId) {
|
||||
// 获取当天的开始时间(00:00:00)
|
||||
LocalDateTime startOfDay = LocalDateTime.now().with(LocalTime.MIN);
|
||||
|
||||
// 获取当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<GpsEquipmentSonVo> voList = gpsEquipmentService.getClientList(projectId,startOfDay,now);
|
||||
List<GpsEquipmentSonVo> appList = gpsEquipmentService.getUserListByProjectId(projectId,startOfDay,now);
|
||||
List<OthYs7Device> othYs7DeviceList = othYs7DeviceService.lambdaQuery()
|
||||
.eq(OthYs7Device::getProjectId, projectId)
|
||||
.between(OthYs7Device::getUpdateTime, startOfDay, now)
|
||||
.list();
|
||||
List<String> wrjKeys = droProjectDroneService.getTopicsByProjectId(projectId);
|
||||
List<Map<String, Object>> maps = new ArrayList<>();
|
||||
Map<String, Object> gpsMap = new HashMap<>();
|
||||
Map<String, Object> anqmMap = new HashMap<>();
|
||||
Map<String, Object> appMap = new HashMap<>();
|
||||
Map<String, Object> sbMap = new HashMap<>();
|
||||
Map<String, Object> wrjMap = new HashMap<>();
|
||||
Map<String, Object> sxtMap = new HashMap<>();
|
||||
Map<String, Object> wrjMap1 = new HashMap<>();
|
||||
Map<String, Object> sxtMap1 = new HashMap<>();
|
||||
List<Map<String, Object>> gpsChildrenMap = new ArrayList<>();
|
||||
List<Map<String, Object>> sbChildrenMap = new ArrayList<>();
|
||||
List<Map<String, Object>> appChildrenMap = new ArrayList<>();
|
||||
List<Map<String, Object>> anqmChildrenMap = new ArrayList<>();
|
||||
List<Map<String, Object>> wrjChildrenMap = new ArrayList<>();
|
||||
List<Map<String, Object>> wrjChildrenMap1 = new ArrayList<>();
|
||||
List<Map<String, Object>> sxtChildrenMap = new ArrayList<>();
|
||||
List<Map<String, Object>> sxtChildrenMap1 = new ArrayList<>();
|
||||
if (voList != null && !voList.isEmpty()) {
|
||||
for (GpsEquipmentSonVo item : voList) {
|
||||
Map<String, Object> gps = new HashMap<>();
|
||||
gps.put("id", item.getClientId());
|
||||
gps.put("label", item.getClientId());
|
||||
gps.put("name", item.getDeviceName());
|
||||
gps.put("type", "positioningDevice");
|
||||
gps.put("lat", item.getLocLatitude());
|
||||
gps.put("lng", item.getLocLongitude());
|
||||
gps.put("alt", item.getLocAltitude());
|
||||
sbChildrenMap.add(gps);
|
||||
}
|
||||
}
|
||||
if (appList != null && !appList.isEmpty()) {
|
||||
for (GpsEquipmentSonVo item : appList) {
|
||||
Map<String, Object> app = new HashMap<>();
|
||||
app.put("id", item.getClientId());
|
||||
app.put("label", item.getClientId());
|
||||
app.put("name", item.getDeviceName());
|
||||
app.put("type", "positioningDevice");
|
||||
app.put("lat", item.getLocLatitude());
|
||||
app.put("lng", item.getLocLongitude());
|
||||
app.put("alt", item.getLocAltitude());
|
||||
appChildrenMap.add(app);
|
||||
}
|
||||
}
|
||||
if (othYs7DeviceList != null && !othYs7DeviceList.isEmpty()) {
|
||||
for (OthYs7Device item : othYs7DeviceList) {
|
||||
Map<String, Object> sxt = new HashMap<>();
|
||||
sxt.put("id", item.getDeviceSerial());
|
||||
sxt.put("label", item.getDeviceSerial());
|
||||
sxt.put("name", item.getDeviceName());
|
||||
sxt.put("type", "shexiangtou");
|
||||
sxt.put("lat", item.getLatitude());
|
||||
sxt.put("lng", item.getLongitude());
|
||||
sxt.put("alt", item.getAltitude());
|
||||
sxt.put("detail", item.getDetail());
|
||||
sxtChildrenMap1.add(sxt);
|
||||
}
|
||||
}
|
||||
if (wrjKeys != null && !wrjKeys.isEmpty()) {
|
||||
for (String key : wrjKeys) {
|
||||
Object object = stringRedisTemplate.opsForValue().get("wrj:" + key);
|
||||
if (object != null) {
|
||||
JSONObject object1 = JSONUtil.parseObj(object);
|
||||
Map<String, Object> wrj = new HashMap<>();
|
||||
wrj.put("id", key);
|
||||
wrj.put("label", key);
|
||||
wrj.put("name", key);
|
||||
wrj.put("type", "wurenji");
|
||||
wrj.put("lat", object1.getJSONObject("data").get("latitude"));
|
||||
wrj.put("lng", object1.getJSONObject("data").get("longitude"));
|
||||
wrjChildrenMap1.add(wrj);
|
||||
}
|
||||
}
|
||||
}
|
||||
gpsChildrenMap.add(sbMap);
|
||||
gpsChildrenMap.add(appMap);
|
||||
gpsChildrenMap.add(anqmMap);
|
||||
sxtChildrenMap.add(sxtMap1);
|
||||
wrjChildrenMap.add(wrjMap1);
|
||||
|
||||
gpsMap.put("id", 1);
|
||||
gpsMap.put("label", "人员定位");
|
||||
gpsMap.put("children", gpsChildrenMap);
|
||||
sbMap.put("id", 4);
|
||||
sbMap.put("label", "设备定位");
|
||||
sbMap.put("children", sbChildrenMap);
|
||||
appMap.put("id", 5);
|
||||
appMap.put("label", "app定位");
|
||||
appMap.put("children", appChildrenMap);
|
||||
anqmMap.put("id", 6);
|
||||
anqmMap.put("label", "安全帽定位");
|
||||
anqmMap.put("children", anqmChildrenMap);
|
||||
sxtMap.put("id", 2);
|
||||
sxtMap.put("label", "摄像头");
|
||||
sxtMap.put("children", sxtChildrenMap);
|
||||
sxtMap1.put("id", 7);
|
||||
sxtMap1.put("label", "摄像头");
|
||||
sxtMap1.put("children", sxtChildrenMap1);
|
||||
wrjMap.put("id", 3);
|
||||
wrjMap.put("label", "无人机");
|
||||
wrjMap.put("children",wrjChildrenMap);
|
||||
wrjMap1.put("id", 8);
|
||||
wrjMap1.put("label", "无人机");
|
||||
wrjMap1.put("children",wrjChildrenMap1);
|
||||
|
||||
|
||||
maps.add(gpsMap);
|
||||
maps.add(wrjMap);
|
||||
maps.add(sxtMap);
|
||||
return maps;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
package org.dromara.drone.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.drone.domain.DroProjectDrone;
|
||||
import org.dromara.drone.domain.vo.DroProjectDroneVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目无人机信息Mapper接口
|
||||
*
|
||||
@ -12,4 +15,7 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
*/
|
||||
public interface DroProjectDroneMapper extends BaseMapperPlus<DroProjectDrone, DroProjectDroneVo> {
|
||||
|
||||
List<String> getTopicsByKeyPrefix();
|
||||
|
||||
List<String> getTopicsByProjectId(@Param("projectId") Long projectId);
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.dromara.drone.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.drone.domain.DroProjectDrone;
|
||||
@ -74,4 +75,12 @@ public interface IDroProjectDroneService extends IService<DroProjectDrone> {
|
||||
* @param projectId 项目id
|
||||
*/
|
||||
Boolean addDroneMsgByProject(Long projectId);
|
||||
|
||||
/**
|
||||
* 查询所有无人机序列号
|
||||
* @return
|
||||
*/
|
||||
List<String> getTopicsByKeyPrefix();
|
||||
|
||||
List<String> getTopicsByProjectId(Long projectId);
|
||||
}
|
||||
|
||||
@ -145,4 +145,14 @@ public class DroProjectDroneServiceImpl extends ServiceImpl<DroProjectDroneMappe
|
||||
droneManager.addAirportInfoByProject(list.stream().map(DroProjectDrone::getDroneSn).toList(), projectId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTopicsByKeyPrefix() {
|
||||
return baseMapper.getTopicsByKeyPrefix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTopicsByProjectId(Long projectId) {
|
||||
return baseMapper.getTopicsByProjectId(projectId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ public interface GpsEquipmentSonMapper extends BaseMapperPlus<GpsEquipmentSon, G
|
||||
" gps_equipment_son \n" +
|
||||
"WHERE \n" +
|
||||
"project_id = #{projectId} \n " +
|
||||
"AND create_time BETWEEN #{startTime} AND #{endTime}\n" +
|
||||
")\n" +
|
||||
"SELECT\n" +
|
||||
" *\n" +
|
||||
@ -32,7 +33,7 @@ public interface GpsEquipmentSonMapper extends BaseMapperPlus<GpsEquipmentSon, G
|
||||
" RankedData\n" +
|
||||
"WHERE\n" +
|
||||
" rn = 1;")
|
||||
List<GpsEquipmentSonVo> getClientList(@Param("projectId") Long projectId);
|
||||
List<GpsEquipmentSonVo> getClientList(@Param("projectId") Long projectId, @Param("startTime") LocalDateTime startOfDay, @Param("endTime") LocalDateTime now);
|
||||
|
||||
@Select("SELECT loc_latitude AS locLatitude," +
|
||||
" loc_longitude AS locLongitude " +
|
||||
@ -56,4 +57,23 @@ public interface GpsEquipmentSonMapper extends BaseMapperPlus<GpsEquipmentSon, G
|
||||
"FROM ges " +
|
||||
"WHERE rn=1;")
|
||||
List<GpsEquipmentSonVo> selectVoFristList(@Param("projectId") Long projectId);
|
||||
|
||||
@Select("WITH RankedData AS (\n" +
|
||||
" SELECT\n" +
|
||||
" *,\n" +
|
||||
" ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY create_time DESC) AS rn\n" +
|
||||
" FROM\n" +
|
||||
" gps_equipment_son \n " +
|
||||
"WHERE \n" +
|
||||
"project_id = #{projectId}\n " +
|
||||
"AND client_id IS NULL \n" +
|
||||
"AND create_time BETWEEN #{startTime} AND #{endTime} \n" +
|
||||
")\n" +
|
||||
"SELECT\n" +
|
||||
" *\n" +
|
||||
"FROM\n" +
|
||||
" RankedData\n" +
|
||||
"WHERE\n" +
|
||||
" rn = 1;")
|
||||
List<GpsEquipmentSonVo> getUserListByProjectId(@Param("projectId") Long projectId, @Param("startTime") LocalDateTime startOfDay, @Param("endTime") LocalDateTime now);
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.gps.domain.vo.GpsProjectVo;
|
||||
import org.dromara.gps.domain.vo.GpsUserVo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@ -96,7 +97,9 @@ public interface IGpsEquipmentService extends IService<GpsEquipment>{
|
||||
|
||||
List<GpsProjectVo> getProjectList();
|
||||
|
||||
List<GpsEquipmentSonVo> getClientList(Long projectId);
|
||||
List<GpsEquipmentSonVo> getClientList(Long projectId, LocalDateTime startOfDay, LocalDateTime now);
|
||||
|
||||
void setData(String jsonData);
|
||||
|
||||
List<GpsEquipmentSonVo> getUserListByProjectId(Long projectId, LocalDateTime startOfDay, LocalDateTime now);
|
||||
}
|
||||
|
||||
@ -7,6 +7,8 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -69,9 +71,11 @@ public interface IGpsEquipmentSonService extends IService<GpsEquipmentSon>{
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
List<GpsEquipmentSonVo> getClientList(Long projectId);
|
||||
List<GpsEquipmentSonVo> getClientList(Long projectId, LocalDateTime startOfDay, LocalDateTime now);
|
||||
|
||||
Map<String, Object> getAppList(GpsEquipmentSonBo bo);
|
||||
|
||||
List<GpsEquipmentSonVo> getLargerScreenList(GpsEquipmentSonBo bo);
|
||||
|
||||
List<GpsEquipmentSonVo> getUserListByProjectId(Long projectId, LocalDateTime startOfDay, LocalDateTime now);
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package org.dromara.gps.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@ -45,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -432,8 +432,8 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GpsEquipmentSonVo> getClientList(Long projectId) {
|
||||
return gpsEquipmentSonService.getClientList(projectId);
|
||||
public List<GpsEquipmentSonVo> getClientList(Long projectId, LocalDateTime startOfDay, LocalDateTime now) {
|
||||
return gpsEquipmentSonService.getClientList(projectId,startOfDay,now);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -477,5 +477,10 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
|
||||
updateDeviceAliveStatus(gpsEquipment.getClientId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GpsEquipmentSonVo> getUserListByProjectId(Long projectId, LocalDateTime startOfDay, LocalDateTime now) {
|
||||
return gpsEquipmentSonService.getUserListByProjectId(projectId,startOfDay,now);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package org.dromara.gps.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.dromara.common.core.service.OssService;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@ -26,6 +24,7 @@ import org.dromara.gps.domain.GpsEquipmentSon;
|
||||
import org.dromara.gps.mapper.GpsEquipmentSonMapper;
|
||||
import org.dromara.gps.service.IGpsEquipmentSonService;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -157,8 +156,8 @@ public class GpsEquipmentSonServiceImpl extends ServiceImpl<GpsEquipmentSonMappe
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GpsEquipmentSonVo> getClientList(Long projectId) {
|
||||
return baseMapper.getClientList(projectId);
|
||||
public List<GpsEquipmentSonVo> getClientList(Long projectId, LocalDateTime startOfDay, LocalDateTime now) {
|
||||
return baseMapper.getClientList(projectId,startOfDay,now);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -190,4 +189,9 @@ public class GpsEquipmentSonServiceImpl extends ServiceImpl<GpsEquipmentSonMappe
|
||||
}
|
||||
return gpsEquipmentSonVoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GpsEquipmentSonVo> getUserListByProjectId(Long projectId, LocalDateTime startOfDay, LocalDateTime now) {
|
||||
return baseMapper.getUserListByProjectId(projectId,startOfDay,now);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,4 +4,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.drone.mapper.DroProjectDroneMapper">
|
||||
|
||||
<select id="getTopicsByKeyPrefix" resultType="java.lang.String">
|
||||
SELECT
|
||||
drone_sn
|
||||
FROM
|
||||
`dro_project_drone`
|
||||
GROUP BY drone_sn
|
||||
</select>
|
||||
<select id="getTopicsByProjectId" resultType="java.lang.String">
|
||||
SELECT
|
||||
drone_sn
|
||||
FROM
|
||||
`dro_project_drone`
|
||||
WHERE project_id = #{projectId}
|
||||
GROUP BY drone_sn
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user