单据联查凭证可以找个如收款结算单的仿写一个。
而总账凭证联查单据则需要实现联查单据的类,重新写一个类。并把类注册进数据库。
最终效果:
public class QuerySellcarryBillService implements IBillReflectorService { public Collection<FipExtendAggVO> queryBillByRelations( Collection<FipRelationInfoVO> relationvos) throws BusinessException { List<String> pkList = new ArrayList<String>(); // 收入结转单主键 String pkfld = "pk_sellcarry_h"; Class cl = AggSellcarryHVO.class; boolean bl = true; String billtype = ""; for (FipRelationInfoVO vo : relationvos) { pkList.add(vo.getRelationID()); if (bl) { billtype = vo.getPk_billtype(); checkTemplet(billtype);// 检查模板 String transtype = this.querytranstype(billtype); // 单据类型 if ("HZ19".equals(billtype) || (transtype != null && "HZ19".equals(transtype))) { pkfld = "pk_sellcarry_h"; cl = AggSellcarryHVO.class; } bl = false; } } String[] pks = pkList.toArray(new String[0]); String sql = ""; sql = SqlUtils.getInStr(pkfld, pks, true); NCObject[] results = MDPersistenceService .lookupPersistenceQueryService().queryBillOfNCObjectByCond(cl, sql, false); List<FipExtendAggVO> fipAggVOList = new ArrayList<FipExtendAggVO>(); if (!ArrayUtils.isEmpty(results)) { for (NCObject aggvo : results) { AggSellcarryHVO aggVo2 = (AggSellcarryHVO) aggvo .getContainmentObject(); FipExtendAggVO fipAggVO = new FipExtendAggVO(); fipAggVO.setRelationID(aggVo2.getPrimaryKey()); fipAggVO.setBillVO(aggVo2); fipAggVOList.add(fipAggVO); } } return fipAggVOList; } private void checkTemplet(String billtype) throws BusinessException { try { IBillTemplateQry impl = (IBillTemplateQry) NCLocator.getInstance() .lookup(IBillTemplateQry.class); IUAPQueryBS bs = (IUAPQueryBS) NCLocator.getInstance().lookup( IUAPQueryBS.class); // 默认HZ19的查询模板主键。 String sql = "select templateid from pub_systemplate_base where templateid='0001ZZ100000005442CC'"; String id = (String) bs.executeQuery(sql, new ColumnProcessor()); BillTempletVO template = impl.findCardTempletData(id); if (template == null) { throw new BusinessException("交易类型:" + billtype + "没有分配模板,请在功能节点默认模板设置进行分配!"); } } catch (BusinessException e) { e.printStackTrace(); throw new BusinessException("查询模板出现异常:" + e.getMessage()); } } // 去查询交易类型与单据类型的关联关系, public String querytranstype(String billtype) throws BusinessException { String sql = "select parentbilltype from bd_billtype where pk_billtypecode='" + billtype + "'"; Object tr = new BaseDAO().executeQuery(sql, new ColumnProcessor()); if (tr != null) { if (!StringUtils.isEmpty(tr.toString()) && !"~".equals(tr.toString())) { return tr.toString(); } } return null; } }
注册进数据库
insert into fip_billregister (BILLDRAWCLASS, BILLREFLECTCLASS, BILLSUMCLASS, CLASS_ENTITY_ID, CTRLORGFINDCLASS, DEFDOC1, DEFDOC2, DEFDOC3, DEFQUERYCLASS, DESBILLSERVCLASS, DESBILLSUMCLASS, DESCTRLRULECLASS, DESSUMRULECLASS, DESSUMRULEENTITY, DESSUMRULEREF, DISPLAYCLASS, DR, DRAWQUERYCLASS, EDITCLASS, LINKQUERYCLASS, MODULECODE, ORG_CTRL_ENTITY1, ORG_CTRL_ENTITY2, ORG_ENTITY_ID, PK_BILLREGISTER, PK_BILLTYPE, PK_GROUP, PK_ORG, TS) values (null, 'nc.bs.hzctr.sellcarry.ace.bp.QuerySellcarryBillService', null, '~', null, null, null, null, null, null, null, null, null, null, null, null, 0, null, null, null, 'hzctr', '~', '~', '~', '0000Z30000000HPF0811', 'HZ19', '~', '~', '2017-08-11 10:03:11');