多分录的单据在做套打时,一般都有好几个Query,可通过下面方法做相应设置:
注:parentid是新建Query中的字段名称,可做相应的修改。
- public void actionPrint_actionPerformed(ActionEvent e) throws Exception {
- // super.actionPrint_actionPerformed(e);
- if (editData.getId() != null) {
- String id = editData.getId().toString();
- DataProvider data = new DataProvider(id);
- KDNoteHelper appHlp = new KDNoteHelper();
- appHlp.print("bim/custom/classmanage/reportclass/Reportdaxiaoban",
- data, javax.swing.SwingUtilities.getWindowAncestor(this));
- } else {
- MsgBox.showWarning("请先保存单据,再点打印!");
- }
- public class DataProvider implements BOSQueryDelegate {
- private static final Logger logger = CoreUIObject
- .getLogger(AbstractFrozenDaxiaobanEditUI.class);
- private String billId;
- public DataProvider(String billId) {
- this.billId = billId;
- }
- public IRowSet execute(BOSQueryDataSource ds) {
- //
- IRowSet rs = null;
- //
- try {
- IQueryExecutor iqec = null;
- FilterInfo filterInfo = new FilterInfo();
- EntityViewInfo viewInfo = new EntityViewInfo();
- if (ds.getID().equals("BillQuery")) {
- iqec = QueryExecutorFactory.getRemoteInstance(new MetaDataPK(
- "com.kingdee.eas.custom.test.app",
- "BillQuery"));
- filterInfo.getFilterItems().add(
- new FilterItemInfo("id", this.billId,
- CompareType.EQUALS));
- viewInfo.setFilter(filterInfo);
- iqec.setObjectView(viewInfo);
- iqec.option().isAutoTranslateBoolean = true;
- iqec.option().isAutoTranslateEnum = true;
- //
- rs = iqec.executeQuery();
- }else if (ds.getID().equals("Entry2Query")) {
- iqec = QueryExecutorFactory.getRemoteInstance(new MetaDataPK(
- "com.kingdee.eas.custom.test.app",
- "Entry2Query"));
- filterInfo.getFilterItems().add(
- new FilterItemInfo("parentid", this.billId,
- CompareType.EQUALS));
- viewInfo.setFilter(filterInfo);
- iqec.setObjectView(viewInfo);
- iqec.option().isAutoTranslateBoolean = true;
- iqec.option().isAutoTranslateEnum = true;
- //
- rs = iqec.executeQuery();
- } else if (ds.getID().equals("EntryQuery")) {
- iqec = QueryExecutorFactory.getRemoteInstance(new MetaDataPK(
- "com.kingdee.eas.custom.test.app",
- "EntryQuery"));
- filterInfo.getFilterItems().add(
- new FilterItemInfo("parentid", this.billId,
- CompareType.EQUALS));
- viewInfo.setFilter(filterInfo);
- iqec.setObjectView(viewInfo);
- iqec.option().isAutoTranslateBoolean = true;
- iqec.option().isAutoTranslateEnum = true;
- //
- rs = iqec.executeQuery();
- } else {
- logger.info("==============其他执行,ds.getID()====" + ds.getID());
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- int rowcount = rs.size();
- logger.info("rs.size====" + rowcount);
- return rs;
- }
- }
注:parentid是新建Query中的字段名称,可做相应的修改。