EAS常用技巧
1、如何给F7控件设置过滤条件
EntityViewInfo evi = new EntityViewInfo(); //创建实体视图
FilterInfo f = new FilterInfo();//创建过滤对象
FilterItemInfo filter1 = new FilterItemInfo("number", "SHFL001", CompareType.GREATER);//创建第一个过滤条件,第一个参数:所查询的实体的属性,第二个参数:属性的目标值,第三个参数:比较符
FilterItemInfo filter2= new FilterItemInfo("age", "20", CompareType.GREATER);//创建第二个过滤条件
f.getFilterItems().add(filter1);//将过滤条件添加到过滤对象中
f.getFilterItems().add(filter2);
f.setMaskString("#0 or #1");//设置两个过滤条件之间的关系
evi.setFilter(f);//设置实体视图的过滤器
f7.setEntityViewInfo(evi);//将实体视图绑定到F7控件
f7.getQueryAgent().resetRuntimeEntityView();
2:EAS-BOS项目路径变更的方法
拷贝工作区的时候,会出现目录变更,在发布项目是,会出现启动ear失败情况,如下错误:
1. 修改:$ProjectPath$\runtime\server\profiles\server1\config\bosconfig.xml
<attribute key="MetaDataPath" value="D:\workspace\EWorld/metadata" />`
2. 修改$ProjectPath$\runtime\server\profiles\server1\config\licensefile.xml
<uri>D:\workspace\EWorld\runtime\server\profiles\server1\config\licenses\license</uri>
3. $ProjectPath$\runtime\server\profiles\server1\config\portalConfig\easWebConfig.xml <!--本地元数据加载路径-->
<attribute key="metadatapath" value="D:\workspace\EWorld\metadata" />
4. 修改$ProjectPath$\EWorld\runtime\apusic\config\server.xml<server>
<application name="eas.ear" base="D:/workspace/EWorld/runtime/server/deploy/eas.ear" start="auto" /></server>
3、如何获取当前用户
1、在UI扩展类中,获取当前用户可通过工具类SysContext 如:SysContext.getSysContext().getCurrentUserInfo()
2、在ControlerBean的扩展类中,获取当前用户可通过工具类ContextUtil 如:ContextUtil.getCurrentUserInfo(ctx)
注意:关于SysContext和ContextUtil这两个工具类中方法的介绍: 这两个类是EAS的全局工具类,用于获取当前用户信息,当前组织单元信息、客户端IP、客户端名字等信息。SysContext用于客户端,如UI扩展类中;而ContextUtil用于服务端,如ControllerBean扩展类中。
4、如何增加F7界面上的过滤条件
找到F7界面所对应的Query后,选择字段页签,找对应的属性?扩展属性:增加“是否在通用过滤中显示”的扩展属性,并将其值设置为true。重新发布。
5、手动添加合计行
//添加合计栏
KDTFootManager footmgr = new KDTFootManager(kdtE2);
footmgr.addFootView();
kdtE2.setFootManager(footmgr);
kdtE2.addFootRow(0);
IRow row = footmgr.getFootRow(0);
row.getCell(0).setValue("合计:");// 设置合计字段(重视父类方法)
protected void setTableToSumField() {
setTableToSumField(kdtE1, new String[] { "ContractAmount" });
super.setTableToSumField();
}
完整详细代码
IRow row = tblMain.addRow(); row.getStyleAttributes().setBackground(new Color(236, 255, 255)); row.getCell(0).setValue("合 计 栏 :"); row.getStyleAttributes().setBold(true); row.getStyleAttributes().setFontColor(Color.RED); BigDecimal sum1 = new BigDecimal("0.00"); sum2 = new BigDecimal("0.00"); BigDecimal sum3 = new BigDecimal("0.00"), sum4 = new BigDecimal("0.00"); for (int i = 0; i < tblMain.getRowCount(); i++) {// 合计最后俩栏 if (tblMain.getCell(i, 1).getValue() != null && !tblMain.getCell(i, 1).getValue().equals("")) { tblMain.getCell(i, 1).setValue(((BigDecimal) tblMain.getCell(i, 1).getValue()).setScale(2)); sum1 = sum1.add((BigDecimal) tblMain.getCell(i, 1).getValue()); } if (tblMain.getCell(i, 2).getValue() != null && !tblMain.getCell(i, 2).getValue().equals("")) { tblMain.getCell(i, 2).setValue(((BigDecimal) tblMain.getCell(i, 2).getValue()).setScale(2)); sum2 = sum2.add((BigDecimal) tblMain.getCell(i, 2).getValue()); } } row.getCell(1).setValue(sum1.setScale(2)); row.getCell(2).setValue(sum2.setScale(2));
6、屏蔽分录双击排序功能
this.kdtEntrys.removeKDTMouseListener(this.kdtEntrys.getSortMange());//所有列 tblMain.getColumn(i).setSortable(false); //单个
7、获取单元格显示的值
detailTable.getCellDisplayText(cell);
8、合并这两个EntityViewInfo
EntityViewInfo view1 = new EntityViewInfo(); EntityViewInfo view2 = new EntityViewInfo(); view1.getFilter().mergeFilter(view2.getFilter(), "and");
9、指定F7对字段排序
SorterItemCollection sorter = new SorterItemCollection(); SorterItemInfo sortinfo = new SorterItemInfo(); sortinfo.setPropertyName("属性名称"); sortinfo.setSortType(SortType.DESCEND);//排序方式,asc 还是 desc EntityViewInfo entityInfo = new EntityViewInfo(); entityInfo.setSorter(sorter); my_PromptBox.setEntityViewInfo(entityInfo);
10、如何让编辑界面一打开就是最大化
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setPreferredSize(screenSize);
11、去掉导出Excel右键菜单
public void addCommonMenusToTable(KDTable table) { super.addCommonMenusToTable(table); PopupMenuManager mgr = getPopupMenuManager(table); mgr.removeMenuSection("export"); }
12、设置是否在调入列表界面之前先出过滤框
protected boolean initDefaultFilter() { return true; }
13、隐藏EditUI上面板上的添加行删除行的按钮
this.kdtPaymentInfoEntry_detailPanel.getAddNewLineButton().setVisible(false); this.kdtPaymentInfoEntry_detailPanel.getInsertLineButton().setVisible(false); this.kdtPaymentInfoEntry_detailPanel.getRemoveLinesButton().setVisible(false);
14、通过实体获取表名
String id = "09MdQVjnSOyTGn6RwzLDGvSvTwM="; DataTableInfo table = MetaDataLoaderFactory.getRemoteMetaDataLoader().getEntity(BOSUuid.read(id).getType()).getTable(); String tableName = table.getDisplayName();
15、组织切换(app下代码处理)
OrgSwitchFacadeFactory.getLocalInstance(ctx).orgSwitch(company.getId().toString());
16、在程序中给F7增加过滤参数,发现有组织隔离的F7,比如养户档案,得到F7的Filter后增加一个FilterItemInfo条件,调试的时候没有看到我加的条件,只看到了框架做的组织隔离的条件?(适用于序时簿的过滤)##
重载方法:
protected FilterInfo getDefaultFilterForQuery() { FilterInfo info =super.getDefaultFilterForQuery(); FilterInfo info1 = new FilterInfo(); info.merge(info1,"AND"); }
17、做过组织隔离的F7进行再过滤在实现类构造函数里添加如下代码(适用于编辑界面)##
EntityViewInfo evInfo = new EntityViewInfo(); FilterInfo filter = new FilterInfo(); filter.getFilterItems.add("",""); // 加用户的过滤项 evInfo.setFilter(filter); F7PromptControl.setEntityViewInfo(evInfo);
18、getCurrentFIUnit()和getCurrentOrgUnit()之间的区别?##
如果我当前登录的组织是库存组织, getCurrentFIUnit()是不是就会找当前组织的上一级财务组织单元?其他的 getCurrentCtrlUnit(), getCurrentAdminUnit(), getCurrentCostUnit()等是否也是这个原理?
1、getCurrentFIUnit就是取当前财务组织,一般用于财务类型的单据;
2、getCurrentOrgUnit是取当前的业务组织,适用于所有单据;
3、getCurrentFIUnit()是指取当前登录用户所对应的财务组织;
同理:getCurrentCtrlUnit()、getCurrentAdminUnit()、getCurrentCostUnit()分别指当前用户所切换组织所对应的CU,行政组织,成本组织。
19.获取当前窗口的工作状态(新增、修改或查看)
getOprtState().equals(OprtState.ADDNEW);
20、在listui 中,有个小数字段,我在EDITUI中录入0时,保存后在LISTUI中显示为空,而不是0,请问怎么让他显示出来?##
请重载listui
里的getQueryExecutor()
方法,然后在语句“super.getQueryExecutor();”后面加上exec.option().isAutoIgnoreZero = false; 用来设置0不转换为空。
protected IQueryExecutor getQueryExecutor(IMetaDataPK queryPK, EntityViewInfo viewInfo) { IQueryExecutor executor = super.getQueryExecutor(queryPK, viewInfo); executor.option().isAutoIgnoreZero = false; return executor; }
21、我想让一个EditUI的分录不能新增行,已经把新增行的按钮什么的都去掉了,但在分录的最后一列按回车,table还是会自动新增一行。请问怎么屏蔽掉?##
在屏蔽“新增分录”那个按钮的同时, 调用屏蔽table的自动新增行语句disableAutoAddLine();
使之不能自动新增行
22、多分录单据如何刷新editData?##
调用loadData();
23、通过编号更新EAS用户密码##
protected String _updatePassword(Context ctx, String number, String oldPwd, String newPwd) throws BOSException { IUser instance = UserFactory.getLocalInstance(ctx); UserCollection collection = instance.getUserCollection("where number='" + number + "'"); if (collection.size() > 0) { UserInfo userInfo = collection.get(0); try { String strOldPwd = CryptoTean.encrypt(userInfo.getNumber(), oldPwd); String strNewPwd = CryptoTean.encrypt(userInfo.getNumber(), newPwd); IObjectPK iObjectPK = new ObjectUuidPK(userInfo.getId().toString()); instance.updatePass(iObjectPK, strOldPwd, strNewPwd); return "0000|update password is Success."; } catch (CryptException e) { e.printStackTrace(); return "0003|" + e.toString(); } catch (EASBizException e) { e.printStackTrace(); return "0001|" + e.toString(); } } else { return "9999|number not found user info."; } }
24、分录添加默认值##
protected IObjectValue createNewDetailData(KDTable table) { BizContractPayPlanEntryInfo info = new BizContractPayPlanEntryInfo(); info.setAmount(BigDecimal.ZERO); return info; }
25、获取当前在线用户数##
本文介绍的是在FacadeControllerBean也就是服务端获取的方法,GUI层面获取的方法在UserMonitorUI.class里已有代码,请自行查看;
UMRegistryCollection regs = null; try { ILoginModule loginModule = LoginModuleFactory.getLocalInstance(ctx); String encodePwd = CryptoTean.encrypt("EAS用户名", "密码"); //获取一个用户登录的上下文对象 LoginContext loginContext = new LoginContext("EAS用户名", encodePwd, ctx.getSolution(), ctx.getAIS(), ctx.getLocale()); loginContext.put("dbType", "Oracle"); loginContext.put("UserAuthPattern", "BaseDB"); try { String sessionId = loginModule.login(loginContext); ctx = SessionManager.getInstance().getSession(sessionId).getContext(); } catch (BOSLoginException e) { e.printStackTrace(); throw new BOSException(e.getMessage()); } regs = ((UMRegistryCollection) UserMonitorFactory.getLocalInstance(ctx).getCollectionUsingOrgRange( DataCenterName)); } catch (Exception e1) { e1.printStackTrace(); } int total = regs.size(); //这个就是总用户数了,如果要区分出哪些是GUI哪些是PORTAL的,可自行去UserMonitorUIj里看相关代码 ;
26、根据职员获取职位和职称##
PositionInfo getPositionByPerson(Context ctx, PersonInfo info) throws EASBizException, BOSException { EntityViewInfo view = new EntityViewInfo(); SelectorItemCollection sic = new SelectorItemCollection(); sic.add(new SelectorItemInfo("id")); sic.add(new SelectorItemInfo("person.id")); sic.add(new SelectorItemInfo("person.name")); sic.add(new SelectorItemInfo("person.number")); sic.add(new SelectorItemInfo("position.id")); sic.add(new SelectorItemInfo("position.number")); sic.add(new SelectorItemInfo("position.name")); sic.add(new SelectorItemInfo("position.job.id")); sic.add(new SelectorItemInfo("position.job.number")); sic.add(new SelectorItemInfo("position.job.name")); view.setSelector(sic); FilterInfo filter = new FilterInfo(); filter.getFilterItems().add(new FilterItemInfo("person.id", info.getId() + "")); filter.getFilterItems().add(new FilterItemInfo("isPrimary", new Integer(1))); view.setFilter(filter); PositionMemberCollection col = PositionMemberFactory.getLocalInstance(ctx).getPositionMemberCollection(view); if ((col != null) && (col.size() > 0) && (col.get(0) != null)) { return col.get(0).getPosition(); } return null; }
27、KDTable 表达式应用工具类##
/** *给单元格添加sum表达式 * @param cell * @param from * @param to */ public static void setCellSumExpr(ICell cell, int from, int to) { cell.setExpressions(getSumExpr(from, to)); } /** * 给单元格添加IF表达式 * @param cell * @param condExpr * @param expr1 */ public static void setCellIFExpr(ICell cell, String condExpr, String expr1, String expr2) { cell.setExpressions(getIFExpr(condExpr, expr1, expr2)); } /** * * 给单元格添加Add表达式 * @param cell * @param a * @param b */ public static void setCellAddExpr(ICell cell, int a, int b) { cell.setExpressions(getAddExpr(a, b)); } /** * * 给单元格添加Add表达式,允许不连续区域求和 * @param cell * @param range */ public static void setCellAddRangeExpr(ICell cell, int[] range) { cell.setExpressions(getAddRangeExpr(range)); } /** * * 给单元格添加Substract表达式 * @param cell * @param a * @param b */ public static void setCellSubExpr(ICell cell, int a, int b) { cell.setExpressions(getSubExpr(a, b)); } // return =sum(from:to); public static String getSumExpr(int from, int to) { StringBuffer buff = new StringBuffer(); buff.append("=SUM(").append(getExcelColumnLabel(from)); buff.append(":").append(getExcelColumnLabel(to)); buff.append(")"); return buff.toString().intern(); } // return =a+b public static String getAddExpr(int a, int b) { StringBuffer buff = new StringBuffer(); buff.append("=").append(getExcelColumnLabel(a)); buff.append("+").append(getExcelColumnLabel(b)); return buff.toString().intern(); } // return =range[0]+range[1]+...+range[n] public static String getAddRangeExpr(int[] range) { StringBuffer buff = new StringBuffer(); buff.append("="); boolean flag = false; for (int i = 0, n = range.length; i < n; i++) { if (flag) { buff.append("+"); } buff.append(getExcelColumnLabel(range[i])); flag = true; } return buff.toString().intern(); } // return =a-b public static String getSubExpr(int a, int b) { StringBuffer buff = new StringBuffer(); buff.append("=").append(getExcelColumnLabel(a)); buff.append("-").append(getExcelColumnLabel(b)); return buff.toString().intern(); } // retur =IF(condExpr,expr1,expr2); public static String getIFExpr(String condExpr, String expr1, String expr2) { StringBuffer buff = new StringBuffer(); buff.append("=IF(").append(condExpr).append(","); buff.append(expr1).append(",").append(expr2); buff.append(")"); return buff.toString(); } /** *根据列的的位置获取列标,如A、AA、AB...采用类似进制转换的算法 */ public static String getExcelColumnLabel(int colCount) { String rs = ""; do { colCount--; rs = ((char) (colCount % 26 + (int) 'A')) + rs; colCount = (int) ((colCount - colCount % 26) / 26); } while (colCount > 0); return rs; } /** *根据列标获取列的索引,采用类似进制转换的算法 */ public static int getExcelColumnIndex(String colName) { if (colName == null || colName.equals("")) { return -1; } colName = colName.toUpperCase(); int count = -1; char[] cs = colName.toCharArray(); for (int i = 0; i < cs.length; i++) { count += (cs[i] - 64) * Math.pow(26, cs.length - 1 - i); } return count; }
28:客户F7 物料F7 左树右表##
public void getMaterialF7ForReportFilterUI(KDBizPromptBox kDBizPromptBoxMaterial) throws Exception { GeneralKDPromptSelectorAdaptor selectorLisenterMaterial = null; MaterialGroupInfo info = new MaterialGroupInfo(); selectorLisenterMaterial = new GeneralKDPromptSelectorAdaptor(kDBizPromptBoxMaterial, new F7MaterialTreeListUI(), this, info.getBOSType().toString(), "com.kingdee.eas.basedata.master.material.app.F7MaterialInventoryQuery", "materialGroup.id", false); selectorLisenterMaterial.setIsMultiSelect(false); selectorLisenterMaterial.setQueryProperty("helpCode", "or"); kDBizPromptBoxMaterial.setSelector(selectorLisenterMaterial); kDBizPromptBoxMaterial.addSelectorListener(selectorLisenterMaterial); kDBizPromptBoxMaterial.setQueryInfo("com.kingdee.eas.basedata.master.material.app.F7MaterialInventoryNoGroupQuery"); } /** * 描述:获得客户F7<用于表头客户F7> * @param prmtPromptBox F7控件 * * @param queryInfo QueryInfo * * @param owner 所有者 * @param orgType 组织类型 */ public static void getBizCustomerF7(KDBizPromptBox prmtPromptBox, String queryInfo, Component owner, OrgType orgType) { OrgUnitInfo orgInfo = SysContext.getSysContext().getCurrentOrgUnit(orgType); SCMGroupClientUtils.setBizCustomerF7(prmtPromptBox, owner, orgType, queryInfo); SCMGroupClientUtils.setApproved4CustomerF7(prmtPromptBox, orgType); prmtPromptBox.setCurrentMainBizOrgUnit(orgInfo, orgType); } /** * 描述:获得物料F7<用于表头物料F7> * @param prmtPromptBox F7控件 * @param queryInfo QueryInfo * @param owner 所有者 * @param orgType 组织类型 * @throws BOSException */ public static void getBizMaterialF7(KDBizPromptBox prmtPromptBox, String queryInfo, Component owner, OrgType orgType, boolean isMulSelect) throws BOSException { OrgUnitInfo orgUnit = SysContext.getSysContext().getCurrentOrgUnit(orgType); SCMGroupClientUtils.setBizMaterialF7(prmtPromptBox, owner, orgType, isMulSelect, queryInfo); SCMGroupClientUtils.setApproved4MaterialF7(prmtPromptBox, orgType); prmtPromptBox.setCurrentMainBizOrgUnit(orgUnit, orgType); } //Query 设置为null,会根据组织类型查询Query SLClientUtils.getBizCustomerF7(prmtCustomer, "com.kingdee.eas.basedata.master.cssp.app.F7CustomerQuery", this, OrgType.Sale); SLClientUtils.getBizMaterialF7(prmtMaterial, null, this, OrgType.Sale, false); }
29、EAS BOS 服务端直接调用BOTP
参数说明:
-
ctx :服务端上下文
-
srcBosType:源单据的BosType
-
destBosType:目标单据的BosType
-
srcBillCollection:源单据集合,可以批量转换
-
botpPK:要使用的BOTP的PK。 可以通过表T_BOT_Mapping查找到id,将id转换成PK。 select t.fid from T_BOT_Mapping t where t.fname='',是botp的名称。
public static void generateDestBill(Context ctx, String srcBosType, String destBosType, CoreBillBaseCollection srcBillCollection, IObjectPK botpPK) throws Exception { IBOTMapping botMapping = BOTMappingFactory.getLocalInstance(ctx); CoreBillBaseInfo billInfo = srcBillCollection.get(0); BOTMappingInfo botMappingInfo = botMapping.getMapping(billInfo, destBosType, DefineSysEnum.BTP); if (botMappingInfo == null) { throw new FMException(FMException.NODESTBILL); } IBTPManager iBTPManager = BTPManagerFactory.getLocalInstance(ctx); BTPTransformResult btpResult = null; /* String[] ids = new String[srcBillCollection.size()]; for (int i = 0; i < srcBillCollection.size(); ++i) { CoreBaseInfo info = srcBillCollection.get(i); ids[i] = info.getId().toString(); } */ btpResult = iBTPManager.transformForBotp(srcBillCollection, destBosType, botpPK); IObjectCollection destBillCols = btpResult.getBills(); BOTRelationCollection botRelationCols = btpResult.getBOTRelationCollection(); for (int i = 0; i < destBillCols.size(); i++) { CoreBillBaseInfo destBillInfo = (CoreBillBaseInfo) destBillCols.getObject(i); iBTPManager.submitRelations(destBillInfo, botRelationCols); } }
30、进度条(没有百分比)##
LongTimeDialog dialog = new LongTimeDialog((Frame)SwingUtilities.getWindowAncestor(this)); dialog.setLongTimeTask(new ILongTimeTask() { public Object exec() throws Exception { Object obj = "12345"; // 进度条期间的操作 MeterProcureTrackReportUI.this.queryData(); return obj; } public void afterExec(Object result) throws Exception { } }); Component[] cps=dialog.getContentPane().getComponents(); for(Component cp:cps) { if(cp instanceof JLabel) { ((JLabel) cp).setText("数据查询中......."); } } dialog.show(); int count = this.kdtreport.getRowCount(); if (count < 1) { MsgBox.showInfo("没有找到相关记录!"); }
31、手动保存botp关系或增加上下查关系##
可以动用BOTPUtil.saveBOTRelation(Context ctx, Map idMap)或者saveBOTRelation(Context ctx, List srcIdList, String destBillId)
具体实现见代码
public static void saveBOTRelation(Context ctx, List srcIdList, String destBillId) /* */ throws BOSException /* */ { /* 38 */ if ((srcIdList == null) || (srcIdList.isEmpty()) || (EmptyUtil.isEmpty(destBillId))) { /* 39 */ return; /* */ } /* */ /* 42 */ String srcBillId = null; /* */ /* */ /* 45 */ IBOTRelation iBOTRelation = BOTRelationFactory.getLocalInstance(ctx); /* */ /* 47 */ int i = 0; for (int size = srcIdList.size(); i < size; ++i) /* */ { /* 49 */ BOTRelationInfo relateInfo = new BOTRelationInfo(); /* */ /* 51 */ srcBillId = (String)srcIdList.get(i); /* */ /* 53 */ relateInfo.setSrcEntityID(BOSUuid.read(srcBillId).getType().toString()); /* */ /* 55 */ relateInfo.setDestEntityID(BOSUuid.read(destBillId).getType().toString()); /* */ /* 57 */ relateInfo.setSrcObjectID(srcBillId); /* 58 */ relateInfo.setDestObjectID(destBillId); /* 59 */ relateInfo.setDate(new Date()); /* 60 */ relateInfo.setOperatorID("unknown"); /* 61 */ relateInfo.setIsEffected(true); /* 62 */ relateInfo.setType(0); /* */ /* 64 */ iBOTRelation.addnew(relateInfo); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public static void saveBOTRelation(Context ctx, Map idMap) /* */ throws BOSException /* */ { /* 78 */ if ((idMap == null) || (idMap.isEmpty())) { /* 79 */ return; /* */ } /* */ /* 82 */ BOTRelationInfo relateInfo = null; /* 83 */ String srcBillId = null; /* 84 */ String destBillId = null; /* */ /* */ /* 87 */ IBOTRelation iBOTRelation = BOTRelationFactory.getLocalInstance(ctx); /* */ /* 89 */ for (Iterator iter = idMap.entrySet().iterator(); iter.hasNext(); ) /* */ { /* 91 */ Map.Entry entry = (Map.Entry)iter.next(); /* */ /* 93 */ srcBillId = (String)entry.getKey(); /* 94 */ destBillId = (String)entry.getValue(); /* */ /* 96 */ relateInfo = new BOTRelationInfo(); /* */ /* 98 */ relateInfo.setSrcEntityID(BOSUuid.read(srcBillId).getType().toString()); /* */ /* 100 */ relateInfo.setDestEntityID(BOSUuid.read(destBillId).getType().toString()); /* */ /* 102 */ relateInfo.setSrcObjectID(srcBillId); /* 103 */ relateInfo.setDestObjectID(destBillId); /* 104 */ relateInfo.setDate(new Date()); /* 105 */ relateInfo.setOperatorID("unknown"); /* 106 */ relateInfo.setIsEffected(true); /* 107 */ relateInfo.setType(0); /* */ /* 109 */ iBOTRelation.addnew(relateInfo); /* */ } /* */ }
32、手工发送消息
SenderAgent senderAgent = SenderAgent.getSenderAgent(); Message message;Locale[] lcla = getContextLocales(ctx); //获取ctx的语言信息列表 Locale locale = null; message = MessageFactory.newMessage("kingdee.workflow"); //生成一个消息对象 for (int j = 0, m = lcla.length; j < m; j++) { //此处循环进行多语言消息的设置 locale = lcla[j]; message.setLocaleStringHeader("title","标题", locale);//设置消息标题 message.setLocaleStringHeader("sender","发送人" , locale);//设置发送人,属于文本,不是ID message.setLocaleStringHeader("body", "消息体内容",Locale);//设置消息体内容,根据具体业务自己设定 } message.setIntHeader("type", MsgType.NOTICE_VALUE);//设置消息类型为通知 message.setIntHeader("bizType", MsgBizType.WORKFLOW_VALUE);//业务类型设置为工作流 message.setIntHeader("sourceStatus", MsgSourceStatus.EMPTY_VALUE);//设置任务状态,此处是通知消息,所以设置空 message.setIntHeader("priority", MsgPriority.MIDDLE_VALUE);//设置消息优先级,自己根据需要设定相应的级别 message.setStringHeader("databaseCenter", ctx.getAIS());//得到数据中心 message.setStringHeader("solution", ctx.getSolution());//设置解决方案 message.setStringHeader("receiver", '4ff9eebb-0108-1000-e000-15acc0a813c813B7DE7F;4ff9eebb-0108-1000-e000-1db0c0a813c813B7DE7F'); //设置接收者,后面那参数是用户ID,多个ID可用分号";"分割 senderAgent.sendMessage(message); //发送消息 /**
33、KDSpinner控件选择年
Calendar cal = Calendar.getInstance(); Integer year = cal.get(Calendar.YEAR); Integer min = new Integer(2002); Integer max = new Integer(9999); Integer step = new Integer(1); SpinnerNumberModel model = new SpinnerNumberModel(year, min, max, step); txtYear.setModel(model);
34、bean根据编码规则获取编号
if(mmsi.getNumber()==null){ ICodingRuleManager iCodingRuleManager = null; iCodingRuleManager = CodingRuleManagerFactory.getLocalInstance(arg0); String orgUnitID = ContextUtil.getCurrentOrgUnit(arg0).getId().toString(); if(iCodingRuleManager.isExist(mmsi, orgUnitID)){ if(iCodingRuleManager.isUseIntermitNumber(mmsi, orgUnitID) ){ //编码规则不允许断号 --> 获取断号编码 mmsi.setNumber(iCodingRuleManager.getNonbreakNumber(mmsi,orgUnitID)); }else{ mmsi.setNumber(iCodingRuleManager.getNumber(mmsi,orgUnitID)); } } }
35、如何通过代码将query数据进行查询数据
IMetaDataPK queryPK = new MetaDataPK("com.kingdee.eas.gzw.basedata.app.CentralCorpobyOrgQuery"); IQueryExecutor queryExcutor = QueryExecutorFactory.getRemoteInstance(queryPK); // 设置过滤条件 queryExcutor.setObjectView(viewInfo); //查询出所有满足条件的集合; IRowSet rows=queryExcutor.executeQuery();
36、手动刷新EditUI
if (editData.getId() != null) { com.kingdee.bos.dao.IObjectPK iObjectPk = new ObjectUuidPK(editData.getId()); editData = ((IOtherReceivable) getBizInterface()).getOtherReceivableInfo(iObjectPk, getSelectors()); setDataObject(editData); loadFields(); loadData(); }
37、在分录上添加按钮
// 调用方法 public void onLoad() throws Exception { super.onLoad(); addButtonToHMDEntry(getDetailTable(), btnAudit); } public static void addButtonToHMDEntry(KDTable table, KDWorkButton button) { if (table.getParent() == null || table.getParent().getParent() == null) return; // 隐藏按钮 Component c = table.getParent().getParent(); if (c instanceof DetailPanel) { JPanel panel = (JPanel) c; JPanel controlPanel = null; // 获取controlPanel Component[] components = panel.getComponents(); for (int i = 0; i < components.length; i++) { Component component = components[i]; if ("controlPanel".equals(component.getName())) { controlPanel = (KDPanel) component; } } // 添加btn if (controlPanel != null) { controlPanel.add(button, new com.kingdee.bos.ctrl.swing.KDLayout.Constraints(table.getWidth() - 140, 5, button.getWidth(), 19, 9)); // 9=1+8上右固定,左边缩放} } } }
38、在controllerBean下调用存储过程
--新建存储过程-Oracle create or replace procedure proc_invperiodclose ( projectorg in varchar2 default '' , projectid in varchar2 default '' , periodid in varchar2 default '' , lastperiodid in varchar2 default '' ) as begin --清空缓存表 DELETE FROM tempTable; end proc_invperiodclose;
代码调用
public static Map<String, String> executeStoredProcedure(Context ctx, String proc, String[] params, String[] paramNames, String[] outParamNames) throws BOSException { Connection conn = null; CallableStatement cstmt = null; ResultSet rs = null; Map map = null; try { try { conn = EJBFactory.getConnection(ctx); } catch (Exception e) { e.printStackTrace(); } cstmt = conn.prepareCall(proc); for (int i = 0; i < params.length; ++i) { cstmt.setString(paramNames[i], params[i]); } for (int i = 0; i < outParamNames.length; ++i) { cstmt.registerOutParameter(outParamNames[i], 12); } cstmt.execute(); map = new HashMap(); for (int i = 0; i < outParamNames.length; ++i) { map.put(outParamNames[i], cstmt.getString(outParamNames[i])); } } catch (SQLException exc) { StringBuffer sb = new StringBuffer(""); for (int i = 0; i < params.length; ++i) sb.append("param ").append(i).append(" is:").append(params[i]); throw new BOSException("Sql execute exception : " + proc, exc); } finally { com.kingdee.util.db.SQLUtils.cleanup(rs, cstmt, conn); } return map; } // 系统调用代码 String[] params=new String[]{projectOrg,project,period,lastperiodid}; String[] paramNames=new String[]{"projectorg","projectid","periodid","lastperiodid"}; DBUtils.executeStoredProcedure(ctx, "{call proc_invperiodclose(?,?,?,?)}",params , paramNames, new String[]{});
39、删除已发布流程脚本
注: 1、以下代码需一条一条分步执行执行
2、JKSZLP-0001为发布到流程模版表单编码,请对应修改
3、此语句会删除已经起草的审批流程,请慎用!
--1、删除处理过的工作流任务 select * from T_WFR_AssignDetail where fbizobjid in (select fid from CT_WFB_JSKZLP-0001)delete from T_WFR_AssignDetail where fbizobjid in (select fid from CT_WFB_JSKZLP-0001) --2.查看工作流任务 select * from T_WFR_Assign where fbizobjid in (select fid from CT_WFB_JSKZLP-0001)delete from T_WFR_Assign where fbizobjid in (select fid from CT_WFB_JSKZLP-0001) --3.删除工作流实例 select * from T_WFR_ProcInst where fprocdefname_l2 like '%JSKZLP-0001%'delete from T_WFR_ProcInst where fprocdefname_l2 like '%JSKZLP-0001%' --4.删除所有流程单据 select * from CT_WFB_JSKZLP-0001drop table CT_WFB_JSKZLP-0001 --5.删除流程模板 select * from t_bas_template where fnumber = 'JSKZLP-0001'delete from T_BAS_Template where fnumber = 'JSKZLP-0001'
40、二次开发的目录在子系统树中没有正确显示
1、保证服务器目录eas/servser/properties/下的文件subsystem_bos.xml文件中有二次开发的路径;
2、保证服务器元数据目录eas/server/metas以及eas\server\deploy\fileserver.ear\easWebClient\metas目录下的所有元数据包中只有一份.mdbview文件,且存在与metas/bos/mdbview-metas.jar中,其他jar中的.mdbview文件如果存在,建议将其删除;(具体方法:可以使用类似winrar的压缩工具查找功能,在metas目录下搜索*.mdbview文件)
3、如果服务器eas\server\profiles\server1\config\subsystem目录下存在*.mdbview文件(如果目录不存在,则此步骤忽略),建议确认是否有人在“系统平台-参数配置-子系统树管理”里面有修改过子系统树配置?如果不确定,可以现将该目录下的mdbview文件,备份至其他目录,此目录下文件都清空。
4、重新生成子系统树
41、EAS查询大数据量中断问题
--中断信息:Caused exception message is: fetched too much rows, cell number exceeding limit 1000000. fetched column count:20. fected row count:50000. fected cell count:1000000 [Client -- String Serialize]
解决方法:
1、停止服务器
2、关闭EAS管理控制台
3、eas服务器安装目录eas\admin\config下有个admin.vmoptions文件
需要修改该文件的exceptionCellNumber参数,由原来的1000000改成8000000(因现场需要调整)
4、启动eas管理控制台
5、启动服务