Commit d54a7a66 by zhangxk

修改字符编码为GBK

1 parent e3b9e586
...@@ -9,6 +9,7 @@ import com.viontech.utils.IntUtils; ...@@ -9,6 +9,7 @@ import com.viontech.utils.IntUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.ParseException; import java.text.ParseException;
import java.util.Base64; import java.util.Base64;
...@@ -97,11 +98,11 @@ public class BehaviorProcess implements Process { ...@@ -97,11 +98,11 @@ public class BehaviorProcess implements Process {
} }
String locationName = location.getString("name"); String locationName = location.getString("name");
if (locationName != null) { if (locationName != null) {
byte[] locationNameBytes = locationName.getBytes(StandardCharsets.UTF_8); byte[] locationNameBytes = locationName.getBytes(Charset.forName("GBK"));
System.arraycopy(locationNameBytes, 0, model.getEventLocation(), 0, Math.min(locationNameBytes.length, 32)); System.arraycopy(locationNameBytes, 0, model.getEventLocation(), 0, Math.min(locationNameBytes.length, 32));
} }
// todo 录像路径 // todo 录像路径
byte[] videoPathBytes = "testVideoPath".getBytes(StandardCharsets.UTF_8); byte[] videoPathBytes = "testVideoPath".getBytes(Charset.forName("GBK"));
System.arraycopy(videoPathBytes, 0, model.getEventSnapshotPath(), 0, videoPathBytes.length); System.arraycopy(videoPathBytes, 0, model.getEventSnapshotPath(), 0, videoPathBytes.length);
} }
...@@ -119,7 +120,7 @@ public class BehaviorProcess implements Process { ...@@ -119,7 +120,7 @@ public class BehaviorProcess implements Process {
if (plate != null) { if (plate != null) {
String text = plate.getString("text"); String text = plate.getString("text");
if (text != null && !"".equals(text)) { if (text != null && !"".equals(text)) {
byte[] bytes = text.getBytes(StandardCharsets.UTF_8); byte[] bytes = text.getBytes(Charset.forName("GBK"));
System.arraycopy(bytes, 0, model.getLicensePlateText(), 0, Math.min(bytes.length, model.getLicensePlateText().length)); System.arraycopy(bytes, 0, model.getLicensePlateText(), 0, Math.min(bytes.length, model.getLicensePlateText().length));
} }
} }
......
...@@ -10,6 +10,7 @@ import com.viontech.utils.IntUtils; ...@@ -10,6 +10,7 @@ import com.viontech.utils.IntUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.ParseException; import java.text.ParseException;
import java.util.Base64; import java.util.Base64;
...@@ -95,7 +96,7 @@ public class TrafficProcess implements Process { ...@@ -95,7 +96,7 @@ public class TrafficProcess implements Process {
} catch (Exception ignore) { } catch (Exception ignore) {
} }
// ftpClientHelper.storeFile(filePath, bytes); // ftpClientHelper.storeFile(filePath, bytes);
byte[] videoPathBytes = filePath.getBytes(StandardCharsets.UTF_8); byte[] videoPathBytes = filePath.getBytes(Charset.forName("GBK"));
System.arraycopy(videoPathBytes, 0, model.getVideoPath(), 0, videoPathBytes.length); System.arraycopy(videoPathBytes, 0, model.getVideoPath(), 0, videoPathBytes.length);
} }
} }
...@@ -145,7 +146,7 @@ public class TrafficProcess implements Process { ...@@ -145,7 +146,7 @@ public class TrafficProcess implements Process {
JSONObject plate = vehicle.getJSONObject("plate"); JSONObject plate = vehicle.getJSONObject("plate");
// ----------------- 车牌 ------------------ // ----------------- 车牌 ------------------
if (plate != null) { if (plate != null) {
byte[] text = plate.getString("text").getBytes(StandardCharsets.UTF_8); byte[] text = plate.getString("text").getBytes(Charset.forName("GBK"));
System.arraycopy(text, 0, model.getPlateText(), 0, Math.min(text.length, 16)); System.arraycopy(text, 0, model.getPlateText(), 0, Math.min(text.length, 16));
// todo 车牌类型待实现 // todo 车牌类型待实现
model.setPlateType(1); model.setPlateType(1);
...@@ -204,7 +205,7 @@ public class TrafficProcess implements Process { ...@@ -204,7 +205,7 @@ public class TrafficProcess implements Process {
model.setDirection(directionCode); model.setDirection(directionCode);
} }
String locationName = location.getString("name"); String locationName = location.getString("name");
byte[] locationNameBytes = locationName.getBytes(StandardCharsets.UTF_8); byte[] locationNameBytes = locationName.getBytes(Charset.forName("GBK"));
System.arraycopy(locationNameBytes, 0, model.getRouteLocation(), 0, Math.min(locationNameBytes.length, 32)); System.arraycopy(locationNameBytes, 0, model.getRouteLocation(), 0, Math.min(locationNameBytes.length, 32));
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!