locationRecord 定位记录查询
This commit is contained in:
parent
acb9da6087
commit
0a9652f144
@ -0,0 +1,39 @@
|
|||||||
|
package cn.skcks.matrix.v2.api.locatioin.record;
|
||||||
|
|
||||||
|
import cn.skcks.matrix.v2.annotation.web.JsonMapping;
|
||||||
|
import cn.skcks.matrix.v2.annotation.web.methods.PostJson;
|
||||||
|
import cn.skcks.matrix.v2.config.swagger.SwaggerConfig;
|
||||||
|
import cn.skcks.matrix.v2.model.location.record.dto.LocationRecordParams;
|
||||||
|
import cn.skcks.matrix.v2.model.location.record.vo.LocationRecordVo;
|
||||||
|
import cn.skcks.matrix.v2.services.location.record.LocationRecordService;
|
||||||
|
import cn.skcks.matrix.v2.utils.json.JsonResponse;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springdoc.core.models.GroupedOpenApi;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Tag(name = "定位记录")
|
||||||
|
@RestController
|
||||||
|
@JsonMapping("/location/record")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class LocationRecordController {
|
||||||
|
private final LocationRecordService locationRecordService;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public GroupedOpenApi docs() {
|
||||||
|
return SwaggerConfig.api("Location Record", "/location/record");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostJson("/")
|
||||||
|
@Operation(summary = "查询记录")
|
||||||
|
public JsonResponse<Collection<LocationRecordVo>> getLocationRecord(@RequestBody LocationRecordParams params){
|
||||||
|
return locationRecordService.getLocationRecord(params).parseResponse();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package cn.skcks.matrix.v2.model.location.record.convert;
|
||||||
|
|
||||||
|
import cn.skcks.matrix.v2.model.location.record.vo.LocationRecordVo;
|
||||||
|
import cn.skcks.matrix.v2.orm.mybatis.dynamic.model.LocationRecord;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
import org.mapstruct.Mappings;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public abstract class LocationRecordConvertor {
|
||||||
|
public final static LocationRecordConvertor INSTANCE = Mappers.getMapper(LocationRecordConvertor.class);
|
||||||
|
|
||||||
|
@Mappings({
|
||||||
|
@Mapping(source = "id", target = "id"),
|
||||||
|
@Mapping(source = "userId", target = "userId")
|
||||||
|
})
|
||||||
|
abstract public LocationRecordVo daoToVo(LocationRecord user);
|
||||||
|
|
||||||
|
abstract public Collection<LocationRecordVo> daoToVo(Collection<LocationRecord> users);
|
||||||
|
|
||||||
|
abstract public PageInfo<LocationRecordVo> daoToVo(PageInfo<LocationRecord> userPageInfo);
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package cn.skcks.matrix.v2.model.location.record.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LocationRecordParams {
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date endTime;
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package cn.skcks.matrix.v2.model.location.record.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(title = "定位记录信息")
|
||||||
|
public class LocationRecordVo {
|
||||||
|
@Schema(description = "记录id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Schema(description = "定位时间")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date locationTime;
|
||||||
|
|
||||||
|
@Schema(description = "定位类型")
|
||||||
|
private Integer locationType;
|
||||||
|
|
||||||
|
@Schema(description = "(高德) 纬度")
|
||||||
|
private Double latitude;
|
||||||
|
|
||||||
|
@Schema(description = "(高德) 经度")
|
||||||
|
private Double longitude;
|
||||||
|
|
||||||
|
@Schema(description = "精度")
|
||||||
|
private Double accuracy;
|
||||||
|
|
||||||
|
@Schema(description = "高度(m)")
|
||||||
|
private Double altitude;
|
||||||
|
|
||||||
|
@Schema(description = "方向角(°)")
|
||||||
|
private Double bearing;
|
||||||
|
|
||||||
|
@Schema(description = "速度(m/s)")
|
||||||
|
private Double speed;
|
||||||
|
|
||||||
|
@Schema(description = "国家")
|
||||||
|
private String country;
|
||||||
|
|
||||||
|
@Schema(description = "省份")
|
||||||
|
private String province;
|
||||||
|
|
||||||
|
@Schema(description = "城市")
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
@Schema(description = "区")
|
||||||
|
private String district;
|
||||||
|
|
||||||
|
@Schema(description = "街道")
|
||||||
|
private String street;
|
||||||
|
|
||||||
|
@Schema(description = "街道号码")
|
||||||
|
private String streetNumber;
|
||||||
|
|
||||||
|
@Schema(description = "城市代号")
|
||||||
|
private String cityCode;
|
||||||
|
|
||||||
|
@Schema(description = "区域编码")
|
||||||
|
private String adCode;
|
||||||
|
|
||||||
|
@Schema(description = "详细地址(大概)")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Schema(description = "描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "用户id")
|
||||||
|
private String userId;
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package cn.skcks.matrix.v2.services.location.record;
|
||||||
|
|
||||||
|
import cn.skcks.matrix.v2.model.location.record.dto.LocationRecordParams;
|
||||||
|
import cn.skcks.matrix.v2.model.location.record.vo.LocationRecordVo;
|
||||||
|
import cn.skcks.matrix.v2.model.services.ServiceResult;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface LocationRecordService {
|
||||||
|
ServiceResult<Collection<LocationRecordVo>> getLocationRecord(LocationRecordParams params);
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package cn.skcks.matrix.v2.services.location.record;
|
||||||
|
|
||||||
|
import cn.skcks.matrix.v2.model.location.record.convert.LocationRecordConvertor;
|
||||||
|
import cn.skcks.matrix.v2.model.location.record.dto.LocationRecordParams;
|
||||||
|
import cn.skcks.matrix.v2.model.location.record.vo.LocationRecordVo;
|
||||||
|
import cn.skcks.matrix.v2.model.services.ServiceResult;
|
||||||
|
import cn.skcks.matrix.v2.orm.mybatis.dynamic.mapper.LocationRecordDynamicSqlSupport;
|
||||||
|
import cn.skcks.matrix.v2.orm.mybatis.dynamic.mapper.LocationRecordMapper;
|
||||||
|
import cn.skcks.matrix.v2.orm.mybatis.dynamic.model.LocationRecord;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.mybatis.dynamic.sql.SqlBuilder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class LocationRecordServiceImpl implements LocationRecordService{
|
||||||
|
private final LocationRecordMapper locationRecordMapper;
|
||||||
|
@Override
|
||||||
|
public ServiceResult<Collection<LocationRecordVo>> getLocationRecord(LocationRecordParams params) {
|
||||||
|
List<LocationRecord> recordList = locationRecordMapper.select((s)-> s.applyWhere(dsl -> {
|
||||||
|
if (params.getStartTime() != null) {
|
||||||
|
dsl.and(LocationRecordDynamicSqlSupport.locationTime, SqlBuilder.isGreaterThanOrEqualTo(params.getStartTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.getEndTime() != null) {
|
||||||
|
dsl.and(LocationRecordDynamicSqlSupport.locationTime,SqlBuilder.isLessThanOrEqualTo(params.getEndTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
dsl.and(LocationRecordDynamicSqlSupport.id,SqlBuilder.isNotNull());
|
||||||
|
}));
|
||||||
|
|
||||||
|
return ServiceResult.<Collection<LocationRecordVo>>builder()
|
||||||
|
.result(recordList.stream().map(LocationRecordConvertor.INSTANCE::daoToVo).toList())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user