From 4a6124d181258b145898a3eb660efe5264679f02 Mon Sep 17 00:00:00 2001 From: ffr <492210217@qq.com> Date: Fri, 5 Apr 2024 10:10:12 +0800 Subject: [PATCH] upd commit --- .../common/domain/CoupletVehicleData.java | 117 ++++++++++++++++++ .../domain/request/RealTimeDataRequest.java | 2 +- .../couplet/remote/RemoteVehicleService.java | 2 +- .../factory/RemoteVehicleFallbackFactory.java | 1 - ...ot.autoconfigure.AutoConfiguration.imports | 1 - .../analyze/msg/contents/StateConstant.java | 39 ------ .../analyze/msg/model/ModelMessage.java | 3 +- .../service/impl/BreakdownServiceImpl.java | 1 - .../service/impl/RealTimeDataServiceImpl.java | 3 - .../mapper/incident/SysIncidentMapper.xml | 2 +- .../controller/OnLineVehicleController.java | 37 ++++++ .../server/mapper/OnLineVehicleMapper.java | 11 ++ .../server/service/OnLineVehicleService.java | 10 ++ .../service/impl/OnLineVehicleImpl.java | 25 ++++ .../mapper/business/OnLineVehicleMapper.xml | 29 +++++ couplet-modules/couplet-modules-mq/pom.xml | 4 + .../com/couplet/mq/CoupletMqApplatcaion.java | 2 +- .../couplet/mq/controller/MqController.java | 17 ++- ...pplication.java => OnlineApplication.java} | 4 +- 19 files changed, 256 insertions(+), 54 deletions(-) create mode 100644 couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/CoupletVehicleData.java delete mode 100644 couplet-common/couplet-common-business/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports delete mode 100644 couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/contents/StateConstant.java create mode 100644 couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/OnLineVehicleController.java create mode 100644 couplet-modules/couplet-business/src/main/java/com/couplet/business/server/mapper/OnLineVehicleMapper.java create mode 100644 couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/OnLineVehicleService.java create mode 100644 couplet-modules/couplet-business/src/main/java/com/couplet/business/server/service/impl/OnLineVehicleImpl.java create mode 100644 couplet-modules/couplet-business/src/main/resources/mapper/business/OnLineVehicleMapper.xml rename couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/{CoupletOnlineApplication.java => OnlineApplication.java} (87%) 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/request/RealTimeDataRequest.java b/couplet-common/couplet-common-business/src/main/java/com/couplet/common/domain/request/RealTimeDataRequest.java index 5135e00..512a86e 100644 --- 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 @@ -18,7 +18,7 @@ import lombok.ToString; public class RealTimeDataRequest { - private Integer userId; + private Long userId; private String vin; diff --git a/couplet-common/couplet-common-business/src/main/java/com/couplet/remote/RemoteVehicleService.java b/couplet-common/couplet-common-business/src/main/java/com/couplet/remote/RemoteVehicleService.java index c953032..7e8a46b 100644 --- a/couplet-common/couplet-common-business/src/main/java/com/couplet/remote/RemoteVehicleService.java +++ b/couplet-common/couplet-common-business/src/main/java/com/couplet/remote/RemoteVehicleService.java @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; @FeignClient(contextId = "remoteVehicleService" , - value = ServiceNameConstants.BUSINESS_SERVICE, + value = ServiceNameConstants.VEHICLE_SERVICE, fallbackFactory = RemoteVehicleFallbackFactory.class, path = "/vehicle" ) 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-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/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..9789155 --- /dev/null +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/OnLineVehicleController.java @@ -0,0 +1,37 @@ +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 org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +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; + + @PostMapping("onlineList") + public Result> onlineList(){ + List onlineList = onLineVehicleService.onlineList(); + Result> success = Result.success(onlineList); + return success; + } + + + + + +} 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/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/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/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-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..1ebb1d1 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; @@ -23,7 +25,8 @@ public class MqController { //队列名 @Value("${mq.queueName}") public String queueName; - + @Value("${mq.VinQueueName}") + public String finByVinQueueName; //交换机 @Value("${mq.exchangeName}") public String exchangeName; @@ -52,4 +55,16 @@ public class MqController { ); } + + + @PostMapping("findByVin") + public void postFindByVin(@RequestBody RealTimeDataRequest request){ + Long userId = SecurityUtils.getUserId(); + request.setUserId(userId); + rabbitTemplate.convertAndSend(exchangeName, routingKey, request, 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("车辆上线模块启动成功"); } }