添加已选物料过滤、修改获取勾选分录行的代码逻辑
This commit is contained in:
parent
4de5577200
commit
1ea070267e
|
@ -21,6 +21,8 @@ import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
import kd.sdk.plugin.Plugin;
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单据界面插件
|
* 单据界面插件
|
||||||
*/
|
*/
|
||||||
|
@ -122,7 +124,7 @@ public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements
|
||||||
FormOperate operate = (FormOperate) args.getSource();
|
FormOperate operate = (FormOperate) args.getSource();
|
||||||
String operateKey = operate.getOperateKey();
|
String operateKey = operate.getOperateKey();
|
||||||
if ("importpurchase".equals(operateKey)) {
|
if ("importpurchase".equals(operateKey)) {
|
||||||
showPurchaseApplyBill("purchase");
|
//showPurchaseApplyBill("purchase");
|
||||||
} else if ("importpurchase2".equals(operateKey)) {
|
} else if ("importpurchase2".equals(operateKey)) {
|
||||||
showPurchaseApplyBill("purchase2");
|
showPurchaseApplyBill("purchase2");
|
||||||
}
|
}
|
||||||
|
@ -133,6 +135,28 @@ public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements
|
||||||
listShowParameter.setFormId("bos_listf7");
|
listShowParameter.setFormId("bos_listf7");
|
||||||
listShowParameter.getOpenStyle().setShowType(ShowType.Modal);
|
listShowParameter.getOpenStyle().setShowType(ShowType.Modal);
|
||||||
listShowParameter.setCloseCallBack(new CloseCallBack(this, actionId));
|
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);
|
this.getView().showForm(listShowParameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,20 +193,42 @@ public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements
|
||||||
IDataModel model = this.getModel();
|
IDataModel model = this.getModel();
|
||||||
ListSelectedRowCollection selectedRows = (ListSelectedRowCollection) closedCallBackEvent.getReturnData();
|
ListSelectedRowCollection selectedRows = (ListSelectedRowCollection) closedCallBackEvent.getReturnData();
|
||||||
if (selectedRows != null && !selectedRows.isEmpty()) {
|
if (selectedRows != null && !selectedRows.isEmpty()) {
|
||||||
for (ListSelectedRow selectedRow : selectedRows) {
|
HashMap<Long, ArrayList<Long>> ids = new HashMap<>();
|
||||||
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);
|
|
||||||
|
|
||||||
int index = model.createNewEntryRow("projectentry");
|
List<Map<Object, Object>> pkEntryIdValues = selectedRows.getPKEntryIdValues();
|
||||||
model.setValue("purentrycontent", entry.get("qeug_materialname"), index);
|
for (Map<Object, Object> pkEntryIdValue : pkEntryIdValues) {
|
||||||
DynamicObject project = entry.getDynamicObject("qeug_project");
|
ArrayList<Long> entryIds = new ArrayList<>();
|
||||||
if (project != null) {
|
Set<Object> objects = pkEntryIdValue.keySet();
|
||||||
QFilter projectQF = new QFilter("number", QCP.equals, project.getString("number"));
|
for (Object object : objects) {
|
||||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle("rebm_purproject", projectQF.toArray());
|
ArrayList<Long> list = ids.get((Long)object);
|
||||||
model.setValue("purentryproject", dynamicObject, index);
|
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 purproject = BusinessDataServiceHelper.loadSingle("rebm_purproject", projectQF.toArray());
|
||||||
|
model.setValue("purentryproject", purproject, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue