用友nc65 uap开发参照节点数据拉单之二----直接通过调用查询模版查询上游单据

用友nc65 uap开发参照节点数据拉单之二----直接通过调用查询模版查询上游单据
前面一篇博客讲了利用查询模版并显示在弹窗面板上的拉单方法。此次是直接通过调用查询模版查询上游所有单据。如图所示:
按钮调用查询面板
在这里插入图片描述
将符合条件的所有数据直接显示在编辑状态的面板上:
在这里插入图片描述
代码如下:
xml代码:

<bean id="refAction" class="nc.ui.fdc_pr.h303201570.ace.action.ReferAction">
		<property name="model">
			<ref bean="bmModel" />
		</property>
		<property name="editor" ref="billForm" />
		<!--当前单据类型编码 -->
		<property name="currBilltype" value="H338" />
		<!-- 来源单据类型编码 -->
		<property name="sourceBillType" value="H345" />
		<!-- 来源单据类型名称 -->
		<property name="sourceBillName" value="参照收费清单" />
 
		<property name="exceptionHandler">
			<ref bean="exceptionHandler" />
		</property>
		<property name="defaultUIF2RefEditor">
			<ref bean="defaultUIF2RefEditor" />
		</property>
	</bean>
 
	<!-- 导入编辑器 -->
	<bean id="defaultUIF2RefEditor" class="nc.itf.fdc.pub.DefaultUIF2RefEditor">
		<property name="addAction" ref="addAction" />
		<property name="billcardPanelEditor" ref="billForm" />
		<property name="appModel" ref="bmModel" />
	</bean>

按钮代码类:

package nc.ui.fdc_pr.h303201570.ace.action;
 
import java.awt.Container;
import java.awt.event.ActionEvent;
 
import nc.bs.framework.common.NCLocator;
import nc.bs.pf.pub.BillTypeCacheKey;
import nc.itf.fdc.pub.DefaultUIF2RefEditor;
import nc.itf.fdc_pr.IH303201525Maintain;
import nc.md.data.access.NCObject;
import nc.ui.ml.NCLangRes;
import nc.ui.pf.pub.PfUIDataCache;
import nc.ui.pr.H30301.LogonBO_Client;
import nc.ui.pub.beans.UIDialog;
import nc.ui.pub.bill.BillStatus;
import nc.ui.pubapp.uif2app.actions.AbstractReferenceAction;
import nc.ui.pubapp.uif2app.model.BillManageModel;
import nc.ui.querytemplate.IBillReferQuery;
import nc.ui.querytemplate.QueryConditionDLG;
import nc.ui.uif2.UIState;
import nc.ui.uif2.editor.IBillCardPanelEditor;
import nc.vo.fdc_pr.h303201525.Bill;
import nc.vo.fdc_pr.h303201570.AggDjzb;
import nc.vo.fdc_pr.h303201570.Djfb;
import nc.vo.fdc_pr.h303201570.Djzb;
import nc.vo.pub.BusinessException;
import nc.vo.pub.VOStatus;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pub.pf.BillStatusEnum;
import nc.vo.pubapp.AppContext;
import nc.vo.querytemplate.TemplateInfo;
import nc.vo.uap.pf.PFBusinessException;
import nc.vo.uif2.LoginContext;
 
import org.apache.commons.lang.StringUtils;
 
public class ReferAction extends AbstractReferenceAction {
 
	private static final long serialVersionUID = -7167526730230052116L;
 
	// 卡片面板
	private IBillCardPanelEditor editor;
 
	// model
	private BillManageModel model;
 
	private String currBilltype;
 
	private IBillReferQuery dlg;
	
	private DefaultUIF2RefEditor defaultUIF2RefEditor = null;
 
 
	public ReferAction() {
		super();
	}
 
