瀏覽代碼

自动切枪

jek 2 月之前
父節點
當前提交
597c1ede8f

+ 6 - 0
src/main/java/com/zhili/stationserver/component/KafkaMessageHandler.java

@@ -149,6 +149,12 @@ public class KafkaMessageHandler {
             chargeStopDto.setGunNo(dto.getGunNo());
             chargeStopDto.setChgType(dto.getChgType());
             sendToChannel(dto.getStationConnInfo().getConnIdStr(), chargeStopDto);
+        }else if ("autoCharge".equals(dto.getType())) {
+            ChargeStopDto chargeStopDto = new ChargeStopDto();
+            chargeStopDto.setChargerId(dto.getChargerId());
+            chargeStopDto.setGunNo(dto.getGunNo());
+            chargeStopDto.setChgType(dto.getChgType());
+            sendToChannel(dto.getStationConnInfo().getConnIdStr(), chargeStopDto);
         }
         ack.acknowledge();
     }

+ 21 - 0
src/main/java/com/zhili/stationserver/dto/ChargeAutoDto.java

@@ -0,0 +1,21 @@
+package com.zhili.stationserver.dto;
+
+import com.zhili.stationserver.annotation.ProtocalTranform;
+import com.zhili.stationserver.annotation.TransformField;
+import lombok.Data;
+
+import static com.zhili.stationserver.constant.TransformType.UINT_TYPE;
+
+/**
+ * @author jek
+ */
+@Data
+@ProtocalTranform(command = StationMessage.CommandType.AUTO_CHARGE, size = 3)
+public class ChargeAutoDto {
+    @TransformField(start = 0, type = UINT_TYPE)
+    Integer chargerId;
+    @TransformField(start = 1, type = UINT_TYPE)
+    Integer gunNo;
+    @TransformField(start = 2, type = UINT_TYPE)
+    Integer chgType;
+}

+ 27 - 0
src/main/java/com/zhili/stationserver/dto/ChargeAutoReply.java

@@ -0,0 +1,27 @@
+package com.zhili.stationserver.dto;
+
+import com.zhili.stationserver.annotation.ProtocalTranform;
+import com.zhili.stationserver.annotation.TransformField;
+import lombok.Data;
+
+import static com.zhili.stationserver.constant.TransformType.STRING_TYPE;
+import static com.zhili.stationserver.constant.TransformType.UINT_TYPE;
+
+/**
+ * @author jek
+ */
+@Data
+@ProtocalTranform(command = StationMessage.CommandType.AUTO_CHARGE_REPLY, size = 33)
+public class ChargeAutoReply {
+    String stationCode;
+    String type;
+    @TransformField(start = 0, type = UINT_TYPE)
+    private Integer chargerId;
+    @TransformField(start = 1, type = UINT_TYPE)
+    private Integer gunNo;
+    // 0-成功 1-失败
+    @TransformField(start = 2, type = UINT_TYPE)
+    private Integer state;
+    @TransformField(start = 3, type = STRING_TYPE,length = 30)
+    private String msg;
+}

+ 2 - 0
src/main/java/com/zhili/stationserver/dto/StationMessage.java

@@ -43,5 +43,7 @@ public class StationMessage {
         public static final int STOP_CHARGE_REPLY = 308;
         public static final int EXCHANGE_RECORD = 501;
         public static final int EXCHANGE_RECORD_REPLY = 502;
+        public static final int AUTO_CHARGE = 309;
+        public static final int AUTO_CHARGE_REPLY = 310;
     }
 }