jek 1 month ago
parent
commit
687be1953f

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

@@ -150,11 +150,11 @@ public class KafkaMessageHandler {
             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);
+            AutoChargeDto autoChargeDto = new AutoChargeDto();
+            autoChargeDto.setChargerId(dto.getChargerId());
+            autoChargeDto.setGunNo(dto.getGunNo());
+            autoChargeDto.setChgType(dto.getChgType());
+            sendToChannel(dto.getStationConnInfo().getConnIdStr(), autoChargeDto);
         }
         ack.acknowledge();
     }

+ 12 - 1
src/main/java/com/zhili/stationserver/component/stationserver/handler/StationMessageHandler.java

@@ -163,7 +163,7 @@ public class StationMessageHandler extends ChannelInboundHandlerAdapter {
             PerceptionUploadAvailableBatsDto dto = parse(stationMessage, PerceptionUploadAvailableBatsDto.class);
             dto.setStationCode(stationCode);
             String topic = serverConfig.getServiceCenterName() + "_PERCEPTION_BAT_AVAILABLE";
-            log.info("================可用电池数:{}",dto);
+            //log.info("================可用电池数:{}",dto);
             kafkaTemplate.send(topic, JSON.toJSONString(dto));
         } else if (command.equals(StationMessage.CommandType.PERCEPTION_PLC)) {
             //plc感知
@@ -272,6 +272,17 @@ public class StationMessageHandler extends ChannelInboundHandlerAdapter {
             chargeStopReply.setType("stopChargeReply");
             String topic = serverConfig.getServiceCenterName() + "_CHARGER_REPLY";
             kafkaTemplate.send(topic, JSON.toJSONString(chargeStopReply));
+        }else if (command.equals(StationMessage.CommandType.AUTO_CHARGE_REPLY)) {
+            String stationCode = StationCenter.getStation(ctx.channel());
+            if (StringUtils.isBlank(stationCode)) {
+                return;
+            }
+            AutoChargeReply autoChargeReply = parse(stationMessage, AutoChargeReply.class);
+            log.info("小程自动切枪电回复:{}",autoChargeReply);
+            autoChargeReply.setStationCode(stationCode);
+            autoChargeReply.setType("autoChargeReply");
+            String topic = serverConfig.getServiceCenterName() + "_CHARGER_REPLY";
+            kafkaTemplate.send(topic, JSON.toJSONString(autoChargeReply));
         }
     }
 

+ 34 - 0
src/main/java/com/zhili/stationserver/dto/AutoChargeDto.java

@@ -0,0 +1,34 @@
+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.*;
+
+/**
+ * @author jek
+ */
+@Data
+@ProtocalTranform(command = StationMessage.CommandType.AUTO_CHARGE, size = 69)
+public class AutoChargeDto {
+
+    @TransformField(start = 0, type = UINT_TYPE)
+    Integer chargerId;
+    @TransformField(start = 1, type = UINT_TYPE, length = 2)
+    Integer userId;
+    @TransformField(start = 3, type = UINT_TYPE)
+    Integer gunNo;
+    @TransformField(start = 4, type = UINT_TYPE)
+    Integer strategy;
+    @TransformField(start = 5, type = FLOAT_TYPE, length = 2)
+    Float strategyParam;
+    @TransformField(start = 7, type = UINT_TYPE)
+    Integer chgType;
+    @TransformField(start = 8, type = STRING_TYPE, length = 27)
+    String sn;
+    @TransformField(start = 35, type = UINT_TYPE, length = 2)
+    Integer fleetId;
+    @TransformField(start = 37, type = STRING_TYPE, length = 32)
+    String orderId;
+}

+ 27 - 0
src/main/java/com/zhili/stationserver/dto/AutoChargeReply.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 AutoChargeReply {
+    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;
+}