diff --git a/pom.xml b/pom.xml index dbf3e17..1904b41 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,6 @@ 3.6.3 - com.dragon dragon-vehicle-history 3.6.3 pom diff --git a/vehicle-history-common/src/main/java/com/dragon/vehicle/history/common/domain/Car.java b/vehicle-history-common/src/main/java/com/dragon/vehicle/history/common/domain/Car.java index 0bad128..dfd1d91 100644 --- a/vehicle-history-common/src/main/java/com/dragon/vehicle/history/common/domain/Car.java +++ b/vehicle-history-common/src/main/java/com/dragon/vehicle/history/common/domain/Car.java @@ -8,6 +8,8 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; + /** * @author Wenkang Tang * @date 2023/11/20 19:26 diff --git a/vehicle-history-common/src/main/java/com/dragon/vehicle/history/common/domain/VehicleOperation.java b/vehicle-history-common/src/main/java/com/dragon/vehicle/history/common/domain/VehicleOperation.java index 5d2623a..c8150ad 100644 --- a/vehicle-history-common/src/main/java/com/dragon/vehicle/history/common/domain/VehicleOperation.java +++ b/vehicle-history-common/src/main/java/com/dragon/vehicle/history/common/domain/VehicleOperation.java @@ -216,15 +216,17 @@ public class VehicleOperation { */ private Integer chgStatus; /** - * 车辆状态 报文 + * 逻辑删除 0-否 1-是 */ - private String vehicleStatusMsg; + private Integer isDelete; /** - * 智能硬件 报文 + * 开始时间 */ - private String smartHardwareMsg; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date startTime; /** - * 电池报文 + * 结束时间 */ - private String batteryMsg; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date endTime; } diff --git a/vehicle-history-common/src/main/java/com/dragon/vehicle/history/common/domain/req/HistoryReq.java b/vehicle-history-common/src/main/java/com/dragon/vehicle/history/common/domain/req/HistoryReq.java new file mode 100644 index 0000000..f982ea3 --- /dev/null +++ b/vehicle-history-common/src/main/java/com/dragon/vehicle/history/common/domain/req/HistoryReq.java @@ -0,0 +1,32 @@ +package com.dragon.vehicle.history.common.domain.req; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Wenkang Tang + * @date 2023/11/29 14:46 + * @description + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class HistoryReq { + /** + * 当前页数 + */ + private Integer pageNum=1; + + /** + * 每页条数 + */ + private Integer pageSize=10; + + /** + * 车辆VIN + */ + private String carVin; +} diff --git a/vehicle-history-server/pom.xml b/vehicle-history-server/pom.xml index d253291..9db41e1 100644 --- a/vehicle-history-server/pom.xml +++ b/vehicle-history-server/pom.xml @@ -22,6 +22,7 @@ vehicle-history-common 3.6.3 + com.alibaba.cloud diff --git a/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/controller/HistoricalTrackController.java b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/controller/HistoricalTrackController.java index d8f4c8d..7c81785 100644 --- a/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/controller/HistoricalTrackController.java +++ b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/controller/HistoricalTrackController.java @@ -1,9 +1,12 @@ package com.dragon.vehicle.history.server.controller; +import com.dragon.common.core.domain.Result; +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.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -17,5 +20,23 @@ public class HistoricalTrackController { @Autowired private HistoricalTrackService historicalTrackService; + /** + * 历史轨迹列表 + * @return + */ + @PostMapping("/listHistoricalTrack") + public Result> listHistoricalTrack(@RequestBody HistoryReq historyReq) { + return Result.success(historicalTrackService.listHistoricalTrack(historyReq)); + } + /** + * 删除历史轨迹 + * @param vin + * @return + */ + @PostMapping("/delHistoricalTrack") + public Result delHistoricalTrack(@RequestParam String vin){ + historicalTrackService.delHistoricalTrack(vin); + return Result.success("删除成功!"); + } } diff --git a/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/controller/LatestTrackController.java b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/controller/LatestTrackController.java new file mode 100644 index 0000000..c60f5d4 --- /dev/null +++ b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/controller/LatestTrackController.java @@ -0,0 +1,33 @@ +package com.dragon.vehicle.history.server.controller; + +import com.dragon.common.core.domain.Result; +import com.dragon.vehicle.history.common.domain.VehicleOperation; +import com.dragon.vehicle.history.common.domain.req.ReqCar; +import com.dragon.vehicle.history.server.service.LatestTrackService; +import org.springframework.beans.factory.annotation.Autowired; +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; + +/** + * @author Wenkang Tang + * @date 2023/11/29 15:05 + * @description + */ +@RestController +@RequestMapping("/latest") +public class LatestTrackController { + @Autowired + private LatestTrackService latestTrackService; + + /** + * 实时轨迹 + * @return + */ + @GetMapping("/listLatestTrack") + public Result> listLatestTrack() { + return Result.success(latestTrackService.listLatestTrack()); + } +} diff --git a/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/mapper/LatestTrackMapper.java b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/mapper/LatestTrackMapper.java new file mode 100644 index 0000000..55c4661 --- /dev/null +++ b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/mapper/LatestTrackMapper.java @@ -0,0 +1,14 @@ +package com.dragon.vehicle.history.server.mapper; + +import com.dragon.vehicle.history.common.domain.VehicleOperation; +import com.github.yulichang.base.MPJBaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author Wenkang Tang + * @date 2023/11/29 15:07 + * @description + */ +@Mapper +public interface LatestTrackMapper extends MPJBaseMapper { +} diff --git a/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/HistoricalTrackService.java b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/HistoricalTrackService.java index 5680ca9..15baef1 100644 --- a/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/HistoricalTrackService.java +++ b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/HistoricalTrackService.java @@ -1,8 +1,24 @@ package com.dragon.vehicle.history.server.service; +import com.dragon.vehicle.history.common.domain.VehicleOperation; +import com.dragon.vehicle.history.common.domain.req.HistoryReq; + +import java.util.List; + /** * @author Wenkang Tang * @date 2023/11/19 19:55 */ public interface HistoricalTrackService { + /** + * 历史轨迹列表 + * @return + */ + List listHistoricalTrack(HistoryReq historyReq); + + /** + * 删除历史轨迹 + * @param vin + */ + void delHistoricalTrack(String vin); } diff --git a/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/LatestTrackService.java b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/LatestTrackService.java new file mode 100644 index 0000000..d0c9305 --- /dev/null +++ b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/LatestTrackService.java @@ -0,0 +1,18 @@ +package com.dragon.vehicle.history.server.service; + +import com.dragon.vehicle.history.common.domain.VehicleOperation; + +import java.util.List; + +/** + * @author Wenkang Tang + * @date 2023/11/29 15:06 + * @description + */ +public interface LatestTrackService { + /** + * 实时轨迹 + * @return + */ + List listLatestTrack(); +} diff --git a/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/impl/HistoricalTrackServiceImpl.java b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/impl/HistoricalTrackServiceImpl.java index cda4bc7..5e0e040 100644 --- a/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/impl/HistoricalTrackServiceImpl.java +++ b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/impl/HistoricalTrackServiceImpl.java @@ -1,10 +1,17 @@ package com.dragon.vehicle.history.server.service.impl; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +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.service.HistoricalTrackService; +import com.github.yulichang.wrapper.MPJLambdaWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** * @author Wenkang Tang * @date 2023/11/19 19:55 @@ -14,4 +21,31 @@ public class HistoricalTrackServiceImpl implements HistoricalTrackService { @Autowired private HistoricalTrackMapper historicalTrackMapper; + /** + * 历史轨迹列表 + * + * @param historyReq 历史轨迹请求对象 + * @return 历史轨迹列表 + */ + @Override + public List listHistoricalTrack(HistoryReq historyReq) { + Page page = new Page<>(historyReq.getPageNum(), historyReq.getPageSize()); + return historicalTrackMapper.selectJoinPage(page, VehicleOperation.class, new MPJLambdaWrapper() + .selectAll(VehicleOperation.class) + .eq(historyReq.getCarVin() != null, VehicleOperation::getVin, historyReq.getCarVin())) + .getRecords(); + } + + + /** + * 删除历史轨迹 + * + * @param vin + */ + @Override + public void delHistoricalTrack(String vin) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + LambdaUpdateWrapper wrapper = updateWrapper.eq(VehicleOperation::getVin, vin); + historicalTrackMapper.delete(wrapper); + } } diff --git a/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/impl/LatestTrackServiceImpl.java b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/impl/LatestTrackServiceImpl.java new file mode 100644 index 0000000..7803587 --- /dev/null +++ b/vehicle-history-server/src/main/java/com/dragon/vehicle/history/server/service/impl/LatestTrackServiceImpl.java @@ -0,0 +1,30 @@ +package com.dragon.vehicle.history.server.service.impl; + +import com.dragon.vehicle.history.common.domain.VehicleOperation; +import com.dragon.vehicle.history.server.mapper.LatestTrackMapper; +import com.dragon.vehicle.history.server.service.LatestTrackService; +import com.github.yulichang.wrapper.MPJLambdaWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author Wenkang Tang + * @date 2023/11/29 15:06 + * @description + */ +@Service +public class LatestTrackServiceImpl implements LatestTrackService { + @Autowired + private LatestTrackMapper latestTrackMapper; + + /** + * 实时轨迹 + * @return + */ + @Override + public List listLatestTrack() { + return latestTrackMapper.selectList(new MPJLambdaWrapper().selectAll(VehicleOperation.class)); + } +}