master
1 year ago
parent 720bf4b557
commit 0c05aa4395

@ -64,5 +64,9 @@ namespace Khd.Core.Wcs
} }
} }
} }
public readonly static object SecondTaskLock = new ();
public readonly static object ThirdTaskLock = new ();
public readonly static object FiveTaskLock = new ();
} }
} }

@ -351,6 +351,8 @@ namespace Khd.Core.Wcs.Wcs
while (true) while (true)
{ {
try try
{
lock (SystemData.FiveTaskLock)
{ {
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload()); dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 29); BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 29);
@ -477,6 +479,7 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
_logger.Error(ex.Message + "\n" + ex.StackTrace); _logger.Error(ex.Message + "\n" + ex.StackTrace);
@ -839,6 +842,8 @@ namespace Khd.Core.Wcs.Wcs
while (true) while (true)
{ {
try try
{
lock (SystemData.ThirdTaskLock)
{ {
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload()); dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
bool task = dbContext.WcsTask.Where(t => t.nextPointId == 9 && t.taskStatus <= 5).Any(); bool task = dbContext.WcsTask.Where(t => t.nextPointId == 9 && t.taskStatus <= 5).Any();
@ -1074,10 +1079,15 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
_logger.Error(ex.Message + "\n" + ex.StackTrace); _logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
finally
{
Thread.Sleep(5000);
}
} }
} }
@ -1423,6 +1433,8 @@ namespace Khd.Core.Wcs.Wcs
{ {
bool task = dbContext.WcsTask.Where(t => t.nextPointId == 8 && t.taskStatus <= 7).Any(); bool task = dbContext.WcsTask.Where(t => t.nextPointId == 8 && t.taskStatus <= 7).Any();
if (!task) if (!task)
{
lock (SystemData.SecondTaskLock)
{ {
var proStock = dbContext.WmsProductStock var proStock = dbContext.WmsProductStock
.Where(t => t.warehouseId == 231) .Where(t => t.warehouseId == 231)
@ -1646,6 +1658,7 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex.Message + ex.StackTrace); Console.WriteLine(ex.Message + ex.StackTrace);
@ -1704,8 +1717,7 @@ namespace Khd.Core.Wcs.Wcs
var endEquip = dbContext.BaseEquip.FirstOrDefault(t => t.equipNo == item.endStationCode); var endEquip = dbContext.BaseEquip.FirstOrDefault(t => t.equipNo == item.endStationCode);
if (endEquip != null && endEquip.floorNo == 5) if (endEquip != null && endEquip.floorNo == 5)
{ {
lock (SystemData.outStockLock)
{
#region CTU出库没用背负Agv的逻辑 #region CTU出库没用背负Agv的逻辑
//if (endEquip.equipType == 8)//CTU出库 //if (endEquip.equipType == 8)//CTU出库
//{ //{
@ -1841,6 +1853,8 @@ namespace Khd.Core.Wcs.Wcs
//}//CTU出库 //}//CTU出库
#endregion #endregion
if (endEquip.equipType == 10)//CTU出库到装配区 if (endEquip.equipType == 10)//CTU出库到装配区
{
lock (SystemData.outStockLock)
{ {
//原材料库存 //原材料库存
var rawStock = dbContext.WmsRawStock var rawStock = dbContext.WmsRawStock
@ -2067,7 +2081,12 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
} }
else if (endEquip.equipType == 12)//原材料到柜体验收区,背板安装 }
else
{
lock (SystemData.FiveTaskLock)
{
if (endEquip.equipType == 12)//原材料到柜体验收区,背板安装
{ {
var rawStock = dbContext.WmsRawStock var rawStock = dbContext.WmsRawStock
.Where(t => t.activeFlag == "1").ToList(); .Where(t => t.activeFlag == "1").ToList();
@ -2486,11 +2505,12 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
_logger.Error(ex.Message + "\n" + ex.StackTrace); _logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
Thread.Sleep(1000); Thread.Sleep(3000);
} }

@ -101,6 +101,8 @@ namespace Khd.Core.Wcs.Wcs
else//小托盘 else//小托盘
{ {
if (wcsTask.taskStatus == 5)//入库,提升机任务是完成状态 if (wcsTask.taskStatus == 5)//入库,提升机任务是完成状态
{
lock (SystemData.FiveTaskLock)
{ {
var wmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseFloor == FloorNo) var wmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseFloor == FloorNo)
.Where(t => t.activeFlag == "1") .Where(t => t.activeFlag == "1")
@ -121,13 +123,14 @@ namespace Khd.Core.Wcs.Wcs
.Where(t => t.locDeep == 1) .Where(t => t.locDeep == 1)
.Select(t => t.containerCode).ToList();//深库位的托盘 .Select(t => t.containerCode).ToList();//深库位的托盘
containerCodes.RemoveAll(t => string.IsNullOrEmpty(t)); containerCodes.RemoveAll(t => string.IsNullOrEmpty(t));
List<MesBaseBarcodeInfo> mesBasePalletInfos = dbContext.MesBaseBarcodeInfo List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock
.Where(t => t.materialId == wcsTask.materialId) .Where(t => t.materialId == mesBaseBarcodeInfo.materialId)
.Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId) .Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)
.Where(t => t.palletInfoCode != null) .Where(t => t.palletInfoCode != null)
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料 .Where(t => t.warehouseId == 511)
mesBasePalletInfos.RemoveAll(t => t.palletInfoCode == null); .Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();
var bill = from a in mesBasePalletInfos
var bill = from a in wmsRawStocks
join b in wmsBaseLocations join b in wmsBaseLocations
.Where(t => t.locDeep == 1 && mesBaseBarcodeInfo.completeFlag == "0" ? t.returnFlag == "1" : t.returnFlag == "0") on a.palletInfoCode equals b.containerCode .Where(t => t.locDeep == 1 && mesBaseBarcodeInfo.completeFlag == "0" ? t.returnFlag == "1" : t.returnFlag == "0") on a.palletInfoCode equals b.containerCode
select new { b };//等于当前任务的物料的托盘的库位信息 select new { b };//等于当前任务的物料的托盘的库位信息
@ -212,7 +215,7 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
} }
}
} }
else if (wcsTask.taskStatus == 6) //出库任务,小车任务是完成状态 else if (wcsTask.taskStatus == 6) //出库任务,小车任务是完成状态
{ {

@ -227,6 +227,8 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
if (Convert.ToInt32(agvGetValue) == 1 && !string.IsNullOrEmpty(rfidValue))//小包出口成品入口 if (Convert.ToInt32(agvGetValue) == 1 && !string.IsNullOrEmpty(rfidValue))//小包出口成品入口
{
lock (SystemData.SecondTaskLock)
{ {
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == rfidValue); MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == rfidValue);
if (mesBasePalletInfo != null) if (mesBasePalletInfo != null)
@ -252,13 +254,13 @@ namespace Khd.Core.Wcs.Wcs
.Where(t => t.locDeep == 1) .Where(t => t.locDeep == 1)
.Select(t => t.containerCode).ToList();//深库位的有托盘 .Select(t => t.containerCode).ToList();//深库位的有托盘
containerCodes.RemoveAll(t => string.IsNullOrEmpty(t)); containerCodes.RemoveAll(t => string.IsNullOrEmpty(t));
List<MesBaseBarcodeInfo> mesBasePalletInfos = dbContext.MesBaseBarcodeInfo
.Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)//销售订单 List<WmsProductStock> productStocks = wmsProductStocks.Where(t => t.productId == mesBaseBarcodeInfo.materialId)
.Where(t => t.materialId == mesBasePalletInfo.materialId)//物料Id .Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)
.Where(t => t.palletInfoCode != null) .Where(t => t.palletInfoCode != null)
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料 .Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();
mesBasePalletInfos.RemoveAll(t=>t.palletInfoCode==null);
var bill = from a in mesBasePalletInfos var bill = from a in productStocks
join b in wmsBaseLocations.Where(t => t.locDeep == 1) on a.palletInfoCode equals b.containerCode join b in wmsBaseLocations.Where(t => t.locDeep == 1) on a.palletInfoCode equals b.containerCode
select new { b };//等于当前任务的物料的托盘的库位信息 select new { b };//等于当前任务的物料的托盘的库位信息
@ -331,6 +333,7 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
if (ex is PlcException) if (ex is PlcException)

@ -198,7 +198,7 @@ namespace Khd.Core.Wcs.Wcs
{ {
try try
{ {
StaticData.PlcDic[0].Read(HeartBeat30.plcpointAddress); StaticData.PlcDic[2].Read(HeartBeat30.plcpointAddress);
} }
catch catch
{ {

@ -67,6 +67,8 @@ namespace Khd.Core.Wcs.Wcs
if (wcsTask != null)//如果不是null if (wcsTask != null)//如果不是null
{ {
if (wcsTask.taskStatus == 5)//提升机任务是完成状态 if (wcsTask.taskStatus == 5)//提升机任务是完成状态
{
lock (SystemData.ThirdTaskLock)
{ {
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.Where(t => t.palletInfoCode == rfid).FirstOrDefault(); MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.Where(t => t.palletInfoCode == rfid).FirstOrDefault();
if (mesBasePalletInfo != null) if (mesBasePalletInfo != null)
@ -85,13 +87,13 @@ namespace Khd.Core.Wcs.Wcs
List<string> containerCodes = wmsBaseLocations.Where(t => t.locDeep == 1).Select(t => t.containerCode).ToList();//深库位的托盘 List<string> containerCodes = wmsBaseLocations.Where(t => t.locDeep == 1).Select(t => t.containerCode).ToList();//深库位的托盘
containerCodes.RemoveAll(t => string.IsNullOrEmpty(t)); containerCodes.RemoveAll(t => string.IsNullOrEmpty(t));
List<MesBaseBarcodeInfo> mesBasePalletInfos = dbContext.MesBaseBarcodeInfo List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => t.materialId == mesBaseBarcodeInfo.materialId)
.Where(t => t.materialId == wcsTask.materialId)
.Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId) .Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)
.Where(t => t.palletInfoCode != null) .Where(t => t.palletInfoCode != null)
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料 .Where(t => t.warehouseId == 311)
mesBasePalletInfos.RemoveAll(t => t.palletInfoCode == null); .Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();
var bill = from a in mesBasePalletInfos
var bill = from a in wmsRawStocks
join b in wmsBaseLocations.Where(t => t.locDeep == 1 && !string.IsNullOrEmpty(t.containerCode)) on a.palletInfoCode equals b.containerCode join b in wmsBaseLocations.Where(t => t.locDeep == 1 && !string.IsNullOrEmpty(t.containerCode)) on a.palletInfoCode equals b.containerCode
select new { b };//等于当前任务的物料的托盘的库位信息 select new { b };//等于当前任务的物料的托盘的库位信息
@ -156,7 +158,7 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
} }
}
} }
else if (wcsTask.taskStatus == 6)//小车任务是完成状态,说明是出库 else if (wcsTask.taskStatus == 6)//小车任务是完成状态,说明是出库
{ {

Loading…
Cancel
Save