diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleEditPluginExt.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleEditPluginExt.java index be8c492..17bfa98 100644 --- a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleEditPluginExt.java +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/OutContractSettleEditPluginExt.java @@ -5,588 +5,25 @@ package zcgj.zcdev.zcdev.pr.plugin.form; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.ArrayList; -import java.util.Date; -import java.util.EventObject; -import java.util.Iterator; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; -import kd.bos.bill.AbstractBillPlugIn; import kd.bos.bill.BillShowParameter; +import kd.bos.bill.OperationStatus; import kd.bos.dataentity.entity.DynamicObject; -import kd.bos.dataentity.entity.DynamicObjectCollection; -import kd.bos.dataentity.resource.ResManager; import kd.bos.dataentity.utils.StringUtils; -import kd.bos.entity.datamodel.IDataModel; -import kd.bos.entity.datamodel.ListSelectedRow; -import kd.bos.entity.datamodel.ListSelectedRowCollection; import kd.bos.entity.datamodel.events.ChangeData; -import kd.bos.entity.datamodel.events.PropertyChangedArgs; -import kd.bos.entity.report.FilterInfo; -import kd.bos.entity.report.ReportQueryParam; -import kd.bos.form.CloseCallBack; -import kd.bos.form.ConfirmCallBackListener; -import kd.bos.form.MessageBoxOptions; -import kd.bos.form.MessageBoxResult; -import kd.bos.form.ShowFormHelper; -import kd.bos.form.ShowType; -import kd.bos.form.control.EntryGrid; -import kd.bos.form.events.AfterDoOperationEventArgs; -import kd.bos.form.events.BeforeDoOperationEventArgs; -import kd.bos.form.events.ClosedCallBackEvent; -import kd.bos.form.events.HyperLinkClickEvent; -import kd.bos.form.events.HyperLinkClickListener; -import kd.bos.form.events.MessageBoxClosedEvent; -import kd.bos.form.field.BasedataEdit; -import kd.bos.form.field.events.BeforeF7SelectEvent; -import kd.bos.form.field.events.BeforeF7SelectListener; -import kd.bos.form.operate.FormOperate; -import kd.bos.form.plugin.AbstractFormPlugin; -import kd.bos.list.ListShowParameter; -import kd.bos.orm.query.QFilter; -import kd.bos.report.ReportShowParameter; -import kd.bos.servicehelper.BusinessDataServiceHelper; -import kd.ec.basedata.business.model.ecma.ReconciliationConstant; -import kd.ec.basedata.common.enums.BillStatusEnum; -import kd.ec.basedata.common.utils.EcDateUtils; +import kd.ec.contract.formplugin.settle.OutContractSettleEditPlugin; import kd.ec.contract.utils.SettleUpdateAmtUtils; -import org.apache.commons.beanutils.ConvertUtils; -import org.apache.commons.collections.CollectionUtils; + +import java.util.EventObject; /* * 支出合同结算单系统插件二开 */ -public class OutContractSettleEditPluginExt extends AbstractBillPlugIn implements HyperLinkClickListener, BeforeF7SelectListener { - private static final String TREE_CONTROL_PROJECT = "treecontrolproject"; - private static final String TREE_CONTROL_UNITPROJECT = "treecontrolunitproject"; - private static final String EQ_SETTLE_PAGE_CACHED = "eqSettleChanged"; - private static final String MEASUREITEM_ID = "506427748873442304"; - +public class OutContractSettleEditPluginExt extends OutContractSettleEditPlugin { public OutContractSettleEditPluginExt() { + super(); } - public void beforeDoOperation(BeforeDoOperationEventArgs args) { - super.beforeDoOperation(args); - FormOperate operate = (FormOperate)args.getSource(); - String operateKey = operate.getOperateKey(); - if (StringUtils.equals(operateKey, "addmaterialin") && this.validateContractAndDate()) { - this.addMaterialIn(); - } else if (StringUtils.equals(operateKey, "autofetch") && this.validateContractAndDate()) { - this.autoFetch(); - } else if (StringUtils.equals(operateKey, "settlestatistics")) { - this.settleStatistics(); - } else if (StringUtils.equals(operateKey, "addreconc") && this.validateContractAndDate()) { - this.addReconciliation(); - } else if (StringUtils.equals(operateKey, "addeqentry") && this.validateContractAndDate()) { - this.openEqSettle(); - } - - } - - protected void addReconciliation() { - DynamicObject purchaseContract = (DynamicObject)this.getModel().getValue("contract"); - if (purchaseContract == null) { - this.getView().showTipNotification(ResManager.loadKDString("请选择“合同”。", "OutContractSettleEditPlugin_0", "ec-contract-formplugin", new Object[0])); - } else { - DynamicObject period = (DynamicObject)this.getModel().getValue("period"); - if (period == null) { - this.getView().showTipNotification(ResManager.loadKDString("请选择“结算期间”。", "OutContractSettleEditPlugin_1", "ec-contract-formplugin", new Object[0])); - } else { - ListShowParameter reconciliationParam = ShowFormHelper.createShowListForm("ecma_reconciliation", true); - int rowCount = this.getModel().getEntryRowCount("reconcentry"); - List billIds = new ArrayList(rowCount); - - for(int index = 0; index < rowCount; ++index) { - String billId = (String)this.getModel().getValue("reconcbillid", index); - billIds.add(StringUtils.isEmpty(billId) ? 0L : Long.valueOf(billId)); - } - - QFilter filter = new QFilter("id", "not in", billIds); - filter.and("period.enddate", "<=", period.getDate("enddate")); - filter.and("issettled", "=", "0"); - DynamicObject supplier = purchaseContract.getDynamicObject("partb"); - filter.and("supplier", "=", supplier == null ? 0L : supplier.getPkValue()); - filter.and("billstatus", "=", BillStatusEnum.AUDIT.getValue()); - filter.and(this.getReconcileContractFilter(purchaseContract)); - DynamicObject[] reconciliationBills = BusinessDataServiceHelper.load("ecma_reconciliation", "billno,billname,reconciledate,period,totalreconcileamount,totalreconciletax,totalreconcileoftax,totalreconcilediffoftax,materialinbills", new QFilter[]{filter}); - if (reconciliationBills != null && reconciliationBills.length > 0) { - for(int i = 0; i < reconciliationBills.length; ++i) { - DynamicObject bill = reconciliationBills[i]; - String materialinbills = bill.getString("materialinbills"); - String[] ids = materialinbills.split(";"); - long[] materialinIds = (long[])((long[])ConvertUtils.convert(ids, Long.TYPE)); - DynamicObject[] materialInBills = BusinessDataServiceHelper.load("ecma_materialinbill", "settlestatus", new QFilter[]{new QFilter("id", "in", materialinIds)}); - - for(int j = 0; j < materialInBills.length; ++j) { - if (materialInBills[j].getBoolean("settlestatus")) { - billIds.add(Long.valueOf(bill.getPkValue().toString())); - break; - } - } - } - } - - reconciliationParam.getListFilterParameter().getQFilters().add(filter); - reconciliationParam.setFormId("bos_listf7"); - CloseCallBack callBack = new CloseCallBack(this, "addreconc"); - reconciliationParam.setCloseCallBack(callBack); - this.getView().showForm(reconciliationParam); - } - } - } - - protected QFilter getReconcileContractFilter(DynamicObject purchaseContract) { - QFilter contractTypeFilter = new QFilter("reconciletype", "=", "A"); - contractTypeFilter.and("contract", "=", purchaseContract.getPkValue()); - QFilter purchaseTypeFilter = new QFilter("reconciletype", "=", "B"); - purchaseTypeFilter.and("purchaseorder.contract", "=", purchaseContract.getPkValue()); - return contractTypeFilter.or(purchaseTypeFilter); - } - - public void registerListener(EventObject e) { - super.registerListener(e); - EntryGrid materialInEntry = (EntryGrid)this.getControl("materialinentry"); - materialInEntry.addHyperClickListener(this); - EntryGrid reconciliationEntry = (EntryGrid)this.getControl("reconcentry"); - reconciliationEntry.addHyperClickListener(this); - EntryGrid eqSettleEntry = (EntryGrid)this.getControl("eqsettleentry"); - eqSettleEntry.addHyperClickListener(this); - BasedataEdit itemCbsEdit = (BasedataEdit)this.getControl("itemcbs"); - itemCbsEdit.addBeforeF7SelectListener(this); - BasedataEdit itemBoqEdit = (BasedataEdit)this.getControl("itemboq"); - itemBoqEdit.addBeforeF7SelectListener(this); - BasedataEdit unitProjectEdit = (BasedataEdit)this.getControl("itemunitproject"); - unitProjectEdit.addBeforeF7SelectListener(this); - BasedataEdit listCbsEdit = (BasedataEdit)this.getControl("listcbs"); - listCbsEdit.addBeforeF7SelectListener(this); - BasedataEdit listBoqEdit = (BasedataEdit)this.getControl("listboq"); - listBoqEdit.addBeforeF7SelectListener(this); - } - - protected void settleStatistics() { - ReportShowParameter rsp = new ReportShowParameter(); - ReportQueryParam queryParam = new ReportQueryParam(); - FilterInfo filterInfo = new FilterInfo(); - DynamicObjectCollection inEntry = this.getModel().getEntryEntity("materialinentry"); - if (inEntry != null && inEntry.size() != 0) { - Set inBillSet = (Set)inEntry.stream().map((bill) -> { - return Long.valueOf(bill.getString("materialinbillid")); - }).collect(Collectors.toSet()); - filterInfo.addFilterItem("settle", inBillSet); - queryParam.setFilter(filterInfo); - rsp.setQueryParam(queryParam); - rsp.setFormId("ecma_settlestattrpt"); - rsp.getOpenStyle().setShowType(ShowType.MainNewTabPage); - this.getView().showForm(rsp); - } else { - this.getView().showTipNotification(ResManager.loadKDString("当前入库单为空,无法查看结算统计。", "OutContractSettleEditPlugin_2", "ec-contract-formplugin", new Object[0])); - } - } - - protected void autoFetch() { - DynamicObject purchaseContract = (DynamicObject)this.getModel().getValue("contract"); - Object endDate = this.getModel().getValue("enddate"); - DynamicObject period = (DynamicObject)this.getModel().getValue("period"); - if (period == null) { - this.getView().showTipNotification(ResManager.loadKDString("请选择“结算期间”。", "OutContractSettleEditPlugin_1", "ec-contract-formplugin", new Object[0])); - } else { - Date periodEndDate = period.getDate("enddate"); - QFilter qFilter = this.getNotSettleMaterialInBillFilter(purchaseContract, periodEndDate); - DynamicObject[] materialInBills = BusinessDataServiceHelper.load("ecma_materialinbill", "billno,billname,bizdate,period,matamount,matoftaxamount,transamount,transoftaxamount", new QFilter[]{qFilter}); - this.getModel().deleteEntryData("materialinentry"); - if (materialInBills.length == 0) { - this.getView().showTipNotification(ResManager.loadKDString("没有对应的数据。", "OutContractSettleEditPlugin_3", "ec-contract-formplugin", new Object[0])); - } else { - this.fillMaterialInEntry(materialInBills); - } - } - } - - protected void fillMaterialInEntry(DynamicObject[] materialInBills) { - if (materialInBills != null && materialInBills.length > 0) { - int[] rowIndexes = this.getModel().batchCreateNewEntryRow("materialinentry", materialInBills.length); - - for(int i = 0; i < materialInBills.length; ++i) { - this.getModel().setValue("bizdate", materialInBills[i].getDate("bizdate"), rowIndexes[i]); - this.getModel().setValue("materialinbillid", materialInBills[i].getPkValue().toString(), rowIndexes[i]); - this.getModel().setValue("matinname", materialInBills[i].getString("billname"), rowIndexes[i]); - this.getModel().setValue("matinnumber", materialInBills[i].getString("billno"), rowIndexes[i]); - this.getModel().setValue("matinperiod", materialInBills[i].getDynamicObject("period").getPkValue(), rowIndexes[i]); - this.getModel().setValue("matnotaxamount", materialInBills[i].getBigDecimal("matamount"), rowIndexes[i]); - this.getModel().setValue("mattaxamount", materialInBills[i].getBigDecimal("matoftaxamount"), rowIndexes[i]); - this.getModel().setValue("transnotaxamount", materialInBills[i].getBigDecimal("transamount"), rowIndexes[i]); - this.getModel().setValue("transtaxamount", materialInBills[i].getBigDecimal("transoftaxamount"), rowIndexes[i]); - } - } - - } - - protected void addMaterialIn() { - DynamicObject purchaseContract = (DynamicObject)this.getModel().getValue("contract"); - Object endDate = this.getModel().getValue("enddate"); - DynamicObject period = (DynamicObject)this.getModel().getValue("period"); - if (period == null) { - this.getView().showTipNotification(ResManager.loadKDString("请选择“结算期间”。", "OutContractSettleEditPlugin_1", "ec-contract-formplugin", new Object[0])); - } else { - Date periodEndDate = period.getDate("enddate"); - ListShowParameter materialInParameter = ShowFormHelper.createShowListForm("ecma_materialinbill", true); - int materialInRowCount = this.getModel().getEntryRowCount("materialinentry"); - List materialInBillIds = new ArrayList(materialInRowCount); - - for(int index = 0; index < materialInRowCount; ++index) { - String materialInBillId = (String)this.getModel().getValue("materialinbillid", index); - Long longMaterialInId = Long.valueOf(materialInBillId); - materialInBillIds.add(longMaterialInId); - } - - materialInParameter.getListFilterParameter().getQFilters().add(new QFilter("id", "not in", materialInBillIds)); - materialInParameter.getListFilterParameter().getQFilters().add(this.getNotSettleMaterialInBillFilter(purchaseContract, periodEndDate)); - materialInParameter.setFormId("bos_listf7"); - CloseCallBack addMaterialInCallBack = new CloseCallBack(this, "addmaterialin"); - materialInParameter.setCloseCallBack(addMaterialInCallBack); - this.getView().showForm(materialInParameter); - } - } - - protected QFilter getNotSettleMaterialInBillFilter(DynamicObject contract, Object endDate) { - DynamicObject partB = contract.getDynamicObject("partb"); - QFilter qFilter = new QFilter("supplier", "=", partB.getPkValue()); - qFilter.and(new QFilter("contract", "=", contract.getPkValue())); - qFilter.and(new QFilter("period.enddate", "<=", endDate)); - qFilter.and(new QFilter("settlestatus", "=", "0")); - qFilter.and(new QFilter("ismeasure", "=", "0")); - qFilter.and(new QFilter("billstatus", "=", "C")); - return qFilter; - } - - protected boolean validateContractAndDate() { - DynamicObject purchaseContract = (DynamicObject)this.getModel().getValue("contract"); - Object endDate = this.getModel().getValue("enddate"); - if (purchaseContract == null && endDate == null) { - this.getView().showTipNotification(ResManager.loadKDString("请选择合同和结束日期。", "OutContractSettleEditPlugin_4", "ec-contract-formplugin", new Object[0])); - return false; - } else if (purchaseContract == null) { - this.getView().showTipNotification(ResManager.loadKDString("请选择合同。", "OutContractSettleEditPlugin_5", "ec-contract-formplugin", new Object[0])); - return false; - } else if (endDate == null) { - this.getView().showTipNotification(ResManager.loadKDString("请选择结束日期。", "OutContractSettleEditPlugin_6", "ec-contract-formplugin", new Object[0])); - return false; - } else { - return true; - } - } - - public void afterDoOperation(AfterDoOperationEventArgs e) { - super.afterDoOperation(e); - String key = e.getOperateKey(); - if (!StringUtils.equals(key, "deleteentry") && !StringUtils.equals(key, "autofetch")) { - if (StringUtils.equals(key, "deletereconc")) { - this.sumReconciliationAmountToItemEntry(); - SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); - } else if (StringUtils.equals(key, "deleteeqentry")) { - this.sumEquipmentSettleToItemEntry(); - } - } else { - this.sumMaterialInAmountToItemEntry(); - SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); - } - - } - - protected void sumReconciliationAmountToItemEntry() { - this.getModel().updateCache(); - DynamicObjectCollection reconcEntries = this.getModel().getEntryEntity("reconcentry"); - if (reconcEntries != null && reconcEntries.size() != 0) { - BigDecimal amount = BigDecimal.ZERO; - BigDecimal ofTaxAmount = BigDecimal.ZERO; - - BigDecimal reconcOfTax; - for(Iterator var4 = reconcEntries.iterator(); var4.hasNext(); ofTaxAmount = ofTaxAmount.add(reconcOfTax)) { - DynamicObject reconcData = (DynamicObject)var4.next(); - reconcOfTax = reconcData.getBigDecimal("reconcoftax"); - BigDecimal reconcAmount = reconcData.getBigDecimal("reconcamount"); - amount = amount.add(reconcAmount); - } - - this.getModel().setValue("oftaxamount", ofTaxAmount, 0); - this.getModel().setValue("amount", amount, 0); - if (BigDecimal.ZERO.compareTo(amount) != 0) { - this.getPageCache().put("ignoreRateChanged", "1"); - this.getModel().setValue("rate", ofTaxAmount.subtract(amount).divide(amount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)), 0); - } - - this.getModel().setValue("taxamt", ofTaxAmount.subtract(amount), 0); - } else { - this.getModel().setValue("oftaxamount", 0, 0); - DynamicObject taxRate = this.getModel().getDataEntity().getDynamicObject("taxrate"); - if (taxRate != null) { - this.getModel().setValue("rate", taxRate.getBigDecimal("taxrate"), 0); - } - - this.getModel().setValue("taxamt", 0, 0); - } - - } - - protected void sumMaterialInAmountToItemEntry() { - this.getModel().updateCache(); - DynamicObjectCollection materialInEntry = this.getModel().getEntryEntity("materialinentry"); - if (materialInEntry != null && materialInEntry.size() != 0) { - BigDecimal amount = BigDecimal.ZERO; - BigDecimal ofTaxAmount = BigDecimal.ZERO; - boolean isSettleTrans = false; - BigDecimal transAmount = BigDecimal.ZERO; - BigDecimal transOfTaxAmount = BigDecimal.ZERO; - Iterator var7 = materialInEntry.iterator(); - - DynamicObject transSettleItem; - while(var7.hasNext()) { - transSettleItem = (DynamicObject)var7.next(); - BigDecimal materialTaxAmount = transSettleItem.getBigDecimal("mattaxamount"); - BigDecimal materialNoTaxAmount = transSettleItem.getBigDecimal("matnotaxamount"); - amount = amount.add(materialNoTaxAmount); - ofTaxAmount = ofTaxAmount.add(materialTaxAmount); - boolean settleTrans = transSettleItem.getBoolean("istranssettle"); - if (settleTrans) { - BigDecimal transTaxAmount = transSettleItem.getBigDecimal("transtaxamount"); - BigDecimal transNoTaxAmount = transSettleItem.getBigDecimal("transnotaxamount"); - transAmount = transAmount.add(transNoTaxAmount); - transOfTaxAmount = transOfTaxAmount.add(transTaxAmount); - isSettleTrans = true; - } - } - - this.getModel().setValue("oftaxamount", ofTaxAmount, 0); - this.getModel().setValue("amount", amount, 0); - if (BigDecimal.ZERO.compareTo(amount) != 0) { - this.getPageCache().put("ignoreRateChanged", "1"); - this.getModel().setValue("rate", ofTaxAmount.subtract(amount).divide(amount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)), 0); - } - - this.getModel().setValue("taxamt", ofTaxAmount.subtract(amount), 0); - int entryRowCount = this.getModel().getEntryRowCount("itementry"); - if (entryRowCount <= 1) { - if (isSettleTrans) { - this.getModel().insertEntryRow("itementry", 1); - this.getModel().setValue("payitem", "760004250343646208", 1); - this.fillItemEntryCbs(1); - } - } else { - transSettleItem = this.getModel().getEntryRowEntity("itementry", 1); - DynamicObject payItem = transSettleItem.getDynamicObject("payitem"); - boolean hasSettleTrans = "YFJS".equals(payItem.getString("number")); - if (isSettleTrans && !hasSettleTrans) { - this.getModel().insertEntryRow("itementry", 1); - this.getModel().setValue("payitem", "760004250343646208", 1); - this.fillItemEntryCbs(1); - } else if (!isSettleTrans && hasSettleTrans) { - this.getModel().setValue("oftaxamount", transOfTaxAmount, 1); - this.getModel().setValue("amount", transAmount, 1); - this.getModel().deleteEntryRow("itementry", 1); - } - } - - if (isSettleTrans) { - this.getModel().setValue("oftaxamount", transOfTaxAmount, 1); - this.getModel().setValue("amount", transAmount, 1); - if (BigDecimal.ZERO.compareTo(transAmount) != 0) { - this.getModel().setValue("rate", transOfTaxAmount.subtract(transAmount).divide(transAmount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)), 1); - } - - this.getModel().setValue("taxamt", transOfTaxAmount.subtract(transAmount), 1); - } - } else { - int entryRowCount = this.getModel().getEntryRowCount("itementry"); - DynamicObject taxRate; - if (entryRowCount > 1) { - taxRate = this.getModel().getEntryRowEntity("itementry", 1); - DynamicObject payItem = taxRate.getDynamicObject("payitem"); - if (payItem != null && "YFJS".equals(payItem.getString("number"))) { - this.getModel().deleteEntryRow("itementry", 1); - } - } - - this.getModel().setValue("oftaxamount", 0, 0); - taxRate = this.getModel().getDataEntity().getDynamicObject("taxrate"); - if (taxRate != null) { - this.getModel().setValue("rate", taxRate.getBigDecimal("taxrate"), 0); - } - - this.getModel().setValue("taxamt", 0, 0); - } - - } - - protected void fillItemEntryCbs(int row) { - DynamicObject cbs = this.getNeedFillCbs(); - if (cbs != null && !(Boolean)this.getModel().getValue("isonlist")) { - this.getModel().setValue("itemcbs", cbs.getPkValue(), row); - } - - } - - protected DynamicObject getNeedFillCbs() { - DynamicObject project = this.getModel().getDataEntity().getDynamicObject("project"); - DynamicObject contract = this.getModel().getDataEntity().getDynamicObject("contract"); - if (project != null && contract != null) { - boolean isBudgetControl = project.getBoolean("budgetcontrol"); - String controlModel = project.getString("costcontrolmodel"); - if (isBudgetControl && controlModel.contains("1")) { - return contract.getDynamicObject("cbs"); - } - } - - return null; - } - - public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) { - super.closedCallBack(closedCallBackEvent); - String actionId = closedCallBackEvent.getActionId(); - if ("addmaterialin".equals(actionId)) { - this.materialInBillClosedCallBack(closedCallBackEvent); - } else if (StringUtils.equals(actionId, "addreconc")) { - this.reconciliationCallBack(closedCallBackEvent); - } else if (StringUtils.equals(actionId, "addeqentry")) { - this.equipmentSettleCallBack(closedCallBackEvent); - } - - } - - protected void reconciliationCallBack(ClosedCallBackEvent closedCallBackEvent) { - ListSelectedRowCollection rows = (ListSelectedRowCollection)closedCallBackEvent.getReturnData(); - if (rows != null && rows.size() > 0) { - List returnIds = (List)rows.stream().map(ListSelectedRow::getPrimaryKeyValue).collect(Collectors.toList()); - QFilter qFilter = new QFilter("id", "in", returnIds); - DynamicObject[] reconciliationBills = BusinessDataServiceHelper.load("ecma_reconciliation", "billno,billname,reconciledate,period,totalreconcileamount,totalreconciletax,totalreconcileoftax,totalreconcilediffoftax,materialinbills", new QFilter[]{qFilter}); - this.fillReconciliationEntry(reconciliationBills); - this.sumReconciliationAmountToItemEntry(); - SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); - } - } - - protected void fillReconciliationEntry(DynamicObject[] reconciliationBills) { - if (reconciliationBills != null && reconciliationBills.length > 0) { - for(int i = 0; i < reconciliationBills.length; ++i) { - DynamicObject bill = reconciliationBills[i]; - String materialinbills = bill.getString("materialinbills"); - String[] ids = materialinbills.split(";"); - long[] materialinIds = (long[])((long[])ConvertUtils.convert(ids, Long.TYPE)); - DynamicObject[] materialInBills = BusinessDataServiceHelper.load("ecma_materialinbill", "settlestatus", new QFilter[]{new QFilter("id", "in", materialinIds)}); - boolean isSettles = false; - - int index; - for(index = 0; index < materialInBills.length; ++index) { - if (materialInBills[index].getBoolean("settlestatus")) { - isSettles = true; - break; - } - } - - if (!isSettles) { - index = this.getModel().createNewEntryRow("reconcentry"); - this.getModel().setValue("reconcnumber", bill.getString("billno"), index); - this.getModel().setValue("reconcname", bill.getLocaleString("billname").getLocaleValue(), index); - this.getModel().setValue("reconcdate", bill.getDate("reconciledate"), index); - this.getModel().setValue("reconcperiod", bill.getDynamicObject("period").getPkValue(), index); - this.getModel().setValue("reconcamount", bill.getBigDecimal("totalreconcileamount"), index); - this.getModel().setValue("reconctax", bill.getBigDecimal("totalreconciletax"), index); - this.getModel().setValue("reconcoftax", bill.getBigDecimal("totalreconcileoftax"), index); - this.getModel().setValue("reconcdiffamount", bill.getBigDecimal("totalreconcilediffoftax"), index); - this.getModel().setValue("reconcbillid", bill.getString(ReconciliationConstant.ID_ENTITY_PK), index); - } - } - } - - } - - protected void materialInBillClosedCallBack(ClosedCallBackEvent closedCallBackEvent) { - ListSelectedRowCollection rows = (ListSelectedRowCollection)closedCallBackEvent.getReturnData(); - if (rows != null && rows.size() > 0) { - List returnIds = (List)rows.stream().map(ListSelectedRow::getPrimaryKeyValue).collect(Collectors.toList()); - QFilter qFilter = new QFilter("id", "in", returnIds); - DynamicObject[] materialInBills = BusinessDataServiceHelper.load("ecma_materialinbill", "billno,billname,bizdate,period,matamount,matoftaxamount,transamount,transoftaxamount", new QFilter[]{qFilter}); - this.fillMaterialInEntry(materialInBills); - this.sumMaterialInAmountToItemEntry(); - SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); - } - } - - public void propertyChanged(PropertyChangedArgs e) { - String name = e.getProperty().getName(); - ChangeData changeData = e.getChangeSet()[0]; - if (StringUtils.equals(name, "issettlebymatin")) { - this.isSettleByMaterialInChanged(changeData); - } else if (StringUtils.equals(name, "istranssettle")) { - this.sumMaterialInAmountToItemEntry(); - SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); - } else if (StringUtils.equals(name, "itemboq")) { - this.itemBoqChanged(changeData); - } else if (StringUtils.equals(name, "itemunitproject")) { - this.itemUnitProjectChanged(changeData); - } else if (StringUtils.equals(name, "contract")) { - this.contractChanged(changeData); - } else if (StringUtils.equals(name, "issettlebyreconc")) { - this.isSettleByReconciliationChanged(changeData); - } else if (StringUtils.equals(name, "period")) { - this.periodChanged(changeData); - } else if (StringUtils.equals(name, "iseqsettle")) { - this.isEqSettleChanged(changeData); - } - - } - - protected void periodChanged(ChangeData changeData) { - boolean isSettleByReconciliation = (Boolean)this.getModel().getValue("issettlebyreconc"); - if (isSettleByReconciliation) { - this.getModel().deleteEntryData("reconcentry"); - this.autoFillReconciliationData(); - } - - boolean isSettleByMatin = (Boolean)this.getModel().getValue("issettlebymatin"); - if (isSettleByMatin) { - this.getModel().deleteEntryData("materialinentry"); - this.sumMaterialInAmountToItemEntry(); - SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); - } - - boolean isEqSettle = (Boolean)this.getModel().getValue("iseqsettle"); - if (isEqSettle) { - this.isEqSettleChanged((ChangeData)null); - } - - } - - protected void isSettleByReconciliationChanged(ChangeData changeData) { - this.getModel().deleteEntryData("reconcentry"); - boolean newValue = (Boolean)changeData.getNewValue(); - if (newValue) { - this.getModel().setValue("issettlebymatin", false); - this.autoFillReconciliationData(); - } - - } - - protected void autoFillReconciliationData() { - DynamicObject purchaseContract = (DynamicObject)this.getModel().getValue("contract"); - DynamicObject period = (DynamicObject)this.getModel().getValue("period"); - if (period != null && purchaseContract != null) { - QFilter filter = new QFilter("period.enddate", "<=", period.getDate("enddate")); - filter.and("issettled", "=", "0"); - filter.and("billstatus", "=", BillStatusEnum.AUDIT.getValue()); - DynamicObject supplier = purchaseContract.getDynamicObject("partb"); - filter.and("supplier", "=", supplier == null ? 0L : supplier.getPkValue()); - filter.and(this.getReconcileContractFilter(purchaseContract)); - DynamicObject[] reconciliationBills = BusinessDataServiceHelper.load("ecma_reconciliation", "billno,billname,reconciledate,period,totalreconcileamount,totalreconciletax,totalreconcileoftax,totalreconcilediffoftax,materialinbills", new QFilter[]{filter}); - this.fillReconciliationEntry(reconciliationBills); - this.sumReconciliationAmountToItemEntry(); - SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); - } - } - + @Override protected void contractChanged(ChangeData changeData) { this.getModel().setValue("issettlebymatin", false); this.getModel().deleteEntryData("materialinentry"); @@ -631,421 +68,24 @@ public class OutContractSettleEditPluginExt extends AbstractBillPlugIn implement } } - protected void itemUnitProjectChanged(ChangeData changeData) { - int rowIndex = changeData.getRowIndex(); - DynamicObject newValue = (DynamicObject)changeData.getNewValue(); - long newUnitId = newValue == null ? 0L : newValue.getLong("id"); - DynamicObject boq = (DynamicObject)this.getModel().getValue("itemboq", rowIndex); - DynamicObject boqUnitProject = boq == null ? null : boq.getDynamicObject("unitproject"); - long boqUnitId = boqUnitProject == null ? 0L : boqUnitProject.getLong("id"); - if (newUnitId != boqUnitId) { - this.getModel().setValue("itemboq", (Object)null, rowIndex); - } - - } - - protected void itemBoqChanged(ChangeData changeData) { - DynamicObject newValue = (DynamicObject)changeData.getNewValue(); - int rowIndex = changeData.getRowIndex(); - DynamicObject boqUnitProject = newValue == null ? null : newValue.getDynamicObject("unitproject"); - long boqUnitId = boqUnitProject == null ? 0L : boqUnitProject.getLong("id"); - DynamicObject unitProject = (DynamicObject)this.getModel().getValue("itemunitproject", rowIndex); - long unitId = unitProject == null ? 0L : unitProject.getLong("id"); - if (unitId != boqUnitId) { - this.getModel().setValue("itemunitproject", boqUnitId, rowIndex); - } - - } - - protected void isSettleByMaterialInChanged(ChangeData changeData) { - boolean isSettleByMaterialIn = (Boolean)changeData.getNewValue(); - this.initItemEntry(isSettleByMaterialIn); - if (!isSettleByMaterialIn) { - this.getModel().deleteEntryData("materialinentry"); - } else { - this.getModel().setValue("issettlebyreconc", false); - } - - } - - protected void initItemEntry(boolean isSettleByMaterialIn) { - int entryRowCount = this.getModel().getEntryRowCount("itementry"); - if (!isSettleByMaterialIn) { - if (entryRowCount <= 1) { - return; - } - - DynamicObject transSettleItem = this.getModel().getEntryRowEntity("itementry", 1); - DynamicObject payItem = transSettleItem.getDynamicObject("payitem"); - if ("YFJS".equals(payItem.getString("number"))) { - this.getModel().deleteEntryRow("itementry", 1); - SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); - } - } - - if (entryRowCount > 0) { - this.getModel().setValue("amount", 0, 0); - this.getModel().setValue("oftaxamount", 0, 0); - this.getModel().setValue("taxamt", 0, 0); - } - - } - - public void hyperLinkClick(HyperLinkClickEvent hyperLinkClickEvent) { - String fieldName = hyperLinkClickEvent.getFieldName(); - int rowIndex = hyperLinkClickEvent.getRowIndex(); - if (StringUtils.equals(fieldName, "matinnumber")) { - this.materialInBillLinkClick(rowIndex); - } else if (StringUtils.equals(fieldName, "reconcnumber")) { - this.reconciliationLinkClick(rowIndex); - } else if (StringUtils.equals(fieldName, "eqnumber")) { - this.equipmentSettleLinkClick(rowIndex); - } - - } - - protected void reconciliationLinkClick(int rowIndex) { - String billId = (String)this.getModel().getValue("reconcbillid", rowIndex); - BillShowParameter showParameter = new BillShowParameter(); - showParameter.setFormId("ecma_reconciliation"); - showParameter.setPkId(Long.parseLong(billId)); - showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); - this.getView().showForm(showParameter); - } - - protected void materialInBillLinkClick(int rowIndex) { - Object matInBillId = this.getModel().getValue("materialinbillid", rowIndex); - BillShowParameter showParameter = new BillShowParameter(); - showParameter.setFormId("ecma_materialinbill"); - showParameter.setPkId(matInBillId); - showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); - this.getView().showForm(showParameter); - } - - protected void equipmentSettleLinkClick(int rowIndex) { - Object matInBillId = this.getModel().getValue("eqsettleid", rowIndex); - BillShowParameter showParameter = new BillShowParameter(); - showParameter.setFormId("eceq_settle"); - showParameter.setPkId(matInBillId); - showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage); - this.getView().showForm(showParameter); - } - - public void beforeF7Select(BeforeF7SelectEvent beforeF7SelectEvent) { - String propName = beforeF7SelectEvent.getProperty().getName(); - if (!StringUtils.equals(propName, "itemcbs") && !StringUtils.equals(propName, "listcbs") && !StringUtils.equals(propName, "listboq")) { - if (StringUtils.equals(propName, "itemboq")) { - this.beforeItemBoqSelect(beforeF7SelectEvent); - } else if (StringUtils.equals(propName, "itemunitproject")) { - this.beforeItemUnitProjectSelect(beforeF7SelectEvent); - } - } else { - this.addProjectFilter(beforeF7SelectEvent); - } - - } - - protected void beforeItemUnitProjectSelect(BeforeF7SelectEvent arg0) { - ListShowParameter parameter = (ListShowParameter)arg0.getFormShowParameter(); - DynamicObject project = this.getModel().getDataEntity().getDynamicObject("project"); - long projectId = project == null ? 0L : project.getLong("id"); - parameter.getListFilterParameter().getQFilters().add(new QFilter("parent", "=", projectId)); - parameter.getListFilterParameter().getQFilters().add(this.getContractUnitProjectFilter()); - } - - protected QFilter getContractUnitProjectFilter() { - List unitProjects = this.getContractUnitProjects(); - return unitProjects != null && !unitProjects.isEmpty() ? new QFilter("id", "in", unitProjects) : new QFilter("id", "!=", 0L); - } - - protected List getContractUnitProjects() { - DynamicObject contract = (DynamicObject)this.getModel().getValue("contract"); - List unitProjectIds = new ArrayList(); - if (contract != null) { - boolean isOnList = contract.getBoolean("isonlist"); - if (isOnList) { - QFilter filter = new QFilter("contractid", "=", contract.getPkValue()); - filter.and(new QFilter("listunitproject", "!=", 0L)); - DynamicObject[] listings = BusinessDataServiceHelper.load("ec_outtreelisting", "listunitproject", new QFilter[]{filter}); - if (listings != null && listings.length > 0) { - DynamicObject[] var6 = listings; - int var7 = listings.length; - - for(int var8 = 0; var8 < var7; ++var8) { - DynamicObject listing = var6[var8]; - DynamicObject listUnitProject = listing.getDynamicObject("listunitproject"); - if (listUnitProject != null) { - unitProjectIds.add(listUnitProject.getPkValue()); - } - } - } - } else if (contract.getDynamicObject("unitproject") != null) { - unitProjectIds.add(contract.getDynamicObject("unitproject").getPkValue()); - } - } - - return unitProjectIds; - } - - protected void beforeItemBoqSelect(BeforeF7SelectEvent arg0) { - ListShowParameter parameter = (ListShowParameter)arg0.getFormShowParameter(); - int row = arg0.getRow(); - DynamicObject project = (DynamicObject)this.getModel().getValue("project"); - if (project != null) { - parameter.getListFilterParameter().getQFilters().add(new QFilter("project", "=", project.getPkValue())); - parameter.getCustomParams().put("treecontrolproject", project.getPkValue()); - } - - if (project != null && StringUtils.equals(project.getString("boqmode"), "unitproject")) { - DynamicObject unitProject = (DynamicObject)this.getModel().getValue("itemunitproject", row); - Object unitProjects; - if (unitProject != null) { - unitProjects = new ArrayList(10); - ((List)unitProjects).add(unitProject.getPkValue()); - parameter.getListFilterParameter().getQFilters().add(new QFilter("unitproject", "=", unitProject.getPkValue())); - } else { - unitProjects = this.getContractUnitProjects(); - if (unitProjects != null && !((List)unitProjects).isEmpty()) { - parameter.getListFilterParameter().getQFilters().add(new QFilter("unitproject", "in", unitProjects)); - } - } - - if (unitProjects != null && !((List)unitProjects).isEmpty()) { - parameter.getCustomParams().put("treecontrolunitproject", unitProjects); - } - } - - } - - protected void addProjectFilter(BeforeF7SelectEvent beforeF7SelectEvent) { - ListShowParameter parameter = (ListShowParameter)beforeF7SelectEvent.getFormShowParameter(); - DynamicObject project = this.getModel().getDataEntity().getDynamicObject("project"); - if (project != null) { - QFilter projectFilter = new QFilter("project", "=", project.getPkValue()); - parameter.getListFilterParameter().getQFilters().add(projectFilter); - parameter.setFormId("bos_listf7"); - } - - parameter.getListFilterParameter().getQFilters().add(new QFilter("isleaf", "=", "1")); - } - + @Override public void afterBindData(EventObject e) { super.afterBindData(e); - boolean isPurchaseContract = this.isPurchaseType(); - this.getView().setVisible(isPurchaseContract, new String[]{"issettlebymatin"}); - this.getView().setVisible(isPurchaseContract, new String[]{"issettlebyreconc"}); - boolean isLeaseType = this.isLeaseType(); - this.getView().setVisible(isLeaseType, new String[]{"iseqsettle"}); - } - - public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) { - super.confirmCallBack(messageBoxClosedEvent); - if (StringUtils.equals("eqSettleChanged", messageBoxClosedEvent.getCallBackId())) { - } - - } - - protected void eqSettlePreiodEdit(MessageBoxClosedEvent messageBoxClosedEvent) { - if (messageBoxClosedEvent.getResult().equals(MessageBoxResult.Yes)) { - this.isEqSettleChanged((ChangeData)null); - } else { - Long oldValue = Long.valueOf(this.getPageCache().get("eqSettleChanged")); - this.getModel().beginInit(); - this.getModel().setValue("period", oldValue); - DynamicObject period = BusinessDataServiceHelper.loadSingle(oldValue, "bd_period"); - this.getModel().setValue("begindate", period == null ? null : period.getDate("begindate")); - this.getModel().setValue("enddate", period == null ? null : period.getDate("enddate")); - this.getView().updateView("fs_baseinfo"); - this.getModel().endInit(); - } - - } - - protected boolean isPurchaseType() { - DynamicObject contractAttr = (DynamicObject)this.getModel().getValue("contattr"); - if (contractAttr == null) { - return false; - } else { - String basicType = contractAttr.getString("basictype"); - return "02".equals(basicType) || "09".equals(basicType); - } - } - - protected boolean isLeaseType() { - DynamicObject contractAttr = (DynamicObject)this.getModel().getValue("contattr"); - if (contractAttr != null) { - String basicType = contractAttr.getString("basictype"); - return "04".equals(basicType); - } else { - return false; - } - } - - protected void openEqSettle() { - DynamicObject purchaseContract = (DynamicObject)this.getModel().getValue("contract"); - if (purchaseContract == null) { - this.getView().showTipNotification(ResManager.loadKDString("请选择“合同”。", "OutContractSettleEditPlugin_0", "ec-contract-formplugin", new Object[0])); - } else { - DynamicObject period = (DynamicObject)this.getModel().getValue("period"); - if (period == null) { - this.getView().showTipNotification(ResManager.loadKDString("请选择“结算期间”。", "OutContractSettleEditPlugin_1", "ec-contract-formplugin", new Object[0])); - } else { - ListShowParameter showParameter = ShowFormHelper.createShowListForm("eceq_settle", true); - int rowCount = this.getModel().getEntryRowCount("eqsettleentry"); - List billIds = new ArrayList(rowCount); - - for(int index = 0; index < rowCount; ++index) { - String billId = (String)this.getModel().getValue("eqsettleid", index); - billIds.add(StringUtils.isEmpty(billId) ? 0L : Long.parseLong(billId)); - } - - QFilter filter = new QFilter("id", "not in", billIds); - filter.and("period.begindate", "<=", period.getDate("begindate")); - filter.and("issettle", "=", "0"); - filter.and("iscost", "=", "1"); - filter.and("billstatus", "=", BillStatusEnum.AUDIT.getValue()); - filter.and("contract", "=", purchaseContract.getPkValue()); - showParameter.getListFilterParameter().getQFilters().add(filter); - showParameter.setFormId("bos_listf7"); - CloseCallBack callBack = new CloseCallBack(this, "addeqentry"); - showParameter.setCloseCallBack(callBack); - this.getView().showForm(showParameter); - } - } - } - - protected void equipmentSettleCallBack(ClosedCallBackEvent closedCallBackEvent) { - ListSelectedRowCollection rows = (ListSelectedRowCollection)closedCallBackEvent.getReturnData(); - if (rows != null && rows.size() > 0) { - List returnIds = (List)rows.stream().map(ListSelectedRow::getPrimaryKeyValue).collect(Collectors.toList()); - QFilter qFilter = new QFilter("id", "in", returnIds); - DynamicObject[] bills = BusinessDataServiceHelper.load("eceq_settle", "billno,billname,objecttype,internalorg,externalunit,curoftaxamount,curamount,period,totaltax", new QFilter[]{qFilter}); - DynamicObjectCollection eqEntryEntity = this.getModel().getEntryEntity("eqsettleentry"); - if (bills != null && bills.length > 0) { - int index = 0; - DynamicObject[] var9 = bills; - int var10 = bills.length; - - for(int var11 = 0; var11 < var10; ++var11) { - DynamicObject bill = var9[var11]; - DynamicObject object = new DynamicObject(eqEntryEntity.getDynamicObjectType()); - object.set("eqnumber", bill.getString("billno")); - object.set("eqname", bill.getString("billname")); - object.set("eqperiod", bill.getDynamicObject("period")); - object.set("eqcuroftaxamount", bill.getBigDecimal("curoftaxamount")); - object.set("eqcuramount", bill.getBigDecimal("curamount")); - object.set("eqcurtax", bill.getBigDecimal("totaltax")); - object.set("eqsettleid", bill.getPkValue()); - String objecttype = bill.getString("objecttype"); - if ("1".equals(objecttype)) { - object.set("eqobjecttype", "bos_org"); - object.set("eqobject", bill.getDynamicObject("internalorg")); - } else if ("2".equals(objecttype)) { - object.set("eqobjecttype", "bd_supplier"); - object.set("eqobject", bill.getDynamicObject("externalunit")); - } - - eqEntryEntity.add(object); - ++index; - } - } - - this.getModel().updateEntryCache(eqEntryEntity); - this.getView().updateView("eqsettleentry"); - this.sumEquipmentSettleToItemEntry(); - SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); - } - } - - protected void sumEquipmentSettleToItemEntry() { - this.getModel().updateCache(); - DynamicObjectCollection eqSettleEntry = this.getModel().getEntryEntity("eqsettleentry"); - if (eqSettleEntry != null && eqSettleEntry.size() != 0) { - EntryGrid entryGrid = (EntryGrid)this.getView().getControl("eqsettleentry"); - BigDecimal ofTaxAmount = entryGrid.getSum("eqcuroftaxamount"); - BigDecimal amount = entryGrid.getSum("eqcuramount"); - this.getModel().setValue("oftaxamount", ofTaxAmount, 0); - this.getModel().setValue("amount", amount, 0); - if (BigDecimal.ZERO.compareTo(amount) != 0) { - this.getPageCache().put("ignoreRateChanged", "1"); - this.getModel().setValue("rate", ofTaxAmount.subtract(amount).divide(amount, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)), 0); - } - - this.getModel().setValue("taxamt", ofTaxAmount.subtract(amount), 0); - this.getModel().setValue("hasdetail", true, 0); - this.getView().setVisible(false, new String[]{"itemca", "itemcbs", "itemboq"}); - } else { - this.getModel().setValue("oftaxamount", 0, 0); - DynamicObject taxRate = this.getModel().getDataEntity().getDynamicObject("taxrate"); - if (taxRate != null) { - this.getModel().setValue("rate", taxRate.getBigDecimal("taxrate"), 0); - } - - this.getModel().setValue("taxamt", 0, 0); - } - - } - - protected void isEqSettleChanged(ChangeData changeData) { - int entryRowCount = this.getModel().getEntryRowCount("itementry"); - if (entryRowCount > 0) { - this.getModel().setValue("amount", 0, 0); - this.getModel().setValue("oftaxamount", 0, 0); - this.getModel().setValue("taxamt", 0, 0); - DynamicObject taxRate = (DynamicObject)this.getModel().getValue("taxrate"); - BigDecimal rate = taxRate == null ? BigDecimal.ZERO : taxRate.getBigDecimal("taxrate"); - this.getModel().setValue("rate", rate, 0); - if (changeData != null) { - boolean isSettle = (Boolean)changeData.getNewValue(); - if (!isSettle) { - this.getModel().setValue("hasdetail", false, 0); - this.getView().setVisible(true, new String[]{"itemca", "itemcbs", "itemboq"}); + DynamicObject dataEntity = this.getModel().getDataEntity(true); + Object pkValue = this.getModel().getDataEntity(true).getPkValue(); + if (pkValue != null) { + BillShowParameter bsp = (BillShowParameter) this.getView().getFormShowParameter(); + // Map> ecOutContractSettle = BFTrackerServiceHelper.findSourceBills("ec_out_contract_settle", new Long[]{(Long) pkValue}); + if (bsp.getStatus() == OperationStatus.ADDNEW ) { + boolean isSettleByMatin = (Boolean)this.getModel().getValue("issettlebymatin"); + if (isSettleByMatin) { + //this.getModel().deleteEntryData("materialinentry"); + this.sumMaterialInAmountToItemEntry(); + SettleUpdateAmtUtils.calAllTypeAmount(this.getModel()); } } } - this.getModel().deleteEntryData("eqsettleentry"); - DynamicObjectCollection entryEntity = this.getModel().getEntryEntity("payitemdetailentry"); - List del = new ArrayList(); - - for(int i = 0; i < entryEntity.size(); ++i) { - DynamicObject entry = (DynamicObject)entryEntity.get(i); - DynamicObject detailPayItem = entry.getDynamicObject("detailpayitem"); - if (Optional.ofNullable(detailPayItem).isPresent() && StringUtils.equals(detailPayItem.getString("id"), "506427748873442304")) { - del.add(i); - } - } - - this.getModel().deleteEntryRows("payitemdetailentry", del.stream().mapToInt(Integer::valueOf).toArray()); } - protected void onChangeWithMessageBox(PropertyChangedArgs e, String message, String callBackId) { - ChangeData[] data = e.getChangeSet(); - if (data.length > 0) { - ChangeData changeData = data[0]; - Object newValue = changeData.getNewValue(); - Object oldValue = changeData.getOldValue(); - if (newValue == null || !newValue.equals(oldValue)) { - this.getView().showConfirm(message, MessageBoxOptions.OKCancel, new ConfirmCallBackListener(callBackId, this)); - String cacheOldValue = ""; - if (oldValue != null) { - if (oldValue instanceof DynamicObject) { - cacheOldValue = ((DynamicObject)oldValue).getPkValue().toString(); - } else if (oldValue instanceof Date) { - cacheOldValue = EcDateUtils.formatShortDate((Date)oldValue); - } else { - cacheOldValue = oldValue.toString(); - } - } - - this.getPageCache().put(callBackId, cacheOldValue); - } - } - } - - public static boolean isEntryEmpty(AbstractFormPlugin formPlugin, String entryMetaTag) { - IDataModel model = formPlugin.getView().getModel(); - DynamicObjectCollection entryEntity = model.getEntryEntity(entryMetaTag); - return CollectionUtils.isEmpty(entryEntity); - } }