master
2 years ago
parent 3fabdc2b12
commit 5573b86225

@ -99,6 +99,7 @@ namespace Khd.Core.Wcs.Wcs
{ {
using var scope = _host.Services.CreateScope(); using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>(); using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
List<string> cannotIn=new List<string>();
while (true) while (true)
{ {
try try
@ -160,11 +161,10 @@ namespace Khd.Core.Wcs.Wcs
//如果是4则找3如果是1则找2 //如果是4则找3如果是1则找2
&& a.b.locColumn == b.locColumn//列数相同 && a.b.locColumn == b.locColumn//列数相同
&& string.IsNullOrEmpty(b.containerCode) && string.IsNullOrEmpty(b.containerCode)
select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息 select new { a,b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
wmsBaseLocation ??= outBill.Where(t=> !cannotIn.Contains(t.b.locationCode)).FirstOrDefault()?.b;//先找相同物料的外侧库位
wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位 wmsBaseLocation ??= wmsBaseLocations.Where(t => !cannotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 2);//找不到再找深库位 wmsBaseLocation ??= wmsBaseLocations.Where(t => !cannotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
if (wmsBaseLocation != null)//如果找到库位,生成入库任务 if (wmsBaseLocation != null)//如果找到库位,生成入库任务
{ {
if (wmsBaseLocation.locDeep == 1) if (wmsBaseLocation.locDeep == 1)
@ -175,8 +175,9 @@ namespace Khd.Core.Wcs.Wcs
.Any(); .Any();
if (!hasLocation) if (!hasLocation)
{ {
Console.WriteLine(DateTime.Now + $":目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法移库"); cannotIn.Add(wmsBaseLocation.locationCode);
_logger.Info($"目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法移库"); Console.WriteLine(DateTime.Now + $":目标库位{cannotIn.Join(",")}的浅库位库位状态异常,无法移库");
_logger.Info($"目标库位{cannotIn.Join(",")}的浅库位库位状态异常,无法移库");
continue; continue;
} }
} }
@ -206,6 +207,7 @@ namespace Khd.Core.Wcs.Wcs
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask); WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog); dbContext.Add(wcsTaskLog);
dbContext.SaveChanges(); dbContext.SaveChanges();
cannotIn.Clear();
Console.WriteLine(DateTime.Now + ":二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid); Console.WriteLine(DateTime.Now + ":二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid);
_logger.Info("二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid); _logger.Info("二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid);
} }
@ -277,7 +279,7 @@ namespace Khd.Core.Wcs.Wcs
select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息 select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位 wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 2);//找不到再找深库位 wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位 wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
if (wmsBaseLocation != null)//如果找到库位,生成入库任务 if (wmsBaseLocation != null)//如果找到库位,生成入库任务
{ {
@ -1275,7 +1277,6 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Update(location); dbContext.Update(location);
dbContext.Add(wcsTask); dbContext.Add(wcsTask);
dbContext.Update(stock); dbContext.Update(stock);
dbContext.SaveChanges();
break; break;
} }
} }

@ -290,9 +290,14 @@ namespace Khd.Core.Wcs.Wcs
BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 1); BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 1);
if (Convert.ToInt32(linesignal01Value) == 1) if (Convert.ToInt32(linesignal01Value) == 1)
{ {
bool hasTask = dbContext.WcsTask.Where(t => t.nextPointId == 6 && t.currPointId == 1).Any();
if (hasTask)
{
continue;
}
//判断task表里没有该rfid的未完成的入库 //判断task表里没有该rfid的未完成的入库
//信息,未下发去向 //信息,未下发去向
var task = dbContext.WcsTask.Where(t => t.IsDelete == 0||t.IsDelete==null).Where(t => t.nextPointId == 1).OrderBy(t => t.createTime).FirstOrDefault(); var task = dbContext.WcsTask.Where(t => t.IsDelete == 0 || t.IsDelete == null).Where(t => t.nextPointId == 1).OrderBy(t => t.createTime).FirstOrDefault();
if (task == null) if (task == null)
{ {
if (BigContainerCodes.Contains(RFID001Value)) if (BigContainerCodes.Contains(RFID001Value))
@ -509,6 +514,9 @@ namespace Khd.Core.Wcs.Wcs
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload()); dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var wcsTasks = dbContext.WcsTask.Where(t => t.nextPointId == T01).OrderBy(t => t.createTime).ToList(); var wcsTasks = dbContext.WcsTask.Where(t => t.nextPointId == T01).OrderBy(t => t.createTime).ToList();
foreach (var wcsTask in wcsTasks) foreach (var wcsTask in wcsTasks)
{
bool hasTask = dbContext.WcsTask.Where(t => t.endPointId == wcsTask.endPointId && t.objid != wcsTask.objid).Any();
if (!hasTask)
{ {
wcsTask.serialNo ??= SystemData.GetSerialNo(dbContext); wcsTask.serialNo ??= SystemData.GetSerialNo(dbContext);
if (wcsTasks.Where(t => t.taskStatus > 0).Where(t => t.objid != wcsTask.objid).Any()) if (wcsTasks.Where(t => t.taskStatus > 0).Where(t => t.objid != wcsTask.objid).Any())
@ -694,6 +702,11 @@ namespace Khd.Core.Wcs.Wcs
} }
break; break;
} }
else
{
continue;
}
}
} }
} }
} }

@ -87,7 +87,6 @@ namespace Khd.Core.Wcs.Wcs
Console.WriteLine($"{DateTime.Now}:5楼接驳位上有货无法下发Agv出库任务"); Console.WriteLine($"{DateTime.Now}:5楼接驳位上有货无法下发Agv出库任务");
continue; continue;
} }
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
BaseEquip nextEquip = StaticData.BaseEquip.First(t => t.floorNo == 5 && t.equipType == 1); BaseEquip nextEquip = StaticData.BaseEquip.First(t => t.floorNo == 5 && t.equipType == 1);
RequestAGVTaskDto agvTask = new () RequestAGVTaskDto agvTask = new ()
{ {
@ -96,7 +95,7 @@ namespace Khd.Core.Wcs.Wcs
{ {
new () new ()
{ {
positionCode=wmsBaseLocation.agvPositionCode, positionCode=item.currPointNo,
type="00" type="00"
}, },
new () new ()
@ -115,7 +114,7 @@ namespace Khd.Core.Wcs.Wcs
if (reponseMessage != null && reponseMessage.message == "成功") if (reponseMessage != null && reponseMessage.message == "成功")
{ {
_logger.Info("五楼Agv下发任务成功" + message); _logger.Info("五楼Agv下发任务成功" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + wmsBaseLocation.agvPositionCode + "," + nextEquip.agvPositionCode); Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + item.containerNo + "," + nextEquip.agvPositionCode);
item.taskCode = reponseMessage.data; item.taskCode = reponseMessage.data;
item.taskStatus = 1; item.taskStatus = 1;
lineEquip.equipStatus = 1; lineEquip.equipStatus = 1;
@ -134,7 +133,6 @@ namespace Khd.Core.Wcs.Wcs
else if (item.taskType == 33)//原材料到背板安装 else if (item.taskType == 33)//原材料到背板安装
{ {
BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == 30); BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == 30);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
RequestAGVTaskDto agvTask = new() RequestAGVTaskDto agvTask = new()
{ {
reqCode = StaticData.SnowId.NextId().ToString(), reqCode = StaticData.SnowId.NextId().ToString(),
@ -142,7 +140,7 @@ namespace Khd.Core.Wcs.Wcs
{ {
new () new ()
{ {
positionCode=wmsBaseLocation.agvPositionCode, positionCode=item.currPointNo,
type="00" type="00"
}, },
new () new ()
@ -160,7 +158,7 @@ namespace Khd.Core.Wcs.Wcs
if (reponseMessage != null && reponseMessage.message == "成功") if (reponseMessage != null && reponseMessage.message == "成功")
{ {
_logger.Info("五楼Agv下发任务成功" + message); _logger.Info("五楼Agv下发任务成功" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + wmsBaseLocation.agvPositionCode + "," + endEquip.agvPositionCode); Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + item.currPointNo + "," + endEquip.agvPositionCode);
item.taskCode = reponseMessage.data; item.taskCode = reponseMessage.data;
item.taskStatus = 1; item.taskStatus = 1;
dbContext.Update(item); dbContext.Update(item);
@ -174,7 +172,6 @@ namespace Khd.Core.Wcs.Wcs
} }
else if (item.taskType == 34)//背板安装到半成品 else if (item.taskType == 34)//背板安装到半成品
{ {
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
BaseEquip currentEquip = StaticData.BaseEquip.First(t => t.objid == 30); BaseEquip currentEquip = StaticData.BaseEquip.First(t => t.objid == 30);
var agvTask = new RequestAGVTaskDto var agvTask = new RequestAGVTaskDto
{ {
@ -188,7 +185,7 @@ namespace Khd.Core.Wcs.Wcs
}, },
new () new ()
{ {
positionCode=wmsBaseLocation.agvPositionCode, positionCode=item.endPointNo,
type="00" type="00"
} }
}, },
@ -201,7 +198,7 @@ namespace Khd.Core.Wcs.Wcs
if (reponseMessage != null && reponseMessage.message == "成功") if (reponseMessage != null && reponseMessage.message == "成功")
{ {
_logger.Info("五楼Agv下发任务成功" + message); _logger.Info("五楼Agv下发任务成功" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + currentEquip.agvPositionCode + "," + wmsBaseLocation.agvPositionCode); Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + currentEquip.agvPositionCode + "," + item.endPointNo);
item.taskCode = reponseMessage.data; item.taskCode = reponseMessage.data;
item.taskStatus = 1; item.taskStatus = 1;
dbContext.Update(item); dbContext.Update(item);
@ -215,7 +212,6 @@ namespace Khd.Core.Wcs.Wcs
} }
else if (item.taskType == 46)//原材料到拆分区 else if (item.taskType == 46)//原材料到拆分区
{ {
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
BaseEquip currentEquip = StaticData.BaseEquip.First(t => t.objid == 29); BaseEquip currentEquip = StaticData.BaseEquip.First(t => t.objid == 29);
RequestAGVTaskDto agvTask = new() RequestAGVTaskDto agvTask = new()
{ {
@ -224,7 +220,7 @@ namespace Khd.Core.Wcs.Wcs
{ {
new () new ()
{ {
positionCode=wmsBaseLocation.agvPositionCode, positionCode=item.currPointNo,
type="00" type="00"
}, },
new () new ()
@ -242,7 +238,7 @@ namespace Khd.Core.Wcs.Wcs
if (reponseMessage != null && reponseMessage.message == "成功") if (reponseMessage != null && reponseMessage.message == "成功")
{ {
_logger.Info("五楼Agv下发任务成功" + message); _logger.Info("五楼Agv下发任务成功" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + wmsBaseLocation.agvPositionCode + "," + currentEquip.agvPositionCode); Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + item.currPointNo + "," + currentEquip.agvPositionCode);
item.taskCode = reponseMessage.data; item.taskCode = reponseMessage.data;
item.taskStatus = 1; item.taskStatus = 1;
dbContext.Update(item); dbContext.Update(item);
@ -257,7 +253,6 @@ namespace Khd.Core.Wcs.Wcs
else if (item.taskType == 28)//拆分区返库 else if (item.taskType == 28)//拆分区返库
{ {
BaseEquip currentEquip = StaticData.BaseEquip.First(t => t.objid == 29); BaseEquip currentEquip = StaticData.BaseEquip.First(t => t.objid == 29);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
RequestAGVTaskDto agvTask = new() RequestAGVTaskDto agvTask = new()
{ {
reqCode = StaticData.SnowId.NextId().ToString(), reqCode = StaticData.SnowId.NextId().ToString(),
@ -270,7 +265,7 @@ namespace Khd.Core.Wcs.Wcs
}, },
new() new()
{ {
positionCode = wmsBaseLocation.agvPositionCode, positionCode = item.endPointNo,
type = "00" type = "00"
} }
}, },
@ -284,7 +279,7 @@ namespace Khd.Core.Wcs.Wcs
if (reponseMessage != null && reponseMessage.message == "成功") if (reponseMessage != null && reponseMessage.message == "成功")
{ {
_logger.Info("五楼Agv下发任务成功" + message); _logger.Info("五楼Agv下发任务成功" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + currentEquip.agvPositionCode + "," + wmsBaseLocation.agvPositionCode); Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + currentEquip.agvPositionCode + "," + item.endPointNo);
item.taskCode = reponseMessage.data; item.taskCode = reponseMessage.data;
item.taskStatus = 1; item.taskStatus = 1;
dbContext.Update(item); dbContext.Update(item);
@ -299,7 +294,6 @@ namespace Khd.Core.Wcs.Wcs
else if (item.taskType == 47)//原材料入库 else if (item.taskType == 47)//原材料入库
{ {
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == 5); BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == 5);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
var agvTask = new RequestAGVTaskDto var agvTask = new RequestAGVTaskDto
{ {
reqCode = StaticData.SnowId.NextId().ToString(), reqCode = StaticData.SnowId.NextId().ToString(),
@ -312,7 +306,7 @@ namespace Khd.Core.Wcs.Wcs
}, },
new () new ()
{ {
positionCode=wmsBaseLocation.agvPositionCode, positionCode=item.endPointNo,
type="00" type="00"
} }
}, },
@ -325,7 +319,7 @@ namespace Khd.Core.Wcs.Wcs
if (reponseMessage != null && reponseMessage.message == "成功") if (reponseMessage != null && reponseMessage.message == "成功")
{ {
_logger.Info("五楼Agv下发任务成功" + message); _logger.Info("五楼Agv下发任务成功" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + startEquip.agvPositionCode + "," + wmsBaseLocation.agvPositionCode); Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + startEquip.agvPositionCode + "," + item.endPointNo);
item.taskCode = reponseMessage.data; item.taskCode = reponseMessage.data;
item.taskStatus = 1; item.taskStatus = 1;
dbContext.Update(item); dbContext.Update(item);
@ -339,8 +333,6 @@ namespace Khd.Core.Wcs.Wcs
} }
else if (item.taskType == 66)//移库 else if (item.taskType == 66)//移库
{ {
WmsBaseLocation fromBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
WmsBaseLocation toBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
var agvTask = new RequestAGVTaskDto var agvTask = new RequestAGVTaskDto
{ {
reqCode = StaticData.SnowId.NextId().ToString(), reqCode = StaticData.SnowId.NextId().ToString(),
@ -348,12 +340,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
new () new ()
{ {
positionCode=fromBaseLocation.agvPositionCode, positionCode=item.currPointNo,
type="00" type="00"
}, },
new () new ()
{ {
positionCode=toBaseLocation.agvPositionCode, positionCode=item.endPointNo,
type="00" type="00"
} }
}, },
@ -366,7 +358,7 @@ namespace Khd.Core.Wcs.Wcs
if (reponseMessage != null && reponseMessage.message == "成功") if (reponseMessage != null && reponseMessage.message == "成功")
{ {
_logger.Info("五楼Agv下发任务成功" + message); _logger.Info("五楼Agv下发任务成功" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + fromBaseLocation.agvPositionCode + "," + toBaseLocation.agvPositionCode); Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data; item.taskCode = reponseMessage.data;
item.taskStatus = 1; item.taskStatus = 1;
dbContext.Update(item); dbContext.Update(item);

@ -143,6 +143,11 @@ namespace Khd.Core.Wcs.Wcs
dbContext.SaveChanges(); dbContext.SaveChanges();
} }
} }
else
{
//报警
StaticData.PlcDic[1].WriteToPoint(CtuLineWaring.plcpointAddress, true, CtuLineWaring.plcpointLength.ToString());
}
} }
else else
{ {
@ -234,6 +239,10 @@ namespace Khd.Core.Wcs.Wcs
StaticData.PlcDic[1].WriteToPoint(CtuLineWaring.plcpointAddress, true, CtuLineWaring.plcpointLength.ToString()); StaticData.PlcDic[1].WriteToPoint(CtuLineWaring.plcpointAddress, true, CtuLineWaring.plcpointLength.ToString());
} }
} }
else
{
StaticData.PlcDic[1].WriteToPoint(CtuLineWaring.plcpointAddress, false, CtuLineWaring.plcpointLength.ToString());
}
//else if (receiveMaterial != null && Convert.ToInt32(receiveMaterial) == 0) //else if (receiveMaterial != null && Convert.ToInt32(receiveMaterial) == 0)
//{ //{
// lock (SystemData.outStockLock) // lock (SystemData.outStockLock)

@ -94,6 +94,7 @@ namespace Khd.Core.Wcs.Wcs
List<string> containerCodes = wmsBaseLocations List<string> containerCodes = wmsBaseLocations
.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));
List<MesBaseBarcodeInfo> mesBasePalletInfos = dbContext.MesBaseBarcodeInfo List<MesBaseBarcodeInfo> mesBasePalletInfos = dbContext.MesBaseBarcodeInfo
.Where(t => t.materialId == wcsTask.materialId) .Where(t => t.materialId == wcsTask.materialId)
.Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId) .Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)
@ -111,17 +112,30 @@ namespace Khd.Core.Wcs.Wcs
&& a.b.locColumn == b.locColumn && a.b.locColumn == b.locColumn
&& b.locationStatus == "1" && b.locationStatus == "1"
&& string.IsNullOrEmpty(b.containerCode) && string.IsNullOrEmpty(b.containerCode)
select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息 select new { a,b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
WmsBaseLocation? wmsBaseLocation = null; WmsBaseLocation? wmsBaseLocation = null;
wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位 wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 2);//找不到再找深库位 wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位 wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
//深浅库位问题?库位入库优先级等 //深浅库位问题?库位入库优先级等
var AgvEquip = StaticData.BaseEquip.First(t => t.objid == 28);//5楼叉车 var AgvEquip = StaticData.BaseEquip.First(t => t.objid == 28);//5楼叉车
if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null) if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null)
{ {
if (wmsBaseLocation.locDeep == 1)
{
bool hasLocation = wmsBaseLocations
.Where(t => t.locRow == (wmsBaseLocation.locRow % 2 == 1 ? (wmsBaseLocation.locRow + 1) : (wmsBaseLocation.locRow - 1)))
.Where(t => t.locColumn == wmsBaseLocation.locColumn)
.Any();
if (!hasLocation)
{
Console.WriteLine(DateTime.Now + $":目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库");
_logger.Info($"目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库");
continue;
}
}
WcsTask newTask = CoreMapper.Map<WcsTask>(wcsTask); WcsTask newTask = CoreMapper.Map<WcsTask>(wcsTask);
newTask.taskStatus = 0;//创建状态 newTask.taskStatus = 0;//创建状态
newTask.updateTime = DateTime.Now; newTask.updateTime = DateTime.Now;

@ -150,7 +150,6 @@ namespace Khd.Core.Wcs.Wcs
} }
else if (item.taskType == 49)//小包出口-库位 else if (item.taskType == 49)//小包出口-库位
{ {
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
BaseEquip startEquip = dbContext.BaseEquip.First(t => t.objid == item.currPointId); BaseEquip startEquip = dbContext.BaseEquip.First(t => t.objid == item.currPointId);
var agvTask = new RequestAGVTaskDto var agvTask = new RequestAGVTaskDto
{ {
@ -164,7 +163,7 @@ namespace Khd.Core.Wcs.Wcs
}, },
new () new ()
{ {
positionCode=wmsBaseLocation.agvPositionCode, positionCode=item.endPointNo,
type="00" type="00"
} }
}, },
@ -277,8 +276,6 @@ namespace Khd.Core.Wcs.Wcs
} }
else if (item.taskType == 55)//2F移库 else if (item.taskType == 55)//2F移库
{ {
WmsBaseLocation fromWmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
WmsBaseLocation toWmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
var agvTask = new RequestAGVTaskDto var agvTask = new RequestAGVTaskDto
{ {
reqCode = StaticData.SnowId.NextId().ToString(), reqCode = StaticData.SnowId.NextId().ToString(),
@ -286,12 +283,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
new() new()
{ {
positionCode = fromWmsBaseLocation.agvPositionCode, positionCode = item.currPointNo,
type = "00" type = "00"
}, },
new() new()
{ {
positionCode = toWmsBaseLocation.agvPositionCode, positionCode = item.endPointNo,
type = "00" type = "00"
} }

@ -249,7 +249,7 @@ namespace Khd.Core.Wcs.Wcs
List<string> containerCodes = wmsBaseLocations List<string> containerCodes = wmsBaseLocations
.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));
List<MesBaseBarcodeInfo> mesBasePalletInfos = dbContext.MesBaseBarcodeInfo List<MesBaseBarcodeInfo> mesBasePalletInfos = dbContext.MesBaseBarcodeInfo
.Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)//销售订单 .Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)//销售订单
.Where(t => t.materialId == mesBasePalletInfo.materialId)//物料Id .Where(t => t.materialId == mesBasePalletInfo.materialId)//物料Id
@ -270,10 +270,23 @@ namespace Khd.Core.Wcs.Wcs
select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息 select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位 wmsBaseLocation ??= outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 2);//找不到再找深库位 wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位
wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位 wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
if (wmsBaseLocation != null)//如果找到库位,生成入库任务 if (wmsBaseLocation != null)//如果找到库位,生成入库任务
{ {
if (wmsBaseLocation.locDeep == 1)
{
bool hasLocation = wmsBaseLocations
.Where(t => t.locRow == (wmsBaseLocation.locRow % 2 == 1 ? (wmsBaseLocation.locRow + 1) : (wmsBaseLocation.locRow - 1)))
.Where(t => t.locColumn == wmsBaseLocation.locColumn)
.Any();
if (!hasLocation)
{
Console.WriteLine(DateTime.Now + $":目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库");
_logger.Info($"目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库");
continue;
}
}
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == 37); BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == 37);
var wcsTask = new WcsTask() var wcsTask = new WcsTask()
{ {

@ -128,8 +128,6 @@ namespace Khd.Core.Wcs.Wcs
BaseDictionary baseDictionary = StaticData.BaseDictionary.First(t => t.objid == item.taskType); BaseDictionary baseDictionary = StaticData.BaseDictionary.First(t => t.objid == item.taskType);
if (item.taskType == 67)//移库 if (item.taskType == 67)//移库
{ {
WmsBaseLocation fromBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
WmsBaseLocation toBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
var agvTask = new RequestAGVTaskDto var agvTask = new RequestAGVTaskDto
{ {
reqCode = StaticData.SnowId.NextId().ToString(), reqCode = StaticData.SnowId.NextId().ToString(),
@ -137,12 +135,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
new () new ()
{ {
positionCode=fromBaseLocation.agvPositionCode, positionCode=item.currPointNo,
type="00" type="00"
}, },
new () new ()
{ {
positionCode=toBaseLocation.agvPositionCode, positionCode=item.endPointNo,
type="00" type="00"
} }
}, },
@ -170,7 +168,6 @@ namespace Khd.Core.Wcs.Wcs
else if (item.taskType == 39)//提升机-库位 else if (item.taskType == 39)//提升机-库位
{ {
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == 3); BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == 3);
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.endPointId);
var agvTask = new RequestAGVTaskDto var agvTask = new RequestAGVTaskDto
{ {
reqCode = StaticData.SnowId.NextId().ToString(), reqCode = StaticData.SnowId.NextId().ToString(),
@ -183,7 +180,7 @@ namespace Khd.Core.Wcs.Wcs
}, },
new () new ()
{ {
positionCode=wmsBaseLocation.agvPositionCode, positionCode=item.endPointNo,
type="00" type="00"
} }
}, },

@ -83,6 +83,7 @@ namespace Khd.Core.Wcs.Wcs
.ToList(); .ToList();
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));
List<MesBaseBarcodeInfo> mesBasePalletInfos = dbContext.MesBaseBarcodeInfo List<MesBaseBarcodeInfo> mesBasePalletInfos = dbContext.MesBaseBarcodeInfo
.Where(t => t.materialId == wcsTask.materialId) .Where(t => t.materialId == wcsTask.materialId)
.Where(t=>t.saleOrderId== mesBaseBarcodeInfo.saleOrderId) .Where(t=>t.saleOrderId== mesBaseBarcodeInfo.saleOrderId)
@ -108,6 +109,19 @@ namespace Khd.Core.Wcs.Wcs
if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null) if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null)
{ {
if (wmsBaseLocation.locDeep == 1)
{
bool hasLocation = wmsBaseLocations
.Where(t => t.locRow == (wmsBaseLocation.locRow % 2 == 1 ? (wmsBaseLocation.locRow + 1) : (wmsBaseLocation.locRow - 1)))
.Where(t => t.locColumn == wmsBaseLocation.locColumn)
.Any();
if (!hasLocation)
{
Console.WriteLine(DateTime.Now + $":目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库");
_logger.Info($"目标库位{wmsBaseLocation.locationCode}的浅库位库位状态异常,无法入库");
continue;
}
}
dbContext.Remove(wcsTask); dbContext.Remove(wcsTask);
WcsTask newTask = CoreMapper.Map<WcsTask>(wcsTask); WcsTask newTask = CoreMapper.Map<WcsTask>(wcsTask);
newTask.objid = StaticData.SnowId.NextId(); newTask.objid = StaticData.SnowId.NextId();

Loading…
Cancel
Save