1.采购立项引用采购需求(无明细的情况)

S
This commit is contained in:
weiyunlong 2025-01-06 14:41:39 +08:00
parent 24aae452c7
commit dced18f74d
2 changed files with 49 additions and 0 deletions

View File

@ -19,10 +19,13 @@ import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.events.ClosedCallBackEvent;
import kd.bos.form.operate.FormOperate;
import kd.bos.list.ListShowParameter;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.sdk.plugin.Plugin;
import shkd.repc.recon.formplugin.ContractFormPlugin;
import java.util.*;
@ -32,6 +35,8 @@ import java.util.*;
*/
public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements Plugin {
private static final Log logger = LogFactory.getLog(ImportPurchaseApplyBillPlugin.class);
@Override
public void afterBindData(EventObject e) {
super.afterBindData(e);
@ -146,22 +151,28 @@ public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements
super.closedCallBack(closedCallBackEvent);
String actionId = closedCallBackEvent.getActionId();
if ("purchase2".equals(actionId)) {
logger.info("11");
IDataModel model = this.getModel();
//获取采购需求id
ListSelectedRowCollection selectedRows = (ListSelectedRowCollection) closedCallBackEvent.getReturnData();
if (selectedRows != null && !selectedRows.isEmpty()) {
logger.info("22");
HashMap<Long, ArrayList<Long>> ids = new HashMap<>();
List<Map<Object, Object>> pkEntryIdValues = selectedRows.getPKEntryIdValues();
for (Map<Object, Object> pkEntryIdValue : pkEntryIdValues) {
logger.info("33");
ArrayList<Long> entryIds = new ArrayList<>();
Set<Object> objects = pkEntryIdValue.keySet();
for (Object object : objects) {
logger.info("44");
ArrayList<Long> list = ids.get((Long)object);
if (list != null && !list.isEmpty()) {
logger.info("55");
list.add((Long) pkEntryIdValue.get(object));
ids.put((Long)object, list);
} else {
logger.info("66");
entryIds.add((Long) pkEntryIdValue.get(object));
ids.put((Long)object, entryIds);
}
@ -169,14 +180,40 @@ public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements
}
Set<Long> billIds = ids.keySet();
logger.info("77");
for (Long billId : billIds) {
logger.info("88");
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(billId, "recon_settleplanbill");//采购需求
if (null != dynamicObject) {
logger.info("99");
}
DynamicObject project = dynamicObject.getDynamicObject("qeug_renovation_proj");//项目
DynamicObjectCollection entries = dynamicObject.getDynamicObjectCollection("qeug_cgxqentry");
for (DynamicObject entry : entries) {
long entryId = entry.getLong("id");
ArrayList<Long> entryIds = ids.get(billId);
if (entries.size() == 1) {
DynamicObject entrie = entries.get(0);
String qeugReqdes = entrie.getString("qeug_reqdes");
if ("本次采购需求未填写明细".equals(qeugReqdes)) {
int index = model.createNewEntryRow("projectentry");
model.setValue("qeug_purxq_id", billId, index);//需求id
model.setValue("purentrycontent", dynamicObject.getString("qeug_comment"), index);// 需求描述-->采购明细
// model.setValue("qeug_qty", entry.get("qeug_qty"), index);// 数量
model.setValue("purentryproject", project, index);// 项目
model.setValue("qeug_cgxq", dynamicObject, index);//需求单据
model.setValue("controlamount", dynamicObject.getBigDecimal("qeug_applyamount"), index);//采购控制金额含税
if (entryIds.contains(entryId)) {
model.setValue("qeug_purentry_id", entryId, index);//分录id
}
break;
}
}
logger.info("1010");
if (entryIds.contains(entryId)) {
logger.info("1111");
int index = model.createNewEntryRow("projectentry");
model.setValue("qeug_purxq_id", billId, index);//需求id
model.setValue("qeug_purentry_id", entryId, index);//分录id
@ -186,6 +223,16 @@ public class ImportPurchaseApplyBillPlugin extends AbstractBillPlugIn implements
model.setValue("qeug_cgxq", dynamicObject, index);//需求单据
}
}
//采购需求无明细
if (entries.isEmpty()) {
int index = model.createNewEntryRow("projectentry");
model.setValue("qeug_purxq_id", billId, index);//需求id
model.setValue("purentrycontent", dynamicObject.getString("qeug_comment"), index);// 需求描述-->采购明细
// model.setValue("qeug_qty", entry.get("qeug_qty"), index);// 数量
model.setValue("purentryproject", project, index);// 项目
model.setValue("qeug_cgxq", dynamicObject, index);//需求单据
model.setValue("controlamount", dynamicObject.getBigDecimal("qeug_applyamount"), index);//采购控制金额含税
}
}
}
}

View File

@ -4,6 +4,7 @@ import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
/**
@ -19,6 +20,7 @@ public class PurapplyAuditOPPlugin extends AbstractOperationServicePlugIn {
if ("audit1".equals(operationKey)) {
DynamicObject[] dataEntities = e.getDataEntities();
DynamicObject dataEntity = dataEntities[0];
dataEntity = BusinessDataServiceHelper.loadSingle(dataEntity.getPkValue(),"recon_settleplanbill");
DynamicObjectCollection collection = dataEntity.getDynamicObjectCollection("qeug_cgxqentry");
if (collection.isEmpty()) {
DynamicObject add = collection.addNew();