Acumatica 以编程方式生成波浪拾取列表

Acumatica 以编程方式生成波浪拾取列表,acumatica,Acumatica,你好 我想通过编程从创建和打印拾取列表(SO50305)屏幕生成一个波浪拾取列表 其思想是,每当wave pick列表的状态更改为picking时,就会发出推送通知,然后在webhook处理程序中使用该通知 我已经成功地获得了推送通知设置,webhook处理程序正在很好地接收通知。到目前为止,我已经设法在webhook处理程序中获得了一些很好的身份验证(遵循中的概念),但是我有点不了解如何真正实现以编程方式生成wave picklist的目标 据我所知,我需要做3件事才能让它工作: 设置SOPi

你好

我想通过编程从创建和打印拾取列表(SO50305)屏幕生成一个波浪拾取列表

其思想是,每当wave pick列表的状态更改为picking时,就会发出推送通知,然后在webhook处理程序中使用该通知

我已经成功地获得了推送通知设置,webhook处理程序正在很好地接收通知。到目前为止,我已经设法在webhook处理程序中获得了一些很好的身份验证(遵循中的概念),但是我有点不了解如何真正实现以编程方式生成wave picklist的目标

据我所知,我需要做3件事才能让它工作:

  • 设置SOPickingWorksheetProcess.HeaderFilter&SOPickingWorksheetProcess.HeaderSettings值(以使后续请求/流程可以拾取这些值的方式),以便筛选适用的装运,并填充拾取者+提手的数量,等等
  • “从筛选器将返回的装运的较大列表中选择”工作表中应处理/包括的特定数量的装运。理想情况下,我希望一次装运4批货
  • 触发“流程”,以便创建工作表
  • 作为一个附带问题,我使用推送通知和Webhook的方法有意义吗?我们的想法是,当仓库的拣选人员开始拣选清单时,总是要生成一批新的拣选清单,但我们不应该提前生成太多的拣选清单(因为我们希望在不久的将来包含一些逻辑,以满足快递等方面的需求),这意味着我们不能仅仅使用自动化计划在时间间隔的基础上生成这些

    我们将非常感谢您的任何帮助

    我已准备好以下代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net.Http;
    using System.Net.Http.Formatting;
    using System.Threading;
    using System.Threading.Tasks;
    using System.Web.Http;
    using System.Web.Http.Results;
    using Newtonsoft.Json;
    using PX.Common;
    using PX.Data;
    using PX.Data.Webhooks;
    using PX.Objects;
    using PX.Objects.SO;
    using SHPNW.Helpers;
    
    namespace SHPNW
    {
        public class WavePickListAutomationHandler : IWebhookHandler
        {
            public async Task<System.Web.Http.IHttpActionResult> ProcessRequestAsync(
              HttpRequestMessage request, CancellationToken cancellationToken)
            {
                var ok = new OkResult(request);
    
                using (var scope = GetAdminScope())
                {
                    try
                    {
                        // Deserialize JSON into our Notification class
                        var notification = JsonConvert.DeserializeObject<NotificationMessage>(await request.Content.ReadAsStringAsync());
    
                        // No changes to make, lets exit
                        if (notification == null || (notification?.Inserted?.Count ?? 0) < 1)
                        {
                            return ok;
                        }
    
                        // Authorization Check
                        var secret = string.Empty;
    
                        if (request.Headers.TryGetValues("AuthHeaderKey", out IEnumerable<string> headerValues))
                        {
                            secret = headerValues.FirstOrDefault();
                        }
    
                        var queryHash = 'A UNIQUE HASHED STRING';
    
                        // If secret does not match we reject the notification
                        if (secret != queryHash)
                        {
                            return new StatusCodeResult(System.Net.HttpStatusCode.Unauthorized, request);
                        }
    
                        // Use the Create & Print Pick Lists graph to generate the next wave.
                        var graph = PXGraph.CreateInstance<SOPickingWorksheetProcess>();
                        var filter = graph.Filter;
    
                        // Here I would need to set the values on the filter
    
                        // Here I would need to 'select' 4 shipments from the filtered list of shipments.
    
                        // Here I would need to 'trigger' the Process button.
    
                    }
                    catch (Exception ex)
                    {
                        var failed = new ExceptionResult(ex, false, new DefaultContentNegotiator(), request, new[] { new JsonMediaTypeFormatter() });
                        return failed;
                    }
                }
    
                return ok;
            }
    
            private IDisposable GetAdminScope()
            {
                var userName = "admin";
                if (PXDatabase.Companies.Length > 0)
                {
                    var company = PXAccess.GetCompanyName();
                    if (string.IsNullOrEmpty(company))
                    {
                        company = PXDatabase.Companies[0];
                    }
                    userName = userName + "@" + company;
                }
                return new PXLoginScope(userName);
            }
        }
    }
    
    使用系统;
    使用System.Collections.Generic;
    使用System.Linq;
    使用System.Net.Http;
    使用System.Net.Http.Formatting;
    使用系统线程;
    使用System.Threading.Tasks;
    使用System.Web.Http;
    使用System.Web.Http.Results;
    使用Newtonsoft.Json;
    使用PX.Common;
    使用PX数据;
    使用PX.Data.Webhooks;
    使用PX.Objects;
    使用PX.Objects.SO;
    使用SHPNW.Helpers;
    命名空间SHPNW
    {
    公共类WavePickListAutomationHandler:IWebhookHandler
    {
    公共异步任务ProcessRequestAsync(
    HttpRequestMessage请求,CancellationToken CancellationToken)
    {
    var ok=新的ok结果(请求);
    使用(var scope=GetAdminScope())
    {
    尝试
    {
    //将JSON反序列化到我们的通知类中
    var notification=JsonConvert.DeserializeObject(wait request.Content.ReadAsStringAsync());
    //没有要做的更改,让我们退出
    如果(通知==null | |(通知?.Inserted?.Count?0)<1)
    {
    返回ok;
    }
    //授权检查
    var secret=string.Empty;
    if(request.Headers.TryGetValues(“AuthHeaderKey”,out IEnumerable headerValues))
    {
    secret=headerValues.FirstOrDefault();
    }
    var queryHash='A UNIQUE hash STRING';
    //如果机密不匹配,我们将拒绝通知
    如果(机密!=查询)
    {
    返回新的StatusCodeResult(System.Net.HttpStatusCode.Unauthorized,request);
    }
    //使用“创建和打印拾取列表”图形生成下一个波浪。
    var-graph=PXGraph.CreateInstance();
    var filter=graph.filter;
    //在这里,我需要设置过滤器上的值
    //在这里,我需要从筛选的装运列表中“选择”4个装运。
    //在这里,我需要“触发”进程按钮。
    }
    捕获(例外情况除外)
    {
    var failed=new ExceptionResult(例如,false,new defaultcontentcongregator(),request,new[]{new JsonMediaTypeFormatter()});
    返回失败;
    }
    }
    返回ok;
    }
    私有IDisposable GetAdminScope()
    {
    var userName=“admin”;
    如果(PXDatabase.companys.Length>0)
    {
    var company=PXAccess.GetCompanyName();
    if(string.IsNullOrEmpty(公司))
    {
    company=PXDatabase.companys[0];
    }
    用户名=用户名+“@”+公司;
    }
    返回新的PXLoginScope(用户名);
    }
    }
    }
    
    查看源代码中的processing delegate ProcessShipmentsHandler()方法,该方法可以让您了解如何以编程方式生成wave picklist。