|
|
|
|
@ -163,7 +163,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
using var transaction = dbContext.Database.BeginTransaction();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
var dmsBaseDeviceLedgers = dbContext.DmsBaseDeviceLedger.ToList();
|
|
|
|
|
var wcsAgvStatuses = dbContext.WcsAgvStatus.ToList();
|
|
|
|
|
var agvStatus = from a in dmsBaseDeviceLedgers
|
|
|
|
|
@ -285,7 +285,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
List<WcsTask> wcsTasks = dbContext.WcsTask.Where(t => t.IsDelete == 1).ToList();
|
|
|
|
|
foreach (var item in wcsTasks)
|
|
|
|
|
{
|
|
|
|
|
@ -294,7 +294,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
{
|
|
|
|
|
if (item.endPointId == 11)
|
|
|
|
|
{
|
|
|
|
|
dbContext.WcsTask.Remove(item);
|
|
|
|
|
dbContext.Remove(item);
|
|
|
|
|
if (item.taskStatus == 6)
|
|
|
|
|
{
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
@ -321,7 +321,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dbContext.WcsTask.Remove(item);
|
|
|
|
|
dbContext.Remove(item);
|
|
|
|
|
var cancelTask = new
|
|
|
|
|
{
|
|
|
|
|
reqCode = StaticData.SnowId.NextId().ToString(),
|
|
|
|
|
@ -339,10 +339,20 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
_logger.Error($"任务{item.taskCode}删除失败,原因:{result?.message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
WmsBaseLocation? wmsBaseLocation = dbContext.WmsBaseLocation.FirstOrDefault(t => t.locationCode == item.currPointNo);
|
|
|
|
|
WmsBaseLocation? toBaseLocation = dbContext.WmsBaseLocation.FirstOrDefault(t => t.locationCode == item.endPointNo);
|
|
|
|
|
if (wmsBaseLocation != null)
|
|
|
|
|
{
|
|
|
|
|
SystemData.UnLockOutLocation(wmsBaseLocation, dbContext);
|
|
|
|
|
}
|
|
|
|
|
if (toBaseLocation != null)
|
|
|
|
|
{
|
|
|
|
|
SystemData.UnLockOutLocation(toBaseLocation, dbContext);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dbContext.WcsTask.Remove(item);
|
|
|
|
|
dbContext.Remove(item);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
_logger.Info($"任务{item.objid}已删除");
|
|
|
|
|
}
|
|
|
|
|
@ -373,7 +383,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
if (errorCount > 3)
|
|
|
|
|
{
|
|
|
|
|
_logger.Error($"Plc220短线重连失败超过{errorCount}次");
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
SystemData.InsertWaringLog(dbContext, WaringType.设备Plc通讯异常, $"Plc220短线重连失败超过{errorCount}次");
|
|
|
|
|
//var dmsRecordAlarmTime = dbContext.DmsRecordAlarmTime.Where(t => t.CreateBy == "WCS" && t.DeviceId == 15).FirstOrDefault();
|
|
|
|
|
//if (dmsRecordAlarmTime == null)
|
|
|
|
|
@ -397,7 +407,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
StaticData.PlcDic[2].Read(HeartBeat30.plcpointAddress);
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
SystemData.DeleteWaringLog(dbContext, WaringType.设备Plc通讯异常);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@ -438,7 +448,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
if (errorCount > 3)
|
|
|
|
|
{
|
|
|
|
|
_logger.Error($"Plc30短线重连失败超过{errorCount}次");
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
SystemData.InsertWaringLog(dbContext, WaringType.提升机Plc通讯异常, $"Plc30短线重连失败超过{errorCount}次");
|
|
|
|
|
//var dmsRecordAlarmTime = dbContext.DmsRecordAlarmTime.Where(t => t.CreateBy == "WCS" && t.DeviceId == 13).FirstOrDefault();
|
|
|
|
|
//if (dmsRecordAlarmTime == null)
|
|
|
|
|
@ -464,7 +474,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
}
|
|
|
|
|
heartBeatCount = !heartBeatCount;
|
|
|
|
|
StaticData.PlcDic[0].WriteToPoint(HeartBeat30.plcpointAddress, heartBeatCount, HeartBeat30.plcpointLength?.ToString());
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
SystemData.DeleteWaringLog(dbContext, WaringType.提升机Plc通讯异常);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
@ -504,7 +514,8 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
if (errorCount > 3)
|
|
|
|
|
{
|
|
|
|
|
_logger.Error($"Plc31短线重连失败超过{errorCount}次");
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
|
|
|
|
|
SystemData.InsertWaringLog(dbContext, WaringType.U型线Plc通讯异常, $"Plc31短线重连失败超过{errorCount}次");
|
|
|
|
|
//var dmsRecordAlarmTime = dbContext.DmsRecordAlarmTime.Where(t => t.CreateBy == "WCS" && t.DeviceId == 14).FirstOrDefault();
|
|
|
|
|
//if (dmsRecordAlarmTime == null)
|
|
|
|
|
@ -529,7 +540,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
}
|
|
|
|
|
heartBeatCount = !heartBeatCount;
|
|
|
|
|
StaticData.PlcDic[1].WriteToPoint(HeartBeat31.plcpointAddress, heartBeatCount, HeartBeat31.plcpointLength?.ToString());
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
SystemData.DeleteWaringLog(dbContext, WaringType.U型线Plc通讯异常);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
@ -569,14 +580,14 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
List<BaseEquip> updateEquips = dbContext.BaseEquip.Where(t => t.remark == "99").ToList();
|
|
|
|
|
if (updateEquips.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var equip in updateEquips)
|
|
|
|
|
{
|
|
|
|
|
equip.remark = "0";
|
|
|
|
|
dbContext.BaseEquip.Update(equip);
|
|
|
|
|
dbContext.Update(equip);
|
|
|
|
|
dbContext.SaveChanges();
|
|
|
|
|
}
|
|
|
|
|
StaticData.BaseEquip = dbContext.BaseEquip.ToList();
|
|
|
|
|
@ -620,7 +631,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbContext.Database.BeginTransaction();
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
var dmsBaseAlarmRules = StaticData.DmsBaseAlarmRuleList.Where(t => t.DeviceId == -1).ToList();
|
|
|
|
|
var wcsAgvStatuses = dbContext.WcsAgvStatus.ToList();
|
|
|
|
|
var robotCodes = wcsAgvStatuses.Select(t => long.Parse(t.RobotCode)).ToList();
|
|
|
|
|
@ -634,7 +645,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
{
|
|
|
|
|
if (dmsRecordAlarmTime == null)
|
|
|
|
|
{
|
|
|
|
|
dmsRecordAlarmTime=new DmsRecordAlarmTime
|
|
|
|
|
dmsRecordAlarmTime = new DmsRecordAlarmTime
|
|
|
|
|
{
|
|
|
|
|
DeviceId = int.Parse(agvStatus.RobotCode),
|
|
|
|
|
AlarmBeginTime = DateTime.Now,
|
|
|
|
|
@ -845,7 +856,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
using var scope = host.Services.CreateScope();
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 9);
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
var basePlcs = StaticData.basePlcs.Where(t => t.Station == "3楼AGV").ToList();
|
|
|
|
|
var data = new
|
|
|
|
|
{
|
|
|
|
|
@ -908,7 +919,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
{
|
|
|
|
|
using var scope = host.Services.CreateScope();
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 8);
|
|
|
|
|
var basePlcs = StaticData.basePlcs.Where(t => t.Station == "2楼AGV").ToList();
|
|
|
|
|
var data = new
|
|
|
|
|
@ -980,7 +991,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
using var scope = host.Services.CreateScope();
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 28);
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
var basePlcs = StaticData.basePlcs.Where(t => t.Station == "5楼AGV").ToList();
|
|
|
|
|
var wcsCmds = dbContext.WcsTask.Where(t => t.nextPointId == 28).ToList();
|
|
|
|
|
if (wcsCmds.Count > 0)
|
|
|
|
|
@ -1018,7 +1029,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
var XPlc = basePlcs.First(t => t.Name.Contains('X'));
|
|
|
|
|
var Ylc = basePlcs.First(t => t.Name.Contains('Y'));
|
|
|
|
|
var status = basePlcs.First(t => t.Name.Contains("Status"));
|
|
|
|
|
if(cardStatus.Online.ToLower()== "true")
|
|
|
|
|
if (cardStatus.Online.ToLower() == "true")
|
|
|
|
|
{
|
|
|
|
|
StaticData.PlcDic[2].WriteToPoint(status.Address, cardStatus.Status, status.type);
|
|
|
|
|
}
|
|
|
|
|
@ -1083,7 +1094,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
{
|
|
|
|
|
using var scope = host.Services.CreateScope();
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
var basePlcs = StaticData.basePlcs.Where(t => t.Station == "5楼背负式").ToList();
|
|
|
|
|
var wcsCmds = dbContext.WcsTask.Where(t => t.nextPointId == 10).ToList();
|
|
|
|
|
if (wcsCmds.Count > 0)
|
|
|
|
|
@ -1123,7 +1134,7 @@ namespace Khd.Core.Wcs.Wcs
|
|
|
|
|
using var scope = host.Services.CreateScope();
|
|
|
|
|
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
|
|
|
|
|
var baseEquip = StaticData.BaseEquip.First(t => t.objid == 11);
|
|
|
|
|
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
|
|
|
|
|
dbContext.ChangeTracker.Clear();
|
|
|
|
|
var basePlcs = StaticData.basePlcs.Where(t => t.Station == "5楼CTU").ToList();
|
|
|
|
|
var wcsCmds = dbContext.WcsTask.Where(t => t.nextPointId == 11).ToList();
|
|
|
|
|
if (wcsCmds.Count > 0)
|
|
|
|
|
|