diff --git a/Sln.Wcs.HikRoBotApi/Service/Impl/HikRoBotService.cs b/Sln.Wcs.HikRoBotApi/Service/Impl/HikRoBotService.cs index ecdd3d2..7ddd699 100644 --- a/Sln.Wcs.HikRoBotApi/Service/Impl/HikRoBotService.cs +++ b/Sln.Wcs.HikRoBotApi/Service/Impl/HikRoBotService.cs @@ -1,6 +1,5 @@ using Sln.Wcs.HikRoBotApi.Domain.Dto.CancelTask; using Sln.Wcs.HikRoBotApi.Domain.Dto.ContinueTask; -using Sln.Wcs.HikRoBotApi.Domain.Dto.GenAgvSchedulingTask; using Sln.Wcs.HikRoBotApi.Enum; using Sln.Wcs.HikRoBotApi.Util; using Sln.Wcs.HikRoBotSdk; @@ -10,6 +9,9 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; +using Sln.Wcs.HikRoBotSdk.Dto.GenAgvSchedulingTask; +using GenAgvSchedulingTaskDto = Sln.Wcs.HikRoBotApi.Domain.Dto.GenAgvSchedulingTask.GenAgvSchedulingTaskDto; +using GenAgvSchedulingTaskResultDto = Sln.Wcs.HikRoBotApi.Domain.Dto.GenAgvSchedulingTask.GenAgvSchedulingTaskResultDto; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- @@ -65,10 +67,19 @@ namespace Sln.Wcs.HikRoBotApi.Service.Impl throw new ArgumentException($"输入参数为空。"); } + // var data = new HikRoBotSdk.Dto.GenAgvSchedulingTask.GenAgvSchedulingTaskDto() + // { + // reqCode = genAgvSchedulingTask.reqCode, + // taskTyp = genAgvSchedulingTask.taskTyp, + // }; var data = new HikRoBotSdk.Dto.GenAgvSchedulingTask.GenAgvSchedulingTaskDto() { - reqCode = genAgvSchedulingTask.reqCode, - taskTyp = genAgvSchedulingTask.taskTyp, + taskType = "PF-FMR-COMMON", + targetRoutes = new List() + { + new targetRoute(){type = "STORAGE",code = "R5001A02011"}, + new targetRoute(){type = "STORAGE",code = "R5001A01011"} + } }; var resp = this.hikRoBotSdk.GenAgvSchedulingTask(data); @@ -83,8 +94,8 @@ namespace Sln.Wcs.HikRoBotApi.Service.Impl { code = resp.code, message = resp.message, - reqCode = resp.reqCode, - data = resp.data + //reqCode = resp.reqCode, + //data = resp.data }, }; diff --git a/Sln.Wcs.HikRoBotSdk/Config/HikRoBotConfig.cs b/Sln.Wcs.HikRoBotSdk/Config/HikRoBotConfig.cs index dcb8fa4..0e43bed 100644 --- a/Sln.Wcs.HikRoBotSdk/Config/HikRoBotConfig.cs +++ b/Sln.Wcs.HikRoBotSdk/Config/HikRoBotConfig.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Flurl.Http; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- @@ -32,11 +33,10 @@ namespace Sln.Wcs.HikRoBotSdk.Config public class HikRoBotConfig { public readonly string api = ""; - public readonly string partnerId; - public readonly string accesskey; - public readonly string secretkey; - public readonly string version; - public readonly string test; + public readonly string contentType = ""; + public readonly string userAgent=""; + public readonly string xlrRequestId="";//随机生成 + public readonly string xlrVersion=""; /// /// 注入海康 SDK 配置参数 @@ -45,15 +45,26 @@ namespace Sln.Wcs.HikRoBotSdk.Config /// IConfiguration configuration public HikRoBotConfig(IConfiguration configuration) { - // if (string.IsNullOrEmpty(configuration["sdk_api"])) - // { - // throw new Exception("sdk_api 配置不正确,请检查Apollo配置."); - // } - // if (string.IsNullOrEmpty(configuration["sdk_json_str"])) - // { - // throw new Exception("sdk_partner_id 配置不正确,请检查Apollo配置."); - // } - // api = configuration["sdk_json_str"]; + if (string.IsNullOrEmpty(configuration["HikRoBot_Url"])) + { + throw new Exception("HikRoBot_Url 配置不正确,请检查Apollo配置."); + } + if (string.IsNullOrEmpty(configuration["HikRoBot_Content-Type"])) + { + throw new Exception("HikRoBot_Content-Type 配置不正确,请检查Apollo配置."); + } + if (string.IsNullOrEmpty(configuration["HikRoBot_User-Agent"])) + { + throw new Exception("HikRoBot_User-Agent 配置不正确,请检查Apollo配置."); + } + if (string.IsNullOrEmpty(configuration["HikRoBot_X-lr-version"])) + { + throw new Exception("HikRoBot_X-lr-version 配置不正确,请检查Apollo配置."); + } + api = configuration["HikRoBot_Url"]; + contentType = configuration["HikRoBot_ContentType"]; + userAgent = configuration["HikRoBot_User-Agent"]; + xlrVersion = configuration["HikRoBot_X-lr-version"]; } } diff --git a/Sln.Wcs.HikRoBotSdk/Dto/GenAgvSchedulingTask/GenAgvSchedulingTaskDto.cs b/Sln.Wcs.HikRoBotSdk/Dto/GenAgvSchedulingTask/GenAgvSchedulingTaskDto.cs index 0113ea8..4b3f7a1 100644 --- a/Sln.Wcs.HikRoBotSdk/Dto/GenAgvSchedulingTask/GenAgvSchedulingTaskDto.cs +++ b/Sln.Wcs.HikRoBotSdk/Dto/GenAgvSchedulingTask/GenAgvSchedulingTaskDto.cs @@ -30,129 +30,139 @@ namespace Sln.Wcs.HikRoBotSdk.Dto.GenAgvSchedulingTask { public class GenAgvSchedulingTaskDto { - //这里写请求参数 - /// - /// 请求编号,每个请求都要一个唯一编号, 同一个请求重复提交, 使用同一编号。; - /// - public string reqCode { get; set; } + + public string taskType{get;set;} + + public List targetRoutes{get;set;} + + // /// + // /// 请求编号,每个请求都要一个唯一编号, 同一个请求重复提交, 使用同一编号。; + // /// + // public string reqCode { get; set; } + // + // /// + // /// 请求时间截 格式: “yyyy-MM-dd HH:mm:ss”。 + // /// + // public string reqTime { get; set; } + // + // /// + // /// 客户端编号,如PDA,HCWMS等。 + // /// + // public string clientCode { get; set; } + // + // /// + // /// 令牌号, 由调度系统颁发 + // /// + // public string tokenCode { get; set; } + // + // /// + // /// 任务类型, + // /// 业务流程 + // /// 5层柜体来料验收拆分 柜体物料 提升机输送线对接位-验收拆分区 WMS F501 2 + // /// 5层柜体来料入库 柜体物料 验收拆分区-原材料周转区 WMS F502 2 + // /// 5层辅料立体库物料入库 辅料料箱 回转输送线回库口-辅料库货架 WMS F503 1 + // /// 5层辅料立体库分拣出库 辅料料箱 辅料库货架-回转输送线出库口 WMS F504 1 + // /// 5层辅料立体库分拣回库 辅料料箱 回转输送线回库口-辅料库货架 WMS F505 1 + // /// 5层辅料配送流程 辅料料箱 物料分拣位-装配区领料工位 WMS F506 空值 + // /// 5层背板安装区物料配送 柜体物料 原材料周转区-背板安装区 WMS F507 2 + // /// 5层半成品下线 半成品柜 背板安装区-半成品周转区 WMS F508 2 + // /// 5层半成品检验 半成品柜 半成品周转区-检测台 WMS F509 2 + // /// 5层成品柜体入库 成品柜体 检验台-成品区 WMS F510 2 + // /// 5层成品柜体出库 成品柜体 成品区-提升机输送线对接点 WMS F511 2 + // /// + // public string taskTyp { get; set; } + // + // /// + // /// 容器类型(叉车/CTU专用)叉车项目必传 + // /// + // public string ctnrTyp { get; set; } + // + // /// + // /// 容器编号(叉车/CTU专用) + // /// + // public string ctnrCode { get; set; } + // + // /// + // /// 容器数量(叉车堆叠专用),默认值1,仅记录堆叠的数量不记录堆叠的每个容器号 + // /// + // public string ctnrNum { get; set; } + // + // /// + // /// 任务模式 0-普通move 1-出库move 2-入库move 3-移库move + // /// + // public string taskMode { get; set; } + // + // /// + // /// 工作位,一般为机台或工作台位置,与RCS-2000端配置的位置名称一致, 工作位名称为字母\数字\或组合, 不超过32位。 + // /// + // public string wbCode { get; set; } + // + // /// + // /// 位置路径:AGV关键路径位置集合,与任务类型中模板配置的位置路径一一对应。待现场地图部署、配置完成后可获取。 + // /// + // public List positionCodePath { get; set; } + // + // /// + // /// “180”,”0”,”90”,”-90” 分别对应地图的”左”,”右”,”上”,”下” ,不指定方向可以为空 + // /// + // public string podDir { get; set; } + // + // /// + // /// “180”,”0”,”90”,”-90” 分别对应地图的”左”,”右”,”上”,”下” ,不指定方向可以为空 + // /// + // public string podTyp { get; set; } + // + // /// + // /// “180”,”0”,”90”,”-90” 分别对应地图的”左”,”右”,”上”,”下” ,不指定方向可以为空 + // /// + // public string podCode { get; set; } + // + // /// + // /// 物料批次或货架上的物料唯一编码, + // /// + // public string materialLot { get; set; } + // + // /// + // /// 物料类型, 仅移载机器人协议专用必填, 其它车型任务不填 + // /// + // public string materialType { get; set; } + // + // /// + // /// 优先级,从(1~127)级,最大优先级最高。为空时,采用任务模板的优先级。 + // /// + // public string priority { get; set; } + // + // /// + // /// 任务单号,选填, 不填系统自动生成,UUID小于等于64位 + // /// + // public string taskCode { get; set; } + // + // /// + // /// AGV编号,填写表示指定某一编号的AGV执行该任务 + // /// + // public string agvCode { get; set; } + // + // /// + // /// 组编号 + // /// + // public string groupId { get; set; } + // + // /// + // /// 设备类型 + // /// + // public string agvTyp { get; set; } + // + // /// + // /// 区域/策略中挑选货架以及根据物料批次挑选货架时的先进先出规则 + // /// + // public string positionSelStrategy { get; set; } + // + // public string data { get; set; } + } - /// - /// 请求时间截 格式: “yyyy-MM-dd HH:mm:ss”。 - /// - public string reqTime { get; set; } - - /// - /// 客户端编号,如PDA,HCWMS等。 - /// - public string clientCode { get; set; } - - /// - /// 令牌号, 由调度系统颁发 - /// - public string tokenCode { get; set; } - - /// - /// 任务类型, - /// 业务流程 - /// 5层柜体来料验收拆分 柜体物料 提升机输送线对接位-验收拆分区 WMS F501 2 - /// 5层柜体来料入库 柜体物料 验收拆分区-原材料周转区 WMS F502 2 - /// 5层辅料立体库物料入库 辅料料箱 回转输送线回库口-辅料库货架 WMS F503 1 - /// 5层辅料立体库分拣出库 辅料料箱 辅料库货架-回转输送线出库口 WMS F504 1 - /// 5层辅料立体库分拣回库 辅料料箱 回转输送线回库口-辅料库货架 WMS F505 1 - /// 5层辅料配送流程 辅料料箱 物料分拣位-装配区领料工位 WMS F506 空值 - /// 5层背板安装区物料配送 柜体物料 原材料周转区-背板安装区 WMS F507 2 - /// 5层半成品下线 半成品柜 背板安装区-半成品周转区 WMS F508 2 - /// 5层半成品检验 半成品柜 半成品周转区-检测台 WMS F509 2 - /// 5层成品柜体入库 成品柜体 检验台-成品区 WMS F510 2 - /// 5层成品柜体出库 成品柜体 成品区-提升机输送线对接点 WMS F511 2 - /// - public string taskTyp { get; set; } - - /// - /// 容器类型(叉车/CTU专用)叉车项目必传 - /// - public string ctnrTyp { get; set; } - - /// - /// 容器编号(叉车/CTU专用) - /// - public string ctnrCode { get; set; } - - /// - /// 容器数量(叉车堆叠专用),默认值1,仅记录堆叠的数量不记录堆叠的每个容器号 - /// - public string ctnrNum { get; set; } - - /// - /// 任务模式 0-普通move 1-出库move 2-入库move 3-移库move - /// - public string taskMode { get; set; } - - /// - /// 工作位,一般为机台或工作台位置,与RCS-2000端配置的位置名称一致, 工作位名称为字母\数字\或组合, 不超过32位。 - /// - public string wbCode { get; set; } - - /// - /// 位置路径:AGV关键路径位置集合,与任务类型中模板配置的位置路径一一对应。待现场地图部署、配置完成后可获取。 - /// - public List positionCodePath { get; set; } - - /// - /// “180”,”0”,”90”,”-90” 分别对应地图的”左”,”右”,”上”,”下” ,不指定方向可以为空 - /// - public string podDir { get; set; } - - /// - /// “180”,”0”,”90”,”-90” 分别对应地图的”左”,”右”,”上”,”下” ,不指定方向可以为空 - /// - public string podTyp { get; set; } - - /// - /// “180”,”0”,”90”,”-90” 分别对应地图的”左”,”右”,”上”,”下” ,不指定方向可以为空 - /// - public string podCode { get; set; } - - /// - /// 物料批次或货架上的物料唯一编码, - /// - public string materialLot { get; set; } - - /// - /// 物料类型, 仅移载机器人协议专用必填, 其它车型任务不填 - /// - public string materialType { get; set; } - - /// - /// 优先级,从(1~127)级,最大优先级最高。为空时,采用任务模板的优先级。 - /// - public string priority { get; set; } - - /// - /// 任务单号,选填, 不填系统自动生成,UUID小于等于64位 - /// - public string taskCode { get; set; } - - /// - /// AGV编号,填写表示指定某一编号的AGV执行该任务 - /// - public string agvCode { get; set; } - - /// - /// 组编号 - /// - public string groupId { get; set; } - - /// - /// 设备类型 - /// - public string agvTyp { get; set; } - - /// - /// 区域/策略中挑选货架以及根据物料批次挑选货架时的先进先出规则 - /// - public string positionSelStrategy { get; set; } - - public string data { get; set; } + public class targetRoute + { + public string type{get;set;} + public string code{get;set;} } } diff --git a/Sln.Wcs.HikRoBotSdk/Dto/GenAgvSchedulingTask/GenAgvSchedulingTaskResultDto.cs b/Sln.Wcs.HikRoBotSdk/Dto/GenAgvSchedulingTask/GenAgvSchedulingTaskResultDto.cs index d386294..6fbc3c6 100644 --- a/Sln.Wcs.HikRoBotSdk/Dto/GenAgvSchedulingTask/GenAgvSchedulingTaskResultDto.cs +++ b/Sln.Wcs.HikRoBotSdk/Dto/GenAgvSchedulingTask/GenAgvSchedulingTaskResultDto.cs @@ -43,14 +43,21 @@ namespace Sln.Wcs.HikRoBotSdk.Dto.GenAgvSchedulingTask /// public string message { get; set; } + public data data { get; set; } + /// /// 请求编号 /// - public string reqCode { get; set; } + public string errorCode { get; set; } /// /// 自定义返回(返回任务单号) /// - public string data { get; set; } + public bool success { get; set; } + } + + public class data + { + public string robotTaskCode { get; set; } } } diff --git a/Sln.Wcs.HikRoBotSdk/HIkRoBotSdk.cs b/Sln.Wcs.HikRoBotSdk/HIkRoBotSdk.cs index 31ceae6..88d636a 100644 --- a/Sln.Wcs.HikRoBotSdk/HIkRoBotSdk.cs +++ b/Sln.Wcs.HikRoBotSdk/HIkRoBotSdk.cs @@ -7,6 +7,7 @@ using Sln.Wcs.HikRoBotSdk.Dto.GenAgvSchedulingTask; using System; using System.Collections.Generic; using System.Linq; +using System.Security.Authentication; using System.Text; using System.Threading.Tasks; @@ -55,10 +56,15 @@ namespace Sln.Wcs.HikRoBotSdk /// public GenAgvSchedulingTaskResultDto GenAgvSchedulingTask(GenAgvSchedulingTaskDto genAgvSchedulingTask) { - + string url = $"{hikRoBotConfig.api}/task/submit"; + var request = url + .WithHeader("Content-Type", hikRoBotConfig.contentType) + .WithHeader("User-Agent",hikRoBotConfig.userAgent) + .WithHeader("X-lr-request-id", System.Guid.NewGuid().ToString("N")) + .WithHeader("X-lr-version", hikRoBotConfig.xlrVersion); Console.WriteLine($"请求报文:{JsonConvert.SerializeObject(genAgvSchedulingTask)}"); - return this.hikRoBotConfig.api.PostJsonAsync(genAgvSchedulingTask).Result.GetJsonAsync().Result; + return request.PostJsonAsync(genAgvSchedulingTask).Result.GetJsonAsync().Result; } /// diff --git a/Sln.Wcs/Program.cs b/Sln.Wcs/Program.cs index 203f000..6050bfb 100644 --- a/Sln.Wcs/Program.cs +++ b/Sln.Wcs/Program.cs @@ -1,9 +1,13 @@ using System.Reflection; using Com.Ctrip.Framework.Apollo; +using Flurl.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NeoSmart.Caching.Sqlite; +using Sln.Wcs.HikRoBotApi.Domain.Dto.GenAgvSchedulingTask; +using Sln.Wcs.HikRoBotApi.Service; +using Sln.Wcs.HikRoBotApi.Service.Impl; using Sln.Wcs.Repository; using Sln.Wcs.Serilog; using Sln.Wcs.Plc; @@ -18,6 +22,11 @@ namespace Sln.Wcs static async Task Main(string[] args) { + TimeZoneInfo chinaZone = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"); + DateTimeOffset utcNow = DateTimeOffset.UtcNow; + DateTimeOffset beijingTime = TimeZoneInfo.ConvertTime(utcNow, chinaZone); + string beijingTimeString = beijingTime.ToString("yyyy-MM-dd HH:mm"); + Console.WriteLine(beijingTimeString); var services = new ServiceCollection(); ConfigureServices(services); @@ -32,9 +41,16 @@ namespace Sln.Wcs // MaterialInStoreTest? service = serviceProvider.GetService(); // service?.Run(); + + //禁用 SSL + FlurlHttp.ConfigureClientForUrl("https://172.16.12.11") + .ConfigureInnerHandler(handler => + { + handler.ServerCertificateCustomValidationCallback = (_, _, _, _) => true; + }); - var service = serviceProvider.GetService(); - service.Run(); + // var service = serviceProvider.GetService(); + // var res = service.GetGenAgvSchedulingTask(new GenAgvSchedulingTaskDto()); Task.Delay(-1).Wait(); }