fix:修复打车行程没有更新地点计算字段的问题

This commit is contained in:
lulz1 2024-07-05 15:08:21 +08:00
parent ae404ff1fd
commit c1ef9fa1db
1 changed files with 25 additions and 12 deletions

View File

@ -8,11 +8,14 @@ import com.chint.domain.aggregates.order.Location;
import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.order.OrderDetail;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER; import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI; import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
@ -99,26 +102,36 @@ public class LegRes {
legRes.setSupplierNameList(new ArrayList<>()); legRes.setSupplierNameList(new ArrayList<>());
} }
StringBuilder sb = getStringBuilder(leg, originLocation, destinationLocation);
legRes.setLocationNameList(sb.toString());
return legRes;
}
private static @NotNull StringBuilder getStringBuilder(Leg leg,
Location originLocation,
Location destinationLocation) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
Set<String> locationSet = new HashSet<>();
if (leg.getLegType().equals(LEG_TYPE_TAXI) || leg.getLegType().equals(LEG_TYPE_OTHER)) { if (leg.getLegType().equals(LEG_TYPE_TAXI) || leg.getLegType().equals(LEG_TYPE_OTHER)) {
List<Location> locationList = leg.getLegExtensionField().getLocationList(); List<Location> locationList = leg.getLegExtensionField().getLocationList();
if (locationList != null && !locationList.isEmpty()) { if (locationList != null && !locationList.isEmpty()) {
for (Location location : locationList) { for (Location location : locationList) {
sb.append(location.getLocationName()); locationSet.add(location.getLocationName());
}
}
} else {
locationSet.add(originLocation.getLocationName());
locationSet.add(destinationLocation.getLocationName());
}
for (String locationName : locationSet) {
sb.append(locationName);
sb.append(","); sb.append(",");
} }
// Remove the last comma // Remove the last comma if StringBuilder is not empty
if (!sb.isEmpty()) { if (!sb.isEmpty()) {
sb.setLength(sb.length() - 1); sb.setLength(sb.length() - 1);
} }
legRes.setLocationNameList(sb.toString()); return sb;
}
} else {
sb.append(originLocation.getLocationName());
sb.append(",");
sb.append(destinationLocation.getLocationName());
}
legRes.setLocationNameList(sb.toString());
return legRes;
} }
} }