OA传SAP设置(备忘)

package com.seeyon.apps.ext.kk.flow.hc;

import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.xml.rpc.ServiceException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.seeyon.apps.ext.kk.flow.KKBaseFlow;
import com.seeyon.apps.ext.kk.sap.DT_ACCOUNT_PERIOD_REQZACCOUNT_PERIOD_REQ;
import com.seeyon.apps.ext.kk.sap.DT_ACCOUNT_PERIOD_RESZACCOUNT_PERIOD_RES;
import com.seeyon.apps.ext.kk.sap.SI_ACCOUNT_PERIOD_OUTBindingStub;
import com.seeyon.apps.ext.kk.sap.SI_ACCOUNT_PERIOD_OUTServiceLocator;
import com.seeyon.ctp.common.exceptions.BusinessException;
import com.seeyon.ctp.util.DateUtil;
import com.seeyon.ctp.workflow.event.AbstractWorkflowEvent;
import com.seeyon.ctp.workflow.event.WorkflowEventData;
import com.seeyon.ctp.workflow.event.WorkflowEventResult;

public class ZqxgSqWorkFlow extends KKBaseFlow {
    private static final Log LOG = LogFactory.getLog(ZqxgSqWorkFlow.class);

    @Override
    public String getId() {// 这个是唯一ID
        return "Zqxg001";
    }

    @Override
    public String getLabel() {// 这个是在开发高级里面显示的事件名称
        return "账期修改申请(处理前)";
    }

    // 节点操作事件:处理前事件
    public WorkflowEventResult onBeforeFinishWorkitem(WorkflowEventData data) {

        WorkflowEventResult error = new WorkflowEventResult();
        try {
            SI_ACCOUNT_PERIOD_OUTServiceLocator locator = new SI_ACCOUNT_PERIOD_OUTServiceLocator();//编译这个类可以跳转至对应SAP的IP地址
            SI_ACCOUNT_PERIOD_OUTBindingStub stub = (SI_ACCOUNT_PERIOD_OUTBindingStub) locator.getHTTP_Port();
            stub.setUsername(this.userName);
            stub.setPassword(this.passWord);

            Date t = new Date();// 传入日期
            SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");

            Date p = new Date();// 传入时间
            SimpleDateFormat time = new SimpleDateFormat("HHmmss");

            List burks = (List) data.getBusinessData().get("field0009");// 公司代码
            List kunnr = (List) data.getBusinessData().get("field0010"); // 客户名称
            List zterm = (List) data.getBusinessData().get("field0013"); // 原账期
            List oterm = (List) data.getBusinessData().get("field0015"); // 现付款账期

            Date crdat = (Date) data.getBusinessData().get("field0003"); // 申请日期
            List efdat = (List) data.getBusinessData().get("field0014"); // 实行的对账月份

            String zdate = sf.format(t);// 传入日期
            String ztime = time.format(p);// 传入时间

            String zoanum = (String) data.getBusinessData().get("field0001");// 流水号
            String usnam = (String) data.getBusinessData().get("field0002");// 发起人
            // 查找员工号
            String skrName = this.orgManager.getMemberById((Long.valueOf(usnam))).getCode();
            SimpleDateFormat simple = new SimpleDateFormat("yyyyMMdd");

            List vl = new ArrayList();

            for (int i = 0; i < burks.size(); i++) {
                DT_ACCOUNT_PERIOD_REQZACCOUNT_PERIOD_REQ req = new DT_ACCOUNT_PERIOD_REQZACCOUNT_PERIOD_REQ();
                req.setBURKS(burks.get(i).toString());
                req.setKUNNR(kunnr.get(i).toString());
                req.setZTERM(zterm.get(i).toString());
                req.setOTERM(oterm.get(i).toString());
                req.setCRDAT(DateUtil.format(crdat, "yyyyMMdd"));
                req.setEFDAT(DateUtil.format((Date) (efdat.get(i)), "yyyyMMdd"));
                req.setZDATE(zdate);// 传入日期
                req.setZTIME(ztime);// 传入时间
                req.setZOANUM(zoanum);
                req.setUSNAM(skrName.toString());
                vl.add(req);
            }
            DT_ACCOUNT_PERIOD_RESZACCOUNT_PERIOD_RES[] res = stub
                    .SI_ACCOUNT_PERIOD_OUT(vl.toArray(new DT_ACCOUNT_PERIOD_REQZACCOUNT_PERIOD_REQ[0]));
            for (DT_ACCOUNT_PERIOD_RESZACCOUNT_PERIOD_RES obj : res) {
                if ("E".equals(obj.getZRESULT())) {
                    error.setAlertMessage("Sap返回结果:" + obj.getZMESS() + ";");
                }
            }
        } catch (Exception e) {
            error.setAlertMessage("请联系管理员:" + e.getMessage());
            e.printStackTrace();
            LOG.info(e.getMessage());
        }
        return error;// NULL 流程可以正常走
    }
    // 节点操作事件:处理事件
}

private java.lang.String HTTPS_Port_address = "https://"+AppContext.getSystemProperty("ffl.sap.ip")+":50001/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_OA&receiverParty=&receiverService=&interface=SI_ACCOUNT_PERIOD_OUT&interfaceNamespace=http%3A%2F%2Fhuacan.com%2FOA%2FS4HAHA%2Faccount_period";

"ffl.sap.ip"引号里面的值可以直接使用接口的IP地址代替。

也可以直接在

OA传SAP设置(备忘)_第1张图片

 

 OA传SAP设置(备忘)_第2张图片

 

 

xml version="1.0" encoding="UTF-8"?>
<ctpConfig>
    <kk>
        <sapUsername mark="userconfig" desc="Sap登录名">HUACAN-OA]]>sapUsername>
        <sapPassword mark="{password} {VE}" desc="Sap密码">12345678]]>sapPassword>
        <sapSender mark="userconfig" desc="Sap发送人登陆名">test]]>sapSender>
        <sapIp mark="userconfig" desc="Sap地址的Ip">sapIp>
    kk>
ctpConfig>

另外一种

xml version="1.0" encoding="UTF-8"?>
<ctpConfig>
    <auth>
        <authip mark="{VE}" desc="设置IP">http://127.0.0.1authip>
    auth>
    <ffl>
        <sap>
            <userName mark="userconfig" desc="用户名">15361userName>
            <passWord mark="userconfig" desc="密码">jinqi1986passWord>
            <ip mark="userconfig" desc="ip">192.169.12.171ip>
        sap>
    ffl>
ctpConfig>

 

你可能感兴趣的:(OA传SAP设置(备忘))