From cfa829af899676b1464eccac65b11084aa2a8508 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Wed, 20 Dec 2023 16:39:21 +0800
Subject: [PATCH] 实时位置
---
src/main/java/org/springblade/modules/location/controller/LivePersonLocationController.java | 52 +++++++++++++++++
src/main/java/org/springblade/modules/location/entity/LivePersonLocation.java | 31 ++++++++++
src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.xml | 13 ++++
src/main/java/org/springblade/modules/location/service/ILivePersonLocationService.java | 11 +++
src/main/java/org/springblade/modules/location/vo/LivePersonLocationVO.java | 8 ++
src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.java | 14 ++++
src/main/java/org/springblade/modules/location/service/impl/LivePersonLocationServiceImpl.java | 36 ++++++++++++
7 files changed, 165 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/springblade/modules/location/controller/LivePersonLocationController.java b/src/main/java/org/springblade/modules/location/controller/LivePersonLocationController.java
new file mode 100644
index 0000000..e13e8e2
--- /dev/null
+++ b/src/main/java/org/springblade/modules/location/controller/LivePersonLocationController.java
@@ -0,0 +1,52 @@
+package org.springblade.modules.location.controller;
+
+import io.swagger.annotations.ApiOperation;
+import lombok.AllArgsConstructor;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.tool.api.R;
+import org.springblade.modules.location.entity.LivePersonLocation;
+import org.springblade.modules.location.entity.Locus;
+import org.springblade.modules.location.service.ILivePersonLocationService;
+import org.springblade.modules.location.vo.LivePersonLocationVO;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @author zhongrj
+ * @time 2021-07-21
+ * @desc 实时位置控制层
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/livePersonLocation")
+public class LivePersonLocationController extends BladeController {
+
+ private final ILivePersonLocationService livePersonLocationService;
+
+ /**
+ * 新增
+ */
+ @PostMapping("/save")
+ public R save(@RequestBody LivePersonLocation livePersonLocation) {
+ return R.status(livePersonLocationService.save(livePersonLocation));
+ }
+
+
+ /**
+ * 新增或更新位置信息
+ */
+ @PostMapping("/saveOrUpdate")
+ public R saveOrUpdate(@RequestBody LivePersonLocation livePersonLocation) {
+ return R.status(livePersonLocationService.saveOrUpdate(livePersonLocation));
+ }
+
+ /**
+ * 新增或更新位置信息
+ */
+ @GetMapping("/getList")
+ public R getList(LivePersonLocationVO livePersonLocation) {
+ List<LivePersonLocationVO> list = livePersonLocationService.getList(livePersonLocation);
+ return R.data(list);
+ }
+}
diff --git a/src/main/java/org/springblade/modules/location/entity/LivePersonLocation.java b/src/main/java/org/springblade/modules/location/entity/LivePersonLocation.java
new file mode 100644
index 0000000..99350d7
--- /dev/null
+++ b/src/main/java/org/springblade/modules/location/entity/LivePersonLocation.java
@@ -0,0 +1,31 @@
+package org.springblade.modules.location.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 人员实时位置
+ */
+@Data
+@TableName("sys_live_person_location")
+public class LivePersonLocation implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @TableId(value = "id",type = IdType.AUTO)
+ private Long id;
+
+ private String longitude;
+
+ private String latitude;
+
+ private Long userId;
+
+ private Date recordTime;
+
+}
diff --git a/src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.java b/src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.java
new file mode 100644
index 0000000..4841475
--- /dev/null
+++ b/src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.java
@@ -0,0 +1,14 @@
+package org.springblade.modules.location.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.modules.location.entity.LivePersonLocation;
+import org.springblade.modules.location.vo.LivePersonLocationVO;
+
+import java.util.List;
+
+public interface LivePersonLocationMapper extends BaseMapper<LivePersonLocation> {
+ LivePersonLocation getUserLocation(@Param("userId") Long userId);
+
+ List<LivePersonLocationVO> getList(@Param("vo") LivePersonLocationVO livePersonLocation);
+}
diff --git a/src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.xml b/src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.xml
new file mode 100644
index 0000000..462a67a
--- /dev/null
+++ b/src/main/java/org/springblade/modules/location/mapper/LivePersonLocationMapper.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.modules.location.mapper.LivePersonLocationMapper">
+
+
+ <select id="getUserLocation" resultType="org.springblade.modules.location.entity.LivePersonLocation">
+ SELECT * FROM sys_live_person_location WHERE user_id = #{userId}
+ </select>
+
+ <select id="getList" resultType="org.springblade.modules.location.vo.LivePersonLocationVO">
+ SELECT lpl.* FROM sys_live_person_location lpl
+ </select>
+</mapper>
diff --git a/src/main/java/org/springblade/modules/location/service/ILivePersonLocationService.java b/src/main/java/org/springblade/modules/location/service/ILivePersonLocationService.java
new file mode 100644
index 0000000..1fa9204
--- /dev/null
+++ b/src/main/java/org/springblade/modules/location/service/ILivePersonLocationService.java
@@ -0,0 +1,11 @@
+package org.springblade.modules.location.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.modules.location.entity.LivePersonLocation;
+import org.springblade.modules.location.vo.LivePersonLocationVO;
+
+import java.util.List;
+
+public interface ILivePersonLocationService extends IService<LivePersonLocation> {
+ List<LivePersonLocationVO> getList(LivePersonLocationVO livePersonLocation);
+}
diff --git a/src/main/java/org/springblade/modules/location/service/impl/LivePersonLocationServiceImpl.java b/src/main/java/org/springblade/modules/location/service/impl/LivePersonLocationServiceImpl.java
new file mode 100644
index 0000000..5683186
--- /dev/null
+++ b/src/main/java/org/springblade/modules/location/service/impl/LivePersonLocationServiceImpl.java
@@ -0,0 +1,36 @@
+package org.springblade.modules.location.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.core.tool.utils.DateUtil;
+import org.springblade.modules.location.entity.LivePersonLocation;
+import org.springblade.modules.location.mapper.LivePersonLocationMapper;
+import org.springblade.modules.location.service.ILivePersonLocationService;
+import org.springblade.modules.location.vo.LivePersonLocationVO;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class LivePersonLocationServiceImpl extends ServiceImpl<LivePersonLocationMapper, LivePersonLocation> implements ILivePersonLocationService {
+ @Override
+ public boolean saveOrUpdate(LivePersonLocation entity) {
+ Date recordTime = DateUtil.now();
+ entity.setRecordTime(recordTime);
+
+ //查询数据库中是否已有该人员
+ LivePersonLocation livePersonLocation = baseMapper.getUserLocation(entity.getUserId());
+
+ if (livePersonLocation == null){
+ return baseMapper.insert(entity)>-1;
+ }else{
+ entity.setId(livePersonLocation.getId());
+ return baseMapper.updateById(entity)>-1;
+ }
+ }
+
+ @Override
+ public List<LivePersonLocationVO> getList(LivePersonLocationVO livePersonLocation) {
+ return baseMapper.getList(livePersonLocation);
+ }
+}
diff --git a/src/main/java/org/springblade/modules/location/vo/LivePersonLocationVO.java b/src/main/java/org/springblade/modules/location/vo/LivePersonLocationVO.java
new file mode 100644
index 0000000..bb547ee
--- /dev/null
+++ b/src/main/java/org/springblade/modules/location/vo/LivePersonLocationVO.java
@@ -0,0 +1,8 @@
+package org.springblade.modules.location.vo;
+
+import lombok.Data;
+import org.springblade.modules.location.entity.LivePersonLocation;
+
+@Data
+public class LivePersonLocationVO extends LivePersonLocation {
+}
--
Gitblit v1.9.3