1. NC登录案例
1.1 登录界面设置
对于登录界面,在新建的时候只需要采用向导中的模板创建就可以了,如下图所示

1.2 移动端登陆动作设置
此处设置的loginAction动作,调用系统服务UMService.login,注意需要勾选“数据收集”
对于其中的参数type类型需要设置为nc;具体设置如下所示:
1.3 Maserver端配置
需要在移动的maserver/conf/configure目录下建立需要访问的对应于NC系统中的待登录用户有访问权限的功能节点编号的编号,确保用户能够有权限登录;如此处设置的TR100101,建议创建移动项目以TR100101为名创建工程
String serviceid = " ncLoginService";String appid = "TR100101";IGatewayService service = GatewayServiceFactory._findGatewayService_(appid, serviceid, map);Object retObj = service.doService();
当服务调用的方式采用以上的调用方式时,需要配置以下三个文件信息;
Services.xml中配置的是登录服务ncLoginService的相关调用的信息,具体配置如下所示:
services.xml
<?xml version="1.0" encoding="UTF-8"?><gateway><service id="ncLoginService" provider="nclocator" method="umLogin" returntype="uap.vo.umobile.UMResult"><properties><params>context:uap.vo.umobile.UMContext</params><interface>uap.itf.umoblie.IUapMoblieServ</interface><security>false</security></properties><ds-set><datasource name="mobile63" /></ds-set></service></gateway>
Provider.xml用于设置几种服务调用的方式,该文件不需要修改
provider.xml
<provider-set><provider id="nclocator" class="com.yonyou.uap.um.gateway.service.NCLocatorGatewayService" /><provider id="http" class="com.yonyou.uap.um.gateway.service.HTTPGatewayService" /><provider id="jdbc" class="com.yonyou.uap.um.gateway.service.JDBCGatewayService" /><provider id="u8http" class="com.yonyou.uap.um.gateway.service.U8HTTPGatewayService" /></provider-set>
对于service.xml中的datasource name需要设置为datasources.xml文件中的配置项,datasource.xml中的url表示要访问的服务的地址,这里指的是nc访问地址,ncds则是配置的nc中的访问数据源。
datasources.xml
<?xml version="1.0" encoding="UTF-8"?><dsset><datasource id="mobile63" isdefault="true"><url>http://127.0.0.1:80/</url><ncds>design</ncds></datasource></dsset>
1.4 UAP/NC Home端配置
需要在home下的modules中的uap中打上补丁,将modules直接覆盖home下的uap中modules即可,然后重启一下UAP
补丁目的:移动端和UAP63的登陆接口。

uap.itf.umoblie.IUapMoblieServ 接口在UAP/NC中的实现类Uap.impl.umobile.UapMobileServImpl,其中会结合appid与userid判断用户是否有权限访问该功能;
NC其它入库数据

环境配置
NC,iuap mobile,MA Server
1.Mobile端
1.1.界面设计
NC登录
首先,UMService.writeConfigure的IP地址设置。

其它入库新增

