diff --git a/couplet-auth/src/main/resources/bootstrap.yml b/couplet-auth/src/main/resources/bootstrap.yml index 427f682..b89bb00 100644 --- a/couplet-auth/src/main/resources/bootstrap.yml +++ b/couplet-auth/src/main/resources/bootstrap.yml @@ -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 # 共享配置 diff --git a/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/CoupletVehicleData.java b/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/CoupletVehicleData.java new file mode 100644 index 0000000..2827b40 --- /dev/null +++ b/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/CoupletVehicleData.java @@ -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; + +} diff --git a/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/Vehicle.java b/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/Vehicle.java index ef89d45..fbe6b10 100644 --- a/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/Vehicle.java +++ b/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/Vehicle.java @@ -21,7 +21,15 @@ import lombok.experimental.SuperBuilder; @AllArgsConstructor @NoArgsConstructor @TableName("couplet_vehicle") -public class Vehicle{ +public class Vehicle { + /* + * @param null: + * @return null + * @author 付凡芮 + * @description 中间表id + * @date + */ + private Long middleId; /* *车辆id * */ diff --git a/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/VehicleMiddle.java b/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/VehicleMiddle.java index 3b6308f..86c9a13 100644 --- a/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/VehicleMiddle.java +++ b/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/VehicleMiddle.java @@ -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 vehicleIds; } diff --git a/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/request/RealTimeDataRequest.java b/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/request/RealTimeDataRequest.java new file mode 100644 index 0000000..1dc7bb4 --- /dev/null +++ b/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/request/RealTimeDataRequest.java @@ -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; + + + +} diff --git a/couplet-common/couplet-common-business/src/main/java/com/couplet/remote/factory/RemoteVehicleFallbackFactory.java b/couplet-common/couplet-common-business/src/main/java/com/couplet/remote/factory/RemoteVehicleFallbackFactory.java index 8084062..58fa254 100644 --- a/couplet-common/couplet-common-business/src/main/java/com/couplet/remote/factory/RemoteVehicleFallbackFactory.java +++ b/couplet-common/couplet-common-business/src/main/java/com/couplet/remote/factory/RemoteVehicleFallbackFactory.java @@ -48,7 +48,6 @@ public class RemoteVehicleFallbackFactory implements FallbackFactory> findByVIN(String vin) { - log.error("车辆服务调用失败:"+cause.getMessage()); return Result.error("车辆服务调用失败:" + cause.getMessage()); } }; diff --git a/couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 7a358b3..0000000 --- a/couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1 +0,0 @@ -com.couplet.remote.factory.RemoteVehicleFallbackFactory diff --git a/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/constant/ServiceNameConstants.java b/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/constant/ServiceNameConstants.java index e6fc17d..2d20f16 100644 --- a/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/constant/ServiceNameConstants.java +++ b/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/constant/ServiceNameConstants.java @@ -30,4 +30,5 @@ public class ServiceNameConstants { * @date */ public static final String BUSINESS_SERVICE = "couplet-business"; + public static final String VEHICLE_SERVICE = "vehicle-service"; } diff --git a/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/exception/analyze/AnalyzeException.java b/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/exception/analyze/AnalyzeException.java deleted file mode 100644 index d939053..0000000 --- a/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/exception/analyze/AnalyzeException.java +++ /dev/null @@ -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() { - - } -} diff --git a/couplet-gateway/src/main/resources/bootstrap.yml b/couplet-gateway/src/main/resources/bootstrap.yml index 091e68a..acd4642 100644 --- a/couplet-gateway/src/main/resources/bootstrap.yml +++ b/couplet-gateway/src/main/resources/bootstrap.yml @@ -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 # 共享配置 diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/contents/StateConstant.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/contents/StateConstant.java deleted file mode 100644 index b94c76a..0000000 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/contents/StateConstant.java +++ /dev/null @@ -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 ; - - -} diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java index 2e92c39..c992ddc 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java @@ -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); } } diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/BreakdownServiceImpl.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/BreakdownServiceImpl.java index 721046f..3a5ca25 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/BreakdownServiceImpl.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/BreakdownServiceImpl.java @@ -23,7 +23,6 @@ public class BreakdownServiceImpl implements IncidentService { public void incident(CoupletMsgData coupletMsgData) { log.info("故障事件开始....."); - log.info("故障事件结束....."); diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/RealTimeDataServiceImpl.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/RealTimeDataServiceImpl.java index 7bbcbb9..971e428 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/RealTimeDataServiceImpl.java +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/service/impl/RealTimeDataServiceImpl.java @@ -23,9 +23,6 @@ public class RealTimeDataServiceImpl implements IncidentService { public void incident(CoupletMsgData coupletMsgData) { log.info("实时数据事件开始....."); - - - log.info("实时数据事件结束....."); } diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/mapper/incident/SysIncidentMapper.xml b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/mapper/incident/SysIncidentMapper.xml index 39f16ee..3b863a6 100644 --- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/mapper/incident/SysIncidentMapper.xml +++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/resources/mapper/incident/SysIncidentMapper.xml @@ -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`) diff --git a/couplet-modules/couplet-business/pom.xml b/couplet-modules/couplet-business/pom.xml index cc7969f..bc2d817 100644 --- a/couplet-modules/couplet-business/pom.xml +++ b/couplet-modules/couplet-business/pom.xml @@ -81,6 +81,11 @@ com.couplet couplet-common-swagger + + + org.springframework.boot + spring-boot-starter-amqp + diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/OnLineVehicleController.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/OnLineVehicleController.java new file mode 100644 index 0000000..49f25eb --- /dev/null +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/OnLineVehicleController.java @@ -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> onlineList(){ + List onlineList = onLineVehicleService.onlineList(); + Result> 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); + } + + +} diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleController.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleController.java index ad24025..d7198d5 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleController.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleController.java @@ -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> UserUnderTheVehicleList(@PathVariable(value = "userId") Long userId){ + return Result.success(vehicleService.UserUnderTheVehicleList(userId)); + } + + + /* + * @param middleId: + * @return Result + * @author 付凡芮 + * @description 删除员工管理的车辆 + * @date + */ + @DeleteMapping("/{middleId}") + public Result deleteVehicle(@PathVariable(value = "middleId") Long middleId){ + return Result.success(vehicleService.deleteVehicle(middleId)); + } + + + @PostMapping + public Result addVehicle(@RequestBody VehicleMiddle vehicleMiddle){ + return Result.success(vehicleService.addVehicle(vehicleMiddle)); + } + + + + @PostMapping("vehicleAll") + public Result> VehicleManageList(){ + + return Result.success(vehicleService.vehicleAll()); + } + + + + + + + + + } diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleDetectionController.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleDetectionController.java new file mode 100644 index 0000000..96e804b --- /dev/null +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleDetectionController.java @@ -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> + * @author 付凡芮 + * @description 查询上线的车辆信息 + * @date + */ + @PostMapping("/detectionList") + public Result> detectionList() { + return Result.success(vehicleDetectionService.detectionList()); + } + + + /* + * @param vin: + * @return Result> + * @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); + } + +} diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/mapper/OnLineVehicleMapper.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/mapper/OnLineVehicleMapper.java new file mode 100644 index 0000000..4c069bc --- /dev/null +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/mapper/OnLineVehicleMapper.java @@ -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 onlineList(); +} diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/mapper/VehicleDetectionMapper.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/mapper/VehicleDetectionMapper.java new file mode 100644 index 0000000..33ab95a --- /dev/null +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/mapper/VehicleDetectionMapper.java @@ -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 detectionList(); + + List findByVin(Integer vehicleId); +} diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/mapper/VehicleMapper.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/mapper/VehicleMapper.java index 2f3a903..dd8a493 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/mapper/VehicleMapper.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/mapper/VehicleMapper.java @@ -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 { Integer deleteVehicle(Long middleId); - Integer addVehicle(VehicleMiddle vehicleMiddle); + List vehicleAll(); + + Integer addVehicle(@Param("userId") Long userId, @Param("vehicleIds") List vehicleIds); + } diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/OnLineVehicleService.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/OnLineVehicleService.java new file mode 100644 index 0000000..7f1b8cc --- /dev/null +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/OnLineVehicleService.java @@ -0,0 +1,10 @@ +package com.couplet.business.server.service; + +import com.couplet.common.domain.Vehicle; + +import java.util.List; + +public interface OnLineVehicleService { + List onlineList(); + +} diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/VehicleDetectionService.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/VehicleDetectionService.java new file mode 100644 index 0000000..2da84f6 --- /dev/null +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/VehicleDetectionService.java @@ -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 detectionList(); + + List findByVin(Integer vehicleId); +} diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/OnLineVehicleImpl.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/OnLineVehicleImpl.java new file mode 100644 index 0000000..9b80642 --- /dev/null +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/OnLineVehicleImpl.java @@ -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 onlineList() { + return onLineVehicleMapper.onlineList(); + } +} diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleDetectionServiceImpl.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleDetectionServiceImpl.java new file mode 100644 index 0000000..d0d29ce --- /dev/null +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleDetectionServiceImpl.java @@ -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 detectionList() { + return vehicleDetectionMapper.detectionList(); + } + + @Override + public List findByVin(Integer vehicleId) { + return vehicleDetectionMapper.findByVin(vehicleId); + } +} diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleManageServiceImpl.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleManageServiceImpl.java index fa3c412..c50ef02 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleManageServiceImpl.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleManageServiceImpl.java @@ -61,8 +61,6 @@ public class VehicleManageServiceImpl implements VehicleManageService { */ @Override public Result addVehicle(VehicleMiddle middle) { - Long userId = SecurityUtils.getUserId(); - middle.setUserId(userId); Result integerResult = remoteVehicleService.addVehicle(middle); Integer resultData = integerResult.getData(); return resultData==1?Result.success():Result.error("添加失败"); diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java index 1ee5a95..48d6e9b 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/VehicleServiceImpl.java @@ -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 impl @Override public Integer addVehicle(VehicleMiddle vehicleMiddle) { - - return vehicleMapper.addVehicle(vehicleMiddle); + Long userId = SecurityUtils.getUserId(); + return vehicleMapper.addVehicle(userId,vehicleMiddle.getVehicleIds()); } @Override diff --git a/couplet-modules/couplet-business/src/main/resources/mapper/business/OnLineVehicleMapper.xml b/couplet-modules/couplet-business/src/main/resources/mapper/business/OnLineVehicleMapper.xml new file mode 100644 index 0000000..a22fb86 --- /dev/null +++ b/couplet-modules/couplet-business/src/main/resources/mapper/business/OnLineVehicleMapper.xml @@ -0,0 +1,29 @@ + + + + + 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 + + + diff --git a/couplet-modules/couplet-business/src/main/resources/mapper/business/VehicleDetectionMapper.xml b/couplet-modules/couplet-business/src/main/resources/mapper/business/VehicleDetectionMapper.xml new file mode 100644 index 0000000..bf0db67 --- /dev/null +++ b/couplet-modules/couplet-business/src/main/resources/mapper/business/VehicleDetectionMapper.xml @@ -0,0 +1,36 @@ + + + + + + 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 + + + + diff --git a/couplet-modules/couplet-business/src/main/resources/mapper/business/VehicleMapper.xml b/couplet-modules/couplet-business/src/main/resources/mapper/business/VehicleMapper.xml index 4eb95a7..18b0d34 100644 --- a/couplet-modules/couplet-business/src/main/resources/mapper/business/VehicleMapper.xml +++ b/couplet-modules/couplet-business/src/main/resources/mapper/business/VehicleMapper.xml @@ -41,10 +41,16 @@ INSERT INTO `couplet-cloud`.`couplet_middle` (`user_id`, `vehicle_id`, `del_flag`) VALUES - - (#{userId}, #{vehicleId}, 0) + + (#{userId}, #{singleVehicleId}, 0) + + + + + + update couplet_middle set del_flag = '2' diff --git a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml index b0d1d24..8681657 100644 --- a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-file/src/main/resources/bootstrap.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 # 共享配置 diff --git a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml index b024662..d2834c9 100644 --- a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-gen/src/main/resources/bootstrap.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 # 共享配置 diff --git a/couplet-modules/couplet-job/src/main/resources/bootstrap.yml b/couplet-modules/couplet-job/src/main/resources/bootstrap.yml index bb8e219..3b56a22 100644 --- a/couplet-modules/couplet-job/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-job/src/main/resources/bootstrap.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 # 共享配置 diff --git a/couplet-modules/couplet-modules-mq/pom.xml b/couplet-modules/couplet-modules-mq/pom.xml index dded87b..9f61159 100644 --- a/couplet-modules/couplet-modules-mq/pom.xml +++ b/couplet-modules/couplet-modules-mq/pom.xml @@ -102,6 +102,10 @@ org.springframework.kafka spring-kafka + + com.couplet + couplet-common-business + diff --git a/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/CoupletMqApplatcaion.java b/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/CoupletMqApplatcaion.java index c96528a..d1c309f 100644 --- a/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/CoupletMqApplatcaion.java +++ b/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/CoupletMqApplatcaion.java @@ -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模块启动成功"); } } diff --git a/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/MqController.java b/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/MqController.java index 057ac32..a0ccd6b 100644 --- a/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/MqController.java +++ b/couplet-modules/couplet-modules-mq/src/main/java/com/couplet/mq/controller/MqController.java @@ -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()) + ); + } } diff --git a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/CoupletOnlineApplication.java b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/OnlineApplication.java similarity index 87% rename from couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/CoupletOnlineApplication.java rename to couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/OnlineApplication.java index 3937491..e68b054 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/CoupletOnlineApplication.java +++ b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/OnlineApplication.java @@ -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("车辆上线模块启动成功"); } } diff --git a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml index aeddeaa..05ffe2d 100644 --- a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml @@ -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 # 共享配置 diff --git a/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml b/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml index d219500..94d42fc 100644 --- a/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml +++ b/couplet-visual/couplet-monitor/src/main/resources/bootstrap.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 # 共享配置