You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
4.1 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.api.ld.web;
import com.engine.ld.functions.sap.gjly.ZMM_TOOLRECIPIENTS_IMP_PortType;
import com.engine.ld.functions.sap.gjly.ZMM_TOOLRECIPIENTS_IMP_ServiceLocator;
import com.engine.ld.optimize.Gjly;
import com.engine.ld.utils.DealXml;
import com.weaver.general.BaseBean;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import java.net.URL;
import java.util.Map;
/**
* @author ZhangLei
* @date 2021/7/1
* 工具领用
*/
public class GjlyAction implements Action {
private static final BaseBean bb = new BaseBean();
@Override
public String execute(RequestInfo requestInfo) {
String billtable = requestInfo.getRequestManager().getBillTableName();
String requestid = requestInfo.getRequestid() ;
bb.writeLog("step2--------------");
RecordSet rs = new RecordSet();
try {
bb.writeLog("GjlyAction");
String saphost = bb.getPropValue("CGDD_WORKFLOW","SAPHOST");
bb.writeLog("ZMM_MATERIALDATA_MAINTAIN_Action-saphost:"+saphost);
String client = "" ;
String sql =" SELECT id,client FROM " + billtable + " WHERE REQUESTID=" + requestid;
rs.execute(sql);
if (rs.next()){
client = Util.null2String(rs.getString("client"));
}
bb.writeLog("ZMM_MATERIALDATA_MAINTAIN_Action-client:"+client);
if(StringUtils.isNotEmpty(client)) {
// http://lemprd.lemtech.cn:8000/sap/bc/srt/rfc/sap/zmm_toolrecipients_imp/300/zmm_toolrecipients_imp/zmm_toolrecipients_imp
String wsdl = saphost + "/sap/bc/srt/rfc/sap/zmm_toolrecipients_imp/" + client + "/zmm_toolrecipients_imp/zmm_toolrecipients_imp";
bb.writeLog("ZMM_MATERIALDATA_MAINTAIN_Action-wsdl:" + wsdl);
URL wsdlUrl = new URL(wsdl);
bb.writeLog("START-SAP");
ZMM_TOOLRECIPIENTS_IMP_PortType ZMM_TOOLRECIPIENTS_IMP_PortType = new ZMM_TOOLRECIPIENTS_IMP_ServiceLocator().getZMM_TOOLRECIPIENTS_IMP(wsdlUrl);
String dataXml = new Gjly().GjlyXml(requestid,billtable) ;
String SAPBackXml = ZMM_TOOLRECIPIENTS_IMP_PortType.ZMM_TOOLRECIPIENTS_IMP(dataXml);
bb.writeLog("SAP的返回结果是" + SAPBackXml);
Map<String, Object> sapBackMap = new DealXml().XmlResultMap(SAPBackXml);
bb.writeLog("step6---"+sapBackMap);
String type = sapBackMap.get("TYPE").toString();
String message = sapBackMap.get("MESSAGE").toString();
message = message.contains("'")?message.replace("'","''"):message;
bb.writeLog("解析后type:"+type+";message:"+message);
sql = "UPDATE "+billtable+" SET TYPE='"+type+"',MESSAGE='"+message+"' WHERE requestId="+requestid;
boolean isTrue = rs.executeUpdate(sql);
if(isTrue){
if(!"S".equals(type)){
requestInfo.getRequestManager().setMessageid("1000");
requestInfo.getRequestManager().setMessagecontent("SAP接口返回错误");
return Action.FAILURE_AND_CONTINUE;
}
}else{
requestInfo.getRequestManager().setMessageid("1000");
requestInfo.getRequestManager().setMessagecontent("更新接口返回数据异常");
return Action.FAILURE_AND_CONTINUE;
}
}else{
requestInfo.getRequestManager().setMessageid("1000");
requestInfo.getRequestManager().setMessagecontent("client获取值为空");
return Action.FAILURE_AND_CONTINUE;
}
} catch (Exception e) {
e.printStackTrace();
requestInfo.getRequestManager().setMessageid("1000");
requestInfo.getRequestManager().setMessagecontent("接口执行异常");
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
}