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