提交代码

This commit is contained in:
hehaibing-1996
2024-07-16 16:45:18 +08:00
parent ed3673db03
commit 7b8a885669
64 changed files with 1389 additions and 176 deletions

View File

@ -39,6 +39,8 @@ namespace WCS.BLL.Config
public string? WMSUrl { get; set; }
public bool IsResetDBOrTable { get; set; }
public int InstoreTimeOut { get; set; } = 5000;
#region
public bool IsMx { get; set; }
/// <summary>

View File

@ -0,0 +1,46 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.Model.ApiModel.OutStore;
namespace WCS.BLL.DbModels
{
[SugarTable("wcs_app_version")]
public class AppVersion
{
/// <summary>
/// 主键 自增Id
/// </summary>
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// APP文件名称
/// </summary>
[SugarColumn(ColumnName = "app_name", Length = 100, IsNullable = false, ColumnDescription = "APP文件名称")]
public string AppName { get; set; }
/// <summary>
/// 版本号
/// </summary>
[SugarColumn(ColumnName = "version", Length = 100, IsNullable = false, ColumnDescription = "版本号")]
public string Version { get; set; }
/// <summary>
/// 更新内容
/// </summary>
[SugarColumn(ColumnName = "content", Length = 250, IsNullable = true, ColumnDescription = "更新内容")]
public string Content { get; set; }
/// <summary>
/// 操作时间
/// </summary>
[SugarColumn(ColumnName = "operate_time", IsNullable = false, ColumnDescription = "操作时间")]
public DateTime OperateTime { get; set; } = DateTime.Now;
}
}

View File

@ -72,6 +72,18 @@ namespace WCS.DAL.DbModels
[SugarColumn(ColumnName = "client_ip", Length = 50, IsNullable = false, ColumnDescription = "货架对应Can模块的Ip")]
public string ClientIp { get; set; }
/// <summary>
/// 连接Can模块的端口号
/// </summary>
[SugarColumn(ColumnName = "port", Length = 50, IsNullable = true, ColumnDescription = "连接Can模块的端口号")]
public string Port { get; set; }
/// <summary>
/// 货架对应后端的Ip
/// </summary>
[SugarColumn(ColumnName = "server_ip", Length = 50, IsNullable = false, ColumnDescription = "货架对应后端服务的Ip")]
public string ServerIp { get; set; }
/// <summary>
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
/// </summary>

View File

@ -66,6 +66,8 @@ namespace WCS.BLL.HardWare
public string GroupName { get; set; }
public string WebSocketIpAddress { get; set; }
public string? CurrentCom { get; set; }
/// <summary>
/// 模组
/// </summary>

View File

