fix:修复安能新增和修改行程的审批单传参
This commit is contained in:
parent
14c46363eb
commit
c41bf4524f
|
@ -23,6 +23,7 @@ import java.time.LocalDateTime;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||
|
@ -99,7 +100,7 @@ public class ApprovalPlatformAN implements ApprovalPlatform {
|
|||
approvalPlatformInfo.changeUrl()
|
||||
.ifPresent(url -> {
|
||||
ApprovalScheduleParam approvalScheduleParam = createApprovalScheduleParam(approvalData);
|
||||
CompletableFuture.runAsync(()-> DelayDispatch.attemptToSend(() -> postRequest.post(url, approvalScheduleParam, ANResponse.class)
|
||||
CompletableFuture.runAsync(() -> DelayDispatch.attemptToSend(() -> postRequest.post(url, approvalScheduleParam, ANResponse.class)
|
||||
.getSuccess(), 0));
|
||||
});
|
||||
}
|
||||
|
@ -119,39 +120,64 @@ public class ApprovalPlatformAN implements ApprovalPlatform {
|
|||
.filter(it -> it.getApprovalRecordNo().equals(approvalData.getApprovalRecordNo()))
|
||||
.findFirst()
|
||||
.ifPresent(it -> approvalScheduleParam.setRemark(it.getApprovalReason()));
|
||||
|
||||
List<ScheduleItem> scheduleItemList = new ArrayList<>();
|
||||
for (Pair<Leg, Leg> legPair : approvalData.getChangeLegList()) {
|
||||
Leg newLeg = legPair.getFirst();
|
||||
Leg oldLeg = legPair.getSecond();
|
||||
ScheduleItem scheduleItem = new ScheduleItem();
|
||||
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());
|
||||
ScheduleItem scheduleItem = createScheduleItem(newLeg, oldLeg, "2");
|
||||
scheduleItemList.add(scheduleItem);
|
||||
}
|
||||
for (Leg leg : approvalData.getAddLegList()) {
|
||||
ScheduleItem scheduleItem = new ScheduleItem();
|
||||
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());
|
||||
ScheduleItem scheduleItem = createScheduleItem(leg, null, "1");
|
||||
scheduleItemList.add(scheduleItem);
|
||||
}
|
||||
approvalScheduleParam.setScheduleList(scheduleItemList);
|
||||
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) {
|
||||
return switch (legType) {
|
||||
case LEG_TYPE_TRAIN -> "3";
|
||||
|
@ -285,6 +311,7 @@ public class ApprovalPlatformAN implements ApprovalPlatform {
|
|||
public String originalStartTime;
|
||||
public String originalEndTime;
|
||||
public BigDecimal amount;
|
||||
public String remark;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
|
Loading…
Reference in New Issue