diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/AgvRealInfoOutput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/AgvRealInfoOutput.cs new file mode 100644 index 00000000..00817d05 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/AgvRealInfoOutput.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.Outputs +{ + /// + /// Agv 实时信息输出类 + /// + public class AgvRealInfoOutput + { + /// + /// 设备序号 + /// + public string deviceCode { get; set; } + /// + /// 设备所在二维码的x,y坐标,前边的值是x,后边的是y + /// + public double[] devicePostionRec { get; set; } + /// + /// 设备当前位置 + /// + public string devicePosition { get; set; } + /// + /// 方向,0.001度 + /// + public int oritation { get; set; } + /// + /// 速度 + /// + public int speed { get; set; } + /// + /// 当前搬运的货架编号,对应载具编号 + /// + public string shelfNumber { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/AgvRealInfoQuery.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/AgvRealInfoQuery.cs new file mode 100644 index 00000000..4ed35bbd --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/AgvRealInfoQuery.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.Queries +{ + /// + /// 获取Agv实时信息,查询输入参数 + /// + public class AgvRealInfoQuery + { + /// + /// 区域Id:集成控制系統提供,该字段主要用来区分不同的仓库或区域。默认为1 + /// + public string areaId { get; set; } = "1"; + /// + /// 设备类型 固定值:0 + /// + public int deviceType { get; set; } = 0; + /// + /// 设备编号:可用作模糊搜索。多个设备编号英文逗号分隔,不穿插所有 + /// + public string deviceCode { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs index 606f6ac9..0afc5cfb 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs @@ -22,6 +22,7 @@ using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.WarehouseMgr.Entities.Dto.Outputs; +using Tnb.WarehouseMgr.Entities.Dto.Queries; using Tnb.WarehouseMgr.Entities.Entity; using Tnb.WarehouseMgr.Entities.Enums; using Tnb.WarehouseMgr.Interfaces; @@ -365,6 +366,68 @@ namespace Tnb.WarehouseMgr return await ToApiResult(HttpStatusCode.OK, "未启用"); } + /// + /// 根据产线获取Agv列表 + /// + /// 产线Id,默认空,(潍柴的只有一条产线所以不用传) + /// + /// returns: + ///
{ + ///
name:设备名称 + ///
code:设备代码 + ///
} + ///
+ [HttpGet("lineId"), AllowAnonymous] + public async Task GetAgvListByLineId(string lineId = "") + { + var devList = await _db.Queryable().InnerJoin((a, b) => a.equip_type_id == b.id) + .Where((a, b) => b.code == "003" && b.status == 1) + .Select((a, b) => new + { + a.name, + a.code, + }) + .ToListAsync(); + return devList; + } + /// + /// 获取Agv实时信息 + /// + /// 查询输入参数 + /// + ///
{ + ///
deviceCode:设备序号 + ///
devicePostionRec:设备所在二维码的x,y坐标,前边的值是x,后边的是y + ///
devicePosition:设备当前位置 + ///
oritation:方向 + ///
speed:速度 + ///
shelfNumber:当前搬运的货架编号,对应载具编号 + ///
} + ///
+ [HttpGet, AllowAnonymous] + public async Task> GetAgvRealInfo([FromQuery] AgvRealInfoQuery q) + { + //请求Les接口,bing解析返回结果 绑定到AgvRealInfoOutput实例 此处忽略 + var devCodes = new[] { "Dev01", "Dev02", "Dev03", "Dev04", "Dev05" }; + if (!q.deviceCode.IsNullOrWhiteSpace()) + { + devCodes = devCodes.Where(x => q.deviceCode.Contains(x)).ToArray(); + } + var result = new List(); + for (int i = 0; i < devCodes.Length; i++) + { + AgvRealInfoOutput output = new(); + output.deviceCode = devCodes[i]; + output.oritation = 0; + output.speed = Random.Shared.Next(0, 100); + var x = Random.Shared.NextDouble() * 100; + var y = Random.Shared.NextDouble() * 100; + output.devicePostionRec = new[] { x, y }; + output.shelfNumber = "xxxx"; + result.Add(output); + } + return result; + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs index 3fd7551a..6718c9fd 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryService.cs @@ -238,11 +238,12 @@ namespace Tnb.WarehouseMgr { int i = 0, r = 0, num = 0; var nonZeroPattern = @"[1-9]+"; - if (Regex.IsMatch(input.carry_code, @"\d+")) + var code = input.carry_code.Match(@"\D+"); + if (input.carry_code.IsMatch(@"\d+")) { num = input.carry_code.Match(nonZeroPattern).ParseToInt(); } - var carrys = await _db.Queryable().Where(it => it.carry_code.Contains(input.carry_code)).ToListAsync(); + var carrys = await _db.Queryable().Where(it => it.carry_code.Contains(code)).ToListAsync(); if (carrys?.Count < 1) { i = Math.Max(num, 1); @@ -253,7 +254,7 @@ namespace Tnb.WarehouseMgr num = lastCarry?.carry_code.Match(nonZeroPattern).ParseToInt() ?? -1; i = num + 1; } - var code = input.carry_code.Match(@"\D+"); + var batchCarrys = new List(); for (; i <= input.quantity; i++) { @@ -266,7 +267,7 @@ namespace Tnb.WarehouseMgr carry.carry_name = carryCode; carry.carry_code = carryCode; carry.create_id = "25398501929509"; - carry.create_time= DateTime.Now; + carry.create_time = DateTime.Now; batchCarrys.Add(carry); } r = await _db.Insertable(batchCarrys).ExecuteCommandAsync();