Commit efae680578d8d0083c1b29db8c9d0985c70e15d1
1 parent
47908511
1.zyl接口加入电量信息
Showing
3 changed files
with
342 additions
and
0 deletions
src/main/java/com/bsth/entity/Data.java
0 → 100644
src/main/java/com/bsth/entity/VehicleData.java
0 → 100644
| 1 | +package com.bsth.entity; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| 4 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
| 5 | +import com.fasterxml.jackson.annotation.JsonProperty; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * @author Hill | ||
| 9 | + * 整车数据 | ||
| 10 | + */ | ||
| 11 | +@JsonIgnoreProperties(ignoreUnknown = true) | ||
| 12 | +public class VehicleData extends Data { | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 车辆状态 | ||
| 16 | + * 0x01 车辆启动 | ||
| 17 | + * 0x02 车辆熄火 | ||
| 18 | + * 0x03 其它 | ||
| 19 | + * 0xFE 异常 | ||
| 20 | + * 0xFF 无效 | ||
| 21 | + */ | ||
| 22 | + private byte vehicleState; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 充电状态 | ||
| 26 | + * 0x01 停车充电 | ||
| 27 | + * 0x02 行驶充电 | ||
| 28 | + * 0x03 未充电 | ||
| 29 | + * 0x04 充电完成 | ||
| 30 | + * 0xFE 异常 | ||
| 31 | + * 0xFF 无效 | ||
| 32 | + */ | ||
| 33 | + private byte chargeState; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 运行模式 | ||
| 37 | + * 0x01 纯电 | ||
| 38 | + * 0x02 混动 | ||
| 39 | + * 0x03 燃油 | ||
| 40 | + * 0xFE 异常 | ||
| 41 | + * 0xFF 无效 | ||
| 42 | + */ | ||
| 43 | + private byte runMode; | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * 车速 0-2200 | ||
| 47 | + * 分辨率0.1km/h | ||
| 48 | + * 0xff 0xfe 异常 | ||
| 49 | + * 0xff 0xff 无效 | ||
| 50 | + */ | ||
| 51 | + private short speed; | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * 累计里程 0-9999999 | ||
| 55 | + * 分辨率0.1km/h | ||
| 56 | + * 0xff 0xff 0xff 0xfe 异常 | ||
| 57 | + * 0xff 0xff 0xff 0xff 无效 | ||
| 58 | + */ | ||
| 59 | + private int totalMiles; | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 总电压 0-10000 | ||
| 63 | + * 分辨率0.1v | ||
| 64 | + * 0xff 0xfe 异常 | ||
| 65 | + * 0xff 0xff 无效 | ||
| 66 | + */ | ||
| 67 | + private short totalVoltage; | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * 总电流 0-20000 | ||
| 71 | + * 分辨率0.1a | ||
| 72 | + * 0xff 0xfe 异常 | ||
| 73 | + * 0xff 0xff 无效 | ||
| 74 | + */ | ||
| 75 | + private short totalCurrent; | ||
| 76 | + | ||
| 77 | + /** | ||
| 78 | + * soc 0-100% | ||
| 79 | + * 分辨率1% | ||
| 80 | + * 0xFE 异常 | ||
| 81 | + * 0xFF 无效 | ||
| 82 | + */ | ||
| 83 | + private byte soc; | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * dc-dc状态 | ||
| 87 | + * 0x01 工作 | ||
| 88 | + * 0x02 断开 | ||
| 89 | + * 0xFE 异常 | ||
| 90 | + * 0xFF 无效 | ||
| 91 | + */ | ||
| 92 | + private byte dcState; | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * 挡位 | ||
| 96 | + */ | ||
| 97 | + @JsonIgnore | ||
| 98 | + private byte gear; | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * 驱动力 | ||
| 102 | + */ | ||
| 103 | + private boolean drivingForce; | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * 制动力 | ||
| 107 | + */ | ||
| 108 | + private boolean brakingForce; | ||
| 109 | + | ||
| 110 | + /** | ||
| 111 | + * 挡位(json) | ||
| 112 | + */ | ||
| 113 | + @JsonProperty("gear") | ||
| 114 | + private byte gear1; | ||
| 115 | + | ||
| 116 | + /** | ||
| 117 | + * 绝缘电阻 0-60000 | ||
| 118 | + * 分辨率 1k欧 | ||
| 119 | + */ | ||
| 120 | + private int insulationResistance; | ||
| 121 | + | ||
| 122 | + /** | ||
| 123 | + * 加速踏板行程值 0-100% | ||
| 124 | + * 分辨率1% | ||
| 125 | + * 0xFE 异常 | ||
| 126 | + * 0xFF 无效 | ||
| 127 | + */ | ||
| 128 | + private byte acceleratorState; | ||
| 129 | + | ||
| 130 | + /** | ||
| 131 | + * 制动踏板状态 0-100% | ||
| 132 | + * 分辨率1% 在无具体行程值情况下,用“101”表示制动有效状态 | ||
| 133 | + * 0xFE 异常 | ||
| 134 | + * 0xFF 无效 | ||
| 135 | + */ | ||
| 136 | + private byte brakePedalState; | ||
| 137 | + | ||
| 138 | + public VehicleData() { | ||
| 139 | + | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + public byte getVehicleState() { | ||
| 143 | + return vehicleState; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + public void setVehicleState(byte vehicleState) { | ||
| 147 | + this.vehicleState = vehicleState; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + public byte getChargeState() { | ||
| 151 | + return chargeState; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + public void setChargeState(byte chargeState) { | ||
| 155 | + this.chargeState = chargeState; | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + public byte getRunMode() { | ||
| 159 | + return runMode; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + public void setRunMode(byte runMode) { | ||
| 163 | + this.runMode = runMode; | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + public short getSpeed() { | ||
| 167 | + return speed; | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + public void setSpeed(short speed) { | ||
| 171 | + this.speed = speed; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + public int getTotalMiles() { | ||
| 175 | + return totalMiles; | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + public void setTotalMiles(int totalMiles) { | ||
| 179 | + this.totalMiles = totalMiles; | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + public short getTotalVoltage() { | ||
| 183 | + return totalVoltage; | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + public void setTotalVoltage(short totalVoltage) { | ||
| 187 | + this.totalVoltage = totalVoltage; | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + public short getTotalCurrent() { | ||
| 191 | + return totalCurrent; | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + public void setTotalCurrent(short totalCurrent) { | ||
| 195 | + this.totalCurrent = totalCurrent; | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + public byte getSoc() { | ||
| 199 | + return soc; | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + public void setSoc(byte soc) { | ||
| 203 | + this.soc = soc; | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + public byte getDcState() { | ||
| 207 | + return dcState; | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + public void setDcState(byte dcState) { | ||
| 211 | + this.dcState = dcState; | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + public byte getGear() { | ||
| 215 | + return gear; | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + public void setGear(byte gear) { | ||
| 219 | + this.gear = gear; | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + public boolean isDrivingForce() { | ||
| 223 | + return drivingForce; | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + public void setDrivingForce(boolean drivingForce) { | ||
| 227 | + this.drivingForce = drivingForce; | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + public boolean isBrakingForce() { | ||
| 231 | + return brakingForce; | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + public void setBrakingForce(boolean brakingForce) { | ||
| 235 | + this.brakingForce = brakingForce; | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + public byte getGear1() { | ||
| 239 | + return gear1; | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + public void setGear1(byte gear1) { | ||
| 243 | + this.gear1 = gear1; | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + public int getInsulationResistance() { | ||
| 247 | + return insulationResistance; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + public void setInsulationResistance(int insulationResistance) { | ||
| 251 | + this.insulationResistance = insulationResistance; | ||
| 252 | + } | ||
| 253 | + | ||
| 254 | + public byte getAcceleratorState() { | ||
| 255 | + return acceleratorState; | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + public void setAcceleratorState(byte acceleratorState) { | ||
| 259 | + this.acceleratorState = acceleratorState; | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + public byte getBrakePedalState() { | ||
| 263 | + return brakePedalState; | ||
| 264 | + } | ||
| 265 | + | ||
| 266 | + public void setBrakePedalState(byte brakePedalState) { | ||
| 267 | + this.brakePedalState = brakePedalState; | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + @Override | ||
| 271 | + public String toString() { | ||
| 272 | + StringBuilder sb = new StringBuilder(); | ||
| 273 | + sb.append("车辆状态: ").append(vehicleState) | ||
| 274 | + .append(" 充电状态: ").append(chargeState) | ||
| 275 | + .append(" 运行模式: ").append(runMode) | ||
| 276 | + .append(" 车速: ").append(speed) | ||
| 277 | + .append(" 累计里程: ").append(totalMiles) | ||
| 278 | + .append(" 总电压: ").append(totalVoltage) | ||
| 279 | + .append(" 总电流: ").append(totalCurrent) | ||
| 280 | + .append(" soc: ").append(soc) | ||
| 281 | + .append(" dc-dc状态: ").append(dcState) | ||
| 282 | + .append(" 挡位: ").append(gear) | ||
| 283 | + .append(" 绝缘电阻: ").append(insulationResistance) | ||
| 284 | + .append(" 加速踏板行程值: ").append(acceleratorState) | ||
| 285 | + .append(" 制动踏板状态: ").append(brakePedalState); | ||
| 286 | + | ||
| 287 | + return sb.toString(); | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + @Override | ||
| 291 | + public String getType() { | ||
| 292 | + return "vehicle_data"; | ||
| 293 | + } | ||
| 294 | +} |
src/main/java/com/bsth/server_rs/gps/buffer/VehicleRealDataBuffer.java
0 → 100644
| 1 | +package com.bsth.server_rs.gps.buffer; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.VehicleData; | ||
| 4 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 5 | +import org.springframework.kafka.annotation.KafkaListener; | ||
| 6 | +import org.springframework.messaging.Message; | ||
| 7 | +import org.springframework.stereotype.Component; | ||
| 8 | + | ||
| 9 | +import java.io.IOException; | ||
| 10 | +import java.util.HashMap; | ||
| 11 | +import java.util.Map; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * @author Hill | ||
| 15 | + */ | ||
| 16 | +@Component | ||
| 17 | +public class VehicleRealDataBuffer { | ||
| 18 | + | ||
| 19 | + private static Map<String, VehicleData> VIN_VECHICLE = new HashMap<>(); | ||
| 20 | + | ||
| 21 | + private ObjectMapper mapper = new ObjectMapper(); | ||
| 22 | + | ||
| 23 | + @KafkaListener(topics="LGGJ_ELEC_VEHICLE") | ||
| 24 | + public void handle(Message<String> message) throws IOException { | ||
| 25 | + String json = message.getPayload(); | ||
| 26 | + Map<String, Object> map = mapper.readValue(json, Map.class); | ||
| 27 | + String vin = (String) map.get("vin"); | ||
| 28 | + Object vehicleData = map.get("vehicle_data"); | ||
| 29 | + VIN_VECHICLE.put(vin, mapper.convertValue(vehicleData, VehicleData.class)); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public static VehicleData getVehicleData(String vin) { | ||
| 33 | + return VIN_VECHICLE.get(vin); | ||
| 34 | + } | ||
| 35 | +} |