diff --git a/pom.xml b/pom.xml index e4897e5..7744442 100644 --- a/pom.xml +++ b/pom.xml @@ -7,20 +7,135 @@ ruoyi 3.6.3 - pom - - ruoyi-receive-common - ruoyi-receive-remote - ruoyi-receive-server - + jar 3.6.3 4.0.0 - ruoyi-modules-receive + ruoyireceive ruoyi-modules-receive 接收模块 + + + com.ruoyi + ruoyi-receive-common + 3.6.3 + + + com.ruoyi + ruoyi-common-redis + 3.6.3 + + + + + + + + + + + + + + + + + + + + + + com.ruoyi + ruoyi-common-swagger + + + + com.ruoyi + ruoyi-file-remote + 3.6.3 + + + + + io.netty + netty-all + + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + org.springframework.boot + spring-boot-starter-thymeleaf + 2.0.4.RELEASE + + + + org.springframework.kafka + spring-kafka + + + + + org.apache.curator + curator-framework + 4.2.0 + + + + com.gu + ruoyi-business-cache + 3.6.3 + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + + + + + + com.ruoyi + ruoyi-common-core + 3.6.3 + + diff --git a/ruoyi-receive-common/.gitignore b/ruoyi-receive-common/.gitignore deleted file mode 100644 index 5ff6309..0000000 --- a/ruoyi-receive-common/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ -*.iws -*.iml -*.ipr - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git a/ruoyi-receive-common/pom.xml b/ruoyi-receive-common/pom.xml deleted file mode 100644 index 61a16f4..0000000 --- a/ruoyi-receive-common/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - 4.0.0 - - com.ruoyi - ruoyi-modules-receive - 3.6.3 - - - com.ruoyi - ruoyi-receive-common - - - 8 - 8 - UTF-8 - - - - - org.projectlombok - lombok - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-sentinel - - - - - org.springframework.boot - spring-boot-starter-actuator - - - - - io.springfox - springfox-swagger-ui - ${swagger.fox.version} - - - - - - - - - - com.ruoyi - ruoyi-common-core - 3.6.3 - - - - diff --git a/ruoyi-receive-remote/.gitignore b/ruoyi-receive-remote/.gitignore deleted file mode 100644 index 5ff6309..0000000 --- a/ruoyi-receive-remote/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ -*.iws -*.iml -*.ipr - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git a/ruoyi-receive-remote/pom.xml b/ruoyi-receive-remote/pom.xml deleted file mode 100644 index 48cb0b4..0000000 --- a/ruoyi-receive-remote/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - - com.ruoyi - ruoyi-modules-receive - 3.6.3 - - - com.ruoyi - ruoyi-receive-remote - - - 8 - 8 - UTF-8 - - - - - com.ruoyi - ruoyi-receive-common - 3.6.3 - - - - \ No newline at end of file diff --git a/ruoyi-receive-server/.gitignore b/ruoyi-receive-server/.gitignore deleted file mode 100644 index 5ff6309..0000000 --- a/ruoyi-receive-server/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ -*.iws -*.iml -*.ipr - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git a/ruoyi-receive-server/pom.xml b/ruoyi-receive-server/pom.xml deleted file mode 100644 index 432fd30..0000000 --- a/ruoyi-receive-server/pom.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - 4.0.0 - - com.ruoyi - ruoyi-modules-receive - 3.6.3 - - - com.ruoyi - ruoyi-receive-server - - - 8 - 8 - UTF-8 - - - - - - - com.ruoyi - ruoyi-receive-common - 3.6.3 - - - - - - - - - - - - - - - - - - - - - - com.ruoyi - ruoyi-common-swagger - - - - com.ruoyi - ruoyi-file-remote - 3.6.3 - - - - - io.netty - netty-all - - - - - org.springframework.boot - spring-boot-starter-data-redis - - - - org.springframework.boot - spring-boot-starter-thymeleaf - 2.0.4.RELEASE - - - - org.springframework.kafka - spring-kafka - - - - - org.apache.curator - curator-framework - 4.2.0 - - - - com.gu - ruoyi-business-cache - 3.6.3 - - - - - - ${project.artifactId} - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - org.apache.maven.plugins - maven-deploy-plugin - - true - - - - - - - diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/server/impl/KafkaConsumerServiceImpl.java b/ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/server/impl/KafkaConsumerServiceImpl.java deleted file mode 100644 index b1ac634..0000000 --- a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/server/impl/KafkaConsumerServiceImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.ruoyi.receive.netty.server.impl; - -import com.ruoyi.receive.netty.server.KafkaConsumerService; -import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.apache.kafka.clients.consumer.ConsumerRecords; -import org.springframework.stereotype.Service; - -@Service -public class KafkaConsumerServiceImpl implements KafkaConsumerService { - - @Override - public void service(ConsumerRecords records) { - - for (ConsumerRecord record : records){ - System.out.println("消息:key = " + record.key() + ",value = " + record.value()); - } - - } -} diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/RuoYiReceiveApplication.java b/src/main/java/com/ruoyi/receive/RuoYiReceiveApplication.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/RuoYiReceiveApplication.java rename to src/main/java/com/ruoyi/receive/RuoYiReceiveApplication.java diff --git a/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/Car.java b/src/main/java/com/ruoyi/receive/domain/Car.java similarity index 100% rename from ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/Car.java rename to src/main/java/com/ruoyi/receive/domain/Car.java diff --git a/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/Response.java b/src/main/java/com/ruoyi/receive/domain/Response.java similarity index 100% rename from ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/Response.java rename to src/main/java/com/ruoyi/receive/domain/Response.java diff --git a/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/SystemServer.java b/src/main/java/com/ruoyi/receive/domain/SystemServer.java similarity index 100% rename from ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/SystemServer.java rename to src/main/java/com/ruoyi/receive/domain/SystemServer.java diff --git a/src/main/java/com/ruoyi/receive/domain/VehicleConstant.java b/src/main/java/com/ruoyi/receive/domain/VehicleConstant.java new file mode 100644 index 0000000..ffc56f4 --- /dev/null +++ b/src/main/java/com/ruoyi/receive/domain/VehicleConstant.java @@ -0,0 +1,76 @@ +package com.ruoyi.receive.domain; + +/** + * 连接常量 + */ +public class VehicleConstant { + /** + * 分包符 + */ + public static final String DATA_PACK_SEPARATOR = "#$&*"; + + /** + * 报文起始位 + */ + public static final String MSG_START = "7E "; + + /** + * 报文结束位 + */ + public static final String MSG_END = "7E"; + + /** + * 连接消息VIN + */ + public final static String START_VIN_SUF = "START_VIN:"; + /** + * 连接消息VIN + */ + public final static String START_VIN_SUCCESS_SUF = "SUCCESS_VIN:"; + /** + * 车辆消息报文前缀 + */ + public final static String VEHICLE_MSG_SUF = "VEHICLE_MSG:"; + /** + * 车辆启动报文前缀 + */ + public final static String VEHICLE_START_SUF = "VEHICLE_START:"; + /** + * 车辆关闭报文前缀 + */ + public final static String VEHICLE_STOP_SUF = "VEHICLE_STOP:"; + + /** + * 连接启动信息 + */ + public final static String NETTY_CONNECT = "CONNECT"; + /** + * 连接关闭信息 + */ + public final static String NETTY_WILL_CLOSE = "WILL_CLOSE:"; + /** + * 连接关闭信息 + */ + public final static String NETTY_CLOSE = "CLOSE"; + + /** + * 车辆VIN正则表达式 + */ + public final static String VIN_REGEX = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{17}$"; + + + /** + * 车辆基础故障组 + */ + public final static String VEHICLE_BASE_FAULT = "vehicle_base"; + + /** + * 车辆零配件故障组 + */ + public final static String VEHICLE_PARTS_FAULT = "vehicle_parts"; + + /** + * 车辆电池故障组 + */ + public final static String VEHICLE_BATTERY_FAULT = "vehicle_battery"; +} diff --git a/src/main/java/com/ruoyi/receive/domain/VehicleMessage.java b/src/main/java/com/ruoyi/receive/domain/VehicleMessage.java new file mode 100644 index 0000000..f5441f8 --- /dev/null +++ b/src/main/java/com/ruoyi/receive/domain/VehicleMessage.java @@ -0,0 +1,582 @@ +package com.ruoyi.receive.domain; + +/** + * 报文实体类 + */ +public class VehicleMessage { + //消息标识 + private String identification; + //VIN码 + private String vinCode; + //经度 + private String longitude; + //纬度 + private String latitude; + //车速 + private String speedOfVehicle; + //总里程 + private String totalMileage; + //总电压 + private String totalVoltage; + //总电流 + private String combinedCurrent; + //绝缘电阻 + private String insulationResistance; + //档位 + private String gearPosition; + //加速踏板行程值 + private String acceleratorPedalTravelValue; + //制动踏板行程值 + private String brakePedalTravelValue; + //燃料消耗率 + private String specificFuelConsumption; + //电机控制器温度 + private String motorControllerTemperature; + //电机转速 + private String motorSpeed; + //电机转矩 + private String motorTorque; + //电机温度 + private String motorTemperature; + //电机电压 + private String motorVoltage; + //电机电流 + private String motorCurrent; + //动力电池剩余电量SOC + private String electricalSoc; + //当前状态允许的最大反馈功率 + private String maximumFeedbackPower; + //当前状态允许最大放电功率 + private String maximumDischargePower; + //BMS自检计数器 + private String bms; + //动力电池充放电电流 + private String batteryCurrent; + //动力电池负载端总电压V3 + private String v3; + //单次最大电压 + private String singleMaximumVoltage; + //单体电池最低电压 + private String minimumVoltageOfBattery; + //单体电池最高温度 + private String maximumBatteryTemperature; + //单体电池最低温度 + private String minimumBatteryTemperature; + //动力电池可用容量 + private String powerBatteryAvailableCapacity; + //车辆状态 + private Integer carStatus; + //充电状态 + private Integer chargingState; + //运行状态 + private Integer runningState; + //SOC + private String soc; + //可充电储能装置工作状态 + private String workingCondition; + //驱动电机状态 + private String driveMotorCondition; + //定位是否有效 + private String whetherTheLocationValid; + //EAS + private String eas; + //PTC + private String ptc; + //EPS + private String eps; + //ABS + private String abs; + //MCU + private String mcu; + //动力电池加热状态 + private String powerBatteryHeatingState; + //动力电池当前状态 + private String powerBattery; + //动力电池保温状态 + private String powerBatteryInsulationState; + //DCDC + private String dcdc; + //CHG + private String chg; + + //时间 + private Long time; + + public String getIdentification() { + return identification; + } + + public void setIdentification(Object identification) { + if(identification!=null) {this.identification = (String) identification;} + } + + public String getVinCode() { + return vinCode; + } + + public void setVinCode(Object vinCode) { + if (vinCode!=null) { + this.vinCode = (String) vinCode; + } + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(Object longitude) { + if (longitude!=null) { + this.longitude = (String) longitude; + } + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(Object latitude) { + if (latitude!=null) { + this.latitude = (String) latitude; + } + } + + public String getSpeedOfVehicle() { + return speedOfVehicle; + } + + public void setSpeedOfVehicle(Object speedOfVehicle) { + if (speedOfVehicle!=null) { + this.speedOfVehicle = (String) speedOfVehicle; + } + } + + public String getTotalMileage() { + return totalMileage; + } + + public void setTotalMileage(Object totalMileage) { + if (totalMileage!=null) { + this.totalMileage = (String) totalMileage; + } + } + + public String getTotalVoltage() { + return totalVoltage; + } + + public void setTotalVoltage(Object totalVoltage) { + if (totalVoltage!=null) { + this.totalVoltage = (String) totalVoltage; + } + } + + public String getCombinedCurrent() { + return combinedCurrent; + } + + public void setCombinedCurrent(Object combinedCurrent) { + if (combinedCurrent!=null) { + this.combinedCurrent = (String) combinedCurrent; + } + } + + public String getInsulationResistance() { + return insulationResistance; + } + + public void setInsulationResistance(Object insulationResistance) { + if (insulationResistance!=null) { + this.insulationResistance = (String) insulationResistance; + } + } + + public String getGearPosition() { + return gearPosition; + } + + public void setGearPosition(Object gearPosition) { + if (gearPosition!=null) { + this.gearPosition = (String) gearPosition; + } + } + + public String getAcceleratorPedalTravelValue() { + return acceleratorPedalTravelValue; + } + + public void setAcceleratorPedalTravelValue(Object acceleratorPedalTravelValue) { + if (acceleratorPedalTravelValue!=null) { + this.acceleratorPedalTravelValue = (String) acceleratorPedalTravelValue; + } + } + + public String getBrakePedalTravelValue() { + return brakePedalTravelValue; + } + + public void setBrakePedalTravelValue(Object brakePedalTravelValue) { + if (brakePedalTravelValue!=null) { + this.brakePedalTravelValue = (String) brakePedalTravelValue; + } + } + + public String getSpecificFuelConsumption() { + return specificFuelConsumption; + } + + public void setSpecificFuelConsumption(Object specificFuelConsumption) { + if (specificFuelConsumption!=null) { + this.specificFuelConsumption = (String) specificFuelConsumption; + } + } + + public String getMotorControllerTemperature() { + return motorControllerTemperature; + } + + public void setMotorControllerTemperature(Object motorControllerTemperature) { + if (motorControllerTemperature!=null) { + this.motorControllerTemperature = (String) motorControllerTemperature; + } + } + + public String getMotorSpeed() { + return motorSpeed; + } + + public void setMotorSpeed(Object motorSpeed) { + if (motorSpeed!=null) { + this.motorSpeed = (String) motorSpeed; + } + } + + public String getMotorTorque() { + return motorTorque; + } + + public void setMotorTorque(Object motorTorque) { + if (motorTorque!=null) { + this.motorTorque = (String) motorTorque; + } + } + + public String getMotorTemperature() { + return motorTemperature; + } + + public void setMotorTemperature(Object motorTemperature) { + if (motorTemperature!=null) { + this.motorTemperature = (String) motorTemperature; + } + } + + public String getMotorVoltage() { + return motorVoltage; + } + + public void setMotorVoltage(Object motorVoltage) { + if (motorVoltage!=null) { + this.motorVoltage = (String) motorVoltage; + } + } + + public String getMotorCurrent() { + return motorCurrent; + } + + public void setMotorCurrent(Object motorCurrent) { + if (motorCurrent!=null) { + this.motorCurrent = (String) motorCurrent; + } + } + + public String getElectricalSoc() { + return electricalSoc; + } + + public void setElectricalSoc(Object electricalSoc) { + if (electricalSoc!=null) { + this.electricalSoc = (String) electricalSoc; + } + } + + public String getMaximumFeedbackPower() { + return maximumFeedbackPower; + } + + public void setMaximumFeedbackPower(Object maximumFeedbackPower) { + if (maximumFeedbackPower!=null) { + this.maximumFeedbackPower = (String) maximumFeedbackPower; + } + } + + public String getMaximumDischargePower() { + return maximumDischargePower; + } + + public void setMaximumDischargePower(Object maximumDischargePower) { + if (maximumDischargePower!=null) { + this.maximumDischargePower = (String) maximumDischargePower; + } + } + + public String getBms() { + return bms; + } + + public void setBms(Object bms) { + if (bms!=null) { + this.bms = (String) bms; + } + } + + public String getBatteryCurrent() { + return batteryCurrent; + } + + public void setBatteryCurrent(Object batteryCurrent) { + if (batteryCurrent!=null) { + this.batteryCurrent = (String) batteryCurrent; + } + } + + public String getV3() { + return v3; + } + + public void setV3(Object v3) { + if (v3!=null) { + this.v3 = (String) v3; + } + } + + public String getSingleMaximumVoltage() { + return singleMaximumVoltage; + } + + public void setSingleMaximumVoltage(Object singleMaximumVoltage) { + if (singleMaximumVoltage!=null) { + this.singleMaximumVoltage = (String) singleMaximumVoltage; + } + } + + public String getMinimumVoltageOfBattery() { + return minimumVoltageOfBattery; + } + + public void setMinimumVoltageOfBattery(Object minimumVoltageOfBattery) { + if (minimumVoltageOfBattery!=null) { + this.minimumVoltageOfBattery = (String) minimumVoltageOfBattery; + } + } + + public String getMaximumBatteryTemperature() { + return maximumBatteryTemperature; + } + + public void setMaximumBatteryTemperature(Object maximumBatteryTemperature) { + if (maximumBatteryTemperature!=null) { + this.maximumBatteryTemperature = (String) maximumBatteryTemperature; + } + } + + public String getMinimumBatteryTemperature() { + return minimumBatteryTemperature; + } + + public void setMinimumBatteryTemperature(Object minimumBatteryTemperature) { + if (minimumBatteryTemperature!=null) { + this.minimumBatteryTemperature = (String) minimumBatteryTemperature; + } + } + + public String getPowerBatteryAvailableCapacity() { + return powerBatteryAvailableCapacity; + } + + public void setPowerBatteryAvailableCapacity(Object powerBatteryAvailableCapacity) { + if (powerBatteryAvailableCapacity!=null) { + this.powerBatteryAvailableCapacity = (String) powerBatteryAvailableCapacity; + } + } + + public Integer getCarStatus() { + return carStatus; + } + + public void setCarStatus(Object carStatus) { + if (carStatus!=null) { + this.carStatus = Integer.valueOf(carStatus.toString()); + } + } + + public Integer getChargingState() { + return chargingState; + } + + public void setChargingState(Object chargingState) { + if (chargingState!=null) { + this.chargingState = Integer.valueOf(chargingState.toString()); + } + } + + public Integer getRunningState() { + return runningState; + } + + public void setRunningState(Object runningState) { + if (runningState!=null) { + this.runningState = Integer.valueOf(runningState.toString()); + } + } + + public String getSoc() { + return soc; + } + + public void setSoc(Object soc) { + if (soc!=null) { + this.soc = (String) soc; + } + } + + public String getWorkingCondition() { + return workingCondition; + } + + public void setWorkingCondition(Object workingCondition) { + if (workingCondition!=null) { + this.workingCondition = (String) workingCondition; + } + } + + public String getDriveMotorCondition() { + return driveMotorCondition; + } + + public void setDriveMotorCondition(Object driveMotorCondition) { + if (driveMotorCondition!=null) { + this.driveMotorCondition = (String) driveMotorCondition; + } + } + + public String getWhetherTheLocationValid() { + return whetherTheLocationValid; + } + + public void setWhetherTheLocationValid(Object whetherTheLocationValid) { + if (whetherTheLocationValid!=null) { + this.whetherTheLocationValid = (String) whetherTheLocationValid; + } + } + + public String getEas() { + return eas; + } + + public void setEas(Object eas) { + if (eas!=null) { + this.eas = (String) eas; + } + } + + public String getPtc() { + return ptc; + } + + public void setPtc(Object ptc) { + if (ptc!=null) { + this.ptc = (String) ptc; + } + } + + public String getEps() { + return eps; + } + + public void setEps(Object eps) { + if (eps!=null) { + this.eps = (String) eps; + } + } + + public String getAbs() { + return abs; + } + + public void setAbs(Object abs) { + if (abs!=null) { + this.abs = (String) abs; + } + } + + public String getMcu() { + return mcu; + } + + public void setMcu(Object mcu) { + if (mcu!=null) { + this.mcu = (String) mcu; + } + } + + public String getPowerBatteryHeatingState() { + return powerBatteryHeatingState; + } + + public void setPowerBatteryHeatingState(Object powerBatteryHeatingState) { + if (powerBatteryHeatingState!=null) { + this.powerBatteryHeatingState = (String) powerBatteryHeatingState; + } + } + + public String getPowerBattery() { + return powerBattery; + } + + public void setPowerBattery(Object powerBattery) { + if (powerBattery!=null) { + this.powerBattery = (String) powerBattery; + } + } + + public String getPowerBatteryInsulationState() { + return powerBatteryInsulationState; + } + + public void setPowerBatteryInsulationState(Object powerBatteryInsulationState) { + if (powerBatteryInsulationState!=null) { + this.powerBatteryInsulationState = (String) powerBatteryInsulationState; + } + } + + public String getDcdc() { + return dcdc; + } + + public void setDcdc(Object dcdc) { + if (dcdc!=null) { + this.dcdc = (String) dcdc; + } + } + + public String getChg() { + return chg; + } + + public void setChg(Object chg) { + if (chg!=null) { + this.chg = (String) chg; + } + } + + public Long getTime() { + return time; + } + + public void setTime(Object time) { + if (time!=null) { + this.time = Long.valueOf(time.toString()); + } + } +} diff --git a/ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/enums/ResponseEnum.java b/src/main/java/com/ruoyi/receive/domain/enums/ResponseEnum.java similarity index 100% rename from ruoyi-receive-common/src/main/java/com/ruoyi/receive/domain/enums/ResponseEnum.java rename to src/main/java/com/ruoyi/receive/domain/enums/ResponseEnum.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/Consumer.java b/src/main/java/com/ruoyi/receive/kafka/config/Consumer.java similarity index 87% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/Consumer.java rename to src/main/java/com/ruoyi/receive/kafka/config/Consumer.java index b373c85..3afe5b2 100644 --- a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/Consumer.java +++ b/src/main/java/com/ruoyi/receive/kafka/config/Consumer.java @@ -21,24 +21,23 @@ import java.util.Properties; @Component public class Consumer { - private final KafkaConsumerConfig kafkaConsumerConfig; + private final KafkaConfig kafkaConfig; private final ConsumerCustomConfig consumerCustomConfig; private final KafkaConsumerService kafkaConsumerService; - public Consumer(KafkaConsumerConfig kafkaConsumerConfig, ConsumerCustomConfig consumerCustomConfig, KafkaConsumerService kafkaConsumerService) { - this.kafkaConsumerConfig = kafkaConsumerConfig; + public Consumer(KafkaConfig kafkaConfig, ConsumerCustomConfig consumerCustomConfig, KafkaConsumerService kafkaConsumerService) { + this.kafkaConfig = kafkaConfig; this.consumerCustomConfig = consumerCustomConfig; this.kafkaConsumerService = kafkaConsumerService; } - @Bean public KafkaConsumer consumerInit(){ //创建kafka消费者配置 Properties properties = new Properties(); - properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,kafkaConsumerConfig.consumerConfigs() ); + properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,kafkaConfig.getHosts() ); properties.put(ConsumerConfig.GROUP_ID_CONFIG,consumerCustomConfig.getGroup()); properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName()); properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,StringDeserializer.class.getName()); diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/ConsumerCustomConfig.java b/src/main/java/com/ruoyi/receive/kafka/config/ConsumerCustomConfig.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/ConsumerCustomConfig.java rename to src/main/java/com/ruoyi/receive/kafka/config/ConsumerCustomConfig.java diff --git a/src/main/java/com/ruoyi/receive/kafka/config/KafkaConfig.java b/src/main/java/com/ruoyi/receive/kafka/config/KafkaConfig.java new file mode 100644 index 0000000..f561693 --- /dev/null +++ b/src/main/java/com/ruoyi/receive/kafka/config/KafkaConfig.java @@ -0,0 +1,28 @@ +package com.ruoyi.receive.kafka.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * kafka config配置类 + */ + +@Data +@Configuration +@ConfigurationProperties(prefix = "kafka.config") +public class KafkaConfig { + + + /** + * 服务地址 + */ + private String hosts; + + /** + * topic + */ + + private String topic; + +} diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaConsumerConfig.java b/src/main/java/com/ruoyi/receive/kafka/config/KafkaConsumerConfig.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaConsumerConfig.java rename to src/main/java/com/ruoyi/receive/kafka/config/KafkaConsumerConfig.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaProviderConfig.java b/src/main/java/com/ruoyi/receive/kafka/config/KafkaProviderConfig.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaProviderConfig.java rename to src/main/java/com/ruoyi/receive/kafka/config/KafkaProviderConfig.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaSendResultHandler.java b/src/main/java/com/ruoyi/receive/kafka/config/KafkaSendResultHandler.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaSendResultHandler.java rename to src/main/java/com/ruoyi/receive/kafka/config/KafkaSendResultHandler.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaSender.java b/src/main/java/com/ruoyi/receive/kafka/config/KafkaSender.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaSender.java rename to src/main/java/com/ruoyi/receive/kafka/config/KafkaSender.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaTopic.java b/src/main/java/com/ruoyi/receive/kafka/config/KafkaTopic.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/KafkaTopic.java rename to src/main/java/com/ruoyi/receive/kafka/config/KafkaTopic.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/MyKafkaListenerErrorHandler.java b/src/main/java/com/ruoyi/receive/kafka/config/MyKafkaListenerErrorHandler.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/MyKafkaListenerErrorHandler.java rename to src/main/java/com/ruoyi/receive/kafka/config/MyKafkaListenerErrorHandler.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/MyPartitioner.java b/src/main/java/com/ruoyi/receive/kafka/config/MyPartitioner.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/kafka/config/MyPartitioner.java rename to src/main/java/com/ruoyi/receive/kafka/config/MyPartitioner.java diff --git a/src/main/java/com/ruoyi/receive/kafka/consumer/KafkaConsumer.java b/src/main/java/com/ruoyi/receive/kafka/consumer/KafkaConsumer.java new file mode 100644 index 0000000..f2fcc63 --- /dev/null +++ b/src/main/java/com/ruoyi/receive/kafka/consumer/KafkaConsumer.java @@ -0,0 +1,42 @@ +package com.ruoyi.receive.kafka.consumer; + +import com.ruoyi.receive.domain.VehicleConstant; + +public class KafkaConsumer { + + + public static boolean checkMessageHandler(String message){ + + if(!message.contains(VehicleConstant.DATA_PACK_SEPARATOR)){ + return false; + } + String temp = message.replaceAll("#\\$&\\*",""); + if(message.indexOf(VehicleConstant.MSG_START) !=0) return false; + if((message.lastIndexOf(VehicleConstant.MSG_END)+2) != temp.length()) return false; + String content = message.substring(2,message.length()-9); + String data = content.replace(" ", ""); + int dSum = 0; + int length = data.length(); + int index = 0; + // 遍历十六进制,并计算总和 + while (index < length) { + // 截取2位字符 + String s = data.substring(index, index + 2); + // 十六进制转成十进制 , 并计算十进制的总和 + dSum += Integer.parseInt(s, 16); + index = index + 2; + } + // 用256取余,十六进制最大是FF,FF的十进制是255 + int mod = dSum % 256; + // 余数转成十六进制 + String checkSumHex = Integer.toHexString(mod); + length = checkSumHex.length(); + if (length < 2) { + // 校验位不足两位的,在前面补0 + checkSumHex = "0" + checkSumHex; + } + String parityBit = message.substring(message.length() - 9,message.length() - 7); + return parityBit.equals(checkSumHex); + } + +} diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/config/Config.java b/src/main/java/com/ruoyi/receive/netty/config/Config.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/config/Config.java rename to src/main/java/com/ruoyi/receive/netty/config/Config.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/config/Constants.java b/src/main/java/com/ruoyi/receive/netty/config/Constants.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/config/Constants.java rename to src/main/java/com/ruoyi/receive/netty/config/Constants.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/handler/NettyServerHandler.java b/src/main/java/com/ruoyi/receive/netty/handler/NettyServerHandler.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/handler/NettyServerHandler.java rename to src/main/java/com/ruoyi/receive/netty/handler/NettyServerHandler.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/server/KafkaConsumerService.java b/src/main/java/com/ruoyi/receive/netty/server/KafkaConsumerService.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/server/KafkaConsumerService.java rename to src/main/java/com/ruoyi/receive/netty/server/KafkaConsumerService.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/server/NettyServer.java b/src/main/java/com/ruoyi/receive/netty/server/NettyServer.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/server/NettyServer.java rename to src/main/java/com/ruoyi/receive/netty/server/NettyServer.java diff --git a/ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/server/ServiceRegistry.java b/src/main/java/com/ruoyi/receive/netty/server/ServiceRegistry.java similarity index 100% rename from ruoyi-receive-server/src/main/java/com/ruoyi/receive/netty/server/ServiceRegistry.java rename to src/main/java/com/ruoyi/receive/netty/server/ServiceRegistry.java diff --git a/src/main/java/com/ruoyi/receive/netty/server/impl/KafkaConsumerServiceImpl.java b/src/main/java/com/ruoyi/receive/netty/server/impl/KafkaConsumerServiceImpl.java new file mode 100644 index 0000000..1d2c403 --- /dev/null +++ b/src/main/java/com/ruoyi/receive/netty/server/impl/KafkaConsumerServiceImpl.java @@ -0,0 +1,34 @@ +package com.ruoyi.receive.netty.server.impl; + +import com.ruoyi.receive.domain.VehicleMessage; +import com.ruoyi.receive.kafka.consumer.KafkaConsumer; +import com.ruoyi.receive.netty.server.KafkaConsumerService; +import lombok.extern.log4j.Log4j2; +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.springframework.stereotype.Service; + +@Log4j2 +@Service +public class KafkaConsumerServiceImpl implements KafkaConsumerService { + + @Override + public void service(ConsumerRecords records) { + + for (ConsumerRecord record : records){ + log.info("消息:key:{},msg:{}",record.key(),record.value()); + + String vehicleMessage = record.value(); + + boolean checkMessageHandler = KafkaConsumer.checkMessageHandler(vehicleMessage); + + if (checkMessageHandler){ + VehicleMessage message = new VehicleMessage(); + }else { + throw new RuntimeException("解析错误"); + } + + } + + } +} diff --git a/src/main/java/com/ruoyi/receive/service/MessageContext.java b/src/main/java/com/ruoyi/receive/service/MessageContext.java new file mode 100644 index 0000000..37c1d29 --- /dev/null +++ b/src/main/java/com/ruoyi/receive/service/MessageContext.java @@ -0,0 +1,52 @@ +package com.ruoyi.receive.service; + +import com.ruoyi.common.core.utils.SpringUtils; +import com.ruoyi.common.redis.service.RedisService; +import com.ruoyi.receive.domain.VehicleMessage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.PostMapping; + +import javax.annotation.PostConstruct; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 消息处理上下文 + */ +@Component +public class MessageContext { + + @Autowired + private RedisService redisService; + + private Map messageServiceMap = new HashMap<>(); + + + + @PostConstruct + private void init(){ + List allMessageServiceKeyList = redisService.getCacheObject("消息处理的key"); + allMessageServiceKeyList.forEach(allMessageServiceKey ->{ + MessageService messageService = SpringUtils.getBean(allMessageServiceKey); + messageServiceMap.put(allMessageServiceKey,messageService); + }); + } + + public void handler(VehicleMessage message){ + String vinCode = message.getVinCode(); + + List analysisList = redisService.getCacheList("msg:analysis:" + vinCode); + + analysisList.forEach(analysis ->{ + MessageService messageService = messageServiceMap.get(analysis); + messageService.excetion(message); + }); + + + + } + +} + diff --git a/src/main/java/com/ruoyi/receive/service/MessageService.java b/src/main/java/com/ruoyi/receive/service/MessageService.java new file mode 100644 index 0000000..bc5e7d3 --- /dev/null +++ b/src/main/java/com/ruoyi/receive/service/MessageService.java @@ -0,0 +1,16 @@ +package com.ruoyi.receive.service; + +import com.ruoyi.receive.domain.VehicleMessage; + +/** + * 报文处理基准 + */ +public interface MessageService { + + /** + * 车辆解析 + * @param message + */ + public void excetion(VehicleMessage message); + +} diff --git a/src/main/java/com/ruoyi/receive/service/impl/MessageGuZhangServiceImpl.java b/src/main/java/com/ruoyi/receive/service/impl/MessageGuZhangServiceImpl.java new file mode 100644 index 0000000..cf7859e --- /dev/null +++ b/src/main/java/com/ruoyi/receive/service/impl/MessageGuZhangServiceImpl.java @@ -0,0 +1,18 @@ +package com.ruoyi.receive.service.impl; + +import com.ruoyi.receive.domain.VehicleMessage; +import com.ruoyi.receive.service.MessageService; +import org.springframework.stereotype.Service; + +/** + * 故障 + */ +@Service("guzhang") +public class MessageGuZhangServiceImpl implements MessageService { + + + @Override + public void excetion(VehicleMessage message) { + + } +} diff --git a/src/main/java/com/ruoyi/receive/service/impl/MessageShiShiServiceImpl.java b/src/main/java/com/ruoyi/receive/service/impl/MessageShiShiServiceImpl.java new file mode 100644 index 0000000..0204e5d --- /dev/null +++ b/src/main/java/com/ruoyi/receive/service/impl/MessageShiShiServiceImpl.java @@ -0,0 +1,18 @@ +package com.ruoyi.receive.service.impl; + +import com.ruoyi.receive.domain.VehicleMessage; +import com.ruoyi.receive.service.MessageService; +import org.springframework.stereotype.Service; + +/** + * 实时数据 + */ +@Service("shishi") +public class MessageShiShiServiceImpl implements MessageService { + + + @Override + public void excetion(VehicleMessage message) { + + } +} diff --git a/src/main/java/com/ruoyi/receive/service/impl/MessageWeiLanServiceImpl.java b/src/main/java/com/ruoyi/receive/service/impl/MessageWeiLanServiceImpl.java new file mode 100644 index 0000000..10a8138 --- /dev/null +++ b/src/main/java/com/ruoyi/receive/service/impl/MessageWeiLanServiceImpl.java @@ -0,0 +1,18 @@ +package com.ruoyi.receive.service.impl; + +import com.ruoyi.receive.domain.VehicleMessage; +import com.ruoyi.receive.service.MessageService; +import org.springframework.stereotype.Service; + +/** + * 电子围栏 + */ +@Service("weilan") +public class MessageWeiLanServiceImpl implements MessageService { + + + @Override + public void excetion(VehicleMessage message) { + + } +} diff --git a/src/main/java/com/ruoyi/receive/service/impl/MessageYuJingServiceImpl.java b/src/main/java/com/ruoyi/receive/service/impl/MessageYuJingServiceImpl.java new file mode 100644 index 0000000..95e751b --- /dev/null +++ b/src/main/java/com/ruoyi/receive/service/impl/MessageYuJingServiceImpl.java @@ -0,0 +1,18 @@ +package com.ruoyi.receive.service.impl; + +import com.ruoyi.receive.domain.VehicleMessage; +import com.ruoyi.receive.service.MessageService; +import org.springframework.stereotype.Service; + +/** + * 预警 + */ +@Service("yujing") +public class MessageYuJingServiceImpl implements MessageService { + + + @Override + public void excetion(VehicleMessage message) { + + } +} diff --git a/ruoyi-receive-server/src/main/resources/banner.txt b/src/main/resources/banner.txt similarity index 100% rename from ruoyi-receive-server/src/main/resources/banner.txt rename to src/main/resources/banner.txt diff --git a/ruoyi-receive-server/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml similarity index 100% rename from ruoyi-receive-server/src/main/resources/bootstrap.yml rename to src/main/resources/bootstrap.yml diff --git a/ruoyi-receive-server/src/main/resources/logback.xml b/src/main/resources/logback.xml similarity index 100% rename from ruoyi-receive-server/src/main/resources/logback.xml rename to src/main/resources/logback.xml diff --git a/ruoyi-receive-server/src/main/resources/templates/index.html b/src/main/resources/templates/index.html similarity index 100% rename from ruoyi-receive-server/src/main/resources/templates/index.html rename to src/main/resources/templates/index.html