	@Override
	public void doAction(ActionEvent e) throws Exception {
 
		LoginContext context = this.getModel().getContext();
		String funNode = PfUIDataCache.getBillType(
				new BillTypeCacheKey().buildBilltype(getSourceBillType())
						.buildPkGroup(context.getPk_group())).getNodecode();
		if (funNode == null || funNode.equals(""))
			throw new PFBusinessException(NCLangRes.getInstance().getStrByID(
					"pfworkflow1", "PfUtilClient-000001", null,
					new String[] { getSourceBillType() })/* 请注册单据{0}的功能节点号 */);
 
		// 1.构造查询对话框
 
		if (dlg == null) {
			dlg = setConditionClient(null, context.getEntranceUI(),
					context.getPk_loginUser(), funNode, context.getPk_group());
		}
 
		if (dlg.showModal() != UIDialog.ID_OK) {
			return;
		}
 
		//not exists ( select 1 from fdc_pr_FareType ft where nvl(ft.dr,0)=0 and nvl(ft.reserve1,'N')='Y' and ft.pk_head = fdc_pr_Bill.pk_faretypeid )
		StringBuffer strWhere = new StringBuffer();
		if(dlg.getWhereSQL()==null||dlg.getWhereSQL().trim().length()==0){
			strWhere.append(" 1=1 ");
		}else{
			strWhere.append(dlg.getWhereSQL());
		}
		
		strWhere.append( " and isnull(fdc_pr_Bill.dr,0)=0 and isnull(fdc_pr_Bill.bisarap,'N')='N' ");
		strWhere.append( " and not exists ( select 1 from fdc_pr_FareType ft where isnull(ft.dr,0)=0 and isnull(ft.reserve1,'N')='Y' and ft.pk_head = fdc_pr_Bill.pk_faretypeid )  ");
		strWhere.append( " and isnull(fdc_pr_Bill.bclose,'N')='N'" );//关闭的数据不参照过来
		// 2.根据查询条件得到收费清单:
 
		// 2. 1 根据单据类型,利用元数据查询 :前提要求上游元数据,实现了IHeadBodyQueryItf接口
		// IPFConfig pfConfig = (IPFConfig)
		// NCLocator.getInstance().lookup(IPFConfig.class.getName());
		// CircularlyAccessibleValueObject[] tmpHeadVo =
		// pfConfig.queryHeadAllData(getSourceBillType(), tmpWhere);
 
		// 2. 2 调用上游查询接口
 
		IH303201525Maintain maint = NCLocator.getInstance().lookup(
				IH303201525Maintain.class);
		//查询模板查询条件查询收费清单*(已经收完款的不用查出来)
		NCObject[] bills = maint.querybillbywhere(strWhere.toString());
//		Bill[] bills = maint.query(strWhere);
 
		if (bills == null || bills.length == 0) {
			 throw new BusinessException("未查询到收费清单数据.");
		}
		// 3. 转换数据:可以代码 硬编码转换,也可以调用单据转换规则。
 
		AggDjzb bill = chg(bills);//生成单据
		
		
		// 4. 设置编辑状态数据
		getDefaultUIF2RefEditor().addNew();
		getDefaultUIF2RefEditor().setValue(bill);
	}
	
	
	/**
	 * 生成“财务应收单”
	 * */
	private AggDjzb chg(NCObject[] bills) {
		
		AggDjzb bill = new AggDjzb();
 
		Djzb zb = chgHead(bills);
 
		bill.setParentVO(zb);
 
		bill.setChildrenVO(chgBodys(bills));
 
		return bill;
	}
	
	/**
	 * 设置表头数据
	 * */
	public Djzb chgHead(NCObject[] bills) {
		Djzb head = new Djzb();
		head.setPk_group(AppContext.getInstance().getPkGroup());//集团
		head.setDbilldate(AppContext.getInstance().getBusiDate());//单据日期
		head.setAttributeValue("approvestatus", BillStatusEnum.FREE.value());//单据状态
		String pk_org = getModel().getContext().getPk_org();
		if (StringUtils.isBlank(pk_org)) {
			if (bills != null && bills.length > 0) {
				pk_org = (String) bills[0].getAttributeValue("pk_org");
			}
	    		getModel().getContext().setPk_org(pk_org);
		}
		head.setPk_org(pk_org);//组织
		//是否传会计平台
		head.setFisvoucher(UFBoolean.TRUE);
		//计财务应收日期
		head.setDrecordapdate(AppContext.getInstance().getBusiDate());
		//制单人
		head.setCreator(AppContext.getInstance().getPkUser());
		//制单日期
		head.setMaketime(AppContext.getInstance().getServerTime());
		//单据状态
		head.setVbillstatus(BillStatus.FREE);
		//服务中心
//		head.setPk_managementsecid();
		//经办人
		head.setPk_psndoc(AppContext.getInstance().getPkUser());
		//单据类型
		head.setBilltype("H338");
		//创建人
		head.setBillmaker(AppContext.getInstance().getPkUser());
		//币种
		head.setVdef1("");
		//
		head.setStatus(VOStatus.NEW);
		
		head.setPk_managementsecid(LogonBO_Client.getManageUnit());//服务中心
		head.setPk_psndoc(AppContext.getInstance().getPkUser());//经办人	
		
		return head;
	}
 
