Merge remote-tracking branch 'origin/master'
commit
4ccc21132c
|
@ -1,8 +0,0 @@
|
|||
package com.zhilian.business.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MarkersVo {
|
||||
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package com.zhilian.business.remote;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public interface RemoteFenceService {
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package com.zhilian.business.remote.factory;
|
||||
|
||||
import com.zhilian.common.core.constant.ServiceNameConstants;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
//@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
|
||||
public class RemoteFenceFallbackFactory {
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.zhilian.business.domain;
|
||||
package com.zhilian.common.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
|
@ -13,7 +13,12 @@ import lombok.NoArgsConstructor;
|
|||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName Fence
|
||||
* @Description 电子围栏实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:28 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
|
@ -1,4 +1,4 @@
|
|||
package com.zhilian.business.domain;
|
||||
package com.zhilian.common.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
|
@ -10,7 +10,12 @@ import lombok.*;
|
|||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName Markers
|
||||
* @Description 车辆标识实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:29 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@SuperBuilder
|
||||
|
@ -20,12 +25,16 @@ import java.util.List;
|
|||
@TableName("business_markers")
|
||||
public class Markers extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 车辆标识编号
|
||||
*/
|
||||
@TableId(value = "markers_id", type = IdType.AUTO)
|
||||
@Excel(name = "标识编号")
|
||||
private Long markersId;
|
||||
|
||||
/**
|
||||
* 车辆标识名称
|
||||
*/
|
||||
@TableField("markers_name")
|
||||
@Excel(name = "标识名称")
|
||||
private String markersName;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.zhilian.business.domain;
|
||||
package com.zhilian.common.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
|
@ -12,7 +12,10 @@ import lombok.experimental.SuperBuilder;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆信息对象 business_vehicle
|
||||
* @ClassName Vehicle
|
||||
* @Description 车辆信息实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:27 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
|
@ -1,4 +1,4 @@
|
|||
package com.zhilian.business.domain;
|
||||
package com.zhilian.common.business.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
|
@ -10,7 +10,12 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @ClassName VehicleType
|
||||
* @Description 车辆类型实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:30 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
|
@ -1,9 +1,14 @@
|
|||
package com.zhilian.business.domain.middle;
|
||||
package com.zhilian.common.business.domain.middle;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* @ClassName MarkersFence
|
||||
* @Description 车辆标识与电子围栏中间表
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:30 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@TableName("business_markers_fence")
|
||||
|
@ -13,6 +18,9 @@ public class MarkersFence {
|
|||
*/
|
||||
@TableId(value = "markers_id",type = IdType.INPUT)
|
||||
private Long markerId;
|
||||
/**
|
||||
* 电子围栏编号
|
||||
*/
|
||||
@TableField(value = "fence_id",insertStrategy = FieldStrategy.IGNORED)
|
||||
private Long fenceId;
|
||||
|
|
@ -1,9 +1,14 @@
|
|||
package com.zhilian.business.domain.middle;
|
||||
package com.zhilian.common.business.domain.middle;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* @ClassName VehicleMarkers
|
||||
* @Description 车辆管理与车辆标识 中间表
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:27 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@TableName("business_vehicle_markers")
|
|
@ -1,14 +1,14 @@
|
|||
package com.zhilian.business.domain.vo;
|
||||
package com.zhilian.common.business.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* @ClassName FenceResp //类名称
|
||||
* @Author: yannan //作者
|
||||
* @CreateDate: 2024/3/26 20:03 //创建时间
|
||||
* @ClassName FenceVo
|
||||
* @Description 电子围栏查询信息实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:27 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
|
@ -1,9 +1,12 @@
|
|||
package com.zhilian.business.domain.vo;
|
||||
package com.zhilian.common.business.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.zhilian.common.core.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName VehicleVo
|
||||
* @Description 车辆管理查询信息实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:28 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
public class VehicleVo {
|
||||
/**
|
|
@ -0,0 +1,32 @@
|
|||
package com.zhilian.common.business.remote;
|
||||
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.remote.factory.RemoteVehicleFallbackFactory;
|
||||
import com.zhilian.common.core.constant.ServiceNameConstants;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(contextId = "remoteVehicleService", value = ServiceNameConstants.VIEHICLE_SERVICE, fallbackFactory = RemoteVehicleFallbackFactory.class)
|
||||
public interface RemoteVehicleService {
|
||||
// @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
// public Result<SysFile> upload (@RequestPart(value = "file") MultipartFile file);
|
||||
|
||||
/**
|
||||
* 根据VIN获取车辆信息
|
||||
* @param vehicleVIN
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/vehicle/getMarkersByVIN/{vehicleVIN}")
|
||||
public Result<Vehicle> getVehicleByVIN(@PathVariable("vehicleVIN") String vehicleVIN);
|
||||
|
||||
/**
|
||||
* 更新车辆状态
|
||||
* @param vehicle
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/vehicle/updateState")
|
||||
public Result updateState(@RequestBody Vehicle vehicle);
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.zhilian.common.business.remote.factory;
|
||||
|
||||
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.remote.RemoteVehicleService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class RemoteVehicleFallbackFactory implements FallbackFactory<RemoteVehicleService> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RemoteVehicleFallbackFactory.class);
|
||||
@Override
|
||||
public RemoteVehicleService create(Throwable throwable) {
|
||||
log.error("用户服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteVehicleService() {
|
||||
@Override
|
||||
public Result<Vehicle> getVehicleByVIN(String vehicleVIN) {
|
||||
return Result.error("获取车辆信息失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateState(Vehicle vehicle) {
|
||||
return Result.error("更新车辆状态失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.zhilian.common.business.remote.factory.RemoteVehicleFallbackFactory
|
|
@ -20,4 +20,8 @@ public class ServiceNameConstants {
|
|||
* 文件服务的serviceid
|
||||
*/
|
||||
public static final String FILE_SERVICE = "zhilian-file";
|
||||
/**
|
||||
* 车辆服务的serviceid
|
||||
*/
|
||||
public static final String VIEHICLE_SERVICE = "zhilian-vehicle";
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.business
|
||||
* @Description 启动类
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-03-31 10:13
|
||||
* @Description: TODO
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.zhilian.business.controller;
|
|||
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.core.web.controller.BaseController;
|
||||
import com.zhilian.business.domain.Fence;
|
||||
import com.zhilian.common.business.domain.Fence;
|
||||
import com.zhilian.business.service.FenceService;
|
||||
import com.zhilian.common.core.web.page.TableDataInfo;
|
||||
import com.zhilian.common.security.utils.SecurityUtils;
|
||||
|
@ -25,7 +25,9 @@ public class FenceController extends BaseController {
|
|||
private FenceService fenceService;
|
||||
|
||||
/**
|
||||
* TODO: 围栏管理
|
||||
* 电子围栏列表
|
||||
* @param fence
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public Result<TableDataInfo<Fence>> fenceList(@RequestBody Fence fence) {
|
||||
|
@ -48,7 +50,9 @@ public class FenceController extends BaseController {
|
|||
|
||||
|
||||
/**
|
||||
* 修改电子围栏
|
||||
* 修改围栏信息
|
||||
* @param fence
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/fenceUpdate")
|
||||
public Result fenceUpdate(@RequestBody Fence fence) {
|
||||
|
@ -57,6 +61,11 @@ public class FenceController extends BaseController {
|
|||
return toAjax(fenceService.updateById(fence));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改电子围栏地图
|
||||
* @param fence
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/fenceUpdateMap")
|
||||
public Result fenceUpdateMap(@RequestBody Fence fence) {
|
||||
fence.setUpdateBy(SecurityUtils.getUsername());
|
||||
|
|
|
@ -1,18 +1,25 @@
|
|||
package com.zhilian.business.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhilian.business.domain.Markers;
|
||||
import com.zhilian.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
import com.zhilian.common.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.service.MarkersFenceService;
|
||||
import com.zhilian.business.service.MarkersService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.core.web.controller.BaseController;
|
||||
import com.zhilian.common.core.web.page.TableDataInfo;
|
||||
import com.zhilian.common.security.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName MarkersController
|
||||
* @Description 车辆标识控制层
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:31 2024/4/8
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/markers")
|
||||
public class MarkersController extends BaseController {
|
||||
|
@ -33,22 +40,51 @@ public class MarkersController extends BaseController {
|
|||
return getDataTable(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆标识全部数据
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("markersVehicle")
|
||||
public Result<List<Markers>> markersVehicle() {
|
||||
List<Markers> listMarkers = markersService.listMarkers();
|
||||
return Result.success(listMarkers);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增车辆标识
|
||||
* @param markers
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("insert")
|
||||
public Result insert(@RequestBody Markers markers){
|
||||
return toAjax(markersService.save(markers));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改车辆标识
|
||||
* @param markers
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("update")
|
||||
public Result update(@RequestBody Markers markers) {
|
||||
return toAjax(markersService.updateById(markers));
|
||||
markers.setUpdateBy(SecurityUtils.getUsername());
|
||||
markers.setUpdateTime(new Date());
|
||||
markersFenceService.removeAllFence(markers);
|
||||
|
||||
//修改原表数据
|
||||
boolean update =markersService.updateById(markers);
|
||||
|
||||
//重新添加中间表数据
|
||||
markersFenceService.insert(markers);
|
||||
|
||||
return toAjax(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除车辆标识
|
||||
* @param markersId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("delete/{markersId}")
|
||||
public Result delete(@PathVariable Long markersId) {
|
||||
markersFenceList(markersId).forEach(markersFence -> {
|
||||
|
@ -57,11 +93,22 @@ public class MarkersController extends BaseController {
|
|||
return toAjax(markersService.removeById(markersId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定电子围栏
|
||||
* @param markers
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("insertMarkersFence")
|
||||
public Result insertMarkersFenceMarkers(@RequestBody MarkersFence markersFence){
|
||||
return toAjax(markersFenceService.save(markersFence));
|
||||
public Result insertMarkersFenceMarkers(@RequestBody Markers markers){
|
||||
boolean insert = markersFenceService.insert(markers);
|
||||
return toAjax(insert);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询标识与电子围栏中间表信息
|
||||
* @param markersId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("markersFenceList/{markersId}")
|
||||
public List<MarkersFence> markersFenceList(@PathVariable Long markersId){
|
||||
LambdaQueryWrapper<MarkersFence> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.zhilian.business.controller;
|
||||
|
||||
import com.zhilian.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.common.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.service.MarkersFenceService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.core.web.controller.BaseController;
|
||||
|
@ -10,7 +10,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName MarkersFenceController
|
||||
* @Description 标识与围栏中间表控制层
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:31 2024/4/8
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/markersFence")
|
||||
public class MarkersFenceController extends BaseController {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package com.zhilian.business.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhilian.business.domain.Markers;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.business.service.MarkersService;
|
||||
import com.zhilian.business.service.VehicleMarkersService;
|
||||
import com.zhilian.business.service.VehicleService;
|
||||
import com.zhilian.business.service.VehicleTypeService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.core.web.controller.BaseController;
|
||||
import com.zhilian.common.core.web.page.TableDataInfo;
|
||||
|
@ -26,6 +26,9 @@ public class VehicleController extends BaseController {
|
|||
@Autowired
|
||||
private VehicleMarkersService vehicleMarkersService;
|
||||
|
||||
@Autowired
|
||||
private VehicleTypeService vehicleTypeService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private MarkersService markersService;
|
||||
|
@ -87,17 +90,6 @@ public class VehicleController extends BaseController {
|
|||
queryWrapper.eq(VehicleMarkers::getVehicleId, vehicleId);
|
||||
return vehicleMarkersService.list(queryWrapper);
|
||||
}
|
||||
|
||||
// @PostMapping("/getMarkers/{vehicleId}")
|
||||
// public List<Markers> getMarkers(@PathVariable Long vehicleId){
|
||||
// LambdaQueryWrapper<VehicleMarkers> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.eq(VehicleMarkers::getVehicleId, vehicleId);
|
||||
// List<VehicleMarkers> list = vehicleMarkersService.list(queryWrapper);
|
||||
// list.forEach(vehicleMarkers -> {
|
||||
// Markers markers = markersService.getById(vehicleMarkers.getMarkersId());
|
||||
// });
|
||||
// return null;
|
||||
// }
|
||||
/**
|
||||
* 删除车辆
|
||||
* @param vehicleId
|
||||
|
@ -121,4 +113,26 @@ public class VehicleController extends BaseController {
|
|||
boolean insert = vehicleMarkersService.insert(vehicle);
|
||||
return toAjax(insert);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据VIN查询车辆信息
|
||||
* @param vehicleVIN
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getMarkersByVIN/{vehicleVIN}")
|
||||
public Result<Vehicle> getVehicleByVIN(@PathVariable("vehicleVIN") String vehicleVIN) {
|
||||
Vehicle vehicle = vehicleService.getVehicleByVIN(vehicleVIN);
|
||||
// vehicleMarkersService.getById(vehicle.getVehicleId());
|
||||
return Result.success(vehicle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据车辆VIN修改车辆状态
|
||||
* @param vehicle
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/updateState")
|
||||
public Result updateState(@RequestBody Vehicle vehicle) {
|
||||
return toAjax(vehicleService.updateState(vehicle));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.zhilian.business.controller;
|
||||
|
||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.common.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.business.service.VehicleMarkersService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.core.web.controller.BaseController;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.zhilian.business.controller;
|
||||
|
||||
import com.zhilian.business.domain.VehicleType;
|
||||
import com.zhilian.common.business.domain.VehicleType;
|
||||
import com.zhilian.business.service.VehicleTypeService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.core.web.controller.BaseController;
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.business.domain.Fence;
|
||||
import com.zhilian.business.domain.vo.FenceVo;
|
||||
import com.zhilian.common.business.domain.Fence;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface FenceMapper extends BaseMapper<Fence> {
|
||||
List<Fence> fenceList(FenceVo fenceVo);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.common.business.domain.middle.MarkersFence;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.business.domain.Markers;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.common.business.domain.middle.VehicleMarkers;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.business.domain.VehicleType;
|
||||
import com.zhilian.common.business.domain.VehicleType;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.business.domain.Fence;
|
||||
import com.zhilian.common.business.domain.Fence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
import com.zhilian.common.business.domain.middle.MarkersFence;
|
||||
|
||||
public interface MarkersFenceService extends IService<MarkersFence> {
|
||||
// List<MarkersFence> selectFenceByIdAndMarkersBuyId(List<MarkersFence> list, List<Fence> list1, List<Markers> list2,MarkersFence markersFence);
|
||||
boolean insert(Markers markers);
|
||||
|
||||
void removeAllFence(Markers markers);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.business.domain.Markers;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.domain.middle.VehicleMarkers;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -9,4 +9,7 @@ public interface VehicleService extends IService<Vehicle> {
|
|||
|
||||
List<Vehicle> selectVehicleList(Vehicle vehicle);
|
||||
|
||||
Vehicle getVehicleByVIN(String vehicleVIN);
|
||||
|
||||
boolean updateState(Vehicle vehicle);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.business.domain.VehicleType;
|
||||
import com.zhilian.common.business.domain.VehicleType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.zhilian.business.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.business.domain.Fence;
|
||||
import com.zhilian.common.business.domain.Fence;
|
||||
import com.zhilian.business.mapper.FenceMapper;
|
||||
import com.zhilian.business.service.FenceService;
|
||||
import com.zhilian.common.core.utils.StringUtils;
|
||||
|
|
|
@ -1,16 +1,38 @@
|
|||
package com.zhilian.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
import com.zhilian.common.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.mapper.MarkersFenceMapper;
|
||||
import com.zhilian.business.service.MarkersFenceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class MarkersFenceServiceImpl extends ServiceImpl<MarkersFenceMapper, MarkersFence> implements MarkersFenceService {
|
||||
@Autowired
|
||||
private MarkersFenceMapper markersFenceMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean insert(Markers markers) {
|
||||
markers.getFenceIds().forEach(fenceId -> {
|
||||
MarkersFence markersFence = new MarkersFence();
|
||||
markersFence.setMarkerId(markers.getMarkersId());
|
||||
markersFence.setFenceId(fenceId);
|
||||
markersFenceMapper.insert(markersFence);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllFence(Markers markers) {
|
||||
List<MarkersFence> list = this.list(new LambdaQueryWrapper<MarkersFence>().eq(MarkersFence::getMarkerId, markers.getMarkersId()));
|
||||
list.forEach(item -> {
|
||||
this.removeById(item.getMarkerId());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.zhilian.business.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.business.domain.Markers;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
import com.zhilian.business.mapper.MarkersMapper;
|
||||
import com.zhilian.business.service.MarkersService;
|
||||
import com.zhilian.common.core.utils.StringUtils;
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.zhilian.business.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.business.mapper.VehicleMarkersMapper;
|
||||
import com.zhilian.business.service.VehicleMarkersService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
|
@ -2,21 +2,19 @@ package com.zhilian.business.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.business.mapper.VehicleMapper;
|
||||
import com.zhilian.business.mapper.VehicleMarkersMapper;
|
||||
import com.zhilian.business.service.VehicleService;
|
||||
import com.zhilian.common.core.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> implements VehicleService {
|
||||
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
|
||||
@Override
|
||||
public List<Vehicle> selectVehicleList(Vehicle vehicle) {
|
||||
|
@ -60,4 +58,20 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vehicle getVehicleByVIN(String vehicleVIN) {
|
||||
LambdaQueryWrapper<Vehicle> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Vehicle::getVehicleVIN, vehicleVIN);
|
||||
return vehicleMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateState(Vehicle vehicle) {
|
||||
int update = vehicleMapper.update(vehicle, new LambdaQueryWrapper<Vehicle>().eq(Vehicle::getVehicleVIN, vehicle.getVehicleVIN()));
|
||||
if(update==0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.business.domain.VehicleType;
|
||||
import com.zhilian.common.business.domain.VehicleType;
|
||||
import com.zhilian.business.mapper.VehicleTypeMapper;
|
||||
import com.zhilian.business.service.VehicleTypeService;
|
||||
import com.zhilian.common.redis.service.RedisService;
|
||||
|
|
|
@ -98,6 +98,12 @@
|
|||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zhilian</groupId>
|
||||
<artifactId>zhilian-common-business</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -14,9 +14,12 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
|
@ -74,7 +77,7 @@ public class MqttxConfig {
|
|||
/**
|
||||
* kafka订阅topic
|
||||
*/
|
||||
private String topicName = "test-topic";
|
||||
private String topicName = "vehicle-topic";
|
||||
|
||||
/**
|
||||
* kafka服务
|
||||
|
@ -85,35 +88,15 @@ public class MqttxConfig {
|
|||
/**
|
||||
* 线程池
|
||||
*/
|
||||
private ExecutorService executorService = Executors.newFixedThreadPool(3);
|
||||
private ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
|
||||
/**
|
||||
* kafka服务
|
||||
*/
|
||||
private KafkaProducer<String, String> kafkaProducer;
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @Description: 初始化kafka服务
|
||||
*/
|
||||
@PostConstruct
|
||||
public KafkaProducer<Object, Object> initKafkaProducer() {
|
||||
Properties properties = new Properties();
|
||||
properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrap_servers);
|
||||
properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
|
||||
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
|
||||
|
||||
return new KafkaProducer<>(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
* @Description: 发送消息
|
||||
*/
|
||||
private void sendMsg(String msg) {
|
||||
kafkaProducer.send(new ProducerRecord<>(topicName, msg));
|
||||
log.info("Kafka在topic:{}中发送消息{}", topicName, msg);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void initMqtt() {
|
||||
|
@ -128,7 +111,7 @@ public class MqttxConfig {
|
|||
mqttConnectOptions.setPassword(password.toCharArray());
|
||||
|
||||
//链接超时
|
||||
mqttConnectOptions.setConnectionTimeout(60);
|
||||
mqttConnectOptions.setConnectionTimeout(10);
|
||||
//心跳检测
|
||||
mqttConnectOptions.setKeepAliveInterval(60);
|
||||
mqttClient.connect(mqttConnectOptions);
|
||||
|
@ -143,10 +126,10 @@ public class MqttxConfig {
|
|||
while (mqttClient.isConnected()) {
|
||||
try {
|
||||
//每次重连间隔60秒
|
||||
Thread.sleep(1000 * 60);
|
||||
Thread.sleep(1000 * 5);
|
||||
mqttClient.connect();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
log.error("重连失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -157,21 +140,9 @@ public class MqttxConfig {
|
|||
|
||||
//将接受到的车辆报文存储到kafka中
|
||||
executorService.execute(() -> {
|
||||
//解析得出原始报文String
|
||||
String sourceMsg = new String(mqttMessage.getPayload());
|
||||
//对原始报文进行解析
|
||||
String parseMsg = MessageResolver.parseMsg(sourceMsg);
|
||||
|
||||
//截取原始报文获得车辆VIN码
|
||||
String vin = parseMsg.substring(0, 17);
|
||||
|
||||
log.info("当前车辆VIN码:{}",vin);
|
||||
|
||||
//调取接口,查询是否是我们的车
|
||||
|
||||
|
||||
|
||||
executorTask(mqttMessage);
|
||||
});
|
||||
// executorTask(mqttMessage);
|
||||
|
||||
}
|
||||
|
||||
|
@ -191,4 +162,65 @@ public class MqttxConfig {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void executorTask(MqttMessage mqttMessage){
|
||||
//解析得出原始报文String
|
||||
String sourceMsg = new String(mqttMessage.getPayload());
|
||||
//对原始报文进行解析
|
||||
String parseMsg = MessageResolver.parseMsg(sourceMsg);
|
||||
|
||||
//截取原始报文获得车辆VIN码
|
||||
String vin = parseMsg.substring(0, 17);
|
||||
|
||||
log.info("当前车辆VIN码:{}",vin);
|
||||
|
||||
|
||||
//查询该vin码是否为我们的车
|
||||
List<Object> cacheList = redisService.getCacheList("our-car");
|
||||
List<String> carList = cacheList.stream().map(item -> {
|
||||
return String.valueOf(item);
|
||||
}).collect(Collectors.toList());
|
||||
if (carList.contains(vin)){
|
||||
//将车辆vin码存入redis中,用于判断车辆是否处于上线状态
|
||||
redisService.setCacheObject("online-vehicle",vin,60L, TimeUnit.SECONDS);
|
||||
|
||||
//发送rabbitMQ信息修改车辆上线状态
|
||||
|
||||
String string = mqttMessage.toString();
|
||||
//将车辆报文发送到kafka
|
||||
sendMsg(new String(mqttMessage.getPayload()));
|
||||
|
||||
|
||||
}else {
|
||||
//不是我们的车
|
||||
log.info("车辆{}不是我们的车",vin);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @Description: 初始化kafka服务
|
||||
*/
|
||||
@PostConstruct
|
||||
public KafkaProducer<Object, Object> initKafkaProducer() {
|
||||
Properties properties = new Properties();
|
||||
properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrap_servers);
|
||||
properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
|
||||
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
|
||||
this.kafkaProducer = new KafkaProducer<>(properties);
|
||||
return new KafkaProducer<>(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
* @Description: 发送消息
|
||||
*/
|
||||
private void sendMsg(String msg) {
|
||||
kafkaProducer.send(new ProducerRecord<>(topicName, msg));
|
||||
log.info("Kafka在topic:{}中发送消息{}", topicName, msg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue