针对潍柴项目,新增模拟获取Agv信息,实时数据接口
This commit is contained in:
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Agv 实时信息输出类
|
||||
/// </summary>
|
||||
public class AgvRealInfoOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备序号
|
||||
/// </summary>
|
||||
public string deviceCode { get; set; }
|
||||
/// <summary>
|
||||
/// 设备所在二维码的x,y坐标,前边的值是x,后边的是y
|
||||
/// </summary>
|
||||
public double[] devicePostionRec { get; set; }
|
||||
/// <summary>
|
||||
/// 设备当前位置
|
||||
/// </summary>
|
||||
public string devicePosition { get; set; }
|
||||
/// <summary>
|
||||
/// 方向,0.001度
|
||||
/// </summary>
|
||||
public int oritation { get; set; }
|
||||
/// <summary>
|
||||
/// 速度
|
||||
/// </summary>
|
||||
public int speed { get; set; }
|
||||
/// <summary>
|
||||
/// 当前搬运的货架编号,对应载具编号
|
||||
/// </summary>
|
||||
public string shelfNumber { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取Agv实时信息,查询输入参数
|
||||
/// </summary>
|
||||
public class AgvRealInfoQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// 区域Id:集成控制系統提供,该字段主要用来区分不同的仓库或区域。默认为1
|
||||
/// </summary>
|
||||
public string areaId { get; set; } = "1";
|
||||
/// <summary>
|
||||
/// 设备类型 固定值:0
|
||||
/// </summary>
|
||||
public int deviceType { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 设备编号:可用作模糊搜索。多个设备编号英文逗号分隔,不穿插所有
|
||||
/// </summary>
|
||||
public string deviceCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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, "未启用");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据产线获取Agv列表
|
||||
/// </summary>
|
||||
/// <param name="lineId">产线Id,默认空,(潍柴的只有一条产线所以不用传)</param>
|
||||
/// <returns>
|
||||
/// returns:
|
||||
/// <br/>{
|
||||
/// <br/> name:设备名称
|
||||
/// <br/> code:设备代码
|
||||
/// <br/>}
|
||||
/// </returns>
|
||||
[HttpGet("lineId"), AllowAnonymous]
|
||||
public async Task<dynamic> GetAgvListByLineId(string lineId = "")
|
||||
{
|
||||
var devList = await _db.Queryable<EqpEquipment>().InnerJoin<EqpEquipType>((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;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取Agv实时信息
|
||||
/// </summary>
|
||||
/// <param name="q">查询输入参数</param>
|
||||
/// <returns>
|
||||
/// <br/>{
|
||||
/// <br/> deviceCode:设备序号
|
||||
/// <br/> devicePostionRec:设备所在二维码的x,y坐标,前边的值是x,后边的是y
|
||||
/// <br/> devicePosition:设备当前位置
|
||||
/// <br/> oritation:方向
|
||||
/// <br/> speed:速度
|
||||
/// <br/> shelfNumber:当前搬运的货架编号,对应载具编号
|
||||
/// <br/>}
|
||||
/// </returns>
|
||||
[HttpGet, AllowAnonymous]
|
||||
public async Task<List<AgvRealInfoOutput>> 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<AgvRealInfoOutput>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<WmsCarryH>().Where(it => it.carry_code.Contains(input.carry_code)).ToListAsync();
|
||||
var carrys = await _db.Queryable<WmsCarryH>().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<WmsCarryH>();
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user