gps定位接口

This commit is contained in:
2025-09-09 17:47:49 +08:00
parent 9d682a3290
commit a52b9078a0
10 changed files with 266 additions and 11 deletions

View File

@ -11,21 +11,27 @@ import org.dromara.bigscreen.domain.vo.ProjectPeopleVo;
import org.dromara.bigscreen.domain.vo.ProjectSafetyInspectionVo;
import org.dromara.bigscreen.service.ProjectBigScreenService;
import org.dromara.common.core.domain.R;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.gps.domain.bo.GpsEquipmentBo;
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
import org.dromara.gps.service.IGpsEquipmentService;
import org.dromara.land.domain.BusLandBlock;
import org.dromara.land.domain.BusLandTransferLedger;
import org.dromara.land.service.IBusLandBlockService;
import org.dromara.land.service.IBusLandTransferLedgerService;
import org.dromara.other.domain.OthYs7Device;
import org.dromara.other.service.IOthYs7DeviceService;
import org.dromara.project.domain.vo.project.BusProjectSafetyDayVo;
import org.dromara.project.domain.vo.project.BusProjectWeatherVo;
import org.dromara.project.domain.vo.projectnews.BusProjectNewsVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -49,6 +55,10 @@ public class ProjectBigScreenController {
private final IBusLandBlockService busLandBlockService;
private final IGpsEquipmentService gpsEquipmentService;
private final IOthYs7DeviceService othYs7DeviceService;
/**
* 查询项目土地统计
*/
@ -167,4 +177,179 @@ public class ProjectBigScreenController {
@PathVariable Long projectId) {
return R.ok(projectBigScreenService.getProjectGeneralize(projectId));
}
/**
* 查询设备列表
*/
@SaCheckPermission("project:bigScreen:getClientList")
@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.getLocLatitude());
//// sxt.put("lng", item.getLocLongitude());
//// sxt.put("alt", item.getLocAltitude());
// 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);
}
/**
* 查询GPS设备用户列表
*/
@SaCheckPermission("project:bigScreen:getList")
@GetMapping("/getList")
public R<List<String>> getList(Long projectId) {
return R.ok(projectBigScreenService.getList(projectId));
}
/**
* 新增GPS设备详细
*/
@SaCheckPermission("project:bigScreen:setList")
@Log(title = "GPS设备详细", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping("/setList")
public void setList(@RequestBody GpsEquipmentBo bo) {
projectBigScreenService.setList(bo);
}
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", "1222222");
map1.put("name", "22");
map1.put("type", "camera");
map1.put("lng", 106.48349615411811);
map1.put("lat", 29.54856374364732);
map1.put("alt", 0);
HashMap<String, Object> map2 = new HashMap<>();
map2.put("id", "56");
map2.put("label", "1222223");
map2.put("name", "23");
map2.put("type", "camera");
map2.put("lng", 106.48442273257676);
map2.put("lat", 29.53841670498476);
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", 106.49197896482423);
map3.put("lat", 29.52931974282576);
map3.put("alt", 0);
HashMap<String, Object> map4 = new HashMap<>();
map4.put("id", "58");
map4.put("label", "1222225");
map4.put("name", "25");
map4.put("type", "camera");
map4.put("lng", 106.50293584930655);
map4.put("lat", 29.533025743929034);
map4.put("alt", 0);
sxtChildrenMap.add(map1);
sxtChildrenMap.add(map2);
sxtChildrenMap.add(map3);
sxtChildrenMap.add(map4);
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", "6222222");
map1.put("name", "32");
map1.put("type", "drone");
map1.put("lng", 106.49556855602525);
map1.put("lat", 29.534393226355515);
map1.put("alt", 0);
HashMap<String, Object> map2 = new HashMap<>();
map2.put("id", "66");
map2.put("label", "2222223");
map2.put("name", "33");
map2.put("type", "drone");
map2.put("lng", 106.49142431645038);
map2.put("lat", 29.534472802500083);
map2.put("alt", 0);
HashMap<String, Object> map3 = new HashMap<>();
map3.put("id", "67");
map3.put("label", "2222224");
map3.put("name", "34");
map3.put("type", "drone");
map3.put("lng", 106.49142125177437);
map3.put("lat", 29.541881138875755);
map3.put("alt", 0);
HashMap<String, Object> map4 = new HashMap<>();
map4.put("id", "68");
map4.put("label", "2222225");
map4.put("name", "35");
map4.put("type", "drone");
map4.put("lng", 106.50256649933792);
map4.put("lat", 29.54260793685717);
map4.put("alt", 0);
sxtChildrenMap.add(map1);
sxtChildrenMap.add(map2);
sxtChildrenMap.add(map3);
sxtChildrenMap.add(map4);
return sxtChildrenMap;
}
}

View File

@ -3,6 +3,7 @@ package org.dromara.bigscreen.service;
import org.dromara.bigscreen.domain.vo.ProjectImageProgressVo;
import org.dromara.bigscreen.domain.vo.ProjectPeopleVo;
import org.dromara.bigscreen.domain.vo.ProjectSafetyInspectionVo;
import org.dromara.gps.domain.bo.GpsEquipmentBo;
import org.dromara.project.domain.vo.project.BusProjectSafetyDayVo;
import org.dromara.project.domain.vo.project.BusProjectWeatherVo;
import org.dromara.project.domain.vo.projectnews.BusProjectNewsVo;
@ -70,4 +71,8 @@ public interface ProjectBigScreenService {
* @return 项目概括
*/
String getProjectGeneralize(Long projectId);
List<String> getList(Long projectId);
void setList(GpsEquipmentBo bo);
}

View File

@ -1,6 +1,8 @@
package org.dromara.bigscreen.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import jakarta.annotation.Resource;
import org.dromara.bigscreen.domain.vo.ProjectImageProgressVo;
import org.dromara.bigscreen.domain.vo.ProjectPeopleVo;
@ -9,9 +11,11 @@ import org.dromara.bigscreen.domain.vo.ProjectTeamAttendanceVo;
import org.dromara.bigscreen.service.ProjectBigScreenService;
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.contractor.domain.SubConstructionUser;
import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.gps.domain.bo.GpsEquipmentBo;
import org.dromara.progress.domain.PgsProgressCategory;
import org.dromara.progress.domain.enums.PgsProgressUnitTypeEnum;
import org.dromara.progress.service.IPgsProgressCategoryService;
@ -359,4 +363,25 @@ public class ProjectBigScreenServiceImpl implements ProjectBigScreenService {
}
}
@Override
public List<String> getList(Long projectId) {
if (projectId == null){
throw new ServiceException("项目id不能为空");
}
Object object = RedisUtils.getCacheObject("xmjdp:" + projectId);
if (object == null) {
return null;
}
JSONArray objects = JSONUtil.parseArray(object);
return objects.toList(String.class);
}
@Override
public void setList(GpsEquipmentBo bo) {
if (bo.getProjectId() == null){
throw new ServiceException("项目id不能为空");
}
RedisUtils.setCacheObject("xmjdp:"+bo.getProjectId(), bo.getIdList());
}
}

View File

@ -1,6 +1,7 @@
package org.dromara.gps.controller;
import java.util.List;
import java.util.Map;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -16,9 +17,7 @@ import org.dromara.contractor.domain.dto.constructionuser.SubConstructionUserQue
import org.dromara.contractor.domain.exportvo.BusConstructionUserExportVo;
import org.dromara.contractor.domain.vo.constructionuser.SubConstructionUserVo;
import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.gps.domain.vo.ConstructionUser;
import org.dromara.gps.domain.vo.GpsProjectVo;
import org.dromara.gps.domain.vo.GpsUserVo;
import org.dromara.gps.domain.vo.*;
import org.dromara.project.service.IBusProjectService;
import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.vo.SysUserVo;
@ -33,7 +32,6 @@ import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.gps.domain.vo.GpsEquipmentVo;
import org.dromara.gps.domain.bo.GpsEquipmentBo;
import org.dromara.gps.service.IGpsEquipmentService;
import org.dromara.common.mybatis.core.page.TableDataInfo;

View File

