fix:修复打车行程没有更新地点计算字段的问题
This commit is contained in:
parent
e8c277926e
commit
ae404ff1fd
|
@ -9,12 +9,14 @@ import com.chint.domain.aggregates.order.OrderDetail;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER;
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
|
||||
|
||||
@Data
|
||||
public class LegRes {
|
||||
@Id
|
||||
|
@ -51,7 +53,7 @@ public class LegRes {
|
|||
private Integer legApprovalStatus;
|
||||
private String legApprovalStatusName;
|
||||
private String currencyType;
|
||||
|
||||
private String locationNameList;
|
||||
private List<LocationRes> otherLocationList;
|
||||
|
||||
private List<OrderDetail> orderDetails; //这个属性不做持久化保存 ,根据下单事件进行获取
|
||||
|
@ -84,8 +86,10 @@ public class LegRes {
|
|||
if (leg.getCurrencyType() != null) {
|
||||
legRes.setCurrencyType(leg.getCurrencyType().getCode());
|
||||
}
|
||||
legRes.setOriginLocation(LocationRes.copyFrom(leg.getOriginLocation()));
|
||||
legRes.setDestinationLocation(LocationRes.copyFrom(leg.getDestinationLocation()));
|
||||
Location originLocation = leg.getOriginLocation();
|
||||
Location destinationLocation = leg.getDestinationLocation();
|
||||
legRes.setOriginLocation(LocationRes.copyFrom(originLocation));
|
||||
legRes.setDestinationLocation(LocationRes.copyFrom(destinationLocation));
|
||||
|
||||
if (legRes.getSupplierList() == null) {
|
||||
legRes.setSupplierList(new ArrayList<>());
|
||||
|
@ -94,6 +98,27 @@ public class LegRes {
|
|||
if (legRes.getSupplierNameList() == null) {
|
||||
legRes.setSupplierNameList(new ArrayList<>());
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
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(",");
|
||||
}
|
||||
// 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());
|
||||
}
|
||||
legRes.setLocationNameList(sb.toString());
|
||||
return legRes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ public class LegDomainService {
|
|||
List<Long> locationIdsAsLong = getLocationIdsAsLong(legExtensionField);
|
||||
List<Location> locationList = legExtensionField.getLocationList();
|
||||
if (locationList == null || locationList.size() != locationIdsAsLong.size() ||
|
||||
checkIfSameLocationList(locationList, locationIdsAsLong)) {
|
||||
!checkIfSameLocationList(locationList, locationIdsAsLong)) {
|
||||
List<Location> byNameList = locationRepository.findByNameList(locationIdsAsLong);
|
||||
legExtensionField.setLocationList(byNameList);
|
||||
updated = true;
|
||||
|
|
|
@ -1506,4 +1506,21 @@ class RouteApplicationTests {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void spiltTest() {
|
||||
String[] parts = "2024-07-05 00:00:00|2024-07-19 00:00:00|null|null|200.00|53".split("\\|");
|
||||
if (parts.length >= 5) {
|
||||
System.out.println(parts[0]);
|
||||
System.out.println(parts[1]);
|
||||
System.out.println(parts[2]);
|
||||
System.out.println(parts[3]);
|
||||
System.out.println(parts[4]);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid legString format.");
|
||||
}
|
||||
if (parts.length >= 6 && parts[5] != null && !parts[5].isEmpty() && !"null".equals(parts[5])) {
|
||||
System.out.println(parts[5]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue