fix:修复打车行程没有更新地点计算字段的问题
This commit is contained in:
parent
ae404ff1fd
commit
c1ef9fa1db
|
@ -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());
|
||||
locationSet.add(location.getLocationName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
locationSet.add(originLocation.getLocationName());
|
||||
locationSet.add(destinationLocation.getLocationName());
|
||||
}
|
||||
for (String locationName : locationSet) {
|
||||
sb.append(locationName);
|
||||
sb.append(",");
|
||||
}
|
||||
// Remove the last comma
|
||||
// Remove the last comma if StringBuilder is not empty
|
||||
if (!sb.isEmpty()) {
|
||||
sb.setLength(sb.length() - 1);
|
||||
}
|
||||
legRes.setLocationNameList(sb.toString());
|
||||
}
|
||||
} else {
|
||||
sb.append(originLocation.getLocationName());
|
||||
sb.append(",");
|
||||
sb.append(destinationLocation.getLocationName());
|
||||
}
|
||||
legRes.setLocationNameList(sb.toString());
|
||||
return legRes;
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue