新增人员实时位置功能
This commit is contained in:
parent
9f05383de0
commit
4fa6b4927e
7
pom.xml
7
pom.xml
@ -106,6 +106,13 @@
|
|||||||
<artifactId>login-oauth2-server</artifactId>
|
<artifactId>login-oauth2-server</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mongodb start -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- mongodb end -->
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
package cn.com.tenlion.usercenter.controller.api.userrealtimelocation;
|
||||||
|
|
||||||
|
import cn.com.tenlion.usercenter.service.userrealtimelocation.IUserRealtimeLocationService;
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.module.map.pojo.dtos.userlocation.UserLocationDTO;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: UserRealtimeLocationController
|
||||||
|
* @Description: 用户实时定位
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-29 15:37:01
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "用户实时定位接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.API_PREFIX + "/user-realtime-location")
|
||||||
|
public class UserRealtimeLocationController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IUserRealtimeLocationService userRealtimeLocationService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除用户实时定位", notes = "删除用户实时定位接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@DeleteMapping("remove/{ids}")
|
||||||
|
public SuccessResult remove(@PathVariable("ids") String ids) {
|
||||||
|
userRealtimeLocationService.remove(Arrays.asList(ids.split("\\_")));
|
||||||
|
return new SuccessResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "用户定位列表", notes = "用户定位列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path", required = true),
|
||||||
|
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String", required = true),
|
||||||
|
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String", required = true)
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("list/{startTime}/{endTime}")
|
||||||
|
public List<UserLocationDTO> list(@PathVariable("userId") String userId,
|
||||||
|
@PathVariable("startTime") String startTime,
|
||||||
|
@PathVariable("endTime") String endTime) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
return userRealtimeLocationService.listByUserIdAndStartTimeAndEndTime(params, userId, startTime, endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "用户实时定位分页列表", notes = "用户实时定位分页列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||||
|
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||||
|
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("listpage/{startTime}/{endTime}")
|
||||||
|
public SuccessResultList<List<UserLocationDTO>> listPage(ListPage page,
|
||||||
|
@PathVariable("startTime") String startTime,
|
||||||
|
@PathVariable("endTime") String endTime) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
page.setParams(params);
|
||||||
|
return userRealtimeLocationService.listPageByStartTimeAndEndTime(page, startTime, endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "用户实时定位分页列表", notes = "用户实时定位分页列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||||
|
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||||
|
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("listpage")
|
||||||
|
public SuccessResultList<List<UserLocationDTO>> listPage(ListPage page) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
page.setParams(params);
|
||||||
|
return userRealtimeLocationService.listPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package cn.com.tenlion.usercenter.controller.app.api.userrealtimelocation;
|
||||||
|
|
||||||
|
import cn.com.tenlion.usercenter.service.userrealtimelocation.IUserRealtimeLocationService;
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.module.map.pojo.dtos.userlocation.UserLocationDTO;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: UserRealtimeLocationAppController
|
||||||
|
* @Description: 用户实时定位
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-29 15:37:01
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "用户实时定位接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.APP_PREFIX + "/user-realtime-location")
|
||||||
|
public class UserRealtimeLocationAppController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IUserRealtimeLocationService userRealtimeLocationService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "用户定位列表", notes = "用户定位列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header", required = true),
|
||||||
|
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String", required = true),
|
||||||
|
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String", required = true)
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("list")
|
||||||
|
public List<UserLocationDTO> list(@RequestHeader("token") String token,
|
||||||
|
@RequestParam("startTime") String startTime,
|
||||||
|
@RequestParam("endTime") String endTime) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
return userRealtimeLocationService.listByTokenAndStartTimeAndEndTime(params, token, startTime, endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "用户定位分页列表", notes = "用户定位分页列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "token", value = "token", paramType = "header", required = true),
|
||||||
|
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||||
|
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||||
|
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String", required = true),
|
||||||
|
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String", required = true)
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("listpage")
|
||||||
|
public SuccessResultList<List<UserLocationDTO>> listPage(@RequestHeader("token") String token,
|
||||||
|
ListPage page,
|
||||||
|
@RequestParam("startTime") String startTime,
|
||||||
|
@RequestParam("endTime") String endTime) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
page.setParams(params);
|
||||||
|
return userRealtimeLocationService.listPageByTokenAndStartTimeAndEndTime(token, page, startTime, endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package cn.com.tenlion.usercenter.controller.resource.userrealtimelocation;
|
||||||
|
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.module.map.pojo.dtos.userlocation.UserLocationDTO;
|
||||||
|
import ink.wgink.module.map.service.userlocation.IUserLocationService;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: UserRealtimeLocationResourceController
|
||||||
|
* @Description: 用户定位
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-29 15:37:01
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_RESOURCE_PREFIX + "用户实时定位接口")
|
||||||
|
@Primary
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/user-realtime-location")
|
||||||
|
public class UserRealtimeLocationResourceController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IUserLocationService userLocationService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "用户定位分页列表", notes = "用户定位分页列表接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
||||||
|
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
||||||
|
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
||||||
|
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@GetMapping("listpage")
|
||||||
|
public SuccessResultList<List<UserLocationDTO>> listPage(ListPage page) {
|
||||||
|
Map<String, Object> params = requestParams();
|
||||||
|
page.setParams(params);
|
||||||
|
return userLocationService.listPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.com.tenlion.usercenter.controller.route.userrealtimelocation;
|
||||||
|
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: UserLocationController
|
||||||
|
* @Description: 用户定位
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2021-10-29 15:37:01
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "用户实时定位路由")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/user-realtime-location")
|
||||||
|
public class UserRealtimeLocationRouteController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@GetMapping("list")
|
||||||
|
public ModelAndView list() {
|
||||||
|
return new ModelAndView("user-realtime-location/list");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package cn.com.tenlion.usercenter.enums.mongo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: MongoCollectionEnum
|
||||||
|
* @Description: mongo集合
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/29 4:21 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public enum MongoCollectionEnum {
|
||||||
|
|
||||||
|
USER_REALTIME_LOCATION("userRealtimeLocation", "用户实时定位");
|
||||||
|
|
||||||
|
private String collection;
|
||||||
|
private String summary;
|
||||||
|
|
||||||
|
MongoCollectionEnum(String collection, String summary) {
|
||||||
|
this.collection = collection;
|
||||||
|
this.summary = summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCollection() {
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSummary() {
|
||||||
|
return summary;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package cn.com.tenlion.usercenter.enums.websocket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: WebSocketCustomTypeEnum
|
||||||
|
* @Description: 自定义消息枚举类型
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/29 4:15 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public enum WebSocketCustomTypeEnum {
|
||||||
|
|
||||||
|
LOCATION_REALTIME(11001, "实时定位");
|
||||||
|
|
||||||
|
private int value;
|
||||||
|
private String summary;
|
||||||
|
|
||||||
|
WebSocketCustomTypeEnum(int value, String summary) {
|
||||||
|
this.value = value;
|
||||||
|
this.summary = summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSummary() {
|
||||||
|
return summary == null ? "" : summary.trim();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package cn.com.tenlion.usercenter.service.userrealtimelocation;
|
||||||
|
|
||||||
|
import ink.wgink.module.map.pojo.dtos.userlocation.UserLocationDTO;
|
||||||
|
import ink.wgink.module.map.pojo.vos.userlocation.UserLocationVO;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IUserRealtimeService
|
||||||
|
* @Description: 用户实时定位
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/29 3:57 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public interface IUserRealtimeLocationService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增用户定位
|
||||||
|
*
|
||||||
|
* @param userLocationVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void save(UserLocationVO userLocationVO);
|
||||||
|
|
||||||
|
void remove(List<String> ids);
|
||||||
|
|
||||||
|
List<UserLocationDTO> listByTokenAndStartTimeAndEndTime(Map<String,Object> params, String token, String startTime, String endTime);
|
||||||
|
|
||||||
|
List<UserLocationDTO> listByUserIdAndStartTimeAndEndTime(Map<String,Object> params, String userId, String startTime, String endTime);
|
||||||
|
|
||||||
|
SuccessResultList<List<UserLocationDTO>> listPageByTokenAndStartTimeAndEndTime(String token, ListPage page, String startTime, String endTime);
|
||||||
|
|
||||||
|
SuccessResultList<List<UserLocationDTO>> listPageByUserIdAndStartTimeAndEndTime(ListPage page, String userId, String startTime, String endTime);
|
||||||
|
|
||||||
|
SuccessResultList<List<UserLocationDTO>> listPageByStartTimeAndEndTime(ListPage page, String startTime, String endTime);
|
||||||
|
|
||||||
|
SuccessResultList<List<UserLocationDTO>> listPage(ListPage page);
|
||||||
|
}
|
@ -0,0 +1,139 @@
|
|||||||
|
package cn.com.tenlion.usercenter.service.userrealtimelocation.impl;
|
||||||
|
|
||||||
|
import cn.com.tenlion.usercenter.enums.mongo.MongoCollectionEnum;
|
||||||
|
import cn.com.tenlion.usercenter.service.userrealtimelocation.IUserRealtimeLocationService;
|
||||||
|
import ink.wgink.app.AppTokenManager;
|
||||||
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
|
import ink.wgink.module.map.pojo.dtos.userlocation.UserLocationDTO;
|
||||||
|
import ink.wgink.module.map.pojo.vos.userlocation.UserLocationVO;
|
||||||
|
import ink.wgink.module.map.service.userlocation.IUserLocationService;
|
||||||
|
import ink.wgink.pojo.ListPage;
|
||||||
|
import ink.wgink.pojo.result.SuccessResultList;
|
||||||
|
import ink.wgink.util.date.DateUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
import org.springframework.data.mongodb.core.query.Criteria;
|
||||||
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: UserRealtimeServiceImpl
|
||||||
|
* @Description: 用户实时定位
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/29 3:57 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UserRealtimeLocationServiceImpl extends DefaultBaseService implements IUserRealtimeLocationService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IUserLocationService userLocationService;
|
||||||
|
@Autowired
|
||||||
|
private MongoTemplate mongoTemplate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(UserLocationVO userLocationVO) {
|
||||||
|
userLocationVO.setGmtCreate(DateUtil.getTime());
|
||||||
|
userLocationService.save(userLocationVO.getCreator(), userLocationVO);
|
||||||
|
mongoTemplate.insert(userLocationVO, MongoCollectionEnum.USER_REALTIME_LOCATION.getCollection());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove(List<String> ids) {
|
||||||
|
userLocationService.remove(ids);
|
||||||
|
Query query = new Query(Criteria.where("userLocationId").in(ids));
|
||||||
|
mongoTemplate.remove(query, MongoCollectionEnum.USER_REALTIME_LOCATION.getCollection());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserLocationDTO> listByTokenAndStartTimeAndEndTime(Map<String, Object> params, String token, String startTime, String endTime) {
|
||||||
|
String userId = AppTokenManager.getInstance().getToken(token).getUserId();
|
||||||
|
return listByUserIdAndStartTimeAndEndTime(params, userId, startTime, endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserLocationDTO> listByUserIdAndStartTimeAndEndTime(Map<String, Object> params, String userId, String startTime, String endTime) {
|
||||||
|
Query query = getListQuery(userId, startTime, endTime, params);
|
||||||
|
return mongoTemplate.find(query, UserLocationDTO.class, MongoCollectionEnum.USER_REALTIME_LOCATION.getCollection());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<UserLocationDTO>> listPageByTokenAndStartTimeAndEndTime(String token, ListPage page, String startTime, String endTime) {
|
||||||
|
String userId = AppTokenManager.getInstance().getToken(token).getUserId();
|
||||||
|
return listPageByUserIdAndStartTimeAndEndTime(page, userId, startTime, endTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<UserLocationDTO>> listPageByUserIdAndStartTimeAndEndTime(ListPage page, String userId, String startTime, String endTime) {
|
||||||
|
Query query = getListQuery(userId, startTime, endTime, page.getParams());
|
||||||
|
return listPage(query, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<UserLocationDTO>> listPageByStartTimeAndEndTime(ListPage page, String startTime, String endTime) {
|
||||||
|
Query query = getListQuery(null, startTime, endTime, page.getParams());
|
||||||
|
return listPage(query, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SuccessResultList<List<UserLocationDTO>> listPage(ListPage page) {
|
||||||
|
String startTime = Objects.toString(page.getParams().get("startTime"), "");
|
||||||
|
String endTime = Objects.toString(page.getParams().get("endTime"), "");
|
||||||
|
Query query = getListQuery(null, startTime, endTime, page.getParams());
|
||||||
|
return listPage(query, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param query
|
||||||
|
* @param page
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private SuccessResultList<List<UserLocationDTO>> listPage(Query query, ListPage page) {
|
||||||
|
long total = mongoTemplate.count(query, MongoCollectionEnum.USER_REALTIME_LOCATION.getCollection());
|
||||||
|
query.with(Pageable.ofSize(page.getRows()).withPage(page.getPage() - 1));
|
||||||
|
List<UserLocationDTO> userLocationDTOs = mongoTemplate.find(query, UserLocationDTO.class, MongoCollectionEnum.USER_REALTIME_LOCATION.getCollection());
|
||||||
|
return new SuccessResultList<>(userLocationDTOs, page.getPage(), total);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到列表请求对象
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param startTime
|
||||||
|
* @param endTime
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Query getListQuery(String userId, String startTime, String endTime, Map<String, Object> params) {
|
||||||
|
Query query = new Query();
|
||||||
|
if (!StringUtils.isBlank(startTime) || !StringUtils.isBlank(endTime)) {
|
||||||
|
Criteria criteria = Criteria.where("gmtCreate");
|
||||||
|
if (!StringUtils.isBlank(startTime)) {
|
||||||
|
criteria.gt(startTime);
|
||||||
|
}
|
||||||
|
if (!StringUtils.isBlank(endTime)) {
|
||||||
|
criteria.lt(endTime);
|
||||||
|
}
|
||||||
|
query.addCriteria(criteria);
|
||||||
|
}
|
||||||
|
if (!StringUtils.isBlank(userId)) {
|
||||||
|
query.addCriteria(Criteria.where("uerId").is(userId));
|
||||||
|
}
|
||||||
|
String keywords = getKeywords(params);
|
||||||
|
if (!StringUtils.isBlank(keywords)) {
|
||||||
|
Pattern pattern = Pattern.compile("^.*" + keywords + ".*$", Pattern.CASE_INSENSITIVE);
|
||||||
|
query.addCriteria(Criteria.where("userName").regex(pattern));
|
||||||
|
query.addCriteria(Criteria.where("uerUsername").regex(pattern));
|
||||||
|
}
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package cn.com.tenlion.usercenter.service.websocket;
|
||||||
|
|
||||||
|
import cn.com.tenlion.usercenter.enums.websocket.WebSocketCustomTypeEnum;
|
||||||
|
import cn.com.tenlion.usercenter.service.userrealtimelocation.IUserRealtimeLocationService;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
|
import ink.wgink.module.instantmessage.service.IWebSocketTextCustomService;
|
||||||
|
import ink.wgink.module.instantmessage.websocket.exception.CustomHandleException;
|
||||||
|
import ink.wgink.module.instantmessage.websocket.pojo.WebSocketClientMessage;
|
||||||
|
import ink.wgink.module.map.pojo.vos.userlocation.UserLocationVO;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: WebSocketTextCustomServiceImpl
|
||||||
|
* @Description: 自定义websocket业务实现
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/10/29 2:40 下午
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class WebSocketTextCustomServiceImpl extends DefaultBaseService implements IWebSocketTextCustomService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IUserRealtimeLocationService userRealtimeLocationService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Channel channel, WebSocketClientMessage webSocketClientMessage) throws CustomHandleException {
|
||||||
|
try {
|
||||||
|
if (WebSocketCustomTypeEnum.LOCATION_REALTIME.getValue() == webSocketClientMessage.getType()) {
|
||||||
|
UserLocationVO userLocationVO = JSONObject.parseObject(webSocketClientMessage.getBody(), UserLocationVO.class);
|
||||||
|
userRealtimeLocationService.save(userLocationVO);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new CustomHandleException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -50,13 +50,16 @@ spring:
|
|||||||
slow-sql-millis: 2000
|
slow-sql-millis: 2000
|
||||||
connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
|
connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
|
||||||
use-global-data-source-stat: true
|
use-global-data-source-stat: true
|
||||||
|
data:
|
||||||
|
mongodb:
|
||||||
|
uri: mongodb://usercenter:usercenter@192.168.0.156:27017/smart-city-usercenter
|
||||||
|
|
||||||
mybatis:
|
mybatis:
|
||||||
config-location: classpath:mybatis/mybatis-config.xml
|
config-location: classpath:mybatis/mybatis-config.xml
|
||||||
mapper-locations: classpath*:mybatis/mapper/**/*.xml
|
mapper-locations: classpath*:mybatis/mapper/**/*.xml
|
||||||
|
|
||||||
swagger:
|
swagger:
|
||||||
base-package-list: ink.wgink,com.cn
|
base-package-list: ink.wgink,cn.com.tenlion
|
||||||
|
|
||||||
file:
|
file:
|
||||||
upload-path: /Users/wanggeng/Desktop/UploadFiles/
|
upload-path: /Users/wanggeng/Desktop/UploadFiles/
|
||||||
@ -90,6 +93,6 @@ logging:
|
|||||||
name: /Users/wanggeng/Desktop/UploadFiles/logs/usercenter-logs.log
|
name: /Users/wanggeng/Desktop/UploadFiles/logs/usercenter-logs.log
|
||||||
level:
|
level:
|
||||||
root: error
|
root: error
|
||||||
|
org.springframework.data.mongodb: debug
|
||||||
org.springframework.boot.autoconfigure.security.servlet: debug
|
org.springframework.boot.autoconfigure.security.servlet: debug
|
||||||
ink.wgink: debug
|
ink.wgink: debug
|
||||||
cn.com: debug
|
|
276
src/main/resources/templates/user-realtime-location/list.html
Normal file
276
src/main/resources/templates/user-realtime-location/list.html
Normal file
@ -0,0 +1,276 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'}">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||||
|
<div class="layui-row">
|
||||||
|
<div class="layui-col-md12">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="keywords" class="layui-input search-item search-item-width-100" placeholder="输入关键字">
|
||||||
|
</div>
|
||||||
|
新增时间
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="startTime" class="layui-input search-item" placeholder="开始时间" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="layui-inline">
|
||||||
|
<input type="text" id="endTime" class="layui-input search-item" placeholder="结束时间" readonly>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||||
|
<i class="fa fa-lg fa-search"></i> 搜索
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||||
|
<!-- 表头按钮组 -->
|
||||||
|
<script type="text/html" id="headerToolBar">
|
||||||
|
<div class="layui-btn-group">
|
||||||
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
|
||||||
|
<i class="fa fa-lg fa-plus"></i> 新增
|
||||||
|
</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
|
||||||
|
<i class="fa fa-lg fa-edit"></i> 编辑
|
||||||
|
</button>
|
||||||
|
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
|
||||||
|
<i class="fa fa-lg fa-trash"></i> 删除
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||||
|
<script>
|
||||||
|
layui.config({
|
||||||
|
base: 'assets/layuiadmin/'
|
||||||
|
}).extend({
|
||||||
|
index: 'lib/index'
|
||||||
|
}).use(['index', 'table', 'laydate', 'common'], function() {
|
||||||
|
var $ = layui.$;
|
||||||
|
var $win = $(window);
|
||||||
|
var table = layui.table;
|
||||||
|
var admin = layui.admin;
|
||||||
|
var laydate = layui.laydate;
|
||||||
|
var common = layui.common;
|
||||||
|
var resizeTimeout = null;
|
||||||
|
var startTime = common.formatDate('yyyy-MM-dd', new Date()) +' 00:00:00';
|
||||||
|
var endTime = common.formatDate('yyyy-MM-dd', new Date()) +' 23:59:59'
|
||||||
|
|
||||||
|
var tableUrl = 'api/user-realtime-location/listpage';
|
||||||
|
|
||||||
|
// 初始化表格
|
||||||
|
function initTable() {
|
||||||
|
table.render({
|
||||||
|
elem: '#dataTable',
|
||||||
|
id: 'dataTable',
|
||||||
|
url: top.restAjax.path(tableUrl, [startTime, endTime]),
|
||||||
|
width: admin.screen() > 1 ? '100%' : '',
|
||||||
|
height: $win.height() - 90,
|
||||||
|
limit: 20,
|
||||||
|
limits: [20, 40, 60, 80, 100, 200],
|
||||||
|
toolbar: '#headerToolBar',
|
||||||
|
request: {
|
||||||
|
pageName: 'page',
|
||||||
|
limitName: 'rows'
|
||||||
|
},
|
||||||
|
cols: [
|
||||||
|
[
|
||||||
|
{type:'checkbox', fixed: 'left'},
|
||||||
|
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||||
|
{field: 'userUsername', width: 180, title: '用户名', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'userName', width: 180, title: '昵称', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'userLng', width: 180, title: '用户经度', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'userLat', width: 180, title: '用户精度', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'isOverstep', width: 180, title: '是否越界', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{field: 'gmtCreate', width: 180, title: '创建时间', align:'center',
|
||||||
|
templet: function(row) {
|
||||||
|
var rowData = row[this.field];
|
||||||
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
return rowData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
],
|
||||||
|
page: true,
|
||||||
|
parseData: function(data) {
|
||||||
|
return {
|
||||||
|
'code': 0,
|
||||||
|
'msg': '',
|
||||||
|
'count': data.total,
|
||||||
|
'data': data.rows
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 重载表格
|
||||||
|
function reloadTable(currentPage) {
|
||||||
|
table.reload('dataTable', {
|
||||||
|
where: {
|
||||||
|
keywords: $('#keywords').val(),
|
||||||
|
startTime: $('#startTime').val(),
|
||||||
|
endTime: $('#endTime').val()
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
curr: currentPage
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 初始化日期
|
||||||
|
function initDate() {
|
||||||
|
// 日期选择
|
||||||
|
laydate.render({
|
||||||
|
elem: '#startTime',
|
||||||
|
type: 'datetime',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
});
|
||||||
|
laydate.render({
|
||||||
|
elem: '#endTime',
|
||||||
|
type: 'datetime',
|
||||||
|
format: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 删除
|
||||||
|
function removeData(ids) {
|
||||||
|
top.dialog.msg(top.dataMessage.delete, {
|
||||||
|
time: 0,
|
||||||
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||||
|
shade: 0.3,
|
||||||
|
yes: function (index) {
|
||||||
|
top.dialog.close(index);
|
||||||
|
var layIndex;
|
||||||
|
top.restAjax.delete(top.restAjax.path('api/user-location/remove/{ids}', [ids]), {}, null, function (code, data) {
|
||||||
|
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
||||||
|
reloadTable();
|
||||||
|
}, function (code, data) {
|
||||||
|
top.dialog.msg(data.msg);
|
||||||
|
}, function () {
|
||||||
|
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
|
||||||
|
}, function () {
|
||||||
|
top.dialog.close(layIndex);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initTable();
|
||||||
|
initDate();
|
||||||
|
// 事件 - 页面变化
|
||||||
|
$win.on('resize', function() {
|
||||||
|
clearTimeout(resizeTimeout);
|
||||||
|
resizeTimeout = setTimeout(function() {
|
||||||
|
reloadTable();
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
// 事件 - 搜索
|
||||||
|
$(document).on('click', '#search', function() {
|
||||||
|
reloadTable(1);
|
||||||
|
});
|
||||||
|
// 事件 - 增删改
|
||||||
|
table.on('toolbar(dataTable)', function(obj) {
|
||||||
|
var layEvent = obj.event;
|
||||||
|
var checkStatus = table.checkStatus('dataTable');
|
||||||
|
var checkDatas = checkStatus.data;
|
||||||
|
if(layEvent === 'saveEvent') {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: false,
|
||||||
|
closeBtn: 0,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
shadeClose: true,
|
||||||
|
anim: 2,
|
||||||
|
content: top.restAjax.path('route/user-location/save', []),
|
||||||
|
end: function() {
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if(layEvent === 'updateEvent') {
|
||||||
|
if(checkDatas.length === 0) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectEdit);
|
||||||
|
} else if(checkDatas.length > 1) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectOneEdit);
|
||||||
|
} else {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: false,
|
||||||
|
closeBtn: 0,
|
||||||
|
area: ['100%', '100%'],
|
||||||
|
shadeClose: true,
|
||||||
|
anim: 2,
|
||||||
|
content: top.restAjax.path('route/user-location/update?userLocationId={userLocationId}', [checkDatas[0].userLocationId]),
|
||||||
|
end: function() {
|
||||||
|
reloadTable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if(layEvent === 'removeEvent') {
|
||||||
|
if(checkDatas.length === 0) {
|
||||||
|
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||||
|
} else {
|
||||||
|
var ids = '';
|
||||||
|
for(var i = 0, item; item = checkDatas[i++];) {
|
||||||
|
if(i > 1) {
|
||||||
|
ids += '_';
|
||||||
|
}
|
||||||
|
ids += item['userLocationId'];
|
||||||
|
}
|
||||||
|
removeData(ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user