From ec5c03c0f0f733a5bc6c5cdd3afedfc12d4f8e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=9A=E8=B1=86=E8=B1=86?= <13356128+sunandmoon60@user.noreply.gitee.com> Date: Mon, 18 Aug 2025 17:53:31 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=BF=94=E5=88=A9=E8=A7=84=E5=88=99=E5=A2=9E?= =?UTF-8?q?=E8=A1=8C=E5=BC=B9=E7=AA=97=202.=E9=87=87=E8=B4=AD=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E5=8F=8D=E5=86=99=E6=89=B9=E5=8F=B7=E4=B8=BB=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/conm/RebateRulesBillPlugin.java | 2 + .../conm/purconmAddRebateRulesPlugin.java | 92 +++++++++++++- .../form/im/ReturnStockSyncNoticePlugin.java | 2 - .../operate/im/PurInlotReceiptPlugin.java | 120 ++++++++++++++++++ 4 files changed, 212 insertions(+), 4 deletions(-) create mode 100644 lc123/cloud/app/plugin/operate/im/PurInlotReceiptPlugin.java diff --git a/lc123/cloud/app/plugin/form/conm/RebateRulesBillPlugin.java b/lc123/cloud/app/plugin/form/conm/RebateRulesBillPlugin.java index 1436da3..ad78c46 100644 --- a/lc123/cloud/app/plugin/form/conm/RebateRulesBillPlugin.java +++ b/lc123/cloud/app/plugin/form/conm/RebateRulesBillPlugin.java @@ -30,4 +30,6 @@ public class RebateRulesBillPlugin extends AbstractBillPlugIn implements Plugin this.getModel().setValue("tqq9_conm_purcontract", purcontract); } + + } \ No newline at end of file diff --git a/lc123/cloud/app/plugin/form/conm/purconmAddRebateRulesPlugin.java b/lc123/cloud/app/plugin/form/conm/purconmAddRebateRulesPlugin.java index 56006c0..5270d42 100644 --- a/lc123/cloud/app/plugin/form/conm/purconmAddRebateRulesPlugin.java +++ b/lc123/cloud/app/plugin/form/conm/purconmAddRebateRulesPlugin.java @@ -2,8 +2,14 @@ package tqq9.lc123.cloud.app.plugin.form.conm; import kd.bos.bill.BillShowParameter; import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.datamodel.IDataModel; +import kd.bos.entity.datamodel.ListSelectedRow; +import kd.bos.entity.datamodel.ListSelectedRowCollection; import kd.bos.form.CloseCallBack; import kd.bos.form.FormShowParameter; +import kd.bos.form.IFormView; import kd.bos.form.ShowType; import kd.bos.form.control.events.BeforeItemClickEvent; import kd.bos.form.control.events.ItemClickEvent; @@ -16,6 +22,8 @@ import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.sdk.plugin.Plugin; +import java.math.BigDecimal; +import java.util.Date; import java.util.EventObject; import java.util.Map; @@ -31,22 +39,102 @@ public class purconmAddRebateRulesPlugin extends AbstractFormPlugin implements P public void registerListener(EventObject e) { super.registerListener(e); this.addItemClickListeners("tbmain"); + this.addItemClickListeners("tqq9_rebatetoolbarap"); } - @Override public void itemClick(ItemClickEvent evt) { super.itemClick(evt); String itemKey = evt.getItemKey(); if ("tqq9_pur_rebate".equals(itemKey)) { -// FormShowParameter param = new FormShowParameter(); BillShowParameter param = new BillShowParameter(); param.setFormId("tqq9_pur_rebate"); param.setCustomParam("purcontract_billno", this.getModel().getValue("billno")); param.setCloseCallBack(new CloseCallBack(this, "rebateSync")); param.getOpenStyle().setShowType(ShowType.Modal); this.getView().showForm(param); + } else if (StringUtils.equals("tqq9_rebate_addrow", itemKey)) { + BillShowParameter param = new BillShowParameter(); + param.setFormId("tqq9_pur_rebate"); + param.setCustomParam("purcontract_billno", this.getModel().getValue("billno")); + param.setCloseCallBack(new CloseCallBack(this, "entry_rebateSync")); + param.getOpenStyle().setShowType(ShowType.Modal); + this.getView().showForm(param); + } + } + + + /** + * 点击增行分录返回值 + * + * @param closedCallBackEvent + */ + @Override + public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) { + super.closedCallBack(closedCallBackEvent); + IDataModel model = this.getModel(); + IFormView view = this.getView(); + String actionId = closedCallBackEvent.getActionId(); + Object returnData = closedCallBackEvent.getReturnData(); + if (returnData != null) { + if ("entry_rebateSync".equals(actionId)) { + DynamicObjectCollection tqq9_entryentity = this.getModel().getDataEntity(true).getDynamicObjectCollection("tqq9_entryentity"); + int size = tqq9_entryentity.size(); + ListSelectedRow listSelectedRow = ((ListSelectedRowCollection) returnData).get(0); + DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(listSelectedRow.toString(), "cas_paybill"); + String name = dynamicObject.getString("name");//规则名称 + DynamicObjectCollection tqq9_rebatebrand = dynamicObject.getDynamicObjectCollection("tqq9_rebatebrand");//品牌 + DynamicObjectCollection tqq9_supplier = dynamicObject.getDynamicObjectCollection("tqq9_supplier");//供应商 + Date tqq9_startdate = dynamicObject.getDate("tqq9_startdate");//返利开始时间 + Date tqq9_enddate = dynamicObject.getDate("tqq9_enddate");//返利结束时间 + String tqq9_status = dynamicObject.getString("tqq9_status");//返利状态 + DynamicObject creator = dynamicObject.getDynamicObject("creator");//创建人 + Date createtime = dynamicObject.getDate("createtime");//创建时间 + Date tqq9_lastdate = dynamicObject.getDate("tqq9_lastdate");//最后一次执行时间 + String tqq9_rebatesub = dynamicObject.getString("tqq9_rebatesub");//返利主体 + StringBuilder stringBuilder = new StringBuilder(); + if (StringUtils.equals("A", tqq9_rebatesub)) { + Boolean tqq9_shanghailici = dynamicObject.getBoolean("tqq9_shanghailici"); + if (tqq9_shanghailici) { + stringBuilder.append(",").append("上海励齿"); + } + Boolean tqq9_beijinglichi = dynamicObject.getBoolean("tqq9_beijinglichi"); + if (tqq9_beijinglichi) { + stringBuilder.append(",").append("北京励齿"); + Boolean tqq9_guangzhoulici = dynamicObject.getBoolean("tqq9_guangzhoulici"); + if (tqq9_guangzhoulici) { + stringBuilder.append(",").append("广州励齿"); + } + } else if (StringUtils.equals("B", tqq9_rebatesub)) { + BigDecimal tqq9_shlcbl = dynamicObject.getBigDecimal("tqq9_shlcbl"); + if (tqq9_shlcbl.compareTo(BigDecimal.ZERO) == 0) { + stringBuilder.append(",").append("上海励齿"); + } + BigDecimal tqq9_bjlcbl = dynamicObject.getBigDecimal("tqq9_bjlcbl"); + if (tqq9_bjlcbl.compareTo(BigDecimal.ZERO) == 0) { + stringBuilder.append(",").append("北京励齿"); + } + BigDecimal tqq9_gzlcbl = dynamicObject.getBigDecimal("tqq9_gzlcbl"); + if (tqq9_gzlcbl.compareTo(BigDecimal.ZERO) == 0) { + stringBuilder.append(",").append("广州励齿"); + } + } + + + model.setValue("tqq9_rulename", name,size-1);//规则名称 + model.setValue("tqq9_company", stringBuilder,size-1);//主体 + model.setValue("tqq9_brand", tqq9_rebatebrand,size-1);//品牌 + model.setValue("tqq9_supplier", tqq9_supplier,size-1);//供应商 + model.setValue("tqq9_startdate", tqq9_startdate,size-1);//返利开始时间 + model.setValue("tqq9_enddate", tqq9_enddate,size-1);//返利结束时间 + model.setValue("tqq9_status", tqq9_status,size-1);//返利状态 + model.setValue("creator", creator,size-1);//创建人 + model.setValue("createtime", createtime,size-1);//创建时间 + model.setValue("tqq9_lastdate", tqq9_lastdate,size-1);//最后一次执行时间 + } + } + this.getView().updateView(); } } diff --git a/lc123/cloud/app/plugin/form/im/ReturnStockSyncNoticePlugin.java b/lc123/cloud/app/plugin/form/im/ReturnStockSyncNoticePlugin.java index 6bf9371..27fc432 100644 --- a/lc123/cloud/app/plugin/form/im/ReturnStockSyncNoticePlugin.java +++ b/lc123/cloud/app/plugin/form/im/ReturnStockSyncNoticePlugin.java @@ -35,8 +35,6 @@ public class ReturnStockSyncNoticePlugin extends AbstractFormPlugin implements P OperationResult operationResult = afterDoOperationEventArgs.getOperationResult(); String message = operationResult.getMessage(); if (StringUtils.isNotBlank(message)) { -// StringBuilder stringBuilder = new StringBuilder(); -// stringBuilder.append("补货失败,").append("\n").append(message); this.getView().showMessage(message); } } diff --git a/lc123/cloud/app/plugin/operate/im/PurInlotReceiptPlugin.java b/lc123/cloud/app/plugin/operate/im/PurInlotReceiptPlugin.java new file mode 100644 index 0000000..9097809 --- /dev/null +++ b/lc123/cloud/app/plugin/operate/im/PurInlotReceiptPlugin.java @@ -0,0 +1,120 @@ +package tqq9.lc123.cloud.app.plugin.operate.im; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.plugin.AbstractOperationServicePlugIn; +import kd.bos.entity.plugin.PreparePropertysEventArgs; +import kd.bos.entity.plugin.args.AfterOperationArgs; +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.bos.servicehelper.operation.SaveServiceHelper; +import kd.sdk.plugin.Plugin; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +/** + * 采购入库反写批号主档 + */ +public class PurInlotReceiptPlugin extends AbstractOperationServicePlugIn implements Plugin { + private final static Log logger = LogFactory.getLog(PurInlotReceiptPlugin.class); + + + @Override + public void afterExecuteOperationTransaction(AfterOperationArgs e) { + super.afterExecuteOperationTransaction(e); + String operationKey = e.getOperationKey(); + if (StringUtils.equals("audit", operationKey)) { + for (DynamicObject dataEntity : e.getDataEntities()) { + ArrayList billnos = new ArrayList<>(); + HashMap entryMap = new HashMap<>(); + String billno1 = dataEntity.getString("billno"); + DynamicObject im_purinbill = BusinessDataServiceHelper.loadSingle("im_purinbill", new QFilter[]{new QFilter("billno", QCP.equals, billno1)}); + DynamicObjectCollection billentry = im_purinbill.getDynamicObjectCollection("billentry"); + + //处理采购入库逻辑 + for (DynamicObject dynamicObject : billentry) { + String billno = dynamicObject.getString("mainbillnumber");//采购订单编号 + Long entryid = dynamicObject.getLong("mainbillentryid");//核心单据行id + DynamicObject lot = dynamicObject.getDynamicObject("lot");//批号主档 + billnos.add(billno); + entryMap.put(entryid, lot); + } + //查询采购订单 + QFilter qFilter = new QFilter("billno", QCP.in, billnos); + DynamicObject[] pm_purorderbills = BusinessDataServiceHelper.load("pm_purorderbill", "id,billno,billentry.id,billentry.tqq9_bd_lot", qFilter.toArray()); + if (pm_purorderbills != null && pm_purorderbills.length > 0) { + for (DynamicObject pm_purorderbill : pm_purorderbills) { + + DynamicObjectCollection billentry1 = pm_purorderbill.getDynamicObjectCollection("billentry"); + + for (DynamicObject dynamicObject : billentry1) { + long id = dynamicObject.getLong("id"); + if (entryMap.containsKey(id)) { + DynamicObject lot = entryMap.get(id); + DynamicObjectCollection tqq9_bd_lot = dynamicObject.getDynamicObjectCollection("tqq9_bd_lot"); + DynamicObject newlot = new DynamicObject(tqq9_bd_lot.getDynamicObjectType()); + newlot.set("fbasedataId", lot); + if (!tqq9_bd_lot.contains(newlot)) { + tqq9_bd_lot.add(newlot); + } + } + } + } + SaveServiceHelper.save(pm_purorderbills); + } + } + } else if (StringUtils.equals("unaudit", operationKey)) { + for (DynamicObject dataEntity : e.getDataEntities()) { + ArrayList billnos = new ArrayList<>(); + String billno1 = dataEntity.getString("billno"); + + DynamicObject im_purinbill = BusinessDataServiceHelper.loadSingle("im_purinbill", new QFilter[]{new QFilter("billno", QCP.equals, billno1)}); + DynamicObjectCollection billentry = im_purinbill.getDynamicObjectCollection("billentry"); + + //处理采购入库逻辑 + for (DynamicObject dynamicObject : billentry) { + String billno = dynamicObject.getString("mainbillnumber");//采购订单编号 + billnos.add(billno); + } + //查询采购订单 + QFilter qFilter = new QFilter("billno", QCP.in, billnos); + DynamicObject[] pm_purorderbills = BusinessDataServiceHelper.load("pm_purorderbill", "id,billno,billentry.id,billentry.tqq9_bd_lot", qFilter.toArray()); + //删除禁用批号 + for (DynamicObject pm_purorderbill : pm_purorderbills) { + DynamicObjectCollection billentry1 = pm_purorderbill.getDynamicObjectCollection("billentry"); + for (DynamicObject dynamicObject : billentry1) { + DynamicObjectCollection tqq9_bd_lot = dynamicObject.getDynamicObjectCollection("tqq9_bd_lot"); + Iterator iterator = tqq9_bd_lot.iterator(); + while (iterator.hasNext()){ + DynamicObject lot = iterator.next(); + DynamicObject bd_lot = lot.getDynamicObject("fbasedataId"); + bd_lot = BusinessDataServiceHelper.loadSingle("bd_lot", new QFilter[]{new QFilter("id", QCP.equals, bd_lot.getLong("id"))}); + String lotstatus = bd_lot.getString("lotstatus"); + if (lotstatus.equals("B")) { + iterator.remove(); + } + } +// for (DynamicObject lot : tqq9_bd_lot) { +// DynamicObject bd_lot = lot.getDynamicObject("fbasedataId"); +// bd_lot = BusinessDataServiceHelper.loadSingle("bd_lot", new QFilter[]{new QFilter("id", QCP.equals, bd_lot.getLong("id"))}); +// String lotstatus = bd_lot.getString("lotstatus"); +// if (lotstatus.equals("B")) { +// tqq9_bd_lot.remove(bd_lot); +// } +// } + + } + } + SaveServiceHelper.save(pm_purorderbills); + } + } + + } +} \ No newline at end of file