BPM流程接口调整

This commit is contained in:
dengwc 2024-03-02 16:04:10 +08:00
parent ac730f039d
commit 8c14110a91
11 changed files with 204 additions and 50 deletions

View File

@ -112,14 +112,14 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
hotelOrderDetail = new HotelOrderDetail();
}
if (byOrderNo.isPresent() && byOrderNo.get()
.getLastEvent()
.getEventType()
.equals(ORDER_EVENT_ETA)) {
hotelOrderDetail.setOverStandard("true");
} else {
hotelOrderDetail.setOverStandard("false");
}
// if (byOrderNo.isPresent() && byOrderNo.get()
// .getLastEvent()
// .getEventType()
// .equals(ORDER_EVENT_ETA)) {
// hotelOrderDetail.setOverStandard("true");
// } else {
// hotelOrderDetail.setOverStandard("false");
// }
hotelOrderDetail.setOrderNo(orderNo); //订单号
hotelOrderDetail.setOverStandard(null); //是否超标

View File

@ -39,7 +39,7 @@ public class SupplierServiceImpl implements SupplierService {
Optional<OrderLegData> data = orderDataAdapterSelector.of(supplierName).adapt(callbackData);
if (data.isPresent()) {
//获取使用RouteUpdateOrderCommand命令创建的orderDetail
OrderLegData orderLegData = data.get();
OrderLegData orderLegData = data.get();
Properties properties = Command.of(RouteUpdateOrderCommand.class).data(orderLegData).sendToQueue();
ResultContainer byPropertyName = properties.findByPropertyName(RESULT_ORDER_DETAIL);
OrderDetail orderDetail = (OrderDetail) byPropertyName.getValue();
@ -50,9 +50,13 @@ public class SupplierServiceImpl implements SupplierService {
//根据产品的不同类型添加不同的扩展字段
switch (productType) {
case LegConstant.LEG_TYPE_TRAIN -> orderDetail.addTrainOrderData(
orderExtensionFactory.createTrainOrderDetail(orderLegData.getTrainOrderDetailData())
);
case LegConstant.LEG_TYPE_TRAIN -> {
if (orderLegData.getTrainOrderDetailData() != null) {
orderDetail.addTrainOrderData(
orderExtensionFactory.createTrainOrderDetail(orderLegData.getTrainOrderDetailData())
);
}
}
case LegConstant.LEG_TYPE_AIRPLANE -> orderDetail.addFlightOrderData(
orderExtensionFactory.createFlightOrderDetail(orderLegData.getFlightOrderDetailData())
);

View File

@ -10,11 +10,16 @@ public class BPMConstant {
public static final String AN_FSSC = "ANFSSC";
public static final String ANYS_BPM = "ANYSBPM";
public static final String H3BPM_EXCEED_STANDARD_URL = "/Portal/Webservices/ExternalStartService.asmx/StartWorkflowByEntityTransJson";//H3BPM
public static final String XNBPM_TOKEN_URL = "/api/login/crm/ajax";//新能云枢获取token和用户id
public static final String YSBPM_TOKEN_URL = "/api/login/crm/ajax";//新能云枢获取token和用户id
public static final String XNBPM_EXCEED_STANDARD_URL = "/api/openapi/v3/workflow/start";//新能云枢发起流程
public static final String CLIENT_ID = "xclient";//客户端id
public static final String CLIENT_SECRET = "0a417ecce58c31b32364ce19ca8fcd15";//密钥
//新能云枢
public static final String XN_CLIENT_ID = "xclient";//客户端id
public static final String XN_CLIENT_SECRET = "0a417ecce58c31b32364ce19ca8fcd15";//密钥
//智维云枢
public static final String ZW_CLIENT_ID = "xclient";//客户端id
public static final String ZW_CLIENT_SECRET = "0a417ecce58c31b32364ce19ca8fcd15";//密钥
public static final String EXCEED_STANDARD_TYPE_TRAIN = "火车票超标";//方法名称
public static final String EXCEED_STANDARD_TYPE_HOTEL = "酒店超标";//方法名称

View File

@ -9,7 +9,7 @@ import com.chint.domain.aggregates.user.User;
import com.chint.infrastructure.util.BaseContext;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.bpm.XNBPM.ClientFactory;
import com.chint.interfaces.rest.bpm.XNBPM.XNTokenDto;
import com.chint.interfaces.rest.bpm.XNBPM.YSTokenDto;
import com.chint.interfaces.rest.bpm.dot.BPMBaseResponse;
import com.chint.interfaces.rest.bpm.dto.*;
import com.google.gson.Gson;
@ -21,8 +21,7 @@ import org.springframework.stereotype.Service;
import java.lang.reflect.Type;
import java.util.HashMap;
import static com.chint.infrastructure.constant.BPMConstant.H3BPM_EXCEED_STANDARD_URL;
import static com.chint.infrastructure.constant.BPMConstant.XNBPM_TOKEN_URL;
import static com.chint.infrastructure.constant.BPMConstant.*;
@Service
@ -37,11 +36,15 @@ public class BPMRequest {
@Value("${bpm.XNBPMUrl}")
private String XNBPMUrl;
@Value("${bpm.ZWBPMUrl}")
private String ZWBPMUrl;
//超标申请
public BPMResponse exceedStandard(ExceedStandardDto exceedStandardDto, String sysCode) {
return switch (sysCode) {
case "FSSC", "H3BPM" -> H3BPMSubmitWorkflow("JT_FI_CLCESQ", exceedStandardDto);
case "XNFSSC" -> XNBPMSubmitWorkflow("JG_AS_CLCESQ", exceedStandardDto);
case "XNFSSC" -> BPMSubmitWorkflow("JG_AS_CLCESQ", exceedStandardDto, XNBPMUrl, sysCode);
case "ZWFSSC" -> BPMSubmitWorkflow("ZW_AS_CLCESQ", exceedStandardDto, ZWBPMUrl, sysCode);
case "ANFSSC" -> null;
default -> {
BPMResponse bpmResponse = new BPMResponse();
@ -56,7 +59,8 @@ public class BPMRequest {
public BPMResponse reschedule(RescheduleDto rescheduleDto, String sysCode) {
return switch (sysCode) {
case "FSSC", "H3BPM" -> H3BPMSubmitWorkflow("JT_FI_CLGQSQ", rescheduleDto);
case "XNFSSC" -> XNBPMSubmitWorkflow("JG_AS_CLGQSQ", rescheduleDto);
case "XNFSSC" -> BPMSubmitWorkflow("JG_AS_CLGQSQ", rescheduleDto, XNBPMUrl, sysCode);
case "ZWFSSC" -> BPMSubmitWorkflow("ZW_AS_CLGQSQ", rescheduleDto, ZWBPMUrl, sysCode);
case "ANFSSC" -> null;
default -> {
BPMResponse bpmResponse = new BPMResponse();
@ -71,7 +75,8 @@ public class BPMRequest {
public <T> BPMResponse change(T changeDto, String sysCode) {
return switch (sysCode) {
case "FSSC", "H3BPM" -> H3BPMSubmitWorkflow("JT_FI_CLBGSQ", changeDto);
case "XNFSSC" -> XNBPMSubmitWorkflow("XN_AS_CLBGSQ", changeDto);
case "XNFSSC" -> BPMSubmitWorkflow("XN_AS_CLBGSQ", changeDto, XNBPMUrl, sysCode);
case "ZWFSSC" -> BPMSubmitWorkflow("ZW_AS_CLBGSQ", changeDto, ZWBPMUrl, sysCode);
case "ANFSSC" -> null;
default -> {
BPMResponse bpmResponse = new BPMResponse();
@ -101,18 +106,26 @@ public class BPMRequest {
}
/**
* 新能云枢接口
* 新能智维云枢接口
*/
public BPMResponse XNBPMSubmitWorkflow(String workflowCode, Object entityObject) {
public BPMResponse BPMSubmitWorkflow(String workflowCode, Object entityObject, String url, String sysCode) {
//获取用户信息
User user = BaseContext.getCurrentUser();
String employeeNo = user.getEmployeeNo();//sf号
XNTokenDto xnTokenDto = httpPostRequest.get(XNBPMUrl + XNBPM_TOKEN_URL + "?code=" + employeeNo, XNTokenDto.class);
if (!"0".equals(xnTokenDto.getErrcode())) {
YSTokenDto tokenDto = httpPostRequest.get(url + YSBPM_TOKEN_URL + "?code=" + employeeNo, YSTokenDto.class);
if (!"0".equals(tokenDto.getErrcode())) {
throw new RuntimeException("用户不存在!");
}
String userId = xnTokenDto.getUser_id();
CloudpivotOpenClient client = ClientFactory.getInstance();
String userId = tokenDto.getUser_id();
CloudpivotOpenClient client;
if ("XNFSSC".equals(sysCode)) {
//新能
client = ClientFactory.getXNInstance();
} else {
//智维
client = ClientFactory.getZWInstance();
}
StartWorkflowRequest request = new StartWorkflowRequest();
Gson gson = new Gson();
String entityParamValues = gson.toJson(entityObject);

View File

@ -17,18 +17,36 @@ public class ClientFactory {
private static CloudpivotOpenClient client;
private static String XNBPMUrl;
private static String ZWBPMUrl;
@Value("${bpm.XNBPMUrl}")
public void setXNBPMUrl(String XNBPMUrl) {
ClientFactory.XNBPMUrl = XNBPMUrl;
}
@Value("${bpm.ZWBPMUrl}")
public void setZWBPMUrl(String ZWBPMUrl) {
ClientFactory.ZWBPMUrl = ZWBPMUrl;
}
public synchronized static CloudpivotOpenClient getInstance() {
public synchronized static CloudpivotOpenClient getXNInstance() {
if (client == null) {
synchronized (CloudpivotOpenClient.class) {
if (client == null) {
CloudpivotEnvConfig config = new CloudpivotEnvConfig(XNBPMUrl + "/api", CLIENT_ID, CLIENT_SECRET);
CloudpivotEnvConfig config = new CloudpivotEnvConfig(XNBPMUrl + "/api", XN_CLIENT_ID, XN_CLIENT_SECRET);
client = new CloudpivotOpenClient(config, new JdkHttpClient());
}
}
}
return client;
}
public synchronized static CloudpivotOpenClient getZWInstance() {
if (client == null) {
synchronized (CloudpivotOpenClient.class) {
if (client == null) {
CloudpivotEnvConfig config = new CloudpivotEnvConfig(ZWBPMUrl + "/api", ZW_CLIENT_ID, ZW_CLIENT_SECRET);
client = new CloudpivotOpenClient(config, new JdkHttpClient());
}
}

View File

@ -3,7 +3,7 @@ package com.chint.interfaces.rest.bpm.XNBPM;
import lombok.Data;
@Data
public class XNTokenDto {
public class YSTokenDto {
private String errcode;
private String access_token;
private String refresh_token;

View File

@ -4,7 +4,7 @@ import lombok.Data;
@Data
public class BPMBack {
private String tag;//BPM平台H3BPM/XNBPM/其它
private String tag;//BPM平台H3BPM/XNBPM/ZWBPM/CPSH3/其它
private String orderNo;//订单号
private String orderType;//订单类型 超标:酒店超标火车票超标机票超标 改签:机票改签机票退票火车票改签火车票退票
private String orderSource;//订单来源: 携程商旅/同程商旅

View File

@ -66,4 +66,5 @@ paila:
bpm:
H3BPMUrl: http://10.207.0.245:8012
XNBPMUrl: http://10.145.30.119:8090
XNBPMUrl: http://10.145.30.119:8090
ZWBPMUrl: https://zwtbpm.astronergy.com

View File

@ -54,4 +54,5 @@ paila:
bpm:
H3BPMUrl: http://10.207.0.245:8012
XNBPMUrl: http://10.145.30.119:8090
XNBPMUrl: http://10.145.30.119:8090
ZWBPMUrl: https://zwtbpm.astronergy.com

View File

@ -11,7 +11,7 @@ import com.chint.infrastructure.constant.LYConstant;
import com.chint.infrastructure.util.BaseContext;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.bpm.XNBPM.ClientFactory;
import com.chint.interfaces.rest.bpm.XNBPM.XNTokenDto;
import com.chint.interfaces.rest.bpm.XNBPM.YSTokenDto;
import com.chint.interfaces.rest.bpm.dot.*;
import com.chint.interfaces.rest.bpm.dto.*;
import com.chint.interfaces.rest.ly.LYLoginRequest;
@ -37,9 +37,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import static com.chint.infrastructure.constant.BPMConstant.H3BPM_EXCEED_STANDARD_URL;
import static com.chint.infrastructure.constant.BPMConstant.XNBPM_TOKEN_URL;
import static com.chint.infrastructure.constant.BPMConstant.*;
@SpringBootTest
public class LYTest {
@ -65,6 +63,10 @@ public class LYTest {
@Value("${bpm.XNBPMUrl}")
private String XNBPMUrl;
@Value("${bpm.ZWBPMUrl}")
private String ZWBPMUrl;
public static final String L_Y_BASE_URL = "https://api.qa.dttrip.cn/openapi";
public static final String L_Y_ORDER_PATH = "/openapi/api/TravelApplyOrder/ApplyOrderSync";
@ -425,12 +427,12 @@ public class LYTest {
*/
@Test
public void testDemo() throws Exception {
XNTokenDto xnTokenDto = httpPostRequest.get(XNBPMUrl + XNBPM_TOKEN_URL + "?code=" + "191107079", XNTokenDto.class);
if (!"0".equals(xnTokenDto.getErrcode())) {
YSTokenDto tokenDto = httpPostRequest.get(XNBPMUrl + YSBPM_TOKEN_URL + "?code=" + "191107079", YSTokenDto.class);
if (!"0".equals(tokenDto.getErrcode())) {
throw new RuntimeException("用户不存在!");
}
String userId = xnTokenDto.getUser_id();
CloudpivotOpenClient client = ClientFactory.getInstance();
String userId = tokenDto.getUser_id();
CloudpivotOpenClient client = ClientFactory.getXNInstance();
StartWorkflowRequest request = new StartWorkflowRequest();
Gson gson = new Gson();
ExceedStandardDto exceedStandardDto = new ExceedStandardDto();
@ -468,12 +470,12 @@ public class LYTest {
*/
@Test
public void testDemo2() throws Exception {
XNTokenDto xnTokenDto = httpPostRequest.get(XNBPMUrl + XNBPM_TOKEN_URL + "?code=" + "191107079", XNTokenDto.class);
if (!"0".equals(xnTokenDto.getErrcode())) {
YSTokenDto tokenDto = httpPostRequest.get(XNBPMUrl + YSBPM_TOKEN_URL + "?code=" + "191107079", YSTokenDto.class);
if (!"0".equals(tokenDto.getErrcode())) {
throw new RuntimeException("用户不存在!");
}
String userId = xnTokenDto.getUser_id();
CloudpivotOpenClient client = ClientFactory.getInstance();
String userId = tokenDto.getUser_id();
CloudpivotOpenClient client = ClientFactory.getXNInstance();
StartWorkflowRequest request = new StartWorkflowRequest();
Gson gson = new Gson();
RescheduleDto rescheduleDto = new RescheduleDto();
@ -510,12 +512,12 @@ public class LYTest {
*/
@Test
public void testDemo3() throws Exception {
XNTokenDto xnTokenDto = httpPostRequest.get(XNBPMUrl + XNBPM_TOKEN_URL + "?code=" + "191107079", XNTokenDto.class);
if (!"0".equals(xnTokenDto.getErrcode())) {
YSTokenDto tokenDto = httpPostRequest.get(XNBPMUrl + YSBPM_TOKEN_URL + "?code=" + "191107079", YSTokenDto.class);
if (!"0".equals(tokenDto.getErrcode())) {
throw new RuntimeException("用户不存在!");
}
String userId = xnTokenDto.getUser_id();
CloudpivotOpenClient client = ClientFactory.getInstance();
String userId = tokenDto.getUser_id();
CloudpivotOpenClient client = ClientFactory.getXNInstance();
StartWorkflowRequest request = new StartWorkflowRequest();
Gson gson = new Gson();
XNChangeDto changeDto = new XNChangeDto();
@ -573,4 +575,114 @@ public class LYTest {
}
}
//智维BPM
@Test
public void testDemo4() throws Exception {
YSTokenDto tokenDto = httpPostRequest.get(ZWBPMUrl + YSBPM_TOKEN_URL + "?code=" + "210413023", YSTokenDto.class);//191107079
if (!"0".equals(tokenDto.getErrcode())) {
throw new RuntimeException("用户不存在!");
}
String userId = tokenDto.getUser_id();
CloudpivotOpenClient client = ClientFactory.getZWInstance();
StartWorkflowRequest request = new StartWorkflowRequest();
Gson gson = new Gson();
ZWChangeDto changeDto = new ZWChangeDto();
//新增行程
ArrayList<LegNewTrip> newTrips = new ArrayList<>();
LegNewTrip newTrip = new LegNewTrip();
newTrip.setAllowProductTypes("飞机")
.setDepartCitiesName("温州")
.setArriveCitiesName("北京")
.setBsDate("2024-03-01")
.setEdDate("2024-03-01")
.setReason("出差帮扶");
newTrips.add(newTrip);
//原行程
ArrayList<LegOldTrip> oldTrips = new ArrayList<>();
LegOldTrip oldTrip = new LegOldTrip();
oldTrip.setAllowProductTypes("火车")
.setDepartCitiesName("温州")
.setArriveCitiesName("杭州")
.setBsDate("2024-03-01")
.setEdDate("2024-03-01");
oldTrips.add(oldTrip);
//变更行程
ArrayList<LegChangeTrip> changeTrips = new ArrayList<>();
LegChangeTrip changeTrip = new LegChangeTrip();
changeTrip.setAllowProductTypes("火车")
.setDepartCitiesName("乐清")
.setArriveCitiesName("杭州")
.setBsDate("2024-03-01")
.setEdDate("2024-03-01")
.setReason("出发地变更");
changeTrips.add(changeTrip);
//设置值
changeDto.setStartTime("2024-03-01")//出差开始时间
.setEndTime("2024-03-01")//出差结束时间
.setReason("出差帮扶")//出差说明
.setZW_AS_CLBGSQ_ITEM_NewTrip(newTrips)//新增行程信息
.setZW_AS_CLBGSQ_ITEM_OldTrip(oldTrips)//原行程信息
.setZW_AS_CLBGSQ_ITEM_ChangeTrip(changeTrips);//变更行程信息
String entityParamValues = gson.toJson(changeDto);
Type type = new TypeToken<HashMap<String, Object>>() {
}.getType();
HashMap<String, Object> map = gson.fromJson(entityParamValues, type);
request.setData(map);//数据
request.setDepartmentId("");//部门id默认主部门
request.setFinishStart(true);//发起流程
request.setUserId(userId);//员工号
request.setWorkflowCode("ZW_AS_CLBGSQ");//差旅变更流程
try {
StartWorkflowResponse response = client.startWorkflow(request);
System.out.println("response = " + JSON.toJSONString(response));
} catch (ApiException e) {
throw new RuntimeException(e.getMessage());
}
}
/**
* 云枢超标流程测试
*/
@Test
public void testDemo5() throws Exception {
YSTokenDto tokenDto = httpPostRequest.get(ZWBPMUrl + YSBPM_TOKEN_URL + "?code=" + "210413023", YSTokenDto.class);
if (!"0".equals(tokenDto.getErrcode())) {
throw new RuntimeException("用户不存在!");
}
String userId = tokenDto.getUser_id();
CloudpivotOpenClient client = ClientFactory.getZWInstance();
StartWorkflowRequest request = new StartWorkflowRequest();
Gson gson = new Gson();
ExceedStandardDto exceedStandardDto = new ExceedStandardDto();
exceedStandardDto.setOrderType("酒店超标")//内容选项酒店超标火车票超标机票超标
.setOrderSource("携程商旅")//内容选项:携程商旅/同程商旅
.setOrderNo("001021214")//订单号
.setHotelStandard("标间")//酒店超标提供住宿标准
.setHotelName("酒店名称")//酒店超标提供酒店名称
.setHouseLayout("双人床")//酒店超标提供房型
.setSeatingStandard("")//火车票超标提供席别标准
.setCabinClass("")//机票超标提供舱等
.setExcessAmount(BigDecimal.valueOf(1000))//超标金额
.setReason("酒店爆满订不到");//超标原因
String entityParamValues = gson.toJson(exceedStandardDto);
Type type = new TypeToken<HashMap<String, Object>>() {
}.getType();
HashMap<String, Object> map = gson.fromJson(entityParamValues, type);
request.setData(map);//数据
request.setDepartmentId("");//部门id默认主部门
request.setFinishStart(true);//发起流程
request.setUserId(userId);//员工号
request.setWorkflowCode("ZW_AS_CLCESQ");//超标流程
try {
StartWorkflowResponse response = client.startWorkflow(request);
System.out.println("response = " + JSON.toJSONString(response));
} catch (ApiException e) {
throw new RuntimeException(e.getMessage());
}
}
}

View File

@ -144,7 +144,7 @@ class RouteApplicationTests {
}
@Test
void loginSign() {
String sfno = "230615020";
String sfno = "231116011";
String syscode = "FSSC";
String billcode = "CLSQ240301009999";
String companycode = "正泰集团股份有限公司";