fix:审批功能重构-安能添加行程和变更行程-细节问题修复
This commit is contained in:
parent
eaa76fbce3
commit
708226b3c8
|
@ -60,7 +60,6 @@ public class OrderPublicController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("审批拒绝行程规划单")
|
@ApiOperation("审批拒绝行程规划单")
|
||||||
@PostMapping("/reject")
|
@PostMapping("/reject")
|
||||||
public Result<String> rejectOrder(@RequestBody ApproveRouteData approveRouteData) {
|
public Result<String> rejectOrder(@RequestBody ApproveRouteData approveRouteData) {
|
||||||
|
@ -106,7 +105,7 @@ public class OrderPublicController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("提交需要审批的行程节点")
|
@ApiOperation("处理审批结果回复")
|
||||||
@PostMapping("/approve/response")
|
@PostMapping("/approve/response")
|
||||||
public Result<String> approveOrder(@RequestBody ApprovalResultData data) {
|
public Result<String> approveOrder(@RequestBody ApprovalResultData data) {
|
||||||
routeApprovalDomainService.handlerApprovalResponse(data);
|
routeApprovalDomainService.handlerApprovalResponse(data);
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.chint.domain.aggregates.base.BaseEvent;
|
||||||
import com.chint.domain.aggregates.order.Leg;
|
import com.chint.domain.aggregates.order.Leg;
|
||||||
import com.chint.domain.aggregates.order.LegApprovalEvent;
|
import com.chint.domain.aggregates.order.LegApprovalEvent;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import org.springframework.data.util.Pair;
|
import org.springframework.data.util.Pair;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -36,9 +35,8 @@ public class ApprovalLegAddAndChangeBatch extends ApprovalProcess {
|
||||||
approvalData.setAddLegList(legMap.get(true));
|
approvalData.setAddLegList(legMap.get(true));
|
||||||
List<Pair<Leg, Leg>> pairList = legMap.get(false).stream()
|
List<Pair<Leg, Leg>> pairList = legMap.get(false).stream()
|
||||||
.map(leg -> {
|
.map(leg -> {
|
||||||
Gson gson = new Gson();
|
|
||||||
String extension = leg.getLastEvent().getExtension();
|
String extension = leg.getLastEvent().getExtension();
|
||||||
Leg oldLeg = gson.fromJson(extension, Leg.class);
|
Leg oldLeg = leg.deepClone().restoreFromLegString(extension);
|
||||||
return Pair.of(leg, oldLeg);
|
return Pair.of(leg, oldLeg);
|
||||||
}).toList();
|
}).toList();
|
||||||
approvalData.setChangeLegList(pairList);
|
approvalData.setChangeLegList(pairList);
|
||||||
|
@ -67,22 +65,37 @@ public class ApprovalLegAddAndChangeBatch extends ApprovalProcess {
|
||||||
public void handlerApprovalResultBefore(ApprovalResultData data) {
|
public void handlerApprovalResultBefore(ApprovalResultData data) {
|
||||||
String approvalRecordNo = data.getApprovalRecordNo();
|
String approvalRecordNo = data.getApprovalRecordNo();
|
||||||
RouteOrder routeOrder = data.getRouteOrder();
|
RouteOrder routeOrder = data.getRouteOrder();
|
||||||
|
|
||||||
routeOrder.getLegItems().stream()
|
routeOrder.getLegItems().stream()
|
||||||
.filter(leg -> {
|
.filter(leg -> isLegApprovalPending(leg, approvalRecordNo))
|
||||||
BaseEvent lastEvent = leg.getLastEvent();
|
.forEach(leg -> handleLegApprovalResult(data, routeOrder, leg));
|
||||||
return lastEvent.getEventType().equals(LEG_APPROVAL_STATUS_SUBMIT) &&
|
}
|
||||||
lastEvent.getExtension().equals(approvalRecordNo);
|
private boolean isLegApprovalPending(Leg leg, String approvalRecordNo) {
|
||||||
}).forEach(leg -> {
|
BaseEvent lastEvent = leg.getLastEvent();
|
||||||
if (data.getApprovalStatus().equals(ApprovalRecord.successApprovalStatus())) {
|
return lastEvent.getEventType().equals(LEG_APPROVAL_STATUS_SUBMIT) &&
|
||||||
leg.addEvent(LegApprovalEvent.success());
|
lastEvent.getExtension().equals(approvalRecordNo);
|
||||||
|
}
|
||||||
|
private void handleLegApprovalResult(ApprovalResultData data, RouteOrder routeOrder, Leg leg) {
|
||||||
|
if (data.getApprovalStatus().equals(ApprovalRecord.successApprovalStatus())) {
|
||||||
|
leg.addEvent(LegApprovalEvent.success());
|
||||||
|
} else {
|
||||||
|
leg.addEvent(LegApprovalEvent.reject());
|
||||||
|
rollbackLegState(routeOrder, leg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void rollbackLegState(RouteOrder routeOrder, Leg leg) {
|
||||||
|
leg.getLegApprovalEventList().stream()
|
||||||
|
.filter(event -> event.getEventType().equals(LEG_APPROVAL_STATUS_PREPARE))
|
||||||
|
.max(Comparator.comparing(LegApprovalEvent::getHappenTime))
|
||||||
|
.ifPresent(lastPrepareEvent -> {
|
||||||
|
if (isRollbackToOriginalLeg(lastPrepareEvent)) {
|
||||||
|
routeOrder.deleteLeg(leg.getLegNo());
|
||||||
} else {
|
} else {
|
||||||
leg.addEvent(LegApprovalEvent.reject());//如果行程被驳回 ,那么就要回滚到审批前的状态
|
leg.restoreFromLegString(lastPrepareEvent.getExtension());
|
||||||
leg.getLegApprovalEventList()
|
|
||||||
.stream()
|
|
||||||
.filter(legApprovalEvent -> legApprovalEvent.getEventType().equals(LEG_APPROVAL_STATUS_PREPARE))
|
|
||||||
.max(Comparator.comparing(LegApprovalEvent::getHappenTime))
|
|
||||||
.ifPresent(it -> leg.restoreFromLegString(it.getExtension()));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
private boolean isRollbackToOriginalLeg(LegApprovalEvent lastPrepareEvent) {
|
||||||
|
return lastPrepareEvent.getExtension() == null || lastPrepareEvent.getExtension().isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,14 @@ import com.chint.domain.aggregates.order.Leg;
|
||||||
import com.chint.domain.aggregates.order.LegApprovalEvent;
|
import com.chint.domain.aggregates.order.LegApprovalEvent;
|
||||||
import com.chint.domain.aggregates.order.OrderDetail;
|
import com.chint.domain.aggregates.order.OrderDetail;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
|
import com.chint.domain.exceptions.CommandException;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import static com.chint.infrastructure.constant.LegConstant.LEG_APPROVAL_STATUS_PREPARE;
|
||||||
|
|
||||||
|
|
||||||
// 定义抽象类 ApprovalProcess
|
// 定义抽象类 ApprovalProcess
|
||||||
@Data
|
@Data
|
||||||
|
@ -52,8 +56,16 @@ public abstract class ApprovalProcess {
|
||||||
RouteOrder routeOrder = approvalData.getRouteOrder();
|
RouteOrder routeOrder = approvalData.getRouteOrder();
|
||||||
if (routeOrder != null) {
|
if (routeOrder != null) {
|
||||||
ApprovalRecord approvalRecord = ApprovalRecord.of(routeOrder, this);
|
ApprovalRecord approvalRecord = ApprovalRecord.of(routeOrder, this);
|
||||||
|
List<Leg> legs = routeOrder.getLegItems()
|
||||||
|
.stream()
|
||||||
|
.filter(legItem -> legItem.getLastEvent().getEventType().equals(LEG_APPROVAL_STATUS_PREPARE))
|
||||||
|
.toList();
|
||||||
|
if (legs.isEmpty()) {
|
||||||
|
throw new CommandException("不存在需要审批的行程");
|
||||||
|
}
|
||||||
approvalData.setApprovalRecordNo(approvalRecord.getApprovalRecordNo());
|
approvalData.setApprovalRecordNo(approvalRecord.getApprovalRecordNo());
|
||||||
consumer.accept(approvalRecord); // 使用传入的Consumer对象
|
routeOrder.addApprovalRecord(approvalRecord);
|
||||||
|
consumer.accept(approvalRecord);
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -82,10 +94,11 @@ public abstract class ApprovalProcess {
|
||||||
|
|
||||||
public ApprovalProcess beforeSubmitToBpm() {
|
public ApprovalProcess beforeSubmitToBpm() {
|
||||||
//所有被提交审批的被加入审批事件
|
//所有被提交审批的被加入审批事件
|
||||||
approvalData.getAddLegList().forEach(leg -> leg.addEvent(LegApprovalEvent.submit()));
|
String approvalRecordNo = approvalData.getApprovalRecordNo();
|
||||||
|
approvalData.getAddLegList().forEach(leg -> leg.addEvent(LegApprovalEvent.submit(approvalRecordNo)));
|
||||||
approvalData.getChangeLegList().forEach(it -> {
|
approvalData.getChangeLegList().forEach(it -> {
|
||||||
Leg newLeg = it.getFirst();
|
Leg newLeg = it.getFirst();
|
||||||
newLeg.addEvent(LegApprovalEvent.submit());
|
newLeg.addEvent(LegApprovalEvent.submit(approvalRecordNo));
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.chint.domain.aggregates.approval;
|
package com.chint.domain.aggregates.approval;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.approval.platform.ApprovalPlatform;
|
import com.chint.domain.aggregates.approval.platform.ApprovalPlatform;
|
||||||
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
import com.chint.domain.repository.ApprovalRecordRepository;
|
import com.chint.domain.repository.ApprovalRecordRepository;
|
||||||
import com.chint.domain.repository.RouteRepository;
|
import com.chint.domain.repository.RouteRepository;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -9,8 +10,10 @@ import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@ -57,14 +60,25 @@ public class ApprovalSubmit implements ApplicationListener<ApplicationReadyEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
//用于处理审批结果
|
//用于处理审批结果
|
||||||
|
@Transactional
|
||||||
public void handleApprovalResult(ApprovalResultData data) {
|
public void handleApprovalResult(ApprovalResultData data) {
|
||||||
approvalRecordRepository.findByApprovalRecordNo(data.getApprovalRecordNo())
|
Optional<ApprovalRecord> optionalApprovalRecord = approvalRecordRepository.findByApprovalRecordNo(data.getApprovalRecordNo());
|
||||||
.ifPresent(it -> {
|
if (optionalApprovalRecord.isPresent()) {
|
||||||
data.setRouteOrder(routeRepository.queryById(it.getRouteId()));
|
ApprovalRecord approvalRecord = optionalApprovalRecord.get();
|
||||||
ApprovalProcess approvalProcess = of(ApprovalType.valueOf(it.getApprovalType()), it.getApprovalPlatformMark());
|
RouteOrder routeOrder = routeRepository.queryById(approvalRecord.getRouteId());
|
||||||
approvalProcess.handlerApprovalResult(data);
|
data.setRouteOrder(routeOrder);
|
||||||
approvalRecordRepository.save(it);
|
Optional<ApprovalRecord> matchingApprovalRecord = routeOrder.getApprovalRecordList().stream()
|
||||||
routeRepository.save(data.getRouteOrder());
|
.filter(record -> record.getApprovalRecordNo().equals(data.getApprovalRecordNo()))
|
||||||
});
|
.findFirst();
|
||||||
|
matchingApprovalRecord.ifPresent(record -> processHandleApprovalResult(data, routeOrder, record));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processHandleApprovalResult(ApprovalResultData data, RouteOrder routeOrder, ApprovalRecord approvalRecord) {
|
||||||
|
ApprovalProcess approvalProcess = of(ApprovalType.valueOf(approvalRecord.getApprovalType()),
|
||||||
|
approvalRecord.getApprovalPlatformMark());
|
||||||
|
approvalProcess.handlerApprovalResult(data);
|
||||||
|
approvalRecord.setApprovalStatus(data.getApprovalStatus());
|
||||||
|
routeRepository.save(routeOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class ApprovalPlatformAN implements ApprovalPlatform {
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
void init() {
|
void init() {
|
||||||
approvalPlatformInfoRepository.findByPlatformMark(platformMark)
|
approvalPlatformInfoRepository.findByPlatformMark(platformMark)
|
||||||
.ifPresent(approvalPlatformInfo -> approvalPlatformInfo.setPlatformMark(platformMark));
|
.ifPresent(approvalPlatformInfo -> this.approvalPlatformInfo = approvalPlatformInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,7 +14,7 @@ public interface EventManageable {
|
||||||
default void addEvent(BaseEvent event) {
|
default void addEvent(BaseEvent event) {
|
||||||
List<BaseEvent> events = (List<BaseEvent>) getEvents();
|
List<BaseEvent> events = (List<BaseEvent>) getEvents();
|
||||||
BaseEvent lastEvent = getLastEvent();
|
BaseEvent lastEvent = getLastEvent();
|
||||||
if (!Objects.equals(lastEvent.getEventType(), event.getEventType())) {
|
if (lastEvent == null || !Objects.equals(lastEvent.getEventType(), event.getEventType())) {
|
||||||
events.add(event);
|
events.add(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,18 +421,20 @@ public class Leg implements Serializable, EventManageable {
|
||||||
public String generateLegString() {
|
public String generateLegString() {
|
||||||
return DateTimeUtil.timeToStrCommon(startTime) + "|" +
|
return DateTimeUtil.timeToStrCommon(startTime) + "|" +
|
||||||
DateTimeUtil.timeToStrCommon(endTime) + "|" +
|
DateTimeUtil.timeToStrCommon(endTime) + "|" +
|
||||||
originId + "|" + destinationId;
|
originId + "|" + destinationId + "|" + estimateAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreFromLegString(String legString) {
|
public Leg restoreFromLegString(String legString) {
|
||||||
String[] parts = legString.split("\\|");
|
String[] parts = legString.split("\\|");
|
||||||
if (parts.length == 4) {
|
if (parts.length == 5) {
|
||||||
this.startTime = DateTimeUtil.strToTime(parts[0]);
|
this.startTime = DateTimeUtil.strToTime(parts[0]);
|
||||||
this.endTime = DateTimeUtil.strToTime(parts[1]);
|
this.endTime = DateTimeUtil.strToTime(parts[1]);
|
||||||
this.originId = Long.parseLong(parts[2]);
|
this.originId = Long.parseLong(parts[2]);
|
||||||
this.destinationId = Long.parseLong(parts[3]);
|
this.destinationId = Long.parseLong(parts[3]);
|
||||||
|
this.estimateAmount = parts[4];
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Invalid legString format.");
|
throw new IllegalArgumentException("Invalid legString format.");
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package com.chint.domain.aggregates.order;
|
package com.chint.domain.aggregates.order;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.base.BaseEvent;
|
import com.chint.domain.aggregates.base.BaseEvent;
|
||||||
import com.chint.infrastructure.util.Json;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.relational.core.mapping.Column;
|
import org.springframework.data.relational.core.mapping.Column;
|
||||||
|
@ -53,6 +52,13 @@ public class LegApprovalEvent extends BaseEvent implements Serializable {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LegApprovalEvent submit(String extension) {
|
||||||
|
LegApprovalEvent event = new LegApprovalEvent();
|
||||||
|
event.setEventType(LEG_APPROVAL_STATUS_SUBMIT);
|
||||||
|
event.setExtension(extension);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
public static LegApprovalEvent success() {
|
public static LegApprovalEvent success() {
|
||||||
LegApprovalEvent event = new LegApprovalEvent();
|
LegApprovalEvent event = new LegApprovalEvent();
|
||||||
event.setEventType(LEG_APPROVAL_STATUS_SUCCESS);
|
event.setEventType(LEG_APPROVAL_STATUS_SUCCESS);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.chint.domain.aggregates.order;
|
||||||
|
|
||||||
|
|
||||||
import com.chint.application.commands.LegOrderedCommand;
|
import com.chint.application.commands.LegOrderedCommand;
|
||||||
|
import com.chint.domain.aggregates.approval.ApprovalRecord;
|
||||||
import com.chint.domain.factoriy.leg.LegFactory;
|
import com.chint.domain.factoriy.leg.LegFactory;
|
||||||
import com.chint.domain.service.LegDomainService;
|
import com.chint.domain.service.LegDomainService;
|
||||||
import com.chint.domain.service.amount_estimate.EstimateAdapter;
|
import com.chint.domain.service.amount_estimate.EstimateAdapter;
|
||||||
|
@ -102,6 +103,9 @@ public class RouteOrder implements Serializable {
|
||||||
@MappedCollection(idColumn = "route_id", keyColumn = "route_order_key")
|
@MappedCollection(idColumn = "route_id", keyColumn = "route_order_key")
|
||||||
private List<RouteRequest> routeRequestList;
|
private List<RouteRequest> routeRequestList;
|
||||||
|
|
||||||
|
@MappedCollection(idColumn = "route_id", keyColumn = "route_order_key")
|
||||||
|
private List<ApprovalRecord> approvalRecordList;
|
||||||
|
|
||||||
@ApiModelProperty("启用状态,1启动,0禁用")
|
@ApiModelProperty("启用状态,1启动,0禁用")
|
||||||
public Integer status = 1;
|
public Integer status = 1;
|
||||||
|
|
||||||
|
@ -224,6 +228,15 @@ public class RouteOrder implements Serializable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RouteOrder addApprovalRecord(ApprovalRecord approvalRecord) {
|
||||||
|
if (this.approvalRecordList == null) {
|
||||||
|
this.approvalRecordList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
this.approvalRecordList = new ArrayList<>(this.approvalRecordList);
|
||||||
|
this.approvalRecordList.add(approvalRecord);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public RouteOrder addRouteRequest(RouteRequest routeRequest) {
|
public RouteOrder addRouteRequest(RouteRequest routeRequest) {
|
||||||
if (this.routeRequestList == null) {
|
if (this.routeRequestList == null) {
|
||||||
this.routeRequestList = new ArrayList<>();
|
this.routeRequestList = new ArrayList<>();
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class SystemCode implements Serializable {
|
||||||
|
|
||||||
private String getExtensionValue(String fieldName) {
|
private String getExtensionValue(String fieldName) {
|
||||||
if (systemCodeExtensionFieldList == null || systemCodeExtensionFieldList.isEmpty()) {
|
if (systemCodeExtensionFieldList == null || systemCodeExtensionFieldList.isEmpty()) {
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
return this.systemCodeExtensionFieldList.stream().filter(it -> it.getFieldName().equals(fieldName))
|
return this.systemCodeExtensionFieldList.stream().filter(it -> it.getFieldName().equals(fieldName))
|
||||||
.map(SystemCodeExtensionField::getFieldValue)
|
.map(SystemCodeExtensionField::getFieldValue)
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class SystemOrganization implements Serializable {
|
||||||
|
|
||||||
private String getExtensionValue(String fieldName) {
|
private String getExtensionValue(String fieldName) {
|
||||||
if (systemOrganizationExtensionList == null || systemOrganizationExtensionList.isEmpty()) {
|
if (systemOrganizationExtensionList == null || systemOrganizationExtensionList.isEmpty()) {
|
||||||
return "";
|
return null;
|
||||||
}
|
}
|
||||||
return this.systemOrganizationExtensionList.stream().filter(it -> it.getFieldName().equals(fieldName))
|
return this.systemOrganizationExtensionList.stream().filter(it -> it.getFieldName().equals(fieldName))
|
||||||
.map(SystemOrganizationExtension::getFieldValue)
|
.map(SystemOrganizationExtension::getFieldValue)
|
||||||
|
|
|
@ -228,7 +228,8 @@ public class LegDomainService {
|
||||||
List<Leg> filteredLegItems = legItems.stream()
|
List<Leg> filteredLegItems = legItems.stream()
|
||||||
.filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER) && it.legIsInternal())
|
.filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER) && it.legIsInternal())
|
||||||
.peek(Leg::reloadStatus)
|
.peek(Leg::reloadStatus)
|
||||||
.filter(it -> !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_SUBMIT))
|
.filter(it -> !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_SUBMIT) &&
|
||||||
|
!it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_PREPARE))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// 根据供应商名称查找供应商并进行处理
|
// 根据供应商名称查找供应商并进行处理
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.chint.domain.aggregates.approval.ApprovalResultData;
|
||||||
import com.chint.domain.aggregates.approval.ApprovalSubmit;
|
import com.chint.domain.aggregates.approval.ApprovalSubmit;
|
||||||
import com.chint.domain.aggregates.base.PermissionConfig;
|
import com.chint.domain.aggregates.base.PermissionConfig;
|
||||||
import com.chint.domain.aggregates.order.ApproveOrderNo;
|
import com.chint.domain.aggregates.order.ApproveOrderNo;
|
||||||
|
import com.chint.domain.aggregates.order.Leg;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
import com.chint.domain.aggregates.system.SystemCode;
|
import com.chint.domain.aggregates.system.SystemCode;
|
||||||
import com.chint.domain.aggregates.system.SystemOrganization;
|
import com.chint.domain.aggregates.system.SystemOrganization;
|
||||||
|
@ -12,6 +13,7 @@ import com.chint.domain.repository.*;
|
||||||
import com.chint.domain.value_object.enums.RoutePermission;
|
import com.chint.domain.value_object.enums.RoutePermission;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -40,6 +42,10 @@ public class RouteApprovalDomainService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApprovalRecordRepository approvalRecordRepository;
|
private ApprovalRecordRepository approvalRecordRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LegDomainService legDomainService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
private ApprovalSubmit approvalSubmit;
|
private ApprovalSubmit approvalSubmit;
|
||||||
|
|
||||||
public void legApprovalResponse() {
|
public void legApprovalResponse() {
|
||||||
|
@ -54,15 +60,17 @@ public class RouteApprovalDomainService {
|
||||||
approvalSubmit.handleApprovalResult(data);
|
approvalSubmit.handleApprovalResult(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public void approveRouteOfLegChangeAndAdd(LegApprovalParam param) {
|
public void approveRouteOfLegChangeAndAdd(LegApprovalParam param) {
|
||||||
RouteOrder routeOrder = routeRepository.queryById(param.getRouteId());
|
RouteOrder routeOrder = routeRepository.queryById(param.getRouteId());
|
||||||
|
List<Leg> legItems = routeOrder.getLegItems();
|
||||||
|
if (legItems != null && !legItems.isEmpty() && legItems.get(0).getOriginLocation() == null) {
|
||||||
|
legDomainService.queryLocation(legItems);
|
||||||
|
}
|
||||||
String approvalPlatformMark = getApprovalPlatformMark(routeOrder);
|
String approvalPlatformMark = getApprovalPlatformMark(routeOrder);
|
||||||
ApprovalSubmit.of(LEG_ADD_CHANGE_BATCH, approvalPlatformMark)
|
ApprovalSubmit.of(LEG_ADD_CHANGE_BATCH, approvalPlatformMark)
|
||||||
.approveData(routeOrder)
|
.approveData(routeOrder)
|
||||||
.record(record -> {
|
.record(it -> it.setApprovalReason(param.getApprovalReason()))
|
||||||
record.setApprovalReason(param.getApprovalReason());
|
|
||||||
approvalRecordRepository.save(record);
|
|
||||||
})
|
|
||||||
.submitToBpm();
|
.submitToBpm();
|
||||||
routeRepository.save(routeOrder);
|
routeRepository.save(routeOrder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,8 @@ public interface SupplierOrderSync extends SupplierAdapter {
|
||||||
.stream()
|
.stream()
|
||||||
.map(RouteRequestLeg::getLeg)
|
.map(RouteRequestLeg::getLeg)
|
||||||
.peek(Leg::reloadStatus)
|
.peek(Leg::reloadStatus)
|
||||||
.filter(it -> !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_SUBMIT))
|
.filter(it -> !it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_SUBMIT) &&
|
||||||
|
!it.getLegApprovalStatus().equals(LEG_APPROVAL_STATUS_PREPARE))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// Legs can not be empty
|
// Legs can not be empty
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.chint.infrastructure.repository;
|
package com.chint.infrastructure.repository;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.order.ApproveOrderNo;
|
import com.chint.domain.aggregates.order.ApproveOrderNo;
|
||||||
|
import com.chint.domain.aggregates.order.Leg;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
import com.chint.domain.repository.RouteRepository;
|
import com.chint.domain.repository.RouteRepository;
|
||||||
|
import com.chint.domain.service.LegDomainService;
|
||||||
import com.chint.domain.value_object.OrderQueryData;
|
import com.chint.domain.value_object.OrderQueryData;
|
||||||
import com.chint.infrastructure.cache.RouteCacheService;
|
import com.chint.infrastructure.cache.RouteCacheService;
|
||||||
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
|
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
|
||||||
|
@ -32,10 +34,14 @@ public class RouteRepositoryImpl implements RouteRepository {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisTemplate<String, RouteOrder> redisTemplate;
|
private RedisTemplate<String, RouteOrder> redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RouteOrder queryById(Long orderId) {
|
public RouteOrder queryById(Long orderId) {
|
||||||
// jdbcRouteRepository.findByRouteId(orderId);
|
RouteOrder routeOrder = routeCacheService.getRouteById(orderId);
|
||||||
return routeCacheService.getRouteById(orderId);
|
if (routeOrder != null && routeOrder.getOrderStatus() == null) {
|
||||||
|
routeOrder.reloadStatus();
|
||||||
|
}
|
||||||
|
return routeOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class DelayDispatch {
|
||||||
if (attempt >= 5) {
|
if (attempt >= 5) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean success = requestSupplier.get(); // 使用Supplier<Boolean>获取请求成功与否的状态
|
boolean success = requestSupplier != null && requestSupplier.get() != null && requestSupplier.get(); // 使用Supplier<Boolean>获取请求成功与否的状态
|
||||||
if (!success) {
|
if (!success) {
|
||||||
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
|
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
|
||||||
scheduler.schedule(() -> {
|
scheduler.schedule(() -> {
|
||||||
|
|
Loading…
Reference in New Issue