1.查询
1.1 通过BaseDAO查询结果集并转换
//通过BaseDAO进行查询,并将查询结果转换为列表
SqlBuilder sql = new SqlBuilder();
sql.append(" select ");
sql.append(" account.code,accasoa.name,accasoa.name2,accasoa.name3,accasoa.name4,accasoa.name5,accasoa.name6,account.balanorient,accasoa.pk_accasoa,accasoa.endflag");
sql.append(" from BD_ACCASOA accasoa");
sql.append(" inner join BD_ACCOUNT account on accasoa.PK_ACCOUNT = account.PK_ACCOUNT ");
if(subjType != null && subjType.equals(1)){// 查询往来类科目
sql.append(" and account.TRAFFICSIGNS = 'Y' ");
}
sql.append(" inner join BD_ACCCHART accchart on accasoa.PK_ACCCHART = accchart.PK_ACCCHART ");
sql.append(" inner join BD_ACCTYPE acctype on account.PK_ACCTYPE = acctype.PK_ACCTYPE ");
if(subjType != null && subjType.equals(2)){ // 查询损益类科目
sql.append(" and acctype.TYPE = 1 ");
}
sql.append(" inner join ORG_ACCOUNTINGBOOK book on accchart.PK_ACCCHART = book.PK_CURRACCCHART and book.PK_ACCOUNTINGBOOK =?");
SQLParameter param = new SQLParameter();
param.addParam(pk_accountbook);
// BeanListProcessor 的参数VO不需要元数据,保证Sql查询出的列名与字段名一致即可(处理器可在同包下查看)
List<DiffAccasoaVO> result = (List<DiffAccasoaVO>)this.getBaseDAO().executeQuery(sql.toString(), param, new BeanListProcessor(DiffAccasoaVO.class));
return result;
1.2 通过VOQuery查询单表对象
//查询条件以and开头,(String)null参数是order的语句,可为空
SqlBuilder sql = new SqlBuilder();
sql.append(" and ");
sql.append(ICPubMetaNameConst.PK_ORG, pk_org);
sql.append(" and ");
sql.append(ICPubMetaNameConst.CMATERIALVID,cmaterialvids);
VOQuery<OnhandDimVO> query = new VOQuery<OnhandDimVO>(OnhandDimVO.class);
query.query(sql.toString(), (String)null);
1.3 通过EfficientBillQuery查询聚合对象
SqlBuilder headCond = new SqlBuilder();
headCond.append(" from drugic_priceadjust_h where ");
String pkGroup = (String) bgwc.getKeyMap().get("pk_group");
headCond.append("pk_group", pkGroup);
headCond.append(" and ");
String pkOrg = (String) bgwc.getKeyMap().get("pk_org");
headCond.append("pk_org", pkOrg);
headCond.append(" and ");
headCond.append("approvestatus", BillStatusEnum.APPROVED.valueIndex());
headCond.append(" and ");
headCond.append("dr", 0);
EfficientBillQuery<AggPriceAdjustHeadVO> query = new EfficientBillQuery<AggPriceAdjustHeadVO>(AggPriceAdjustHeadVO.class);
AggPriceAdjustHeadVO[] vos = (AggPriceAdjustHeadVO[]) query.query(headCond.toString());
1.4 通过IUAPQueryBS查询结果集
IUAPQueryBS iquery = (IUAPQueryBS)NCLocator.getInstance().lookup(IUAPQueryBS.class);
ArrayList list = null;
String sql =" select pk_dept from bd_psnjob where ismainjob ='Y' and pk_psndoc ='"+pk_psndoc+"' and dr = 0 ";
list = (ArrayList) iquery.executeQuery(sql, new ArrayListProcessor());
1.5 通过IOnhandQry查询现存量信息
OnhandQryCond onhandQryCond = new OnhandQryCond();//构造查询条件
if(cond.getByBatch()){//可以根据条件来选择要查询的现存量维度字段
onhandQryCond.addAllSelectFields();
}else{
onhandQryCond.addSelectFields(new String[]{"pk_group", "pk_org",
"cwarehouseid", "cmaterialvid", "cmaterialoid", "castunitid",
"clocationid", "vchangerate",
"cvmivenderid", "ctplcustomerid", "cstateid", "cvendorid",
"cprojectid", "casscustid", "cproductorid", "cffileid", "vfree1",
"vfree2", "vfree3", "vfree4", "vfree5", "vfree6", "vfree7",
"vfree8", "vfree9", "vfree10"});
}
onhandQryCond.setISSum(true);//设置现存量是否求和
StringBuilder sbSelFields = new StringBuilder();
sbSelFields.append(OnhandDimVO.ALIASNAME + ".").append(ICPubMetaNameConst.CWAREHOUSEID).append("='")
.append(cond.getInvWh()).append("' AND ");// 仓库
sbSelFields.append(OnhandDimVO.ALIASNAME + ".").append(ICPubMetaNameConst.PK_ORG).append("='")
.append(cond.getPk_org()).append("' ");// 库存组织
if (!cond.getZeroOnhand()) {//添加现存量是否需要大于0的查询条件
sbSelFields.append(" AND (").append(OnhandNumVO.TABLENAME).append(".nonhandnum <> 0 or ")
.append(OnhandNumVO.TABLENAME).append(".nonhandastnum <> 0 ) ");
}
onhandQryCond.setWhere(sbSelFields.toString());
onhandQryCond.setBinnerWhere(true);
try {
OnhandVO[] onhandVOs = NCLocator.getInstance().lookup(IOnhandQry.class).queryOnhand(onhandQryCond);
if (ValueCheckUtil.isNullORZeroLength(onhandVOs)) {
return null;
}
return onhandVOs;//返回查询到的现存量信息
} catch (BusinessException e) {
ExceptionUtils.wrappException(e);
}
1.6 客户端Client端查询(不建议使用)
SqlBuilder whereSql = new SqlBuilder();
whereSql.append(MaintensDrugVO.PK_STOCK,this.m_sWhID);
whereSql.append(" and ");
whereSql.append(MaintensDrugVO.PRODUCTNAME, CollectionUtils.setToArray(set));
MaintensDrugVO[] MaintensDrugVOs = (MaintensDrugVO[])HYPubBO_Client.queryByCondition(MaintensDrugVO.class,whereSql.toString());
2.更新
2.1 通过VOUpdate更新单表对象
//VO中的status必须设置为更新态 ,可以更新指定字段
VOUpdate<OnhandNumVO> updateOnhand = new VOUpdate<OnhandNumVO>();
onhandNum.setStatus(VOStatus.UPDATED);
updateOnhand.update(onhandNumVOs, new String[]{"nnum1"});
2.1 通过BillUpdate更新单据(聚合对象)
BillUpdate<AggPriceAdjustHeadVO> billUpd = new BillUpdate<>();
billUpd.update(new AggPriceAdjustHeadVO[]{aggVO},new AggPriceAdjustHeadVO[]{originBill});
2.1 通过IOnhandUpdate更新现存量
IOnhandUpdate update = NCLocator.getInstance().lookup(IOnhandUpdate.class);
update.modifyOnhandNum(onhandVOs);
3.界面操作
3.1 根据model获取当前选中的表头表体数据
AggPriceAdjustHeadVO aggVO = (AggPriceAdjustHeadVO)this.model.getSelectedData();
PriceAdjustHeadVO parentVO = aggVO.getParentVO();
CircularlyAccessibleValueObject[] childVOs = aggVO.getChildrenVO();
3.2 根据model获取当前选中数据的审批状态
if(null != getModel().getSelectedData()){
NCObject obj = NCObject.newInstance(getModel().getSelectedData());
if (obj != null) {
Integer status = nc.bs.pubapp.pf.util.ApproveFlowUtil.getBillStatus(obj);
}
}
3.3 根据条件控制按钮是否可操作性
//按钮的Action中,继承NCAction并重写isActionEnable方法是控制按钮是否可操作的方法,默认返回true(可以操作)
@Override
protected boolean isActionEnable() {return true}
//----------------------------------------------------------------------
//点击新增,自动增行(在新增事件--addhandler实现implements IAppEventHandler<AddEvent>)
public void handleAppEvent(AddEvent e) {
BillCardPanel panel = e.getBillForm().getBillCardPanel();
Action action = panel.getBodyPanel().getBillTableAction(0);
if (action instanceof AbstractBodyTableExtendAction) {
AbstractBodyTableExtendAction addAction = (AbstractBodyTableExtendAction)action;
ActionEvent ae = null;
ae = new ActionEvent(panel.getBodyPanel().getTable(), 1234, "AutoLine");
addAction.actionPerformed(ae);
}
}
3.4 根据BillCardPanel动态设置表头表体字段是否为必输项(固定则在单据模板中配置)
getBillCardPanel().getHeadItem(DrugBDInfoVO.PRICE_SALE).setNull(true);
getBillCardPanel().getBodyItem("code").setNull(true);
3.5 根据BillCardPanel获取当前页签及其billModel
String tableCode = getBillCardPanel().getCurrentBodyTableCode();
BillModel billModel = getBillCardPanel().getBillModel(tableCode);
3.6 根据BillCardPanel获取界面的聚合对象,返回AggregatedValueObject
需要传入三个VO的名字,返回值类型可强制转换
AggregatedValueObject bill = e.getBillCardPanel().getBillValueVO(aggClassName, headClassName, bodyClassName);
3.7 根据BillListPanel或者BillCardPanel处理界面精度
//列表界面(在界面InitUI中加入)
ListPaneScaleProcessor scaleProcessor = new ListPaneScaleProcessor(AppContext.getInstance().getPkGroup(),this.getBillListPanel());
String[] pricekeys = new String[]{"localdebitamount","localcreditamount","debitamount","creditamount"};
PosEnum pos = PosEnum.head;
scaleProcessor.setPriceCtlInfo(pricekeys, pos, (String)null, "pk_currtype", pos, (String)null);
scaleProcessor.process();
//卡片界面(在界面InitUI中加入)
CardPaneScaleProcessor scaleProcessor = new CardPaneScaleProcessor(AppContext.getInstance().getPkGroup(),this.getBillCardPanel());
String[] pricekeys = new String[]{"amount"};
PosEnum pos = PosEnum.body;
scaleProcessor.setPriceCtlInfo(pricekeys, pos, (String)null, "currtype", pos, (String)null);
scaleProcessor.process();
3.8 根据BillCardPanel设置表体数据及加载参照显示信息(不加载则显示主键)
DiffAdjustVO headVO = ((AggDiffAdjustVO)agg).getParentVO();
DiffAdjustBodyVO bodyVO = new DiffAdjustBodyVO();
bodyVO.setPk_org(headVO.getPk_org());
bodyVO.setPk_accountbook(headVO.getPk_accountingbook());
bodyVO.setPk_voucher(headVO.getPk_voucher());
bodyVO.setPk_detail(headVO.getPk_detail());
bodyVO.setPk_accasoa(headVO.getPk_accasoa());
int row = getCardPanel().getBillModel().getRowCount()-1;
this.getCardPanel().getBillModel().setBodyRowVO(bodyVO, row);
this.getCardPanel().getBillModel().loadLoadRelationItemValue();
3.9 禁止列表表头排序
//重写列表界面的初始化方法,移除监听
nc.ui.pubapp.uif2app.view.ShowUpableBillListView
public void initUI() {
super.initUI();
getBillListPanel().getHeadTable().removeSortListener();
}
3.10 根据BillCardPanel控制某个单元格是否可编辑
getBillCardPanel().getBillModel().setCellEditable(int row,String key,Boolean editable);
3.11 获取当前屏幕尺寸
Dimension screen=Toolkit.getDefaultToolkit.getScreenSize();
4.窗口提示
4.1 界面弹窗(成功、失败、警告等)
//弹框提示,可以选择多种,根据自己的需求选择(提示界面标志flag:{是:4,否:8,取消:2})
nc.ui.pub.beans.MessageDialog.showWarningDlg(null, "选择提示", "请选择单据后再点击执行");
4.2 界面底部提示信息
//在界面底部提示信息
ShowStatusBarMsgUtil.showStatusBarMsg("执行成功!", getModel().getContext());
//在界面底部弹出异常信息,中断当前操作(会出现失效情况,可配合上面提示信息使用,终止操作)
nc.vo.pubapp.pattern.exception.ExceptionUtils.wrappBusinessException("表体数据为空时,不能保存。");
4.3 自定义档案编码和名称的唯一性校验
//可以在[基础数据管控模式]节点,配置规则,如果无法新增规则,可在数据库中插入数据
select * from bd_uniquerule ;
select * from bd_uniquerule_item;
可以在[基础数据管控模式]节点中新增一条规则点击保存后,然后在此方法中进行断点调试,获取需要插入的VO信息
nc.impl.bd.config.uniquerule.BDUniqueruleManageServiceImpl.insert(BDUniqueruleVO)
5.单据模板公式
5.1 单据模板根据公式获取值
//公式可以直接获取返回值并赋值给下一条语句
pk_onhandim->getcolvalue(IC_ONHANDDIM ,PK_ONHANDDIM ,CMATERIALVID ,code_pd.pk_source );
num1->getcolvalue(IC_ONHANDNUM ,NNUM1 ,PK_ONHANDDIM ,pk_onhandim );//(表名,查询字段,条件字段,条件值)
price->getcolvalue(drugic_priceadjust_b ,price_before ,pk_priceadjust_b ,pk_priceadjust_b );
iif(price>0 ,price ,num1 );
6.参照
6.1 根据BillCardPanel获取界面参照类型字段并设置是否可多选
BillItem item = e.getBillCardPanel().getBodyItem(e.getKey());
if (item == null)
return;
JComponent componen = item.getComponent();
if (componen instanceof UIRefPane){
UIRefPane refPane = (UIRefPane) componen;
refPane.setMultiSelectedEnabled(true);
}
6.2 获取参照的值
UIRefPane measdocRef = (UIRefPane) getBillCardPanel().getHeadItem(MaterialVO.PK_MEASDOC).getComponent();
measdocRef.getRefPK(); //主键
measdocRef.getRefName(); //名称
measdocRef.getRefCode(); //编码
6.3 设置参照过滤条件
//可以添加在编辑前事件中
UIRefPane refPane=(UIRefPane)billForm.getBillCardPanel().getHeadItem("def2").getComponent();
AbstractRefModel refModel=(AbstractRefModel) refPane.getRefModel();
String wherePart=" and def5='1001H2100000004MJ7SV' ";//Sql以and开头
refModel.addWherePart(wherePart, false);//第二个参数为是否刷新该数据
refPane.setMultiCorpRef(false);//设置不能跨组织
6.4 参照选择后显示主键或编码,不显示名称
- 进入单据模板初始化节点,选择对应节点的模板并点击修改
- 进入节点模板,点击要显示名称的参照字段,在左侧界面选择高级属性
- 选中‘类型设置’行,双击值的位置会有一个参照按钮,点击参照会弹出一个界面
- 在界面中勾选‘焦点离开后显示名称’
7.其他
7.1 查找多语信息
在NCHOME中找到langlib文件夹,内部有多语jar;
根据所属模块,在功能注册节点中找到对应的编码(如库存管理为ic);
根据模块编码找到对应的多语jar;
根据代码中的resdir信息,找到jar中对应的文件夹;