|
@@ -1,5 +1,6 @@
|
|
|
package com.hr.externelSystem;
|
|
package com.hr.externelSystem;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.hr.dto.AggregateQueryDTO;
|
|
import com.hr.dto.AggregateQueryDTO;
|
|
|
import com.hr.dto.ApiLogDto;
|
|
import com.hr.dto.ApiLogDto;
|
|
@@ -60,21 +61,22 @@ public class BizHandlerFactory {
|
|
|
Class requestClass = handler.getRequestClass();
|
|
Class requestClass = handler.getRequestClass();
|
|
|
Object o = JSON.parseObject(decrypt, requestClass);
|
|
Object o = JSON.parseObject(decrypt, requestClass);
|
|
|
wrapOrder(req, dto, ipOrderPO, ipInterfacePO,ipLogPO);
|
|
wrapOrder(req, dto, ipOrderPO, ipInterfacePO,ipLogPO);
|
|
|
- ipOrderPO.setOrderStatus("handle");
|
|
|
|
|
|
|
+ ipOrderPO.setStatus("handle");
|
|
|
ipOrderRepository.save(ipOrderPO);
|
|
ipOrderRepository.save(ipOrderPO);
|
|
|
ipLogRepository.save(ipLogPO);
|
|
ipLogRepository.save(ipLogPO);
|
|
|
Object handle = handler.handle(o, ipInterfacePO,logDto);
|
|
Object handle = handler.handle(o, ipInterfacePO,logDto);
|
|
|
ipLogPO.setSystemResponse(JSON.toJSONString(handle));
|
|
ipLogPO.setSystemResponse(JSON.toJSONString(handle));
|
|
|
String errorMessage = logDto.getErrorMessage();
|
|
String errorMessage = logDto.getErrorMessage();
|
|
|
if(StringUtils.isEmpty(errorMessage)){
|
|
if(StringUtils.isEmpty(errorMessage)){
|
|
|
- ipOrderPO.setOrderStatus("success");
|
|
|
|
|
|
|
+ ipOrderPO.setStatus("success");
|
|
|
ipLogPO.setStatus("success");
|
|
ipLogPO.setStatus("success");
|
|
|
|
|
|
|
|
}else{
|
|
}else{
|
|
|
- ipOrderPO.setOrderStatus("fail");
|
|
|
|
|
|
|
+ ipOrderPO.setStatus("fail");
|
|
|
ipLogPO.setStatus("fail");
|
|
ipLogPO.setStatus("fail");
|
|
|
}
|
|
}
|
|
|
ipOrderPO.setUpdateTime(LocalDateTime.now());
|
|
ipOrderPO.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
+ ipOrderPO.setBusinessNo(ipOrderPO.getOrderNo());
|
|
|
ipLogPO.setUrl(logDto.getUrl());
|
|
ipLogPO.setUrl(logDto.getUrl());
|
|
|
ipLogPO.setRequestParam(logDto.getRequestParam());
|
|
ipLogPO.setRequestParam(logDto.getRequestParam());
|
|
|
ipLogPO.setUpdateTime(LocalDateTime.now());
|
|
ipLogPO.setUpdateTime(LocalDateTime.now());
|
|
@@ -111,4 +113,34 @@ public class BizHandlerFactory {
|
|
|
ipLogPO.setStatus("handle");
|
|
ipLogPO.setStatus("handle");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public Boolean doCallBack(String interfaceNo, String businessNo, JSONObject json) {
|
|
|
|
|
+ IpOrderPO ipOrderPO = ipOrderRepository.queryByBusinessNo(businessNo);
|
|
|
|
|
+ if(ipOrderPO != null){
|
|
|
|
|
+ log.error("找不到对应的业务编码");
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ String callbackStatus = ipOrderPO.getCallbackStatus();
|
|
|
|
|
+ if("success".equals(callbackStatus)){
|
|
|
|
|
+ log.info("当前业务回调已处理,已忽略");
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ Boolean isCallback = ipOrderPO.getIsCallback();
|
|
|
|
|
+ if(!isCallback){
|
|
|
|
|
+ log.info("当前业务未设置回调,已忽略");
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ BizHandler handler = getHandler(interfaceNo);
|
|
|
|
|
+ Boolean callbackResult = false;
|
|
|
|
|
+ ipOrderPO.setCallbackStatus("handle");
|
|
|
|
|
+ for (Integer i = 0; i < ipOrderPO.getCallbackNum(); i++) {
|
|
|
|
|
+ Boolean result = handler.doCallBack(ipOrderPO, json);
|
|
|
|
|
+ if(result){
|
|
|
|
|
+ callbackResult = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ipOrderPO.setCallbackStatus(callbackResult ? "success" : "fail");
|
|
|
|
|
+ ipOrderRepository.save(ipOrderPO);
|
|
|
|
|
+ return callbackResult;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|