upd commit
parent
4a6124d181
commit
2f2547e2b8
|
@ -22,6 +22,14 @@ import lombok.experimental.SuperBuilder;
|
|||
@NoArgsConstructor
|
||||
@TableName("couplet_vehicle")
|
||||
public class Vehicle {
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description 中间表id
|
||||
* @date
|
||||
*/
|
||||
private Long middleId;
|
||||
/*
|
||||
*车辆id
|
||||
* */
|
||||
|
|
|
@ -6,6 +6,8 @@ import lombok.NoArgsConstructor;
|
|||
import lombok.ToString;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
|
@ -23,4 +25,5 @@ public class VehicleMiddle{
|
|||
private Long userId;
|
||||
private Long vehicleId;
|
||||
private Long delFlag;
|
||||
private List<Long> vehicleIds;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
|
@ -15,7 +17,7 @@ import lombok.ToString;
|
|||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class RealTimeDataRequest {
|
||||
public class RealTimeDataRequest implements Serializable {
|
||||
|
||||
|
||||
private Long userId;
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
import java.util.List;
|
||||
|
||||
@FeignClient(contextId = "remoteVehicleService" ,
|
||||
value = ServiceNameConstants.VEHICLE_SERVICE,
|
||||
value = ServiceNameConstants.BUSINESS_SERVICE,
|
||||
fallbackFactory = RemoteVehicleFallbackFactory.class,
|
||||
path = "/vehicle"
|
||||
)
|
||||
|
|
|
@ -30,4 +30,5 @@ public class ServiceNameConstants {
|
|||
* @date
|
||||
*/
|
||||
public static final String BUSINESS_SERVICE = "couplet-business";
|
||||
public static final String VEHICLE_SERVICE = "vehicle-service";
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package com.couplet.common.core.exception.analyze;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/4
|
||||
* @Description: 解析系统统一异常
|
||||
*/
|
||||
public class AnalyzeException extends RuntimeException{
|
||||
|
||||
private int code;
|
||||
private String message;
|
||||
|
||||
public AnalyzeException(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public AnalyzeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public AnalyzeException() {
|
||||
|
||||
}
|
||||
}
|
|
@ -81,6 +81,11 @@
|
|||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<!-- RabbitMQ依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -3,8 +3,14 @@ package com.couplet.business.server.controller;
|
|||
import com.couplet.business.server.service.OnLineVehicleService;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitTemplateConfigurer;
|
||||
import org.springframework.data.redis.core.ReactiveRedisOperations;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
@ -22,7 +28,8 @@ public class OnLineVehicleController {
|
|||
|
||||
@Autowired
|
||||
private OnLineVehicleService onLineVehicleService;
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
@PostMapping("onlineList")
|
||||
public Result<List<Vehicle>> onlineList(){
|
||||
List<Vehicle> onlineList = onLineVehicleService.onlineList();
|
||||
|
@ -30,8 +37,14 @@ public class OnLineVehicleController {
|
|||
return success;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/monitorinData")
|
||||
public void monitorinData(@RequestBody RealTimeDataRequest realTimeDataRequest){
|
||||
String exchangeName = "exchangeName"; // 交换机名称
|
||||
String routingKey = "routingKey"; // 路由键
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
realTimeDataRequest.setUserId(userId);
|
||||
rabbitTemplate.convertAndSend(exchangeName, routingKey, realTimeDataRequest);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.couplet.business.server.service.VehicleService;
|
|||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.web.controller.BaseController;
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import com.couplet.common.domain.VehicleMiddle;
|
||||
import com.couplet.common.domain.request.VehicleEditParams;
|
||||
import com.couplet.common.domain.request.VehicleInsertParams;
|
||||
import com.couplet.common.domain.request.VehicleListParams;
|
||||
|
@ -133,4 +134,48 @@ public class VehicleController extends BaseController {
|
|||
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("UserUnderTheVehicle/{userId}")
|
||||
public Result<List<Vehicle>> UserUnderTheVehicleList(@PathVariable(value = "userId") Long userId){
|
||||
return Result.success(vehicleService.UserUnderTheVehicleList(userId));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param middleId:
|
||||
* @return Result<Integer>
|
||||
* @author 付凡芮
|
||||
* @description 删除员工管理的车辆
|
||||
* @date
|
||||
*/
|
||||
@DeleteMapping("/{middleId}")
|
||||
public Result<Integer> deleteVehicle(@PathVariable(value = "middleId") Long middleId){
|
||||
return Result.success(vehicleService.deleteVehicle(middleId));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
public Result<Integer> addVehicle(@RequestBody VehicleMiddle vehicleMiddle){
|
||||
return Result.success(vehicleService.addVehicle(vehicleMiddle));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("vehicleAll")
|
||||
public Result<List<Vehicle>> VehicleManageList(){
|
||||
|
||||
return Result.success(vehicleService.vehicleAll());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@ package com.couplet.business.server.controller;
|
|||
import com.couplet.business.server.service.VehicleDetectionService;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -25,7 +25,8 @@ public class VehicleDetectionController {
|
|||
|
||||
@Autowired
|
||||
private VehicleDetectionService vehicleDetectionService;
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
/*
|
||||
* @param :
|
||||
* @return Result<List<Vehicle>>
|
||||
|
@ -46,8 +47,15 @@ public class VehicleDetectionController {
|
|||
* @description 根据vin查询车辆信息
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("/findByVin/{vehicleId}")
|
||||
public Result<List<Vehicle>> findByVin(@PathVariable("vehicleId") Integer vehicleId) {
|
||||
return Result.success(vehicleDetectionService.findByVin(vehicleId));
|
||||
@PostMapping("/monitorinData/{vin}")
|
||||
public void monitorinData(@PathVariable String vin){
|
||||
String exchangeName = "exchangeName"; // 交换机名称
|
||||
String routingKey = "routingKey"; // 路由键
|
||||
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
realTimeDataRequest.setUserId(userId);
|
||||
realTimeDataRequest.setVin(vin);
|
||||
rabbitTemplate.convertAndSend(exchangeName, routingKey, realTimeDataRequest);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import com.couplet.common.domain.Vehicle;
|
||||
import com.couplet.common.domain.VehicleMiddle;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -21,7 +22,10 @@ public interface VehicleMapper extends BaseMapper<Vehicle> {
|
|||
|
||||
Integer deleteVehicle(Long middleId);
|
||||
|
||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
||||
|
||||
|
||||
List<Vehicle> vehicleAll();
|
||||
|
||||
Integer addVehicle(@Param("userId") Long userId, @Param("vehicleIds") List<Long> vehicleIds);
|
||||
|
||||
}
|
||||
|
|
|
@ -61,8 +61,6 @@ public class VehicleManageServiceImpl implements VehicleManageService {
|
|||
*/
|
||||
@Override
|
||||
public Result addVehicle(VehicleMiddle middle) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
middle.setUserId(userId);
|
||||
Result<Integer> integerResult = remoteVehicleService.addVehicle(middle);
|
||||
Integer resultData = integerResult.getData();
|
||||
return resultData==1?Result.success():Result.error("添加失败");
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.couplet.common.domain.VehicleType;
|
|||
import com.couplet.common.domain.request.VehicleEditParams;
|
||||
import com.couplet.common.domain.request.VehicleInsertParams;
|
||||
import com.couplet.common.domain.request.VehicleListParams;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -273,8 +274,8 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
|
||||
@Override
|
||||
public Integer addVehicle(VehicleMiddle vehicleMiddle) {
|
||||
|
||||
return vehicleMapper.addVehicle(vehicleMiddle);
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return vehicleMapper.addVehicle(userId,vehicleMiddle.getVehicleIds());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -41,10 +41,16 @@
|
|||
</sql>
|
||||
<insert id="addVehicle">
|
||||
INSERT INTO `couplet-cloud`.`couplet_middle` (`user_id`, `vehicle_id`, `del_flag`) VALUES
|
||||
<foreach collection="vehicleId" item="vehicleId" separator=",">
|
||||
(#{userId}, #{vehicleId}, 0)
|
||||
<foreach collection="vehicleIds" item="singleVehicleId" separator=",">
|
||||
(#{userId}, #{singleVehicleId}, 0)
|
||||
</foreach>
|
||||
</insert>
|
||||
<!-- <insert id="addVehicle" useGeneratedKeys="true" keyProperty="vehicleId">-->
|
||||
<!-- INSERT INTO `couplet-cloud`.`couplet_middle` (`user_id`, `vehicle_id`, `del_flag`) VALUES-->
|
||||
<!-- <foreach collection="vehicleId" item="vehicleId" separator=",">-->
|
||||
<!-- (#{userId}, #{vehicleId}, 0)-->
|
||||
<!-- </foreach>-->
|
||||
<!-- </insert>-->
|
||||
<delete id="deleteVehicle">
|
||||
update couplet_middle
|
||||
set del_flag = '2'
|
||||
|
|
|
@ -24,16 +24,16 @@ public class MqController {
|
|||
// 通过注入的方式获取队列名、交换机名和路由键
|
||||
//队列名
|
||||
@Value("${mq.queueName}")
|
||||
public String queueName;
|
||||
@Value("${mq.VinQueueName}")
|
||||
public String finByVinQueueName;
|
||||
public static final String queueName="queueName";
|
||||
@Value("${mq.finByVinQueueName}")
|
||||
public static final String finByVinQueueName="finByVinQueueName";
|
||||
//交换机
|
||||
@Value("${mq.exchangeName}")
|
||||
public String exchangeName;
|
||||
public static final String exchangeName="exchangeName";
|
||||
|
||||
//路由键
|
||||
@Value("${mq.routingKey}")
|
||||
public String routingKey;
|
||||
public static final String routingKey="routingKey";
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
@ -57,11 +57,13 @@ public class MqController {
|
|||
}
|
||||
|
||||
|
||||
@PostMapping("findByVin")
|
||||
public void postFindByVin(@RequestBody RealTimeDataRequest request){
|
||||
@PostMapping("findByVin/{vin}")
|
||||
public void postFindByVin(@PathVariable String vin){
|
||||
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
request.setUserId(userId);
|
||||
rabbitTemplate.convertAndSend(exchangeName, routingKey, request, message -> {
|
||||
realTimeDataRequest.setUserId(userId);
|
||||
realTimeDataRequest.setVin(vin);
|
||||
rabbitTemplate.convertAndSend(exchangeName, routingKey, realTimeDataRequest, message -> {
|
||||
message.getMessageProperties().setMessageId(IdUtils.randomUUID());
|
||||
return message;
|
||||
}, new CorrelationData(IdUtils.randomUUID())
|
||||
|
|
Loading…
Reference in New Issue