feat(来料检验调用接口):新增
This commit is contained in:
parent
792fa24dc5
commit
98edf427fa
@ -0,0 +1,69 @@
|
||||
package com.foreverwin.iep.integration.handler.def.sap;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foreverwin.iep.integration.constant.Msg;
|
||||
import com.foreverwin.iep.integration.domain.InvokeRequest;
|
||||
import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.iep.integration.service.HandlerService;
|
||||
import com.foreverwin.iep.integration.utils.JS;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 来料检验调用接口
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service("SAP_INCOMING_INSPECTION")
|
||||
public class SapIncomingInspection implements HandlerService {
|
||||
|
||||
@Override
|
||||
public InvokeResponse call(InvokeRequest invokeRequest) {
|
||||
JSONObject messageContentjsonObject = JS.parseObject(invokeRequest.getMessageContent());
|
||||
String jsonInputString = messageContentjsonObject.get(Msg.MESSAGE_CONTENT).toString(); // JSON 格式的请求数据
|
||||
|
||||
try {
|
||||
// 统一调用 SAP 接口
|
||||
InvokeResponse invokeResponse = SapUtil.sendSap(jsonInputString);
|
||||
if(!"E".equals(invokeResponse.getResult())){
|
||||
// 请求处理成功
|
||||
JSONObject jsonObject = JS.parseObject(invokeResponse.getMessageContent());
|
||||
invokeResponse = new InvokeResponse();
|
||||
invokeResponse.setTransSid(invokeRequest.getTransSid());
|
||||
invokeResponse.setResult(Msg.S);
|
||||
invokeResponse.setMessageContent(Msg.SUCCESS);
|
||||
JSONObject responseContextJson = jsonObject.getJSONObject("RESPONSE_CONTEXT");
|
||||
if ("200".equals(responseContextJson.getString("RFC_CODE"))) {
|
||||
JSONObject responseBodyJson = jsonObject.getJSONObject("RESPONSE_BODY");
|
||||
if (ObjectUtil.isNotEmpty(responseBodyJson)) {
|
||||
JSONObject esReturnJson = responseBodyJson.getJSONObject("ES_RETURN");
|
||||
if (esReturnJson != null) {
|
||||
String msgty = esReturnJson.getString("MSGTY");
|
||||
if (Msg.E.equals(msgty)) {
|
||||
invokeResponse.setResult(Msg.E);
|
||||
}
|
||||
invokeResponse.setMessageContent(esReturnJson.getString("MSGTX"));
|
||||
} else {
|
||||
invokeResponse.setResult(Msg.E);
|
||||
invokeResponse.setMessageContent("ERP接口调用返回ES_RETURN无数据!");
|
||||
}
|
||||
} else {
|
||||
invokeResponse.setResult(Msg.E);
|
||||
invokeResponse.setMessageContent("ERP接口调用返回RESPONSE_BODY无数据!");
|
||||
}
|
||||
} else {
|
||||
invokeResponse.setResult(Msg.E);
|
||||
invokeResponse.setMessageContent(responseContextJson.getString("RFC_REASON"));
|
||||
}
|
||||
}
|
||||
return invokeResponse;
|
||||
} catch (Exception e) {
|
||||
return getDefaultInvoke().fail(invokeRequest.getTransSid(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String validation(InvokeRequest invokeRequest) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user