|
@@ -286,9 +286,9 @@ public class VehicleService {
|
|
|
String frontWheelSuspensionKinematicsCoefficient = par.substring(par.indexOf("R_US_STR")).split("\\s")[1];
|
|
|
String rearWheelSuspensionKinematicsCoefficient = par.substring(par.lastIndexOf("R_US_STR")).split("\\s")[1];
|
|
|
String frontWheelUnsprungMassAll = par.substring(par.indexOf("#FullDataName Suspension: Independent System Kinematics`C-Class, Hatchback - Front`C-Class"));
|
|
|
- String frontWheelUnsprungMass = frontWheelUnsprungMassAll.substring(rreAll.indexOf("M_US")).split("\\s")[1];
|
|
|
+ String frontWheelUnsprungMass = frontWheelUnsprungMassAll.substring(frontWheelUnsprungMassAll.indexOf("M_US")).split("\\s")[1];
|
|
|
String rearWheelUnsprungMassAll = par.substring(par.indexOf("#FullDataName Suspension: Independent System Kinematics`C-Class, Hatchback - Rear`C-Class"));
|
|
|
- String rearWheelUnsprungMass = rearWheelUnsprungMassAll.substring(par.lastIndexOf("M_US")).split("\\s")[1];
|
|
|
+ String rearWheelUnsprungMass = rearWheelUnsprungMassAll.substring(rearWheelUnsprungMassAll.lastIndexOf("M_US")).split("\\s")[1];
|
|
|
String frontWheelTrackWidth = par.substring(par.indexOf("L_TRACK")).split("\\s")[1];
|
|
|
String rearWheelTrackWidth = par.substring(par.lastIndexOf("L_TRACK")).split("\\s")[1];
|
|
|
String windwardArea = par.substring(par.indexOf("AREA_AERO")).split("\\s")[1];
|
|
@@ -521,9 +521,24 @@ public class VehicleService {
|
|
|
|
|
|
public List<List<String>> convertTableToArray(String table) {
|
|
|
List<List<String>> result = new ArrayList<>();
|
|
|
+
|
|
|
+ //1 判断有几列生成表头
|
|
|
String[] lines = StringUtil.splitByLineSeparator(table);
|
|
|
- for (String line : lines) {
|
|
|
- String lineWithoutBlank = line.replaceAll(" ", "");
|
|
|
+ int columnCount = lines[1].replaceAll(" ", "").split(",").length;
|
|
|
+ List<String> headList;
|
|
|
+ if (columnCount == 2) {
|
|
|
+ headList = CollectionUtil.createArrayList("X Axis", "Y Axis");
|
|
|
+ } else if (columnCount > 2) {
|
|
|
+ headList = CollectionUtil.createArrayList("X Axis");
|
|
|
+ for (int i = 1; i <= columnCount - 1; i++) {
|
|
|
+ headList.add(String.valueOf(i));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("列数不能小于2");
|
|
|
+ }
|
|
|
+ result.add(headList);
|
|
|
+ for (int i = 1; i < lines.length; i++) {
|
|
|
+ String lineWithoutBlank = lines[i].replaceAll(" ", "");
|
|
|
String[] split = lineWithoutBlank.split(",");
|
|
|
result.add(Arrays.asList(split));
|
|
|
}
|
|
@@ -531,8 +546,25 @@ public class VehicleService {
|
|
|
}
|
|
|
|
|
|
public String convertArrayToTable(List<List<String>> lines) {
|
|
|
+ //1 判断有几列生成表头
|
|
|
+ List<String> headList;
|
|
|
+ int columnCount = lines.get(0).size();
|
|
|
+ if (columnCount == 2) {
|
|
|
+ headList = CollectionUtil.createArrayList("X Axis", "Y Axis");
|
|
|
+ } else {
|
|
|
+ headList = CollectionUtil.createArrayList("X Axis");
|
|
|
+ for (int i = 1; i <= columnCount - 1; i++) {
|
|
|
+ headList.add(String.valueOf(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //2 第一行换成表头
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
- for (int i = 0; i < lines.size(); i++) {
|
|
|
+ stringBuilder.append("X Axis");
|
|
|
+ for (int i = 1; i < headList.size(); i++) {
|
|
|
+ stringBuilder.append(",").append(headList.get(i));
|
|
|
+ }
|
|
|
+ stringBuilder.append(System.lineSeparator());
|
|
|
+ for (int i = 1; i < lines.size(); i++) {
|
|
|
List<String> words = lines.get(i);
|
|
|
stringBuilder.append(words.get(0));
|
|
|
for (int j = 1; i < words.size(); i++) {
|