|
|
|
|
@ -102,117 +102,120 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
{
|
|
|
|
|
if (wcsTask.taskStatus == 5)//入库,提升机任务是完成状态
|
|
|
|
|
{
|
|
|
|
|
var wmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseFloor == FloorNo)
|
|
|
|
|
lock (SystemData.FiveTaskLock)
|
|
|
|
|
{
|
|
|
|
|
var wmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseFloor == FloorNo)
|
|
|
|
|
.Where(t => t.activeFlag == "1")
|
|
|
|
|
.Where(t => t.delFlag == "0")
|
|
|
|
|
.Where(t => t.locationScrapType == "1")
|
|
|
|
|
.Where(t => t.warehouseId == 511)
|
|
|
|
|
.Where(t => t.locationStatus == "1")
|
|
|
|
|
.ToList();
|
|
|
|
|
if (wmsBaseLocations.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.Where(t => t.palletInfoCode == rfid).FirstOrDefault();
|
|
|
|
|
if (mesBasePalletInfo != null)
|
|
|
|
|
if (wmsBaseLocations.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
|
|
|
|
|
if (mesBaseBarcodeInfo != null)
|
|
|
|
|
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.Where(t => t.palletInfoCode == rfid).FirstOrDefault();
|
|
|
|
|
if (mesBasePalletInfo != null)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
.Where(t => t.materialId == wcsTask.materialId)
|
|
|
|
|
.Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)
|
|
|
|
|
.Where(t => t.palletInfoCode != null)
|
|
|
|
|
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料
|
|
|
|
|
mesBasePalletInfos.RemoveAll(t => t.palletInfoCode == null);
|
|
|
|
|
var bill = from a in mesBasePalletInfos
|
|
|
|
|
join b in wmsBaseLocations
|
|
|
|
|
.Where(t => t.locDeep == 1 && mesBaseBarcodeInfo.completeFlag == "0" ? t.returnFlag == "1" : t.returnFlag == "0") on a.palletInfoCode equals b.containerCode
|
|
|
|
|
select new { b };//等于当前任务的物料的托盘的库位信息
|
|
|
|
|
var outBill = from a in bill
|
|
|
|
|
from b in wmsBaseLocations
|
|
|
|
|
where b.locDeep == 2
|
|
|
|
|
&& b.locRow == (a.b.locRow % 2 == 0 ? a.b.locRow - 1 : a.b.locRow + 1)
|
|
|
|
|
&& a.b.locColumn == b.locColumn
|
|
|
|
|
&& b.locationStatus == "1"
|
|
|
|
|
&& string.IsNullOrEmpty(b.containerCode)
|
|
|
|
|
select new { a, b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
|
|
|
|
|
if(mesBaseBarcodeInfo.completeFlag == "0")
|
|
|
|
|
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
|
|
|
|
|
if (mesBaseBarcodeInfo != null)
|
|
|
|
|
{
|
|
|
|
|
outBill = outBill.OrderByDescending(t => t.b.locColumn).ToList();
|
|
|
|
|
wmsBaseLocations= wmsBaseLocations.OrderByDescending(t => t.locColumn).ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
outBill = outBill.OrderBy(t => t.b.locColumn).ToList();
|
|
|
|
|
wmsBaseLocations = wmsBaseLocations.OrderBy(t => t.locColumn).ToList();
|
|
|
|
|
}
|
|
|
|
|
WmsBaseLocation? wmsBaseLocation = null;
|
|
|
|
|
wmsBaseLocation ??= outBill.Where(t => !canNotIn.Contains(t.b.locationCode)).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 => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
|
|
|
|
|
//深浅库位问题?库位入库优先级等
|
|
|
|
|
List<string> containerCodes = wmsBaseLocations
|
|
|
|
|
.Where(t => t.locDeep == 1)
|
|
|
|
|
.Select(t => t.containerCode).ToList();//深库位的托盘
|
|
|
|
|
containerCodes.RemoveAll(t => string.IsNullOrEmpty(t));
|
|
|
|
|
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock
|
|
|
|
|
.Where(t => t.materialId == mesBaseBarcodeInfo.materialId)
|
|
|
|
|
.Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)
|
|
|
|
|
.Where(t => t.palletInfoCode != null)
|
|
|
|
|
.Where(t => t.warehouseId == 511)
|
|
|
|
|
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();
|
|
|
|
|
|
|
|
|
|
var AgvEquip = StaticData.BaseEquip.First(t => t.objid == 28);//5楼叉车
|
|
|
|
|
if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null)
|
|
|
|
|
{
|
|
|
|
|
if (wmsBaseLocation.locDeep == 1)
|
|
|
|
|
var bill = from a in wmsRawStocks
|
|
|
|
|
join b in wmsBaseLocations
|
|
|
|
|
.Where(t => t.locDeep == 1 && mesBaseBarcodeInfo.completeFlag == "0" ? t.returnFlag == "1" : t.returnFlag == "0") on a.palletInfoCode equals b.containerCode
|
|
|
|
|
select new { b };//等于当前任务的物料的托盘的库位信息
|
|
|
|
|
var outBill = from a in bill
|
|
|
|
|
from b in wmsBaseLocations
|
|
|
|
|
where b.locDeep == 2
|
|
|
|
|
&& b.locRow == (a.b.locRow % 2 == 0 ? a.b.locRow - 1 : a.b.locRow + 1)
|
|
|
|
|
&& a.b.locColumn == b.locColumn
|
|
|
|
|
&& b.locationStatus == "1"
|
|
|
|
|
&& string.IsNullOrEmpty(b.containerCode)
|
|
|
|
|
select new { a, b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
|
|
|
|
|
if (mesBaseBarcodeInfo.completeFlag == "0")
|
|
|
|
|
{
|
|
|
|
|
bool hasLocation = wmsBaseLocations
|
|
|
|
|
.Where(t => t.locRow == (wmsBaseLocation.locRow % 2 == 1 ? (wmsBaseLocation.locRow + 1) : (wmsBaseLocation.locRow - 1)))
|
|
|
|
|
.Where(t => t.locColumn == wmsBaseLocation.locColumn)
|
|
|
|
|
.Where(t => !string.IsNullOrEmpty(t.containerCode) || t.locationStatus != "1")
|
|
|
|
|
.Any();
|
|
|
|
|
if (hasLocation)
|
|
|
|
|
{
|
|
|
|
|
canNotIn.Add(wmsBaseLocation.locationCode);
|
|
|
|
|
Console.WriteLine(DateTime.Now + $":目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库");
|
|
|
|
|
_logger.Info($"目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
WcsTask newTask = CoreMapper.Map<WcsTask>(wcsTask);
|
|
|
|
|
newTask.taskStatus = 0;//创建状态
|
|
|
|
|
newTask.updateTime = DateTime.Now;
|
|
|
|
|
newTask.currPointId = baseEquip.objid;
|
|
|
|
|
newTask.currPointNo = baseEquip.equipNo;
|
|
|
|
|
newTask.nextPointId = AgvEquip.objid;
|
|
|
|
|
newTask.nextPointNo = AgvEquip.equipNo;
|
|
|
|
|
newTask.endPointId = wmsBaseLocation.locationId;
|
|
|
|
|
newTask.endPointNo = wmsBaseLocation.locationCode;
|
|
|
|
|
newTask.objid = StaticData.SnowId.NextId();
|
|
|
|
|
newTask.createTime = DateTime.Now;
|
|
|
|
|
newTask.taskType = 47;
|
|
|
|
|
if (newTask.fromFloorNo != 1)//如果不是一楼来的,需要通过接口确认入库(质检通过后,点击继续入库)
|
|
|
|
|
{
|
|
|
|
|
newTask.useFlag = 0;
|
|
|
|
|
outBill = outBill.OrderByDescending(t => t.b.locColumn).ToList();
|
|
|
|
|
wmsBaseLocations = wmsBaseLocations.OrderByDescending(t => t.locColumn).ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
newTask.useFlag = 1;
|
|
|
|
|
outBill = outBill.OrderBy(t => t.b.locColumn).ToList();
|
|
|
|
|
wmsBaseLocations = wmsBaseLocations.OrderBy(t => t.locColumn).ToList();
|
|
|
|
|
}
|
|
|
|
|
wmsBaseLocation.locationStatus = "2";
|
|
|
|
|
dbContext.Update(wmsBaseLocation);
|
|
|
|
|
dbContext.Remove(wcsTask);
|
|
|
|
|
SystemData.LockOutLocation(wmsBaseLocation, dbContext);
|
|
|
|
|
WmsBaseLocation? wmsBaseLocation = null;
|
|
|
|
|
wmsBaseLocation ??= outBill.Where(t => !canNotIn.Contains(t.b.locationCode)).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 => !canNotIn.Contains(t.locationCode)).Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
|
|
|
|
|
//深浅库位问题?库位入库优先级等
|
|
|
|
|
|
|
|
|
|
dbContext.Add(newTask);
|
|
|
|
|
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(newTask);
|
|
|
|
|
dbContext.Add(wcsTaskLog);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
canNotIn.Clear();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(DateTime.Now + ":五楼接驳位调度入库任务,未找到库位");
|
|
|
|
|
_logger.Info("五楼接驳位调度入库任务,未找到库位");
|
|
|
|
|
var AgvEquip = StaticData.BaseEquip.First(t => t.objid == 28);//5楼叉车
|
|
|
|
|
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)
|
|
|
|
|
.Where(t => !string.IsNullOrEmpty(t.containerCode) || t.locationStatus != "1")
|
|
|
|
|
.Any();
|
|
|
|
|
if (hasLocation)
|
|
|
|
|
{
|
|
|
|
|
canNotIn.Add(wmsBaseLocation.locationCode);
|
|
|
|
|
Console.WriteLine(DateTime.Now + $":目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库");
|
|
|
|
|
_logger.Info($"目标库位{canNotIn.Join(",")}的浅库位库位状态异常,无法入库");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
WcsTask newTask = CoreMapper.Map<WcsTask>(wcsTask);
|
|
|
|
|
newTask.taskStatus = 0;//创建状态
|
|
|
|
|
newTask.updateTime = DateTime.Now;
|
|
|
|
|
newTask.currPointId = baseEquip.objid;
|
|
|
|
|
newTask.currPointNo = baseEquip.equipNo;
|
|
|
|
|
newTask.nextPointId = AgvEquip.objid;
|
|
|
|
|
newTask.nextPointNo = AgvEquip.equipNo;
|
|
|
|
|
newTask.endPointId = wmsBaseLocation.locationId;
|
|
|
|
|
newTask.endPointNo = wmsBaseLocation.locationCode;
|
|
|
|
|
newTask.objid = StaticData.SnowId.NextId();
|
|
|
|
|
newTask.createTime = DateTime.Now;
|
|
|
|
|
newTask.taskType = 47;
|
|
|
|
|
if (newTask.fromFloorNo != 1)//如果不是一楼来的,需要通过接口确认入库(质检通过后,点击继续入库)
|
|
|
|
|
{
|
|
|
|
|
newTask.useFlag = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
newTask.useFlag = 1;
|
|
|
|
|
}
|
|
|
|
|
wmsBaseLocation.locationStatus = "2";
|
|
|
|
|
dbContext.Update(wmsBaseLocation);
|
|
|
|
|
dbContext.Remove(wcsTask);
|
|
|
|
|
SystemData.LockOutLocation(wmsBaseLocation, dbContext);
|
|
|
|
|
|
|
|
|
|
dbContext.Add(newTask);
|
|
|
|
|
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(newTask);
|
|
|
|
|
dbContext.Add(wcsTaskLog);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
canNotIn.Clear();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(DateTime.Now + ":五楼接驳位调度入库任务,未找到库位");
|
|
|
|
|
_logger.Info("五楼接驳位调度入库任务,未找到库位");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (wcsTask.taskStatus == 6) //出库任务,小车任务是完成状态
|
|
|
|
|
{
|
|
|
|
|
|