Browse Source

数据优化

jek 1 năm trước cách đây
mục cha
commit
55dcb12544

+ 7 - 1
src/main/java/com/zhili/zkstationserver/component/KafkaMessageHandler.java

@@ -34,9 +34,15 @@ public class KafkaMessageHandler {
         log.info("KafkaMessageHandler PostConstruct:" + serverConfig);
     }
 
+    /**
+     * 启动换电
+     * @param record
+     * @param ack
+     * @throws UnsupportedEncodingException
+     */
     @KafkaListener(topics = {"#{serverConfig.getInstanceId()}"}, groupId = "#{serverConfig.getServiceName()}")
     public void processExchangeEvent(ConsumerRecord<String, String> record, Acknowledgment ack) throws UnsupportedEncodingException {
-        log.info("recv************:"+record.value());
+        //log.info("recv************:"+record.value());
         StationControlEvent stationControlEvent = JSON.parseObject(record.value(), StationControlEvent.class);
         if(stationControlEvent.getType().equals("startExchange")){
             StationMessage stationMessage = new StationMessage();

+ 21 - 21
src/main/java/com/zhili/zkstationserver/dto/ExchangeEvent.java

@@ -31,14 +31,14 @@ public class ExchangeEvent {
     Float sourceSoh;
     Float sourceVol;
     Float sourceCur;
-    Integer sourceTotalMiletage;
+    Float sourceTotalMiletage;
     Integer targetIndex;
     String targetSn;
     Float targetRatedEnergy;
     Float targetSoc;
     Float targetSoh;
-    Float frontDistance;
-    Float batteryHeight;
+    Integer frontDistance;
+    Integer batteryHeight;
     String timeStr;
     Integer step;
     Integer startSource;
@@ -73,24 +73,24 @@ public class ExchangeEvent {
         vin = BytesUtil.parseString(ArrayUtils.subarray(data, 86, 103));
         model = BytesUtil.deUnicode(ArrayUtils.subarray(data, 103, 119));
         sourceSn = BytesUtil.parseStringZero(ArrayUtils.subarray(data, 119, 146));
-        sourceRatedEnergy = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 146, 148)) * 0.1f;
-        sourceSoc = Byte.toUnsignedInt(data[148]) * 0.4f;
-        sourceSoh = Byte.toUnsignedInt(data[149]) * 0.4f;
-        sourceVol = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 150, 152)) * 0.1f;
-        sourceCur = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 152, 154)) * 0.1f - 1000f;
-        sourceTotalMiletage = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 154, 158));
-        targetIndex = Byte.toUnsignedInt(data[158]);
-        targetSn = BytesUtil.parseString(ArrayUtils.subarray(data, 159, 186));
-        targetRatedEnergy = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 186, 188)) * 0.1f;
-        targetSoc = Byte.toUnsignedInt(data[188]) * 0.4f;
-        targetSoh = Byte.toUnsignedInt(data[189]) * 0.4f;
-        frontDistance = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 190, 194)) * 0.0001f;
-        batteryHeight = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 194, 198)) * 0.0001f;
-        timeStr = BytesUtil.composeTimeString(ArrayUtils.subarray(data, 198, 206));
-        step = Byte.toUnsignedInt(data[206]);
-        startSource = Byte.toUnsignedInt(data[207]);
-        powerState = Byte.toUnsignedInt(data[208]);
-        lockState = Byte.toUnsignedInt(data[209]);
+        sourceRatedEnergy = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 146, 150)) * 0.2f / 100;
+        sourceSoc = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 150, 154)) * 0.2f / 100;
+        sourceSoh = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 154, 158)) * 0.2f / 100;
+        sourceVol = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 158, 162)) * 0.2f / 100;
+        sourceCur = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 162, 166)) * 0.2f / 100 - 1000f;
+        sourceTotalMiletage = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 166, 170)) * 0.2f / 100;
+        targetIndex = Byte.toUnsignedInt(data[170]);
+        targetSn = BytesUtil.parseString(ArrayUtils.subarray(data, 171, 198));
+        targetRatedEnergy = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 198, 202)) * 0.2f / 100;
+        targetSoc = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 202, 206)) * 0.2f / 100;
+        targetSoh = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 206, 210)) * 0.2f / 100;
+        frontDistance = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 210, 214));
+        batteryHeight = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 214, 218));
+        timeStr = BytesUtil.composeTimeString(ArrayUtils.subarray(data, 218, 226));
+        step = Byte.toUnsignedInt(data[226]);
+        startSource = Byte.toUnsignedInt(data[227]);
+        powerState = Byte.toUnsignedInt(data[228]);
+        lockState = Byte.toUnsignedInt(data[229]);
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date timeD = null;
         try {

+ 12 - 12
src/main/java/com/zhili/zkstationserver/dto/ExchangeRecordInfo.java

@@ -67,18 +67,18 @@ public class ExchangeRecordInfo {
         driverPhone = BytesUtil.parseString(ArrayUtils.subarray(data, 181, 192));
         sourceBatterySn = BytesUtil.parseString(ArrayUtils.subarray(data, 192, 219));
         targetBatterySn = BytesUtil.parseString(ArrayUtils.subarray(data, 219, 246));
-        sourceCapacity = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 246, 248)) * 0.1f;
-        targetCapacity = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 248, 250)) * 0.1f;
-        sourceSoc = Byte.toUnsignedInt(data[250]) * 0.4f;
-        targetSoc = Byte.toUnsignedInt(data[251]) * 0.4f;
-        sourceSoh = Byte.toUnsignedInt(data[252]) * 0.4f;
-        targetSoh = Byte.toUnsignedInt(data[253]) * 0.4f;
-        exchangePower = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 254, 258)) * 0.4f;
-        powerFee = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 258, 262)) * 0.2f;
-        serviceFee = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 262, 266)) * 0.2f;
-        startTime = BytesUtil.composeTimeString(ArrayUtils.subarray(data, 266, 274));
-        endTime = BytesUtil.composeTimeString(ArrayUtils.subarray(data, 274, 282));
-        startSource =  Byte.toUnsignedInt(data[282]);
+        sourceCapacity = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 246, 250)) * 0.2f / 100;
+        targetCapacity = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 250, 254)) * 0.2f / 100;
+        sourceSoc = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 254, 258)) * 0.2f / 100;
+        targetSoc = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 258, 262)) * 0.2f / 100;
+        sourceSoh = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 262, 266)) * 0.2f / 100;
+        targetSoh = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 266, 270)) * 0.2f / 100;
+        exchangePower = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 270, 274)) * 0.2f / 100;
+        powerFee = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 274, 278)) * 0.2f / 100;
+        serviceFee = BytesUtil.toIntWithLowerFirst(ArrayUtils.subarray(data, 278, 282)) * 0.2f / 100;
+        startTime = BytesUtil.composeTimeString(ArrayUtils.subarray(data, 282, 290));
+        endTime = BytesUtil.composeTimeString(ArrayUtils.subarray(data, 290, 298));
+        startSource =  Byte.toUnsignedInt(data[298]);
     }
 
 }