fix:修复安能新增和修改行程的审批单传参

This commit is contained in:
lulz1 2024-07-04 10:50:05 +08:00
parent 14c46363eb
commit c41bf4524f
1 changed files with 48 additions and 21 deletions

View File

@ -23,6 +23,7 @@ import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.StringJoiner;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.LegConstant.*;
@ -119,39 +120,64 @@ public class ApprovalPlatformAN implements ApprovalPlatform {
.filter(it -> it.getApprovalRecordNo().equals(approvalData.getApprovalRecordNo())) .filter(it -> it.getApprovalRecordNo().equals(approvalData.getApprovalRecordNo()))
.findFirst() .findFirst()
.ifPresent(it -> approvalScheduleParam.setRemark(it.getApprovalReason())); .ifPresent(it -> approvalScheduleParam.setRemark(it.getApprovalReason()));
List<ScheduleItem> scheduleItemList = new ArrayList<>(); List<ScheduleItem> scheduleItemList = new ArrayList<>();
for (Pair<Leg, Leg> legPair : approvalData.getChangeLegList()) { for (Pair<Leg, Leg> legPair : approvalData.getChangeLegList()) {
Leg newLeg = legPair.getFirst(); Leg newLeg = legPair.getFirst();
Leg oldLeg = legPair.getSecond(); Leg oldLeg = legPair.getSecond();
ScheduleItem scheduleItem = new ScheduleItem(); ScheduleItem scheduleItem = createScheduleItem(newLeg, oldLeg, "2");
scheduleItem.orderType = ANProductType(newLeg.getLegType()); // 示例值可根据需要动态分配
scheduleItem.changeType = "2"; // 示例值可根据需要动态分配
scheduleItem.fromAddress = newLeg.getOriginLocation() != null ? newLeg.getOriginLocation().getLocationName() : null;
scheduleItem.toAddress = newLeg.getDestinationLocation() != null ? newLeg.getDestinationLocation().getLocationName() : null;
scheduleItem.originalFromAddress = oldLeg.getOriginLocation() != null ? oldLeg.getOriginLocation().getLocationName() : null;
scheduleItem.originalToAddress = oldLeg.getDestinationLocation() != null ? oldLeg.getDestinationLocation().getLocationName() : null;
scheduleItem.startTime = DateTimeUtil.timeToStrCommon(newLeg.getStartTime());
scheduleItem.endTime = DateTimeUtil.timeToStrCommon(newLeg.getEndTime());
scheduleItem.originalStartTime = DateTimeUtil.timeToStrCommon(oldLeg.getStartTime());
scheduleItem.originalEndTime = DateTimeUtil.timeToStrCommon(oldLeg.getEndTime());
scheduleItem.amount = new BigDecimal(newLeg.getEstimateAmount());
scheduleItemList.add(scheduleItem); scheduleItemList.add(scheduleItem);
} }
for (Leg leg : approvalData.getAddLegList()) { for (Leg leg : approvalData.getAddLegList()) {
ScheduleItem scheduleItem = new ScheduleItem(); ScheduleItem scheduleItem = createScheduleItem(leg, null, "1");
scheduleItem.orderType = ANProductType(leg.getLegType()); // 示例值可根据需要动态分配
scheduleItem.changeType = "1"; // 示例值可根据需要动态分配
scheduleItem.fromAddress = leg.getOriginLocation() != null ? leg.getOriginLocation().getLocationName() : null;
scheduleItem.toAddress = leg.getDestinationLocation() != null ? leg.getDestinationLocation().getLocationName(): null;
scheduleItem.startTime = DateTimeUtil.timeToStrCommon(leg.getStartTime());
scheduleItem.endTime = DateTimeUtil.timeToStrCommon(leg.getEndTime());
scheduleItem.amount = new BigDecimal(leg.getEstimateAmount());
scheduleItemList.add(scheduleItem); scheduleItemList.add(scheduleItem);
} }
approvalScheduleParam.setScheduleList(scheduleItemList); approvalScheduleParam.setScheduleList(scheduleItemList);
return approvalScheduleParam; return approvalScheduleParam;
} }
private ScheduleItem createScheduleItem(Leg newLeg, Leg oldLeg, String changeType) {
ScheduleItem scheduleItem = new ScheduleItem();
scheduleItem.orderType = ANProductType(newLeg.getLegType()); // 示例值可根据需要动态分配
scheduleItem.changeType = changeType; // 示例值可根据需要动态分配
scheduleItem.fromAddress = getLocationName(newLeg.getOriginLocation());
scheduleItem.toAddress = getLocationName(newLeg.getDestinationLocation());
scheduleItem.originalFromAddress = oldLeg != null ? getLocationName(oldLeg.getOriginLocation()) : null;
scheduleItem.originalToAddress = oldLeg != null ? getLocationName(oldLeg.getDestinationLocation()) : null;
scheduleItem.startTime = DateTimeUtil.timeToStrCommon(newLeg.getStartTime());
scheduleItem.endTime = DateTimeUtil.timeToStrCommon(newLeg.getEndTime());
scheduleItem.originalStartTime = oldLeg != null ? DateTimeUtil.timeToStrCommon(oldLeg.getStartTime()) : null;
scheduleItem.originalEndTime = oldLeg != null ? DateTimeUtil.timeToStrCommon(oldLeg.getEndTime()) : null;
scheduleItem.amount = new BigDecimal(newLeg.getEstimateAmount());
carLegLocation(newLeg, oldLeg, scheduleItem);
newLeg.getLastChangeEvent().ifPresent(it -> scheduleItem.setRemark(it.getExtension()));
return scheduleItem;
}
private void carLegLocation(Leg newLeg, Leg oldLeg, ScheduleItem scheduleItem) {
if (newLeg != null && LEG_TYPE_TAXI != newLeg.getLegType()) {
scheduleItem.setFromAddress(getCarLegLocationStr(newLeg));
scheduleItem.setToAddress(getCarLegLocationStr(newLeg));
}
if (oldLeg != null && LEG_TYPE_TAXI != oldLeg.getLegType()) {
scheduleItem.setOriginalFromAddress(getCarLegLocationStr(oldLeg));
scheduleItem.setOriginalToAddress(getCarLegLocationStr(oldLeg));
}
}
private String getCarLegLocationStr(Leg leg) {
List<Location> locationList = leg.getLegExtensionField().getLocationList();
StringJoiner locationNames = new StringJoiner(", ");
for (Location location : locationList) {
locationNames.add(location.getLocationName());
}
return locationNames.toString();
}
private String getLocationName(Location location) {
return location != null ? location.getLocationName() : null;
}
private String ANProductType(Integer legType) { private String ANProductType(Integer legType) {
return switch (legType) { return switch (legType) {
case LEG_TYPE_TRAIN -> "3"; case LEG_TYPE_TRAIN -> "3";
@ -285,6 +311,7 @@ public class ApprovalPlatformAN implements ApprovalPlatform {
public String originalStartTime; public String originalStartTime;
public String originalEndTime; public String originalEndTime;
public BigDecimal amount; public BigDecimal amount;
public String remark;
} }
@Data @Data