private void doCache(SuperVO vo, Dataset ds, Row row) { ViewContext widgetCtx = getLifeCycleContext().getViewContext(); // 此子表的dsId String dsId = getSlaveDataset(widgetCtx); DatasetRelation[] rels = widgetCtx.getView().getViewModels().getDsrelations().getDsRelations(); if (rels == null) return; String foreignKey = null; for (int i = 0; i < rels.length; i++) { DatasetRelation dsRel = rels[i]; if (dsRel.getDetailDataset().equals(dsId)) { foreignKey = dsRel.getDetailForeignKey(); break; } } if (foreignKey == null) return; String foreignValue = (String) vo.getAttributeValue(foreignKey); List<SuperVO> list = (List<SuperVO>) LfwCacheManager.getSessionCache().get(foreignValue); if (list == null) { list = new ArrayList<SuperVO>(); } list.add(vo); LfwCacheManager.getSessionCache().put(foreignValue, list); // 删除的子表的行信息 String delRowForeignKey = foreignValue + "_" + dsId; List<Row> listDelRow = (List<Row>) LfwCacheManager.getSessionCache().get(delRowForeignKey); if (listDelRow == null) { listDelRow = new ArrayList<Row>(); } listDelRow.add(row); LfwCacheManager.getSessionCache().put(delRowForeignKey, listDelRow); }
public void execute() { ViewContext widgetctx = getLifeCycleContext().getViewContext(); String dsId = getSlaveDataset(widgetctx); Dataset ds = widgetctx.getView().getViewModels().getDataset(dsId); Row selRow = ds.getSelectedRow(); // 未选择行,给出提示 if (selRow == null) throw new LfwRuntimeException("请选择要删除的行!"); // 持久化 Dataset2SuperVOSerializer ser = new Dataset2SuperVOSerializer(); SuperVO vo = ser.serialize(ds, selRow)[0]; if (vo.getPrimaryKey() == null) delete = true; if (delete) doDeleteVO(vo); else doCache(vo, ds, selRow); if (selRow != null) { int rowIndex = ds.getRowIndex(selRow); ds.removeRow(rowIndex); if (rowIndex > ds.getCurrentRowCount() - 1) rowIndex = ds.getCurrentRowCount() - 1; ds.setRowSelectIndex(rowIndex); } doAfterDelLine(); }
private String getRefTableName(Dataset refDs) { String superClazz = refDs.getVoMeta(); SuperVO vo = (SuperVO) LfwClassUtil.newInstance(superClazz); return vo.getTableName(); }
@Override public DapMsgVO getDapVO(AggregatedValueObject billVo, String opType) throws BusinessException { SuperVO superVO = (SuperVO) billVo.getParentVO(); DapMsgVO msgVo = new DapMsgVO(); msgVo.setBillCode((String) superVO.getAttributeValue(ReturnVO.VBILLNO)); msgVo.setChecker((String) superVO.getAttributeValue(ReturnVO.VAPPROVEID)); msgVo.setSys(FbmBusConstant.SYSCODE_FBM); msgVo.setDestSystem(IAccountPlat.DESTSYS_GL); msgVo.setCorp((String) superVO.getAttributeValue(ReturnVO.PK_CORP)); if (FbmBusConstant.OP_VOUCHER.equals(opType)) { msgVo.setComment( nc.vo.ml.NCLangRes4VoTransl.getNCLangRes() .getStrByID("3620add", "UPP3620ADD-000167") /*@res "票据退票制证"*/); msgVo.setMsgType(DapMsgVO.ADDMSG); // 设置为增加消息 } else { msgVo.setComment( nc.vo.ml.NCLangRes4VoTransl.getNCLangRes() .getStrByID("3620add", "UPP3620ADD-000168") /*@res "票据退票取消制证"*/); msgVo.setMsgType(DapMsgVO.DELMSG); // 设置为删除消息 } msgVo.setProc((String) superVO.getAttributeValue(ReturnVO.PK_BILLTYPECODE)); msgVo.setOperator((String) superVO.getAttributeValue(ReturnVO.VOPERATORID)); msgVo.setProcMsg(superVO.getPrimaryKey()); msgVo.setBusiDate((UFDate) superVO.getAttributeValue(ReturnVO.DAPPROVEDATE)); // 设置业务日期为审核日期 ReturnBillServiceImpl srv = new ReturnBillServiceImpl(); msgVo.setMoney(srv.sumMoneyy(billVo)); ReturnBVO[] bvos = (ReturnBVO[]) billVo.getChildrenVO(); msgVo.setCurrency(bvos[0].getPk_curr()); CurrencyPublicUtil currencyPublicUtil = new CurrencyPublicUtil((String) superVO.getAttributeValue(ReturnVO.PK_CORP)); currencyPublicUtil.setPk_currtype_y(bvos[0].getPk_curr()); UFDouble[] fbrate = currencyPublicUtil.getExchangeRate( String.valueOf(superVO.getAttributeValue(ReturnVO.DVOUCHERDATE))); for (int i = 0; i < bvos.length; i++) { UFDouble[] yfbmoney = currencyPublicUtil.getYfbMoney( bvos[i].getMoneyy(), String.valueOf(superVO.getAttributeValue(ReturnVO.DVOUCHERDATE))); bvos[i].setMoneyb(yfbmoney[2]); bvos[i].setBrate(fbrate[1]); } return msgVo; }
public StorageDataSet getDataSetBySuperVos(SuperVO[] vos, int digit, Class cls) throws BusinessException { int iRowCount = (vos == null) ? 0 : vos.length; SuperVO vo = null; if (iRowCount == 0) { // 查询数据为空,必须构造column // System.out.println("DatasetUtil.getDatasetByCAVOs:行数为0"); try { vo = (SuperVO) cls.newInstance(); } catch (Exception e) { throw new BusinessException(e); } } else { vo = vos[0]; cls = vo.getClass(); } // 反射获得类属性信息 QEDataSet sds = new QEDataSet(); try { String names[] = vo.getAttributeNames(); String realnames[] = null; if (vo instanceof IVarNameDefine) { realnames = ((IVarNameDefine) vo).getVaribleNames(); } // 获得列数 int iColCount = (names == null) ? 0 : names.length; Vector vecName = new Vector(); Vector vecCol = new Vector(); for (int i = 0; i < iColCount; i++) { try { // 创建列 Column col = new Column(); if (!CommonUtil.isNull(realnames) && !CommonUtil.isNull(realnames[i])) { col.setCaption(realnames[i]); col.setColumnName(names[i]); // 记录 vecName.addElement(names[i]); vecCol.addElement(col); // 获得列类型 Field fld = null; try { fld = cls.getField(names[i]); } catch (NoSuchFieldException e) { throw new BusinessException(e); } int iType = class2VariantType(fld.getType()); /* * int iType = Variant.STRING; Object obj = * vos[0].getAttributeValue(names[i]); if (obj != null && * obj.getClass().getSuperclass() == Number.class) iType = * Variant.DOUBLE; */ col.setDataType(iType); } } catch (Exception e) { throw new BusinessException(e); } } // 获得有效列数 iColCount = vecName.size(); if (iColCount == 0) { // System.out.println("DatasetUtil.getDatasetByCAVOs:列数为0"); return null; } // 重构列名数组和列数组 names = new String[iColCount]; vecName.copyInto(names); Column[] cols = new Column[iColCount]; vecCol.copyInto(cols); // 转换 sds = new QEDataSet(); sds.setColumns(cols); sds.open(); for (int i = 0; i < iRowCount; i++) { // 构造数据行 DataRow row = new DataRow(sds); for (int j = 0; j < iColCount; j++) { Object obj = vos[i].getAttributeValue(names[j]); String str = (obj == null) ? null : obj.toString(); int iColType = cols[j].getDataType(); // 填充数据行 DatasetUtil.makeDataRow(row, str, j, iColType); row = row; } // 加行 sds.addRow(row); } sds.first(); } catch (Exception e) { throw new BusinessException(e); } return sds; }