变更流程代码调整

This commit is contained in:
dengwc 2024-03-02 13:12:02 +08:00
parent dbf5d8b2d4
commit ff50758011
6 changed files with 39 additions and 14 deletions

View File

@ -7,6 +7,7 @@ import lombok.Data;
@Data
public class BPMLegChangeCommand extends Command {
private Long routeId;
private Leg oldLeg;
private Leg newleg;
private Integer changeType; //0 is add, 1 is update
@ -21,6 +22,11 @@ public class BPMLegChangeCommand extends Command {
return this;
}
public BPMLegChangeCommand routeId(Long routeId) {
this.routeId = routeId;
return this;
}
public BPMLegChangeCommand changeType(Integer changeType) {
this.changeType = changeType;
return this;

View File

@ -76,16 +76,18 @@ public class OrderApplicationService {
order.reloadStatus();
List<Leg> legs = processLegData(addLegData.getLegData(), order);
orderDomainService.queryLocation(legs);
RouteOrder routeOrder = orderDomainService.saveOrder(order);
legs.forEach(leg -> {
leg.reloadStatus();
Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue();
//如果订单状态已经处于审批中 那么为这个新增的leg也提交审批状态
if (order.getOrderStatus() >= ORDER_STATUS_APPROVAL) {
Command.of(LegApprovalCommand.class).legId(leg.getLegId()).sendToQueue();
}
if (order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) {
Command.of(BPMLegChangeCommand.class).newleg(leg).changeType(0).sendToQueue();
if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) {
Command.of(BPMLegChangeCommand.class).newleg(leg).routeId(routeOrder.getRouteId()).changeType(0).sendToQueue();
}
});
@ -104,19 +106,19 @@ public class OrderApplicationService {
@Transactional
public void changeLeg(AddLegData addLegData) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LegData legData = addLegData.getLegData();
Leg leg = Optional.ofNullable(
legRepository.findByLegId(legData.getLegId())
).orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND));
).orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND)).reloadStatus();
Leg oldLeg = BeanUtil.copyProperties(leg, Leg.class);
leg.setStartTime(LocalDateTime.parse(legData.getStartTime(), formatter));
leg.setEndTime(LocalDateTime.parse(legData.getEndTime(), formatter));
leg.setOriginId(legData.getOriginId());
leg.setDestinationId(legData.getDestinationId());
legRepository.save(leg);
legRepository.save(leg).reloadStatus();
Command.of(BPMLegChangeCommand.class).oldLeg(oldLeg).newleg(leg).changeType(1).sendToQueue();
Command.of(BPMLegChangeCommand.class).routeId(addLegData.getRouteId()).oldLeg(oldLeg).newleg(leg).changeType(1).sendToQueue();
//异步操作-如果是当前的状态已经进行过匹配那么就要订单同步到供应商一次

View File

@ -244,6 +244,9 @@ public class LegEventHandler implements LegEventService {
Integer changeType = command.getChangeType();
Leg leg = command.getNewleg();
Long routeId = leg.getRouteId();
if(routeId == null){
routeId = command.getRouteId();
}
RouteOrder routeOrder = routeRepository.queryById(routeId);
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
SystemCode bySysCode = systemCodeRepository.findBySysCode(sysCode);

View File

@ -76,6 +76,7 @@ public class LegEventServiceImpl implements LegEventService {
}
@Override
@ListenTo(command = "BPMLegChangeCommand", order = 0)
public void pushChangeLegToBpm(BPMLegChangeCommand command) {
legEventHandler.pushChangeLegToBpm(command);
}

View File

@ -4,12 +4,15 @@ import com.chint.domain.aggregates.standards.TravelStandards;
import com.chint.domain.value_object.TravelStandardsData;
import com.chint.infrastructure.constant.BPMConstant;
import com.chint.infrastructure.constant.CommonMessageConstant;
import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.bpm.dot.BPMBack;
import com.chint.interfaces.rest.ctrip.CTripAuditRequest;
import com.chint.interfaces.rest.ly.dto.strokepush.Param;
import com.chint.interfaces.rest.ly.dto.strokepush.StrokeController;
import com.chint.interfaces.rest.ly.dto.strokepush.StrokePushDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -30,6 +33,9 @@ public class BPMController {
@Autowired
private CTripAuditRequest cTripAuditRequest;
@Autowired
private StrokeController strokeController;
//超标
@ApiOperation("BPM超标审批结果回传")
@PostMapping("/exceedStandard/back")
@ -42,7 +48,7 @@ public class BPMController {
//携程商旅
if (SUPPLIER_C_TRIP_BPM_NAME.equals(bpmBack.getOrderSource())) {
Integer orderType = getCTripOrderType(orderTypeValue); // 调用方法获取订单类型
if ("通过".equals(result)||"同意".equals(result)) {
if ("通过".equals(result) || "同意".equals(result)) {
cTripAuditRequest.auditSuccess(bpmBack.getOrderNo(), orderType);
} else {
cTripAuditRequest.auditFail(bpmBack.getOrderNo(), orderType);
@ -50,12 +56,17 @@ public class BPMController {
}
//同程商旅
if (SUPPLIER_L_Y_BPM_NAME.equals(bpmBack.getOrderSource())) {
Integer orderType = getLYOrderType(orderTypeValue); // 调用方法获取订单类型
if ("通过".equals(result)||"同意".equals(result)) {
cTripAuditRequest.auditSuccess(bpmBack.getOrderNo(), orderType);
StrokePushDTO strokePushDTO = new StrokePushDTO();
Param param = new Param();
if ("通过".equals(result) || "同意".equals(result)) {
param.setTravelBizOrderNo(bpmBack.getOrderNo())//同程行程单号
.setApprovalStatus(2);//1驳回 2通过
} else {
cTripAuditRequest.auditFail(bpmBack.getOrderNo(), orderType);
param.setTravelBizOrderNo(bpmBack.getOrderNo())//同程行程单号
.setApprovalStatus(1);//1驳回 2通过
}
strokePushDTO.setParam(param);
strokeController.strokePush(strokePushDTO);
}
}
return Result.Success(CommonMessageConstant.SUCCESS);
@ -94,7 +105,7 @@ public class BPMController {
}
//同程类型映射
public Integer getLYOrderType(String orderType) {
/*public Integer getLYOrderType(String orderType) {
return switch (orderType) {
case EXCEED_STANDARD_TYPE_TRAIN -> PRODUCT_TYPE_TRAIN;
case EXCEED_STANDARD_TYPE_HOTEL -> PRODUCT_TYPE_TRAIN_HOTEL;
@ -102,6 +113,6 @@ public class BPMController {
case EXCEED_STANDARD_TYPE_CAR -> PRODUCT_TYPE_TRAIN_CAR;
default -> 0; // 默认值如果都不匹配则为0
};
}
}*/
}

View File

@ -3,10 +3,12 @@ package com.chint.interfaces.rest.ly.dto.strokepush;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Param {
private String travelBizOrderNo;
private Integer remarks;