目录
应用场景
NC对外开放接口,供其他第三方系统调用。
需求举例:第三方系统通过Json格式参数关联采购合同生成采购订单。
实现过程
1、新建upm文件
首先我们需要确定接口所在模块,例如我本次开发的接口在供应链下的采购模块,找到nchome->modules->pu->META-INF,在此目录下新建upm文件。

upm文件代码:
<?xml version="1.0" encoding="gb2312"?>
<module name="pu">
<public>
<component accessProtected="false" name="Uploadm21ByService" remote="true" singleton="true"
tx="CMT">
<implementation>nc.pu.servlet.OrderByHTServlet</implementation>
</component>
</public>
</module>
component 组件说明
| 属性名称 | 属性作用 |
|---|---|
| name | 组件的名称,如果没配,默认为第一个接口的名称,如果没有接口,为实现类的名称 |
| singleton | 组件级别是否为单例,默认为true |
| remote | 组件是否未远程组件,默认为false,远程组件必须要有接口 |
| tx | 事务属性, NONE表示没有事务,CMT表示容器管理的事务,BMT表示Bean管理的事务 |
2、编写Servlet接口类
servlet接口需继承HttpServlet类,实现IHttpServletAdaptor。具体代码如下
package nc.pu.servlet;
import java.io.BufferedReader;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import nc.bs.framework.adaptor.IHttpServletAdaptor;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.bs.framework.security.token.ISecurityTokenCache;
import nc.bs.framework.server.ISecurityTokenCallback;
import nc.bs.pub.pf.PfUtilTools;
import nc.bs.trade.business.HYPubBO;
import nc.itf.pu.m21.IOrderMaintain;
import nc.itf.uap.pf.IPfExchangeService;
import nc.itf.uap.pf.IWorkflowMachine;
import nc.itf.uap.pf.IplatFormEntry;
import nc.uif.pub.exception.UifException;
import nc.vo.bd.material.MaterialVO;
// import nc.vo.bd.material.measdoc.MeasdocVO;
import nc.vo.bd.taxcode.TaxrateVO;
import nc.vo.ct.purdaily.entity.AggCtPuVO;
import nc.vo.ct.purdaily.entity.CtPuBVO;
import nc.vo.ct.purdaily.entity.CtPuVO;
import nc.vo.ep.bx.JKBXVO;
import nc.vo.logging.Debug;
import nc.vo.org.FinanceOrgVO;
import nc.vo.org.OrgVO;
import nc.vo.org.StockOrgVO;
import nc.vo.pu.m20.entity.PraybillVO;
import nc.vo.pu.m21.context.OrderContext;
import nc.vo.pu.m21.entity.OrderHeaderVO;
import nc.vo.pu.m21.entity.OrderItemVO;
import nc.vo.pu.m21.entity.OrderVO;
import nc.vo.pu.m21.rule.api.Calculate;
import nc.vo.pu.m21.rule.api.FillOrderVOInfoFor3rd;
import nc.vo.pu.pub.enumeration.PricePriority;
import nc.vo.pu.pub.util.PUSysParamUtil;
import nc.vo.pub.BusinessException;
import nc.vo.pub.VOStatus;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pub.workflownote.WorkflownoteVO;
import nc.vo.scmpub.res.billtype.POBillType;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jettison.json.JSONObject;
import org.joda.time.DateTime;
import nc.bs.logging.Logger;
import com.alibaba.fastjson.JSON;
// 采购订单JSON(关联采购合同)导入
@SuppressWarnings({ "restriction", "unused", "unchecked", "rawtypes" })
public class OrderByHTServlet extends HttpServlet implements
IHttpServletAdaptor {
private static final long serialV

最低0.47元/天 解锁文章
3207

被折叠的 条评论
为什么被折叠?



