本文介绍了为满足客户对系统批号拣货的个性化需求,在标准系统配置无法实现时,通过二次开发(二开)批号拣货插件的方式来解决。文中详细描述了无源单和有源单两种场景的批号拣货插件开发过程,包括编写插件、继承基类、重载事件实现逻辑、以及插件的注册和使用。无源单和有源单插件分别继承了不同的基类,并重写了多个方法,用于干预或监视拣货过程。代码示例展示了部分方法的重写,这些方法可以在拣货过程中进行必要的操作或调试。最后,说明了插件编译后需在批号拣货配置界面进行注册,注册字符串为插件的类全名,并可在插件方法中设置断点进行调试,以了解拣货流程及问题所在。
背景:很多客户对系统的批号拣货有个性化需求,在标准系统无法配置实现时,需要通过二开批号拣货插件满足。 场景:涉及录单时无源单批号拣货服务,以及上下游单据下推时(有源单)批号拣货服务。 步骤:1.编写插件继承批号拣货插件基类;2.根据业务需要重载对应事件实现逻辑;3.注册插件至对应服务配置界面。 |
场景一:无源单批号拣货插件
工程需引用:
Kingdee.BOS.dll
Kingdee.BOS.DataEntity.dll
Kingdee.K3.SCM.App.Core
using Kingdee.K3.SCM.App.Core.ConvertBusinessService; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ClassLibrary1 { public class Class1 : AbstractSinglePickPlugIn { /// <summary> /// 捡货之前(插件可取消捡货) /// </summary> public override bool BeforePicking(Kingdee.K3.SCM.App.Core.ConvertBusinessService.LotPickArgs.BeforePickingArgs e) { return base.BeforePicking(e); } /// <summary> /// 系统参数设置为不检霍是否需要执行捡货 /// </summary> public override bool DoPickWhenNoSysSet() { return base.DoPickWhenNoSysSet(); } /// <summary> /// 修正解释库存取数脚本 /// </summary> /// <param name="sql">即时库存取数脚本(获得物料范围的即时库存数据信息)</param> /// <param name="paras">即时库存取数参数</param> public override string RegexGetInvDataSql(string sql, List paras) { return base.RegexGetInvDataSql(sql, paras); } /// <summary> /// 处理当前行的捡货库存捡货结果 /// </summary> public override System.Data.DataRow[] RegexSelectResultByCurRowData(Kingdee.K3.SCM.App.Core.ConvertBusinessService.LotPickArgs.RegexSelectResultByCurRowDataArgs e) { return base.RegexSelectResultByCurRowData(e); } /// <summary> /// 无源单单条捡货库存筛选过滤条件 /// </summary> public override string RegexSinglePickFilterString(Kingdee.K3.SCM.App.Core.ConvertBusinessService.LotPickArgs.RegexSinglePickFilterStringArgs e) { return base.RegexSinglePickFilterString(e); } /// <summary> /// 根据当前行数据整理捡货库存筛选排序字符串 /// </summary> public override string RegexSinglePickSortString(Kingdee.K3.SCM.App.Core.ConvertBusinessService.LotPickArgs.RegexCurRowPickSortStringArgs e) { return base.RegexSinglePickSortString(e); } /// <summary> /// 捡货前重整即时库存数据 /// </summary> public override void RegexUseableInvData(System.Data.DataTable invDatas) { base.RegexUseableInvData(invDatas); } /// <summary> /// 完成无源单单条捡货 /// </summary> public override void AfterSinglePicking(Kingdee.K3.SCM.App.Core.ConvertBusinessService.LotPickArgs.AfterSinglePickingArgs arg) { base.AfterSinglePicking(arg); } } }
场景二:有源单批号拣货插件
工程需引用:
Kingdee.BOS.dll
Kingdee.BOS.DataEntity.dll
Kingdee.K3.SCM.App.Core
namespace ClassLibrary2{ public class Class2 : AbstractLotPickPlugIn { public override bool BeforePicking(Kingdee.K3.SCM.App.Core.ConvertBusinessService.LotPickArgs.BeforePickingArgs e) { return base.BeforePicking(e); } public override bool DoPickWhenNoSysSet() { return base.DoPickWhenNoSysSet(); } public override string RegexGetInvDataSql(string sql, List paras) { return base.RegexGetInvDataSql(sql, paras); } public override string RegexCurRowPickFilterString(Kingdee.K3.SCM.App.Core.ConvertBusinessService.LotPickArgs.RegexCurRowPickFilterStringArgs e) { return base.RegexCurRowPickFilterString(e); } public override string RegexCurRowPickSortString(Kingdee.K3.SCM.App.Core.ConvertBusinessService.LotPickArgs.RegexCurRowPickSortStringArgs e) { return base.RegexCurRowPickSortString(e); } public override void RegexInvDataByCurRowData(Kingdee.K3.SCM.App.Core.ConvertBusinessService.LotPickArgs.RegexInvDataByCurRowDataArgs e) { base.RegexInvDataByCurRowData(e); } public override System.Data.DataRow[] RegexSelectResultByCurRowData(Kingdee.K3.SCM.App.Core.ConvertBusinessService.LotPickArgs.RegexSelectResultByCurRowDataArgs e) { return base.RegexSelectResultByCurRowData(e); } public override void RegexUseableInvData(System.Data.DataTable invDatas) { base.RegexUseableInvData(invDatas); } public override void AfterPicking(Kingdee.K3.SCM.App.Core.ConvertBusinessService.LotPickArgs.AfterPickingArgs e) { base.AfterPicking(e); } /// <summary> /// 获取二开指定的预计出单据取数设置 /// </summary> /// <returns>KeyValue集合,key:单据FormID,Value:包含回溯天数和取数插件类全名,使用冒号隔开,不能有空格,如: 3:test.estbillplugin,test</returns> public override List<KeyValue> GetExtEstoutBillSet() { return base.GetExtEstoutBillSet(); } } }
说明:
1. 代码编译后需要在批号捡货配置界面注册插件,插件注册字符串为二次开发插件的类全名,如:ClassLibrary1.Class,ClassLibrary1
2. 编写插件可以在插件方法中对捡货过程进行干预,也可以用于监视调试捡货过程,在这些方法中打上断点,跟踪调试可以看一下捡货的流程,以及执行过程中参数值,如果捡货没有完成也可以看一下是执行到哪一步之后出现问题不再继续执行
本文转载自:金蝶云
作者:tipi
原文链接:https://vip.kingdee.com/article/20539?channel_level=kdclub
推荐阅读