位置管理功能

This commit is contained in:
cwchen 2025-12-24 09:59:55 +08:00
parent 19ff90cf77
commit ae226ebda6
7 changed files with 263 additions and 0 deletions

View File

@ -0,0 +1,44 @@
package com.bonus.web.controller.data;
import com.bonus.common.annotation.RequiresPermissions;
import com.bonus.common.annotation.SysLog;
import com.bonus.common.core.controller.BaseController;
import com.bonus.common.core.page.TableDataInfo;
import com.bonus.common.domain.data.dto.ParamsDto;
import com.bonus.common.domain.data.vo.DeviceIdentificationDataVo;
import com.bonus.common.domain.data.vo.LocationVo;
import com.bonus.common.enums.OperaType;
import com.bonus.web.service.data.LocationService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @className:LocationController
* @author:cwchen
* @date:2025-12-24-9:19
* @version:1.0
* @description:位置管理-web层
*/
@RestController
@RequestMapping("/data/location")
public class LocationController extends BaseController {
@Resource(name = "LocationService")
private LocationService locationService;
@ApiOperation(notes = "查询位置列表",value = "查询位置列表")
@RequiresPermissions("data:location:list")
@GetMapping("/getLocationList")
@SysLog(title = "位置管理", businessType = OperaType.QUERY, logType = 1, module = "设备管理->位置管理", details = "查询位置列表")
public TableDataInfo getLocationList(ParamsDto dto) {
startPage();
List<LocationVo> list = locationService.getLocationList(dto);
return getDataTable(list);
}
}

View File

@ -0,0 +1,60 @@
package com.bonus.web.service.data;
import com.bonus.common.domain.data.dto.ParamsDto;
import com.bonus.common.domain.data.vo.AlarmVo;
import com.bonus.common.domain.data.vo.LocationVo;
import com.bonus.data.service.DILocationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
* @className:LocationService
* @author:cwchen
* @date:2025-12-24-9:20
* @version:1.0
* @description:位置管理-业务逻辑层
*/
@Service(value = "LocationService")
@Slf4j
public class LocationService {
@Resource(name = "DILocationService")
private DILocationService locationService;
/**
* 查询位置列表
* @param dto
* @return List<LocationVo>
* @author cwchen
* @date 2025/12/24 9:39
*/
public List<LocationVo> getLocationList(ParamsDto dto) {
try {
if (dto.getStartTime() == null || dto.getEndTime() == null) {
// 获取今天的日期
LocalDateTime now = LocalDateTime.now();
// 设置开始时间为 00:00:00
LocalDateTime startOfDay = now.with(LocalTime.MIN);
// 设置结束时间为 23:59:59 (也可以使用 LocalTime.MAX)
LocalDateTime endOfDay = now.with(LocalTime.MAX);
// 转换为 Date 赋值给 dto (如果你的字段类型是 Date)
ZoneId zone = ZoneId.systemDefault();
dto.setStartTime(Date.from(startOfDay.atZone(zone).toInstant()));
dto.setEndTime(Date.from(endOfDay.atZone(zone).toInstant()));
}
List<LocationVo> result = locationService.getLocationList(dto);
return result != null ? result : Collections.emptyList();
} catch (Exception e) {
log.error(e.toString(),e);
return Collections.emptyList();
}
}
}

View File

@ -0,0 +1,55 @@
package com.bonus.common.domain.data.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @className:LocationVo
* @author:cwchen
* @date:2025-12-24-9:27
* @version:1.0
* @description:位置-vo
*/
@Data
public class LocationVo {
/**
* 位置id
*/
private Long locationId;
/**
* 系统id
*/
private Long systemId;
/**
* 地点
*/
private String locationName;
/**
* 经度
*/
private String lon;
/**
* 纬度
*/
private String lat;
/**
* 时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date locationTime;
/**
* 坐标类型 1.百度坐标 2.高德坐标
*/
private String coordinateType;
}

View File

@ -0,0 +1,27 @@
package com.bonus.data.mapper;
import com.bonus.common.domain.data.dto.ParamsDto;
import com.bonus.common.domain.data.vo.LocationVo;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @className:DILocationMapper
* @author:cwchen
* @date:2025-12-24-9:26
* @version:1.0
* @description:位置管理-数据层
*/
@Repository(value = "DILocationMapper")
public interface DILocationMapper {
/**
* 查询位置列表
* @param dto
* @return List<LocationVo>
* @author cwchen
* @date 2025/12/24 9:45
*/
List<LocationVo> getLocationList(ParamsDto dto);
}

View File

@ -0,0 +1,24 @@
package com.bonus.data.service;
import com.bonus.common.domain.data.dto.ParamsDto;
import com.bonus.common.domain.data.vo.LocationVo;
import java.util.List;
/**
* @className:DILocationService
* @author:cwchen
* @date:2025-12-24-9:24
* @version:1.0
* @description:位置管理-业务层
*/
public interface DILocationService {
/**
* 查询位置列表
* @param dto
* @return List<LocationVo>
* @author cwchen
* @date 2025/12/24 9:44
*/
List<LocationVo> getLocationList(ParamsDto dto);
}

View File

@ -0,0 +1,30 @@
package com.bonus.data.service.impl;
import com.bonus.common.domain.data.dto.ParamsDto;
import com.bonus.common.domain.data.vo.LocationVo;
import com.bonus.data.mapper.DILocationMapper;
import com.bonus.data.service.DILocationService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
/**
* @className:DLocationServiceImpl
* @author:cwchen
* @date:2025-12-24-9:24
* @version:1.0
* @description:位置管理-业务逻辑层
*/
@Service(value = "DILocationService")
public class DLocationServiceImpl implements DILocationService {
@Resource(name = "DILocationMapper")
private DILocationMapper diLocationMapper;
@Override
public List<LocationVo> getLocationList(ParamsDto dto) {
return diLocationMapper.getLocationList(dto);
}
}

View File

@ -0,0 +1,23 @@
<?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="com.bonus.data.mapper.DILocationMapper">
<!--查询位置列表-->
<select id="getLocationList" resultType="com.bonus.common.domain.data.vo.LocationVo">
SELECT
location_name AS locationName,
location_time AS locationTime
FROM tb_device_location
<where>
<if test="startTime != null">
AND location_time &gt;= #{startTime}
</if>
<if test="endTime != null">
AND location_time &lt;= #{endTime}
</if>
</where>
ORDER BY location_time DESC
</select>
</mapper>