From 0d1a852481017fbb7a7f7c7c632bd01921d6098c Mon Sep 17 00:00:00 2001 From: sez Date: Thu, 6 Nov 2025 11:46:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E8=B4=A7=E9=80=9A=E7=9F=A5=E5=8D=95?= =?UTF-8?q?=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../result/SmDeliverNoticeBillPlugin.java | 86 ++++++++++++++ .../result/SmDeliverNoticeListPlugin.java | 109 ++++++++++++++++++ .../plugin/utils/BillCloseCancelUtils.java | 35 ++++++ 3 files changed, 230 insertions(+) create mode 100644 lc123/cloud/app/plugin/form/result/SmDeliverNoticeBillPlugin.java create mode 100644 lc123/cloud/app/plugin/form/result/SmDeliverNoticeListPlugin.java diff --git a/lc123/cloud/app/plugin/form/result/SmDeliverNoticeBillPlugin.java b/lc123/cloud/app/plugin/form/result/SmDeliverNoticeBillPlugin.java new file mode 100644 index 0000000..9efd197 --- /dev/null +++ b/lc123/cloud/app/plugin/form/result/SmDeliverNoticeBillPlugin.java @@ -0,0 +1,86 @@ +package tqq9.lc123.cloud.app.plugin.form.result; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.form.control.events.BeforeItemClickEvent; +import kd.bos.form.control.events.ItemClickEvent; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.util.StringUtils; +import tqq9.lc123.cloud.app.plugin.utils.BillCloseCancelUtils; +import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils; + +import java.util.EventObject; + +//发货通知单(单据取消) + +public class SmDeliverNoticeBillPlugin extends AbstractBillPlugIn { + + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + this.addItemClickListeners("tbmain"); + + } + + @Override + public void beforeItemClick(BeforeItemClickEvent evt) { + super.beforeItemClick(evt); + String itemKey = evt.getItemKey(); + if ("tqq9_close".equals(itemKey)) { + boolean tqq9_isclose = (boolean) this.getModel().getValue("tqq9_isclose"); + if (tqq9_isclose) { + this.getView().showMessage("该单据已关闭"); + evt.setCancel(true); + } + } + } + + @Override + public void itemClick(ItemClickEvent evt) { + super.itemClick(evt); + String itemKey = evt.getItemKey(); + if ("tqq9_close".equals(itemKey)) { + String billNo = (String) this.getModel().getValue("billno"); + String message = null; + DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("sm_delivernotice", "id,billno,org,tqq9_ck", + new QFilter[]{new QFilter("billno", QCP.equals, billNo)}); + + String entityType = "sm_delivernotice"; + String entityName; + String label = "tqq9_isclose"; + DynamicObject org = dataEntity.getDynamicObject("org");//收货组织 + if (null != org) { + String number = org.getString("number"); + if ("SHLC".equals(number)) { + String warehouseCode = null; + DynamicObject warehouse = dataEntity.getDynamicObject("tqq9_ck"); + if (null != warehouse) { + warehouseCode = warehouse.getString("number"); + } + String orderType = "PTCK"; + entityName = "WMS-SH-收货通知单取消"; + message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label); + } else if ("BJLC".equals(number)) { + String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL"); + entityName = "WMS-BJ-收货通知单取消"; + message = BillCloseCancelUtils.BGSaCancelSalesOrder(billNo, BJ_URL, entityType, entityName, label); + + } else if ("GZLC".equals(number)) { + String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL"); + entityName = "WMS-GZ-收货通知单取消"; + message = BillCloseCancelUtils.BGSaCancelSalesOrder(billNo, GZURL, entityType, entityName, label); + + } + if (StringUtils.isNotEmpty(message)) { + this.getView().showMessage(String.valueOf(message)); + + } + + } + + } + } +} diff --git a/lc123/cloud/app/plugin/form/result/SmDeliverNoticeListPlugin.java b/lc123/cloud/app/plugin/form/result/SmDeliverNoticeListPlugin.java new file mode 100644 index 0000000..3edd8c5 --- /dev/null +++ b/lc123/cloud/app/plugin/form/result/SmDeliverNoticeListPlugin.java @@ -0,0 +1,109 @@ +package tqq9.lc123.cloud.app.plugin.form.result; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.datamodel.ListSelectedRow; +import kd.bos.entity.datamodel.ListSelectedRowCollection; +import kd.bos.form.control.events.BeforeItemClickEvent; +import kd.bos.form.control.events.ItemClickEvent; +import kd.bos.list.BillList; +import kd.bos.list.plugin.AbstractListPlugin; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.bos.util.StringUtils; +import tqq9.lc123.cloud.app.plugin.utils.BillCloseCancelUtils; +import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils; + +import java.util.EventObject; +import java.util.List; +import java.util.stream.Collectors; + +//发货通知单(单据取消) + +public class SmDeliverNoticeListPlugin extends AbstractListPlugin { + + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + //标准单据列表模板为bos_list,需使用该模板中的控件标识(如工具栏标识toolbarap)进行监听。 + // 列表插件继承AbstractListPlugin时,底层已默认注册工具栏监听,无需重复注册 + } + + @Override + public void beforeItemClick(BeforeItemClickEvent evt) { + super.beforeItemClick(evt); + String itemKey = evt.getItemKey(); + /*if ("tqq9_close".equals(itemKey)) { + BillList billList = this.getControl("billlistap"); + ListSelectedRowCollection selectedRows = billList.getSelectedRows(); + List billnoList = selectedRows.stream().map(ListSelectedRow::getBillNo).distinct().collect(Collectors.toList()); + if (billnoList.size() > 1) { + this.getView().showMessage("请选择一张单据"); + evt.setCancel(true); + return; + } + DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("sm_delivernotice", "id,billno,tqq9_isclose", + new QFilter[]{new QFilter("billno", QCP.in, billnoList)}); + if (null != dataEntity) { + boolean tqq9_isclose = dataEntity.getBoolean("tqq9_isclose"); + if (tqq9_isclose) { + this.getView().showMessage("该单据已关闭"); + evt.setCancel(true); + } + } + + }*/ + } + + @Override + public void itemClick(ItemClickEvent evt) { + super.itemClick(evt); + String itemKey = evt.getItemKey(); + if ("tqq9_close".equals(itemKey)) { + BillList billList = this.getControl("billlistap"); + ListSelectedRowCollection selectedRows = billList.getSelectedRows(); + List billnoList = selectedRows.stream().map(ListSelectedRow::getBillNo).distinct().collect(Collectors.toList()); + for (String billNo : billnoList) { + String message = null; + DynamicObject dataEntity = BusinessDataServiceHelper.loadSingle("sm_delivernotice", "id,billno,org,tqq9_ck", + new QFilter[]{new QFilter("billno", QCP.equals, billNo)}); + + String entityType = "sm_delivernotice"; + String entityName; + String label = "tqq9_isclose"; + DynamicObject org = dataEntity.getDynamicObject("org");//收货组织 + if (null != org) { + String number = org.getString("number"); + if ("SHLC".equals(number)) { + String warehouseCode = null; + DynamicObject warehouse = dataEntity.getDynamicObject("tqq9_ck"); + if (null != warehouse) { + warehouseCode = warehouse.getString("number"); + } + String orderType = "PTCK"; + entityName = "WMS-SH-发货通知单取消"; + message = BillCloseCancelUtils.wmsCancel(orderType, warehouseCode, billNo, entityType, entityName, label); + } else if ("BJLC".equals(number)) { + String BJ_URL = ConfigUtils.getThirdConfigByNumber("BJ_POSTURL"); + entityName = "WMS-BJ-发货通知单取消"; + message = BillCloseCancelUtils.BGSaCancelSalesOrder(billNo, BJ_URL, entityType, entityName, label); + + } else if ("GZLC".equals(number)) { + String GZURL = ConfigUtils.getThirdConfigByNumber("GZ_POSTURL"); + entityName = "WMS-GZ-发货通知单取消"; + message = BillCloseCancelUtils.BGSaCancelSalesOrder(billNo, GZURL, entityType, entityName, label); + + } + if (StringUtils.isNotEmpty(message)) { + this.getView().showMessage(String.valueOf(message)); + + } + + } + + } + + } + } +} diff --git a/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java b/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java index 330b64f..b3a5b7f 100644 --- a/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java +++ b/lc123/cloud/app/plugin/utils/BillCloseCancelUtils.java @@ -215,4 +215,39 @@ public class BillCloseCancelUtils { } return message; } + + + /** + * 北广 发货通知单取消(销售出库拦截) + * + * @param billNo 单据编号 + * @param url 接口地址,北京还是广州 + * @param entityType 单据标识 + * @param entityName 单据名称 + * @param label 推送标识 + * @return 关闭结果 + */ + public static String BGSaCancelSalesOrder(String billNo, String url, String entityType, String entityName, String label) { + String message = null; + String method = "/api/SA/Cancel_SalesOrder"; + Map bj_map = new HashMap<>(); + bj_map.put("cSOCode", billNo); + String bjjsonBody = JSON.toJSONString(bj_map); + try { + String result = HttpRequestUtils.postJson(url + method, bjjsonBody, null); + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode rootNode = objectMapper.readTree(result); + if (null != rootNode) { + message = String.valueOf(rootNode.get("message")); + String code = String.valueOf(rootNode.get("code")); + LCLogServiceImpl lcLogService = new LCLogServiceImpl(); + lcLogService.savelog(entityName, url, true, code.equals("0"), bjjsonBody, result); + lcLogService.isSuccess(entityType, billNo, "billno", label, code.equals("0")); + } + + } catch (IOException e) { + throw new RuntimeException(e); + } + return message; + } }