更改历史轨迹记录数据源
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 drivingRoute;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
|
@ -217,18 +218,4 @@ public class VehicleOperation {
|
|||
* CHG(充电机)状态
|
||||
*/
|
||||
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;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Wenkang Tang
|
||||
* @date 2023/11/29 14:46
|
||||
|
@ -15,18 +18,18 @@ import lombok.NoArgsConstructor;
|
|||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class HistoryReq {
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private Integer pageNum=1;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
private Integer pageSize=10;
|
||||
|
||||
/**
|
||||
* 车辆VIN
|
||||
*/
|
||||
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>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka-clients</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -30,9 +30,8 @@ public class CarController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("/listCar")
|
||||
public Result<PageResult<ResCar>> listCar(@RequestBody ReqCar reqCar){
|
||||
Result<PageResult<ResCar>> result = carService.listCar(reqCar);
|
||||
return result;
|
||||
public Result<PageResult<ResCar>> listCar(@RequestBody ReqCar reqCar) {
|
||||
return carService.listCar(reqCar);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,7 +39,7 @@ public class CarController {
|
|||
* @return
|
||||
*/
|
||||
@GetMapping("/listCarType")
|
||||
public Result<List<CarType>> listCarType(){
|
||||
public Result<List<CarType>> listCarType() {
|
||||
return carService.listCarType();
|
||||
}
|
||||
|
||||
|
@ -49,7 +48,7 @@ public class CarController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("/updateCar")
|
||||
public Result updateCar(@RequestBody Car car){
|
||||
public Result updateCar(@RequestBody Car car) {
|
||||
return carService.updateCar(car);
|
||||
}
|
||||
|
||||
|
@ -59,7 +58,7 @@ public class CarController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("/deleteCar")
|
||||
public Result deleteCar(@RequestParam String carVin){
|
||||
public Result deleteCar(@RequestParam String carVin) {
|
||||
return carService.deleteCar(carVin);
|
||||
}
|
||||
|
||||
|
@ -69,7 +68,7 @@ public class CarController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("/insertCar")
|
||||
public Result insertCar(@RequestBody Car car){
|
||||
public Result insertCar(@RequestBody Car car) {
|
||||
return carService.insertCar(car);
|
||||
}
|
||||
|
||||
|
@ -78,7 +77,7 @@ public class CarController {
|
|||
* @return
|
||||
*/
|
||||
@GetMapping("/listFence")
|
||||
public Result<List<Fence>> listFence(){
|
||||
public Result<List<Fence>> listFence() {
|
||||
return carService.listFence();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package com.dragon.vehicle.history.server.controller;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
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.req.HistoryReq;
|
||||
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.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Wenkang Tang
|
||||
|
@ -25,18 +27,29 @@ public class HistoricalTrackController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("/listHistoricalTrack")
|
||||
public Result<List<VehicleOperation>> listHistoricalTrack(@RequestBody HistoryReq historyReq) {
|
||||
return Result.success(historicalTrackService.listHistoricalTrack(historyReq));
|
||||
@DS(value = "slave")
|
||||
public Result<List<HistoryRecord>> listHistoricalTrack() {
|
||||
return Result.success(historicalTrackService.listHistoricalTrack());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除历史轨迹
|
||||
* @param vin
|
||||
* @param recordId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/delHistoricalTrack")
|
||||
public Result delHistoricalTrack(@RequestParam String vin){
|
||||
historicalTrackService.delHistoricalTrack(vin);
|
||||
public Result delHistoricalTrack(@RequestParam Integer recordId){
|
||||
historicalTrackService.delHistoricalTrack(recordId);
|
||||
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;
|
||||
|
||||
import com.dragon.vehicle.history.common.domain.HistoryRecord;
|
||||
import com.dragon.vehicle.history.common.domain.VehicleOperation;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
@ -9,6 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
* @date 2023/11/19 19:55
|
||||
*/
|
||||
@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;
|
||||
|
||||
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.req.HistoryReq;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Wenkang Tang
|
||||
|
@ -14,11 +17,18 @@ public interface HistoricalTrackService {
|
|||
* 历史轨迹列表
|
||||
* @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
|
||||
@Log4j2
|
||||
|
||||
public class CarServiceImpl implements CarService {
|
||||
@Autowired
|
||||
private CarMapper carMapper;
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
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.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.req.HistoryReq;
|
||||
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.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Wenkang Tang
|
||||
|
@ -20,32 +26,42 @@ import java.util.List;
|
|||
public class HistoricalTrackServiceImpl implements HistoricalTrackService {
|
||||
@Autowired
|
||||
private HistoricalTrackMapper historicalTrackMapper;
|
||||
|
||||
@Autowired
|
||||
private VehicleOperationMapper vehicleOperationMapper;
|
||||
/**
|
||||
* 历史轨迹列表
|
||||
*
|
||||
* @param historyReq 历史轨迹请求对象
|
||||
* @return 历史轨迹列表
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<VehicleOperation> listHistoricalTrack(HistoryReq historyReq) {
|
||||
Page<VehicleOperation> page = new Page<>(historyReq.getPageNum(), historyReq.getPageSize());
|
||||
return historicalTrackMapper.selectJoinPage(page, VehicleOperation.class, new MPJLambdaWrapper<VehicleOperation>()
|
||||
.selectAll(VehicleOperation.class)
|
||||
.eq(historyReq.getCarVin() != null, VehicleOperation::getVin, historyReq.getCarVin()))
|
||||
.getRecords();
|
||||
public List<HistoryRecord> listHistoricalTrack() {
|
||||
return historicalTrackMapper.selectList(new MPJLambdaWrapper<HistoryRecord>().selectAll(HistoryRecord.class));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除历史轨迹
|
||||
*
|
||||
* @param vin
|
||||
* @param recordId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void delHistoricalTrack(String vin) {
|
||||
LambdaUpdateWrapper<VehicleOperation> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
LambdaUpdateWrapper<VehicleOperation> wrapper = updateWrapper.eq(VehicleOperation::getVin, vin);
|
||||
historicalTrackMapper.delete(wrapper);
|
||||
public void delHistoricalTrack(Integer recordId) {
|
||||
LambdaUpdateWrapper<HistoryRecord> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
LambdaUpdateWrapper<HistoryRecord> wrapper = updateWrapper
|
||||
.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}
|
||||
|
|
Loading…
Reference in New Issue