fix:错误日志回推增加订单号,用户部门信息清楚缺失状态和姓名的数据

This commit is contained in:
lulz1 2024-05-15 13:32:50 +08:00
parent 830abc84d8
commit 3159692893
11 changed files with 62 additions and 107 deletions

View File

@ -104,6 +104,12 @@
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.5.6</version>
</dependency>
</dependencies>
<build>

View File

@ -6,12 +6,14 @@ import lombok.Data;
@Data
public class SupplierCallBackErrorCommand extends Command {
private Exception e;
private String orderNo;
private String supplierName;
private String requestBody;
public SupplierCallBackErrorCommand info(String supplierName, String requestBody, Exception e) {
public SupplierCallBackErrorCommand info(String supplierName, String orderNo, String requestBody, Exception e) {
this.setSupplierName(supplierName);
this.setRequestBody(requestBody);
this.setOrderNo(orderNo);
this.setE(e);
return this;
}

View File

@ -3,7 +3,6 @@ package com.chint.domain.aggregates.supplier;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;
import java.io.PrintWriter;
@ -16,6 +15,7 @@ public class SupplierCallBackLog {
@Id
private Long id;
private String supplierName;
private String orderNo;
private LocalDateTime happenTime;
private String callBackJson;
@ -35,10 +35,10 @@ public class SupplierCallBackLog {
return this;
}
public static SupplierCallBackLog fromException(String supplierName, String requestBody, Exception e) {
public static SupplierCallBackLog fromException(String supplierName, String orderNo, String requestBody, Exception e) {
SupplierCallBackLog log = SupplierCallBackLog.start();
log.setSupplierName(supplierName);
log.setOrderNo(orderNo);
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String exceptionDetails = sw.toString();

View File

@ -371,6 +371,7 @@ public class User implements Serializable {
List<UserDepartmentInfo> userDepartmentInfoList = this.getUserDepartmentInfoList();
List<UserDepartmentInfo> result = new ArrayList<>();
if (userDepartmentInfoList != null && !userDepartmentInfoList.isEmpty()) {
userDepartmentInfoList.removeIf(departmentInfo -> departmentInfo.getStatus() == null || departmentInfo.getUname() == null);
userDepartmentInfoList.removeIf(departmentInfo -> departmentInfo.equals(userDepartmentInfo));
List<UserDepartmentInfo> list = userDepartmentInfoList.stream().distinct().toList();
if (userDepartmentInfo.ifPrimary()) {

View File

@ -62,7 +62,7 @@ public class SupplierDomainService {
@ListenTo(command = "SupplierCallBackErrorCommand", order = 0)
public void supplierCallBackError(SupplierCallBackErrorCommand command) {
SupplierCallBackLog supplierCallBackLog = SupplierCallBackLog
.fromException(command.getSupplierName(), command.getRequestBody(), command.getE());
.fromException(command.getSupplierName(), command.getOrderNo(), command.getRequestBody(), command.getE());
supplierCallBackLogRepository.save(supplierCallBackLog);
}
}

View File

@ -91,7 +91,7 @@ public class AmapNoteController {
} catch (Exception e) {
//如果推送异常将异常信息保存到数据库
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
.info(SUPPLIER_AMAP, requestBody, e).sendToQueue());
.info(SUPPLIER_AMAP, data.getAmapOrderId(), requestBody, e).sendToQueue());
e.printStackTrace();
}

View File

@ -116,7 +116,7 @@ public class CTripNoteController {
} catch (Exception e) {
//如果推送异常将异常信息保存到数据库
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
.info(SUPPLIER_C_TRIP, gson.toJson(notification), e).sendToQueue());
.info(SUPPLIER_C_TRIP, notification.getOrderId(), gson.toJson(notification), e).sendToQueue());
e.printStackTrace();
}
i++;

View File

@ -18,8 +18,6 @@ import com.chint.domain.service.RankDomainService;
import com.chint.infrastructure.constant.SFConstant;
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.StringCheck;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.data_center.user.dto.UserDataDTO;
import lombok.extern.slf4j.Slf4j;
@ -29,7 +27,6 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
import java.util.function.Predicate;
import static com.chint.infrastructure.constant.CommonMessageConstant.EMPLOYEE_NO_NOT_EXIST;
import static com.chint.infrastructure.constant.RankConstant.DEFAULT_RANK_NAME;
@ -82,7 +79,7 @@ public class UserHttpRequestImpl implements UserHttpRequest {
List<UserDepartmentInfo> userDepartmentInfoList = user
.getUserDepartmentInfoList()
.stream()
.filter(it -> it.getStatus().equals("A"))
.filter(it -> "A".equals(it.getStatus()))
.toList();
for (UserDepartmentInfo userDepartmentInfo : userDepartmentInfoList) {
String companyCode = userDepartmentInfo.getCompanyCode();
@ -161,7 +158,7 @@ public class UserHttpRequestImpl implements UserHttpRequest {
List<UserDataDTO> fromJson = userSFDataFromOpenApi
.stream()
.filter(userDataDTO -> userDataDTO.getStatus().equals("A"))
.filter(userDataDTO -> "A".equals(userDataDTO.getStatus()))
.toList();

View File

@ -4,7 +4,6 @@ package com.chint.interfaces.rest.ly.in;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.chint.application.commands.SupplierCallBackErrorCommand;
import com.chint.domain.aggregates.order.OrderTravel;
import com.chint.domain.repository.SupplierCallBackLogRepository;
import com.chint.infrastructure.constant.CommonMessageConstant;
import com.chint.infrastructure.echo_framework.command.Command;
@ -22,7 +21,6 @@ import com.chint.interfaces.rest.ly.dto.strokepush.StrokePushResult;
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeParam;
import com.chint.interfaces.rest.ly.dto.strokepush.TrainChange.TrainChangeRequest;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -35,12 +33,10 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y;
@Slf4j
@ -119,25 +115,16 @@ public class CommonController {
if (null == object) {
return;
}
try {
Notification notification = gson.fromJson(String.valueOf(object), Notification.class);
int notifyType = notification.getNotifyType();
switch (notifyType) {
//进行订单数据回推
case 1 -> getOrderFlight(notification);
case 3 -> getOrderHotel(notification);
case 5 -> getOrderTrain(notification);
case 6 -> getOrderCar(notification);
default -> LYNoteResponse.success();
}
} catch (Exception e) {
//如果推送异常将异常信息保存到数据库
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
.info(SUPPLIER_L_Y, String.valueOf(object), e).sendToQueue());
e.printStackTrace();
Notification notification = gson.fromJson(String.valueOf(object), Notification.class);
int notifyType = notification.getNotifyType();
switch (notifyType) {
//进行订单数据回推
case 1 -> getOrderFlight(notification);
case 3 -> getOrderHotel(notification);
case 5 -> getOrderTrain(notification);
case 6 -> getOrderCar(notification);
default -> LYNoteResponse.success();
}
i++;
if (i > 5) {
log.info("CommonBack处理结束");
@ -158,7 +145,14 @@ public class CommonController {
JSONObject jsonObj = JSON.parseObject(notifyData.toString());
ResultBackCar.DataObject orderCar = jsonObj.toJavaObject(ResultBackCar.DataObject.class);
String orderSerialNo = orderCar.getOrder().getOrderSerialNo();
return lyCallBackDataHandler.carCallBackData(orderSerialNo);
try {
return lyCallBackDataHandler.carCallBackData(orderSerialNo);
} catch (Exception e) {
//如果推送异常将异常信息保存到数据库
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
.info(SUPPLIER_L_Y, orderSerialNo, gson.toJson(notification), e).sendToQueue());
e.printStackTrace();
}
}
return new LYNoteResponse("100", "OK");
}
@ -174,7 +168,14 @@ public class CommonController {
if (Objects.nonNull(notifyData)) {
JSONObject jsonObj = JSON.parseObject(notifyData.toString());
ResultBackTrain orderTrain = jsonObj.toJavaObject(ResultBackTrain.class);
return lyCallBackDataHandler.trainCallBackData(orderTrain.getOrderNo());
try {
return lyCallBackDataHandler.trainCallBackData(orderTrain.getOrderNo());
} catch (Exception e) {
//如果推送异常将异常信息保存到数据库
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
.info(SUPPLIER_L_Y, orderTrain.getOrderNo(), gson.toJson(notification), e).sendToQueue());
e.printStackTrace();
}
}
return new LYNoteResponse("100", "OK");
}
@ -193,7 +194,14 @@ public class CommonController {
ResultBackHotel resultBackHotel = jsonObj.toJavaObject(ResultBackHotel.class);
ResultBackHotel.DataObject dataObject = resultBackHotel.getData();
String orderSerialNo = dataObject.getOrderInfo().getOrderSerialNo();
return lyCallBackDataHandler.hotelCallBackData(orderSerialNo);
try {
return lyCallBackDataHandler.hotelCallBackData(orderSerialNo);
} catch (Exception e) {
//如果推送异常将异常信息保存到数据库
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
.info(SUPPLIER_L_Y, orderSerialNo, gson.toJson(notification), e).sendToQueue());
e.printStackTrace();
}
}
return new LYNoteResponse("100", "OK");
}
@ -217,72 +225,19 @@ public class CommonController {
orderSerialNo = dataObject.getOrderDetails().getOrderSerialNo();
}
//正常流程
return lyCallBackDataHandler.flightCallBackData(orderSerialNo);
try {
return lyCallBackDataHandler.flightCallBackData(orderSerialNo);
} catch (Exception e) {
//如果推送异常将异常信息保存到数据库
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
.info(SUPPLIER_L_Y, orderSerialNo, gson.toJson(notification), e).sendToQueue());
e.printStackTrace();
}
}
return new LYNoteResponse("100", "OK");
}
/**
* 50推送
*
* @param notification
* @return
*/
// public LYNoteResponse getOrderType(Notification notification) {
// int subNotifyType = notification.getSubNotifyType();
// Class<?> objClass = notification.getClass();
// Object object = GetObjectNature.getObject(objClass, "notifyData", notification);
// Gson gson = new Gson();
// NotifyData common = gson.fromJson(object.toString(), NotifyData.class);
// boolean emptyHotel = Objects.nonNull(common.getTravelBizOrderList().getHotelOrderList());
// boolean emptyFly = Objects.nonNull(common.getTravelBizOrderList().getFlightOrderList());
// boolean emptyCar = Objects.nonNull(common.getTravelBizOrderList().getCarOrderList());
// boolean emptyTrain = Objects.nonNull(common.getTravelBizOrderList().getTrainOrderList());
// if (emptyHotel) {//酒店
// NotifyData.HotelOrder hotelOrder = common.getTravelBizOrderList().getHotelOrderList().get(0);
// OrderTravel orderTravel = new OrderTravel();
// orderTravel.setOrderNo(hotelOrder.getOrderInfo().getOrderSerialNo());
// orderTravel.setTravelNo(common.getTravelBizOrder().getTravelOrderNo());
// saveOrderTravel(orderTravel);
// String foulReason = hotelOrder.getOrderInfo().getFoulReason();//超标原因
// return lyCallBackDataHandler.hotelCallBackData(hotelOrder.getOrderInfo().getOrderSerialNo(), hotelOrder.getOrderInfo().getRuleViolate() ? 1 : 0, foulReason);
// } else if (emptyFly) {//机票originalOrderNo
// NotifyData.OrderDetails flyOrder = common.getTravelBizOrderList().getFlightOrderList().get(0).getOrderDetails();
// OrderTravel orderTravel = new OrderTravel();
// orderTravel.setOrderNo(flyOrder.getOrderSerialNo());
// orderTravel.setTravelNo(flyOrder.getTravelOrderNo());
// saveOrderTravel(orderTravel);
// int ruleViolate = flyOrder.getRuleViolate() ? 1 : 0;
// //改签
// if (subNotifyType == 9) {
// changeFlight(ruleViolate, subNotifyType, flyOrder.getOrderSerialNo());
// }
// String foulReason = flyOrder.getFoulReason();//超标原因
// return lyCallBackDataHandler.flightCallBackData(flyOrder.getOrderSerialNo(), flyOrder.getRuleViolate() ? 1 : 0, foulReason, subNotifyType);
//
// } else if (emptyTrain) {//火车票
// NotifyData.TrainOrderList.OrderTrain orderTrain = common.getTravelBizOrderList().getTrainOrderList().get(0);
// OrderTravel orderTravel = new OrderTravel();
// orderTravel.setOrderNo(orderTrain.getOrderNo());
// orderTravel.setTravelNo(common.getTravelBizOrder().getTravelOrderNo());
// saveOrderTravel(orderTravel);
// int ruleViolate = orderTrain.getRuleViolate() ? 1 : 0;
// if (subNotifyType == 16) {
// changeTrain(ruleViolate, subNotifyType, orderTrain.getOrderNo());
// }
// String foulReason = orderTrain.getFoulReason();//超标原因
// return lyCallBackDataHandler.trainCallBackData(orderTrain.getOrderNo(), orderTrain.getRuleViolate() ? 1 : 0, foulReason, subNotifyType);
// } else if (emptyCar) {
// NotifyData.CarOrderList.Order orderCar = common.getTravelBizOrderList().getCarOrderList().get(0).getOrder();
// OrderTravel orderTravel = new OrderTravel();
// orderTravel.setOrderNo(orderCar.getOrderSerialNo());
// orderTravel.setTravelNo(common.getTravelBizOrder().getTravelOrderNo());
// saveOrderTravel(orderTravel);
// return lyCallBackDataHandler.carCallBackData(orderCar.getOrderSerialNo(), 0);
// } else {
// return new LYNoteResponse("100", "OK");
// }
// }
public void sendMsg(String travelApplyNo) {
StrokePushDTO strokePushDTO = new StrokePushDTO();
Param param = new Param();
@ -292,12 +247,6 @@ public class CommonController {
strokeController.strokePush(strokePushDTO);
}
public void saveOrderTravel(OrderTravel orderTravel) {
List<OrderTravel> byOrderNo = travelRepository.findByOrderNo(orderTravel.getOrderNo());
if (byOrderNo.isEmpty()) {
travelRepository.save(orderTravel);
}
}
/**
* 机票确认改签接口

View File

@ -120,7 +120,7 @@ public class LYETAController {
} catch (Exception e) {
//如果推送异常将异常信息保存到数据库
CompletableFuture.runAsync(() -> Command.of(SupplierCallBackErrorCommand.class)
.info(SUPPLIER_L_Y, gson.toJson(lyETAPush), e).sendToQueue());
.info(SUPPLIER_L_Y, null, gson.toJson(lyETAPush), e).sendToQueue());
e.printStackTrace();
}
return LYNoteResponse.success();

View File

@ -302,7 +302,7 @@ class RouteApplicationTests {
@Test
void loginSignProd() {
String sfno = "001001002";
String sfno = "180605039";
String syscode = "FSSC";
String billcode = "CLSQ240225000099";
String companycode = "正泰集团股份有限公司";