	/**
	 * 生成表体数据 
	 * 
	 * */
	public Djfb[] chgBodys(NCObject[] bills) {
 
		if (bills == null) {
			return null;
		}
		Djfb[] bodys = new Djfb[bills.length];
 
		for (int i = 0; i < bodys.length; i++) {
			Bill head = (Bill) bills[i].getModelConsistObject();
			if(head.getSrnmny()==null||head.getSrnmny().doubleValue()<=0){
				continue;
			}
			/*if(head.getSrnrevmny()!=null
					&&head.getSrnrevmny().doubleValue()>0
					&&head.getSrnmny().sub(head.getSrnrevmny()).doubleValue()==0D){
				continue;
			}*/
				
			Djfb body = new Djfb();
			body.setVsourcebillid(head.getPk_head());//来源单据ID == 收费清单主键
			body.setReserve5(head.getReserve1());//合同编号
			body.setPk_pact(head.getPk_pact());
			if(head.getPk_currency()!=null){
				body.setPk_currency(head.getPk_currency());//币种
			}else{
				body.setPk_currency("1002Z0100000000001K1");//币种,人民币
			}
			body.setPk_faretypeid(head.getPk_faretypeid());//收费项目
			body.setReserve1(head.getPk_allhouses());//单元
			body.setReserve2(head.getPk_customer());//租户
			body.setDbegin(head.getDbegin());//收费开始日期
			body.setCostbelongmonth(head.getCostbelongmonth());//费用所属月
			body.setDend(head.getDend());//费用截至日期
			body.setDshpay(head.getDshpay());//应收款日期
			body.setBusreceivemonth(head.getBusreceivemonth());//业务应收月
			body.setReserve3(head.getPk_faretypeid());//收费项目
			
			//应收金额信息(原币/本币)
			UFDouble srnmny = new UFDouble(0);
			if(null != head.getSrnmny())srnmny =head.getSrnmny();
			UFDouble srnrevmny = new UFDouble(0);
			if(null != head.getSrnrevmny())srnrevmny =head.getSrnrevmny();
			
//			body.setSrnmny(srnmny.sub(srnrevmny));//应收金额 == 总应收 - 已收金额
			body.setSrnmny(srnmny);//应收金额 
			body.setNmny(srnmny.sub(srnrevmny));
//			body.setNyarapverifmny(nyarapverifmny);//核销金额
			
			//收费清单的来源源单据类型
			body.setSrc_bill_type(head.getVsourcebilltype());
			// 来源单据信息
			body.setVsourcebillid(head.getPrimaryKey());
			//来源单据号
			body.setSrc_bill_code(head.getVbillcode());
			//租约类型
			body.setPk_pacttype(head.getPk_pacttype());
			body.setStatus(VOStatus.NEW);
			//上游单据主键
			body.setVlastbillrowid(head.getPk_head());
			
			bodys[i] = body;
		}
 
		return bodys;
 
	}
 
	/**
	 * 构造一个查询对话框,并为其设置查询模板
	 * 
	 * @param templateId
	 * @param parent
	 * @param isRelationCorp
	 * @param pkOperator
	 * @param funNode
	 */
	private IBillReferQuery setConditionClient(String templateId,
			Container parent, final String pkOperator, final String funNode,
			String pkCorp) {
		TemplateInfo ti = new TemplateInfo();
		ti.setTemplateId(templateId);
		ti.setPk_Org(pkCorp);
		ti.setUserid(pkOperator);
		ti.setCurrentCorpPk(pkCorp);
		ti.setFunNode(funNode);
		ti.setNodekey("qt");
 
		QueryConditionDLG qcDlg = new QueryConditionDLG(parent, ti);
 
		qcDlg.setVisibleNormalPanel(true);
		return qcDlg;
	}
 
