当前位置: 首页 > news >正文

金蝶云星空插件开发记录(二)

实现目的:

在金蝶ERP采购申请列表界面,勾选某些行采购申请物料信息后,点击按钮推送到第三方系统。

实现思路:

通过WebService方式实现两个系统间的数据交互。

实现过程:

1、新建项目,然后通过Visual Studio IDE工具解析第三方WebService服务端地址,具体参照网上教程。

2、项目的app.config配置如下:

<?xml version="1.0" encoding="utf-8" ?>
<configuration><system.serviceModel><bindings><basicHttpBinding><binding name="BatchInsertPendingPurchaseDataServiceSoap" /></basicHttpBinding></bindings><client><endpoint address="http://192.168.23.250/BatchInsertPendingPurchaseDataService.asmx"binding="basicHttpBinding" bindingConfiguration="BatchInsertPendingPurchaseDataServiceSoap"contract="WebServiceClient.BatchInsertPendingPurchaseDataServiceSoap"name="BatchInsertPendingPurchaseDataServiceSoap" /></client></system.serviceModel>
</configuration>

3、创建WebService客户端调用程序:

using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using K3Cloud.Purchase.Requisition.WebServiceClient;namespace K3Cloud.Purchase.Requisition
{public class BachInsertPendingPurchaseDataClient{public static string BachInsertData(List<DataItem> dataItems){try{string Url = "http://192.168.23.250/BatchInsertPendingPurchaseDataService.asmx";// 动态创建绑定和终结点var binding = new BasicHttpBinding();var endpoint = new EndpointAddress(Url);// 使用动态配置创建客户端using (var client = new BatchInsertPendingPurchaseDataServiceSoapClient(binding, endpoint)){return client.BatchInsertData(dataItems.ToArray());}}catch (Exception ex){Console.WriteLine($"调用WebService时发生错误: {ex.Message}");if (ex.InnerException != null){Console.WriteLine($"内部错误: {ex.InnerException.Message}");}return ex.Message;}}}
}

4、新建列表插件,获取选中的列表行数据,然后调用WebService传输数据:

using Kingdee.BOS;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;using Kingdee.BOS.Core.List;using Kingdee.BOS.Core.List.PlugIn;using Kingdee.BOS.Util;
using System.Collections.Generic;
using System.ComponentModel;using System.Linq;
using System.Data;
using K3Cloud.Purchase.Requisition.TRMWebServiceClient;
using System;namespace K3Cloud.Purchase.Requisition
{public class PushPurchaseRequisition:AbstractListPlugIn{public override void BarItemClick(BarItemClickEventArgs e){base.BarItemClick(e);if (e.BarItemKey.EqualsIgnoreCase("tbGetListSelectedRows")){var lv = this.View as IListView;if (lv == null){return;}ListSelectedRowCollection selectedRows = lv.SelectedRowsInfo;if (selectedRows == null || selectedRows.Count == 0){this.View.ShowMessage("当前没有行被选中!");return;}// 1. 收集所有选中行的单据体主键(FEntryID)var entryIds = selectedRows.Select(item => item.EntryPrimaryKeyValue).ToList();// 2. 构建批量查询SQLvar sql = "SELECT * FROM vw_PUR_Requisition_y WHERE LineNumber IN ({0})";var paramNames = new List<string>();var sqlParams = new List<SqlParam>();for (int i = 0; i < entryIds.Count; i++){var paramName = $"@id{i}";paramNames.Add(paramName);sqlParams.Add(new SqlParam(paramName, KDDbType.Int64, entryIds[i]));}sql = string.Format(sql, string.Join(",", paramNames));// 3. 执行查询var ds = DBUtils.ExecuteDataSet(this.Context, sql, sqlParams);if (ds == null || ds.Tables[0].Rows.Count == 0){this.View.ShowMessage("未查询到选中的数据!");return;}// 4. 转换为DataItem列表List<DataItem> dataItems = new List<DataItem>();foreach (DataRow row in ds.Tables[0].Rows){dataItems.Add(new DataItem{MaterialCode = row["MaterialCode"].ToString(),MaterialName = row["MaterialName"].ToString(),SpecModel = row["SpecModel"].ToString(),Unit = row["Unit"].ToString(),Level1 = row["Level1"].ToString(),PurchaseQuantity = Convert.ToDecimal(row["PurchaseQuantity"]), // 避免直接强制转换失败ArrivalDate = Convert.ToDateTime(row["ArriveDate"]),});}// 5. 调用WebService批量插入string res = BachInsertPendingPurchaseDataClient.BachInsertData(dataItems);this.View.ShowMessage(res);}}}
}

5、在BOS平台新增列表操作按钮、新增绑定列表插件,重启后可在采购申请列表页查看新增的按钮,在列表选中行数据后,点击该按钮即可查看效果。


文章转载自:

http://bfvR2Jgr.LwnwL.cn
http://tAtXnOBr.LwnwL.cn
http://zI79MNiv.LwnwL.cn
http://Z6wbhfHN.LwnwL.cn
http://BDEQR38f.LwnwL.cn
http://rKANf3aU.LwnwL.cn
http://Axyaecaf.LwnwL.cn
http://1VtHGUTH.LwnwL.cn
http://eCEwWvrP.LwnwL.cn
http://HLQVWWAq.LwnwL.cn
http://dnET8z6F.LwnwL.cn
http://wQYMkc8I.LwnwL.cn
http://XJvQxoAS.LwnwL.cn
http://eC77e4gA.LwnwL.cn
http://diO5T68H.LwnwL.cn
http://w2K69EUc.LwnwL.cn
http://EBYaJpGi.LwnwL.cn
http://vnypHLrZ.LwnwL.cn
http://VAUssueG.LwnwL.cn
http://dDGtlGz3.LwnwL.cn
http://F1D6whyA.LwnwL.cn
http://PxEQABOP.LwnwL.cn
http://Y4Df3js6.LwnwL.cn
http://55Hjc67D.LwnwL.cn
http://8pFYehXq.LwnwL.cn
http://1nym9Juc.LwnwL.cn
http://mh5gPLQY.LwnwL.cn
http://v6deQ1Cz.LwnwL.cn
http://V1S4Zfjp.LwnwL.cn
http://XiU04S3v.LwnwL.cn
http://www.dtcms.com/a/387654.html

相关文章:

  • Linux服务器中CPU100%如何排查
  • 从源代码开始构建、部署和管理应用程序
  • Java虚拟线程原理与性能优化实践指南
  • Java注解+com.fasterxml.jackson信息脱敏
  • Docker 镜像瘦身实战:从 1.2GB 压缩到 200MB 的优化过程——Node.js 前端 SSR 场景的“node_modules 大屠杀”
  • 外网穿透到内网---访问公网IP映射到内网IP---frp使用
  • Google Veo 3 实战指南:三步告别AI视频“PPT感”
  • NVR接入录像回放平台EasyCVR视频融合平台语音对讲配置指南
  • 【Android】进程间如何通信
  • 从代码源码角度 解读 open-vla 算法架构
  • javaweb Tomcat及运行/HTTP
  • 深入解析 HTTP 状态码
  • PHP 常用函数及用法
  • WordPress 网站邮件通知功能实现指南:以 WP Mail SMTP 插件与 QQ 邮箱为例
  • 【CF】Day144——杂题 (交互 + 思维 | 整除分块)
  • Unity 实验功能实现:天敌捕食猎物(含对象池 + 点击交互)
  • 【docker】——docker国内可用的源
  • React Zustand存储token报错解决方案
  • I/O 多路复用器(select、poll、epoll)与 Reactor 模式详解
  • pytorch自定义算子转tensorrt
  • Springboots上传文件的同时传递参数用对象接收
  • Next.js 中表单处理与校验:React Hook Form 实战
  • 国标GB28181视频平台EasyGBS如何解决安防视频融合与级联管理的核心痛点?
  • Web 页面 SEO 审计自动化 - 基于 n8n 和 Firecrawl
  • arcgis文件导出显示导出对象错误
  • PPT中将图片按比例裁剪
  • React + Zustand 状态管理
  • 复位开关芯片 EY412-A07E50国产低功耗延时芯片方案超低功耗
  • 动态规划-详解回文串系列问题
  • C语言基础学习(五)——进制