超标接口调整

This commit is contained in:
dengwc 2024-03-18 15:57:02 +08:00
parent 6f8aae90e4
commit 00229dea9e
2 changed files with 271 additions and 14 deletions

View File

@ -2,36 +2,61 @@ package com.chint;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import com.alibaba.fastjson.JSON;
import com.authine.cloudpivot.opensdk.ApiException;
import com.authine.cloudpivot.opensdk.CloudpivotOpenClient;
import com.authine.cloudpivot.opensdk.client.impl.JdkHttpClient;
import com.authine.cloudpivot.opensdk.config.CloudpivotEnvConfig;
import com.authine.cloudpivot.opensdk.model.request.workflow.StartWorkflowRequest;
import com.authine.cloudpivot.opensdk.model.response.workflow.StartWorkflowResponse;
import com.chint.application.commands.RefundOrderGenerateCommand;
import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.standards.StaffRank;
import com.chint.domain.aggregates.standards.XNStaffRank;
import com.chint.domain.service.order_sync.LYOrderSyncAdapter;
import com.chint.infrastructure.config.LogConfig.LogController;
import com.chint.infrastructure.config.LogConfig.RedisCache;
import com.chint.infrastructure.config.LogConfig.SystemLog;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.repository.jdbc.JdbcLegRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
import com.chint.infrastructure.repository.jdbc.JdbcStaffRankRepository;
import com.chint.infrastructure.repository.jdbc.JdbcSystemLogRepository;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.bpm.XNBPM.YSTokenDto;
import com.chint.interfaces.rest.bpm.dot.ANBPMBack;
import com.chint.interfaces.rest.bpm.dto.*;
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity;
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
import com.chint.interfaces.rest.ctrip.dto.search.car.CarBasicInfo;
import com.chint.interfaces.rest.ctrip.dto.search.car.CarQuickOrderInfoEntity;
import com.chint.interfaces.rest.ctrip.dto.search.car.OrderFee;
import com.chint.interfaces.rest.ctrip.dto.search.flight.ChangeInfo;
import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightOrderInfoEntity;
import com.chint.interfaces.rest.ly.LYSearchRequest;
import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderResponse;
import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.scheduling.annotation.Async;
import java.io.File;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
import static com.chint.infrastructure.constant.BPMConstant.YSBPM_TOKEN_URL;
@Slf4j
@SpringBootTest
@ -150,17 +175,44 @@ public class ExcelTest {
processedLogCount = 0;
}
// @Test
//@Test
public void saveLog() {
int count = 0; // 初始化计数器
while (count <= 10000) { //当计数器小于10000时执行循环
long logNums = redisCache.getHashSize("SystemLog");
if (logNums <= 0L) {
break;//没有数据结束循环
}
//获取日志信息
Map<String, Object> systemLogMap = redisCache.getCacheHashValues("SystemLog", 100);
if (systemLogMap.isEmpty()) {
break; // 如果没有数据可取跳出循环
}
List<Object> logData = new ArrayList<>(systemLogMap.values());
Gson gson = new Gson();
List<SystemLog> systemLogs = logData.stream().map(log ->
gson.fromJson((String) log, SystemLog.class)
).toList();
jdbcSystemLogRepository.saveAll(systemLogs);
// 删除已处理的日志数据
redisCache.delCacheMapValue("SystemLog", systemLogMap.keySet());
count++;
}
log.info("日志保存成功");
}
// @Test
public void aa111() {
LocalDateTime time1 = LocalDateTime.of(2024, 3, 22, 0, 0, 0);
LocalDateTime time2 = LocalDateTime.of(2024, 3, 22, 0, 0, 0);
Duration duration = Duration.between(time2,time1);
Duration duration = Duration.between(time2, time1);
long days = duration.toDays(); // 获取天数差异
//预估入住天数
int roundedDays = (int) Math.ceil(days); // 向上取整例如大于一天小于二天取1天
}
// @Test
// @Test
public void deleteLog() throws InterruptedException {
/*Integer count = jdbcSystemLogRepository.deleteLogsOlderThanOneMonth();
log.info("日志删除成功:{}条", count);
@ -189,11 +241,214 @@ public class ExcelTest {
@Autowired
LogController logController;
// @Test
// @Test
public void logTableSizeInMB() throws InterruptedException {
Result<Integer> integerResult = logController.deleteLogDays(1);
System.out.println("logMessageDtoResult = " + integerResult);
}
@Autowired
private LYSearchRequest lySearchRequest;
// @Test
public void aaaaa() {
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DTC24031366584001415");
System.out.println("trainOrderDetail = " + trainOrderDetail);
}
@Autowired
private CTripOrderSearchRequest cTripOrderSearchRequest;
// @Test
public void cTrip() {
SearchOrderResponse searchOrderResponse = cTripOrderSearchRequest.searchOrderResponseByOrderId("31025198037");
List<ItineraryEntity> itineraryList = searchOrderResponse.getItineraryList();
ItineraryEntity itineraryEntity = itineraryList.get(0);
FlightOrderInfoEntity flightOrderInfoList = itineraryEntity.getFlightOrderInfoList().get(0);
//改签前时间
String createTime = flightOrderInfoList.getFlightInfo().get(0).getTakeoffTime();
ChangeInfo changeInfo = flightOrderInfoList.getPassengerInfo().get(0).getSequenceInfo().get(0).getChangeInfo().get(0);
//改签后时间
String cTakeOffTime = changeInfo.getCTakeOffTime();
//改签原因
String RebookReasonDesc = changeInfo.getRebookReasonDesc();
FlightOrderInfoEntity flightOrderInfoLists = searchOrderResponse.getItineraryList().get(0).getFlightOrderInfoList().get(0);
String refundResonDesc = flightOrderInfoLists.getRefundInfo().get(0).getRefundResonDesc();
}
// @Test
public void Ly() {
TrainDetailResponse trainDetailResponse = lySearchRequest.getTrainOrderDetail("DTC24031466742283976");
TrainDetailResponse.TrainDetailData data = trainDetailResponse.getData();
String trainNo = data.getTrainNo();//原车次
String planBeginDateOld = data.getPlanBeginDate();//原时间
//原席别
TrainDetailResponse.Item item = data.getItems().get(0);
String seatClassOld = item.getSeatClass();
TrainDetailResponse.ChangeInfo changeInfo = item.getChangeInfo();
String planBeginDate = changeInfo.getPlanBeginDate();//改签后时间
String ticketNo = changeInfo.getTrainNo();//改签后车次
String seatClass = changeInfo.getChangeItem().getSeatClass();//改签后席别
}
@Autowired
private JdbcOrderDetailRepository jdbcOrderDetailRepository;
// @Test
public void LyFlight() {
FlightOrderResponse flightOrderResponse = lySearchRequest.getFlightOrderDetail("DFC24031466775503254");
FlightOrderResponse.FlightSegment flightSegment = flightOrderResponse.getData().getFlightSegmentList().get(0);
String departTimeFull = flightSegment.getDepartTimeFull();//改签后时间
//原订单
FlightOrderResponse.Data data = flightOrderResponse.getData();
String originalOrderNo = data.getOrderDetails().getOriginalOrderNo();
OrderDetail byOrderNo = jdbcOrderDetailRepository.findFirstByOrderNo("DFC24031466775503254");
}
// @Test
public void CarTest() {
SearchOrderResponse searchOrderResponse = cTripOrderSearchRequest.searchOrderResponseByOrderId("30352884087");
List<ItineraryEntity> itineraryList = searchOrderResponse.getItineraryList();
List<CarQuickOrderInfoEntity> carQuickOrderInfoList = itineraryList.get(0).getCarQuickOrderInfoList();
CarBasicInfo basicInfo = carQuickOrderInfoList.get(0).getBasicInfo();
List<OrderFee> orderFeeList = carQuickOrderInfoList.get(0).getOrderFeeList();
for (OrderFee orderFee : orderFeeList) {
//退款
if ("REFUND".equals(orderFee.getCostScene()) || "AFTER_REFUND".equals(orderFee.getCostScene())) {
LocalDateTime localDateTime = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
Command.of(RefundOrderGenerateCommand.class).Info(
String.valueOf(orderFee.getOrderFeeId()),
basicInfo.getOrderId(),
"-" + orderFee.getAmount(),
"4",
localDateTime.format(formatter)
).sendToQueue();
}
}
}
@Autowired
private PostRequest postRequest;
// @Test
public void outOfStandard() {
String ANBPMUrl = "https://fssc.chintanneng.com/fssc";
String AN_Exceed_Standard = "/extapi/businessTravel/exceeding";
String url = ANBPMUrl + AN_Exceed_Standard;
// 定义日期时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS");
String startTime = "2024-03-12T16:31:34.619";
String endTime = "2024-03-12T16:31:34.619";
ANExceedStandardDto anExceedStandardDto = new ANExceedStandardDto();
anExceedStandardDto.setSourceSystemNum("123456")//来源系统ID
.setSourceSystem("chint-trip")//系统标识
.setApplicant("220329071")//申请人
.setApplyNo("CLSQ24031200003")//差旅申请单号
.setOrderNo("order123")//商旅订单号
.setOrderType("火车票超标")//超标原因
.setOrderSource("携程商旅")//订单来源
.setLegNo("L2403121044077470")//行程ID
.setStartPlace("北京")//出发地
.setEndPlace("上海")//目的地
.setStartTime(LocalDateTime.parse(startTime, formatter))//开始日期
.setEndTime(LocalDateTime.parse(endTime, formatter))//结束日期
.setOrderMoney(new BigDecimal("358.16"));//金额
ANBPMBack anbpmBack = postRequest.postANBPM(url, anExceedStandardDto, ANBPMBack.class);
System.out.println("anbpmBack = " + anbpmBack);
}
@Autowired
private PostRequest httpPostRequest;
// @Test
public void aabbcc() {
YSTokenDto tokenDto = httpPostRequest.get("https://bpm.astronergy.com.cn" + YSBPM_TOKEN_URL + "?code=" + "191107079", YSTokenDto.class);
if (!"0".equals(tokenDto.getErrcode())) {
throw new RuntimeException("用户不存在!");
}
String userId = tokenDto.getUser_id();
CloudpivotOpenClient client = getXNInstance();
System.out.println("xnInstance = " + client);
StartWorkflowRequest request = new StartWorkflowRequest();
Gson gson = new Gson();
XNChangeDto changeDto = new XNChangeDto();
//新增行程
ArrayList<LegNewTrip> newTrips = new ArrayList<>();
LegNewTrip newTrip = new LegNewTrip();
newTrip.setAllowProductTypes("飞机")
.setDepartCitiesName("温州")
.setArriveCitiesName("北京")
.setBsDate("2024-03-01")
.setEdDate("2024-03-01")
.setReason("出差帮扶");
newTrips.add(newTrip);
//原行程
ArrayList<LegOldTrip> oldTrips = new ArrayList<>();
LegOldTrip oldTrip = new LegOldTrip();
oldTrip.setAllowProductTypes("火车")
.setDepartCitiesName("温州")
.setArriveCitiesName("杭州")
.setBsDate("2024-03-01")
.setEdDate("2024-03-01");
oldTrips.add(oldTrip);
//变更行程
ArrayList<LegChangeTrip> changeTrips = new ArrayList<>();
LegChangeTrip changeTrip = new LegChangeTrip();
changeTrip.setAllowProductTypes("火车")
.setDepartCitiesName("乐清")
.setArriveCitiesName("杭州")
.setBsDate("2024-03-01")
.setEdDate("2024-03-01")
.setReason("出发地变更");
changeTrips.add(changeTrip);
//设置值
changeDto.setStartTime("2024-03-01")//出差开始时间
.setEndTime("2024-03-01")//出差结束时间
.setReason("出差帮扶")//出差说明
.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());
}
}
private static CloudpivotOpenClient XNClient;
public synchronized static CloudpivotOpenClient getXNInstance() {
if (XNClient == null) {
CloudpivotEnvConfig config = new CloudpivotEnvConfig("https://bpm.astronergy.com.cn" + "/api", "xclient", "0a417ecce58c31b32364ce19ca8fcd15");
XNClient = new CloudpivotOpenClient(config, new JdkHttpClient());
}
return XNClient;
}
}

View File

@ -6,12 +6,14 @@ 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.application.commands.RefundOrderGenerateCommand;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.OrderTravel;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.OrderDetailRepository;
import com.chint.domain.repository.RouteRepository;
import com.chint.infrastructure.constant.LYConstant;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderTravelRepository;
import com.chint.infrastructure.util.BaseContext;
import com.chint.interfaces.rest.base.PostRequest;
@ -793,7 +795,7 @@ public class LYTest {
}
@Test
// @Test
void search() {
// FlightOrderResponse t1 = lySearchRequest
// .getFlightOrderDetail("DF24031466751565416");
@ -820,12 +822,12 @@ public class LYTest {
// System.out.println(json);
}
@Test
// @Test
void conform() {
commonController.changeFlight(0, 9, "T24031566810476306");
}
@Test
// @Test
void sendMsg() {
commonController.sendMsg("T24031566811702174");
}