|
|
|
|
@ -361,7 +361,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
WcsTask? wcsTask = dbContext.WcsTask.Where(t => t.nextPointId == 28).FirstOrDefault();
|
|
|
|
|
if (wcsTask == null)
|
|
|
|
|
{
|
|
|
|
|
WmsRawInstock? wmsRawInstock = dbContext.WmsRawInstock.Where(t => t.warehouseId == 511 && t.instockType == "2" && t.executeStatus == "0").FirstOrDefault();
|
|
|
|
|
WmsRawInstock? wmsRawInstock = dbContext.WmsRawInstock.Where(t => t.warehouseId == 511 && (t.instockType == "2" || t.instockType == "4") && t.executeStatus == "0").FirstOrDefault();
|
|
|
|
|
if (wmsRawInstock != null)
|
|
|
|
|
{
|
|
|
|
|
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == wmsRawInstock.palletInfoCode);
|
|
|
|
|
@ -939,139 +939,130 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
if (wcsTaskManual != null)
|
|
|
|
|
{
|
|
|
|
|
var wmsRawOutstock = dbContext.WmsRawOutstock.FirstOrDefault(t => t.rawOutstockId == wcsTaskManual.orderId);
|
|
|
|
|
if (wmsRawOutstock != null)
|
|
|
|
|
|
|
|
|
|
var wmsRawStocks = dbContext.WmsRawStock
|
|
|
|
|
.WhereIf(wmsRawOutstock != null, t => t.saleOrderId == (wmsRawOutstock.saleOrderId == null ? 0 : wmsRawOutstock.saleOrderId))
|
|
|
|
|
.WhereIf(wmsRawOutstock != null, t => t.materialId == wmsRawOutstock.materialId)
|
|
|
|
|
.Where(t => t.warehouseId == 311)
|
|
|
|
|
.Where(t => t.totalAmount > t.frozenAmount)
|
|
|
|
|
.ToList();
|
|
|
|
|
var wmsRawStockLocations = wmsRawStocks.Select(x => x.locationCode).ToList();
|
|
|
|
|
var AllWmsBaseLocations = dbContext.WmsBaseLocation
|
|
|
|
|
.Where(t => t.activeFlag == "1")
|
|
|
|
|
.Where(t => t.delFlag == "0")
|
|
|
|
|
.Where(t => t.locationScrapType == "1")
|
|
|
|
|
.Where(t => t.warehouseId == 311)
|
|
|
|
|
.Where(t => t.locationStatus == "1").ToList();
|
|
|
|
|
|
|
|
|
|
var wmsBaseLocations = AllWmsBaseLocations
|
|
|
|
|
.Where(t => t.warehouseId == 311)
|
|
|
|
|
.Where(t => wmsRawStockLocations.Contains(t.locationCode))
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(wcsTaskManual.startPointNo), t => t.locationCode == wcsTaskManual.startPointNo)
|
|
|
|
|
.ToList();
|
|
|
|
|
if (!string.IsNullOrEmpty(wcsTaskManual.startPointNo))
|
|
|
|
|
{
|
|
|
|
|
var wmsRawStocks = dbContext.WmsRawStock
|
|
|
|
|
.Where(t => t.saleOrderId == (wmsRawOutstock.saleOrderId == null ? 0 : wmsRawOutstock.saleOrderId))
|
|
|
|
|
.Where(t => t.warehouseId == 311)
|
|
|
|
|
.Where(t => t.materialId == wmsRawOutstock.materialId)
|
|
|
|
|
.Where(t => t.totalAmount > t.frozenAmount)
|
|
|
|
|
.ToList();
|
|
|
|
|
var wmsRawStockLocations = wmsRawStocks.Select(x => x.locationCode).ToList();
|
|
|
|
|
var AllWmsBaseLocations = dbContext.WmsBaseLocation
|
|
|
|
|
.Where(t => t.activeFlag == "1")
|
|
|
|
|
.Where(t => t.delFlag == "0")
|
|
|
|
|
.Where(t => t.locationScrapType == "1")
|
|
|
|
|
.Where(t => t.warehouseId == 311)
|
|
|
|
|
.Where(t => t.locationStatus == "1").ToList();
|
|
|
|
|
|
|
|
|
|
var wmsBaseLocations = AllWmsBaseLocations
|
|
|
|
|
.Where(t => t.warehouseId == 311)
|
|
|
|
|
.Where(t => wmsRawStockLocations.Contains(t.locationCode))
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(wcsTaskManual.startPointNo),t=>t.locationCode== wcsTaskManual.startPointNo)
|
|
|
|
|
.ToList();
|
|
|
|
|
if (!string.IsNullOrEmpty(wcsTaskManual.startPointNo))
|
|
|
|
|
var wmsRawPreferredOut = dbContext.WmsRawPreferredOut.Where(t => t.LocationCode == wcsTaskManual.startPointNo).FirstOrDefault();
|
|
|
|
|
if (wmsRawPreferredOut != null)
|
|
|
|
|
{
|
|
|
|
|
var wmsRawPreferredOut = dbContext.WmsRawPreferredOut.Where(t => t.LocationCode == wcsTaskManual.startPointNo).FirstOrDefault();
|
|
|
|
|
if (wmsRawPreferredOut != null)
|
|
|
|
|
{
|
|
|
|
|
dbContext.Remove(wmsRawPreferredOut);
|
|
|
|
|
}
|
|
|
|
|
dbContext.Remove(wmsRawPreferredOut);
|
|
|
|
|
}
|
|
|
|
|
var bill = from a in wmsBaseLocations
|
|
|
|
|
from b in wmsRawStocks
|
|
|
|
|
where a.locationCode == b.locationCode
|
|
|
|
|
select new { a, b };
|
|
|
|
|
WmsBaseLocation? wmsBaseLocation = null;
|
|
|
|
|
WmsRawStock? wmsRawStock = null;
|
|
|
|
|
var inLocations = AllWmsBaseLocations.Where(t => t.locDeep == 1).Where(t => !string.IsNullOrEmpty(t.containerCode)).ToList();
|
|
|
|
|
var outLocations = AllWmsBaseLocations.Where(t => t.locDeep == 2).Where(t => string.IsNullOrEmpty(t.containerCode)).ToList();
|
|
|
|
|
var list = new List<string>();
|
|
|
|
|
foreach (var item in inLocations)
|
|
|
|
|
}
|
|
|
|
|
var bill = from a in wmsBaseLocations
|
|
|
|
|
from b in wmsRawStocks
|
|
|
|
|
where a.locationCode == b.locationCode
|
|
|
|
|
select new { a, b };
|
|
|
|
|
WmsBaseLocation? wmsBaseLocation = null;
|
|
|
|
|
WmsRawStock? wmsRawStock = null;
|
|
|
|
|
var inLocations = AllWmsBaseLocations.Where(t => t.locDeep == 1).Where(t => !string.IsNullOrEmpty(t.containerCode)).ToList();
|
|
|
|
|
var outLocations = AllWmsBaseLocations.Where(t => t.locDeep == 2).Where(t => string.IsNullOrEmpty(t.containerCode)).ToList();
|
|
|
|
|
var list = new List<string>();
|
|
|
|
|
foreach (var item in inLocations)
|
|
|
|
|
{
|
|
|
|
|
if (outLocations.Where(t => t.locRow == (item.locRow % 2 == 0 ? item.locRow - 1 : item.locRow + 1))
|
|
|
|
|
.Where(t => t.locColumn == item.locColumn).Any())
|
|
|
|
|
{
|
|
|
|
|
if (outLocations.Where(t => t.locRow == (item.locRow % 2 == 0 ? item.locRow - 1 : item.locRow + 1))
|
|
|
|
|
.Where(t => t.locColumn == item.locColumn).Any())
|
|
|
|
|
{
|
|
|
|
|
list.Add(item.locationCode);
|
|
|
|
|
}
|
|
|
|
|
list.Add(item.locationCode);
|
|
|
|
|
}
|
|
|
|
|
bill = bill.OrderBy(t => list.Contains(t.a.locationCode) ? 0 : 1).OrderBy(t => t.b.instockDate.Value.Date);//按某个时间段
|
|
|
|
|
//#region 如果有需要优先投料的库位,则该库位优先投料
|
|
|
|
|
//List<string> PreferredOutsLocation = dbContext.WmsRawPreferredOut.Where(x => x.WarehouseId == 311).ToList().Select(x => x.LocationCode).ToList();
|
|
|
|
|
//if (PreferredOutsLocation != null && PreferredOutsLocation.Count > 0)
|
|
|
|
|
//{
|
|
|
|
|
// bill.OrderBy(t => PreferredOutsLocation.Contains(t.a.locationCode) ? 0 : 1);
|
|
|
|
|
//}
|
|
|
|
|
//#endregion
|
|
|
|
|
}
|
|
|
|
|
bill = bill.OrderBy(t => list.Contains(t.a.locationCode) ? 0 : 1).OrderBy(t => t.b.instockDate.Value.Date);//按某个时间段
|
|
|
|
|
//#region 如果有需要优先投料的库位,则该库位优先投料
|
|
|
|
|
//List<string> PreferredOutsLocation = dbContext.WmsRawPreferredOut.Where(x => x.WarehouseId == 311).ToList().Select(x => x.LocationCode).ToList();
|
|
|
|
|
//if (PreferredOutsLocation != null && PreferredOutsLocation.Count > 0)
|
|
|
|
|
//{
|
|
|
|
|
// bill.OrderBy(t => PreferredOutsLocation.Contains(t.a.locationCode) ? 0 : 1);
|
|
|
|
|
//}
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
foreach (var item in bill)
|
|
|
|
|
foreach (var item in bill)
|
|
|
|
|
{
|
|
|
|
|
// 目标库位
|
|
|
|
|
var fistbill = item;
|
|
|
|
|
|
|
|
|
|
int? locRow = 0;
|
|
|
|
|
if (fistbill.a.locRow % 2 == 1)
|
|
|
|
|
{
|
|
|
|
|
// 目标库位
|
|
|
|
|
var fistbill = item;
|
|
|
|
|
locRow = fistbill.a.locRow + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
locRow = fistbill.a.locRow - 1;
|
|
|
|
|
}
|
|
|
|
|
wmsBaseLocation = fistbill.a;
|
|
|
|
|
|
|
|
|
|
int? locRow = 0;
|
|
|
|
|
if (fistbill.a.locRow % 2 == 1)
|
|
|
|
|
// 目标库位处于深库位,判断是否需要移库浅库位
|
|
|
|
|
if (wmsBaseLocation.locDeep == 1)
|
|
|
|
|
{
|
|
|
|
|
int? row = 0;
|
|
|
|
|
if (wmsBaseLocation.locRow % 2 == 1)
|
|
|
|
|
{
|
|
|
|
|
locRow = fistbill.a.locRow + 1;
|
|
|
|
|
row = wmsBaseLocation.locRow + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
locRow = fistbill.a.locRow - 1;
|
|
|
|
|
row = wmsBaseLocation.locRow - 1;
|
|
|
|
|
}
|
|
|
|
|
wmsBaseLocation = fistbill.a;
|
|
|
|
|
|
|
|
|
|
// 目标库位处于深库位,判断是否需要移库浅库位
|
|
|
|
|
if (wmsBaseLocation.locDeep == 1)
|
|
|
|
|
var lowLocationBill = bill.Where(t => t.a.locRow == locRow).Where(t => t.a.locColumn == wmsBaseLocation.locColumn).Where(t => t.a.warehouseId == wmsBaseLocation.warehouseId).FirstOrDefault();
|
|
|
|
|
if (lowLocationBill != null)
|
|
|
|
|
{
|
|
|
|
|
int? row = 0;
|
|
|
|
|
if (wmsBaseLocation.locRow % 2 == 1)
|
|
|
|
|
//对应的浅库位满足条件,直接出浅库位
|
|
|
|
|
wmsBaseLocation = lowLocationBill.a;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//目标出库库位对应的浅库位
|
|
|
|
|
WmsBaseLocation? fromBaseLocation = dbContext.WmsBaseLocation.Where(t => t.locRow == row)
|
|
|
|
|
.Where(t => t.locColumn == wmsBaseLocation.locColumn)
|
|
|
|
|
.Where(t => t.warehouseId == wmsBaseLocation.warehouseId).FirstOrDefault();
|
|
|
|
|
if (fromBaseLocation != null && !string.IsNullOrEmpty(fromBaseLocation.containerCode) && fromBaseLocation.locationStatus == "1")
|
|
|
|
|
{
|
|
|
|
|
row = wmsBaseLocation.locRow + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
row = wmsBaseLocation.locRow - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var lowLocationBill = bill.Where(t => t.a.locRow == locRow).Where(t => t.a.locColumn == wmsBaseLocation.locColumn).Where(t => t.a.warehouseId == wmsBaseLocation.warehouseId).FirstOrDefault();
|
|
|
|
|
if (lowLocationBill != null)
|
|
|
|
|
{
|
|
|
|
|
//对应的浅库位满足条件,直接出浅库位
|
|
|
|
|
wmsBaseLocation = lowLocationBill.a;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//目标出库库位对应的浅库位
|
|
|
|
|
WmsBaseLocation? fromBaseLocation = dbContext.WmsBaseLocation.Where(t => t.locRow == row)
|
|
|
|
|
.Where(t => t.locColumn == wmsBaseLocation.locColumn)
|
|
|
|
|
.Where(t => t.warehouseId == wmsBaseLocation.warehouseId).FirstOrDefault();
|
|
|
|
|
if (fromBaseLocation != null && !string.IsNullOrEmpty(fromBaseLocation.containerCode) && fromBaseLocation.locationStatus == "1")
|
|
|
|
|
// 浅库位有库存
|
|
|
|
|
WmsRawStock? wmsRawStock1 = dbContext.WmsRawStock.FirstOrDefault(t => t.locationCode == fromBaseLocation.locationCode);
|
|
|
|
|
if (wmsRawStock1 != null)
|
|
|
|
|
{
|
|
|
|
|
// 浅库位有库存
|
|
|
|
|
WmsRawStock? wmsRawStock1 = dbContext.WmsRawStock.FirstOrDefault(t => t.locationCode == fromBaseLocation.locationCode);
|
|
|
|
|
if (wmsRawStock1 != null)
|
|
|
|
|
#region 找寻移库目标库位
|
|
|
|
|
// 寻找移库目的库位
|
|
|
|
|
WmsBaseLocation? toLocation = null;
|
|
|
|
|
|
|
|
|
|
var moveLocationList = AllWmsBaseLocations.Where(t => t.warehouseId == fromBaseLocation.warehouseId)
|
|
|
|
|
.Where(t => t.warehouseId != fromBaseLocation.locationId)
|
|
|
|
|
.Where(t => string.IsNullOrEmpty(t.containerCode)).OrderBy(t => t.locDeep).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (WmsBaseLocation itemLocation in moveLocationList)
|
|
|
|
|
{
|
|
|
|
|
#region 找寻移库目标库位
|
|
|
|
|
// 寻找移库目的库位
|
|
|
|
|
WmsBaseLocation? toLocation = null;
|
|
|
|
|
|
|
|
|
|
var moveLocationList = AllWmsBaseLocations.Where(t => t.warehouseId == fromBaseLocation.warehouseId)
|
|
|
|
|
.Where(t => t.warehouseId != fromBaseLocation.locationId)
|
|
|
|
|
.Where(t => string.IsNullOrEmpty(t.containerCode)).OrderBy(t => t.locDeep).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (WmsBaseLocation itemLocation in moveLocationList)
|
|
|
|
|
if (itemLocation.locDeep == 1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (itemLocation.locDeep == 1)
|
|
|
|
|
bool hasLocation = AllWmsBaseLocations
|
|
|
|
|
.Where(t => t.locRow == (itemLocation.locRow % 2 == 1 ? (itemLocation.locRow + 1) : (itemLocation.locRow - 1)))
|
|
|
|
|
.Where(t => t.locColumn == itemLocation.locColumn)
|
|
|
|
|
.Where(t => t.locationStatus == "1" && string.IsNullOrEmpty(t.containerCode))
|
|
|
|
|
.Any();
|
|
|
|
|
if (!hasLocation)
|
|
|
|
|
{
|
|
|
|
|
bool hasLocation = AllWmsBaseLocations
|
|
|
|
|
.Where(t => t.locRow == (itemLocation.locRow % 2 == 1 ? (itemLocation.locRow + 1) : (itemLocation.locRow - 1)))
|
|
|
|
|
.Where(t => t.locColumn == itemLocation.locColumn)
|
|
|
|
|
.Where(t => t.locationStatus == "1" && string.IsNullOrEmpty(t.containerCode))
|
|
|
|
|
.Any();
|
|
|
|
|
if (!hasLocation)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(DateTime.Now + $":目标库位{toLocation.locationCode}的浅库位库位状态异常,无法移库");
|
|
|
|
|
_logger.Info($"目标库位{toLocation.locationCode}的浅库位库位状态异常,无法移库");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 找到可以移库的目标库位
|
|
|
|
|
toLocation = itemLocation;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(DateTime.Now + $":目标库位{toLocation.locationCode}的浅库位库位状态异常,无法移库");
|
|
|
|
|
_logger.Info($"目标库位{toLocation.locationCode}的浅库位库位状态异常,无法移库");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@ -1081,124 +1072,134 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (toLocation == null)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 找寻下一个可出库库存
|
|
|
|
|
continue;
|
|
|
|
|
// 找到可以移库的目标库位
|
|
|
|
|
toLocation = itemLocation;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var RemoveTask = new WcsTask()
|
|
|
|
|
{
|
|
|
|
|
objid = StaticData.SnowId.NextId(),
|
|
|
|
|
taskType = StaticTaskType.ThirdRemove,
|
|
|
|
|
containerNo = wmsRawStock1.palletInfoCode,
|
|
|
|
|
createBy = "WCS",
|
|
|
|
|
createTime = DateTime.Now.AddSeconds(-10),
|
|
|
|
|
taskStatus = 0,
|
|
|
|
|
currPointId = fromBaseLocation.locationId,
|
|
|
|
|
currPointNo = fromBaseLocation.locationCode,
|
|
|
|
|
nextPointId = baseEquip.objid,
|
|
|
|
|
nextPointNo = baseEquip.equipNo,
|
|
|
|
|
endPointId = toLocation.locationId,
|
|
|
|
|
endPointNo = toLocation.locationCode,
|
|
|
|
|
equipmentNo = baseEquip.equipNo,
|
|
|
|
|
useFlag = 1,
|
|
|
|
|
qty = 1
|
|
|
|
|
};
|
|
|
|
|
SystemData.LockOutLocation(toLocation, dbContext);
|
|
|
|
|
SystemData.LockOutLocation(fromBaseLocation, dbContext);
|
|
|
|
|
toLocation.locationStatus = "4";
|
|
|
|
|
toLocation.updateBy = "WCS";
|
|
|
|
|
toLocation.updateTime = DateTime.Now;
|
|
|
|
|
fromBaseLocation.updateBy = "WCS";
|
|
|
|
|
fromBaseLocation.updateTime = DateTime.Now;
|
|
|
|
|
fromBaseLocation.locationStatus = "4";
|
|
|
|
|
dbContext.Update(toLocation);
|
|
|
|
|
dbContext.Update(fromBaseLocation);
|
|
|
|
|
dbContext.Add(RemoveTask);
|
|
|
|
|
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(RemoveTask);
|
|
|
|
|
dbContext.Add(wcsTaskLog);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (toLocation == null)
|
|
|
|
|
{
|
|
|
|
|
// 找寻下一个可出库库存
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (fromBaseLocation != null && fromBaseLocation.locationStatus != "1")
|
|
|
|
|
{
|
|
|
|
|
//浅库位状态异常,找寻下一个可出库库存
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wmsBaseLocation != null)
|
|
|
|
|
{
|
|
|
|
|
wmsRawStock = wmsRawStocks.Where(t => t.locationCode == wmsBaseLocation.locationCode).First();
|
|
|
|
|
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == wmsRawStock.palletInfoCode);
|
|
|
|
|
if (mesBasePalletInfo != null)
|
|
|
|
|
{
|
|
|
|
|
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
|
|
|
|
|
if (mesBaseBarcodeInfo != null)
|
|
|
|
|
{
|
|
|
|
|
WmsRawOutstockDetail wmsRawOutstockDetail = new WmsRawOutstockDetail()
|
|
|
|
|
{
|
|
|
|
|
rawOutstockDetailId = StaticData.SnowId.NextId(),
|
|
|
|
|
createBy = "WCS",
|
|
|
|
|
createDate = DateTime.Now,
|
|
|
|
|
executeStatus = "0",
|
|
|
|
|
erpAmount = 0,
|
|
|
|
|
erpStatus = "0",
|
|
|
|
|
instockBatch = mesBaseBarcodeInfo.batchCode,
|
|
|
|
|
stackAmount = 1,
|
|
|
|
|
locationCode = wmsBaseLocation.locationCode,
|
|
|
|
|
rawOutstockId = wmsRawOutstock.rawOutstockId,
|
|
|
|
|
planAmount = 1,
|
|
|
|
|
outstockWay = "2",
|
|
|
|
|
outstockPerson = "WCS",
|
|
|
|
|
outstockTime = DateTime.Now,
|
|
|
|
|
materialProductionDate = mesBaseBarcodeInfo.productionDate,
|
|
|
|
|
materialBarcode = mesBasePalletInfo.materialBarcode,
|
|
|
|
|
materialId = wmsRawOutstock.materialId,
|
|
|
|
|
machineName = mesBaseBarcodeInfo.machineName,
|
|
|
|
|
outstockAmount = 1,
|
|
|
|
|
taskCode = wmsRawOutstock.taskCode
|
|
|
|
|
};
|
|
|
|
|
wcsTask = new WcsTask()
|
|
|
|
|
var RemoveTask = new WcsTask()
|
|
|
|
|
{
|
|
|
|
|
objid = StaticData.SnowId.NextId(),
|
|
|
|
|
orderId = wmsRawOutstock.rawOutstockId,
|
|
|
|
|
taskType = StaticTaskType.ThirdRawToFlip,
|
|
|
|
|
containerNo = wmsRawStock.palletInfoCode,
|
|
|
|
|
taskType = StaticTaskType.ThirdRemove,
|
|
|
|
|
containerNo = wmsRawStock1.palletInfoCode,
|
|
|
|
|
createBy = "WCS",
|
|
|
|
|
createTime = DateTime.Now,
|
|
|
|
|
createTime = DateTime.Now.AddSeconds(-10),
|
|
|
|
|
taskStatus = 0,
|
|
|
|
|
materialId = wmsRawOutstock.materialId,
|
|
|
|
|
currPointId = wmsBaseLocation.locationId,
|
|
|
|
|
currPointNo = wmsBaseLocation.locationCode,
|
|
|
|
|
currPointId = fromBaseLocation.locationId,
|
|
|
|
|
currPointNo = fromBaseLocation.locationCode,
|
|
|
|
|
nextPointId = baseEquip.objid,
|
|
|
|
|
nextPointNo = baseEquip.equipNo,
|
|
|
|
|
endPointId = endEquip.objid,
|
|
|
|
|
endPointNo = endEquip.equipNo,
|
|
|
|
|
equipmentNo = endEquip.equipNo,
|
|
|
|
|
endPointId = toLocation.locationId,
|
|
|
|
|
endPointNo = toLocation.locationCode,
|
|
|
|
|
equipmentNo = baseEquip.equipNo,
|
|
|
|
|
useFlag = 1,
|
|
|
|
|
qty = 1
|
|
|
|
|
};
|
|
|
|
|
SystemData.LockOutLocation(wmsBaseLocation, dbContext);
|
|
|
|
|
wmsBaseLocation.locationStatus = "6";
|
|
|
|
|
dbContext.Update(wmsBaseLocation);
|
|
|
|
|
dbContext.Add(wmsRawOutstockDetail);
|
|
|
|
|
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
|
|
|
|
|
dbContext.Remove(wcsTaskManual);
|
|
|
|
|
dbContext.Add(wcsTask);
|
|
|
|
|
SystemData.LockOutLocation(toLocation, dbContext);
|
|
|
|
|
SystemData.LockOutLocation(fromBaseLocation, dbContext);
|
|
|
|
|
toLocation.locationStatus = "4";
|
|
|
|
|
toLocation.updateBy = "WCS";
|
|
|
|
|
toLocation.updateTime = DateTime.Now;
|
|
|
|
|
fromBaseLocation.updateBy = "WCS";
|
|
|
|
|
fromBaseLocation.updateTime = DateTime.Now;
|
|
|
|
|
fromBaseLocation.locationStatus = "4";
|
|
|
|
|
dbContext.Update(toLocation);
|
|
|
|
|
dbContext.Update(fromBaseLocation);
|
|
|
|
|
dbContext.Add(RemoveTask);
|
|
|
|
|
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(RemoveTask);
|
|
|
|
|
dbContext.Add(wcsTaskLog);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
break;
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (fromBaseLocation != null && fromBaseLocation.locationStatus != "1")
|
|
|
|
|
{
|
|
|
|
|
//浅库位状态异常,找寻下一个可出库库存
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wmsBaseLocation != null)
|
|
|
|
|
{
|
|
|
|
|
wmsRawStock = wmsRawStocks.Where(t => t.locationCode == wmsBaseLocation.locationCode).First();
|
|
|
|
|
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == wmsRawStock.palletInfoCode);
|
|
|
|
|
if (mesBasePalletInfo != null)
|
|
|
|
|
{
|
|
|
|
|
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
|
|
|
|
|
if (mesBaseBarcodeInfo != null)
|
|
|
|
|
{
|
|
|
|
|
//if (wmsRawOutstock != null)
|
|
|
|
|
//{
|
|
|
|
|
// WmsRawOutstockDetail wmsRawOutstockDetail = new WmsRawOutstockDetail()
|
|
|
|
|
// {
|
|
|
|
|
// rawOutstockDetailId = StaticData.SnowId.NextId(),
|
|
|
|
|
// createBy = "WCS",
|
|
|
|
|
// createDate = DateTime.Now,
|
|
|
|
|
// executeStatus = "0",
|
|
|
|
|
// erpAmount = 0,
|
|
|
|
|
// erpStatus = "0",
|
|
|
|
|
// instockBatch = mesBaseBarcodeInfo.batchCode,
|
|
|
|
|
// stackAmount = 1,
|
|
|
|
|
// locationCode = wmsBaseLocation.locationCode,
|
|
|
|
|
// rawOutstockId = wmsRawOutstock.rawOutstockId,
|
|
|
|
|
// planAmount = 1,
|
|
|
|
|
// outstockWay = "2",
|
|
|
|
|
// outstockPerson = "WCS",
|
|
|
|
|
// outstockTime = DateTime.Now,
|
|
|
|
|
// materialProductionDate = mesBaseBarcodeInfo.productionDate,
|
|
|
|
|
// materialBarcode = mesBasePalletInfo.materialBarcode,
|
|
|
|
|
// materialId = wmsRawOutstock.materialId,
|
|
|
|
|
// machineName = mesBaseBarcodeInfo.machineName,
|
|
|
|
|
// outstockAmount = 1,
|
|
|
|
|
// taskCode = wmsRawOutstock.taskCode
|
|
|
|
|
// };
|
|
|
|
|
// dbContext.Add(wmsRawOutstockDetail);
|
|
|
|
|
//}
|
|
|
|
|
wcsTask = new WcsTask()
|
|
|
|
|
{
|
|
|
|
|
objid = StaticData.SnowId.NextId(),
|
|
|
|
|
orderId = wmsRawOutstock?.rawOutstockId,
|
|
|
|
|
taskType = StaticTaskType.ThirdRawToFlip,
|
|
|
|
|
containerNo = wmsRawStock.palletInfoCode,
|
|
|
|
|
createBy = "WCS",
|
|
|
|
|
createTime = DateTime.Now,
|
|
|
|
|
taskStatus = 0,
|
|
|
|
|
materialId = mesBaseBarcodeInfo.materialId,
|
|
|
|
|
currPointId = wmsBaseLocation.locationId,
|
|
|
|
|
currPointNo = wmsBaseLocation.locationCode,
|
|
|
|
|
nextPointId = baseEquip.objid,
|
|
|
|
|
nextPointNo = baseEquip.equipNo,
|
|
|
|
|
endPointId = endEquip.objid,
|
|
|
|
|
endPointNo = endEquip.equipNo,
|
|
|
|
|
equipmentNo = endEquip.equipNo,
|
|
|
|
|
useFlag = 1,
|
|
|
|
|
qty = 1
|
|
|
|
|
};
|
|
|
|
|
SystemData.LockOutLocation(wmsBaseLocation, dbContext);
|
|
|
|
|
wmsBaseLocation.locationStatus = "6";
|
|
|
|
|
dbContext.Update(wmsBaseLocation);
|
|
|
|
|
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
|
|
|
|
|
dbContext.Remove(wcsTaskManual);
|
|
|
|
|
dbContext.Add(wcsTask);
|
|
|
|
|
dbContext.Add(wcsTaskLog);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1569,22 +1570,23 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
WmsProductOutstockDetail detail = new()
|
|
|
|
|
{
|
|
|
|
|
productId = item.productId,
|
|
|
|
|
productOutstockId = item.productOutstockId,
|
|
|
|
|
locationCode = location.locationCode,
|
|
|
|
|
executeStatus = "1",
|
|
|
|
|
beginTime = DateTime.Now,
|
|
|
|
|
warehouseId = item.warehouseId,
|
|
|
|
|
erpAmount = 0,
|
|
|
|
|
confirmAmount = 0,
|
|
|
|
|
outstockAmount = 1,
|
|
|
|
|
planAmount = 1,
|
|
|
|
|
productBatch = item.productBatch,
|
|
|
|
|
productOutstockDetailId = StaticData.SnowId.NextId(),
|
|
|
|
|
productBarcode = mesBasePalletInfo.materialBarcode
|
|
|
|
|
};
|
|
|
|
|
//WmsProductOutstockDetail detail = new()
|
|
|
|
|
//{
|
|
|
|
|
// productId = item.productId,
|
|
|
|
|
// productOutstockId = item.productOutstockId,
|
|
|
|
|
// locationCode = location.locationCode,
|
|
|
|
|
// executeStatus = "1",
|
|
|
|
|
// beginTime = DateTime.Now,
|
|
|
|
|
// warehouseId = item.warehouseId,
|
|
|
|
|
// erpAmount = 0,
|
|
|
|
|
// confirmAmount = 0,
|
|
|
|
|
// outstockAmount = 1,
|
|
|
|
|
// planAmount = 1,
|
|
|
|
|
// productBatch = item.productBatch,
|
|
|
|
|
// productOutstockDetailId = StaticData.SnowId.NextId(),
|
|
|
|
|
// productBarcode = mesBasePalletInfo.materialBarcode
|
|
|
|
|
//};
|
|
|
|
|
//dbContext.Add(detail);
|
|
|
|
|
wcsTask = new WcsTask()
|
|
|
|
|
{
|
|
|
|
|
objid = StaticData.SnowId.NextId(),
|
|
|
|
|
@ -1609,7 +1611,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
location.locationStatus = "6";
|
|
|
|
|
location.updateBy = "WCS";
|
|
|
|
|
location.updateTime = DateTime.Now;
|
|
|
|
|
dbContext.Add(detail);
|
|
|
|
|
dbContext.Update(location);
|
|
|
|
|
dbContext.Add(wcsTask);
|
|
|
|
|
dbContext.Update(stock);
|
|
|
|
|
@ -1867,27 +1868,27 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
useFlag = 1,
|
|
|
|
|
qty = 1
|
|
|
|
|
};
|
|
|
|
|
WmsProductOutstockDetail detail = new()
|
|
|
|
|
{
|
|
|
|
|
productId = item.productId,
|
|
|
|
|
productOutstockId = item.productOutstockId,
|
|
|
|
|
locationCode = location.locationCode,
|
|
|
|
|
executeStatus = "1",
|
|
|
|
|
beginTime = DateTime.Now,
|
|
|
|
|
warehouseId = item.warehouseId,
|
|
|
|
|
erpAmount = 0,
|
|
|
|
|
confirmAmount = 0,
|
|
|
|
|
outstockAmount = 1,
|
|
|
|
|
planAmount = 1,
|
|
|
|
|
productBatch = item.productBatch,
|
|
|
|
|
productOutstockDetailId = StaticData.SnowId.NextId(),
|
|
|
|
|
productBarcode = mesBasePalletInfo.materialBarcode,
|
|
|
|
|
};
|
|
|
|
|
//WmsProductOutstockDetail detail = new()
|
|
|
|
|
//{
|
|
|
|
|
// productId = item.productId,
|
|
|
|
|
// productOutstockId = item.productOutstockId,
|
|
|
|
|
// locationCode = location.locationCode,
|
|
|
|
|
// executeStatus = "1",
|
|
|
|
|
// beginTime = DateTime.Now,
|
|
|
|
|
// warehouseId = item.warehouseId,
|
|
|
|
|
// erpAmount = 0,
|
|
|
|
|
// confirmAmount = 0,
|
|
|
|
|
// outstockAmount = 1,
|
|
|
|
|
// planAmount = 1,
|
|
|
|
|
// productBatch = item.productBatch,
|
|
|
|
|
// productOutstockDetailId = StaticData.SnowId.NextId(),
|
|
|
|
|
// productBarcode = mesBasePalletInfo.materialBarcode,
|
|
|
|
|
//};
|
|
|
|
|
//dbContext.Add(detail);
|
|
|
|
|
SystemData.LockOutLocation(location, dbContext);
|
|
|
|
|
location.locationStatus = "6";
|
|
|
|
|
location.updateBy = "WCS";
|
|
|
|
|
location.updateTime = DateTime.Now;
|
|
|
|
|
dbContext.Add(detail);
|
|
|
|
|
dbContext.Update(location);
|
|
|
|
|
dbContext.Add(wcsTask);
|
|
|
|
|
dbContext.Update(stock);
|
|
|
|
|
@ -2553,33 +2554,33 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
qty = qty
|
|
|
|
|
};
|
|
|
|
|
//location是出库的库位,mesBaseBarcodeInfo是条码信息表数据,item是出库申请单
|
|
|
|
|
WmsRawOutstockDetail wmsProductOutstockDetail = new WmsRawOutstockDetail()
|
|
|
|
|
{
|
|
|
|
|
rawOutstockDetailId = StaticData.SnowId.NextId(),
|
|
|
|
|
rawOutstockId = item.rawOutstockId,
|
|
|
|
|
materialId = item.materialId,
|
|
|
|
|
createDate = DateTime.Now,
|
|
|
|
|
createBy = "WCS",
|
|
|
|
|
taskCode = wcsTask.objid.ToString(),
|
|
|
|
|
executeStatus = "1",
|
|
|
|
|
locationCode = location.locationCode,
|
|
|
|
|
outstockAmount = qty,
|
|
|
|
|
planAmount = item.outstockAmount,
|
|
|
|
|
warehouseId = item.warehouseId,
|
|
|
|
|
materialBarcode = mesBaseBarcodeInfo.barcodeInfo,
|
|
|
|
|
instockBatch = mesBaseBarcodeInfo.batchCode,
|
|
|
|
|
stackAmount = qty,
|
|
|
|
|
outstockPerson = "WCS",
|
|
|
|
|
outstockTime = DateTime.Now,
|
|
|
|
|
outstockWay = "2",
|
|
|
|
|
materialProductionDate = mesBaseBarcodeInfo.productionDate
|
|
|
|
|
};
|
|
|
|
|
//WmsRawOutstockDetail wmsProductOutstockDetail = new WmsRawOutstockDetail()
|
|
|
|
|
//{
|
|
|
|
|
// rawOutstockDetailId = StaticData.SnowId.NextId(),
|
|
|
|
|
// rawOutstockId = item.rawOutstockId,
|
|
|
|
|
// materialId = item.materialId,
|
|
|
|
|
// createDate = DateTime.Now,
|
|
|
|
|
// createBy = "WCS",
|
|
|
|
|
// taskCode = wcsTask.objid.ToString(),
|
|
|
|
|
// executeStatus = "1",
|
|
|
|
|
// locationCode = location.locationCode,
|
|
|
|
|
// outstockAmount = qty,
|
|
|
|
|
// planAmount = item.outstockAmount,
|
|
|
|
|
// warehouseId = item.warehouseId,
|
|
|
|
|
// materialBarcode = mesBaseBarcodeInfo.barcodeInfo,
|
|
|
|
|
// instockBatch = mesBaseBarcodeInfo.batchCode,
|
|
|
|
|
// stackAmount = qty,
|
|
|
|
|
// outstockPerson = "WCS",
|
|
|
|
|
// outstockTime = DateTime.Now,
|
|
|
|
|
// outstockWay = "2",
|
|
|
|
|
// materialProductionDate = mesBaseBarcodeInfo.productionDate
|
|
|
|
|
//};
|
|
|
|
|
//dbContext.Add(wmsProductOutstockDetail);
|
|
|
|
|
if (item.beginTime == null)
|
|
|
|
|
{
|
|
|
|
|
item.beginTime = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
SystemData.LockOutLocation(location, dbContext);
|
|
|
|
|
dbContext.Add(wmsProductOutstockDetail);
|
|
|
|
|
location.locationStatus = "6";
|
|
|
|
|
location.updateBy = "WCS";
|
|
|
|
|
location.updateTime = DateTime.Now;
|
|
|
|
|
|