Merge branch 'server_five_fufanrui' of https://gitea.qinmian.online/five-groups/five-groups-couplet into server_five
commit
abce267131
|
@ -17,9 +17,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
package com.couplet.common.domain;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: 车辆实时数据
|
||||
* @date 2024/4/5 9:31
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class CoupletVehicleData {
|
||||
|
||||
|
||||
//报文主键ID
|
||||
private Long id;
|
||||
//VIN 车辆编码
|
||||
private String vin;
|
||||
//报文创建时间
|
||||
private Date createTime;
|
||||
//经度
|
||||
private String longitude;
|
||||
//维度
|
||||
private String latitude;
|
||||
//速度
|
||||
private String speed;
|
||||
//里程
|
||||
private Double mileage;
|
||||
//总电压
|
||||
private String voltage;
|
||||
//总电流
|
||||
private String current;
|
||||
//绝缘电阻
|
||||
private String resistance;
|
||||
//档位 P:停车 D:运行
|
||||
private String gear;
|
||||
//加速踏板行驶值
|
||||
private String accelerationPedal;
|
||||
//燃料消耗率
|
||||
private String fuelConsumptionRate;
|
||||
//电机控制器温度
|
||||
private String motorControllerTemperature;
|
||||
//电机转速
|
||||
private String motorSpeed;
|
||||
//电机转矩
|
||||
private String motorTorque;
|
||||
//电机温度
|
||||
private String motorTemperature;
|
||||
//电机电压
|
||||
private String motorVoltage;
|
||||
//电机电流
|
||||
private String motorCurrent;
|
||||
//动力电池剩余电量SOC
|
||||
private Double remainingBattery;
|
||||
//当前状态允许的最大反馈功率
|
||||
private String maximumFeedbackPower;
|
||||
//当前状态允许的最大放电功率
|
||||
private String maximumDischargePower;
|
||||
//BMS自检计数器
|
||||
private String selfCheckCounter;
|
||||
//动力电池充放电电流
|
||||
private String totalBatteryCurrent;
|
||||
//动力电池负载端电压V3
|
||||
private String totalBatteryVoltage;
|
||||
//单次最大电压
|
||||
private String singleBatteryMaxVoltage;
|
||||
//单体电池最低电压
|
||||
private String singleBatteryMinVoltage;
|
||||
//单体电池最高温度
|
||||
private String singleBatteryMaxTemperature;
|
||||
//单体电池最低温度
|
||||
private String singleBatteryMinTemperature;
|
||||
//动力电池可用容量
|
||||
private String availableBatteryCapacity;
|
||||
//车辆状态 1:正常 0:故障
|
||||
private Long vehicleStatus;
|
||||
//充电状态 1:正常 0:故障
|
||||
private Long chargingStatus;
|
||||
//运行状态 1:正常 0:故障
|
||||
private Long operatingStatus;
|
||||
//SOC 状态 1:正常 0:故障
|
||||
private Long socStatus;
|
||||
//可充电储能装置工作状态 1:正常 0:故障
|
||||
private Long chargingEnergyStorageStatus;
|
||||
//驱动电机状态 1:正常 0:故障
|
||||
private Long driveMotorStatus;
|
||||
//定位是否有效 1:有效 0:无效
|
||||
private Long positionStatus;
|
||||
//EAS(汽车防盗系统)状态 1:正常 0:故障
|
||||
private Long easStatus;
|
||||
//PTC(电动加热器)状态 1:正常 0:故障
|
||||
private Long ptcStatus;
|
||||
//EPS(电动助力系统)状态 1:正常 0:故障
|
||||
private Long epsStatus;
|
||||
//ABS(防抱死)状态 1:正常 0:故障
|
||||
private Long absStatus;
|
||||
//MCU(电机/逆变器)状态 1:正常 0:故障
|
||||
private Long mcuStatus;
|
||||
//动力电池加热状态 1:正常 0:故障
|
||||
private Long heatingStatus;
|
||||
//动力电池当前状态 1:正常 0:故障
|
||||
private Long batteryStatus;
|
||||
//动力电池保温状态 1:正常 0:故障
|
||||
private Long batteryInsulationStatus;
|
||||
//DCDC(电力交换系统) 状态 1:正常 0:故障
|
||||
private Long dcdcStatus;
|
||||
//CHG(充电机)状态 1:正常 0:故障
|
||||
private Long chgStatus;
|
||||
//制动踏板行驶值
|
||||
private Double brakePedal;
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.couplet.common.domain.request;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: 车辆实时数据请求参数
|
||||
* @date 2024/4/4 14:35
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class RealTimeDataRequest implements Serializable {
|
||||
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String vin;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -48,7 +48,6 @@ public class RemoteVehicleFallbackFactory implements FallbackFactory<RemoteVehic
|
|||
|
||||
@Override
|
||||
public Result<List<Vehicle>> findByVIN(String vin) {
|
||||
log.error("车辆服务调用失败:"+cause.getMessage());
|
||||
return Result.error("车辆服务调用失败:" + cause.getMessage());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
com.couplet.remote.factory.RemoteVehicleFallbackFactory
|
|
@ -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() {
|
||||
|
||||
}
|
||||
}
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
package com.couplet.analyze.msg.contents;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: LiJiaYao
|
||||
* @Date: 2024/4/4
|
||||
* @Description:
|
||||
*/
|
||||
@Component
|
||||
public class StateConstant {
|
||||
|
||||
/**
|
||||
* 车辆状态
|
||||
*/
|
||||
public static final Integer VEHICLE_STATUS = 0;
|
||||
|
||||
/**
|
||||
* 充电状态
|
||||
*/
|
||||
public static final Integer CHARGING_STATUS = 0;
|
||||
|
||||
/**
|
||||
* 运行状态
|
||||
*/
|
||||
public static final Integer OPERATING_STATUS = 0;
|
||||
|
||||
/**
|
||||
* soc状态
|
||||
*/
|
||||
public static final Integer SOC_STATUS = 0;
|
||||
|
||||
/**
|
||||
* 可充电储能装置工作状态
|
||||
*/
|
||||
public static final Integer CHARGING_ENERGY_STORAGE_STATUS = 0 ;
|
||||
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@ package com.couplet.analyze.msg.model;
|
|||
|
||||
import com.couplet.analyze.msg.domain.CoupletMsgData;
|
||||
import com.couplet.analyze.msg.service.IncidentService;
|
||||
import com.couplet.common.core.exception.analyze.AnalyzeException;
|
||||
import com.couplet.common.core.utils.SpringUtils;
|
||||
import com.couplet.common.core.utils.uuid.IdUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -111,7 +110,7 @@ public class ModelMessage {
|
|||
|
||||
Thread.sleep(1000*6*10);
|
||||
} catch (Exception e) {
|
||||
throw new AnalyzeException("连接断开:"+ e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ public class BreakdownServiceImpl implements IncidentService {
|
|||
public void incident(CoupletMsgData coupletMsgData) {
|
||||
|
||||
log.info("故障事件开始.....");
|
||||
|
||||
log.info("故障事件结束.....");
|
||||
|
||||
|
||||
|
|
|
@ -23,9 +23,6 @@ public class RealTimeDataServiceImpl implements IncidentService {
|
|||
public void incident(CoupletMsgData coupletMsgData) {
|
||||
|
||||
log.info("实时数据事件开始.....");
|
||||
|
||||
|
||||
|
||||
log.info("实时数据事件结束.....");
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
`single_battery_max_voltage`, `single_battery_min_voltage`,
|
||||
`single_battery_max_temperature`, `single_battery_min_temperature`,
|
||||
`available_battery_capacity`, `vehicle_status`, `charging_status`,
|
||||
`operating_status`, `soc_status`, `charging_energy_storage_status`,
|
||||
`operatingStatus`, `soc_status`, `charging_energy_storage_status`,
|
||||
`drive_motor_status`, `position_status`, `eas_status`, `ptc_status`,
|
||||
`eps_status`, `abs_status`, `mcu_status`, `heating_status`, `battery_status`,
|
||||
`battery_insulation_status`, `dcdc_status`, `chg_status`, `brake_pedal`)
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: 上线车辆列表
|
||||
* @date 2024/4/5 9:37
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("online")
|
||||
public class OnLineVehicleController {
|
||||
|
||||
@Autowired
|
||||
private OnLineVehicleService onLineVehicleService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
@PostMapping("onlineList")
|
||||
public Result<List<Vehicle>> onlineList(){
|
||||
List<Vehicle> onlineList = onLineVehicleService.onlineList();
|
||||
Result<List<Vehicle>> success = Result.success(onlineList);
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
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.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: 车辆检测控制器
|
||||
* @date 2024/4/4 10:11
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("detection")
|
||||
public class VehicleDetectionController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private VehicleDetectionService vehicleDetectionService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
/*
|
||||
* @param :
|
||||
* @return Result<List<Vehicle>>
|
||||
* @author 付凡芮
|
||||
* @description 查询上线的车辆信息
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("/detectionList")
|
||||
public Result<List<Vehicle>> detectionList() {
|
||||
return Result.success(vehicleDetectionService.detectionList());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param vin:
|
||||
* @return Result<List<Vehicle>>
|
||||
* @author 付凡芮
|
||||
* @description 根据vin查询车辆信息
|
||||
* @date
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.couplet.business.server.mapper;
|
||||
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface OnLineVehicleMapper {
|
||||
List<Vehicle> onlineList();
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.couplet.business.server.mapper;
|
||||
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface VehicleDetectionMapper {
|
||||
List<Vehicle> detectionList();
|
||||
|
||||
List<Vehicle> findByVin(Integer vehicleId);
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.couplet.business.server.service;
|
||||
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OnLineVehicleService {
|
||||
List<Vehicle> onlineList();
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.couplet.business.server.service;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface VehicleDetectionService {
|
||||
|
||||
List<Vehicle> detectionList();
|
||||
|
||||
List<Vehicle> findByVin(Integer vehicleId);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.couplet.business.server.service.impl;
|
||||
|
||||
import com.couplet.business.server.mapper.OnLineVehicleMapper;
|
||||
import com.couplet.business.server.service.OnLineVehicleService;
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: 上线车辆实现类
|
||||
* @date 2024/4/5 9:38
|
||||
*/
|
||||
@Service
|
||||
public class OnLineVehicleImpl implements OnLineVehicleService {
|
||||
@Autowired
|
||||
private OnLineVehicleMapper onLineVehicleMapper;
|
||||
@Override
|
||||
public List<Vehicle> onlineList() {
|
||||
return onLineVehicleMapper.onlineList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.couplet.business.server.service.impl;
|
||||
|
||||
import com.couplet.business.server.mapper.VehicleDetectionMapper;
|
||||
import com.couplet.business.server.service.VehicleDetectionService;
|
||||
import com.couplet.business.server.service.VehicleManageService;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.domain.Vehicle;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: 车辆检测服务实现类
|
||||
* @date 2024/4/4 10:23
|
||||
*/
|
||||
@Service
|
||||
public class VehicleDetectionServiceImpl implements VehicleDetectionService{
|
||||
|
||||
@Autowired
|
||||
private VehicleDetectionMapper vehicleDetectionMapper;
|
||||
|
||||
@Override
|
||||
public List<Vehicle> detectionList() {
|
||||
return vehicleDetectionMapper.detectionList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vehicle> findByVin(Integer vehicleId) {
|
||||
return vehicleDetectionMapper.findByVin(vehicleId);
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.couplet.business.server.mapper.OnLineVehicleMapper">
|
||||
<sql id="selectOnlineVehicle">
|
||||
SELECT
|
||||
v.vehicle_id,
|
||||
v.vehicle_type,
|
||||
v.motor_manufacturer,
|
||||
v.battery_manufacturer,
|
||||
v.motor_number,
|
||||
v.battery_number,
|
||||
v.vin,
|
||||
v.vehicle_state,
|
||||
v.isdelete,
|
||||
t.vehicle_type_id,
|
||||
t.vehicle_type_name
|
||||
FROM
|
||||
couplet_vehicle v
|
||||
LEFT JOIN couplet_vehicle_type t ON v.vehicle_type = t.vehicle_type_id
|
||||
WHERE
|
||||
isdelete = 0
|
||||
</sql>
|
||||
<select id="onlineList" resultType="com.couplet.common.domain.Vehicle">
|
||||
<include refid="selectOnlineVehicle"/>
|
||||
AND v.vehicle_state = 1
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.couplet.business.server.mapper.VehicleDetectionMapper">
|
||||
|
||||
<sql id="selectVehicle">
|
||||
SELECT
|
||||
v.vehicle_id,
|
||||
v.vehicle_type,
|
||||
v.motor_manufacturer,
|
||||
v.battery_manufacturer,
|
||||
v.motor_number,
|
||||
v.battery_number,
|
||||
v.vin,
|
||||
v.vehicle_state,
|
||||
v.isdelete,
|
||||
t.vehicle_type_id,
|
||||
t.vehicle_type_name
|
||||
FROM
|
||||
couplet_vehicle v
|
||||
LEFT JOIN couplet_vehicle_type t ON v.vehicle_type = t.vehicle_type_id
|
||||
WHERE v.isdelete = 0
|
||||
</sql>
|
||||
<select id="detectionList" resultType="com.couplet.common.domain.Vehicle">
|
||||
<include refid="selectVehicle"/>
|
||||
AND v.vehicle_state = 1
|
||||
</select>
|
||||
<select id="findByVin" resultType="com.couplet.common.domain.Vehicle">
|
||||
<include refid="selectVehicle"/>
|
||||
<if test="null!=vin and ''!=vin">
|
||||
AND v.vehicle_id, = #{vehicleId}
|
||||
</if>
|
||||
AND v.vehicle_state = 1
|
||||
</select>
|
||||
</mapper>
|
|
@ -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'
|
||||
|
|
|
@ -15,11 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -17,11 +17,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -17,11 +17,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -102,6 +102,10 @@
|
|||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common-business</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -19,6 +19,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
public class CoupletMqApplatcaion {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CoupletMqApplatcaion.class, args);
|
||||
System.out.println("RabbitMQ模块启动成功");
|
||||
System.out.println("获取报文、RabbitMQ模块启动成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.couplet.mq.controller;
|
||||
|
||||
import com.couplet.common.core.utils.uuid.IdUtils;
|
||||
import com.couplet.common.domain.request.RealTimeDataRequest;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import com.couplet.mq.domain.User;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
|
@ -22,15 +24,16 @@ public class MqController {
|
|||
// 通过注入的方式获取队列名、交换机名和路由键
|
||||
//队列名
|
||||
@Value("${mq.queueName}")
|
||||
public String queueName;
|
||||
|
||||
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;
|
||||
|
@ -52,4 +55,18 @@ public class MqController {
|
|||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("findByVin/{vin}")
|
||||
public void postFindByVin(@PathVariable String vin){
|
||||
RealTimeDataRequest realTimeDataRequest = new RealTimeDataRequest();
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
realTimeDataRequest.setUserId(userId);
|
||||
realTimeDataRequest.setVin(vin);
|
||||
rabbitTemplate.convertAndSend(exchangeName, routingKey, realTimeDataRequest, message -> {
|
||||
message.getMessageProperties().setMessageId(IdUtils.randomUUID());
|
||||
return message;
|
||||
}, new CorrelationData(IdUtils.randomUUID())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
//@EnableFeignClients
|
||||
public class CoupletOnlineApplication {
|
||||
public class OnlineApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CoupletOnlineApplication.class);
|
||||
SpringApplication.run(OnlineApplication.class);
|
||||
System.out.println("车辆上线模块启动成功");
|
||||
}
|
||||
}
|
|
@ -16,9 +16,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,11 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue