新能云枢超标、改签、变更流程代码调整

This commit is contained in:
dengwc 2024-03-01 18:15:46 +08:00
parent 12f272a395
commit 040917c413
7 changed files with 286 additions and 35 deletions

View File

@ -6,7 +6,9 @@ import com.chint.infrastructure.constant.BPMConstant;
import com.chint.infrastructure.constant.CommonMessageConstant;
import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.bpm.dot.BPMBack;
import com.chint.interfaces.rest.ctrip.CTripAuditRequest;
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;
@ -16,20 +18,46 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static com.chint.infrastructure.constant.BPMConstant.H3BPM;
import static com.chint.infrastructure.constant.BPMConstant.*;
import static com.chint.infrastructure.constant.Constant.*;
import static com.chint.infrastructure.constant.SupplierNameConstant.*;
@RestController
@RequestMapping("/public/BPM")
public class BPMController {
@Autowired
private CTripAuditRequest cTripAuditRequest;
//超标
@ApiOperation("BPM超标审批结果回传")
@PostMapping("/exceedStandard/back")
public Result<TravelStandards> exceedStandardBack(@RequestBody BPMBack bpmBack) {
//H3BPM平台
if (H3BPM.equals(bpmBack.getTag())) {
System.out.println("H3BPM");
}
System.out.println("bpmBack = " + bpmBack);
String result = bpmBack.getResult();//结果
String orderTypeValue = bpmBack.getOrderType(); // 获取订单类型的值
if (orderTypeValue != null) {
//携程商旅
if (SUPPLIER_C_TRIP_BPM_NAME.equals(bpmBack.getOrderSource())) {
Integer orderType = getCTripOrderType(orderTypeValue); // 调用方法获取订单类型
if ("通过".equals(result)) {
cTripAuditRequest.auditSuccess(bpmBack.getOrderNo(), orderType);
} else {
cTripAuditRequest.auditFail(bpmBack.getOrderNo(), orderType);
}
}
//同程商旅
if (SUPPLIER_L_Y_BPM_NAME.equals(bpmBack.getOrderSource())) {
Integer orderType = getLYOrderType(orderTypeValue); // 调用方法获取订单类型
if ("通过".equals(result)) {
cTripAuditRequest.auditSuccess(bpmBack.getOrderNo(), orderType);
} else {
cTripAuditRequest.auditFail(bpmBack.getOrderNo(), orderType);
}
}
}
return Result.Success(CommonMessageConstant.SUCCESS);
}
@ -50,4 +78,30 @@ public class BPMController {
System.out.println("bpmBack = " + bpmBack);
return Result.Success(CommonMessageConstant.SUCCESS);
}
//类型映射
//携程类型映射
//1:机票2酒店3火车票4用车(接送机/国内租车马上用车国内包车汽车票)
public Integer getCTripOrderType(String orderType) {
return switch (orderType) {
case EXCEED_STANDARD_TYPE_TRAIN -> 3;
case EXCEED_STANDARD_TYPE_HOTEL -> 2;
case EXCEED_STANDARD_TYPE_FLIGHT -> 1;
case EXCEED_STANDARD_TYPE_CAR -> 4;
default -> 0; // 默认值如果都不匹配则为0
};
}
//同程类型映射
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;
case EXCEED_STANDARD_TYPE_FLIGHT -> PRODUCT_TYPE_FLY;
case EXCEED_STANDARD_TYPE_CAR -> PRODUCT_TYPE_TRAIN_CAR;
default -> 0; // 默认值如果都不匹配则为0
};
}
}

View File

