EAS后台常用代码示例

1.BigDecimal类型的使用方式

BigDecimalamounts = new BigDecimal(String.valueOf(0.00)):

2.通过 String 转换成 pk:

ObjectUuidPK pk =new ObjectUuidPK(paymentInfo.getId());

3.单据新增代码

如:新增一行付款单

//构造一条付款单信息构造值对象)
PaymentBillInfo payInfo = new PaymentBillInfo():
payInfo.setNumber(“1001”);
//关联用户
UserInfo userInfo = new Userlnfo():
userInfo.setId(BOSUuid.read("867d5df6-00f8-1000-e000-0009c0a81089sysu"));// 通 过
BOSUuid 建立实体对象
userInfo.setName(“John”):
userInfo.setNumber(“2000”);
BigDecimalex = new BigDecimal("343434.445”)://建立属性
BigDecimalex2=new BigDecimal(12345678901234567.8)://错误
payInfo.setExchangeRate(ex):
paylnfo.setCreator(userInfo);
payInfo.setAuditDate(new Date(System.currentTimeMillis0))://时间属性
Timestamp createdate = new Timestamp(System.currentTimeMillis());
payInfo.setCreateDate(createdate):
payInfo.setBizState(BillBizState.create)://枚据属性
payInfo.setSave(true)://Boolean 属性
PaymentBillItemInfo itemInfo =new PaymentBillItemInfo()://建立分录
itemInfo.setLineNo(34):
itemInfo.setAmounts(ex2);
payInfo.getEntries()add(itemInfo)://添加分录
payInfo.getEntries().add(new ErrandTaskItemInfo())://添加分录
调用新增方法进行保存IPaymentBilliPayBill= PaymentBillFactory.getRemoteInstance()://获取实体
IObjectPK pk =iPayBilladdnew(payInfo)://保存值对象,返回逻辑键,可以通过逻辑键
获取值对象(如下)
// PaymentBillInfo payInfo2 = iPayBillgetValue(pk):

4.单据修改代码 

修改一条付款单信息

IPaymentBill iPayBill = PaymentBillFactory.getRemotelnstance();
Stringid="8b35b903-00f8-1000-e000-0008c0a81089errt":
ObiectUuidPK pk= new ObiectUuidPK(BOSUuid.read(id))://建立逻辑键
PaymentBillInfo payInfo =iPayBill.getValue(pk)://获取值对象;
System.out.println("this:"+ payInfo.getExchangeRate0)://获取属性
payInfo.setExchangeRate(ex)://修改属性属性
iPayBill.update(pk,payInfo)://更新数据

5.单据删除代码

iPayBill.remove(pk);//通过逻辑键删除单据内容获取集合
6.获取集合
Currencylnfo cur = new Currencylnfo();ICurrency c=CurrencyFactory.getRemoteInstance()://建立实体对象
EntityViewInfoevi=new EntityViewInfo0://建立视图信息
FilterInfoi= new FilterInfo)://建立过滤条件
i.getFilterItems().add(
new FilterItemInfo("number", "ddff", CompareType.EQUELS))
i.getFilterItems().add(
new FilterItemInfo("id"."ddff,CompareType.EOUELS))
i. setMaskString("(#O and #1)");
evisetFilter()://添加过滤条件
evi.getSelector()add(new SelectorItemInfo("id"));//添加获取属性
evi.getSelector().add(new SelectorItemInfo("*"));
evi.getSelector().add(new SelectorItemInfo("company.id"));
evi.getSelector().add(new SelectorltemInfo("company.name"):
//三种获取集合方法
//a.获取所有数据:
CurrencyCollection co =c.getCurrencyCollection 0;//获取集合
//b.获取满足上述条件的所有数据
CurrencyCollection co =c.getCurrencyCollection(evi)://获取集合
//c.获取满足 oql所写的条件的所有数据3
CurrencyCollection co =c.getCurrencyCollection (evi)://获取集合

7.获取值对象

Currencylnfo cur = new Currencylnfo():ICurrencyc=CurrencyFactory.getRemoteInstance0;/////建立实体对象
Stringid="8b35b903-00f8-1000-e000-0008c0a81089errt":
ObiectUuidPK pk =new ObjectUuidPK(BOSUuidread(id))://建立逻辑键
c.getValue(pk): 
//或者
c.getCurrencyInfo(pk);

8.界面之间传递参数

//1. 收集父界面要传递给子界面的参数集
HashMap map = new HashMap();
map.put("Owner”,this);//必须。被启动UI的父UI对象
map.put("EASMode", new Integer(this.EASMode));
map.put("table",this.accountTablePrompBox.getData()):
map.put("cu",currentCtrlUnit):
map.put("auxAccount",this.asstAccountPromptBox.getData()):
IUIFactory uiFactory = null;
uiFactory = UIFactory
.createUIFactory("com.kingdee.eas.base.uiframe.client.UIModelDialogFactory"): //以模态对话框方式启动
IUIWindowuiWindow = uiFactory
create("comkingdee.cas.basedatamasterauxacctclient.AccountSelectUI",map);/* 被启动对象的类名称*/
uiWindow.show();

 

  2. 在子界面获取传递下来的数据
private void loadContext(){
  int mode = ((Integer)this.getUIContext().get("EASMode")).intValue():
  AccountTablelnfo accountTablelnfo = (AccountTablelnfo) this.getUIContext().get("table"):
  CtrlUnitInfo culnfo =(CtrlUnitInfo) this.getUlContext).get("cu"):
  AsstAccountInfo asstAccountInfo = (AsstAccountInfo) this.getUIContext).get("auxAccount"):AuxAccountEditUl ui =(AuxAccountEditUD) this.getUIContext().get("Owner");
}

 9.给query传过滤条件

EntityViewInfo evi = new EntityViewInfo():
FilterInfo filterInfo = new FilterInfo()//建立过滤条件
filterInfo.getFilterItems().add(new FilterltemInfo("typelink.id", info.getld().CompareType.EQUALS));
filterInfo.getFilterItems().add(new Filterltemlnfo("currencyCompany.id", companylD.CompareType.EQUALS)):
filterInfo.setMaskString("#0 and #1");evi.setFilter(filterInfo):
if (mainQuery == null) {
mainQuery = new EntityViewInfo():
}
mainQuery.setFilter(filterInfo); //添加过滤条件
this.execQuery();

10.接口方法的访问方式

//3. 客户端访问
Currencylnfo cur = new Currencylnfo();
ICurrency c= CurrencyFactory.getRemoteInstance0://建立实体对象
c.getCurrencyCollection();
//4. 服务端访问
CurrencyInfo cur = new CurrencyInfo();
ICurrency c = CurrencyFactory. getLocalInstance(ctx)://建立实体对象
c. getCurrencyCollection();

11. 特别控件的初始化

 

使用举给 ComboBox 控件赋值
public void setReceiveType(){
    this.kDComboBox2.removeAllItems():
    List list = new List();
    Iterator it = ReceiveType.iterator():
    while (it.hasNext()){
        list.add(ReceiveType.getEnum(it.toString()).toString0);
    }
使用值对象集合给 ComboBox 控件赋值
//获取结算方式列表
IAsstActTypeDefault iAsstActType = AsstActTypeDefaultFactorygetRemotelnstance():
AsstActTypeDefaultCollection asstActTypeColl = iAsstActType.getAsstActTypeDefaultCollection(" where isAccountCussent = 1"):
AsstActTypeDefaultInfo defaultVal = null;
int count = asstActTypeColl.size():
Object[] typeValue = new Object[count]:
for (int i = 0; i < count; i++){
    AsstActTypeDefaultInfo value = (AsstActTypeDefaultlnfo) asstActTypeColl.get(i);
    if(value.isIsDefaultAccountPayable()){
        defaultVal = value;
        }
    ObjectUuidPK pk = new ObjectUuidPK(BOSUuid.read(value.getAsstActType().getString("id"))):
    AsstActTypelnfo asstInfo = AsstActTypeFactory.getRemotelnstance().getAsstActTypelnfo(pk):
  //cbili] = new ComBoxInfo(asstInfo,asstInfo.getName(), true):
    String typeName = asstInfo.getName();
    String typeld = asstInfo.getld().toString();
    String typeQueryName = asstInfo.getDefaultQueryName();
    String typeTableName = asstInfo.getRealtionDataObject);
    int csType = 0: 
  //asstActTypelnfogetCsType().getValue();
    asstActType = ncw AsstActTypeUtils(typeName, typeld, typeTableNamc.typeQueryName,csType);
    typeValue[i] = (Object) asstActType;
  //String strQucryName ="F7SupplicrQucry";
    this.kDComAccountCussentType.removeAllltems():
    this.kDComAccountCussentType.addItems(typeValue);
    this.kDComAccountCussentType.setSelectedIndex(0):
    }

 

12.给F7赋值

 

ObjectUuidPK pk = new ObjectUuidPK(id);
IObjectValuc objVal = DynamicObjectFactory.getRemoteInstance().getValue(pk.getObjectType(), pk);
bizPrompt.setData(objVal);

private void setCompanyF7(){
//公司的 F7 的设置
OrgType[] CompanyType = { OrgType.Company };
//首先定义需要显示那些树,这里只显示财务树
//为F7 控件指定 PromptBox
this.bizPromptCompany.setEditFormat("$number$");
this.bizPromptCompany.setDisplayFormat("$name$");
this.bizPromptCompany.setEditable(true):
this.bizPromptCompany.setCommitFormat("$number$");
OrgUnitTreePromptBox boxCompany = new OrgUnitTreePromptBox(this.newCompanyType, null,OrgSelect.OnlySelectCompanyEntity, false, false, false);
bizPromptCompany.setSelector(boxCompany);
bizPromptCompany.setData(currentCompany);
bizPromptCompany.sctEnabled(false);
}

//设置 币别
private void setCurrency() throws EASBizException, BOSException{
    ICurrency iCurrency = null;
    CurrencyCollection con = null;
    try{
        iCurrency = CurrencyFactory.getRemoteInstance();
        con =iCurrencygetCurrencyCollection(true);
        }catch (Exception e){
        //TODO自动生成 catch 块
            MsgBox.showError(this,EASResource.getString(resClassName,"currencyFail"));
            SysUtil.abort0);
        }
    if (con != null){
        Object[] typeValue = new Object[con.size()];
        int j = 0:
        for (int i= 0;i< con.size(): i++){
            CurrencyInfo currencyInfo =(CurrencyInfo) con.get(i);
            String typeName = currencyInfo.getName();
            String typeld = currencyInfo.getId().toString();
            String typeQueryName = currencylnfo.getNumber();
            asstActType = new AsstActTypeUtils(typeName, typeld, typeQueryName);
            if (asstActType != null){
                typeValue[i] = (Object) asstActType;
                if(typeld.equalslgnoreCase(((Currencylnfo)currentCompanygetBaseCurrency()).getld().toString())){
                    j=i
                }
            }
        }
        this.bizPromptcurrency.removeAlltems();
        this.bizPromptcurrency.addItems(typeValue);
        //默认值为当前公司的本位币
        this.bizPromptcurrency.setSelectedIndex(j);
    }else{
        MsgBox.showError(this,EASResource.getString(resClassName,"currencyFail"));
        SysUtil.abort();
    }
}

 

13.eas获取当前公司

CompanyOrgUnitInfo currentCompany = BaseDataUtil.getCompanyInfo();
CompanyOrgUnitInfo info = SysContext.getSysContext()getCurrentFIUnit():

14.获取当前用户

UserInfo defaultUserInfo = SysContext.getSysContext().getCurrentUserInfo();

15.设置单据分录单元格格式

//设置单据分录格式
getDetailTable().getColumn(TB_RELABILL).setWidth(100);
getDetailTable(.getColumn(TB_ORGUNIT).setWidth(180):
getDetailTable().getColumn(TB_BIZMAN).setWidth(100):
getDetailTable().getColumn(TB_PAYAMOUNT).setEditor(number_CellEditor);
getDetailTable(.getColumn(TB_PAYAMOUNT).getStyleAttributes().setNumberFormat("%r-[=]{#.00)f");
getDetailTable().getColumn(TB_PAYAMOUNT).getStyleAttributes().setHorizontalAlign(HorjzontalAlignment.RIGHT);

16.分录金额可编辑设置

for (int i = 0; i < kdtEntrysgetRowCount(); i++){
    kdtEntrys.getRow(i).getCell("orgUnit").getStyleAttributes().setLocked(false);
    kdtEntrys.getRow(i).getCell("bizMan").getStyleAttributes().setLocked(false):
}
//如果折扣金额为 null 则初始化为 0
if (kdtEntrysgetRow(i)getCell("discountAmount")getValue() == null){
    kdtEntrys.getRow().getCell("discountAmount").setValue(new BigDecimal("0.0")):
}
//汇总分录行金额
BigDecimalamount = new BigDecimal("0"):
for (int i = 0, n = kdtEntrys.getRowCount(); i < n; i++){
    amount = amount.add(UIRuleUtil.getBigDecimal(UlRuleUtil.getBigDecimalValuc(kdtEntrysgetCell(i,TB_PAYAMOUNT).getValue()));
    this.txtTotalAmounts.setText(null):
    this.txtTotalAmounts.setEnable(false):
    this.txtTotalAmounts.setText(amount):
//和零比较
if(amount.compareTo(new BigDecimal("0.00")) == 0)

17.删除单元行

public void actionDeleteLine_actionPerformed(ActionEvent e)throws Exception (
    IRow row = getSelectedRow():
    if (row != null){
        kDTablel.removeRow(row.getRowIndex());
        }
    }

 

 

另有一篇eas客户端常用代码示例见我另一篇随笔:https://www.cnblogs.com/ketoli/p/17221138.html

posted @ 2023-01-29 17:28  凉了记忆  阅读(235)  评论(0编辑  收藏  举报