@ -4,6 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.BLL.DbModels;
using WCS.BLL.Manager;
using WCS.DAL.Db;
using WCS.DAL.DbModels;
using WCS.Model;
using static WCS.BLL.HardWare.WarningLight;
@ -11,26 +14,40 @@ namespace WCS.BLL.HardWare
{
public class SingleLightShelf : IShelfBase
{
public int ShelfId { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public string ShelfCode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public int RowCounts { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public int ColumnCounts { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public Mode CurrentMode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public string ModulesStr { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public string GroupName { get; set; }
public MatInfoResponse InStoreData { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public SingleLightShelf(ShelfInfo shelfInfo)
{
ShelfId = shelfInfo.Id;
ShelfCode = shelfInfo.ShelfCode;
RowCounts = shelfInfo.Rowcounts;
ColumnCounts = shelfInfo.Columncounts;
SetCurrentMode(Mode.);
ClientIp = shelfInfo.ClientIp;
LightId = shelfInfo.LightId;
}
public int ShelfId { get; set; }
public string ShelfCode { get; set; }
public int RowCounts { get; set; }
public int ColumnCounts { get; set; }
public Mode CurrentMode { get; set; }
public string ModulesStr { get; set; }
public string GroupName { get; set; }
public MatInfoResponse InStoreData { get; set; }
public string? CurrentCom { get; set; } = string.Empty;
public string OrderNumber { get; set; }
public int LightId { get; set; }
public LightColorEnum LightColor { get; set; }
public List<int> ModuleIds { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public string ClientIp { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public List<string> ExceptionMessages { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public bool IsWarning { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public string WebSocketIpAddress { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public List<SmartShelfModule> Modules { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public List<int> ModuleIds { get; set; }
public string ClientIp { get; set; }
public List<string> ExceptionMessages { get; set; }
public bool IsWarning { get; set; }
public string WebSocketIpAddress { get; set; }
public List<SmartShelfModule> Modules { get; set; } = new List<SmartShelfModule>();
public DateTime SetCurrentModeTime { get; set; }
public TCPClient TcpCleint { get { return TCPClientManager.GetTCPClientByIPHost(ClientIp); } }
public bool ConfirmStocktakingSingle(int BoardId, int LightNumber)
{
throw new NotImplementedException();

View File

@ -56,6 +56,7 @@ namespace WCS.BLL.HardWare
public int RowCounts { get; set; }
public int ColumnCounts { get; set; }
public Mode CurrentMode { get; set; }
public DateTime SetCurrentModeTime { get; set; }
public string ModulesStr { get; set; }//当前货架所有模组的Str
public string GroupName { get; set; }
@ -95,7 +96,6 @@ namespace WCS.BLL.HardWare
/// </summary>
public List<ProcessingExceptionType> ProcessingExceptions { get; set; } = new List<ProcessingExceptionType>();
public string? CurrentCom { get; set; } = string.Empty;
//TODO 退出入库清除
public MatInfoResponse InStoreData { get; set; }
@ -119,6 +119,7 @@ namespace WCS.BLL.HardWare
{
try
{
Logs.Write($"[GoInInstore IPAddress]{IPAddress}", LogsType.Instore);
if (this.CurrentMode == Mode.)
{
CurrentCom = IPAddress;
@ -217,6 +218,7 @@ namespace WCS.BLL.HardWare
WarningLight.BlueLight(TcpCleint);
//绑定当前进入入库PDA/WCS前端的IP
CurrentCom = IPAddress;
Logs.Write($"[GoInInstore CurrentCom]{CurrentCom}", LogsType.Instore);
//返回成功
return;
}
@ -866,6 +868,15 @@ namespace WCS.BLL.HardWare
}
}
public void CalibrationSetOffset(int moduleId, int offSet)
{
var moudle = Modules.Where(t => t.ModuleId == moduleId).First();
if (moudle != null)
{
moudle.CalibrationSetOffset(offSet, TcpCleint);
}
}
public void SetCurrentMode(Mode mode)
{
this.CurrentMode = mode;
@ -891,11 +902,62 @@ namespace WCS.BLL.HardWare
{
try
{
OrderNumber = "自检中...";
if (CurrentMode == Mode.)
OrderNumber = "自检中...";
foreach (var module in Modules.Where(t => t.IsEnable).ToList())
{
module.IsSelfCheck = true;
module.ShelfCheck(TcpCleint);
}
//状态校验 自检模式未响应
Task.Run(() =>
{
var timeOut = 3000;
var timeSpan = TimeSpan.FromMilliseconds(0);
var beginTime = DateTime.Now;
while (timeSpan <= TimeSpan.FromMilliseconds(timeOut))
{
timeSpan = DateTime.Now - beginTime;
//所有板子成功进入入库模式 表示进入入库模式成功,跳出循环
var isSelfChecking = Modules.Where(t => t.IsSelfCheck)
.Where(t => t.IsEnable)
.Any();
if (!isSelfChecking)
{
break;
}
//循环延时处理
Thread.Sleep(50);
}
var notReturnList = Modules.Where(t => t.IsSelfCheck)
.Where(t => t.IsEnable).ToList();
if (notReturnList.Count > 0)
{
Logs.Write($"货架{ShelfCode}存在模组自检未响应:", LogsType.Instore);
foreach (var item in notReturnList)
{
ExceptionMessages.Add($"模组{item.ModuleCode}未响应自检!");
}
//通信校验
var messages = notReturnList.Select(t => $"模组{t.ModuleCode}未响应自检!").ToList();
var exceptionMessage = string.Join("\r\n", messages);
var warningModel = new WebSocketMessageModel()
{
IsWarning = false,
WarningType = WarningTypeEnum.,
StoreId = 0,
StoreCode = "",
ShelfCode = ShelfCode,
ShelfId = ShelfId,
WarningMessage = exceptionMessage,
ClientIp = WebSocketIpAddress,
};
WarningManager.SendWarning(warningModel);
}
});
}
catch (Exception ex)
{
@ -903,7 +965,8 @@ namespace WCS.BLL.HardWare
}
finally
{
OrderNumber = string.Empty;
if (CurrentMode == Mode.)
OrderNumber = string.Empty;
}
}
#endregion
@ -1211,7 +1274,6 @@ namespace WCS.BLL.HardWare
if (storeInfo == null)
{
//TODO 报错
return;
}
@ -1219,7 +1281,6 @@ namespace WCS.BLL.HardWare
.FirstOrDefault();
if (module == null)
{
//TODO 报错
return;
}
@ -1261,7 +1322,7 @@ namespace WCS.BLL.HardWare
{
module.ComfirmErrInstore(TcpCleint);
WarningLight.WaringLightBlueEnd(TcpCleint);
//TO DO Logs.Write($"[{guid}]该位置已放置物料!");
Logs.Write($"{storeInfo.StoreCode}该位置已放置物料!", LogsType.Instore);
return;
}
#endregion
@ -1293,7 +1354,7 @@ namespace WCS.BLL.HardWare
MatSupplier = this.InStoreData.supplier,
InstoreTime = DateTime.Now,
InstoreUser = ""
InstoreUser = this.InStoreData.InstoreUser,
};
//出入库记录表
@ -1367,9 +1428,10 @@ namespace WCS.BLL.HardWare
.Where(t => t.ShelfId == ShelfId)
.Where(t => t.BoardId == boardId && t.LightNumber == lightNumber)
.First();
//库位未找到
if (storeInfo == null)
{
//TO DO 库位未找到
Logs.Write($"【InStoreExceptionReturnProcess】boardId:{boardId},lightNumber{lightNumber},库位未找到 ", LogsType.Instore);
return;
}
//已放物料丢失了 物料多放了 储位恢复正常
@ -1421,6 +1483,8 @@ namespace WCS.BLL.HardWare
};
WarningManager.SendWarning(warningModel);
WarningLight.WaringLightAlwaysRed(TcpCleint);
ProcessingExceptions.Add(new ProcessingExceptionType()
{
BoardId = boardId,
@ -1446,6 +1510,8 @@ namespace WCS.BLL.HardWare
};
WarningManager.SendWarning(warningModel);
WarningLight.WaringLightAlwaysRed(TcpCleint);
ProcessingExceptions.Add(new ProcessingExceptionType()
{
BoardId = boardId,
@ -1651,6 +1717,7 @@ namespace WCS.BLL.HardWare
var orderMatDetails = DbHelp.db.Queryable<OutOrderMatDetail>()
.Where(t => t.OrderId == CurrentOutOrder.Id)
.Where(t => t.MatSN == inventoryDetail.MatSN)
.Where(t => t.IsSended == false)
.First();
if (orderMatDetails == null)
@ -2030,7 +2097,9 @@ namespace WCS.BLL.HardWare
WarningMessage = exceptionMessage,
ClientIp = WebSocketIpAddress,
};
WarningManager.SendWarning(warningModel);
WarningLight.WaringLightAlwaysRed(TcpCleint);
ProcessingExceptions.Add(new ProcessingExceptionType()
{
@ -2055,7 +2124,9 @@ namespace WCS.BLL.HardWare
WarningMessage = exceptionMessage,
ClientIp = WebSocketIpAddress
};
WarningManager.SendWarning(warningModel);
WarningLight.WaringLightAlwaysRed(TcpCleint);
ProcessingExceptions.Add(new ProcessingExceptionType()
{
@ -2182,6 +2253,16 @@ namespace WCS.BLL.HardWare
public void SelfCheckProcess(byte[] data, int boardId, int lightNumber)
{
var module = this.Modules.Where(t => t.BoardId == boardId).FirstOrDefault();
if (module == null)
{
return;
}
else
{
module.IsSelfCheck = false;
}
if (data[TcpCleint.PreFixLength + 3] == 0x01)
{
//比对结果相同

View File

@ -75,20 +75,33 @@ namespace WCS.BLL.HardWare
/// </summary>
public byte[] VoltageSingleData = { 0x17, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/// <summary>
/// 电压偏移值
/// 查询电压偏移值
/// </summary>
public byte[] OffsetSingleData = { 0x18, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/// <summary>
/// 电压标准值
/// 查询电压标准值
/// </summary>
public byte[] StandardSingleData = { 0x19, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/// <summary>
/// 标定
/// </summary>
public byte[] CalibrationData = { 0x0D, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/// <summary>
/// 设置偏移量 01 F4 = 500
/// </summary>
public byte[] SetOffsetData = { 0x0E, 0x0A, 0x01, 0xF4, 0x00, 0x00, 0x00, 0x00 };
#endregion
public int ModuleId { get; set; }
public string ModuleCode { get; set; }
public int BoardId { get; set; }
public bool IsEnable { get; set; }
public Mode CurrentMode { get; set; }
/// <summary>
/// 是否已发送自检命令
/// </summary>
public bool IsSelfCheck { get; set; } = false;
public List<string> CurrentOutSns { get; set; }
public List<string> CurrentStockTakingSns { get; set; }
@ -197,7 +210,7 @@ namespace WCS.BLL.HardWare
/// <param name="tcpClient"></param>
public void GoInOutStoreMode(TCPClient tcpClient, List<string> outSns)
{
Logs.Write($"模组{ModuleCode},本次亮灯物料{string.Join(",",outSns)}", LogsType.Outstore);
Logs.Write($"模组{ModuleCode},本次亮灯物料{string.Join(",", outSns)}", LogsType.Outstore);
CurrentOutSns = outSns;
var storeInfos = DbHelp.db.Queryable<StoreInfo>().Where(t => t.ModuleId == ModuleId)
.Where(t => t.BoardId == BoardId)
@ -408,5 +421,25 @@ namespace WCS.BLL.HardWare
tcpClient.Send(tcpClient.GenerateMessage(BoardId, OffsetSingleData));
});
}
public void CalibrationSetOffset(int offSet, TCPClient tcpClient)
{
var offSetData = BitConverter.GetBytes(unchecked((short)offSet));
// 检查是否需要交换字节
if (BitConverter.IsLittleEndian)
{
// 如果是小端序系统,则交换字节
byte temp = offSetData[0];
offSetData[0] = offSetData[1];
offSetData[1] = temp;
}
SetOffsetData[2] = offSetData[0];
SetOffsetData[3] = offSetData[1];
tcpClient.Send(tcpClient.GenerateMessage(BoardId, CalibrationData));
Thread.Sleep(100);
tcpClient.Send(tcpClient.GenerateMessage(BoardId, SetOffsetData));
}
}
}

View File

@ -61,10 +61,12 @@ namespace WCS.BLL.Manager
Logs.Write("【初始化数据库】MX", LogsType.StartBoot);
}
//手动修改后台配置后再进行CodeFirst 数据库的生成、表的生成
//如果不配置此参数 每次启动都会持续几十秒才能成功启动后端
if (LocalFile.Config.IsResetDBOrTable)
{
#region
DbHelp.db.DbMaintenance.CreateDatabase();
//新部署时 日志需要建表 不然没得接口记录
DbHelp.dbLog.DbMaintenance.CreateDatabase();
Logs.Write("【初始化数据库】创建数据库", LogsType.StartBoot);
@ -72,12 +74,13 @@ namespace WCS.BLL.Manager
, typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail)
, typeof(ShelfTypeInfo), typeof(MatBaseInfo), typeof(MatInfo)
, typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord)
, typeof(DocumentSerialNumber),typeof(OrderLight),typeof(MatInfoLog)
, typeof(DocumentSerialNumber), typeof(OrderLight), typeof(MatInfoLog)
, typeof(AppVersion)
);
Logs.Write("【初始化数据库】db建表", LogsType.StartBoot);
Logs.Write("【初始化数据库】db业务数据库建表", LogsType.StartBoot);
DbHelp.dbLog.CodeFirst.InitTables(typeof(SystemApiLogRecord));
Logs.Write("【初始化数据库】logdb建表", LogsType.StartBoot);
Logs.Write("【初始化数据库】dblog(日志数据库)建表", LogsType.StartBoot);
//初始化单据序列号数据
if (!DbHelp.db.Queryable<DocumentSerialNumber>().Any())
@ -88,14 +91,12 @@ namespace WCS.BLL.Manager
UpdateDate = DateTime.Now,
CurrentSerialNumber = 0
};
var stockTakingDocumentSerialNumber = new DocumentSerialNumber()
{
DocumentType = DocumentTypeEnum.,
UpdateDate = DateTime.Now,
CurrentSerialNumber = 0
};
DbHelp.db.Insertable(outDocumentSerialNumber).ExecuteCommand();
DbHelp.db.Insertable(stockTakingDocumentSerialNumber).ExecuteCommand();
}

View File

@ -47,7 +47,7 @@ namespace WCS.BLL.Manager
GroupName = shelfInDb.GroupName,
};
case 2:
return new SmartShelf(shelfInDb)
return new SingleLightShelf(shelfInDb)
{
ShelfId = shelfInDb.Id,
ShelfCode = shelfInDb.ShelfCode,

View File

@ -29,7 +29,12 @@ namespace WCS.BLL.Manager
var clientsInDB = DbHelp.db.Queryable<ShelfInfo>()
.WhereIF(!string.IsNullOrEmpty(LocalFile.Config.GroupName), t => t.GroupName == LocalFile.Config.GroupName)
.Select(t => new { IP = t.ClientIp, ShelfTypeName = t.ShelfTypeName })
.Select(t => new
{
IP = t.ClientIp,
ShelfTypeName = t.ShelfTypeName,
Port = t.Port,
})
.Distinct()
.ToList();
Logs.Write($"【InitTcpClient】需要连接的服务端地址如下\r\n{string.Join(";", clientsInDB)}", LogsType.StartBoot);
@ -37,7 +42,7 @@ namespace WCS.BLL.Manager
{
Task.Run(() =>
{
var tcpCleint = new TCPClient(cleientInDB.IP, "",cleientInDB.ShelfTypeName);
var tcpCleint = new TCPClient(cleientInDB.IP, cleientInDB.Port, cleientInDB.ShelfTypeName);
tcpCleint.tcpClient.Received += (client, e) =>
{
var clientIpHost = client.IP + ":" + client.Port;
@ -123,7 +128,7 @@ namespace WCS.BLL.Manager
if (TcpCleint.IsFirstConnected == false)
{
Logs.Write($"【InitTcpClient】{clientIpHost}完成首次连接", LogsType.StartBoot);
Console.WriteLine($"【InitTcpClient】{clientIpHost}完成首次连接");
@ -138,8 +143,8 @@ namespace WCS.BLL.Manager
return EasyTask.CompletedTask;
};
lock(TCPClients)//避免添加失败的情况
{
lock (TCPClients)//避免添加失败的情况
{
TCPClients.Add(tcpCleint);
}

View File

@ -50,10 +50,12 @@ namespace WCS.BLL.Manager
lock (flag)
{
Warnings.Add(warning);
//发送WebSocket记录
Logs.Write(JsonConvert.SerializeObject(warning),LogsType.WebSocket);
WebSoceketManager.TrySendMessage(warning.ClientIp, JsonConvert.SerializeObject(warning));
warning.LastSendTime = DateTime.Now;
}
}
public static void ClearWarning(WebSocketMessageModel warning, SolveTypeEnum solveType)
@ -66,7 +68,6 @@ namespace WCS.BLL.Manager
{
if (solveType == SolveTypeEnum.)
{
//TODO 对应报警处理对应的数据
switch (warningInManager.WarningType)
{
case WarningTypeEnum.:

View File

@ -48,7 +48,6 @@ namespace WCS.BLL.Manager
var warningInManager = WarningManager.Warnings.Where(t => t.Guid == warning.Guid).FirstOrDefault();
if (warningInManager != null)
{
warningInManager.ClientIsReceived = true;
}
}

View File

@ -1,8 +1,10 @@

using WCS.Model;
namespace WCS.BLL.Services.IService
{
public interface IHomerService
{
public Task<ResponseBase> GetShelfServer(RequestBase request);
}
}

View File

@ -14,5 +14,7 @@ namespace WCS.BLL.Services.IService
public Task<ResponseBase> StartSelfCheckByShelfCode(StartSelfCheckByShelfCodeRequest request);
public Task<ResponseBase> StartSelfCheckByGroupName(List<string> GroupNames);
}
}

View File

@ -52,7 +52,13 @@ namespace WCS.BLL.Services.IService
/// <returns></returns>
public Task<ResponseCommon> queryModuleVoltage(QueryModuleVoltageRequest request);
/// <summary>
/// 标定+设置偏移量
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public Task<ResponseCommon> calibrationSetOffset(CalibrationSetOffsetRequest request);
/// <summary>
/// 查询库位列表
/// </summary>

View File

@ -4,11 +4,35 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.BLL.Services.IService;
using WCS.DAL.Db;
using WCS.DAL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.Home;
namespace WCS.BLL.Services.Service
{
public class HomerService: IHomerService
public class HomerService : IHomerService
{
public HomerService() { }
public async Task<ResponseBase> GetShelfServer(RequestBase request)
{
//直接获取数据库数据 分组进行返回
var data = await DbHelp.db.Queryable<ShelfInfo>()
.Where(t => !string.IsNullOrEmpty(t.BigShelfCode))
.Select(t => new GetShelfServerResponseItem()
{
BigShelfCode = t.BigShelfCode,
ServerIp = t.ServerIp,
})
.Distinct()
.ToListAsync();
return new GetShelfServerResponse()
{
Code = 200,
Message = "success",
Data = data
};
}
}
}

View File

@ -220,7 +220,7 @@ namespace WCS.BLL.Services.Service
Message = "success"
};
}
else if (Result != null && Result.Code == 200 && Result.Data == null)
else if (Result != null && Result.Code == 200 && (Result.Data == null || Result.Data.Count == 0))
{
//Mes系统中未获取到物料信息
@ -295,7 +295,6 @@ namespace WCS.BLL.Services.Service
var matInfo = await DbHelp.db.Queryable<MatInfo>().Where(t => t.MatSn == request.MatSn).FirstAsync();
if (matInfo != null)
{
//TODO 改成wcs的实体
if (!request.SingleLightIn && shelf != null)
shelf.InStoreData = new MatInfoResponse()
{
@ -391,8 +390,8 @@ namespace WCS.BLL.Services.Service
};
}
//TODO 配置这个时间相当于需要入库扫码后需要等待的时间
var timeOut = 5000;
//配置这个时间相当于需要入库扫码后需要等待的时间
var timeOut = LocalFile.Config.InstoreTimeOut;
var timeSpan = TimeSpan.FromMilliseconds(0);
var beginTime = DateTime.Now;
while (timeSpan <= TimeSpan.FromMilliseconds(timeOut))

View File

@ -52,7 +52,8 @@ namespace WCS.BLL.Services.Service
Message = $"操作失败:库位【{string.Join(",", storeCodeList)}】不存在!",
};
}
//第二步 获取当前所有库位任务
//第二步 获取库位正在进行的任务
//模式相同视为可以继续发送任务
var currenTasks = DbHelp.db.Queryable<CurrentTask>()
.Where(t => storeCodeList.Contains(t.StoreCode))

View File

@ -5,7 +5,10 @@ using System.Text;
using System.Threading.Tasks;
using WCS.BLL.Manager;
using WCS.BLL.Services.IService;
using WCS.DAL.Db;
using WCS.DAL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.Home;
using WCS.Model.ApiModel.SelfCheck;
using WCS.Model.WebSocketModel;
@ -63,10 +66,11 @@ namespace WCS.BLL.Services.Service
foreach (var ip in cleintIps)
{
var currentIdShelfs = shelfs.Where(t => t.ClientIp == ip)
.Where(t => t.CurrentMode == HardWare.Mode.)
.ToList();
Task.Run(() =>
{
foreach(var shelf in currentIdShelfs)
foreach (var shelf in currentIdShelfs)
{
Task.Run(() =>
@ -116,5 +120,7 @@ namespace WCS.BLL.Services.Service
Message = $"已成功开始自检!",
};
}
}
}

View File

@ -240,7 +240,7 @@ namespace WCS.BLL.Services.Service
}
/// <summary>
/// TODO HardCode 根据模组信息生成库位
///
/// </summary>
/// <returns></returns>
public async Task<ResponseCommon<object>> GenerateStoreInfo()
@ -248,32 +248,32 @@ namespace WCS.BLL.Services.Service
//var shelfInfos = DbHelp.db.Queryable<ShelfInfo>().ToList();
//foreach (var shelfInfo in shelfInfos)
//{
var ModuleInfos = await DbHelp.db.Queryable<ModuleInfo>().ToListAsync();
ModuleInfos.ForEach(moduleInfo =>
var ModuleInfos = await DbHelp.db.Queryable<ModuleInfo>().ToListAsync();
ModuleInfos.ForEach(moduleInfo =>
{
for (int i = 1; i <= moduleInfo.LightCount; i++)
{
for (int i = 1; i <= moduleInfo.LightCount; i++)
var storeInfo = new StoreInfo()
{
var storeInfo = new StoreInfo()
{
StoreCode = moduleInfo.ModuleCode + "-" + i.ToString(),
ShelfTypeId = 1,
ModuleId = moduleInfo.Id,
ModuleCode = moduleInfo.ModuleCode,
ShelfId = moduleInfo.ShelfId,
ShelfCode = moduleInfo.ShelfCode,
BoardId = moduleInfo.BoardId,
LightNumber = i,
Priority = 1,
CurrentMatSn = string.Empty,
BigShelfCode = moduleInfo.Bigshelfcode,
R = moduleInfo.R,
C = moduleInfo.C,
Wei = i.ToString(),
GroupName = moduleInfo.GroupName,
};
DbHelp.db.Insertable(storeInfo).ExecuteCommand();
}
});
StoreCode = moduleInfo.ModuleCode + "-" + i.ToString(),
ShelfTypeId = 1,
ModuleId = moduleInfo.Id,
ModuleCode = moduleInfo.ModuleCode,
ShelfId = moduleInfo.ShelfId,
ShelfCode = moduleInfo.ShelfCode,
BoardId = moduleInfo.BoardId,
LightNumber = i,
Priority = 1,
CurrentMatSn = string.Empty,
BigShelfCode = moduleInfo.Bigshelfcode,
R = moduleInfo.R,
C = moduleInfo.C,
Wei = i.ToString(),
GroupName = moduleInfo.GroupName,
};
DbHelp.db.Insertable(storeInfo).ExecuteCommand();
}
});
//}
return new ResponseCommon<object>() { Message = "111" };
}
@ -443,6 +443,44 @@ namespace WCS.BLL.Services.Service
}
}
public async Task<ResponseCommon> calibrationSetOffset(CalibrationSetOffsetRequest request)
{
try
{
var modules = await DbHelp.db.Queryable<ModuleInfo>().Where(t => request.MouduleIds.Contains(t.Id)).ToListAsync();
var isSend = false;
foreach (var module in modules)
{
var shelf = ShelfManager.Shelves.Where(t => t.ShelfId == module.ShelfId).FirstOrDefault();
if (shelf != null && shelf is SmartShelf)
{
var smartShelf = (SmartShelf)shelf;
smartShelf.CalibrationSetOffset(module.Id, request.OffSet);
isSend = true;
}
}
if (isSend)
return new ResponseCommon()
{
Code = 200,
Message = "Success"
};
else
return new ResponseCommon()
{
Code = 201,
Message = "操作失败:未找到对应模组"
};
}
catch (Exception ex)
{
return new ResponseCommon()
{
Code = 300,
Message = "操作失败:" + ex.Message
};
}
}
#endregion
#region
@ -580,7 +618,6 @@ namespace WCS.BLL.Services.Service
}
}
#endregion
}
}

View File

@ -455,6 +455,7 @@ namespace WCS.BLL.Services.Service
.FirstAsync();
if (user == null)
{
return new ResponseCommon<UserBase>()
{
Code = 201,
@ -497,6 +498,8 @@ namespace WCS.BLL.Services.Service
//返回字串不返回密码
user.Password = "***";
request.PassWord = "***";
var response = new ResponseCommon<UserBase>()
{
Code = 200,

View File

@ -45,6 +45,7 @@ namespace WCS.BLL
/// 入库流程日志
/// </summary>
Instore,
WebSocket,
}
/// <summary>

View File

@ -66,21 +66,42 @@ namespace WCS.BLL
tcpClient = new TcpClient();
//载入配置
tcpClient.Setup(new TouchSocketConfig()
.SetRemoteIPHost(RemoteIPHost)
//.SetBindIPHost(BindIPHost)
.ConfigurePlugins(a =>
{
//配置断线重连
a.UseReconnection(-1, true, 1000);
a.Add<HeartbeatAndReceivePlugin>();
})
.ConfigureContainer(a =>
{
//添加控制台日志注入
a.AddConsoleLogger();
}));
if (string.IsNullOrEmpty(BindIPHost))
{
//载入配置
tcpClient.Setup(new TouchSocketConfig()
.SetRemoteIPHost(new IPHost(RemoteIPHost))
//.SetBindIPHost(BindIPHost)
.ConfigurePlugins(a =>
{
//配置断线重连
a.UseReconnection(-1, true, 1000);
a.Add<HeartbeatAndReceivePlugin>();
})
.ConfigureContainer(a =>
{
//添加控制台日志注入
a.AddConsoleLogger();
}));
}
else
{
//载入配置
tcpClient.Setup(new TouchSocketConfig()
.SetRemoteIPHost(new IPHost(RemoteIPHost))
.SetBindIPHost(new IPHost(BindIPHost))
.ConfigurePlugins(a =>
{
//配置断线重连
a.UseReconnection(-1, true, 1000);
a.Add<HeartbeatAndReceivePlugin>();
})
.ConfigureContainer(a =>
{
//添加控制台日志注入
a.AddConsoleLogger();
}));
}
//添加接收事件 匹配已发送的指令
tcpClient.Received += (client, e) =>
@ -96,7 +117,7 @@ namespace WCS.BLL
//灯控制统一返回的是 FF-00-00-0A-00-02-D7-B5
if (len == 8)
{
if (data[4] == 0x00 && data[0] == 0xFF && data[1] == 0x00 && (data[4] == 0x01 && data[4] == 0x02))
if (data[4] == 0x00 && data[0] == 0xFF && data[1] == 0x00 && (data[5] == 0x01 || data[5] == 0x02))
{
//查询当前板子是否有待验证的指令
var message = new MessageDto();
@ -233,8 +254,8 @@ namespace WCS.BLL
{
Logs.Write($"【发送】{BitConverter.ToString(message)}", LogsType.Instructions);
});
//发送自带8ms间隔
Thread.Sleep(8);
//发送自带15ms间隔
Thread.Sleep(15);
}
}
catch (Exception ex)

View File

@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TouchSocket" Version="2.0.3" />
<PackageReference Include="TouchSocket" Version="2.0.11" />
<PackageReference Include="TouchSocket.Http" Version="2.0.3" />
<PackageReference Include="XLParser" Version="1.7.2" />
</ItemGroup>