。src/public:存放服务接口和实体类(VO),前台调用后台文件的接口。 src/private:后台实现类。 src/client:前台UI META-INF:配置文件
针对上面的卡法模式,我们规范一下代码的包结构: nc.itf.<模块名>: 表示该模块定义的接口(public) nc.impl.<模块名>:表示该模块定义的接口实现(private) nc.vo<模块名>: 表示VO的实现(public) nc.bs.<模块名>: 普通的后台应用(private) nc.ui.<模块名>.*: 客户端代码(client)
1.3 建立数据表
命名规则 表名:模块名_XXX 主键:pk_XXX( 必须是20位的字符)
建立PDM文件,表字段:
pk_group:所属集团 char(20)
pk_corp:公司 char(4) creator:创建人
char(20)
createtime:创建时间 char(19) modifier:修改人 char(20) modifytime:修改时间 char(19) dr:删除标识 int
默认值:default 0
ts:时间戳 char(19) 默认值:default to_char(sysdate,’yyyy-mm-dd
hh24:mi:ss’)
建立完成后将相应sql复制并生成到相应数据库中。
1.4 生成VO
启动中间件:项目右键-Debug AsNC Middleware 启动客户端:项目右键-Debug AsNC Client
步骤如下图所示:
2
1
导入数据字典:进入NC,客户化二次开发工具系统管理工具数据字
典管理选中对应模块(没有就新建一个)工具导入数据字典…
4 5 1 2 3
根据向导导入即可,导入完成后检查每个表的各个字段和类型是否正确或者
是否为空。
确认无误后则可以根据数据表生成VO了
生成VO文件:二次开发工具UAP集成开发工具 UAP集成开发工具工
具和选项根据数据源生成VO
1
2
生成目录:选择对应的项目VO目录 选择数据表:对应要生成VO的数据表
1.5 功能注册
注册菜单结点
二次开发工具系统管理工具功能注册 在对应的菜单结构下建立结点:步骤如下图所示
虚功能节点
可执行功能节点
可执行功能节点
对应文件名或控件名:nc.ui.uif2.ToftPanelAdaptor
参数
参数编码:BeanConfigFilePath 参数值:对应目录下的xml路径
生成xml之后在对应目录下找到xml的路径,然后再填写
1.6 配模板
单据模板
二次开发工具模板管理单据模板初始化
选中表拖动到左边
选中模板选项之后,在高级属性和显示属性这里可以进行一些相应的配置。
1.7 分配默认模板
菜单结点关联模板
二次开发工具系统管理工具功能结点默认模板
选择单据模板,查找到之前配置好的单据模板分配给对应菜单节点就可以
了。查询、打印模板同理。 具体步骤如下图:
3
2 选中功能节点
4 选中
1
5
1.7 接口(src/public)
src/public/student/port/IStudentManageService.java
import nc.vo.StudentVO; import nc.vo.pub.BusinessException; public interface IStudentManageService { /*--------增加-------*/ public StudentVO insertInfo(StudentVO VO) throws BusinessException ; /*--------修改-------*/ public StudentVO updateInfo(StudentVO VO) throws BusinessException ; /*--------删除-------*/ } public void deleteInfo(StudentVO VO) throws BusinessException ;
src/public/student/port/IStudentQueryService.java import nc.vo.StudentVO; import nc.vo.pub.BusinessException; public interface IStudentQueryService { /*--------sql查询-------*/ public StudentVO[] queryInfoByCondtion(String sqlWhere) throws BusinessException; /*--------pk查询-------*/ public StudentVO queryInfoByPK(String pk) throws BusinessException; } 1.8 实现接口(src/private)
StudentManageServiceImpl
实现接口IStudentManageService
import nc.bs.dao.BaseDAO; import nc.jdbc.framework.processor.ColumnProcessor; import nc.vo.StudentVO; import nc.vo.pub.BusinessException; import student.port.IStudentManageService; public class StudentManageServiceImpl implements IStudentManageService{ { String sql = \"select count(*) from bl_student where stucode = \" public StudentVO insertInfo(StudentVO vo) throws BusinessException + \"'\" + vo.getStucode() + \"'\"; int num = (Integer) new BaseDAO().executeQuery(sql, new ColumnProcessor(1)); if(num > 0){ } String pk = new BaseDAO().insertVO(vo); return (StudentVO) new BaseDAO().retrieveByPK(StudentVO.class, throw new BusinessException(\"学号重复!\"); pk); { String sql = \"select count(*) from bl_student where stucode = '\" public StudentVO updateInfo(StudentVO vo) throws BusinessException } + vo.getStucode() + \"' and pk_student <> '\"+vo.getPk_student()+\"'\"; int num = (Integer) new BaseDAO().executeQuery(sql, new ColumnProcessor(1)); if(num > 0){ } new BaseDAO().updateVO(vo); return (StudentVO) new BaseDAO().retrieveByPK(StudentVO.class, throw new BusinessException(\"学号重复!\"); vo.getPk_student()); public void deleteInfo(StudentVO vo) throws BusinessException { } new BaseDAO().deleteVO(vo); } }
StudentQueryServiceImpl 实现IStudentQueryService
import java.util.Collection; import nc.bs.dao.BaseDAO; import nc.vo.StudentVO; import nc.vo.jcom.lang.StringUtil; import nc.vo.pub.BusinessException; import student.port.IStudentQueryService; public class StudentQueryServiceImpl implements IStudentQueryService { { { } } return (StudentVO) new BaseDAO().retrieveByPK(StudentVO.class, pk); public StudentVO queryDataByPK(String pk) throws BusinessException } if (StringUtil.isEmpty(pk)) { } return queryDataByPK(pk); return null; public StudentVO queryInfoByPK(String pk) throws BusinessException public StudentVO[] queryInfoByCondtion(String sqlWhere) } } @SuppressWarnings(\"unchecked\") Collection list = new BaseDAO().retrieveByClause( StudentVO.class, sqlWhere); return list == null ? null : list.toArray(new throws BusinessException { sqlWhere = \"isnull(dr,0)=0\"; if (StringUtil.isEmpty(sqlWhere)) { StudentVO[list.size()]); 1.9 配置前台文件(src/client)BookTypeAppModelService
应用服务类,负责进行模型操作的处理,如:增、删、改
import nc.bs.framework.common.NCLocator; import nc.ui.uif2.model.IAppModelService; import nc.vo.StudentVO; import nc.vo.uif2.LoginContext; import student.port.IStudentManageService; public class StudentAppModelService implements IAppModelService { } public Object update(Object arg0) throws Exception { } return .updateInfo((StudentVO) arg0); public Object[] queryByDataVisibilitySetting(LoginContext arg0) } throws Exception { return null; public Object insert(Object arg0) throws Exception { } return .insertInfo((StudentVO) arg0); public void delete(Object arg0) throws Exception { } // 调用实现类的方法 NCLocator.getInstance().lookup(IStudentManageService.class) .deleteInfo((StudentVO) arg0); NCLocator.getInstance().lookup(IStudentManageService.class) NCLocator.getInstance().lookup(IStudentManageService.class) BookTypeModelDataManager
数据模型管理器,主要负责各种方式的模型初始化,单据初始化所用到的函数。
import nc.bs.framework.common.NCLocator; import nc.bs.logging.Logger; import nc.ui.uif2.model.BillManageModel; import nc.ui.uif2.model.IAppModelDataManager; import nc.vo.StudentVO; import student.port.IStudentQueryService; public class StudentModelDataManager implements IAppModelDataManager { } public void setModel(BillManageModel treeModel) { } this.model = treeModel; public BillManageModel getModel() { } return model; public void initModel() { } StudentVO[] datas = null; try { } getModel().initModel(datas); datas = .queryInfoByCondtion(null); private BillManageModel model; NCLocator.getInstance().lookup(IStudentQueryService.class) } catch (Exception ex) { Logger.error(\"\", ex); Student.xml
class=\"nc.ui.uif2.DefaultExceptionHanler\"> class=\"com.yonyou.ui.gxyy.common.model.GxyyBillManageModel\"> class=\"nc.ui.uif2.editor.value.BillCardPanelHeadVOValueAdapter\"> class=\"com.ui.student.StudentDeleteAction\"> class=\"nc.ui.uap.bd.bdactions.RefreshAction\"> init-method=\"initUI\"> class=\"nc.ui.uif2.components.TangramLayoutConstraint\"> 列表 卡片 center class=\"nc.ui.uif2.components.TangramLayoutConstraint\">
1.10配置META-INF
META-IN相当于一个信息包,目录中的文件和目录获得Java 2平台的认可与解释,用来配置应用程序、扩展程序、类加载器和服务 anifest.mf文件,在用jar打包时自动生成。
module.mxl
Student.upm
使用upm文件来描述后台业务类接口与实现之间的关系。 student.port.IStudentQueryService student.port.impl.StudentQueryServiceImpl student.port.IStudentManageService student.port.impl.StudentManageServiceImpl