|
|
|
|
@ -21,21 +21,20 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
{
|
|
|
|
|
private readonly IHost _host;
|
|
|
|
|
private readonly LoggerUtils _logger = new LoggerUtils();
|
|
|
|
|
int FloorNo { get; set; }
|
|
|
|
|
int EquipID = 8; //2楼AGV
|
|
|
|
|
private int FloorNo { get; set; }
|
|
|
|
|
private int EquipID = 8; //2楼AGV
|
|
|
|
|
|
|
|
|
|
public SecondFloorAGV(IHost host, int floor)
|
|
|
|
|
{
|
|
|
|
|
this._host = host;
|
|
|
|
|
FloorNo = floor;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 启动上件扫描监听
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void StartPoint()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
|
|
|
|
|
FlowPointThread.IsBackground = true;
|
|
|
|
|
FlowPointThread.Name = "SecondFloorAGV";
|
|
|
|
|
@ -44,7 +43,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
_logger.Info("二楼AGV上件扫描监听启动成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 开启线程监听2分钟小包出口光电信号,如果小包出口到位信号消失,即取托盘完成,发送信号通知线体
|
|
|
|
|
/// </summary>
|
|
|
|
|
@ -92,8 +90,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
}).Wait();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void MonitorInLocatorPoint()
|
|
|
|
|
{
|
|
|
|
|
using var scope = _host.Services.CreateScope();
|
|
|
|
|
@ -357,7 +353,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
positionCode = item.endPointNo,
|
|
|
|
|
type = "00"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
taskTyp = baseDictionary.dicValue,
|
|
|
|
|
ctnrTyp = "2",
|
|
|
|
|
@ -622,7 +617,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
var ConnectStatus2F = StaticData.PlcDic[2].Read(ConnectStatus2FPoint.plcpointAddress);//2F托盘库产线数据通讯情况
|
|
|
|
|
var PalletInIsHas2F = StaticData.PlcDic[2].Read(PalletInIsHas2FPoint.plcpointAddress);//2F托盘库入口上料光电
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (agvPutValue != null && ConnectStatus2F != null && PalletInIsHas2F != null && Convert.ToInt32(agvPutValue) == 1 && Convert.ToInt32(ConnectStatus2F) == 1 && Convert.ToInt32(PalletInIsHas2F) == 0)
|
|
|
|
|
{
|
|
|
|
|
// 托盘库叫料信号,并且通讯正常,并且小包入口无料 ,才可放托盘
|
|
|
|
|
@ -645,7 +639,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
{
|
|
|
|
|
var agvGetPoint = StaticData.BasePlcpointList.First(t => t.id == 53);
|
|
|
|
|
var agvGetValue = StaticData.PlcDic[2].Read(agvGetPoint.plcpointAddress);//小包出口的到位
|
|
|
|
|
if (agvGetValue != null && (bool)agvGetValue==true)
|
|
|
|
|
if (agvGetValue != null && (bool)agvGetValue == true)
|
|
|
|
|
{
|
|
|
|
|
var agvTask = new RequestAGVTaskDto
|
|
|
|
|
{
|
|
|
|
|
@ -662,13 +656,9 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
|
|
|
|
|
// 开启线程监听2分钟小包出口光电信号,如果小包出口到位信号消失,即取托盘完成,发送信号通知线体
|
|
|
|
|
ListenForSignal(2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var agvTask = new RequestAGVTaskDto
|
|
|
|
|
@ -685,8 +675,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 4 });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (item.taskStatus == 5)
|
|
|
|
|
{
|
|
|
|
|
@ -724,7 +712,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
var ConnectStatus2F = StaticData.PlcDic[2].Read(ConnectStatus2FPoint.plcpointAddress);//2F托盘库产线数据通讯情况
|
|
|
|
|
var PalletInIsHas2F = StaticData.PlcDic[2].Read(PalletInIsHas2FPoint.plcpointAddress);//2F托盘库入口上料光电
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (agvPutValue != null && ConnectStatus2F != null && PalletInIsHas2F != null && Convert.ToInt32(agvPutValue) == 1 && Convert.ToInt32(ConnectStatus2F) == 1 && Convert.ToInt32(PalletInIsHas2F) == 0)
|
|
|
|
|
{
|
|
|
|
|
// 托盘库叫料信号,并且通讯正常,并且小包入口无料 ,才可放托盘
|
|
|
|
|
@ -743,7 +730,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (item.taskStatus == 7)
|
|
|
|
|
{
|
|
|
|
|
@ -772,7 +758,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
wmsBaseLocation.containerCode = item.containerNo;
|
|
|
|
|
WmsProductStock wmsProductStock = new WmsProductStock()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
productId = mesBasePalletInfo.materialId,
|
|
|
|
|
activeFlag = "1",
|
|
|
|
|
frozenAmount = 0,
|
|
|
|
|
@ -796,6 +781,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
warehouseFloor = 2,
|
|
|
|
|
warehouseId = wmsBaseLocation.warehouseId
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#region 插入WmsProductInstock表
|
|
|
|
|
|
|
|
|
|
WmsProductInstock wmsProductInstock = new WmsProductInstock();
|
|
|
|
|
@ -823,7 +809,9 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
wmsProductInstock.beginTime = DateTime.Now;
|
|
|
|
|
wmsProductInstock.endTime = DateTime.Now;
|
|
|
|
|
dbContext.Add(wmsProductInstock);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion 插入WmsProductInstock表
|
|
|
|
|
|
|
|
|
|
//wmsProductInstockDetail.executeStatus = "2";
|
|
|
|
|
//wmsProductInstock.endTime = DateTime.Now;
|
|
|
|
|
//wmsProductInstock.executeStatus = "2";
|
|
|
|
|
@ -847,7 +835,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
WmsProductOutstock? wmsProductOutstock = dbContext.WmsProductOutstock.FirstOrDefault(t => t.productOutstockId == item.orderId);
|
|
|
|
|
if (wmsProductOutstock != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var wmsBaseLocation = dbContext.WmsBaseLocation.Where(t => t.locationId == item.currPointId).First();
|
|
|
|
|
WmsProductStock wmsProductStock = dbContext.WmsProductStock.First(t => t.locationCode == wmsBaseLocation.locationCode);
|
|
|
|
|
|
|
|
|
|
@ -857,7 +844,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
wmsProductOutstock.endTime = DateTime.Now;
|
|
|
|
|
wmsProductOutstock.executeStatus = "2";
|
|
|
|
|
}
|
|
|
|
|
WmsProductOutstockDetail? wmsProductOutstockDetail = dbContext.WmsProductOutstockDetail.FirstOrDefault(x=>x.productOutstockId== wmsProductOutstock.productOutstockId && x.locationCode== item.currPointId.ToString());
|
|
|
|
|
WmsProductOutstockDetail? wmsProductOutstockDetail = dbContext.WmsProductOutstockDetail.FirstOrDefault(x => x.productOutstockId == wmsProductOutstock.productOutstockId && x.locationCode == item.currPointId.ToString());
|
|
|
|
|
if (wmsProductOutstockDetail != null)
|
|
|
|
|
{ //人工出库,mes会自动插入,wcs只需要更新即可
|
|
|
|
|
wmsProductOutstockDetail.outstockAmount = 1;
|
|
|
|
|
@ -875,7 +862,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
wmsProductOutstockDetail.productBarcode = wmsProductStock.productBatch;
|
|
|
|
|
wmsProductOutstockDetail.productId = wmsProductStock.productId;
|
|
|
|
|
wmsProductOutstockDetail.planAmount = wmsProductOutstock.applyQty;
|
|
|
|
|
wmsProductOutstockDetail.outstockAmount = wmsProductOutstock.outstockQty;
|
|
|
|
|
wmsProductOutstockDetail.outstockAmount = 1;
|
|
|
|
|
wmsProductOutstockDetail.executeStatus = "2";
|
|
|
|
|
wmsProductOutstockDetail.updateBy = "WCS";
|
|
|
|
|
wmsProductOutstockDetail.updateDate = DateTime.Now;
|
|
|
|
|
@ -937,7 +924,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
//放托盘确认信号DB4.DBX310.0写true
|
|
|
|
|
BasePlcpoint SecondInPutOverPoint = StaticData.BasePlcpointList.First(t => t.id == 72);
|
|
|
|
|
StaticData.PlcDic[2].WriteToPoint(SecondInPutOverPoint.plcpointAddress, true, SecondInPutOverPoint.plcpointLength.ToString());
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
BaseEquip startEquip = dbContext.BaseEquip.First(t => t.objid == item.currPointId);
|
|
|
|
|
@ -988,6 +974,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
|
|
|
|
|
|
|
|
|
|
#region 插入移库记录
|
|
|
|
|
|
|
|
|
|
var wmsMove = dbContext.WmsMove.Where(t => t.MoveId == item.orderId).FirstOrDefault();
|
|
|
|
|
if (wmsMove == null)
|
|
|
|
|
{
|
|
|
|
|
@ -1039,7 +1026,8 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
wmsMoveDetail.UpdateDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
dbContext.WmsMoveDetail.Add(wmsMoveDetail);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion 插入移库记录
|
|
|
|
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
SystemData.SendPlcLocation(wmsBaseLocation);
|
|
|
|
|
@ -1100,7 +1088,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
{
|
|
|
|
|
if (ex is PlcException)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@ -1113,6 +1100,5 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|