自定义WebApi接口查询即时库存序列号原创
11人赞赏了该文章
1,879次浏览
编辑于2022年04月19日 18:34:07
一、【需求场景】
接口获取了即时库存后,怎么查每一个物料的具体序列号
二、【问题分析】
系统当前查询对应即时库存的序列号的功能入口,是在即时库存明细选中对应记录联查"序列号报表",WebApi并无相关的接口可以直接调用。
换个思路实现,自定义一个WebApi接口,根据传入的即时库存ID,将联查报表的数据获取到即可满足需求。
三、【方案实现】
1、跟踪联查,追踪到报表核心的SQL查询脚本
2、自定义WebApi接口,传入即时库存ID,查询数据库组织数据返回
using Kingdee.BOS.ServiceFacade.KDServiceFx; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.WebApi.ServicesStub; using Newtonsoft.Json.Linq; using System.Data; namespace CUS.WebApi.ServicesStub { public class InventorySerialQueryService: AbstractWebApiBusinessService { public InventorySerialQueryService(KDServiceContext context):base(context) { } public JObject ExecuteService(string param) { return null; } public DataSet ExecuteDataSet(string param) { return DBServiceHelper.ExecuteDataSet(this.KDContext.Session.AppContext, BuildInventorySerialQuerySql(param)); } public object ExecuteDynamicObject(string param) { return DBServiceHelper.ExecuteDynamicObject(this.KDContext.Session.AppContext, BuildInventorySerialQuerySql(param)); } private string BuildInventorySerialQuerySql(string InvId) { string sql = string.Format(@" SELECT 'BD_SerialMainFile' fformid, SM.FSERIALID fserialId, INV.FID fid, SM.FNUMBER fserialno, ORGL.FNAME fstockorgname, MA.FMaterialId fmaterialId, MA.FNUMBER fmaterialnumber, MAL.FNAME fmaterialname, MAL.FSpecification fmaterialmodel, INV.FAuxPropID fauxpropcomid, ' ' fauxprop, BDSTL.FNAME fstockname, SMORG.FSTOCKSTATUS fstockstatus, Row_number() OVER( ORDER BY INV.FID ASC, SM.FNUMBER ASC) fidentityid FROM T_STK_INVENTORY INV INNER JOIN T_BD_SERIALBILLTRACE TRA ON INV.FID = TRA.FINVID INNER JOIN (SELECT Max(T3.FBILLTRACEID) fbilltraceid FROM T_BD_SERIALBILLTRACE T3 INNER JOIN (SELECT DISTINCT FSERIALID FROM T_BD_SERIALBILLTRACE WHERE FINVID IN ( '{0}' )) t4 ON T4.FSERIALID = T3.FSERIALID WHERE ( T3.FINVID <> ' ' ) GROUP BY T3.FSERIALID) tra2 ON TRA2.FBILLTRACEID = TRA.FBILLTRACEID INNER JOIN T_BD_SERIALMASTER SM ON SM.FSERIALID = TRA.FSERIALID LEFT OUTER JOIN T_ORG_ORGANIZATIONS_L ORGL ON ( ORGL.FORGID = INV.FSTOCKORGID AND ORGL.FLOCALEID = 2052 ) INNER JOIN T_BD_MATERIAL MA ON ( MA.FMASTERID = INV.FMATERIALID AND MA.FUSEORGID = INV.FSTOCKORGID ) LEFT OUTER JOIN T_BD_MATERIAL_L MAL ON ( MAL.FMATERIALID = MA.FMATERIALID AND MAL.FLOCALEID = 2052 ) LEFT OUTER JOIN T_BD_STOCK_L BDSTL ON ( BDSTL.FSTOCKID = INV.FSTOCKID AND BDSTL.FLOCALEID = 2052 ) INNER JOIN T_BD_SERIALMASTERORG SMORG ON ( SMORG.FSERIALID = SM.FSERIALID AND SMORG.FORGID = INV.FSTOCKORGID ) WHERE ( SM.FFORBIDSTATUS = 'A' AND ( INV.FID IN ( '{0}' ) AND TRA.FSTATE = '1' ) ) ORDER BY INV.FID ASC, SM.FNUMBER ASC ", InvId); return sql; } } }
调用登录验证
Postman调用方法:金蝶地址+插件命名控件.类名.方法名,插件命名空间.common.kdsvc
客户端调用方法result = apiClient.Execute<object>("插件命名控件.类名.方法名,插件编译组件名称", new object[] { param });
参考:
1、【二开案例.WebApi.从零开发自定义WebApi接口】
2、【二开自定义webapi接口详解】
3、【WebApi自定义接口】
赞 11
11人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读