1. NC登录案例

1.1 登录界面设置

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

1.2 移动端登陆动作设置

此处设置的loginAction动作,调用系统服务UMService.login,注意需要勾选“数据收集”

对于其中的参数type类型需要设置为nc;具体设置如下所示:

1.3 Maserver端配置

需要在移动的maserver/conf/configure目录下建立需要访问的对应于NC系统中的待登录用户有访问权限的功能节点编号的编号,确保用户能够有权限登录;如此处设置的TR100101,建议创建移动项目以TR100101为名创建工程

  1. String serviceid = " ncLoginService";
  2. String appid = "TR100101";
  3. IGatewayService service = GatewayServiceFactory._findGatewayService_(appid, serviceid, map);
  4. Object retObj = service.doService();

当服务调用的方式采用以上的调用方式时,需要配置以下三个文件信息;

Services.xml中配置的是登录服务ncLoginService的相关调用的信息,具体配置如下所示:

services.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <gateway>
  3. <service id="ncLoginService" provider="nclocator" method="umLogin" returntype="uap.vo.umobile.UMResult">
  4. <properties>
  5. <params>
  6. context:uap.vo.umobile.UMContext
  7. </params>
  8. <interface>
  9. uap.itf.umoblie.IUapMoblieServ
  10. </interface>
  11. <security>
  12. false
  13. </security>
  14. </properties>
  15. <ds-set>
  16. <datasource name="mobile63" />
  17. </ds-set>
  18. </service>
  19. </gateway>

Provider.xml用于设置几种服务调用的方式,该文件不需要修改

provider.xml

  1. <provider-set>
  2. <provider id="nclocator" class="com.yonyou.uap.um.gateway.service.NCLocatorGatewayService" />
  3. <provider id="http" class="com.yonyou.uap.um.gateway.service.HTTPGatewayService" />
  4. <provider id="jdbc" class="com.yonyou.uap.um.gateway.service.JDBCGatewayService" />
  5. <provider id="u8http" class="com.yonyou.uap.um.gateway.service.U8HTTPGatewayService" />
  6. </provider-set>

对于service.xml中的datasource name需要设置为datasources.xml文件中的配置项,datasource.xml中的url表示要访问的服务的地址,这里指的是nc访问地址,ncds则是配置的nc中的访问数据源。

datasources.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <dsset>
  3. <datasource id="mobile63" isdefault="true">
  4. <url>http://127.0.0.1:80/</url>
  5. <ncds>design</ncds>
  6. </datasource>
  7. </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代码

其它入库新增界面:

  1. functioncom$yonyou$login$MainviewController$insertGeneralin(sender, args) {
  2. $ctx.dataCollect();
  3. varCmaterialvid = $ctx.getString("cmaterialvid");
  4. varCwarehouseid = $ctx.getString("cwarehouseid");
  5. varNassistnum = $ctx.getString("nassistnum");
  6. varCvendorid = $ctx.getString("cvendorid");
  7. vartestJson = [{
  8. "cmaterialvid" : Cmaterialvid,
  9. "cwarehouseid" : Cwarehouseid,
  10. "nassistnum" : Nassistnum,
  11. "cvendorid" : Cvendorid
  12. }];
  13. $service.callAction({
  14. "viewid" : "cm.nc.mobile.insertgeneralin", //后台带包名的Controller名
  15. "action" : "insertCommodity", //方法名,
  16. "insertdata" : testJson,//自定义参数
  17. });
  18. }

1.3.后台

接口定义

  1. package nc.itf.ic.cm;
  2. import java.util.List;
  3. import nc.vo.pub.BusinessException;
  4. public interface IGeneralInCm {
  5. public abstract List insertCommodity(String condition) throws BusinessException;
  6. }

其它入库新增,前后台参数传递

  1. package cm.nc.mobile;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5. import com.yonyou.uap.um.context.util.UmContextUtil;
  6. import com.yonyou.uap.um.gateway.exception.GatewayServiceException;
  7. import com.yonyou.uap.um.gateway.service.GatewayServiceFactory;
  8. import com.yonyou.uap.um.gateway.service.IGatewayService;
  9. import org.json.JSONArray;
  10. import org.json.JSONObject;
  11. import com.yonyou.um.webmvc.controller.UMController;
  12. public class insertgeneralin extends UMController {
  13. @SuppressWarnings({ "unchecked", "rawtypes" })
  14. public String insertCommodity(String args) throws Exception {
  15. String resultStr = "";
  16. JSONObject jsonObj = new JSONObject(args);
  17. Map map = UmContextUtil.transJsonToMap(jsonObj);
  18. // Map map=new HashMap();
  19. String indata = jsonObj.getString("insertdata");
  20. String serviceid = "insertCommodity";
  21. String appid = "40080608";
  22. IGatewayService service = GatewayServiceFactory.findGatewayService(appid, serviceid, map);
  23. Object retObj = service.doService();
  24. JSONObject value = new JSONObject();
  25. JSONArray array = new JSONArray(indata);
  26. for (int i = 0; i < array.length(); i++) {
  27. value = array.getJSONObject(i);
  28. }
  29. return value.toString();
  30. }
  31. }