@ -9,6 +9,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.util.List;
/**
* GPS设备详细业务对象 gps_equipment
*
@ -78,4 +80,6 @@ public class GpsEquipmentBo extends BaseEntity {
private Integer type;
private List<String> idList;
}

View File

@ -1,9 +1,13 @@
package org.dromara.gps.mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.dromara.gps.domain.GpsEquipmentSon;
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import java.util.List;
/**
* GPS设备定位信息Mapper接口
*
@ -12,4 +16,20 @@ import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
*/
public interface GpsEquipmentSonMapper extends BaseMapperPlus<GpsEquipmentSon, GpsEquipmentSonVo> {
@Select("WITH RankedData AS (\n" +
" SELECT\n" +
" *,\n" +
" ROW_NUMBER() OVER (PARTITION BY client_id ORDER BY create_time DESC) AS rn\n" +
" FROM\n" +
" gps_equipment_son \n" +
"WHERE \n" +
"project_id = #{projectId}\n" +
")\n" +
"SELECT\n" +
" *\n" +
"FROM\n" +
" RankedData\n" +
"WHERE\n" +
" rn = 1;")
List<GpsEquipmentSonVo> getClientList(@Param("projectId") Long projectId);
}

View File

@ -1,5 +1,6 @@
package org.dromara.gps.service;
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
import org.dromara.gps.domain.vo.GpsEquipmentVo;
import org.dromara.gps.domain.bo.GpsEquipmentBo;
import org.dromara.gps.domain.GpsEquipment;
@ -94,4 +95,6 @@ public interface IGpsEquipmentService extends IService<GpsEquipment>{
List<GpsUserVo> getUserList(GpsEquipmentBo bo);
List<GpsProjectVo> getProjectList();
List<GpsEquipmentSonVo> getClientList(Long projectId);
}

View File

@ -67,4 +67,6 @@ public interface IGpsEquipmentSonService extends IService<GpsEquipmentSon>{
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
List<GpsEquipmentSonVo> getClientList(Long projectId);
}

View File

@ -1,6 +1,7 @@
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;
@ -20,6 +21,7 @@ import org.dromara.common.websocket.dto.WebSocketMessageDto;
import org.dromara.common.websocket.utils.WebSocketUtils;
import org.dromara.gps.domain.GpsManmachine;
import org.dromara.gps.domain.bo.GpsEquipmentSonBo;
import org.dromara.gps.domain.vo.GpsEquipmentSonVo;
import org.dromara.gps.domain.vo.GpsProjectVo;
import org.dromara.gps.domain.vo.GpsUserVo;
import org.dromara.gps.mapper.GpsManmachineMapper;
@ -44,7 +46,6 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.Duration;
import java.util.*;
import java.util.stream.Collectors;
/**
* GPS设备详细Service业务层处理
@ -246,11 +247,11 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
// WebSocketUtils.publishAll(pushContent);
// 2. 发布消息根据是否有用户ID决定发送给指定用户或广播
if (equipment != null && equipment.getUserId() != null) {
if (equipment != null && equipment.getProjectId() != null) {
// 发送给指定用户equipment.getUserId()
WebSocketMessageDto messageDto = new WebSocketMessageDto();
messageDto.setMessage(pushContent);
messageDto.setSessionKeys(Collections.singletonList(equipment.getUserId()));
messageDto.setSessionKeys(Collections.singletonList(equipment.getProjectId()));
WebSocketUtils.publishMessage(messageDto);
} else {
// 无用户ID则广播给所有在线客户端
@ -427,4 +428,11 @@ public class GpsEquipmentServiceImpl extends ServiceImpl<GpsEquipmentMapper, Gps
});
return list;
}
@Override
public List<GpsEquipmentSonVo> getClientList(Long projectId) {
return gpsEquipmentSonService.getClientList(projectId);
}
}

View File

@ -130,4 +130,9 @@ public class GpsEquipmentSonServiceImpl extends ServiceImpl<GpsEquipmentSonMappe
}
return baseMapper.deleteByIds(ids) > 0;
}
@Override
public List<GpsEquipmentSonVo> getClientList(Long projectId) {
return baseMapper.getClientList(projectId);
}
}