@ -11,10 +11,7 @@ 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.dot.BPMBaseResponse;
import com.chint.interfaces.rest.bpm.dto.BPMBaseRequest;
import com.chint.interfaces.rest.bpm.dto.BPMResponse;
import com.chint.interfaces.rest.bpm.dto.ExceedStandardDto;
import com.chint.interfaces.rest.bpm.dto.RescheduleDto;
import com.chint.interfaces.rest.bpm.dto.*;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.springframework.beans.factory.annotation.Autowired;
@ -41,21 +38,48 @@ public class BPMRequest {
private String XNBPMUrl;
//超标申请
public BPMResponse exceedStandard(ExceedStandardDto exceedStandardDto , String sysCode ) {
if ("H3BPM".equals("XNBPM")) {
return XNBPMSubmitWorkflow("JG_AS_CLCESQ", exceedStandardDto);
} else {
return H3BPMSubmitWorkflow("JT_FI_CLCESQ", exceedStandardDto);
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 "ANFSSC" -> null;
default -> {
BPMResponse bpmResponse = new BPMResponse();
bpmResponse.setSuccess(false);
bpmResponse.setMessage("订单系统标识不正确!");
yield bpmResponse;
}
};
}
//改签申请
public BPMResponse reschedule(RescheduleDto rescheduleDto) {
if ("H3BPM".equals("XNBPM")) {
return XNBPMSubmitWorkflow("JG_AS_CLGQSQ", rescheduleDto);
} else {
return H3BPMSubmitWorkflow("JT_FI_CLGQSQ", rescheduleDto);
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 "ANFSSC" -> null;
default -> {
BPMResponse bpmResponse = new BPMResponse();
bpmResponse.setSuccess(false);
bpmResponse.setMessage("订单系统标识不正确!");
yield bpmResponse;
}
};
}
//变更申请
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 "ANFSSC" -> null;
default -> {
BPMResponse bpmResponse = new BPMResponse();
bpmResponse.setSuccess(false);
bpmResponse.setMessage("订单系统标识不正确!");
yield bpmResponse;
}
};
}
/**

View File

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

View File

@ -10,7 +10,7 @@ import java.util.List;
*/
@Data
@Accessors(chain = true)
public class ChangeDto {
public class JTH3ChangeDto {
private String StartTime;//出差开始时间 是否必填
private String EndTime;//出差结束时间 是否必填
private String Reason;//出差说明 是否必填

View File

@ -0,0 +1,51 @@
package com.chint.interfaces.rest.bpm.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
public class XNChangeDto {
private String StartTime;//出差开始时间 是否必填
private String EndTime;//出差结束时间 是否必填
private String Reason;//出差说明 是否必填
private List<JTH3ChangeDto.NewTrip> XN_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填
private List<JTH3ChangeDto.OldTrip> XN_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填
private List<JTH3ChangeDto.ChangeTrip> XN_AS_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填
//新增行程信息
@Data
@Accessors(chain = true)
public static class NewTrip {
private String AllowProductTypes;//行程类型 是否必填
private String DepartCitiesName;//出发地 是否必填
private String ArriveCitiesName;//目的地 是否必填
private String bsDate;//开始时间 是否必填
private String edDate;//结束时间 是否必填
private String Reason;//新增行程原因 是否必填
}
//原行程信息
@Data
@Accessors(chain = true)
public static class OldTrip {
private String AllowProductTypes;//行程类型 是否必填
private String DepartCitiesName;//出发地 是否必填
private String ArriveCitiesName;//目的地 是否必填
private String bsDate;//开始时间 是否必填
private String edDate;//结束时间 是否必填
}
//变更行程信息
@Data
@Accessors(chain = true)
public static class ChangeTrip {
private String AllowProductTypes;//行程类型 是否必填
private String DepartCitiesName;//出发地 是否必填
private String ArriveCitiesName;//目的地 是否必填
private String bsDate;//开始时间 是否必填
private String edDate;//结束时间 是否必填
private String Reason;//新增行程原因 是否必填
}
}

View File

@ -0,0 +1,52 @@
package com.chint.interfaces.rest.bpm.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
public class ZWChangeDto {
private String StartTime;//出差开始时间 是否必填
private String EndTime;//出差结束时间 是否必填
private String Reason;//出差说明 是否必填
private List<JTH3ChangeDto.NewTrip> ZW_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填
private List<JTH3ChangeDto.OldTrip> ZW_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填
private List<JTH3ChangeDto.ChangeTrip> ZW_AS_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填
//新增行程信息
@Data
@Accessors(chain = true)
public static class NewTrip {
private String AllowProductTypes;//行程类型 是否必填
private String DepartCitiesName;//出发地 是否必填
private String ArriveCitiesName;//目的地 是否必填
private String bsDate;//开始时间 是否必填
private String edDate;//结束时间 是否必填
private String Reason;//新增行程原因 是否必填
}
//原行程信息
@Data
@Accessors(chain = true)
public static class OldTrip {
private String AllowProductTypes;//行程类型 是否必填
private String DepartCitiesName;//出发地 是否必填
private String ArriveCitiesName;//目的地 是否必填
private String bsDate;//开始时间 是否必填
private String edDate;//结束时间 是否必填
}
//变更行程信息
@Data
@Accessors(chain = true)
public static class ChangeTrip {
private String AllowProductTypes;//行程类型 是否必填
private String DepartCitiesName;//出发地 是否必填
private String ArriveCitiesName;//目的地 是否必填
private String bsDate;//开始时间 是否必填
private String edDate;//结束时间 是否必填
private String Reason;//新增行程原因 是否必填
}
}

View File

@ -1,6 +1,5 @@
package com.chint;
import cn.hutool.core.lang.hash.Hash;
import com.alibaba.fastjson.JSON;
import com.authine.cloudpivot.opensdk.ApiException;
@ -10,7 +9,6 @@ import com.authine.cloudpivot.opensdk.model.response.workflow.StartWorkflowRespo
import com.chint.domain.aggregates.user.User;
import com.chint.infrastructure.constant.LYConstant;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.OrderNo;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.bpm.XNBPM.ClientFactory;
import com.chint.interfaces.rest.bpm.XNBPM.XNTokenDto;
@ -313,7 +311,7 @@ public class LYTest {
}
//超标
// @Test
@Test
void exceedStandard() {
BPMBaseRequest bpmRequest = new BPMBaseRequest();
Gson gson = new Gson();
@ -340,7 +338,7 @@ public class LYTest {
}
//改签
// @Test
@Test
void reschedule() {
BPMBaseRequest bpmRequest = new BPMBaseRequest();
Gson gson = new Gson();
@ -373,10 +371,10 @@ public class LYTest {
void change() {
BPMBaseRequest bpmRequest = new BPMBaseRequest();
Gson gson = new Gson();
ChangeDto changeDto = new ChangeDto();
JTH3ChangeDto changeDto = new JTH3ChangeDto();
//新增行程
ArrayList<ChangeDto.NewTrip> newTrips = new ArrayList<>();
ChangeDto.NewTrip newTrip = new ChangeDto.NewTrip();
ArrayList<JTH3ChangeDto.NewTrip> newTrips = new ArrayList<>();
JTH3ChangeDto.NewTrip newTrip = new JTH3ChangeDto.NewTrip();
newTrip.setAllowProductTypes("飞机")
.setDepartCitiesName("温州")
.setArriveCitiesName("北京")
@ -385,8 +383,8 @@ public class LYTest {
.setReason("出差帮扶");
newTrips.add(newTrip);
//原行程
ArrayList<ChangeDto.OldTrip> oldTrips = new ArrayList<>();
ChangeDto.OldTrip oldTrip = new ChangeDto.OldTrip();
ArrayList<JTH3ChangeDto.OldTrip> oldTrips = new ArrayList<>();
JTH3ChangeDto.OldTrip oldTrip = new JTH3ChangeDto.OldTrip();
oldTrip.setAllowProductTypes("火车")
.setDepartCitiesName("温州")
.setArriveCitiesName("杭州")
@ -394,8 +392,8 @@ public class LYTest {
.setEdDate("2024-03-01");
oldTrips.add(oldTrip);
//变更行程
ArrayList<ChangeDto.ChangeTrip> changeTrips = new ArrayList<>();
ChangeDto.ChangeTrip changeTrip = new ChangeDto.ChangeTrip();
ArrayList<JTH3ChangeDto.ChangeTrip> changeTrips = new ArrayList<>();
JTH3ChangeDto.ChangeTrip changeTrip = new JTH3ChangeDto.ChangeTrip();
changeTrip.setAllowProductTypes("火车")
.setDepartCitiesName("乐清")
.setArriveCitiesName("杭州")
@ -448,7 +446,8 @@ public class LYTest {
.setReason("酒店爆满订不到");//超标原因
String entityParamValues = gson.toJson(exceedStandardDto);
Type type = new TypeToken<HashMap<String, Object>>(){}.getType();
Type type = new TypeToken<HashMap<String, Object>>() {
}.getType();
HashMap<String, Object> map = gson.fromJson(entityParamValues, type);
request.setData(map);//数据
request.setDepartmentId("");//部门id默认主部门
@ -490,7 +489,8 @@ public class LYTest {
.setFee(BigDecimal.valueOf(100))//费用
.setReason("行程冲突");//原因
String entityParamValues = gson.toJson(rescheduleDto);
Type type = new TypeToken<HashMap<String, Object>>(){}.getType();
Type type = new TypeToken<HashMap<String, Object>>() {
}.getType();
HashMap<String, Object> map = gson.fromJson(entityParamValues, type);
request.setData(map);//数据
request.setDepartmentId("");//部门id默认主部门
@ -505,4 +505,72 @@ 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())) {
throw new RuntimeException("用户不存在!");
}
String userId = xnTokenDto.getUser_id();
CloudpivotOpenClient client = ClientFactory.getInstance();
StartWorkflowRequest request = new StartWorkflowRequest();
Gson gson = new Gson();
XNChangeDto changeDto = new XNChangeDto();
//新增行程
ArrayList<JTH3ChangeDto.NewTrip> newTrips = new ArrayList<>();
JTH3ChangeDto.NewTrip newTrip = new JTH3ChangeDto.NewTrip();
newTrip.setAllowProductTypes("飞机")
.setDepartCitiesName("温州")
.setArriveCitiesName("北京")
.setBsDate("2024-03-01")
.setEdDate("2024-03-01")
.setReason("出差帮扶");
newTrips.add(newTrip);
//原行程
ArrayList<JTH3ChangeDto.OldTrip> oldTrips = new ArrayList<>();
JTH3ChangeDto.OldTrip oldTrip = new JTH3ChangeDto.OldTrip();
oldTrip.setAllowProductTypes("火车")
.setDepartCitiesName("温州")
.setArriveCitiesName("杭州")
.setBsDate("2024-03-01")
.setEdDate("2024-03-01");
oldTrips.add(oldTrip);
//变更行程
ArrayList<JTH3ChangeDto.ChangeTrip> changeTrips = new ArrayList<>();
JTH3ChangeDto.ChangeTrip changeTrip = new JTH3ChangeDto.ChangeTrip();
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("出差帮扶")//出差说明
.setXN_AS_CLBGSQ_ITEM_NewTrip(newTrips)//新增行程信息
.setXN_AS_CLBGSQ_ITEM_OldTrip(oldTrips)//原行程信息
.setXN_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("XN_AS_CLBGSQ");//差旅变更流程
try {
StartWorkflowResponse response = client.startWorkflow(request);
System.out.println("response = " + JSON.toJSONString(response));
} catch (ApiException e) {
throw new RuntimeException(e.getMessage());
}
}
}