提交代码
This commit is contained in:
16
WCS.BLL/Config/JsConfig.cs
Normal file
16
WCS.BLL/Config/JsConfig.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// json配置文件
|
||||
/// </summary>
|
||||
public class JsConfig
|
||||
{
|
||||
public List<string> ModuleCodePatterns { get; set; }
|
||||
}
|
||||
}
|
@ -11,17 +11,15 @@ namespace WCS.BLL.Config
|
||||
/// <summary>
|
||||
/// 本地文件
|
||||
/// </summary>
|
||||
public class LocalFile
|
||||
public static class LocalFile
|
||||
{
|
||||
|
||||
public static readonly string AppDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
/// <summary>
|
||||
/// 程序运行名称(BaseUi.exe)
|
||||
/// </summary>
|
||||
public static readonly string AppName = AppDomain.CurrentDomain.FriendlyName;
|
||||
/// <summary>
|
||||
/// 程序运行目录
|
||||
/// </summary>
|
||||
public static readonly string AppDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
/// <summary>
|
||||
/// 数据目录
|
||||
/// </summary>
|
||||
public static readonly string DataDir = Path.Combine(AppDir, "data");
|
||||
@ -30,76 +28,72 @@ namespace WCS.BLL.Config
|
||||
/// </summary>
|
||||
public static readonly string LogDir = Path.Combine(AppDir, "logs");
|
||||
/// <summary>
|
||||
/// 运行主程序
|
||||
/// </summary>
|
||||
public static readonly string AppPath = Path.Combine(AppDir, AppDomain.CurrentDomain.FriendlyName);
|
||||
/// <summary>
|
||||
/// 配置文件路径
|
||||
/// </summary>
|
||||
public static readonly string ConfigPath = Path.Combine(DataDir, "jsconfig.json");
|
||||
/// <summary>
|
||||
/// 货架模组编码正则表达式
|
||||
/// </summary>
|
||||
public static readonly string ModuleCodePattern = "^[ABCD][0-9]{1,2}-R[0-9]{1,2}C[0-9]{1,2}$";
|
||||
public static readonly string DefaultModuleCodePattern = "^[ABCD][0-9]{1,2}-R[0-9]{1,2}C[0-9]{1,2}$";
|
||||
|
||||
static object lockConfig = new object();
|
||||
|
||||
//static JsConfig config;
|
||||
///// <summary>
|
||||
///// 配置信息
|
||||
///// </summary>
|
||||
//public static JsConfig Config
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (config != null)
|
||||
// return config;
|
||||
// else
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (File.Exists(ConfigPath))
|
||||
// lock (lockConfig)
|
||||
// config = JsonConvert.DeserializeObject<JsConfig>(File.ReadAllText(ConfigPath, Encoding.UTF8));
|
||||
// else
|
||||
// config = null;
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// config = null;
|
||||
// }
|
||||
// }
|
||||
// return config ?? new JsConfig();
|
||||
// }
|
||||
//}
|
||||
static JsConfig config;
|
||||
/// <summary>
|
||||
/// 配置信息
|
||||
/// </summary>
|
||||
public static JsConfig Config
|
||||
{
|
||||
get
|
||||
{
|
||||
if (config != null)
|
||||
return config;
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(ConfigPath))
|
||||
lock (lockConfig)
|
||||
config = JsonConvert.DeserializeObject<JsConfig>(File.ReadAllText(ConfigPath, Encoding.UTF8));
|
||||
else
|
||||
config = null;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
config = null;
|
||||
}
|
||||
}
|
||||
return config ?? new JsConfig();
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 刷新配置信息。将本地的配置信息重新加载到内存中
|
||||
///// </summary>
|
||||
//public static void UpdateConfig()
|
||||
//{
|
||||
// if (File.Exists(ConfigPath))
|
||||
// lock (lockConfig)
|
||||
// config = JsonConvert.DeserializeObject<JsConfig>(File.ReadAllText(ConfigPath, Encoding.UTF8));
|
||||
// else
|
||||
// config = null;
|
||||
//}
|
||||
/// <summary>
|
||||
/// 刷新配置信息。将本地的配置信息重新加载到内存中
|
||||
/// </summary>
|
||||
public static void UpdateConfig()
|
||||
{
|
||||
if (File.Exists(ConfigPath))
|
||||
lock (lockConfig)
|
||||
config = JsonConvert.DeserializeObject<JsConfig>(File.ReadAllText(ConfigPath, Encoding.UTF8));
|
||||
else
|
||||
config = null;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 保存配置信息。将内存中的配置信息保存到本地
|
||||
///// </summary>
|
||||
//public static void SaveConfig()
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// lock (lockConfig)
|
||||
// File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(Config, Formatting.Indented), Encoding.UTF8);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// UpdateConfig();
|
||||
// throw ex;
|
||||
// }
|
||||
//}
|
||||
/// <summary>
|
||||
/// 保存配置信息。将内存中的配置信息保存到本地
|
||||
/// </summary>
|
||||
public static void SaveConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (lockConfig)
|
||||
File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(Config, Formatting.Indented), Encoding.UTF8);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UpdateConfig();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,8 @@ namespace WCS.BLL.HardWare
|
||||
/// 过程中异常 入库过程中异常/出库过程中异常
|
||||
/// </summary>
|
||||
public List<ProcessingExceptionType> ProcessingExceptions { get; set; } = new List<ProcessingExceptionType>();
|
||||
public string? InstoreIpAddress { get; set; } = string.Empty;
|
||||
public string? CurrentCom { get; set; } = string.Empty;
|
||||
//TODO 退出入库清除
|
||||
|
||||
public MatInfoResponse InStoreData { get; set; }
|
||||
|
||||
@ -137,7 +138,7 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
if (this.CurentMode == Mode.入库模式)
|
||||
{
|
||||
InstoreIpAddress = IPAddress;
|
||||
CurrentCom = IPAddress;
|
||||
return;
|
||||
}
|
||||
//判断当前模式是否为待机模式
|
||||
@ -181,7 +182,6 @@ namespace WCS.BLL.HardWare
|
||||
if (deficientTime > 0)
|
||||
Thread.Sleep(deficientTime);
|
||||
//出现异常的未进入入库模式,有红灯进行指引
|
||||
this.CurentMode = Mode.待机模式;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ namespace WCS.BLL.HardWare
|
||||
|
||||
if (notInstoreList.Count > 0)
|
||||
{
|
||||
CurentMode = Mode.待机模式;
|
||||
|
||||
foreach (var item in notInstoreList)
|
||||
{
|
||||
ExceptionMessages.Add($"模组{item.ModuleCode}未进入入库模式!");
|
||||
@ -205,7 +205,7 @@ namespace WCS.BLL.HardWare
|
||||
//警示灯亮起
|
||||
WarningLight.BlueLight(TcpCleint);
|
||||
//绑定当前进入入库PDA/WCS前端的IP
|
||||
InstoreIpAddress = IPAddress;
|
||||
CurrentCom = IPAddress;
|
||||
//返回成功
|
||||
return;
|
||||
}
|
||||
@ -356,7 +356,7 @@ namespace WCS.BLL.HardWare
|
||||
#region 协议返回处理
|
||||
public void ProtocolProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
Logs.Write("协议处理中的数据" + BitConverter.ToString(data) + $"板子id{boardId}");
|
||||
Logs.Write("协议处理4");
|
||||
//协议处理 判断功能位
|
||||
switch (data[TcpCleint.PreFixLength + 2])
|
||||
{
|
||||
@ -381,13 +381,18 @@ namespace WCS.BLL.HardWare
|
||||
case 0x07://正常出库返回信号
|
||||
OutstoreReturnProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x08://出库模式中异常信号
|
||||
OutstoreExceptionReturnProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
case 0x13://复位的返回信号
|
||||
ResetReturnProcess(data, boardId, lightNumber);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
break;
|
||||
|
||||
}
|
||||
Logs.Write("协议处理5");
|
||||
}
|
||||
/// <summary>
|
||||
/// 进入入库模式返回信号处理
|
||||
@ -510,7 +515,7 @@ namespace WCS.BLL.HardWare
|
||||
//库位未配置、返回数据异常
|
||||
else
|
||||
{
|
||||
//Logs.Write($"[进入入库模式异常]板Id{boardIds},库位号{index + 1}找不到对应库位!");
|
||||
Logs.Write($"[进入入库模式异常]板Id{boardId},库位号{index + 1}找不到对应库位!");
|
||||
}
|
||||
}
|
||||
else if (dataTemp[2 * index] == '0')
|
||||
@ -556,22 +561,26 @@ namespace WCS.BLL.HardWare
|
||||
/// <param name="data"></param>
|
||||
public void InStoreReturnProcess(byte[] data)
|
||||
{
|
||||
Logs.Write("协议处理5.1");
|
||||
var boardId = (data[TcpCleint.PreFixLength + 0] << 8) + data[TcpCleint.PreFixLength + 1];
|
||||
var number = Convert.ToInt32(data[TcpCleint.PreFixLength + 3]);
|
||||
var storeInfo = DbHelp.db.Queryable<StoreInfo>().Where(t => t.BoardId == boardId
|
||||
&& t.LightNumber == number).First();
|
||||
Logs.Write("协议处理5.2");
|
||||
if (storeInfo == null)
|
||||
{
|
||||
//TO DO 报错
|
||||
//TODO 报错
|
||||
return;
|
||||
}
|
||||
Logs.Write("协议处理5.3");
|
||||
var module = this.Modules.Where(t => t.BoardId == boardId)
|
||||
.FirstOrDefault();
|
||||
if (module == null)
|
||||
{
|
||||
//TO DO 报错
|
||||
//TODO 报错
|
||||
return;
|
||||
}
|
||||
Logs.Write("协议处理5.4");
|
||||
#region 判断是否扫码获取物料信息
|
||||
//物料未扫码
|
||||
if (this.InStoreData == null)
|
||||
@ -580,18 +589,17 @@ namespace WCS.BLL.HardWare
|
||||
if (!string.IsNullOrEmpty(storeInfo.CurrentMatSn))
|
||||
{
|
||||
module.ComfirmInstore(TcpCleint);
|
||||
//TO DO Logs.Write($"[{guid}]CAN给了多次正常入库信号,防止硬件异常,返回了确认入库");
|
||||
Logs.Write($"CAN给了多次正常入库信号,防止硬件异常,返回了确认入库");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logs.Write("协议处理5.5");
|
||||
var exceptionMessage = storeInfo.StoreCode + "入库过程中存在物料未扫描上架!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
|
||||
Logs.Write("协议处理5.4");
|
||||
module.ComfirmErrInstore(TcpCleint);
|
||||
WarningLight.WaringLightBlueEnd(TcpCleint);
|
||||
//WaringLightBlueEnd(shelfStatus.ClientIp, shelfStatus.LightId);
|
||||
//TO DO Logs.Write($"[{guid}]当前物料信息不存在,请取出后重新扫码进行入库!");
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -664,7 +672,6 @@ namespace WCS.BLL.HardWare
|
||||
this.InStoreData = null;
|
||||
|
||||
//实际入库位置亮灯1S,报警灯同时进行亮绿灯并鸣叫一次提示。
|
||||
Thread.Sleep(20);
|
||||
Task.Run(() =>
|
||||
{
|
||||
//确认入库(硬件入库位置亮灯1秒)
|
||||
@ -694,50 +701,56 @@ namespace WCS.BLL.HardWare
|
||||
/// <param name="lightNumber"></param>
|
||||
public void InStoreExceptionReturnProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
Logs.Write("协议处理5.1");
|
||||
lightNumber = (int)data[TcpCleint.PreFixLength + 4];
|
||||
var store = DbHelp.db.Queryable<StoreInfo>()
|
||||
.Where(t => t.BoardId == boardId && t.LightNumber == lightNumber)
|
||||
.First();
|
||||
Logs.Write("协议处理5.2");
|
||||
if (store == null)
|
||||
{
|
||||
//TO DO 库位未找到
|
||||
return;
|
||||
}
|
||||
Logs.Write("协议处理5.3");
|
||||
//已放物料丢失了 物料多放了 储位恢复正常
|
||||
switch (data[TcpCleint.PreFixLength + 3])
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
Logs.Write("协议处理5.4");
|
||||
var exceptionMessage = store.StoreCode + "恢复正常!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
|
||||
ProcessingExceptions.RemoveAll(t => t.BoardId == boardId);
|
||||
Logs.Write("协议处理5.5");
|
||||
}
|
||||
break;
|
||||
case 0x01:
|
||||
{
|
||||
Logs.Write("协议处理5.4");
|
||||
var exceptionMessage = store.StoreCode + "入库过程中存在物料未扫描上架!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
BoardId = boardId,
|
||||
LightNumber = lightNumber,
|
||||
ExceptionMessage = store.StoreCode + "入库过程中存在物料未扫描上架!"
|
||||
});
|
||||
Logs.Write("协议处理5.5");
|
||||
}
|
||||
break;
|
||||
case 0x02:
|
||||
{
|
||||
Logs.Write("协议处理5.4");
|
||||
var exceptionMessage = store.StoreCode + "物料被取出!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
BoardId = boardId,
|
||||
LightNumber = lightNumber,
|
||||
ExceptionMessage = store.StoreCode + "入库过程中物料丢失!"
|
||||
});
|
||||
Logs.Write("协议处理5.5");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -896,7 +909,7 @@ namespace WCS.BLL.HardWare
|
||||
if (CurentMode != Mode.出库模式)
|
||||
{
|
||||
//TO DO 未在出库模式 要报错
|
||||
//Logs.Write($"[{guid}]出库错误:该货架模式不是出库模式或盘点模式{storeInfo.ShelfCode}!");
|
||||
Logs.Write($"出库错误:{ShelfCode}该货架模式不是出库模式或盘点模式!");
|
||||
return;
|
||||
}
|
||||
lightNumber = Convert.ToInt32(data[TcpCleint.PreFixLength + 3]);
|
||||
@ -927,7 +940,7 @@ namespace WCS.BLL.HardWare
|
||||
//不是本次出库需要出的物料
|
||||
if (!CurrentOutStoreMatSNs.Contains(storeInfo.CurrentMatSn))
|
||||
{
|
||||
//Logs.Write($"{storeInfo.CurrentMatSN}不是本次需要出库的物料");
|
||||
Logs.Write($"{storeInfo.CurrentMatSn}不是本次需要出库的物料");
|
||||
//报警灯报警
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
return;
|
||||
@ -937,7 +950,7 @@ namespace WCS.BLL.HardWare
|
||||
var inventoryDetail = DbHelp.db.Queryable<InventoryDetail>().Where(t => t.MatSN == storeInfo.CurrentMatSn).First();
|
||||
if (inventoryDetail == null)
|
||||
{
|
||||
//Logs.Write($"{storeInfo.CurrentMatSN}库存信息不存在");
|
||||
Logs.Write($"{storeInfo.CurrentMatSn}库存信息不存在");
|
||||
//报警灯报警
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
return;
|
||||
@ -949,7 +962,7 @@ namespace WCS.BLL.HardWare
|
||||
.ToList();
|
||||
if (orderOrderDetails == null || orderOrderDetails.Count == 0)
|
||||
{
|
||||
//Logs.Write($"{storeInfo.CurrentMatSN},OrderDetail出库明细信息不存在");
|
||||
Logs.Write($"{storeInfo.CurrentMatSn},OrderDetail出库明细信息不存在");
|
||||
//报警灯报警
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
return;
|
||||
@ -1003,27 +1016,24 @@ namespace WCS.BLL.HardWare
|
||||
|
||||
//确认本次出库
|
||||
module.ComfirmOutstore(TcpCleint, data[TcpCleint.PreFixLength + 3]);
|
||||
//shelfStatus.SetCurrentModeTime = DateTime.Now;
|
||||
//LocalStatic.IsRefreshOrderDetail = true;
|
||||
Task.Run(() =>
|
||||
{
|
||||
//给信号通知出库页面更新页面的状态
|
||||
});
|
||||
|
||||
//当前柜子是否还存在未出库的
|
||||
CurrentOutStoreMatSNs.RemoveAll(t => t == matSN);//删除本次已出的物料SN
|
||||
|
||||
|
||||
var isExsistOut = CurrentOutStoreMatSNs.Any();
|
||||
//本批次出库已完成
|
||||
if (!isExsistOut)
|
||||
{
|
||||
//Logs.Write($"货架[{shelfStatus.ShelfCode}]:不存在待出物料,退出出库模式");
|
||||
//退出出库模式
|
||||
GoOutOutstore();
|
||||
WarningLight.CloseLight(TcpCleint);
|
||||
|
||||
var currentPickBillNumber = CurrentOutOrder.OrderNumber;
|
||||
CurrentOutOrder = null;
|
||||
Task.Run(() =>
|
||||
{
|
||||
//LocalStatic.UpdatOutOrderStatus(currentPickBillNumber);
|
||||
//给信号通知出库页面更新页面的状态
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -1052,6 +1062,63 @@ namespace WCS.BLL.HardWare
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 出库模式中异常处理
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="boardId"></param>
|
||||
/// <param name="lightNumber"></param>
|
||||
public void OutstoreExceptionReturnProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
lightNumber = (int)data[TcpCleint.PreFixLength + 4];
|
||||
var store = DbHelp.db.Queryable<StoreInfo>()
|
||||
.Where(t => t.BoardId == boardId && t.LightNumber == lightNumber)
|
||||
.First();
|
||||
if (store == null)
|
||||
{
|
||||
//TO DO 库位未找到
|
||||
return;
|
||||
}
|
||||
//已放物料丢失了 物料多放了 储位恢复正常
|
||||
switch (data[TcpCleint.PreFixLength + 3])
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
var exceptionMessage = store.StoreCode + "恢复正常!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
ProcessingExceptions.RemoveAll(t => t.BoardId == boardId);
|
||||
}
|
||||
break;
|
||||
case 0x01:
|
||||
{
|
||||
var exceptionMessage = store.StoreCode + "出库过程中存在物料上架!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
BoardId = boardId,
|
||||
LightNumber = lightNumber,
|
||||
ExceptionMessage = store.StoreCode + "出库过程中存在物料上架!"
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 0x02:
|
||||
{
|
||||
var exceptionMessage = store.StoreCode + "物料被取出!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
BoardId = boardId,
|
||||
LightNumber = lightNumber,
|
||||
ExceptionMessage = store.StoreCode + "出库过程中物料被异常取出!"
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ResetReturnProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
var module = this.Modules.Where(t => t.BoardId == boardId && t.CurrentMode == Mode.入库模式).FirstOrDefault();
|
||||
@ -1065,7 +1132,6 @@ namespace WCS.BLL.HardWare
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
@ -20,10 +20,10 @@ namespace WCS.BLL.Manager
|
||||
public static List<TCPClient> TCPClients = new List<TCPClient>();
|
||||
public static void InitTcpClient()
|
||||
{
|
||||
var ips = DbHelp.db.Queryable<ShelfInfo>().Where(t => t.ShelfCode.Contains("A")).Select(t => t.ClientIp).ToList();
|
||||
var ips = DbHelp.db.Queryable<ShelfInfo>().Where(t => t.ShelfCode.Contains("C")).Select(t => t.ClientIp).ToList();
|
||||
foreach (var ip in ips)
|
||||
{
|
||||
var tcpCleint = new TCPClient(ip, "192.168.0.183:20003");
|
||||
var tcpCleint = new TCPClient(ip, "192.168.9.183:20003");
|
||||
|
||||
|
||||
//var tcpCleint = new TCPClient("192.168.0.183:20002", "192.168.0.183:20003");
|
||||
@ -31,6 +31,7 @@ namespace WCS.BLL.Manager
|
||||
|
||||
tcpCleint.tcpClient.Received += (client, e) =>
|
||||
{
|
||||
|
||||
var clientIpHost = client.IP + ":" + client.Port;
|
||||
var TcpCleint = TCPClientManager.GetTCPClientByIPHost(clientIpHost);
|
||||
if (TcpCleint == null)
|
||||
@ -49,8 +50,8 @@ namespace WCS.BLL.Manager
|
||||
var isEqual = prefixInData.SequenceEqual(TcpCleint.Prefix);
|
||||
if (isEqual)
|
||||
{
|
||||
Logs.Write("协议处理1!");
|
||||
var dataTemp = data.Skip(index).Take(TcpCleint.PreFixLength + TcpCleint.DataLength).ToArray();
|
||||
Logs.Write($"接受到数据:{BitConverter.ToString(dataTemp)}");
|
||||
if (dataTemp.Length < TcpCleint.PreFixLength + TcpCleint.DataLength)//拆包后不满足一条指令的长度
|
||||
{
|
||||
continue;
|
||||
@ -60,6 +61,7 @@ namespace WCS.BLL.Manager
|
||||
var boardId = (dataTemp[TcpCleint.PreFixLength + 0] << 8) + dataTemp[TcpCleint.PreFixLength + 1];
|
||||
var lightNumber = Convert.ToInt32(dataTemp[TcpCleint.PreFixLength + 3]);
|
||||
|
||||
Logs.Write("协议处理2!");
|
||||
//报警灯
|
||||
if (dataTemp[TcpCleint.PreFixLength + 2] == 0x20)
|
||||
{
|
||||
@ -69,9 +71,10 @@ namespace WCS.BLL.Manager
|
||||
var smartShelf = shelf as SmartShelf;
|
||||
smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber);
|
||||
}
|
||||
//货架类型协议返回
|
||||
//!= 0x20 货架类型协议返回
|
||||
else
|
||||
{
|
||||
Logs.Write("协议处理3!");
|
||||
var shelf = ShelfManager.Shelves
|
||||
.Where(t => t.ClientIp == clientIpHost)
|
||||
.Where(t => t.ModuleIds.Contains(boardId))
|
||||
@ -96,6 +99,7 @@ namespace WCS.BLL.Manager
|
||||
//}
|
||||
}
|
||||
}
|
||||
Logs.Write("协议处理完毕!");
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
|
@ -15,6 +15,8 @@ namespace WCS.BLL.Services.IService
|
||||
|
||||
public Task<ResponseBase> GetOutOrderList(GetOutOrderListRequest request);
|
||||
|
||||
public Task<ResponseBase> GetOutOrderListByStatus(GetOutOrderListByStatusRequest request);
|
||||
|
||||
public Task<ResponseBase> GetOutOrderDetail(GetOutOrderDetailRequest request);
|
||||
|
||||
public Task<ResponseBase> GetOutOrderMatDetail(GetOutOrderDetailRequest request);
|
||||
|
@ -27,7 +27,7 @@ namespace WCS.BLL.Services.IService
|
||||
public Task<ResponseBase> queryMatInfoInStocktakingOrder(QueryMatInfoInStocktakingOrderRequest request);
|
||||
|
||||
|
||||
public Task<ResponseBase> comfirmStocktakingOrder(ComfirmStocktakingOrderRequest request);
|
||||
public Task<ResponseBase> confirmStocktakingOrder(ConfirmStocktakingOrderRequest request);
|
||||
|
||||
public Task<ResponseBase> commitStockTakingOrder(GetStockTakingOrderMatDetailRequest request);
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
using WCS.Model;
|
||||
using WCS.DAL.DbModels;
|
||||
|
@ -1,5 +1,4 @@
|
||||
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db.AuthDb;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
@ -11,7 +11,6 @@ using TouchSocket.Core;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
|
@ -23,7 +23,25 @@ namespace WCS.BLL.Services.Service
|
||||
public ResponseBase shelfGoInInStore(ShelfGoInInstoreRequest request)
|
||||
{
|
||||
//校验货架编码规则
|
||||
bool isValid = Regex.IsMatch(request.ModuleCode, LocalFile.ModuleCodePattern);
|
||||
//取配置文件中得货架编码规则
|
||||
bool isValid = false;
|
||||
var patterns = LocalFile.Config.ModuleCodePatterns;
|
||||
if (patterns != null && patterns.Count > 0)
|
||||
{
|
||||
foreach (var pattern in patterns)
|
||||
{
|
||||
isValid = Regex.IsMatch(request.ModuleCode, pattern);
|
||||
//匹配到第一个符合条件的货架码 就直接退出循环 认为匹配成功
|
||||
if (isValid)
|
||||
break;
|
||||
}
|
||||
}
|
||||
//如果配置文件缺失 使用默认正则进行匹配
|
||||
else
|
||||
{
|
||||
isValid = Regex.IsMatch(request.ModuleCode, LocalFile.DefaultModuleCodePattern);
|
||||
}
|
||||
|
||||
if (!isValid)
|
||||
{
|
||||
return new ResponseBase()
|
||||
@ -50,7 +68,7 @@ namespace WCS.BLL.Services.Service
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "货架进入入库模式成功!",
|
||||
Message = $"货架进入入库模式成功!{string.Join(",", shelf.ExceptionMessages)}",
|
||||
Data = new ShelfGoInInstoreDto()
|
||||
{
|
||||
ShelfCode = shelf.ShelfCode,
|
||||
@ -130,7 +148,7 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
#region 获取物料数据 //调用接口或者直接查询数据库
|
||||
//调用接口
|
||||
//TODO做成配置 调用接口
|
||||
if (1 != 1)
|
||||
{
|
||||
|
||||
@ -141,7 +159,7 @@ namespace WCS.BLL.Services.Service
|
||||
var matInfo = await DbHelp.db.Queryable<MatInfo>().Where(t => t.MatSn == request.MatSn).FirstAsync();
|
||||
if (matInfo != null)
|
||||
{
|
||||
|
||||
//TODO 改成wcs的实体
|
||||
shelf.InStoreData = new MatInfoResponse()
|
||||
{
|
||||
materialBar = matInfo.MatSn,
|
||||
@ -198,7 +216,7 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
|
||||
//这个时间相当于需要入库扫码后需要等待的时间
|
||||
//TODO 配置这个时间相当于需要入库扫码后需要等待的时间
|
||||
var timeOut = 5000;
|
||||
var timeSpan = TimeSpan.FromMilliseconds(0);
|
||||
var beginTime = DateTime.Now;
|
||||
|
@ -9,7 +9,6 @@ using TouchSocket.Core;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
|
@ -10,7 +10,6 @@ using TouchSocket.Core;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
|
@ -8,8 +8,6 @@ using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
|
@ -204,6 +204,7 @@ namespace WCS.BLL.Services.Service
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async Task<ResponseBase> GetOutOrderList(GetOutOrderListRequest request)
|
||||
{
|
||||
//直接查询
|
||||
@ -236,6 +237,43 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> GetOutOrderListByStatus(GetOutOrderListByStatusRequest request)
|
||||
{
|
||||
if (request.OrderExeStatus == null || request.OrderExeStatus.Count == 0)
|
||||
{
|
||||
//不传入状态不显示
|
||||
return new PageQueryResponse<OutOrder>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<OutOrder>()
|
||||
{
|
||||
Lists = new List<OutOrder>()
|
||||
}
|
||||
};
|
||||
}
|
||||
//直接查询
|
||||
var recordsQueryable = DbHelp.db.Queryable<OutOrder>();
|
||||
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable
|
||||
.OrderByDescending(t => t.CreateTime)
|
||||
//.Take(request.PageSize)
|
||||
.ToListAsync();
|
||||
|
||||
return new PageQueryResponse<OutOrder>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<OutOrder>()
|
||||
{
|
||||
//TotalCount = totalCount,
|
||||
//MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize),
|
||||
//Count = records.Count,
|
||||
Lists = records.ToList()
|
||||
}
|
||||
};
|
||||
}
|
||||
public async Task<ResponseBase> GetOutOrderDetail(GetOutOrderDetailRequest request)
|
||||
{
|
||||
OutOrder outOrder = null;
|
||||
@ -288,7 +326,6 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
return new ResponseCommon<List<OutOrderDetail>>()
|
||||
{
|
||||
Code = 200,
|
||||
@ -428,7 +465,7 @@ namespace WCS.BLL.Services.Service
|
||||
var matDetails = outOrderMatDetails.Where(t => t.StoreInfo.ShelfCode == shelf.ShelfCode)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
shelf.GoInOutstore(matDetails,order);
|
||||
shelf.GoInOutstore(matDetails, order);
|
||||
});
|
||||
|
||||
//返回
|
||||
|
@ -606,7 +606,7 @@ namespace WCS.BLL.Services.Service
|
||||
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> comfirmStocktakingOrder(ComfirmStocktakingOrderRequest request)
|
||||
public async Task<ResponseBase> confirmStocktakingOrder(ConfirmStocktakingOrderRequest request)
|
||||
{
|
||||
//获取盘点物料明细
|
||||
var stockTakingMatDetail =await DbHelp.db.Queryable<StockTakingOrderMatDetail>()
|
||||
|
@ -8,7 +8,6 @@ using TouchSocket.Core;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db.AuthDb;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
@ -77,6 +77,7 @@ namespace WCS.BLL
|
||||
{
|
||||
var data = e.ByteBlock.Buffer.Take((int)e.ByteBlock.Length).ToArray();
|
||||
//e.ByteBlock.Clear();
|
||||
Logs.Write($"校验发送接收,收到数据" + BitConverter.ToString(data));
|
||||
var len = data.Length;
|
||||
for (int index = 0; index < data.Length - PreFixLength; index++)
|
||||
{
|
||||
@ -103,7 +104,9 @@ namespace WCS.BLL
|
||||
index += (PreFixLength + DataLength - 1);//每次循环index会+1 所以这里-1
|
||||
}
|
||||
}
|
||||
Logs.Write($"校验发送接收处理完毕" + BitConverter.ToString(data));
|
||||
return null;
|
||||
|
||||
};
|
||||
|
||||
tcpClient.Connected += (client, e) =>
|
||||
@ -125,15 +128,23 @@ namespace WCS.BLL
|
||||
{
|
||||
try
|
||||
{
|
||||
//TO DO如果指令未回应n次 则取消重发
|
||||
//TODO如果指令未回应n次 则取消重发
|
||||
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
|
||||
await Task.Delay(3000);
|
||||
await Task.Delay(100);
|
||||
if (MessageList.Count > 0)
|
||||
{
|
||||
var failedMessage = MessageList.Where(t => t.Value.SendTimes >= 3).ToList();
|
||||
foreach (var message in failedMessage)
|
||||
{
|
||||
Logs.Write(BitConverter.ToString(message.Value.Message) +
|
||||
"指令未响应");
|
||||
}
|
||||
MessageList.RemoveWhen(t => t.Value.SendTimes >= 3);
|
||||
|
||||
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
|
||||
foreach (var item in MessageList)
|
||||
{
|
||||
if (item.Value.LastSendTime < DateTime.Now.AddSeconds(3))
|
||||
if (item.Value.LastSendTime < DateTime.Now.AddSeconds(-1))
|
||||
{
|
||||
tcpClient.Send(item.Value.Message);
|
||||
item.Value.SendTimes++;
|
||||
@ -141,6 +152,7 @@ namespace WCS.BLL
|
||||
await Task.Delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch
|
||||
@ -170,6 +182,7 @@ namespace WCS.BLL
|
||||
lock (sendLockObject)
|
||||
{
|
||||
tcpClient.Send(message);
|
||||
//TODO MessageList.AddOrUpdate(new Mes)
|
||||
//发送自带10ms间隔
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
@ -225,6 +238,7 @@ namespace WCS.BLL
|
||||
/// </summary>
|
||||
public byte[] Message { get; set; }
|
||||
|
||||
public bool IsWating { get; set; }
|
||||
/// <summary>
|
||||
/// 发送次数
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user