From 465c959e300480b703399861a407a4d6d364882f Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Fri, 25 Jul 2025 18:09:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=87=87=E8=B4=AD=E7=94=B3=E8=AF=B7=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=90=8E=E5=BC=B9=E5=87=BA=E5=AF=B9=E5=BA=94=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E7=94=B3=E8=AF=B7=E5=88=86=E5=BD=95=E5=86=85=E5=AE=B9?= =?UTF-8?q?=EF=BC=8C=E5=90=8E=E9=80=9A=E8=BF=87=E9=80=89=E6=8B=A9=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E7=9A=84=E9=87=87=E8=B4=AD=E7=94=B3=E8=AF=B7=E5=88=86?= =?UTF-8?q?=E5=BD=95=E8=A1=8C=E8=B5=8B=E5=80=BC=E7=BB=99=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E5=8D=95=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/MaterialInbPurchaseApplyPlugin.java | 106 ++++++++++++++++++ .../plugin/form/PurchaseApplyEntryPlugin.java | 78 +++++++++++++ 2 files changed, 184 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbPurchaseApplyPlugin.java create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PurchaseApplyEntryPlugin.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbPurchaseApplyPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbPurchaseApplyPlugin.java new file mode 100644 index 0000000..1b7b623 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/MaterialInbPurchaseApplyPlugin.java @@ -0,0 +1,106 @@ +package zcgj.zcdev.zcdev.pr.plugin.form; + +import kd.bos.algo.DataSet; +import kd.bos.algo.JoinDataSet; +import kd.bos.algo.JoinType; +import kd.bos.algo.Row; +import kd.bos.bill.AbstractBillPlugIn; +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.EntityMetadataCache; +import kd.bos.entity.datamodel.ListSelectedRowCollection; +import kd.bos.form.*; +import kd.bos.form.events.AfterDoOperationEventArgs; +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.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.servicehelper.QueryServiceHelper; +import kd.sdk.plugin.Plugin; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 入库单表单插件:入库单点击选择采购申请按钮后弹出对应采购申请分录内容,后通过选择弹出的采购申请分录行赋值给入库单中 + */ +public class MaterialInbPurchaseApplyPlugin extends AbstractBillPlugIn implements Plugin { + public void beforeDoOperation(BeforeDoOperationEventArgs args) { + super.beforeDoOperation(args); + FormOperate operate = (FormOperate) args.getSource(); + if ("purchaseapply".equals(operate.getOperateKey())) { + //选择采购申请单 + this.doPurchaseApply(); + } + } + + private void doPurchaseApply() { + DynamicObject purchaseApply = (DynamicObject) this.getModel().getValue("zcgj_purchaseapply");//采购申请单 + if (purchaseApply == null) { + this.getView().showTipNotification(ResManager.loadKDString("请先选择采购申请。", "MaterialInBillEditPlugin_0", "ec-ecma-formplugin", new Object[0])); + } else { + FormShowParameter formShowParameter = new FormShowParameter(); + HashMap paramters = new HashMap<>(); + DynamicObjectCollection entryEntityCollection = this.getModel().getDataEntity(true).getDynamicObjectCollection("entryentity");//入库单分录 + List entryIds = new ArrayList<>(); + for (DynamicObject entryEntity : entryEntityCollection) { + Long entryEntityId = entryEntity.getLong("listingid");//合同清单id + entryIds.add(entryEntityId); + } + + long purchaseApplyId = purchaseApply.getLong("id");//采购申请单id + paramters.put("purchaseApplyId", purchaseApplyId); + paramters.put("entryIds", entryIds); + formShowParameter.setCustomParams(paramters); + formShowParameter.setCaption("采购申请分录列表"); + formShowParameter.setFormId("zcgj_purchaseapplyentry"); + formShowParameter.setCloseCallBack(new CloseCallBack(this, "zcgj_selectpurchaseapply")); + + StyleCss styleCss = new StyleCss(); + styleCss.setWidth("900"); + styleCss.setHeight("545"); + OpenStyle openStyle = formShowParameter.getOpenStyle(); + openStyle.setShowType(ShowType.Modal); + openStyle.setInlineStyleCss(styleCss); + this.getView().showForm(formShowParameter); + } + } + + public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) { + super.closedCallBack(closedCallBackEvent); + String actionId = closedCallBackEvent.getActionId(); + DynamicObjectCollection returnDataCollection = (DynamicObjectCollection) closedCallBackEvent.getReturnData(); + if (returnDataCollection == null) { + return; + } + if ("zcgj_selectpurchaseapply".equals(actionId) && returnDataCollection.size() > 0) { + for (DynamicObject returnData : returnDataCollection) { + int curIndex = this.getModel().createNewEntryRow("entryentity"); + this.getModel().updateCache(); + this.getView().setEnable(false, curIndex, new String[]{"oftaxamount", "notaxamount", "taxamount", "taxprice"}); + + long zcgj_bigintfield = returnData.getLong("zcgj_bigintfield");//采购申请单id + QFilter filter = new QFilter("purchaseentry.id", QCP.equals, zcgj_bigintfield); + DynamicObjectCollection purchaseApply = QueryServiceHelper.query("ecma_purchaseapply", + "purchaseentry,purchaseentry.material,purchaseentry.purchaseqty,purchaseentry.entrytaxrate,purchaseentry.price,purchaseentry.id", + new QFilter[]{filter});//采购申请单 + + long material = purchaseApply.get(0).getLong("purchaseentry.material");//采购申请分录-资源编码 + Object purchaseQty = purchaseApply.get(0).get("purchaseentry.purchaseqty");//采购申请分录-采购数量 + Object entryTaxRate = purchaseApply.get(0).get("purchaseentry.entrytaxrate");//采购申请分录-税率 + Object price = purchaseApply.get(0).get("purchaseentry.price");//采购申请分录-预估单价 + Object purchaseEntryId = purchaseApply.get(0).get("purchaseentry.id");//采购申请分录-预估单价 + this.getModel().setValue("material", material, curIndex);//资源编码 + this.getModel().setValue("entrytaxrate", entryTaxRate, curIndex);//税率名称 + this.getModel().setValue("qty", purchaseQty, curIndex);//数量 + this.getModel().setValue("price", price, curIndex);//入库单价 + this.getModel().setValue("listingid", purchaseEntryId, curIndex);//合同清单id + } + } + } +} diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PurchaseApplyEntryPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PurchaseApplyEntryPlugin.java new file mode 100644 index 0000000..8eaa173 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/PurchaseApplyEntryPlugin.java @@ -0,0 +1,78 @@ +package zcgj.zcdev.zcdev.pr.plugin.form; + +import com.alibaba.fastjson.JSONObject; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.form.control.Button; +import kd.bos.form.control.Control; +import kd.bos.form.control.EntryGrid; +import kd.bos.form.plugin.AbstractFormPlugin; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.sdk.plugin.Plugin; + +import java.util.EventObject; +import java.util.List; +import java.util.Map; + +/* + * 采购申请单物料列表插件:返回入库单点击选择采购申请信息 + */ +public class PurchaseApplyEntryPlugin extends AbstractFormPlugin implements Plugin { + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + Button btnok = this.getControl("btnok");//确定 + btnok.addClickListener(this); + } + + @Override + public void click(EventObject evt) { + super.click(evt); + Control source = (Control) evt.getSource(); + if ("btnok".equals(source.getKey())) { + EntryGrid entryGrid = this.getControl("zcgj_entryentity"); + int[] selectRows = entryGrid.getSelectRows(); + int count = selectRows.length; + //分录行数只有一条的时候才能通过接下来两个if + if (count == 0) { + this.getView().showErrorNotification("请选择一条分录信息!"); + return; + } + DynamicObjectCollection qeug_entryentity = getModel().getEntryEntity("zcgj_entryentity");//分录 + DynamicObjectCollection collection = new DynamicObjectCollection(); + for (int selectRow : selectRows) { + collection.add(qeug_entryentity.get(selectRow)); + } + this.getView().returnDataToParent(collection);//返回所选数据给父级 + this.getView().close(); + } + } + + @Override + public void afterCreateNewData(EventObject e) { + super.afterCreateNewData(e); + Map customParams = this.getView().getFormShowParameter().getCustomParams(); + Long purchaseApplyId = (Long) customParams.get("purchaseApplyId");//采购申请单ID + if (purchaseApplyId != null) { + List entryIds = (List) customParams.get("entryIds"); + DynamicObject ecma_purchaseApply = BusinessDataServiceHelper.loadSingle(purchaseApplyId, "ecma_purchaseapply");//采购申请单 + DynamicObjectCollection purchaseEntryCollection = ecma_purchaseApply.getDynamicObjectCollection("purchaseentry");//采购明细单据体 + DynamicObjectCollection entryEntityCollection = this.getModel().getEntryEntity("zcgj_entryentity");//分录 + for (DynamicObject purchaseEntry : purchaseEntryCollection) { + Long id = (Long) purchaseEntry.get("id"); + if (entryIds != null && entryIds.contains(id)) { + continue; + } + DynamicObject entryEntityNew = entryEntityCollection.addNew(); + entryEntityNew.set("zcgj_bigintfield", id);//分录id + entryEntityNew.set("zcgj_material", purchaseEntry.get("material"));//物料 + entryEntityNew.set("zcgj_modelnum", purchaseEntry.getDynamicObject("material").get("model"));//规格型号 + entryEntityNew.set("zcgj_measureunit", purchaseEntry.get("unit"));//计量单位 + entryEntityNew.set("zcgj_qty", purchaseEntry.get("purchaseqty"));//数量 + entryEntityNew.set("zcgj_price", purchaseEntry.get("oftaxprice"));//合同单价(含税) + entryEntityNew.set("zcgj_oftaxamt", purchaseEntry.get("oftaxamount"));//本次订单金额(含税) + entryEntityNew.set("zcgj_description", purchaseEntry.get("remarks"));//备注 + } + } + } +}