添加已选物料过滤、修改获取勾选分录行的代码逻辑

This commit is contained in:
ggxl 2024-11-30 16:40:04 +08:00
parent 4de5577200
commit 1ea070267e
2 changed files with 60 additions and 46 deletions

View File

@ -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<Long> 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<Long, ArrayList<Long>> ids = new HashMap<>();
List<Map<Object, Object>> pkEntryIdValues = selectedRows.getPKEntryIdValues();
for (Map<Object, Object> pkEntryIdValue : pkEntryIdValues) {
ArrayList<Long> entryIds = new ArrayList<>();
Set<Object> objects = pkEntryIdValue.keySet();
for (Object object : objects) {
ArrayList<Long> 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<Long> 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<Long> 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 dynamicObject = BusinessDataServiceHelper.loadSingle("rebm_purproject", projectQF.toArray());
model.setValue("purentryproject", dynamicObject, index);
DynamicObject purproject = BusinessDataServiceHelper.loadSingle("rebm_purproject", projectQF.toArray());
model.setValue("purentryproject", purproject, index);
}
}
}
}
}

View File

@ -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");
}
}
}