diff --git a/main/java/shkd/repc/rebm/formplugin/ImportPurchaseApplyBillPlugin.java b/main/java/shkd/repc/rebm/formplugin/ImportPurchaseApplyBillPlugin.java index 0d9b975..001d9fd 100644 --- a/main/java/shkd/repc/rebm/formplugin/ImportPurchaseApplyBillPlugin.java +++ b/main/java/shkd/repc/rebm/formplugin/ImportPurchaseApplyBillPlugin.java @@ -21,6 +21,8 @@ import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.sdk.plugin.Plugin; +import java.util.*; + /** * 单据界面插件 */ @@ -122,7 +124,7 @@ public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements FormOperate operate = (FormOperate) args.getSource(); String operateKey = operate.getOperateKey(); if ("importpurchase".equals(operateKey)) { - showPurchaseApplyBill("purchase"); + //showPurchaseApplyBill("purchase"); } else if ("importpurchase2".equals(operateKey)) { showPurchaseApplyBill("purchase2"); } @@ -133,6 +135,28 @@ public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements listShowParameter.setFormId("bos_listf7"); listShowParameter.getOpenStyle().setShowType(ShowType.Modal); listShowParameter.setCloseCallBack(new CloseCallBack(this, actionId)); + if ("purchase2".equals(actionId)) { + IDataModel model = this.getModel(); + List ids = new ArrayList<>(); + DynamicObjectCollection bidSections = model.getEntryEntity("bidsection"); + if (bidSections != null) { + for (DynamicObject bidSection : bidSections) { + DynamicObjectCollection projectEntries = bidSection.getDynamicObjectCollection("projectentry"); + if (projectEntries != null) { + for (DynamicObject projectEntry : projectEntries) { + long id = projectEntry.getLong("qeug_purentry_id"); + if (id != 0) { + ids.add(id); + } + } + } + } + + if (!ids.isEmpty()) { + listShowParameter.getListFilterParameter().getQFilters().add(new QFilter("qeug_entryentity.id", QCP.not_in, ids)); + } + } + } this.getView().showForm(listShowParameter); } @@ -169,20 +193,42 @@ public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements IDataModel model = this.getModel(); ListSelectedRowCollection selectedRows = (ListSelectedRowCollection) closedCallBackEvent.getReturnData(); if (selectedRows != null && !selectedRows.isEmpty()) { - for (ListSelectedRow selectedRow : selectedRows) { - Object keyValue = selectedRow.getPrimaryKeyValue(); - int rowKey = selectedRow.getRowKey(); - DynamicObject purchase = BusinessDataServiceHelper.loadSingle(keyValue, "qeug_purchaseapplybill"); - DynamicObjectCollection entryEntities = purchase.getDynamicObjectCollection("qeug_entryentity");// 明细 - DynamicObject entry = entryEntities.get(rowKey); + HashMap> ids = new HashMap<>(); - int index = model.createNewEntryRow("projectentry"); - model.setValue("purentrycontent", entry.get("qeug_materialname"), index); - DynamicObject project = entry.getDynamicObject("qeug_project"); - if (project != null) { - QFilter projectQF = new QFilter("number", QCP.equals, project.getString("number")); - DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("rebm_purproject", projectQF.toArray()); - model.setValue("purentryproject", dynamicObject, index); + List> pkEntryIdValues = selectedRows.getPKEntryIdValues(); + for (Map pkEntryIdValue : pkEntryIdValues) { + ArrayList entryIds = new ArrayList<>(); + Set objects = pkEntryIdValue.keySet(); + for (Object object : objects) { + ArrayList list = ids.get((Long)object); + if (list != null && !list.isEmpty()) { + list.add((Long) pkEntryIdValue.get(object)); + ids.put((Long)object, list); + } else { + entryIds.add((Long) pkEntryIdValue.get(object)); + ids.put((Long)object, entryIds); + } + } + } + + Set billIds = ids.keySet(); + for (Long billId : billIds) { + DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(billId, "qeug_purchaseapplybill"); + DynamicObjectCollection entries = dynamicObject.getDynamicObjectCollection("qeug_entryentity"); + for (DynamicObject entry : entries) { + long entryId = entry.getLong("id"); + ArrayList entryIds = ids.get(billId); + if (entryIds.contains(entryId)) { + int index = model.createNewEntryRow("projectentry"); + model.setValue("qeug_purentry_id", entryId, index); + model.setValue("purentrycontent", entry.get("qeug_materialname"), index); + DynamicObject project = entry.getDynamicObject("qeug_project"); + if (project != null) { + QFilter projectQF = new QFilter("number", QCP.equals, project.getString("number")); + DynamicObject purproject = BusinessDataServiceHelper.loadSingle("rebm_purproject", projectQF.toArray()); + model.setValue("purentryproject", purproject, index); + } + } } } } diff --git a/main/java/shkd/repc/rebm/formplugin/UpdateDrawPurDataPlugin.java b/main/java/shkd/repc/rebm/formplugin/UpdateDrawPurDataPlugin.java deleted file mode 100644 index 9dd01da..0000000 --- a/main/java/shkd/repc/rebm/formplugin/UpdateDrawPurDataPlugin.java +++ /dev/null @@ -1,32 +0,0 @@ -package shkd.repc.rebm.formplugin; - -import kd.bos.bill.AbstractBillPlugIn; -import kd.bos.dataentity.entity.DynamicObject; -import kd.bos.dataentity.entity.DynamicObjectCollection; -import kd.bos.entity.datamodel.IDataModel; -import kd.bos.form.events.AfterDoOperationEventArgs; -import kd.sdk.plugin.Plugin; - -/** - * 单据界面插件 - */ -public class UpdateDrawPurDataPlugin extends AbstractBillPlugIn implements Plugin { - - @Override - public void afterDoOperation(AfterDoOperationEventArgs args) { - super.afterDoOperation(args); - String operateKey = args.getOperateKey(); - if ("draw".equals(operateKey)) { - IDataModel model = this.getModel(); - int rowIndex = model.getEntryCurrentRowIndex("bidsection"); - DynamicObjectCollection bidSections = model.getEntryEntity("bidsection"); - DynamicObject dynamicObject1 = bidSections.get(rowIndex); - DynamicObject dynamicObject2 = bidSections.get(bidSections.size() - 1); - - DynamicObjectCollection projectEntries = dynamicObject1.getDynamicObjectCollection("projectentry"); - projectEntries.addAll(dynamicObject2.getDynamicObjectCollection("projectentry")); - model.deleteEntryRow("bidsection", bidSections.size() - 1); - this.getView().updateView("projectentry"); - } - } -} \ No newline at end of file