2.MAhome配置

路径:D:mobileyonyouhomeconfconfigure40080608

services.xml配置

  1. <!-- 新增 -->
  2. <!--Provider:为服务提供者id信息;
  3. Method:为接口中使用的方法名;
  4. Returntype:为接口方法的返回值类型(包含包名的类的全名);
  5. Params:为方法参数名称和参数具体类型;
  6. Interface:为调用后台服务的接口名称;
  7. Security:为调用后台服务安全特征(true代表后台服务需要校验的token,false代 表后台服务不需要校验token) -->
  8. <?xml version="1.0" encoding="UTF-8"?>
  9. <gateway>
  10. <service id="ncLoginService" provider="nclocator" method="umLogin"
  11. returntype="uap.vo.umobile.UMResult">
  12. <properties>
  13. <params>context:uap.vo.umobile.UMContext</params>
  14. <interface>uap.itf.umoblie.IUapMoblieServ</interface>
  15. <security>false</security>
  16. </properties>
  17. <ds-set>
  18. <datasource name="mobile" />
  19. </ds-set>
  20. </service>
  21. <service id="insertCommodity" provider="nclocator" method="insertCommodity"
  22. returntype="java.util.List">
  23. <properties>
  24. <params>insertdata:string</params>
  25. <interface>nc.itf.ic.cm.IGeneralInCm</interface>
  26. <security>true</security>
  27. </properties>
  28. <ds-set>
  29. <datasource name="mobile" />
  30. </ds-set>
  31. </service>
  32. </gateway>

services 配置文件的安全配置节“false”要与upm 配置文件的“accessProtected=”false””一致。

datasources.xml配置

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <dsset>
  3. <datasource id="mobile" isdefault="true">
  4. <url>http://127.0.0.1:80/</url>
  5. <ncds>design</ncds>
  6. </datasource>
  7. </dsset>

127.0.0.1:80:nc的ip地址
design:nc数据源

provider.xml配置

  1. <provider-set>
  2. <provider id="nclocator"class="com.yonyou.uap.um.gateway.service.NCLocatorGatewayService" />
  3. <provider id="http" class="com.yonyou.uap.um.gateway.service.HTTPGatewayService" />
  4. <provider id="jdbc" class="com.yonyou.uap.um.gateway.service.JDBCGatewayService" />
  5. <provider id="u8http" class="com.yonyou.uap.um.gateway.service.U8HTTPGatewayService" />
  6. </provider-set>

3.其他入库NC流程

参考: 其它入库节点:40080608
Upm文件:

  1. <component priority="0" singleton="true" remote="true" tx="CMT" supportAlias="true">
  2. <interface>nc.itf.ic.m4a.IGeneralInMaintain</interface>
  3. <implementation>nc.impl.ic.m4a.GeneralInMaintainImpl</implementation>
  4. </component>

接口实现代码

  1. public class GeneralInMaintainImpl implements IGeneralInMaintain {
  2. }

接口

  1. public abstract GeneralInVO[] insert(GeneralInVO ageneralinvo[]) throws BusinessException;

NC端代码

登陆NC代码

新增其它入库单据代码

接口

  1. package nc.itf.ic.cm;
  2. import java.util.List;
  3. import nc.vo.pub.BusinessException;
  4. import uap.vo.umobile.UMContext;
  5. import uap.vo.umobile.UMResult;
  6. public interface IGeneralInCm {
  7. public abstract void insertCommodity(String condition) throws Exception;
  8. }

接口实现

  1. package nc.impl.cm;
  2. public class GeneralInCmImpl implements IGeneralInCm {
  3. public void insertCommodity(String condition) throws Exception {
  4. ---数据插入
  5. ----调用NC的新增接口
  6. }
  7. }
文档更新时间: 2018-01-16 10:11