	public IBillCardPanelEditor getEditor() {
		return this.editor;
	}
 
	/**
	 * @return model
	 */
	public BillManageModel getModel() {
		return this.model;
	}
 
	public void setEditor(IBillCardPanelEditor editor) {
		this.editor = editor;
	}
 
	/**
	 * @param model
	 *            要设置的 model
	 */
	public void setModel(BillManageModel model) {
		this.model = model;
		model.addAppEventListener(this);
	}
 
	public String getCurrBilltype() {
		return currBilltype;
	}
 
	public void setCurrBilltype(String currBilltype) {
		this.currBilltype = currBilltype;
	}
 
	/**
	 * 父类方法重写
	 * 
	 * @see nc.ui.uif2.NCAction#isActionEnable()
	 */
	@Override
	protected boolean isActionEnable() {
		return UIState.NOT_EDIT == this.getModel().getUiState();
	}
 
	/**
	 * 转单是否根据流程过滤
	 * 
	 * @return
	 */
	protected boolean isBusiness() {
		return true;
	}
 
	public DefaultUIF2RefEditor getDefaultUIF2RefEditor() {
		return defaultUIF2RefEditor;
	}
 
	public void setDefaultUIF2RefEditor(DefaultUIF2RefEditor defaultUIF2RefEditor) {
		this.defaultUIF2RefEditor = defaultUIF2RefEditor;
	}
 
}

导入编辑器类:

package nc.itf.fdc.pub;
 
import nc.ui.pub.bill.BillData;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.editor.IBillCardPanelEditor;
import nc.ui.uif2.model.AbstractUIAppModel;
import nc.vo.pub.AggregatedValueObject;
 
 
public  class DefaultUIF2RefEditor  {
 
	
	
	private NCAction addAction = null;
									
	private Exception ex;    //保存过程中通过拦截器将异常抛出 
 
	
	private IBillCardPanelEditor billcardPanelEditor = null;
	
	private AbstractUIAppModel appModel = null;
	
 
	protected NCAction createAddAction()
	{
		return null;
	}
	
	protected NCAction createSaveAction()
	{
		return null;
	} 
	
	protected NCAction createCancelAction()
	{
		return null;
	}
	
	protected IBillCardPanelEditor createBillCardPanelEditor()
	{
		return null;
	}
	
	protected AbstractUIAppModel createAppModel()
	{
		return null;
	}
	
	
	 
	
	/**
	 * 新增操作
	 * 
	 * @see nc.itf.trade.excelimport.IImportableEditor#addNew()
	 */
	public void addNew() {
		try {
			getAddAction().actionPerformed(null);
		} catch (Exception e) {
			nc.bs.logging.Logger.error(e.getMessage());
		}
	} 
	
	/**
	 * 设值操作
	 * 
	 * 标准的操作步骤如下:
	 * 1,转型VO为ExtendedAggregatedValueObject
	 * 2,根据转换规则处理VO的相关属性值
	 * 3,将处理后的VO值设置到界面上
	 */
	public void setValue(Object obj) {
		if(getBillcardPanelEditor() != null)
		{
			BillData bd = getBillcardPanelEditor().getBillCardPanel().getBillData();
			bd.setBillValueVO((AggregatedValueObject)obj);
		}
	}
 
 
 
	
	/**
	 * 返回AddAction对象
	 */
	public NCAction getAddAction() {
		
		if(addAction == null)
			addAction = createAddAction();
		return this.addAction;
	}
 
	
 
	public void setAddAction(NCAction addAction) {
		this.addAction = addAction;
	}
 
	public IBillCardPanelEditor getBillcardPanelEditor() {
		
		if(billcardPanelEditor == null)
			billcardPanelEditor = createBillCardPanelEditor();
		return billcardPanelEditor;
	}
 
	public void setBillcardPanelEditor(IBillCardPanelEditor billcardPanelEditor) {
		this.billcardPanelEditor = billcardPanelEditor;
	}
 
 
 
	
	public AbstractUIAppModel getAppModel() {
		
		if(this.appModel == null)
			appModel = createAppModel();
		return appModel;
	}
 
