提交代码
This commit is contained in:
@ -5,6 +5,8 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
@ -35,6 +37,7 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
ModuleId = module.Id,
|
||||
ModuleCode = module.ModuleCode,
|
||||
BoardId = module.BoardId,
|
||||
IsEnable = module.IsEnable,
|
||||
CurrentMode = module.CurentMode
|
||||
});
|
||||
@ -71,6 +74,9 @@ namespace WCS.BLL.HardWare
|
||||
case 0x01:
|
||||
;
|
||||
break;
|
||||
case 0x03://正常入库信号
|
||||
InStoreReturnProcess(dataTemp);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
break;
|
||||
@ -91,7 +97,7 @@ namespace WCS.BLL.HardWare
|
||||
public List<SmartShelfModule> Modules { get; set; } = new List<SmartShelfModule>();
|
||||
public TCPClient TcpCleint { get; set; }
|
||||
|
||||
public IWarningLightBase WarningLight { get; set; }
|
||||
public WarningLight WarningLight { get; set; }
|
||||
public List<string> ExceptionMessages { get; set; } = new List<string>();
|
||||
|
||||
public string? InstoreIpAddress { get; set; } = string.Empty;
|
||||
@ -100,6 +106,7 @@ namespace WCS.BLL.HardWare
|
||||
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
#region 协议处理
|
||||
public void GoInInstore(string? IPAddress)
|
||||
{
|
||||
//判断当前模式是否为待机模式
|
||||
@ -139,16 +146,10 @@ namespace WCS.BLL.HardWare
|
||||
}
|
||||
//警示灯亮起
|
||||
//WarningLight.BlueLight();
|
||||
//绑定当前入库PDA的IP
|
||||
//绑定当前进入入库PDA/WCS前端的IP
|
||||
InstoreIpAddress = IPAddress;
|
||||
//返回成功
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public void GoInInstoreReturn()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void GoOutInstore()
|
||||
@ -181,7 +182,6 @@ namespace WCS.BLL.HardWare
|
||||
this.CurentMode = Mode.盘点模式;
|
||||
}
|
||||
|
||||
|
||||
public void GoOutOutstore()
|
||||
{
|
||||
this.CurentMode = Mode.待机模式;
|
||||
@ -206,5 +206,140 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void ShelfCheck()
|
||||
{
|
||||
foreach (var module in Modules.Where(t => t.IsEnable).ToList())
|
||||
{
|
||||
module.ShelfCheck(TcpCleint);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 协议返回处理
|
||||
public void InStoreReturnProcess(byte[] data)
|
||||
{
|
||||
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();
|
||||
if (storeInfo == null)
|
||||
{
|
||||
//TO DO 报错
|
||||
return;
|
||||
}
|
||||
var module = this.Modules.Where(t => t.BoardId == boardId)
|
||||
.FirstOrDefault();
|
||||
if (module == null)
|
||||
{
|
||||
//TO DO 报错
|
||||
return;
|
||||
}
|
||||
#region 判断是否扫码获取物料信息
|
||||
//物料未扫码
|
||||
if (this.InStoreData == null)
|
||||
{
|
||||
//重复给了多次信号
|
||||
if (!string.IsNullOrEmpty(storeInfo.CurrentMatSn))
|
||||
{
|
||||
module.ComfirmInstore(TcpCleint);
|
||||
//TO DO Logs.Write($"[{guid}]CAN给了多次正常入库信号,防止硬件异常,返回了确认入库");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
module.ComfirmErrInstore(TcpCleint);
|
||||
//WaringLight(shelfStatus.ClientIp, shelfStatus.LightId);
|
||||
//TO DO Logs.Write($"[{guid}]当前物料信息不存在,请取出后重新扫码进行入库!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//该位置已放置物料
|
||||
else if (!string.IsNullOrEmpty(storeInfo.CurrentMatSn))
|
||||
{
|
||||
//ComfirmErrInstoreByIp(shelfStatus.ClientIp, boardId);
|
||||
//WaringLight(shelfStatus.ClientIp, shelfStatus.LightId);
|
||||
//Logs.Write($"[{guid}]该位置已放置物料!");
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 已扫码且库位未被占用 保存数据
|
||||
{
|
||||
try
|
||||
{
|
||||
DbHelp.db.BeginTran();
|
||||
//库存明细表
|
||||
var inventoryDetail = new InventoryDetail
|
||||
{
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
StoreId = storeInfo.Id,
|
||||
|
||||
MatSN = this.InStoreData.materialBar,
|
||||
MatCode = this.InStoreData.materialCode,
|
||||
MatName = this.InStoreData.materialName,
|
||||
MatSpec = this.InStoreData.materialSpec,
|
||||
MatBatch = this.InStoreData.batchNo,
|
||||
MatQty = (int)this.InStoreData.materialQty,
|
||||
MatCustomer = this.InStoreData.customer,
|
||||
MatSupplier = this.InStoreData.supplier,
|
||||
|
||||
InstoreTime = DateTime.Now,
|
||||
InstoreUser = ""
|
||||
};
|
||||
|
||||
//出入库记录表
|
||||
var inOutRecord = new InOutRecord()
|
||||
{
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreInfo = storeInfo,
|
||||
|
||||
MatSN = this.InStoreData.materialBar,
|
||||
MatCode = this.InStoreData.materialCode,
|
||||
MatName = this.InStoreData.materialName,
|
||||
MatSpec = this.InStoreData.materialSpec,
|
||||
MatBatch = this.InStoreData.batchNo,
|
||||
MatQty = (int)this.InStoreData.materialQty,
|
||||
MatCustomer = this.InStoreData.customer,
|
||||
MatSupplier = this.InStoreData.supplier,
|
||||
|
||||
OperateUser = this.InStoreData.InstoreUser,
|
||||
Direction = DirectionEnum.入库,
|
||||
};
|
||||
|
||||
//库位表
|
||||
storeInfo.CurrentMatSn = this.InStoreData.materialBar;
|
||||
|
||||
//保存and更新数据
|
||||
DbHelp.db.Insertable(inventoryDetail).ExecuteCommand();
|
||||
DbHelp.db.Insertable(inOutRecord).ExecuteCommand();
|
||||
DbHelp.db.Updateable(storeInfo).ExecuteCommand();
|
||||
DbHelp.db.CommitTran();
|
||||
|
||||
//清空扫码信息
|
||||
this.InStoreData = null;
|
||||
|
||||
//实际入库位置亮灯1S,报警灯同时进行亮绿灯并鸣叫一次提示。
|
||||
Thread.Sleep(20);
|
||||
Task.Run(() =>
|
||||
{
|
||||
//确认入库(硬件入库位置亮灯1秒)
|
||||
//ComfirmInstoreByIp(client.IP, boardId);
|
||||
//报警灯亮绿灯 鸣叫一次提示
|
||||
//SuccessLightBlueEnd(shelfStatus.ClientIp, shelfStatus.LightId);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
Logs.Write($"入库保存数据异常,异常信息为{ex.Message}");
|
||||
//报警灯报警
|
||||
//WaringLight(shelfStatus.ClientIp, shelfStatus.LightId);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user