EAS BOS套打设置

/**
	 * output actionPrintPreview_actionPerformed
	 */
	public void actionPrintPreview_actionPerformed(ActionEvent e)
			throws Exception {
		// super.actionPrintPreview_actionPerformed(e);
		if (this.editData.getId() == null) {
			SysUtil.abort();
		}
		ArrayList idList = new ArrayList();

		if (this.editData != null) {
			idList.add(this.editData.getId().toString());
		}

		if (idList == null || idList.size() == 0)
			return;

		// 定义ExampleProvider实例
		BOSQueryDelegate data = new ExampleProvider(idList);
		// 定义printer控件
		KDNoteHelper appHlp = new KDNoteHelper();

		// 指定打印模板example的相对路径、数据provider类、窗体句柄
		// 调用打印功能
		appHlp.printPreview("/bim/coscsc/Offer", data, SwingUtilities
				.getWindowAncestor(this));

	}

	class ExampleProvider implements BOSQueryDelegate {

		// 建议使用query
		private IMetaDataPK mpk = new MetaDataPK(
				"com.kingdee.eas.coscsc.app.OfferQuery");

		private Set ids = null;

		public ExampleProvider(List id) {
			this.ids = new HashSet(id);
		}

		// 实现接口BOSQueryDelegate的execute方法
		public IRowSet execute(BOSQueryDataSource ds) {
			IRowSet iRowSet = null;
			String filterId = "id";
			String sortField = "id";
			if(ds.getID().equalsIgnoreCase("OfferE5Query.bos-query")){
				mpk = new MetaDataPK(
				"com.kingdee.eas.coscsc.app.OfferE5Query");
				filterId = "parent.id";
				sortField = "SEQ";
			}else if(ds.getID().equalsIgnoreCase("OfferE3Query.bos-query")){
				mpk = new MetaDataPK(
				"com.kingdee.eas.coscsc.app.OfferE3Query");
				filterId = "parent.id";
			}else if(ds.getID().equalsIgnoreCase("OfferE4Query.bos-query")){
				mpk = new MetaDataPK(
				"com.kingdee.eas.coscsc.app.OfferE4Query");
				filterId = "parent.id";
			}else if(ds.getID().equalsIgnoreCase("OfferE6Query.bos-query")){
				mpk = new MetaDataPK(
				"com.kingdee.eas.coscsc.app.OfferE6Query");
				filterId = "parent.id";
			}
			try {
				// 动态查询执行器
				IQueryExecutor exec = QueryExecutorFactory
						.getRemoteInstance(mpk);

				// 自动转换查询中的枚举字段
				exec.option().isAutoTranslateEnum = true;
				
				// 构造过滤条件
				EntityViewInfo ev = new EntityViewInfo();
				FilterInfo filter = new FilterInfo();
				filter.getFilterItems().add(
						new FilterItemInfo(filterId, ids, CompareType.INCLUDE));
				ev.setFilter(filter);
				
				// 增加排序字段(可选)
				ev.getSorter().add(new SorterItemInfo(sortField));

				exec.setObjectView(ev);
				System.out.println(exec.getSQL());

				// 执行query,返回结果集
				// 可对结果集进行数据处理在返回
				iRowSet = exec.executeQuery();
				return iRowSet;
			} catch (Exception e1) {
				ExceptionHandler.handle((CoreUI) null, e1);
			}
			return null;

		}
	}



/**
         * ÖØÔØactionPrint_actionPerformed·½·¨
         * @param e  componentΪthis ,idΪeditData.getString("id"),pathΪÌ×´ò¿Í»§¶Ëquery·¾¶ ex£ºxx/xxquery
         * @throws Exception
         */
        public void actionPrint_actionPerformed(Component component,String id,String path) throws Exception {
                if (id==null||"".equals(id)) {
                        return;
                }
                DataProvider data = new DataProvider(id);
                KDNoteHelper appHlp = new KDNoteHelper();
                appHlp.print(path, data,
                                javax.swing.SwingUtilities.getWindowAncestor(component));
        }
        /**
         * ÖØÔØactionPrintPreview_actionPerformed·½·¨
         * @param e
         * @throws Exception
         */
        public void printPreview_actionPerformed(Component component,String id,String path)
                        throws Exception {
                if (id==null||"".equals(id)) {
                        return;
                }
                DataProvider data = new DataProvider(id);
                KDNoteHelper appHlp = new KDNoteHelper();
                appHlp.printPreview(path, data,
                                javax.swing.SwingUtilities.getWindowAncestor(component));
        }

        public class DataProvider implements BOSQueryDelegate {

                private String billId = null;

                public DataProvider() {
                        super();
                }

                public DataProvider(String billId) {
                        super();
                        this.billId = billId;
                }

                public IRowSet execute(BOSQueryDataSource ds) {
                        IRowSet rowSet = null;
                        try {
                                IQueryExecutor iqec = null;
                                FilterInfo filter = new FilterInfo();
                                EntityViewInfo viewInfo = new EntityViewInfo();
                                //query ·¾¶
                                String path = "com.kingdee.eas.custom.panasonic.bc.app";

                                DecimalFormat format = new DecimalFormat("#0.00");

                                String str = ds.getID();
                                //Ì×´ò¿Í»§¶ËqueryÃû³Æ
                                if ("ExpenseAccountBillForPrintQuery.bos-query".equals(str)) {
                                        iqec = QueryExecutorFactory.getRemoteInstance(new MetaDataPK(path,
                                                                        "ExpenseAccountBillForPrintQuery"));
                                        filter.getFilterItems().add(new FilterItemInfo("id", billId));
                                        viewInfo.setFilter(filter);
                                        iqec.setObjectView(viewInfo);
                                        iqec.option().isAutoTranslateBoolean = true;
                                        iqec.option().isAutoTranslateEnum = true;
                                        rowSet = iqec.executeQuery();
                                        String[] names = { "amount" };
                                        updateRowSetBigDecimal(rowSet, names, format);

                                } else if ("approveInfo.bos-query".equals(str)) {
                                        IBillPrintFacade billPrintFacade = BillPrintFacadeFactory.getRemoteInstance();
                                        rowSet = billPrintFacade.queryApproveInfo(billId);
                                }
                        } catch (Exception e) {
//                              handUIException(e);
                        }
                        return rowSet;
                }

                void updateRowSetBigDecimal(IRowSet rowSet, String[] names,
                                Format format) {
                        try {

                                while (rowSet.next()) {
                                        for (int i = 0; i < names.length; i++) {
                                                if (rowSet.getBigDecimal(names[i]) != null) {
                                                        rowSet.updateBigDecimal(names[i], new BigDecimal(
                                                                        format.format(rowSet
                                                                                        .getBigDecimal(names[i]))));
                                                }
                                        }
                                }
                                rowSet.beforeFirst();
                        } catch (SQLException e) {
//                              handUIException(e);
                        }
                }
        }


已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页