同步代码
This commit is contained in:
parent
ac730f039d
commit
25ce2b3b9c
|
@ -6,10 +6,11 @@ import com.chint.infrastructure.echo_framework.command.Command;
|
|||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BPMLegChangeCommand extends Command {
|
||||
public class BPMLegChangeCommand extends Command {
|
||||
private Long routeId;
|
||||
private Leg oldLeg;
|
||||
private Leg newleg;
|
||||
private String reason;
|
||||
private Integer changeType; //0 is add, 1 is update
|
||||
|
||||
public BPMLegChangeCommand oldLeg(Leg leg) {
|
||||
|
@ -21,6 +22,11 @@ public class BPMLegChangeCommand extends Command {
|
|||
this.newleg = leg;
|
||||
return this;
|
||||
}
|
||||
public BPMLegChangeCommand reason(String reason) {
|
||||
this.reason = reason;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public BPMLegChangeCommand routeId(Long routeId) {
|
||||
this.routeId = routeId;
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.chint.application.commands;
|
||||
|
||||
import com.chint.domain.value_object.FinishLegData;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import lombok.Data;
|
||||
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_CHANGE;
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_FINISH;
|
||||
|
||||
@Data
|
||||
public class LegChangeCommand extends Command {
|
||||
private final Integer legEventType = LEG_EVENT_CHANGE;
|
||||
private Long legId;
|
||||
private String reason;
|
||||
|
||||
public LegChangeCommand legId(Long LegId) {
|
||||
this.setLegId(LegId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LegChangeCommand reason(String reason) {
|
||||
this.reason = reason;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ public class LegRes {
|
|||
private LocationRes originLocation;
|
||||
private LocationRes destinationLocation;
|
||||
|
||||
|
||||
private String amount;
|
||||
private String legTypeName;
|
||||
private String legTypeEnName;
|
||||
|
@ -44,7 +45,7 @@ public class LegRes {
|
|||
@ApiModelProperty("目的地详细")
|
||||
private String destinationDescription;
|
||||
private Integer legStatus;
|
||||
|
||||
private String changeReason;
|
||||
|
||||
private String legStatusName;
|
||||
|
||||
|
|
|
@ -25,6 +25,9 @@ public class FSSCController {
|
|||
public Result<LoginResponse> loginToFSSC() {
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
String companyCode = currentUser.getCompanyCode();//公司编号
|
||||
|
||||
|
||||
|
||||
return Result.Success(SUCCESS, LoginResponse.success(FSSCUrl + FSSC_LOGIN_PATH_APPROVAL + currentUser.getEmployeeNo()));
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,8 @@ public class OrderApplicationService {
|
|||
.orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND));
|
||||
order.reloadStatus();
|
||||
|
||||
List<Leg> legs = processLegData(addLegData.getLegData(), order);
|
||||
LegData legData = addLegData.getLegData();
|
||||
List<Leg> legs = processLegData(legData, order);
|
||||
orderDomainService.queryLocation(legs);
|
||||
RouteOrder routeOrder = orderDomainService.saveOrder(order);
|
||||
legs.forEach(leg -> {
|
||||
|
@ -86,6 +87,11 @@ public class OrderApplicationService {
|
|||
Command.of(LegApprovalCommand.class).legId(leg.getLegId()).sendToQueue();
|
||||
}
|
||||
|
||||
//如果是变更事件,推送变更事件
|
||||
if (legData.getChangeReason() != null) {
|
||||
Command.of(LegChangeCommand.class).legId(leg.getLegId()).reason(legData.getChangeReason()).sendToQueue();
|
||||
}
|
||||
|
||||
if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) {
|
||||
Command.of(BPMLegChangeCommand.class).newleg(leg).routeId(routeOrder.getRouteId()).changeType(0).sendToQueue();
|
||||
}
|
||||
|
@ -118,7 +124,20 @@ public class OrderApplicationService {
|
|||
leg.setDestinationId(legData.getDestinationId());
|
||||
orderDomainService.queryLocation(List.of(oldLeg,leg));
|
||||
legRepository.save(leg).reloadStatus();
|
||||
Command.of(BPMLegChangeCommand.class).routeId(addLegData.getRouteId()).oldLeg(oldLeg).newleg(leg).changeType(1).sendToQueue();
|
||||
|
||||
//保存变更事件理由
|
||||
Command.of(LegChangeCommand.class)
|
||||
.legId(leg.getLegId())
|
||||
.reason(legData.getChangeReason())
|
||||
.sendToQueue();
|
||||
//发送bpm保存结果
|
||||
Command.of(BPMLegChangeCommand.class)
|
||||
.routeId(addLegData.getRouteId())
|
||||
.reason(addLegData.getLegData().getChangeReason())
|
||||
.oldLeg(oldLeg)
|
||||
.newleg(leg)
|
||||
.changeType(1)
|
||||
.sendToQueue();
|
||||
|
||||
|
||||
//异步操作-如果是当前的状态已经进行过匹配,那么就要订单同步到供应商一次
|
||||
|
|
|
@ -22,8 +22,7 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER;
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
|
||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
|
@ -68,6 +67,8 @@ public class Leg {
|
|||
@Transient
|
||||
private String legStatusName;
|
||||
@Transient
|
||||
private String changeReason;
|
||||
@Transient
|
||||
private CurrencyType currencyType;
|
||||
@Transient
|
||||
private List<OrderDetail> orderDetails; //这个属性不做持久化保存 ,根据下单事件进行获取
|
||||
|
@ -117,7 +118,14 @@ public class Leg {
|
|||
this.getLegExtensionField().reloadStatus();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
//添加变更理由
|
||||
this.eventList
|
||||
.stream()
|
||||
.filter(legEvent -> legEvent.getEventType().equals(LEG_EVENT_CHANGE))
|
||||
.max(Comparator.comparingLong(LegEvent::getLegEventId))
|
||||
.ifPresent(legEvent -> this.changeReason = legEvent.getExtension());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ public class LegEvent {
|
|||
@Transient
|
||||
private String eventName;
|
||||
|
||||
private String extension;
|
||||
|
||||
private LocalDateTime happenTime;
|
||||
|
||||
@Transient
|
||||
|
@ -36,6 +38,7 @@ public class LegEvent {
|
|||
case LegConstant.LEG_EVENT_NOT_ORDERED -> LegConstant.LEG_EVENT_NOT_ORDERED_NAME;
|
||||
case LegConstant.LEG_EVENT_APPROVAL -> LegConstant.LEG_EVENT_APPROVAL_NAME;
|
||||
case LegConstant.LEG_EVENT_REJECT -> LegConstant.LEG_EVENT_REJECT_NAME;
|
||||
case LegConstant.LEG_EVENT_CHANGE -> LegConstant.LEG_EVENT_CHANGE_NAME;
|
||||
default -> "未知事件";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -47,13 +47,15 @@ public class RouteOrderFactory implements OrderFactory {
|
|||
User currentUser = BaseContext.getCurrentUser();
|
||||
User user = command.getUser();
|
||||
UserLoginParam loginParam = user.getUserLoginParam();
|
||||
String syscode = loginParam.getSyscode();
|
||||
String billcode = loginParam.getBillcode();
|
||||
RouteOrder routeOrder = new RouteOrder();
|
||||
routeOrder.setRouteOrderNo(OrderNo.generate());
|
||||
routeOrder.setRouteOrderNo(OrderNo.generate(syscode, billcode));
|
||||
//根据项目需求,需要保存假审批订单号,真审批订单号 ,创建的时候保存假审批订单号
|
||||
routeOrder.setUserId(loginParam.getSfno());
|
||||
ApproveOrderNo approveOrderNo = new ApproveOrderNo();
|
||||
approveOrderNo.setSysCode(loginParam.getSyscode());
|
||||
approveOrderNo.setFakeOrderNo(loginParam.getBillcode());
|
||||
approveOrderNo.setSysCode(syscode);
|
||||
approveOrderNo.setFakeOrderNo(billcode);
|
||||
approveOrderNo.setAccountCompany(currentUser.getCompanyCode());
|
||||
approveOrderNo.setAccountCompanyName(currentUser.getCompanyName());
|
||||
routeOrder.setApproveOrderNo(approveOrderNo);
|
||||
|
|
|
@ -244,7 +244,7 @@ public class LegEventHandler implements LegEventService {
|
|||
Integer changeType = command.getChangeType();
|
||||
Leg leg = command.getNewleg();
|
||||
Long routeId = leg.getRouteId();
|
||||
if(routeId == null){
|
||||
if (routeId == null) {
|
||||
routeId = command.getRouteId();
|
||||
}
|
||||
RouteOrder routeOrder = routeRepository.queryById(routeId);
|
||||
|
@ -254,7 +254,10 @@ public class LegEventHandler implements LegEventService {
|
|||
switch (bpmCode) {
|
||||
case H3_BPM -> {
|
||||
JTH3ChangeDto jth3ChangeDto = new JTH3ChangeDto();
|
||||
if(changeType.equals(0)){
|
||||
if (leg.getChangeReason() != null) {
|
||||
jth3ChangeDto.setReason(leg.getChangeReason());
|
||||
}
|
||||
if (changeType.equals(0)) {
|
||||
jth3ChangeDto.addLegNewTrip(leg);
|
||||
} else {
|
||||
jth3ChangeDto.addLegOldTrip(command.getOldLeg());
|
||||
|
@ -264,7 +267,10 @@ public class LegEventHandler implements LegEventService {
|
|||
}
|
||||
case XNYS_BPM -> {
|
||||
XNChangeDto xnChangeDto = new XNChangeDto();
|
||||
if(changeType.equals(0)){
|
||||
if (leg.getChangeReason() != null) {
|
||||
xnChangeDto.setReason(leg.getChangeReason());
|
||||
}
|
||||
if (changeType.equals(0)) {
|
||||
xnChangeDto.addLegNewTrip(leg);
|
||||
} else {
|
||||
xnChangeDto.addLegOldTrip(command.getOldLeg());
|
||||
|
@ -279,4 +285,12 @@ public class LegEventHandler implements LegEventService {
|
|||
default -> throw new NotFoundException(DATA_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeLeg(LegChangeCommand command) {
|
||||
Leg byLegId = legRepository.findByLegId(command.getLegId());
|
||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||
byLegId.addEvent(legEvent);
|
||||
legRepository.save(byLegId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,4 +28,6 @@ public interface LegEventService {
|
|||
void rejectLeg(LegRejectCommand command);
|
||||
|
||||
void pushChangeLegToBpm(BPMLegChangeCommand command);
|
||||
|
||||
void changeLeg(LegChangeCommand command);
|
||||
}
|
|
@ -80,4 +80,10 @@ public class LegEventServiceImpl implements LegEventService {
|
|||
public void pushChangeLegToBpm(BPMLegChangeCommand command) {
|
||||
legEventHandler.pushChangeLegToBpm(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ListenTo(command = "LegChangeCommand", order = 0)
|
||||
public void changeLeg(LegChangeCommand command) {
|
||||
legEventHandler.changeLeg(command);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
package com.chint.domain.value_object;
|
||||
|
||||
import com.chint.domain.aggregates.order.LegExtensionField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class LegData {
|
||||
|
||||
|
@ -13,6 +9,7 @@ public class LegData {
|
|||
|
||||
public final Integer legType;
|
||||
|
||||
private final String changeReason;
|
||||
|
||||
public final String startTime;
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ public class LegConstant {
|
|||
public static final String LEG_EVENT_ORDERED_NAME = "下单事件";
|
||||
public static final int LEG_EVENT_PAYED = 5;
|
||||
public static final String LEG_EVENT_PAYED_NAME = "付款事件";
|
||||
public static final int LEG_EVENT_CHANGE = 6;
|
||||
public static final String LEG_EVENT_CHANGE_NAME = "变更事件";
|
||||
public static final int LEG_EVENT_FINISH = 9;
|
||||
public static final String LEG_EVENT_FINISH_NAME = "结束事件";
|
||||
public static final int LEG_EVENT_REJECT = -1;
|
||||
|
|
|
@ -17,6 +17,11 @@ public class OrderNo {
|
|||
return "R" + datePart + randomPart;
|
||||
}
|
||||
|
||||
public static String generate(String sysCode, String billCode) {
|
||||
// 拼接最终的订单号
|
||||
return sysCode + "-" + billCode;
|
||||
}
|
||||
|
||||
public static String generateLegNo() {
|
||||
// 获取当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
|
|
@ -67,8 +67,8 @@ public class HotelBackController {
|
|||
.orderNo(serialNo)
|
||||
.outStatus(String.valueOf(notification.getSubNotifyType()));
|
||||
//状态映射
|
||||
command.eventType(ORDER_EVENT_ETA);
|
||||
command.sendToQueue();
|
||||
command2.eventType(ORDER_EVENT_ETA);
|
||||
command2.sendToQueue();
|
||||
}
|
||||
return new LYNoteResponse("100", "成功收到消息");
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ cTrip:
|
|||
requestSecret: zhengtai2024_nEbmKfOo
|
||||
|
||||
FSSC:
|
||||
baseUrl: http://10.10.14.178:8080
|
||||
baseUrl: https://fssc-t.chint.com
|
||||
|
||||
paila:
|
||||
client-id: 0053df85723db94491e8
|
||||
|
|
|
@ -21,7 +21,7 @@ cTrip:
|
|||
requestSecret: zhengtai2024_nEbmKfOo
|
||||
|
||||
FSSC:
|
||||
baseUrl: http://10.10.14.178:8080
|
||||
baseUrl: https://fssc-t.chint.com
|
||||
|
||||
paila:
|
||||
client-id: 0053df85723db94491e8
|
||||
|
|
|
@ -40,7 +40,7 @@ cTrip:
|
|||
requestSecret: zhengtai2024_nEbmKfOo
|
||||
|
||||
FSSC:
|
||||
baseUrl: http://10.10.14.178:8080
|
||||
baseUrl: https://fssc-t.chint.com
|
||||
|
||||
paila:
|
||||
client-id: 0053df85723db94491e8
|
||||
|
|
Loading…
Reference in New Issue