1.2.JS代码
其它入库新增界面:
functioncom$yonyou$login$MainviewController$insertGeneralin(sender, args) {$ctx.dataCollect();varCmaterialvid = $ctx.getString("cmaterialvid");varCwarehouseid = $ctx.getString("cwarehouseid");varNassistnum = $ctx.getString("nassistnum");varCvendorid = $ctx.getString("cvendorid");vartestJson = [{"cmaterialvid" : Cmaterialvid,"cwarehouseid" : Cwarehouseid,"nassistnum" : Nassistnum,"cvendorid" : Cvendorid}];$service.callAction({"viewid" : "cm.nc.mobile.insertgeneralin", //后台带包名的Controller名"action" : "insertCommodity", //方法名,"insertdata" : testJson,//自定义参数});}
1.3.后台
接口定义

package nc.itf.ic.cm;import java.util.List;import nc.vo.pub.BusinessException;public interface IGeneralInCm {public abstract List insertCommodity(String condition) throws BusinessException;}
其它入库新增,前后台参数传递
package cm.nc.mobile;import java.util.HashMap;import java.util.List;import java.util.Map;import com.yonyou.uap.um.context.util.UmContextUtil;import com.yonyou.uap.um.gateway.exception.GatewayServiceException;import com.yonyou.uap.um.gateway.service.GatewayServiceFactory;import com.yonyou.uap.um.gateway.service.IGatewayService;import org.json.JSONArray;import org.json.JSONObject;import com.yonyou.um.webmvc.controller.UMController;public class insertgeneralin extends UMController {@SuppressWarnings({ "unchecked", "rawtypes" })public String insertCommodity(String args) throws Exception {String resultStr = "";JSONObject jsonObj = new JSONObject(args);Map map = UmContextUtil.transJsonToMap(jsonObj);// Map map=new HashMap();String indata = jsonObj.getString("insertdata");String serviceid = "insertCommodity";String appid = "40080608";IGatewayService service = GatewayServiceFactory.findGatewayService(appid, serviceid, map);Object retObj = service.doService();JSONObject value = new JSONObject();JSONArray array = new JSONArray(indata);for (int i = 0; i < array.length(); i++) {value = array.getJSONObject(i);}return value.toString();}}
2.MAhome配置
路径:D:mobileyonyouhomeconfconfigure40080608

services.xml配置
<!-- 新增 --><!--Provider:为服务提供者id信息;Method:为接口中使用的方法名;Returntype:为接口方法的返回值类型(包含包名的类的全名);Params:为方法参数名称和参数具体类型;Interface:为调用后台服务的接口名称;Security:为调用后台服务安全特征(true代表后台服务需要校验的token,false代 表后台服务不需要校验token) --><?xml version="1.0" encoding="UTF-8"?><gateway><service id="ncLoginService" provider="nclocator" method="umLogin"returntype="uap.vo.umobile.UMResult"><properties><params>context:uap.vo.umobile.UMContext</params><interface>uap.itf.umoblie.IUapMoblieServ</interface><security>false</security></properties><ds-set><datasource name="mobile" /></ds-set></service><service id="insertCommodity" provider="nclocator" method="insertCommodity"returntype="java.util.List"><properties><params>insertdata:string</params><interface>nc.itf.ic.cm.IGeneralInCm</interface><security>true</security></properties><ds-set><datasource name="mobile" /></ds-set></service></gateway>
services 配置文件的安全配置节“
datasources.xml配置
<?xml version="1.0" encoding="UTF-8"?><dsset><datasource id="mobile" isdefault="true"><url>http://127.0.0.1:80/</url><ncds>design</ncds></datasource></dsset>
127.0.0.1:80:nc的ip地址
design:nc数据源
provider.xml配置
<provider-set><provider id="nclocator"class="com.yonyou.uap.um.gateway.service.NCLocatorGatewayService" /><provider id="http" class="com.yonyou.uap.um.gateway.service.HTTPGatewayService" /><provider id="jdbc" class="com.yonyou.uap.um.gateway.service.JDBCGatewayService" /><provider id="u8http" class="com.yonyou.uap.um.gateway.service.U8HTTPGatewayService" /></provider-set>
3.其他入库NC流程
参考:
其它入库节点:40080608
Upm文件:
<component priority="0" singleton="true" remote="true" tx="CMT" supportAlias="true"><interface>nc.itf.ic.m4a.IGeneralInMaintain</interface><implementation>nc.impl.ic.m4a.GeneralInMaintainImpl</implementation></component>
接口实现代码:
public class GeneralInMaintainImpl implements IGeneralInMaintain {}
接口:
public abstract GeneralInVO[] insert(GeneralInVO ageneralinvo[]) throws BusinessException;
NC端代码
登陆NC代码

新增其它入库单据代码

接口
package nc.itf.ic.cm;import java.util.List;import nc.vo.pub.BusinessException;import uap.vo.umobile.UMContext;import uap.vo.umobile.UMResult;public interface IGeneralInCm {public abstract void insertCommodity(String condition) throws Exception;}
接口实现
package nc.impl.cm;public class GeneralInCmImpl implements IGeneralInCm {public void insertCommodity(String condition) throws Exception {---数据插入----调用NC的新增接口}}