	public void setAppModel(AbstractUIAppModel model) {
		this.appModel = model;
	}
	
	public int getExportCount() {
		return 1;
	}
 
	public Exception getEx() {
		return ex;
	}
 
	public void setEx(Exception ex) {
		this.ex = ex;
	}
}

原文链接:https://blog.csdn.net/qq_31968809/article/details/54587896

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Eclipse是一种功能强大的开发工具,广泛被用于Java开发。它具有完整的集成开发环境,提供了丰富的插件和工具,可以帮助开发者更高效地进行代码编写、调试和测试。 NC是全称为NetCentric,是一家专注于企业级软件解决方案的服务商。他们提供了一系列的软件产品和服务,包括企业级应用集成、业务流程管理和移动应用开发等。 UAP-Studio是NC提供的一款用于开发企业级应用的开发工具。该工具基于Eclipse平台,集成了NC自己的开发框架和组件,提供了更便捷的开发环境和丰富的开发功能。 使用UAP-Studio,开发者可以快速构建企业级应用。它提供了代码生成和模板功能,可以快速生成标准化的代码结构,减少重复开发的工作量。同时,它还提供了可视化的界面设计工具,可以快速搭建应用的前端界面。 UAP-Studio还集成了强大的调试和测试工具,帮助开发者快速定位和修复代码问题。此外,它还提供了工程管理和版本控制的功能,方便团队协作和代码管理。 总的来说,Eclipse和UAP-Studio都是常用的开发工具,用于提高开发效率和质量。通过它们的使用,开发者无需从头开始构建开发环境和框架,可以专注于应用商务逻辑的开发。对于需要快速开发高质量企业级应用的开发者来说,Eclipse和UAP-Studio都是不可或缺的工具。 ### 回答2: Eclipse是一种功能强大的开源集成开发环境,被广泛用于Java开发。它提供了各种工具和插件来简化开发过程,比如代码编辑器、调试器、版本控制等。Eclipse的一个主要特点是它的高度可定制性,用户可以通过安装不同的插件来满足不同的开发需求。 NC是“Nuontu Cloud”的缩写,是一种云计算领域的软件平台。它提供了各种云计算服务,如云存储、云虚拟机、云数据库等。NC的目标是帮助开发者更轻松地构建和管理自己的云计算应用。 UAP-Studio是一种基于Eclipse平台的开发工具,专门用于快速开发UAP应用。UAP是“Unification of Asset and Product”的缩写,是用于企业业务和应用集成的平台。UAP-Studio提供了一系列的开发工具和模板,帮助开发者更容易地构建和部署UAP应用。它能够与NC平台无缝集成,方便开发者将应用部署到云端。 总的来说,eclipse nc uap-studio是一个用于Java开发、云计算和UAP应用开发的工具集合。在使用它们的时候,开发者可以更高效地进行开发,通过利用云计算的能力,快速地构建和部署自己的应用。同时,Eclipse的可定制性也使得开发者可以根据自己的需求来进行定制和扩展。 ### 回答3: Eclipse是一个非常受欢迎的开发工具,主要用于Java编程。它提供了许多功能强大的特性,如代码自动补全、调试工具和代码重构等,使得开发者可以更高效地编写代码。 NC是“Nothing Changes”的缩写,是指不改变原有代码而仅仅新增代码的一种开发模式。这种模式使得开发者能够通过模块化的方式来开发应用程序,从而最大程度地保持原有代码的稳定性,减少了出错的可能性。 UAP-Studio是基于Eclipse的一款集成开发环境(IDE),主要用于开发UAP(Unified Application Platform)应用程序。它提供了一系列的工具和插件,方便开发人员进行UAP应用程序的开发、测试和部署。UAP-Studio通过集成多种开发工具和框架,为开发者提供了更全面的开发环境。 总的来说,Eclipse、NCUAP-Studio都是与软件开发相关的工具。Eclipse是一个通用的开发工具,主要用于Java编程,而NCUAP-Studio是在Eclipse的基础上进行的特定领域的开发工具。这些工具都能够提升开发效率,使得开发者能够更方便地进行软件开发

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值