From 7500ba485450e5ab4d6f697c26cc543ed784817d Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 08:21:42 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/out/LoginController.java | 6 +++- .../queryies/estimate/CTripEstimatePrice.java | 36 ++++++++++++------- .../domain/aggregates/order/Location.java | 1 + .../domain/service/LocationDomainService.java | 7 ++-- .../infrastructure/constant/LegConstant.java | 2 +- .../constant/LocationConstant.java | 7 ++-- .../repository/LocationRepositoryImpl.java | 4 +-- .../jdbc/JdbcLocationRepository.java | 2 +- src/main/resources/application-dev.yml | 2 +- src/main/resources/application-prod.yml | 2 +- src/main/resources/application-test.yml | 2 +- src/test/java/com/chint/CTripTest.java | 9 ++--- 12 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/chint/application/out/LoginController.java b/src/main/java/com/chint/application/out/LoginController.java index 3b8c00a7..6b4f3f9b 100644 --- a/src/main/java/com/chint/application/out/LoginController.java +++ b/src/main/java/com/chint/application/out/LoginController.java @@ -3,6 +3,7 @@ package com.chint.application.out; import com.chint.application.commands.OrderCreateCommand; import com.chint.application.services.login.strategy.PailaLoginStrategy; +import com.chint.application.services.login.strategy.PailaMobileLoginStrategy; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.OrderException; import com.chint.domain.service.SystemDomainService; @@ -48,6 +49,9 @@ public class LoginController { @Autowired private PailaLoginStrategy pailaLoginStrategy; + @Autowired + private PailaMobileLoginStrategy pailaMobileLoginStrategy; + @ApiOperation("财务共享登录") @Transactional @GetMapping("/login") @@ -136,7 +140,7 @@ public class LoginController { @PostMapping("/login/sso/mobile") public Result loginSSOMobile(@RequestBody UserLoginParam userLoginParam){ - String employeeNo = pailaLoginStrategy.login(userLoginParam.getCode()); + String employeeNo = pailaMobileLoginStrategy.login(userLoginParam.getCode()); userLoginParam.setSfno(employeeNo); UserLoginResult userLoginResult = authenticateService diff --git a/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java b/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java index b1b9e060..126f3966 100644 --- a/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java +++ b/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java @@ -1,7 +1,6 @@ package com.chint.application.queryies.estimate; import com.chint.domain.aggregates.standards.CityTag; -import com.chint.domain.aggregates.standards.TrainStandards; import com.chint.domain.aggregates.standards.TravelStandards; import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.CityRepository; @@ -30,11 +29,11 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Optional; -import java.util.regex.Matcher; import java.util.regex.Pattern; import static com.chint.domain.aggregates.standards.TrainStandards.trainStandardsMap; import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL; +import static com.chint.infrastructure.constant.RankConstant.STANDARD_LEVEL_ONE; @Component public class CTripEstimatePrice implements EstimatePrice { @@ -98,7 +97,16 @@ public class CTripEstimatePrice implements EstimatePrice { @Override public FlightPriceData queryFlightPrice(PriceQueryData priceQueryData) { FlightProductInfo flightProductInfo = new FlightProductInfo(); - flightProductInfo.setClassType("YCF"); + User currentUser = BaseContext.getCurrentUser(); + String standardLevel = currentUser.getStandardLevel(); + + //差标价值管控 , 差标等级不是一等,只能选择经济舱 + if (standardLevel.equals(STANDARD_LEVEL_ONE)) { + flightProductInfo.setClassType("YCF"); + } else { + flightProductInfo.setClassType("Y"); + } + RouteInfo routeInfo = new RouteInfo(); routeInfo.setArriveCityID( cityRepository.findByCityName(priceQueryData.getArriveCity()).getCity()); @@ -111,15 +119,19 @@ public class CTripEstimatePrice implements EstimatePrice { BookingRelatedApiResponse estimate = cTripEstimateRequest.estimate(bookingRelatedApiRequest); FlightPriceData flightPriceData = new FlightPriceData(); - Optional.ofNullable( - estimate.getData().getFlightValuationResult().getTotalPrice() - ).ifPresentOrElse(price -> { - flightPriceData.setSuccess(true); - flightPriceData.setMaxPrice(String.valueOf(price)); - }, () -> { - flightPriceData.setSuccess(false); - flightPriceData.setMaxPrice("无估算价格"); - }); + if (estimate.getStatus().getSuccess()) { + Optional.ofNullable( + estimate.getData().getFlightValuationResult().getTotalPrice() + ).ifPresentOrElse(price -> { + flightPriceData.setSuccess(true); + flightPriceData.setMaxPrice(String.valueOf(price)); + }, () -> { + flightPriceData.setSuccess(false); + flightPriceData.setMaxPrice("无估算价格"); + }); + } + + return flightPriceData; } diff --git a/src/main/java/com/chint/domain/aggregates/order/Location.java b/src/main/java/com/chint/domain/aggregates/order/Location.java index 9b21aa7c..66feff49 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Location.java +++ b/src/main/java/com/chint/domain/aggregates/order/Location.java @@ -22,6 +22,7 @@ public class Location { private String locationShortName; private String firstPinYin; private Long parentLocationId; + private Integer isInternal; @Column("level") private Integer level; diff --git a/src/main/java/com/chint/domain/service/LocationDomainService.java b/src/main/java/com/chint/domain/service/LocationDomainService.java index 61f37a7b..738c11d5 100644 --- a/src/main/java/com/chint/domain/service/LocationDomainService.java +++ b/src/main/java/com/chint/domain/service/LocationDomainService.java @@ -11,6 +11,9 @@ import org.springframework.stereotype.Service; import java.util.List; +import static com.chint.infrastructure.constant.LocationConstant.LOCATION_IS_INTERNAL; +import static com.chint.infrastructure.constant.LocationConstant.LOCATION_IS_NOT_INTERNAL; + @Service public class LocationDomainService { @@ -33,12 +36,12 @@ public class LocationDomainService { return switch (cityType) { case LocationConstant.CITY_TYPE_DOMESTIC -> queryByCityName .stream() - .filter(location -> location.getLocationPath().startsWith(LocationConstant.CITY_TYPE_DOMESTIC_PATH) + .filter(location -> location.getIsInternal().equals(LOCATION_IS_INTERNAL) && location.getLevel().equals(3)).toList(); case LocationConstant.CITY_TYPE_FOREIGN -> queryByCityName .stream() - .filter(location -> !location.getLocationPath().startsWith(LocationConstant.CITY_TYPE_DOMESTIC_PATH) + .filter(location -> location.getIsInternal().equals(LOCATION_IS_NOT_INTERNAL) && location.getLevel().equals(3)).toList(); default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND); }; diff --git a/src/main/java/com/chint/infrastructure/constant/LegConstant.java b/src/main/java/com/chint/infrastructure/constant/LegConstant.java index ca566a0a..d9159a59 100644 --- a/src/main/java/com/chint/infrastructure/constant/LegConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/LegConstant.java @@ -27,7 +27,7 @@ public class LegConstant { public static final String LEG_TYPE_HOTEL_NAME = "酒店"; public static final String LEG_TYPE_HOTEL_EN_NAME = "Hotel"; public static final int LEG_TYPE_TAXI = 3; - public static final String LEG_TYPE_TAXI_NAME = "出租车"; + public static final String LEG_TYPE_TAXI_NAME = "打车"; public static final String LEG_TYPE_TAXI_EN_NAME = "Traffic"; public static final int LEG_TYPE_OTHER = 4; public static final String LEG_TYPE_OTHER_NAME = "其他"; diff --git a/src/main/java/com/chint/infrastructure/constant/LocationConstant.java b/src/main/java/com/chint/infrastructure/constant/LocationConstant.java index fa3e1286..494a4f56 100644 --- a/src/main/java/com/chint/infrastructure/constant/LocationConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/LocationConstant.java @@ -2,7 +2,10 @@ package com.chint.infrastructure.constant; public class LocationConstant { // 城市类型 - public static final int CITY_TYPE_DOMESTIC = 0;//国内 + public static final int CITY_TYPE_DOMESTIC = 1;//国内 public static final String CITY_TYPE_DOMESTIC_PATH = "3106_1_";//国内 - public static final int CITY_TYPE_FOREIGN = 1;//国外 + public static final int CITY_TYPE_FOREIGN = 0;//国外 + + public static final int LOCATION_IS_INTERNAL = 1;//是国内 + public static final int LOCATION_IS_NOT_INTERNAL = 0;//是国外 } diff --git a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java index 9bb51a57..b468c7b0 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -63,12 +63,12 @@ public class LocationRepositoryImpl implements LocationRepository { @Override public List findByName(LocationParam locationParam) { - return jdbcLocationRepository.findByLocationNameContaining(locationParam.getQueryWord()); + return jdbcLocationRepository.findByLocationPathNameContaining(locationParam.getQueryWord()); } @Override public List findByName(String localName) { - return jdbcLocationRepository.findByLocationNameContaining(localName); + return jdbcLocationRepository.findByLocationPathNameContaining(localName); } @Override diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java index f289cd07..058477e3 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java @@ -21,7 +21,7 @@ public interface JdbcLocationRepository extends CrudRepository { List findByFirstPinYin(String firstPinYin); - List findByLocationNameContaining(String locationName); + List findByLocationPathNameContaining(String locationName); Location findByLocationName(String locationName); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 622493fd..04196998 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -59,7 +59,7 @@ paila: redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ client-mobile-id: 9b24c91ead42ee4b6918 client-mobile-secret: e54494f1272ffd41b818980f1f8524fd68ef - redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/#/ + redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/*.* base-url: https://signin-test.chint.com token-name: token diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index b44eb244..dc8b4074 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -29,6 +29,6 @@ paila: redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ client-mobile-id: 9b24c91ead42ee4b6918 client-mobile-secret: e54494f1272ffd41b818980f1f8524fd68ef - redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/#/ + redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/*.* base-url: https://signin-test.chint.com token-name: token diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 36b48380..a69edc2a 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -48,7 +48,7 @@ paila: redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ client-mobile-id: 9b24c91ead42ee4b6918 client-mobile-secret: e54494f1272ffd41b818980f1f8524fd68ef - redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/#/ + redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/*.* base-url: https://signin-test.chint.com token-name: token diff --git a/src/test/java/com/chint/CTripTest.java b/src/test/java/com/chint/CTripTest.java index 4d0f5145..e3214818 100644 --- a/src/test/java/com/chint/CTripTest.java +++ b/src/test/java/com/chint/CTripTest.java @@ -118,15 +118,16 @@ public class CTripTest { System.out.println(loginRequest.h5Login(null)); } -// @Test + @Test void estimateFlight() { BaseContext.setCurrentUser(user); + user.setCompanyCode("A30000001"); FlightProductInfo flightProductInfo = new FlightProductInfo(); flightProductInfo.setClassType("YCF"); RouteInfo routeInfo = new RouteInfo(); - routeInfo.setArriveCityID("1"); - routeInfo.setDepartCityID("491"); - routeInfo.setDepartDate("2024-04-01"); + routeInfo.setArriveCityID("347"); + routeInfo.setDepartCityID("633"); + routeInfo.setDepartDate("2024-03-02"); flightProductInfo.setRoutes(List.of(routeInfo)); BookingRelatedApiRequest bookingRelatedApiRequest = estimateRequest .generateBaseRequest(flightProductInfo, null); From 1de351fa10c57bb7168dd3cd69e0365173a36ced Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 08:38:41 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9A=82=E6=97=B6=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E6=96=B0=E8=83=BDjar=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 +- .../chint/interfaces/rest/bpm/BPMRequest.java | 75 ++++----- .../rest/bpm/XNBPM/ClientFactory.java | 28 ++-- src/test/java/com/chint/CTripTest.java | 2 +- src/test/java/com/chint/LYTest.java | 143 +++++++++--------- 5 files changed, 119 insertions(+), 139 deletions(-) diff --git a/pom.xml b/pom.xml index ec7065af..d1d73028 100644 --- a/pom.xml +++ b/pom.xml @@ -82,11 +82,11 @@ 3.0.3 - - com.authine.cloudpivot - cloudpivot-opensdk - 1.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 08f50c8a..290eff40 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java @@ -1,33 +1,19 @@ package com.chint.interfaces.rest.bpm; -import com.alibaba.fastjson.JSON; -import com.authine.cloudpivot.opensdk.ApiException; -import com.authine.cloudpivot.opensdk.CloudpivotOpenClient; -import com.authine.cloudpivot.opensdk.model.request.workflow.StartWorkflowRequest; -import com.authine.cloudpivot.opensdk.model.response.workflow.StartWorkflowResponse; 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.dot.*; +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.google.gson.Gson; -import com.google.gson.reflect.TypeToken; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import java.lang.reflect.Type; -import java.math.BigDecimal; -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; @Service @@ -82,34 +68,35 @@ public class BPMRequest { * 新能云枢接口 */ public BPMResponse XNBPMSubmitWorkflow(String workflowCode, Object entityObject) { - //获取用户信息 - 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())) { - throw new RuntimeException("用户不存在!"); - } - String userId = xnTokenDto.getUser_id(); - CloudpivotOpenClient client = ClientFactory.getInstance(); - StartWorkflowRequest request = new StartWorkflowRequest(); - Gson gson = new Gson(); - String entityParamValues = gson.toJson(entityObject); - 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(workflowCode);//超标流程 - try { - StartWorkflowResponse response = client.startWorkflow(request); - System.out.println("response = " + JSON.toJSONString(response)); - } catch (ApiException e) { - throw new RuntimeException(e.getMessage()); - } - BPMResponse bpmResponse = new BPMResponse(); - bpmResponse.setSuccess(true); - return bpmResponse; +// //获取用户信息 +// 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())) { +// throw new RuntimeException("用户不存在!"); +// } +// String userId = xnTokenDto.getUser_id(); +// CloudpivotOpenClient client = ClientFactory.getInstance(); +// StartWorkflowRequest request = new StartWorkflowRequest(); +// Gson gson = new Gson(); +// String entityParamValues = gson.toJson(entityObject); +// 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(workflowCode);//超标流程 +// try { +// StartWorkflowResponse response = client.startWorkflow(request); +// System.out.println("response = " + JSON.toJSONString(response)); +// } catch (ApiException e) { +// throw new RuntimeException(e.getMessage()); +// } +// BPMResponse bpmResponse = new BPMResponse(); +// bpmResponse.setSuccess(true); +// return bpmResponse; + return null; } } diff --git a/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java b/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java index 3e5b7053..3921c55a 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java @@ -1,8 +1,6 @@ package com.chint.interfaces.rest.bpm.XNBPM; -import com.authine.cloudpivot.opensdk.CloudpivotOpenClient; -import com.authine.cloudpivot.opensdk.client.impl.JdkHttpClient; -import com.authine.cloudpivot.opensdk.config.CloudpivotEnvConfig; + import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -13,7 +11,7 @@ import static com.chint.infrastructure.constant.BPMConstant.*; */ @Service public class ClientFactory { - private static CloudpivotOpenClient client; +// private static CloudpivotOpenClient client; private static String XNBPMUrl; @@ -23,15 +21,15 @@ public class ClientFactory { } - public synchronized static CloudpivotOpenClient getInstance() { - if (client == null) { - synchronized (CloudpivotOpenClient.class) { - if (client == null) { - CloudpivotEnvConfig config = new CloudpivotEnvConfig(XNBPMUrl + "/api", CLIENT_ID, CLIENT_SECRET); - client = new CloudpivotOpenClient(config, new JdkHttpClient()); - } - } - } - return client; - } +// public synchronized static CloudpivotOpenClient getInstance() { +// if (client == null) { +// synchronized (CloudpivotOpenClient.class) { +// if (client == null) { +// CloudpivotEnvConfig config = new CloudpivotEnvConfig(XNBPMUrl + "/api", CLIENT_ID, CLIENT_SECRET); +// client = new CloudpivotOpenClient(config, new JdkHttpClient()); +// } +// } +// } +// return client; +// } } \ No newline at end of file diff --git a/src/test/java/com/chint/CTripTest.java b/src/test/java/com/chint/CTripTest.java index e3214818..c1c0646e 100644 --- a/src/test/java/com/chint/CTripTest.java +++ b/src/test/java/com/chint/CTripTest.java @@ -118,7 +118,7 @@ public class CTripTest { System.out.println(loginRequest.h5Login(null)); } - @Test +// @Test void estimateFlight() { BaseContext.setCurrentUser(user); user.setCompanyCode("A30000001"); diff --git a/src/test/java/com/chint/LYTest.java b/src/test/java/com/chint/LYTest.java index 7bf39386..7adbc2fc 100644 --- a/src/test/java/com/chint/LYTest.java +++ b/src/test/java/com/chint/LYTest.java @@ -2,12 +2,7 @@ package com.chint; import cn.hutool.core.lang.hash.Hash; import com.alibaba.fastjson.JSON; -import com.authine.cloudpivot.opensdk.ApiException; -import com.authine.cloudpivot.opensdk.CloudpivotOpenClient; -import com.authine.cloudpivot.opensdk.model.request.bizobject.CreateBoRequest; -import com.authine.cloudpivot.opensdk.model.request.workflow.StartWorkflowRequest; -import com.authine.cloudpivot.opensdk.model.response.bizobject.CreateBoResponse; -import com.authine.cloudpivot.opensdk.model.response.workflow.StartWorkflowResponse; + import com.chint.domain.aggregates.user.User; import com.chint.infrastructure.constant.LYConstant; import com.chint.infrastructure.util.BaseContext; @@ -376,40 +371,40 @@ 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())) { - throw new RuntimeException("用户不存在!"); - } - String userId = xnTokenDto.getUser_id(); - CloudpivotOpenClient client = ClientFactory.getInstance(); - 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>(){}.getType(); - HashMap map = gson.fromJson(entityParamValues, type); - request.setData(map);//数据 - request.setDepartmentId("");//部门id,默认主部门 - request.setFinishStart(true);//发起流程 - request.setUserId(userId);//员工号 - request.setWorkflowCode("JG_AS_CLCESQ");//超标流程 - try { - StartWorkflowResponse response = client.startWorkflow(request); - System.out.println("response = " + JSON.toJSONString(response)); - } catch (ApiException e) { - throw new RuntimeException(e.getMessage()); - } +// 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(); +// 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>(){}.getType(); +// HashMap map = gson.fromJson(entityParamValues, type); +// request.setData(map);//数据 +// request.setDepartmentId("");//部门id,默认主部门 +// request.setFinishStart(true);//发起流程 +// request.setUserId(userId);//员工号 +// request.setWorkflowCode("JG_AS_CLCESQ");//超标流程 +// try { +// StartWorkflowResponse response = client.startWorkflow(request); +// System.out.println("response = " + JSON.toJSONString(response)); +// } catch (ApiException e) { +// throw new RuntimeException(e.getMessage()); +// } } @@ -418,40 +413,40 @@ 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())) { - throw new RuntimeException("用户不存在!"); - } - String userId = xnTokenDto.getUser_id(); - CloudpivotOpenClient client = ClientFactory.getInstance(); - StartWorkflowRequest request = new StartWorkflowRequest(); - Gson gson = new Gson(); - RescheduleDto rescheduleDto = new RescheduleDto(); - rescheduleDto.setOrderType("机票改签")//内容选项:机票改签,机票退票,火车票改签,火车票退票 - .setOrderSource("携程商旅")//携程商旅/同程商旅 - .setOrderNo("00002")//订单号 - .setStartTime("2024-02-22 10:00:00")//机票改签或火车票改签提供: 原时间 - .setRebookStartTime("2024-02-23 10:00:00")//机票改签或火车票改签提供: 改签后时间 - .setTrainNumber("")//火车票改签提供: 原车次 - .setSeatingStandard("")//火车票改签提供: 原席别 - .setRebookTrainNumber("")//火车票改签提供: 改签后车次 - .setRebookSeatingStandard("")//火车票改签提供: 改签后席别 - .setFee(BigDecimal.valueOf(100))//费用 - .setReason("行程冲突");//原因 - String entityParamValues = gson.toJson(rescheduleDto); - 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("JG_AS_CLGQSQ");//改签流程 - try { - StartWorkflowResponse response = client.startWorkflow(request); - System.out.println("response = " + JSON.toJSONString(response)); - } catch (ApiException e) { - throw new RuntimeException(e.getMessage()); - } +// 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(); +// RescheduleDto rescheduleDto = new RescheduleDto(); +// rescheduleDto.setOrderType("机票改签")//内容选项:机票改签,机票退票,火车票改签,火车票退票 +// .setOrderSource("携程商旅")//携程商旅/同程商旅 +// .setOrderNo("00002")//订单号 +// .setStartTime("2024-02-22 10:00:00")//机票改签或火车票改签提供: 原时间 +// .setRebookStartTime("2024-02-23 10:00:00")//机票改签或火车票改签提供: 改签后时间 +// .setTrainNumber("")//火车票改签提供: 原车次 +// .setSeatingStandard("")//火车票改签提供: 原席别 +// .setRebookTrainNumber("")//火车票改签提供: 改签后车次 +// .setRebookSeatingStandard("")//火车票改签提供: 改签后席别 +// .setFee(BigDecimal.valueOf(100))//费用 +// .setReason("行程冲突");//原因 +// String entityParamValues = gson.toJson(rescheduleDto); +// 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("JG_AS_CLGQSQ");//改签流程 +// try { +// StartWorkflowResponse response = client.startWorkflow(request); +// System.out.println("response = " + JSON.toJSONString(response)); +// } catch (ApiException e) { +// throw new RuntimeException(e.getMessage()); +// } } } From 8aeb1948248f9ae74109d8fff039d9ca9c66b85a Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 09:19:31 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/OrderApplicationService.java | 32 +++++++++++-------- .../chint/domain/aggregates/order/Leg.java | 19 +++++++---- .../order_detail/OrderDetailFactoryImpl.java | 3 ++ .../amount_estimate/CTripEstimate.java | 1 - .../service/leg_event/LegEventHandler.java | 16 ++++------ .../constant/RouteConstant.java | 2 +- 6 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/chint/application/services/OrderApplicationService.java b/src/main/java/com/chint/application/services/OrderApplicationService.java index 6a923445..2feac52a 100644 --- a/src/main/java/com/chint/application/services/OrderApplicationService.java +++ b/src/main/java/com/chint/application/services/OrderApplicationService.java @@ -73,15 +73,29 @@ public class OrderApplicationService { RouteOrder order = Optional.ofNullable(routeRepository.queryById(addLegData.getRouteId())) .orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND)); order.reloadStatus(); - if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) { - throw new OrderException(ORDER_STATUS_ERROR); - } +// if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) { +// throw new OrderException(ORDER_STATUS_ERROR); +// } List legs = processLegData(addLegData.getLegData(), order); RouteOrder routeOrder = orderDomainService.saveOrder(order); legs.forEach(leg -> Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue()); return routeOrder; // 仅在所有操作完成后保存一次 } + @Transactional + public void changeLeg(AddLegData addLegData) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"); + LegData legData = addLegData.getLegData(); + Leg byLegId = Optional.ofNullable( + legRepository.findByLegId(legData.getLegId()) + ).orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND)); + byLegId.setStartTime(LocalDateTime.parse(legData.getStartTime(), formatter)); + byLegId.setEndTime(LocalDateTime.parse(legData.getEndTime(), formatter)); + byLegId.setOriginId(legData.getOriginId()); + byLegId.setDestinationId(legData.getDestinationId()); + legRepository.save(byLegId); + } + private List processLegData(LegData legData, RouteOrder order) { List legs = switch (legData.legType) { case LegConstant.LEG_TYPE_TRAIN -> legFactory.createTrainLeg(legData); @@ -156,15 +170,5 @@ public class OrderApplicationService { public void updateLegToOrder(AddLegData addLegData) { } - @Transactional - public void changeLeg(AddLegData addLegData) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"); - LegData legData = addLegData.getLegData(); - Leg byLegId = legRepository.findByLegId(legData.getLegId()); - byLegId.setStartTime(LocalDateTime.parse(legData.getStartTime(), formatter)); - byLegId.setEndTime(LocalDateTime.parse(legData.getEndTime(), formatter)); - byLegId.setOriginId(legData.getOriginId()); - byLegId.setDestinationId(legData.getDestinationId()); - legRepository.save(byLegId); - } + } diff --git a/src/main/java/com/chint/domain/aggregates/order/Leg.java b/src/main/java/com/chint/domain/aggregates/order/Leg.java index 0c971028..0bb6b3a8 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Leg.java +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -20,6 +20,9 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER; +import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI; + @Slf4j @Data @Table("leg") @@ -82,7 +85,11 @@ public class Leg { } public Leg queryEstimateAmount(EstimateAdapter estimateAdapter, String supplierName) { - this.estimateAmount = estimateAdapter.of(supplierName).amountEstimate(this); + if (this.getLegType().equals(LEG_TYPE_OTHER) || this.getLegType().equals(LEG_TYPE_TAXI)) { + + } else { + this.estimateAmount = estimateAdapter.of(supplierName).amountEstimate(this); + } return this; } @@ -146,8 +153,8 @@ public class Leg { case LegConstant.LEG_TYPE_TRAIN -> LegConstant.LEG_TYPE_TRAIN_NAME; case LegConstant.LEG_TYPE_AIRPLANE -> LegConstant.LEG_TYPE_AIRPLANE_NAME; case LegConstant.LEG_TYPE_HOTEL -> LegConstant.LEG_TYPE_HOTEL_NAME; - case LegConstant.LEG_TYPE_TAXI -> LegConstant.LEG_TYPE_TAXI_NAME; - case LegConstant.LEG_TYPE_OTHER -> LegConstant.LEG_TYPE_OTHER_NAME; + case LEG_TYPE_TAXI -> LegConstant.LEG_TYPE_TAXI_NAME; + case LEG_TYPE_OTHER -> LegConstant.LEG_TYPE_OTHER_NAME; default -> "未知类型"; }; } @@ -157,8 +164,8 @@ public class Leg { case LegConstant.LEG_TYPE_TRAIN -> LegConstant.LEG_TYPE_TRAIN_EN_NAME; case LegConstant.LEG_TYPE_AIRPLANE -> LegConstant.LEG_TYPE_AIRPLANE_EN_NAME; case LegConstant.LEG_TYPE_HOTEL -> LegConstant.LEG_TYPE_HOTEL_EN_NAME; - case LegConstant.LEG_TYPE_TAXI -> LegConstant.LEG_TYPE_TAXI_EN_NAME; - case LegConstant.LEG_TYPE_OTHER -> LegConstant.LEG_TYPE_OTHER_EN_NAME; + case LEG_TYPE_TAXI -> LegConstant.LEG_TYPE_TAXI_EN_NAME; + case LEG_TYPE_OTHER -> LegConstant.LEG_TYPE_OTHER_EN_NAME; default -> "未知类型"; }; } @@ -192,7 +199,7 @@ public class Leg { if (!eventList.isEmpty()) { LegEvent lastEvent = eventList.get(eventList.size() - 1); int lastEventType = lastEvent.getEventType(); - if (newEventType != lastEventType && Math.abs(newEventType - lastEventType) > 1) { + if (newEventType != lastEventType && Math.abs(newEventType - lastEventType) > 5) { throw new LegEventException("New event must be the same as, immediately before, or immediately after the last event type."); } } diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java index 72c1db54..e3af7bcb 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java @@ -20,6 +20,9 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory { orderDetail.setCurrencyType(CurrencyType.getByCode(orderLegData.getCurrencyCode())); orderDetail.setDestinationId(orderLegData.getDestinationId()); orderDetail.setOriginId(orderLegData.getOriginId()); + orderDetail + .price(orderLegData.getPrice()) + .productType(orderLegData.getProductType()); return orderDetail; } diff --git a/src/main/java/com/chint/domain/service/amount_estimate/CTripEstimate.java b/src/main/java/com/chint/domain/service/amount_estimate/CTripEstimate.java index ae760c75..c502f128 100644 --- a/src/main/java/com/chint/domain/service/amount_estimate/CTripEstimate.java +++ b/src/main/java/com/chint/domain/service/amount_estimate/CTripEstimate.java @@ -32,7 +32,6 @@ public class CTripEstimate implements AmountEstimate { @Override public String amountEstimate(Leg leg) { - Integer legType = leg.getLegType(); return switch (legType) { case LEG_TYPE_TRAIN -> queryTrainPrice(leg); diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java index dd6cf0a5..a71db450 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java @@ -106,13 +106,14 @@ public class LegEventHandler implements LegEventService { public void syncLeg(LegSyncCommand command) { SyncLegData data = command.getData(); RouteOrder routeOrder = routeRepository.queryById(data.getRouteId()).reloadStatus(); - if (routeOrder.getOrderStatus() > (RouteConstant.ORDER_STATUS_APPROVAL)) { - throw new CommandException("订单已同步"); - } +// if (routeOrder.getOrderStatus() > (RouteConstant.ORDER_STATUS_APPROVAL)) { +// throw new CommandException("订单已同步"); +// } if (routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE)) { throw new CommandException("订单未提交审批"); } - if (routeOrder.getOrderStatus().equals(RouteConstant.ORDER_STATUS_APPROVAL)) { + //这里暂时的策略是只要订单状态是大于提交审批状态 , 就可以同步 + if (routeOrder.getOrderStatus() >= RouteConstant.ORDER_STATUS_APPROVAL) { String supplierName = data.getSupplierName(); routeOrder.setSupplierName(supplierName); //这里order所有的leg触发sync事件 @@ -153,15 +154,10 @@ public class LegEventHandler implements LegEventService { if (byOrderNo.isEmpty()) { //否则创建新的订单添加到routeOrder orderDetail = orderDetailFactory.create(data) - .price(data.getPrice()).productType(data.getProductType()) .employeeNo(routeOrder.getUserId()); routeOrder.addOrderDetail(orderDetail); routeOrder = routeRepository.save(routeOrder); -// OrderDetail orderDetail = routeOrder -// .getOrderDetails() -// .stream() -// .max(Comparator.comparing(OrderDetail::getCreateTime)) -// .orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND)); + //为订单添加订单已下单事件,这里需要发出额外的命令进行处理 orderDetail = routeOrder.matchOrderWithLeg(orderDetail); } else { diff --git a/src/main/java/com/chint/infrastructure/constant/RouteConstant.java b/src/main/java/com/chint/infrastructure/constant/RouteConstant.java index dae9e3f7..e0bbac0f 100644 --- a/src/main/java/com/chint/infrastructure/constant/RouteConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/RouteConstant.java @@ -5,7 +5,7 @@ public class RouteConstant { public static final int ORDER_STATUS_PREPARE = 0; public static final String ORDER_STATUS_PREPARE_NAME = "规划中"; public static final int ORDER_STATUS_APPROVAL = 1; - public static final String ORDER_STATUS_APPROVAL_NAME = "提交审批"; + public static final String ORDER_STATUS_APPROVAL_NAME = "未同步"; public static final int ORDER_STATUS_NOT_ORDERED = 2; public static final String ORDER_STATUS_NOT_ORDERED_NAME = "未下单"; public static final int ORDER_STATUS_ORDERED = 3; From 99bd01fe7b97f9165850c95cae5f2e5c7ae01507 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 09:34:00 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dtos/response/LocationRes.java | 3 ++ .../application/queryies/OrderQuery.java | 36 +++++++++++-------- .../chint/domain/aggregates/order/Leg.java | 4 +-- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/chint/application/dtos/response/LocationRes.java b/src/main/java/com/chint/application/dtos/response/LocationRes.java index 18b331fd..15ec5d93 100644 --- a/src/main/java/com/chint/application/dtos/response/LocationRes.java +++ b/src/main/java/com/chint/application/dtos/response/LocationRes.java @@ -15,6 +15,9 @@ public class LocationRes { private String province; public static LocationRes copyFrom(Location location) { + if (location == null) { + return null; + } LocationRes locationRes = BeanUtil.copyProperties(location, LocationRes.class); String[] parts = location.getLocationPathName().split("_"); if (parts.length != 4) { diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index a2ac90e6..7d38946d 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -232,22 +232,28 @@ public class OrderQuery { CityEntity destinationCity; ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail.builder(); if (!leg.getLegType().equals(LegConstant.LEG_TYPE_OTHER)) { - originCity = cityEntities.stream().filter(cityEntity -> cityEntity - .getCityName() - .equals(leg.getOriginLocation().getLocationName())) - .findFirst().get(); - destinationCity = cityEntities.stream().filter(cityEntity -> cityEntity - .getCityName() - .equals(leg.getDestinationLocation().getLocationName())) - .findFirst().get(); - scheduleDetailBuilder - .startCity(originCity.getCityName()) - .startCityName(originCity.getCityName()) - .startCityEnName(originCity.getCityename()) - .endCityName(destinationCity.getCityName()) - .endCity(destinationCity.getCityName()) - .endCityEnName(destinationCity.getCityename()); + if (leg.getOriginLocation() != null) { + originCity = cityEntities.stream().filter(cityEntity -> cityEntity + .getCityName() + .equals(leg.getOriginLocation().getLocationName())) + .findFirst().get(); + scheduleDetailBuilder + .startCity(originCity.getCityName()) + .startCityName(originCity.getCityName()) + .startCityEnName(originCity.getCityename()); + } + + if (leg.getDestinationLocation() != null) { + destinationCity = cityEntities.stream().filter(cityEntity -> cityEntity + .getCityName() + .equals(leg.getDestinationLocation().getLocationName())) + .findFirst().get(); + scheduleDetailBuilder + .endCityName(destinationCity.getCityName()) + .endCity(destinationCity.getCityName()) + .endCityEnName(destinationCity.getCityename()); + } } if (leg.getCurrencyType() != null) { diff --git a/src/main/java/com/chint/domain/aggregates/order/Leg.java b/src/main/java/com/chint/domain/aggregates/order/Leg.java index 0bb6b3a8..b5e6a432 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Leg.java +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -85,9 +85,7 @@ public class Leg { } public Leg queryEstimateAmount(EstimateAdapter estimateAdapter, String supplierName) { - if (this.getLegType().equals(LEG_TYPE_OTHER) || this.getLegType().equals(LEG_TYPE_TAXI)) { - - } else { + if (!this.getLegType().equals(LEG_TYPE_OTHER) && !this.getLegType().equals(LEG_TYPE_TAXI)) { this.estimateAmount = estimateAdapter.of(supplierName).amountEstimate(this); } return this; From 914a4cd959c8ff76a382a05eac14920745012079 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 10:25:18 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 +-- .../services/OrderApplicationService.java | 30 ++++++-- .../domain/value_object/SyncLegData.java | 6 ++ .../rest/bpm/XNBPM/ClientFactory.java | 27 +++---- src/test/java/com/chint/LYTest.java | 72 ++++++++++--------- 5 files changed, 90 insertions(+), 55 deletions(-) diff --git a/pom.xml b/pom.xml index d1d73028..ec7065af 100644 --- a/pom.xml +++ b/pom.xml @@ -82,11 +82,11 @@ 3.0.3 - - - - - + + com.authine.cloudpivot + cloudpivot-opensdk + 1.0 + diff --git a/src/main/java/com/chint/application/services/OrderApplicationService.java b/src/main/java/com/chint/application/services/OrderApplicationService.java index 2feac52a..e7fdef23 100644 --- a/src/main/java/com/chint/application/services/OrderApplicationService.java +++ b/src/main/java/com/chint/application/services/OrderApplicationService.java @@ -26,8 +26,9 @@ import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.concurrent.CompletableFuture; -import static com.chint.infrastructure.constant.CommonMessageConstant.ORDER_STATUS_ERROR; +import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_NOT_ORDERED; import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE; @Service @@ -73,12 +74,20 @@ public class OrderApplicationService { RouteOrder order = Optional.ofNullable(routeRepository.queryById(addLegData.getRouteId())) .orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND)); order.reloadStatus(); -// if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) { -// throw new OrderException(ORDER_STATUS_ERROR); -// } + List legs = processLegData(addLegData.getLegData(), order); RouteOrder routeOrder = orderDomainService.saveOrder(order); legs.forEach(leg -> Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue()); + + //异步操作-如果是当前的状态已经进行过匹配,那么就要订单同步到供应商一次 + if (order.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) { + CompletableFuture.runAsync(() -> { + Command + .of(LegSyncCommand.class) + .data(SyncLegData.of(routeOrder.getRouteId(), routeOrder.getSupplierName())) + .sendToQueue(); + }); + } return routeOrder; // 仅在所有操作完成后保存一次 } @@ -94,6 +103,19 @@ public class OrderApplicationService { byLegId.setOriginId(legData.getOriginId()); byLegId.setDestinationId(legData.getDestinationId()); legRepository.save(byLegId); + + //异步操作-如果是当前的状态已经进行过匹配,那么就要订单同步到供应商一次 + CompletableFuture.runAsync(() -> { + Long routeId = byLegId.getRouteId(); + RouteOrder order = Optional.ofNullable(routeRepository.queryById(routeId)) + .orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND)).reloadStatus(); + if (order.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) { + Command + .of(LegSyncCommand.class) + .data(SyncLegData.of(order.getRouteId(), order.getSupplierName())) + .sendToQueue(); + } + }); } private List processLegData(LegData legData, RouteOrder order) { diff --git a/src/main/java/com/chint/domain/value_object/SyncLegData.java b/src/main/java/com/chint/domain/value_object/SyncLegData.java index d3664a4a..cf09311c 100644 --- a/src/main/java/com/chint/domain/value_object/SyncLegData.java +++ b/src/main/java/com/chint/domain/value_object/SyncLegData.java @@ -9,4 +9,10 @@ public class SyncLegData { private Long routeId; private List routeIds; private String supplierName; + public static SyncLegData of( Long routeId,String supplierName){ + SyncLegData syncLegData = new SyncLegData(); + syncLegData.setSupplierName(supplierName); + syncLegData.setRouteId(routeId); + return syncLegData; + } } diff --git a/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java b/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java index 3921c55a..179d210b 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java @@ -1,6 +1,9 @@ package com.chint.interfaces.rest.bpm.XNBPM; +import com.authine.cloudpivot.opensdk.CloudpivotOpenClient; +import com.authine.cloudpivot.opensdk.client.impl.JdkHttpClient; +import com.authine.cloudpivot.opensdk.config.CloudpivotEnvConfig; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -11,7 +14,7 @@ import static com.chint.infrastructure.constant.BPMConstant.*; */ @Service public class ClientFactory { -// private static CloudpivotOpenClient client; + private static CloudpivotOpenClient client; private static String XNBPMUrl; @@ -21,15 +24,15 @@ public class ClientFactory { } -// public synchronized static CloudpivotOpenClient getInstance() { -// if (client == null) { -// synchronized (CloudpivotOpenClient.class) { -// if (client == null) { -// CloudpivotEnvConfig config = new CloudpivotEnvConfig(XNBPMUrl + "/api", CLIENT_ID, CLIENT_SECRET); -// client = new CloudpivotOpenClient(config, new JdkHttpClient()); -// } -// } -// } -// return client; -// } + public synchronized static CloudpivotOpenClient getInstance() { + if (client == null) { + synchronized (CloudpivotOpenClient.class) { + if (client == null) { + CloudpivotEnvConfig config = new CloudpivotEnvConfig(XNBPMUrl + "/api", CLIENT_ID, CLIENT_SECRET); + client = new CloudpivotOpenClient(config, new JdkHttpClient()); + } + } + } + return client; + } } \ No newline at end of file diff --git a/src/test/java/com/chint/LYTest.java b/src/test/java/com/chint/LYTest.java index 7adbc2fc..6956b640 100644 --- a/src/test/java/com/chint/LYTest.java +++ b/src/test/java/com/chint/LYTest.java @@ -3,6 +3,10 @@ package com.chint; import cn.hutool.core.lang.hash.Hash; import com.alibaba.fastjson.JSON; +import com.authine.cloudpivot.opensdk.ApiException; +import com.authine.cloudpivot.opensdk.CloudpivotOpenClient; +import com.authine.cloudpivot.opensdk.model.request.workflow.StartWorkflowRequest; +import com.authine.cloudpivot.opensdk.model.response.workflow.StartWorkflowResponse; import com.chint.domain.aggregates.user.User; import com.chint.infrastructure.constant.LYConstant; import com.chint.infrastructure.util.BaseContext; @@ -413,40 +417,40 @@ 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())) { -// throw new RuntimeException("用户不存在!"); -// } -// String userId = xnTokenDto.getUser_id(); -// CloudpivotOpenClient client = ClientFactory.getInstance(); -// StartWorkflowRequest request = new StartWorkflowRequest(); -// Gson gson = new Gson(); -// RescheduleDto rescheduleDto = new RescheduleDto(); -// rescheduleDto.setOrderType("机票改签")//内容选项:机票改签,机票退票,火车票改签,火车票退票 -// .setOrderSource("携程商旅")//携程商旅/同程商旅 -// .setOrderNo("00002")//订单号 -// .setStartTime("2024-02-22 10:00:00")//机票改签或火车票改签提供: 原时间 -// .setRebookStartTime("2024-02-23 10:00:00")//机票改签或火车票改签提供: 改签后时间 -// .setTrainNumber("")//火车票改签提供: 原车次 -// .setSeatingStandard("")//火车票改签提供: 原席别 -// .setRebookTrainNumber("")//火车票改签提供: 改签后车次 -// .setRebookSeatingStandard("")//火车票改签提供: 改签后席别 -// .setFee(BigDecimal.valueOf(100))//费用 -// .setReason("行程冲突");//原因 -// String entityParamValues = gson.toJson(rescheduleDto); -// 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("JG_AS_CLGQSQ");//改签流程 -// try { -// StartWorkflowResponse response = client.startWorkflow(request); -// System.out.println("response = " + JSON.toJSONString(response)); -// } catch (ApiException e) { -// throw new RuntimeException(e.getMessage()); -// } + 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(); + RescheduleDto rescheduleDto = new RescheduleDto(); + rescheduleDto.setOrderType("机票改签")//内容选项:机票改签,机票退票,火车票改签,火车票退票 + .setOrderSource("携程商旅")//携程商旅/同程商旅 + .setOrderNo("00002")//订单号 + .setStartTime("2024-02-22 10:00:00")//机票改签或火车票改签提供: 原时间 + .setRebookStartTime("2024-02-23 10:00:00")//机票改签或火车票改签提供: 改签后时间 + .setTrainNumber("")//火车票改签提供: 原车次 + .setSeatingStandard("")//火车票改签提供: 原席别 + .setRebookTrainNumber("")//火车票改签提供: 改签后车次 + .setRebookSeatingStandard("")//火车票改签提供: 改签后席别 + .setFee(BigDecimal.valueOf(100))//费用 + .setReason("行程冲突");//原因 + String entityParamValues = gson.toJson(rescheduleDto); + 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("JG_AS_CLGQSQ");//改签流程 + try { + StartWorkflowResponse response = client.startWorkflow(request); + System.out.println("response = " + JSON.toJSONString(response)); + } catch (ApiException e) { + throw new RuntimeException(e.getMessage()); + } } } From 42174e9bce618f4e41b82091b778fe10fb3fcd76 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 10:33:39 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index ec7065af..f69df198 100644 --- a/pom.xml +++ b/pom.xml @@ -106,4 +106,11 @@ + + + central + 新正泰集团公共仓库 + https://newmaven.chint.com/repository/maven-public/ + + From c8290fd7d9243fb5731133e34c6aba5e2382593b Mon Sep 17 00:00:00 2001 From: dengwc Date: Fri, 1 Mar 2024 10:49:46 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=96=B0=E8=83=BD=E4=BA=91=E6=9E=A2?= =?UTF-8?q?=E8=B6=85=E6=A0=87=E3=80=81=E6=94=B9=E7=AD=BE=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 10 +- .../interfaces/rest/bpm/BPMController.java | 9 + .../chint/interfaces/rest/bpm/BPMRequest.java | 71 +++--- .../rest/bpm/XNBPM/ClientFactory.java | 27 +-- .../interfaces/rest/bpm/dto/ChangeDto.java | 55 +++++ src/test/java/com/chint/LYTest.java | 202 +++++++++++------- 6 files changed, 254 insertions(+), 120 deletions(-) create mode 100644 src/main/java/com/chint/interfaces/rest/bpm/dto/ChangeDto.java diff --git a/pom.xml b/pom.xml index d1d73028..ec7065af 100644 --- a/pom.xml +++ b/pom.xml @@ -82,11 +82,11 @@ 3.0.3 - - - - - + + com.authine.cloudpivot + cloudpivot-opensdk + 1.0 + 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 85668c5b..444d6fb2 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/BPMController.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/BPMController.java @@ -41,4 +41,13 @@ public class BPMController { System.out.println("bpmBack = " + bpmBack); return Result.Success(CommonMessageConstant.SUCCESS); } + + //差旅更变审批 + @ApiOperation("BPM改签审批结果回传") + @PostMapping("/change/back") + public Result changeBack(@RequestBody BPMBack bpmBack) { + //获取订单号和审批结果 + System.out.println("bpmBack = " + bpmBack); + return Result.Success(CommonMessageConstant.SUCCESS); + } } 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 290eff40..20971861 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/BPMRequest.java @@ -1,19 +1,31 @@ package com.chint.interfaces.rest.bpm; +import com.alibaba.fastjson.JSON; +import com.authine.cloudpivot.opensdk.ApiException; +import com.authine.cloudpivot.opensdk.CloudpivotOpenClient; +import com.authine.cloudpivot.opensdk.model.request.workflow.StartWorkflowRequest; +import com.authine.cloudpivot.opensdk.model.response.workflow.StartWorkflowResponse; 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.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.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; 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; @Service @@ -68,35 +80,34 @@ public class BPMRequest { * 新能云枢接口 */ public BPMResponse XNBPMSubmitWorkflow(String workflowCode, Object entityObject) { -// //获取用户信息 -// 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())) { -// throw new RuntimeException("用户不存在!"); -// } -// String userId = xnTokenDto.getUser_id(); -// CloudpivotOpenClient client = ClientFactory.getInstance(); -// StartWorkflowRequest request = new StartWorkflowRequest(); -// Gson gson = new Gson(); -// String entityParamValues = gson.toJson(entityObject); -// 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(workflowCode);//超标流程 -// try { -// StartWorkflowResponse response = client.startWorkflow(request); -// System.out.println("response = " + JSON.toJSONString(response)); -// } catch (ApiException e) { -// throw new RuntimeException(e.getMessage()); -// } -// BPMResponse bpmResponse = new BPMResponse(); -// bpmResponse.setSuccess(true); -// return bpmResponse; - return null; + //获取用户信息 + 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())) { + throw new RuntimeException("用户不存在!"); + } + String userId = xnTokenDto.getUser_id(); + CloudpivotOpenClient client = ClientFactory.getInstance(); + StartWorkflowRequest request = new StartWorkflowRequest(); + Gson gson = new Gson(); + String entityParamValues = gson.toJson(entityObject); + 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(workflowCode);//超标流程 + try { + StartWorkflowResponse response = client.startWorkflow(request); + System.out.println("response = " + JSON.toJSONString(response)); + } catch (ApiException e) { + throw new RuntimeException(e.getMessage()); + } + BPMResponse bpmResponse = new BPMResponse(); + bpmResponse.setSuccess(true); + return bpmResponse; } } diff --git a/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java b/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java index 3921c55a..179d210b 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/XNBPM/ClientFactory.java @@ -1,6 +1,9 @@ package com.chint.interfaces.rest.bpm.XNBPM; +import com.authine.cloudpivot.opensdk.CloudpivotOpenClient; +import com.authine.cloudpivot.opensdk.client.impl.JdkHttpClient; +import com.authine.cloudpivot.opensdk.config.CloudpivotEnvConfig; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -11,7 +14,7 @@ import static com.chint.infrastructure.constant.BPMConstant.*; */ @Service public class ClientFactory { -// private static CloudpivotOpenClient client; + private static CloudpivotOpenClient client; private static String XNBPMUrl; @@ -21,15 +24,15 @@ public class ClientFactory { } -// public synchronized static CloudpivotOpenClient getInstance() { -// if (client == null) { -// synchronized (CloudpivotOpenClient.class) { -// if (client == null) { -// CloudpivotEnvConfig config = new CloudpivotEnvConfig(XNBPMUrl + "/api", CLIENT_ID, CLIENT_SECRET); -// client = new CloudpivotOpenClient(config, new JdkHttpClient()); -// } -// } -// } -// return client; -// } + public synchronized static CloudpivotOpenClient getInstance() { + if (client == null) { + synchronized (CloudpivotOpenClient.class) { + if (client == null) { + CloudpivotEnvConfig config = new CloudpivotEnvConfig(XNBPMUrl + "/api", CLIENT_ID, CLIENT_SECRET); + client = new CloudpivotOpenClient(config, new JdkHttpClient()); + } + } + } + return client; + } } \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/bpm/dto/ChangeDto.java b/src/main/java/com/chint/interfaces/rest/bpm/dto/ChangeDto.java new file mode 100644 index 00000000..64658609 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/bpm/dto/ChangeDto.java @@ -0,0 +1,55 @@ +package com.chint.interfaces.rest.bpm.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.List; + +/** + * 变更 + */ +@Data +@Accessors(chain = true) +public class ChangeDto { + private String StartTime;//出差开始时间 是否必填 是 + private String EndTime;//出差结束时间 是否必填 是 + private String Reason;//出差说明 是否必填 是 + private List JT_FI_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 否 + private List JT_FI_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 否 + private List JT_FI_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 7adbc2fc..1aef8680 100644 --- a/src/test/java/com/chint/LYTest.java +++ b/src/test/java/com/chint/LYTest.java @@ -3,6 +3,10 @@ package com.chint; import cn.hutool.core.lang.hash.Hash; import com.alibaba.fastjson.JSON; +import com.authine.cloudpivot.opensdk.ApiException; +import com.authine.cloudpivot.opensdk.CloudpivotOpenClient; +import com.authine.cloudpivot.opensdk.model.request.workflow.StartWorkflowRequest; +import com.authine.cloudpivot.opensdk.model.response.workflow.StartWorkflowResponse; import com.chint.domain.aggregates.user.User; import com.chint.infrastructure.constant.LYConstant; import com.chint.infrastructure.util.BaseContext; @@ -11,10 +15,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.*; -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.chint.interfaces.rest.ly.LYLoginRequest; import com.chint.interfaces.rest.ly.LYPostRequest; import com.chint.interfaces.rest.ly.LYTokenRequest; @@ -319,7 +320,7 @@ public class LYTest { ExceedStandardDto exceedStandardDto = new ExceedStandardDto(); exceedStandardDto.setOrderType("酒店超标")//内容选项:酒店超标,火车票超标,机票超标 .setOrderSource("携程商旅")//内容选项:携程商旅/同程商旅 - .setOrderNo("001021214")//订单号 + .setOrderNo("001121214")//订单号 .setHotelStandard("标间")//酒店超标提供:住宿标准 .setHotelName("酒店名称")//酒店超标提供:酒店名称 .setHouseLayout("双人床")//酒店超标提供:房型 @@ -366,45 +367,100 @@ public class LYTest { System.out.println("response = " + response); } + + //差旅变更 + @Test + void change() { + BPMBaseRequest bpmRequest = new BPMBaseRequest(); + Gson gson = new Gson(); + ChangeDto changeDto = new ChangeDto(); + //新增行程 + ArrayList newTrips = new ArrayList<>(); + ChangeDto.NewTrip newTrip = new ChangeDto.NewTrip(); + newTrip.setAllowProductTypes("飞机") + .setDepartCitiesName("温州") + .setArriveCitiesName("北京") + .setBsDate("2024-03-01") + .setEdDate("2024-03-01") + .setReason("出差帮扶"); + newTrips.add(newTrip); + //原行程 + ArrayList oldTrips = new ArrayList<>(); + ChangeDto.OldTrip oldTrip = new ChangeDto.OldTrip(); + oldTrip.setAllowProductTypes("火车") + .setDepartCitiesName("温州") + .setArriveCitiesName("杭州") + .setBsDate("2024-03-01") + .setEdDate("2024-03-01"); + oldTrips.add(oldTrip); + //变更行程 + ArrayList changeTrips = new ArrayList<>(); + ChangeDto.ChangeTrip changeTrip = new ChangeDto.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("出差帮扶")//出差说明 + .setJT_FI_CLBGSQ_ITEM_NewTrip(newTrips)//新增行程信息 + .setJT_FI_CLBGSQ_ITEM_OldTrip(oldTrips)//原行程信息 + .setJT_FI_CLBGSQ_ITEM_ChangeTrip(changeTrips);//变更行程信息 + String entityParamValues = gson.toJson(changeDto); + bpmRequest.setWorkflowCode("JT_FI_CLBGSQ")//流程编码 + .setUserCode("231116011")//sf号 + .setFinishStart(true)//true:会自动流转到下一审批点,false:停在手工填写节点 + .setEntityParamValues(entityParamValues); + BPMBaseResponse bpmBaseResponse = httpPostRequest.post(H3BPMUrl + H3BPM_EXCEED_STANDARD_URL, bpmRequest, BPMBaseResponse.class); + System.out.println("response = " + bpmBaseResponse); + BPMResponse response = bpmBaseResponse.getD(); + System.out.println("response = " + response); + } + + /** * 云枢超标流程测试 */ @Test public void testDemo() 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(); -// 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>(){}.getType(); -// HashMap map = gson.fromJson(entityParamValues, type); -// request.setData(map);//数据 -// request.setDepartmentId("");//部门id,默认主部门 -// request.setFinishStart(true);//发起流程 -// request.setUserId(userId);//员工号 -// request.setWorkflowCode("JG_AS_CLCESQ");//超标流程 -// try { -// StartWorkflowResponse response = client.startWorkflow(request); -// System.out.println("response = " + JSON.toJSONString(response)); -// } catch (ApiException e) { -// throw new RuntimeException(e.getMessage()); -// } + 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(); + 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>(){}.getType(); + HashMap map = gson.fromJson(entityParamValues, type); + request.setData(map);//数据 + request.setDepartmentId("");//部门id,默认主部门 + request.setFinishStart(true);//发起流程 + request.setUserId(userId);//员工号 + request.setWorkflowCode("JG_AS_CLCESQ");//超标流程 + try { + StartWorkflowResponse response = client.startWorkflow(request); + System.out.println("response = " + JSON.toJSONString(response)); + } catch (ApiException e) { + throw new RuntimeException(e.getMessage()); + } } @@ -413,40 +469,40 @@ 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())) { -// throw new RuntimeException("用户不存在!"); -// } -// String userId = xnTokenDto.getUser_id(); -// CloudpivotOpenClient client = ClientFactory.getInstance(); -// StartWorkflowRequest request = new StartWorkflowRequest(); -// Gson gson = new Gson(); -// RescheduleDto rescheduleDto = new RescheduleDto(); -// rescheduleDto.setOrderType("机票改签")//内容选项:机票改签,机票退票,火车票改签,火车票退票 -// .setOrderSource("携程商旅")//携程商旅/同程商旅 -// .setOrderNo("00002")//订单号 -// .setStartTime("2024-02-22 10:00:00")//机票改签或火车票改签提供: 原时间 -// .setRebookStartTime("2024-02-23 10:00:00")//机票改签或火车票改签提供: 改签后时间 -// .setTrainNumber("")//火车票改签提供: 原车次 -// .setSeatingStandard("")//火车票改签提供: 原席别 -// .setRebookTrainNumber("")//火车票改签提供: 改签后车次 -// .setRebookSeatingStandard("")//火车票改签提供: 改签后席别 -// .setFee(BigDecimal.valueOf(100))//费用 -// .setReason("行程冲突");//原因 -// String entityParamValues = gson.toJson(rescheduleDto); -// 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("JG_AS_CLGQSQ");//改签流程 -// try { -// StartWorkflowResponse response = client.startWorkflow(request); -// System.out.println("response = " + JSON.toJSONString(response)); -// } catch (ApiException e) { -// throw new RuntimeException(e.getMessage()); -// } + 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(); + RescheduleDto rescheduleDto = new RescheduleDto(); + rescheduleDto.setOrderType("机票改签")//内容选项:机票改签,机票退票,火车票改签,火车票退票 + .setOrderSource("携程商旅")//携程商旅/同程商旅 + .setOrderNo("00002")//订单号 + .setStartTime("2024-02-22 10:00:00")//机票改签或火车票改签提供: 原时间 + .setRebookStartTime("2024-02-23 10:00:00")//机票改签或火车票改签提供: 改签后时间 + .setTrainNumber("")//火车票改签提供: 原车次 + .setSeatingStandard("")//火车票改签提供: 原席别 + .setRebookTrainNumber("")//火车票改签提供: 改签后车次 + .setRebookSeatingStandard("")//火车票改签提供: 改签后席别 + .setFee(BigDecimal.valueOf(100))//费用 + .setReason("行程冲突");//原因 + String entityParamValues = gson.toJson(rescheduleDto); + 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("JG_AS_CLGQSQ");//改签流程 + try { + StartWorkflowResponse response = client.startWorkflow(request); + System.out.println("response = " + JSON.toJSONString(response)); + } catch (ApiException e) { + throw new RuntimeException(e.getMessage()); + } } }