diff --git a/src/main/java/com/chint/interfaces/rest/bpm/BPMController.java b/src/main/java/com/chint/interfaces/rest/bpm/BPMController.java index 444d6fb2..5eb66e51 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/BPMController.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/BPMController.java @@ -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 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 + }; + } + } diff --git a/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java b/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java index 53077865..82bcc383 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java @@ -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 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; + } + }; } /** diff --git a/src/main/java/com/chint/interfaces/rest/bpm/dot/BPMBack.java b/src/main/java/com/chint/interfaces/rest/bpm/dot/BPMBack.java index bc9c0a62..ed3fae61 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/dot/BPMBack.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/dot/BPMBack.java @@ -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;//审批结果:通过/拒绝 } diff --git a/src/main/java/com/chint/interfaces/rest/bpm/dto/ChangeDto.java b/src/main/java/com/chint/interfaces/rest/bpm/dto/JTH3ChangeDto.java similarity index 98% rename from src/main/java/com/chint/interfaces/rest/bpm/dto/ChangeDto.java rename to src/main/java/com/chint/interfaces/rest/bpm/dto/JTH3ChangeDto.java index 64658609..229e70c6 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/dto/ChangeDto.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/dto/JTH3ChangeDto.java @@ -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;//出差说明 是否必填 是 diff --git a/src/main/java/com/chint/interfaces/rest/bpm/dto/XNChangeDto.java b/src/main/java/com/chint/interfaces/rest/bpm/dto/XNChangeDto.java new file mode 100644 index 00000000..3fec3b3f --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/bpm/dto/XNChangeDto.java @@ -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 XN_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 否 + private List XN_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 否 + private List 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;//新增行程原因 是否必填 否 + } +} diff --git a/src/main/java/com/chint/interfaces/rest/bpm/dto/ZWChangeDto.java b/src/main/java/com/chint/interfaces/rest/bpm/dto/ZWChangeDto.java new file mode 100644 index 00000000..6aa498b2 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/bpm/dto/ZWChangeDto.java @@ -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 ZW_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 否 + private List ZW_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 否 + private List 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;//新增行程原因 是否必填 否 + } +} diff --git a/src/test/java/com/chint/LYTest.java b/src/test/java/com/chint/LYTest.java index 1aef8680..f3d46f51 100644 --- a/src/test/java/com/chint/LYTest.java +++ b/src/test/java/com/chint/LYTest.java @@ -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 newTrips = new ArrayList<>(); - ChangeDto.NewTrip newTrip = new ChangeDto.NewTrip(); + ArrayList 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 oldTrips = new ArrayList<>(); - ChangeDto.OldTrip oldTrip = new ChangeDto.OldTrip(); + ArrayList 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 changeTrips = new ArrayList<>(); - ChangeDto.ChangeTrip changeTrip = new ChangeDto.ChangeTrip(); + ArrayList 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>(){}.getType(); + Type type = new TypeToken>() { + }.getType(); HashMap 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>(){}.getType(); + Type type = new TypeToken>() { + }.getType(); HashMap 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 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 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 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>() { + }.getType(); + HashMap 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()); + } + } + }