更改历史轨迹记录数据源
parent
60c5e03819
commit
0845f082af
|
@ -0,0 +1,42 @@
|
||||||
|
package com.dragon.vehicle.history.common.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Wenkang Tang
|
||||||
|
* @date 2023/11/30 19:36
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName(value = "history_record")
|
||||||
|
public class HistoryRecord {
|
||||||
|
/**
|
||||||
|
* 历史轨迹ID
|
||||||
|
*/
|
||||||
|
private Integer recordId;
|
||||||
|
/**
|
||||||
|
* 车辆VIN
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
/**
|
||||||
|
* 车辆开始行驶时间
|
||||||
|
*/
|
||||||
|
private Date startTime;
|
||||||
|
/**
|
||||||
|
* 车辆结束行驶时间
|
||||||
|
*/
|
||||||
|
private Date endTime;
|
||||||
|
/**
|
||||||
|
* 是否删除记录 1-是 0-否
|
||||||
|
*/
|
||||||
|
private Integer isDelete;
|
||||||
|
}
|
|
@ -34,9 +34,10 @@ public class VehicleOperation {
|
||||||
*/
|
*/
|
||||||
private String vin;
|
private String vin;
|
||||||
/**
|
/**
|
||||||
* 行驶路线
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
private String drivingRoute;
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
/**
|
/**
|
||||||
* 经度
|
* 经度
|
||||||
*/
|
*/
|
||||||
|
@ -217,18 +218,4 @@ public class VehicleOperation {
|
||||||
* CHG(充电机)状态
|
* CHG(充电机)状态
|
||||||
*/
|
*/
|
||||||
private Integer chgStatus;
|
private Integer chgStatus;
|
||||||
/**
|
|
||||||
* 逻辑删除 0-否 1-是
|
|
||||||
*/
|
|
||||||
private Integer isDelete;
|
|
||||||
/**
|
|
||||||
* 开始时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date startTime;
|
|
||||||
/**
|
|
||||||
* 结束时间
|
|
||||||
*/
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
private Date endTime;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package com.dragon.vehicle.history.common.domain.req;
|
package com.dragon.vehicle.history.common.domain.req;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Wenkang Tang
|
* @author Wenkang Tang
|
||||||
* @date 2023/11/29 14:46
|
* @date 2023/11/29 14:46
|
||||||
|
@ -15,18 +18,18 @@ import lombok.NoArgsConstructor;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class HistoryReq {
|
public class HistoryReq {
|
||||||
/**
|
|
||||||
* 当前页数
|
|
||||||
*/
|
|
||||||
private Integer pageNum=1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 每页条数
|
|
||||||
*/
|
|
||||||
private Integer pageSize=10;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆VIN
|
* 车辆VIN
|
||||||
*/
|
*/
|
||||||
private String carVin;
|
private String carVin;
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date startTime;
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date endTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,13 @@
|
||||||
<version>1.2.4</version>
|
<version>1.2.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.kafka</groupId>
|
||||||
|
<artifactId>kafka-clients</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,7 @@ public class CarController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/listCar")
|
@PostMapping("/listCar")
|
||||||
public Result<PageResult<ResCar>> listCar(@RequestBody ReqCar reqCar) {
|
public Result<PageResult<ResCar>> listCar(@RequestBody ReqCar reqCar) {
|
||||||
Result<PageResult<ResCar>> result = carService.listCar(reqCar);
|
return carService.listCar(reqCar);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package com.dragon.vehicle.history.server.controller;
|
package com.dragon.vehicle.history.server.controller;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
import com.dragon.common.core.domain.Result;
|
import com.dragon.common.core.domain.Result;
|
||||||
|
import com.dragon.vehicle.history.common.domain.HistoryRecord;
|
||||||
import com.dragon.vehicle.history.common.domain.VehicleOperation;
|
import com.dragon.vehicle.history.common.domain.VehicleOperation;
|
||||||
import com.dragon.vehicle.history.common.domain.req.HistoryReq;
|
import com.dragon.vehicle.history.common.domain.req.HistoryReq;
|
||||||
import com.dragon.vehicle.history.server.service.HistoricalTrackService;
|
import com.dragon.vehicle.history.server.service.HistoricalTrackService;
|
||||||
import org.apache.poi.ss.formula.functions.T;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Wenkang Tang
|
* @author Wenkang Tang
|
||||||
|
@ -25,18 +27,29 @@ public class HistoricalTrackController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/listHistoricalTrack")
|
@PostMapping("/listHistoricalTrack")
|
||||||
public Result<List<VehicleOperation>> listHistoricalTrack(@RequestBody HistoryReq historyReq) {
|
@DS(value = "slave")
|
||||||
return Result.success(historicalTrackService.listHistoricalTrack(historyReq));
|
public Result<List<HistoryRecord>> listHistoricalTrack() {
|
||||||
|
return Result.success(historicalTrackService.listHistoricalTrack());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除历史轨迹
|
* 删除历史轨迹
|
||||||
* @param vin
|
* @param recordId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/delHistoricalTrack")
|
@PostMapping("/delHistoricalTrack")
|
||||||
public Result delHistoricalTrack(@RequestParam String vin){
|
public Result delHistoricalTrack(@RequestParam Integer recordId){
|
||||||
historicalTrackService.delHistoricalTrack(vin);
|
historicalTrackService.delHistoricalTrack(recordId);
|
||||||
return Result.success("删除成功!");
|
return Result.success("删除成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆的历史轨迹记录
|
||||||
|
* @param historyReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/CarRecord")
|
||||||
|
public Result<List<VehicleOperation>> CarRecord(@RequestParam HistoryReq historyReq){
|
||||||
|
return Result.success(historicalTrackService.CarRecord(historyReq));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.dragon.vehicle.history.server.mapper;
|
package com.dragon.vehicle.history.server.mapper;
|
||||||
|
|
||||||
|
import com.dragon.vehicle.history.common.domain.HistoryRecord;
|
||||||
import com.dragon.vehicle.history.common.domain.VehicleOperation;
|
import com.dragon.vehicle.history.common.domain.VehicleOperation;
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
@ -9,6 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
* @date 2023/11/19 19:55
|
* @date 2023/11/19 19:55
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface HistoricalTrackMapper extends MPJBaseMapper<VehicleOperation> {
|
public interface HistoricalTrackMapper extends MPJBaseMapper<HistoryRecord> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.dragon.vehicle.history.server.mapper;
|
||||||
|
|
||||||
|
import com.dragon.vehicle.history.common.domain.VehicleOperation;
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Wenkang Tang
|
||||||
|
* @date 2023/11/30 20:06
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public interface VehicleOperationMapper extends MPJBaseMapper<VehicleOperation> {
|
||||||
|
}
|
|
@ -1,9 +1,12 @@
|
||||||
package com.dragon.vehicle.history.server.service;
|
package com.dragon.vehicle.history.server.service;
|
||||||
|
|
||||||
|
import com.dragon.common.core.domain.Result;
|
||||||
|
import com.dragon.vehicle.history.common.domain.HistoryRecord;
|
||||||
import com.dragon.vehicle.history.common.domain.VehicleOperation;
|
import com.dragon.vehicle.history.common.domain.VehicleOperation;
|
||||||
import com.dragon.vehicle.history.common.domain.req.HistoryReq;
|
import com.dragon.vehicle.history.common.domain.req.HistoryReq;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Wenkang Tang
|
* @author Wenkang Tang
|
||||||
|
@ -14,11 +17,18 @@ public interface HistoricalTrackService {
|
||||||
* 历史轨迹列表
|
* 历史轨迹列表
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<VehicleOperation> listHistoricalTrack(HistoryReq historyReq);
|
List<HistoryRecord> listHistoricalTrack();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除历史轨迹
|
* 删除历史轨迹
|
||||||
* @param vin
|
* @param recordId
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
void delHistoricalTrack(String vin);
|
void delHistoricalTrack(Integer recordId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆的历史轨迹记录
|
||||||
|
* @param historyReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<VehicleOperation> CarRecord(HistoryReq historyReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Log4j2
|
@Log4j2
|
||||||
|
|
||||||
public class CarServiceImpl implements CarService {
|
public class CarServiceImpl implements CarService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CarMapper carMapper;
|
private CarMapper carMapper;
|
||||||
|
|
|
@ -1,16 +1,22 @@
|
||||||
package com.dragon.vehicle.history.server.service.impl;
|
package com.dragon.vehicle.history.server.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.dragon.common.core.domain.Result;
|
||||||
|
import com.dragon.vehicle.history.common.domain.HistoryRecord;
|
||||||
import com.dragon.vehicle.history.common.domain.VehicleOperation;
|
import com.dragon.vehicle.history.common.domain.VehicleOperation;
|
||||||
import com.dragon.vehicle.history.common.domain.req.HistoryReq;
|
import com.dragon.vehicle.history.common.domain.req.HistoryReq;
|
||||||
import com.dragon.vehicle.history.server.mapper.HistoricalTrackMapper;
|
import com.dragon.vehicle.history.server.mapper.HistoricalTrackMapper;
|
||||||
|
import com.dragon.vehicle.history.server.mapper.VehicleOperationMapper;
|
||||||
import com.dragon.vehicle.history.server.service.HistoricalTrackService;
|
import com.dragon.vehicle.history.server.service.HistoricalTrackService;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Wenkang Tang
|
* @author Wenkang Tang
|
||||||
|
@ -20,32 +26,42 @@ import java.util.List;
|
||||||
public class HistoricalTrackServiceImpl implements HistoricalTrackService {
|
public class HistoricalTrackServiceImpl implements HistoricalTrackService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private HistoricalTrackMapper historicalTrackMapper;
|
private HistoricalTrackMapper historicalTrackMapper;
|
||||||
|
@Autowired
|
||||||
|
private VehicleOperationMapper vehicleOperationMapper;
|
||||||
/**
|
/**
|
||||||
* 历史轨迹列表
|
* 历史轨迹列表
|
||||||
*
|
* @return
|
||||||
* @param historyReq 历史轨迹请求对象
|
|
||||||
* @return 历史轨迹列表
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<VehicleOperation> listHistoricalTrack(HistoryReq historyReq) {
|
public List<HistoryRecord> listHistoricalTrack() {
|
||||||
Page<VehicleOperation> page = new Page<>(historyReq.getPageNum(), historyReq.getPageSize());
|
return historicalTrackMapper.selectList(new MPJLambdaWrapper<HistoryRecord>().selectAll(HistoryRecord.class));
|
||||||
return historicalTrackMapper.selectJoinPage(page, VehicleOperation.class, new MPJLambdaWrapper<VehicleOperation>()
|
|
||||||
.selectAll(VehicleOperation.class)
|
|
||||||
.eq(historyReq.getCarVin() != null, VehicleOperation::getVin, historyReq.getCarVin()))
|
|
||||||
.getRecords();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除历史轨迹
|
* 删除历史轨迹
|
||||||
*
|
* @param recordId
|
||||||
* @param vin
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void delHistoricalTrack(String vin) {
|
public void delHistoricalTrack(Integer recordId) {
|
||||||
LambdaUpdateWrapper<VehicleOperation> updateWrapper = new LambdaUpdateWrapper<>();
|
LambdaUpdateWrapper<HistoryRecord> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
LambdaUpdateWrapper<VehicleOperation> wrapper = updateWrapper.eq(VehicleOperation::getVin, vin);
|
LambdaUpdateWrapper<HistoryRecord> wrapper = updateWrapper
|
||||||
historicalTrackMapper.delete(wrapper);
|
.eq(HistoryRecord::getRecordId, recordId);
|
||||||
|
historicalTrackMapper.deleteById(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆的历史轨迹记录
|
||||||
|
* @param historyReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<VehicleOperation> CarRecord(HistoryReq historyReq) {
|
||||||
|
LambdaQueryWrapper<VehicleOperation> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
LambdaQueryWrapper<VehicleOperation> wrapper = queryWrapper
|
||||||
|
.eq(VehicleOperation::getVin, historyReq.getCarVin())
|
||||||
|
.ge(VehicleOperation::getCreateTime, historyReq.getStartTime())
|
||||||
|
.le(VehicleOperation::getCreateTime, historyReq.getEndTime());
|
||||||
|
return vehicleOperationMapper.selectList(wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
Spring Boot Version: ${spring-boot.version}
|
|
||||||
Spring Application Name: ${spring.application.name}
|
Spring Application Name: ${spring.application.name}
|
||||||
|
|
Loading…
Reference in New Issue