|
|
|
@ -8,6 +8,7 @@ using Masuit.Tools;
|
|
|
|
using Masuit.Tools.Logging;
|
|
|
|
using Masuit.Tools.Logging;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Z.EntityFramework.Plus;
|
|
|
|
using Z.EntityFramework.Plus;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Khd.Core.Wcs.Wcs
|
|
|
|
namespace Khd.Core.Wcs.Wcs
|
|
|
|
@ -47,7 +48,6 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
|
|
|
|
|
|
|
public void MonitorInLocatorPoint()
|
|
|
|
public void MonitorInLocatorPoint()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
List<string> BigContainerCodes = new() { "JYHB01020001", "JYHB01020002", "JYHB01020003", "JYHB01020004" };
|
|
|
|
|
|
|
|
List<int?> ITypes = new() { 1, 3, 5, 7 };
|
|
|
|
List<int?> ITypes = new() { 1, 3, 5, 7 };
|
|
|
|
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>();
|
|
|
|
@ -60,21 +60,45 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
//入库任务
|
|
|
|
//入库任务
|
|
|
|
var rfid = StaticData.PlcDic[0].ReadRFID(LineRFID.plcpointAddress);
|
|
|
|
var rfid = StaticData.PlcDic[0].ReadRFID(LineRFID.plcpointAddress);
|
|
|
|
var isSignal = StaticData.PlcDic[0].Read(LineSignal.plcpointAddress);
|
|
|
|
var isSignal = StaticData.PlcDic[0].Read(LineSignal.plcpointAddress);
|
|
|
|
|
|
|
|
BaseEquip baseEquip = StaticData.BaseEquip.First(t => t.equipType == 1 && t.floorNo == FloorNo);
|
|
|
|
if (rfid != null && isSignal != null)
|
|
|
|
if (rfid != null && isSignal != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (BigContainerCodes.Contains(rfid))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//正常读到输送线信息 有到位信号,并且有托盘,获取条码信息
|
|
|
|
//正常读到输送线信息 有到位信号,并且有托盘,获取条码信息
|
|
|
|
if (Convert.ToInt32(isSignal) == 1)//五楼接驳位
|
|
|
|
if (Convert.ToInt32(isSignal) == 1)//五楼接驳位
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//获取条码信息
|
|
|
|
//获取条码信息
|
|
|
|
BaseEquip baseEquip = StaticData.BaseEquip.First(t => t.equipType == 1 && t.floorNo == FloorNo);
|
|
|
|
|
|
|
|
var wcsTask = dbContext.WcsTask.OrderBy(t => t.createTime)
|
|
|
|
var wcsTask = dbContext.WcsTask.OrderBy(t => t.createTime)
|
|
|
|
.FirstOrDefault(t => t.containerNo == rfid && t.nextPointId == baseEquip.objid);
|
|
|
|
.FirstOrDefault(t => t.containerNo == rfid && t.nextPointId == baseEquip.objid);
|
|
|
|
if (wcsTask != null)
|
|
|
|
if (wcsTask != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (StaticData.BigContainerCodes.Contains(rfid))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == rfid);
|
|
|
|
|
|
|
|
if (mesBasePalletInfo != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.Where(t => t.palletInfoCode == rfid).FirstOrDefault();
|
|
|
|
|
|
|
|
if (mesBaseBarcodeInfo != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mesBaseBarcodeInfo.palletInfoCode = null;
|
|
|
|
|
|
|
|
dbContext.Update(mesBaseBarcodeInfo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
mesBasePalletInfo.bindAmount = null;
|
|
|
|
|
|
|
|
mesBasePalletInfo.bindAmount = null;
|
|
|
|
|
|
|
|
mesBasePalletInfo.materialBarcode = null;
|
|
|
|
|
|
|
|
mesBasePalletInfo.materialCode = null;
|
|
|
|
|
|
|
|
mesBasePalletInfo.materialId = null;
|
|
|
|
|
|
|
|
mesBasePalletInfo.materialName = null;
|
|
|
|
|
|
|
|
mesBasePalletInfo.updateBy = "WCS";
|
|
|
|
|
|
|
|
mesBasePalletInfo.updateTime = DateTime.Now;
|
|
|
|
|
|
|
|
dbContext.Update(mesBasePalletInfo);
|
|
|
|
|
|
|
|
dbContext.Remove(wcsTask);
|
|
|
|
|
|
|
|
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 6 });
|
|
|
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (wcsTask.taskStatus == 5)//入库,提升机任务是完成状态
|
|
|
|
if (wcsTask.taskStatus == 5)//入库,提升机任务是完成状态
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -103,7 +127,8 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料
|
|
|
|
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料
|
|
|
|
|
|
|
|
|
|
|
|
var bill = from a in mesBasePalletInfos
|
|
|
|
var bill = from a in mesBasePalletInfos
|
|
|
|
join b in wmsBaseLocations.Where(t => t.locDeep == 1 && wcsTask.fromFloorNo == 4 ? t.returnFlag == "1" : t.returnFlag == "0") on a.palletInfoCode equals b.containerCode
|
|
|
|
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 };//等于当前任务的物料的托盘的库位信息
|
|
|
|
select new { b };//等于当前任务的物料的托盘的库位信息
|
|
|
|
var outBill = from a in bill
|
|
|
|
var outBill = from a in bill
|
|
|
|
from b in wmsBaseLocations
|
|
|
|
from b in wmsBaseLocations
|
|
|
|
@ -113,7 +138,16 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
&& b.locationStatus == "1"
|
|
|
|
&& b.locationStatus == "1"
|
|
|
|
&& string.IsNullOrEmpty(b.containerCode)
|
|
|
|
&& string.IsNullOrEmpty(b.containerCode)
|
|
|
|
select new { a, b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
|
|
|
|
select new { a, b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
|
|
|
|
|
|
|
|
if(mesBaseBarcodeInfo.completeFlag == "0")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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? wmsBaseLocation = null;
|
|
|
|
wmsBaseLocation ??= outBill.Where(t => !canNotIn.Contains(t.b.locationCode)).FirstOrDefault()?.b;//先找相同物料的外侧库位
|
|
|
|
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(t => t.locDeep == 1);//找不到再找深库位
|
|
|
|
@ -202,6 +236,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ex is PlcException)
|
|
|
|
if (ex is PlcException)
|
|
|
|
|