master
2 years ago
parent dcf1a92240
commit e29b760cd2

@ -52,7 +52,7 @@ namespace Khd.Core.Wcs
try try
{ {
//plc.Open(); //plc.Open();
Console.WriteLine(DateTime.Now + ":连接PLC" + plcConfig.IP); Console.WriteLine(DateTime.Now + ":连接PLC" + plcConfig.IP);
} }
catch catch
{ {
@ -98,17 +98,17 @@ namespace Khd.Core.Wcs
//五层接驳位 //五层接驳位
var FifthBaseFloorEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 1).First(); var FifthBaseFloorEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 1).First();
FiveFloorPoint fifthFloorPoint = new(_host, FifthBaseFloorEquip.floorNo.Value); FiveFloorPoint fifthFloorPoint = new(_host, FifthBaseFloorEquip.floorNo.Value);
fifthFloorPoint.StartPoint(); fifthFloorPoint.StartPoint();
//五层CTU //五层CTU
var FiveFloorCTUEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 6).First(); var FiveFloorCTUEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 6).First();
FiveFloorCTU fiveFloorCTU = new(_host,FiveFloorCTUEquip.floorNo.Value); FiveFloorCTU fiveFloorCTU = new(_host, FiveFloorCTUEquip.floorNo.Value);
fiveFloorCTU.StartPoint(); fiveFloorCTU.StartPoint();
//五层AGV //五层AGV
var FifthFloorAgvEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 5).First(); var FifthFloorAgvEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 5).First();
FiveFloorAGV fifthFloorAGV = new(_host, FifthFloorAgvEquip.floorNo.Value); FiveFloorAGV fifthFloorAGV = new(_host, FifthFloorAgvEquip.floorNo.Value);
fifthFloorAGV.StartPoint(); fifthFloorAGV.StartPoint();
//背负式Agv //背负式Agv

@ -14,7 +14,7 @@ internal class Program
private static LoggerUtils _logger = new LoggerUtils(); private static LoggerUtils _logger = new LoggerUtils();
private static void Main(string[] args) private static void Main(string[] args)
{ {
Thread.CurrentThread.Name = "Main";
Console.ForegroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Yellow;
Init(); //初始化加载配置文件 Init(); //初始化加载配置文件
AppDomain.CurrentDomain.UnhandledException += GlobalExceptionHandler; //全局异常捕获 AppDomain.CurrentDomain.UnhandledException += GlobalExceptionHandler; //全局异常捕获
@ -62,12 +62,14 @@ internal class Program
} }
private static void GlobalExceptionHandler(object sender, UnhandledExceptionEventArgs e) private static void GlobalExceptionHandler(object sender, UnhandledExceptionEventArgs e)
{ {
//当前线程名称
Thread.CurrentThread.Name = "Error";
if (e.ExceptionObject is Exception exception) if (e.ExceptionObject is Exception exception)
{ {
Console.WriteLine("全局异常捕获:"); Console.WriteLine("全局异常捕获:");
Console.WriteLine(exception.Message); Console.WriteLine(exception.Message);
Console.WriteLine(exception.StackTrace); Console.WriteLine(exception.StackTrace);
_logger.Info("全局异常捕获:" + exception.Message); _logger.Info("全局异常捕获:" + exception.Message+"\n"+exception.StackTrace);
} }
else else
{ {

@ -19,7 +19,7 @@ namespace Khd.Core.Wcs.Wcs
/// </summary> /// </summary>
public class CreateTaskByRecord public class CreateTaskByRecord
{ {
private readonly LoggerUtils _logger=new LoggerUtils(); private readonly LoggerUtils _logger = new LoggerUtils();
private readonly IHost _host; private readonly IHost _host;
public CreateTaskByRecord(IHost host) public CreateTaskByRecord(IHost host)
{ {
@ -31,6 +31,11 @@ namespace Khd.Core.Wcs.Wcs
/// </summary> /// </summary>
public void StartPoint() public void StartPoint()
{ {
var createRemoveThread = new Thread(CreateRemoveLogic);
createRemoveThread.IsBackground = true;
createRemoveThread.Name = "CreateRemoveLogic";
createRemoveThread.Start();
//背负式Agv返库任务 //背负式Agv返库任务
var createBearAgvReturnThread = new Thread(CreateBearAgvReturnLogic); var createBearAgvReturnThread = new Thread(CreateBearAgvReturnLogic);
createBearAgvReturnThread.IsBackground = true; createBearAgvReturnThread.IsBackground = true;
@ -77,7 +82,7 @@ namespace Khd.Core.Wcs.Wcs
createThirdWasterTaskThread.Name = "CreateThirdWasterTaskLogic"; createThirdWasterTaskThread.Name = "CreateThirdWasterTaskLogic";
createThirdWasterTaskThread.Start(); createThirdWasterTaskThread.Start();
//背负式退库 //背负式退库
var BackReturnTaskThread= new Thread(BackReturnTaskLogic); var BackReturnTaskThread = new Thread(BackReturnTaskLogic);
BackReturnTaskThread.IsBackground = true; BackReturnTaskThread.IsBackground = true;
BackReturnTaskThread.Name = "BackReturnTaskLogic"; BackReturnTaskThread.Name = "BackReturnTaskLogic";
BackReturnTaskThread.Start(); BackReturnTaskThread.Start();
@ -85,6 +90,221 @@ namespace Khd.Core.Wcs.Wcs
_logger.Info("出库任务监听启动成功"); _logger.Info("出库任务监听启动成功");
} }
/// <summary>
/// 主动移库
/// </summary>
/// <param name="obj"></param>
private void CreateRemoveLogic(object? obj)
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService<DefaultDbContext>();
while (true)
{
try
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var CanRemoveWmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.locationStatus == "7").ToList();
List<string> locationCodes = CanRemoveWmsBaseLocations.Select(t => t.locationCode).ToList();
List<WmsProductStock> CanRemoveWmsProductStocks = dbContext.WmsProductStock.Where(t => locationCodes.Contains(t.locationCode)).ToList();
foreach (var wmsProductStock in CanRemoveWmsProductStocks)
{
BaseEquip? agvEquip = null;
if (wmsProductStock.warehouseId == 531)
{
agvEquip = StaticData.BaseEquip.First(t => t.objid == 28);
}
else if (wmsProductStock.warehouseId == 231)
{
agvEquip = StaticData.BaseEquip.First(t => t.objid == 8);
}
if (agvEquip != null)
{
bool hasTask = dbContext.WcsTask.Where(t => t.nextPointId == agvEquip.objid).Any();
if (!hasTask)
{
WmsBaseLocation fromLocationCode = CanRemoveWmsBaseLocations.First(t => t.locationCode == wmsProductStock.locationCode);
if (wmsProductStock.warehouseId == 531 || wmsProductStock.warehouseId == 231)//成品移库
{
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.locationStatus == "1")
.Where(t => t.warehouseId == wmsProductStock.warehouseId)
.ToList();//所有可用库位
var wmsProductStocks = dbContext.WmsProductStock
.Where(t => t.warehouseId == wmsProductStock.warehouseId)
.ToList();//仓库的库存
WmsBaseLocation? wmsBaseLocation = null;
if (wmsBaseLocations.Count > 0)
{
List<string> containerCodes = wmsBaseLocations
.Where(t => t.locDeep == 1)
.Select(t => t.containerCode).ToList();//深库位的有托盘
List<MesBaseBarcodeInfo> mesBasePalletInfos = dbContext.MesBaseBarcodeInfo
.Where(t => t.saleOrderId == (wmsProductStock.saleOrderId == null ? 0 : wmsProductStock.saleOrderId))//销售订单
.Where(t => t.materialId == wmsProductStock.productId)//物料Id
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料
var bill = from a in mesBasePalletInfos
join b in wmsBaseLocations.Where(t => t.locDeep == 1) on a.palletInfoCode equals b.containerCode
select new { b };//等于当前任务的物料的托盘的库位信息
var outBill = from a in bill//深库位托盘和当前任务绑定物料一致的托盘库位
from b in wmsBaseLocations//所有库位
where a.b.layerNum == b.layerNum//层数相同
&& b.locDeep == 2//浅库位
&& b.locRow == (a.b.locRow % 2 == 0 ? a.b.locRow - 1 : a.b.locRow + 1)
//如果是4则找3如果是1则找2
&& a.b.locColumn == b.locColumn//列数相同
&& string.IsNullOrEmpty(b.containerCode)
select new { a.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();//找不到再找任意库位
if (wmsBaseLocation != null)//如果找到库位,生成入库任务
{
var wcsTask = new WcsTask()
{
objid = StaticData.SnowId.NextId(),
currPointId = fromLocationCode.locationId,
currPointNo = fromLocationCode.locationCode,
nextPointId = agvEquip.objid,
nextPointNo = agvEquip.equipNo,
endPointId = wmsBaseLocation.locationId,
endPointNo = wmsBaseLocation.locationCode,
taskStatus = 0,
useFlag = 1,
containerNo = wmsProductStock.palletInfoCode,
createBy = "WCS",
createTime = DateTime.Now,
isEmpty = "0",
taskType = agvEquip.objid == 28 ? 66 : 55,
qty = 1,
};
dbContext.Add(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
Console.WriteLine(DateTime.Now + ":二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid);
_logger.Info("二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid);
}
else
{
//报警
}
}
}
}
}
}
List<WmsRawStock> wmsRawStocks = dbContext.WmsRawStock.Where(t => locationCodes.Contains(t.locationCode)).ToList();
foreach (var wmsRawStock in wmsRawStocks)
{
WmsBaseLocation fromLocationCode = CanRemoveWmsBaseLocations.First(t => t.locationCode == wmsRawStock.locationCode);
if (wmsRawStock.warehouseId == 511 || wmsRawStock.warehouseId == 311)
{
BaseEquip? agvEquip = null;
if (wmsRawStock.warehouseId == 511)
{
agvEquip = StaticData.BaseEquip.First(t => t.objid == 28);
}
else if (wmsRawStock.warehouseId == 311)
{
agvEquip = StaticData.BaseEquip.First(t => t.objid == 9);
}
if (agvEquip != null)
{
bool hasTask = dbContext.WcsTask.Where(t => t.nextPointId == agvEquip.objid).Any();
if (!hasTask)
{
var wmsBaseLocations = dbContext.WmsBaseLocation
.Where(t => t.activeFlag == "1")
.Where(t => t.delFlag == "0")
.Where(t => t.locationScrapType == "1")
.Where(t => t.locationStatus == "1")
.Where(t => t.warehouseId == wmsRawStock.warehouseId)
.ToList();//所有可用库位
var wmsProductStocks = dbContext.WmsRawStock
.Where(t => t.warehouseId == wmsRawStock.warehouseId)
.ToList();//仓库的库存
WmsBaseLocation? wmsBaseLocation = null;
if (wmsBaseLocations.Count > 0)
{
List<string> containerCodes = wmsBaseLocations
.Where(t => t.locDeep == 1)
.Select(t => t.containerCode).ToList();//深库位的有托盘
List<MesBaseBarcodeInfo> mesBasePalletInfos = dbContext.MesBaseBarcodeInfo
.Where(t => t.saleOrderId == (wmsRawStock.saleOrderId == null ? 0 : wmsRawStock.saleOrderId))//销售订单
.Where(t => t.materialId == wmsRawStock.materialId)//物料Id
.Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料
var bill = from a in mesBasePalletInfos
join b in wmsBaseLocations.Where(t => t.locDeep == 1) on a.palletInfoCode equals b.containerCode
select new { b };//等于当前任务的物料的托盘的库位信息
var outBill = from a in bill//深库位托盘和当前任务绑定物料一致的托盘库位
from b in wmsBaseLocations//所有库位
where a.b.layerNum == b.layerNum//层数相同
&& b.locDeep == 2//浅库位
&& b.locRow == (a.b.locRow % 2 == 0 ? a.b.locRow - 1 : a.b.locRow + 1)
//如果是4则找3如果是1则找2
&& a.b.locColumn == b.locColumn//列数相同
&& string.IsNullOrEmpty(b.containerCode)
select new { a.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();//找不到再找任意库位
if (wmsBaseLocation != null)//如果找到库位,生成入库任务
{
var wcsTask = new WcsTask()
{
objid = StaticData.SnowId.NextId(),
currPointId = fromLocationCode.locationId,
currPointNo = fromLocationCode.locationCode,
nextPointId = agvEquip.objid,
nextPointNo = agvEquip.equipNo,
endPointId = wmsBaseLocation.locationId,
endPointNo = wmsBaseLocation.locationCode,
taskStatus = 0,
useFlag = 1,
containerNo = wmsRawStock.palletInfoCode,
createBy = "WCS",
createTime = DateTime.Now,
isEmpty = "0",
taskType = agvEquip.objid == 28 ? 66 : 67,
qty = 1,
};
dbContext.Add(wcsTask);
WcsTaskLog wcsTaskLog = CoreMapper.Map<WcsTaskLog>(wcsTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
Console.WriteLine(DateTime.Now + ":二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid);
_logger.Info("二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid);
}
else
{
//报警
}
}
}
}
}
}
}
catch
{
}
}
}
/// <summary> /// <summary>
/// 五楼柜体拆分返库任务 /// 五楼柜体拆分返库任务
/// </summary> /// </summary>
@ -365,7 +585,7 @@ namespace Khd.Core.Wcs.Wcs
} }
} }
} }
catch(Exception ex) catch (Exception ex)
{ {
_logger.Error(ex.Message + "\n" + ex.StackTrace); _logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
@ -506,7 +726,7 @@ namespace Khd.Core.Wcs.Wcs
if (wmsRawOutstock != null) if (wmsRawOutstock != null)
{ {
var wmsRawStocks = dbContext.WmsRawStock var wmsRawStocks = dbContext.WmsRawStock
.Where(t => t.saleOrderId == wmsRawOutstock.saleOrderId) .Where(t => t.saleOrderId == (wmsRawOutstock.saleOrderId == null ? 0 : wmsRawOutstock.saleOrderId))
.Where(t => t.warehouseId == 311) .Where(t => t.warehouseId == 311)
.ToList(); .ToList();
var AllWmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 311).ToList(); var AllWmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 311).ToList();
@ -900,7 +1120,7 @@ namespace Khd.Core.Wcs.Wcs
{ {
objid = StaticData.SnowId.NextId(), objid = StaticData.SnowId.NextId(),
orderId = item.productOutstockId, orderId = item.productOutstockId,
taskType = 38, taskType = 66,
containerNo = wmsProductStock.palletInfoCode, containerNo = wmsProductStock.palletInfoCode,
createBy = "WCS", createBy = "WCS",
createTime = DateTime.Now.AddSeconds(-10), createTime = DateTime.Now.AddSeconds(-10),
@ -1042,7 +1262,7 @@ namespace Khd.Core.Wcs.Wcs
{ {
var wmsproStocks = proStock var wmsproStocks = proStock
.Where(t => t.productId == item.productId && t.saleOrderId == item.saleOrderId && t.warehouseId == item.warehouseId) .Where(t => t.productId == item.productId && t.saleOrderId == (item.saleOrderId == null ? 0 : item.saleOrderId) && t.warehouseId == item.warehouseId)
.Select(t => t.palletInfoCode) .Select(t => t.palletInfoCode)
.ToList(); .ToList();
List<WmsBaseLocation> AllWmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseId == item.warehouseId).ToList(); List<WmsBaseLocation> AllWmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseId == item.warehouseId).ToList();
@ -1453,7 +1673,7 @@ namespace Khd.Core.Wcs.Wcs
break; break;
} }
var wmsRawStocks = rawStock var wmsRawStocks = rawStock
.Where(t => t.materialId == order.MaterialId && t.saleOrderId == order.SaleOrderId && t.warehouseId == 512) .Where(t => t.materialId == order.MaterialId && t.saleOrderId == (order.SaleOrderId == null ? 0 : order.SaleOrderId) && t.warehouseId == 512)
.Select(t => t.palletInfoCode) .Select(t => t.palletInfoCode)
.ToList(); .ToList();
var AllWmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512).ToList(); var AllWmsBaseLocations = dbContext.WmsBaseLocation.Where(t => t.warehouseId == 512).ToList();
@ -1644,7 +1864,7 @@ namespace Khd.Core.Wcs.Wcs
} }
if (endEquip.equipType == 12 || endEquip.equipType == 13)//原材料到柜体验收区,背板安装 if (endEquip.equipType == 12 || endEquip.equipType == 13)//原材料到柜体验收区,背板安装
{ {
bool hasTask = dbContext.WcsTask.Where(t => t.nextPointId == 28 && t.useFlag == 1 && t.taskStatus <= 5).Any(); bool hasTask = dbContext.WcsTask.Where(t => t.currPointId == endEquip.objid || t.endPointId == endEquip.objid).Any();
if (!hasTask) if (!hasTask)
{ {
if (endEquip.emptyCount == 0) if (endEquip.emptyCount == 0)
@ -1653,7 +1873,7 @@ namespace Khd.Core.Wcs.Wcs
.Where(t => t.materialId == item.materialId && t.warehouseId == item.warehouseId) .Where(t => t.materialId == item.materialId && t.warehouseId == item.warehouseId)
.WhereIf(endEquip.equipType == 13, t => t.completeFlag == "0") .WhereIf(endEquip.equipType == 13, t => t.completeFlag == "0")
.WhereIf(endEquip.equipType == 12, t => t.completeFlag == "1") .WhereIf(endEquip.equipType == 12, t => t.completeFlag == "1")
.Where(t => t.saleOrderId == item.saleOrderId) .Where(t => t.saleOrderId == (item.saleOrderId == null ? 0 : item.saleOrderId))
.Where(t => t.totalAmount > t.frozenAmount) .Where(t => t.totalAmount > t.frozenAmount)
.Select(t => t.palletInfoCode) .Select(t => t.palletInfoCode)
.ToList(); .ToList();
@ -1664,6 +1884,7 @@ namespace Khd.Core.Wcs.Wcs
.Where(t => t.locationScrapType == "1") .Where(t => t.locationScrapType == "1")
.Where(t => t.locationStatus == "1") .Where(t => t.locationStatus == "1")
.Where(t => t.warehouseId == item.warehouseId) .Where(t => t.warehouseId == item.warehouseId)
.OrderByDescending(t => t.locDeep)
.Where(t => wmsRawStocks.Contains(t.containerCode)) .Where(t => wmsRawStocks.Contains(t.containerCode))
.ToList(); .ToList();
@ -1674,7 +1895,6 @@ namespace Khd.Core.Wcs.Wcs
where a.locationCode == b.locationCode where a.locationCode == b.locationCode
select new { a, b }; select new { a, b };
BaseEquip agvEquip = StaticData.BaseEquip.First(t => t.objid == 28); BaseEquip agvEquip = StaticData.BaseEquip.First(t => t.objid == 28);
BaseEquip lineEquip = StaticData.BaseEquip.First(t => t.equipNo == item.endStationCode); BaseEquip lineEquip = StaticData.BaseEquip.First(t => t.equipNo == item.endStationCode);
foreach (var b in bill) foreach (var b in bill)
@ -1686,13 +1906,11 @@ namespace Khd.Core.Wcs.Wcs
int qty = 0; int qty = 0;
if (stock.totalAmount - stock.frozenAmount <= needNumber)//该料箱全部出 if (stock.totalAmount - stock.frozenAmount <= needNumber)//该料箱全部出
{ {
item.realOutstockAmount += stock.totalAmount - stock.frozenAmount;
qty = Convert.ToInt32(stock.totalAmount - stock.frozenAmount); qty = Convert.ToInt32(stock.totalAmount - stock.frozenAmount);
stock.updateDate = DateTime.Now; stock.updateDate = DateTime.Now;
} }
else else
{ {
item.realOutstockAmount += needNumber;
qty = Convert.ToInt32(needNumber); qty = Convert.ToInt32(needNumber);
stock.updateDate = DateTime.Now; stock.updateDate = DateTime.Now;
} }
@ -1704,11 +1922,11 @@ namespace Khd.Core.Wcs.Wcs
int? row = 0; int? row = 0;
if (location.locRow % 2 == 1)//五楼原材料与其他的深浅库位相反 if (location.locRow % 2 == 1)//五楼原材料与其他的深浅库位相反
{ {
row = location.locRow - 1; row = location.locRow + 1;
} }
else else
{ {
row = location.locRow + 1; row = location.locRow - 1;//5
} }
var lowLocationBill = bill.Where(t => t.a.locRow == row).Where(t => t.a.locColumn == location.locColumn).Where(t => t.a.warehouseId == location.warehouseId).FirstOrDefault(); var lowLocationBill = bill.Where(t => t.a.locRow == row).Where(t => t.a.locColumn == location.locColumn).Where(t => t.a.warehouseId == location.warehouseId).FirstOrDefault();
if (lowLocationBill != null) if (lowLocationBill != null)
@ -1718,9 +1936,10 @@ namespace Khd.Core.Wcs.Wcs
} }
else else
{ {
WmsBaseLocation? wmsBaseLocation = AllWmsBaseLocations.Where(t => t.locRow == row) WmsBaseLocation? wmsBaseLocation = AllWmsBaseLocations
.Where(t => t.locColumn == location.locColumn) .Where(t => t.locRow == row)
.Where(t => t.warehouseId == location.warehouseId).FirstOrDefault(); .Where(t => t.locColumn == location.locColumn)
.Where(t => t.warehouseId == location.warehouseId).FirstOrDefault();
if (wmsBaseLocation != null && !string.IsNullOrEmpty(wmsBaseLocation.containerCode)) if (wmsBaseLocation != null && !string.IsNullOrEmpty(wmsBaseLocation.containerCode))
{ {
WmsRawStock? wmsRawStock = dbContext.WmsRawStock.FirstOrDefault(t => t.locationCode == wmsBaseLocation.locationCode); WmsRawStock? wmsRawStock = dbContext.WmsRawStock.FirstOrDefault(t => t.locationCode == wmsBaseLocation.locationCode);
@ -1739,7 +1958,7 @@ namespace Khd.Core.Wcs.Wcs
{ {
objid = StaticData.SnowId.NextId(), objid = StaticData.SnowId.NextId(),
orderId = item.rawOutstockId, orderId = item.rawOutstockId,
taskType = 38, taskType = 66,
containerNo = wmsRawStock.palletInfoCode, containerNo = wmsRawStock.palletInfoCode,
createBy = "WCS", createBy = "WCS",
createTime = DateTime.Now.AddSeconds(-10), createTime = DateTime.Now.AddSeconds(-10),

@ -174,23 +174,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
} }
@ -247,23 +236,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
Thread.Sleep(1000); Thread.Sleep(1000);
} }
@ -479,16 +457,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
foreach (var item in StaticData.PlcDic)
{ }
if (item.Value.IP == ex.Message) else
{ {
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot); _logger.Error(ex.Message + "\n" + ex.StackTrace);
StaticData.PlcDic[item.Key].Open();
}
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
Thread.Sleep(1000); Thread.Sleep(1000);
} }
@ -723,23 +697,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
Thread.Sleep(5000); Thread.Sleep(5000);
} }

@ -515,6 +515,7 @@ namespace Khd.Core.Wcs.Wcs
WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.Where(t => t.rawOutstockId == wmsRawOutstock.rawOutstockId && t.executeStatus == "1").FirstOrDefault(); WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.Where(t => t.rawOutstockId == wmsRawOutstock.rawOutstockId && t.executeStatus == "1").FirstOrDefault();
if (wmsRawOutstockDetail != null) if (wmsRawOutstockDetail != null)
{ {
wmsRawOutstock.realOutstockAmount += 1;
wmsRawOutstockDetail.executeStatus = "2"; wmsRawOutstockDetail.executeStatus = "2";
wmsRawOutstock.executeStatus = "2"; wmsRawOutstock.executeStatus = "2";
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId); WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
@ -595,6 +596,7 @@ namespace Khd.Core.Wcs.Wcs
WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.Where(t => t.rawOutstockId == item.orderId).FirstOrDefault(); WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.Where(t => t.rawOutstockId == item.orderId).FirstOrDefault();
if (wmsRawOutStock != null && wmsRawOutstockDetail != null) if (wmsRawOutStock != null && wmsRawOutstockDetail != null)
{ {
wmsRawOutStock.realOutstockAmount += 1;
wmsRawOutstockDetail.executeStatus = "2"; wmsRawOutstockDetail.executeStatus = "2";
wmsRawOutStock.executeStatus = "2"; wmsRawOutStock.executeStatus = "2";
dbContext.Update(wmsRawOutStock); dbContext.Update(wmsRawOutStock);
@ -756,23 +758,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
finally finally
{ {

@ -78,15 +78,7 @@ namespace Khd.Core.Wcs.Wcs
} }
catch catch
{ {
try
{
StaticData.PlcDic[1] = new Plc.S7.Plc(StaticData.PlcDic[1].CPU, StaticData.PlcDic[1].IP, StaticData.PlcDic[1].Port, StaticData.PlcDic[1].Rack, StaticData.PlcDic[1].Slot);
StaticData.PlcDic[1].Open();
}
catch
{
}
} }
Thread.Sleep(1000); Thread.Sleep(1000);
} }
@ -271,23 +263,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
Thread.Sleep(1000); Thread.Sleep(1000);
} }
@ -658,23 +639,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
finally finally
{ {

@ -190,23 +190,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
finally finally
{ {

@ -119,23 +119,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
finally finally
{ {

@ -442,7 +442,7 @@ namespace Khd.Core.Wcs.Wcs
{ {
BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == item.currPointId); BaseEquip startEquip = StaticData.BaseEquip.First(t => t.objid == item.currPointId);
BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == item.endPointId); BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == item.endPointId);
var agvTask = new RequestAGVTaskDto var agvTask = new RequestAGVTaskDto
{ {
reqCode = StaticData.SnowId.NextId().ToString(), reqCode = StaticData.SnowId.NextId().ToString(),
@ -484,9 +484,9 @@ namespace Khd.Core.Wcs.Wcs
else else
{ {
{ {
_logger.Info("二楼AGV线程完成任务" + item.objid);
if (item.taskStatus == 3) if (item.taskStatus == 3)
{ {
_logger.Info("二楼AGV线程继续任务" + item.objid);
if (item.currPointId == lineEquip.objid) if (item.currPointId == lineEquip.objid)
{ {
var lineSignal02 = StaticData.PlcDic[0].Read(StaticData.BasePlcpointList.First(t => t.plcpointNo == "linesignal02").plcpointAddress); var lineSignal02 = StaticData.PlcDic[0].Read(StaticData.BasePlcpointList.First(t => t.plcpointNo == "linesignal02").plcpointAddress);
@ -645,6 +645,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Remove(item); dbContext.Remove(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
dbContext.SaveChanges(); dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
} }
// } // }
//} //}
@ -678,7 +679,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Update(item); dbContext.Update(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
dbContext.SaveChanges(); dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
} }
} }
} }
@ -691,6 +692,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Remove(item); dbContext.Remove(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
dbContext.SaveChanges(); dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
} }
else if (item.taskType == 53)//提升机到废料口 else if (item.taskType == 53)//提升机到废料口
{ {
@ -705,6 +707,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Remove(item); dbContext.Remove(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
dbContext.SaveChanges(); dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
} }
else if (item.taskType == 51)//输送线到小包入口 else if (item.taskType == 51)//输送线到小包入口
{ {
@ -714,6 +717,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Remove(item); dbContext.Remove(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
dbContext.SaveChanges(); dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
} }
else if (item.taskType == 54)//周转位到废料口 else if (item.taskType == 54)//周转位到废料口
{ {
@ -730,6 +734,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Remove(item); dbContext.Remove(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
dbContext.SaveChanges(); dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
} }
else if (item.taskType == 55)//移库 else if (item.taskType == 55)//移库
{ {
@ -758,6 +763,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
transaction.Commit(); transaction.Commit();
dbContext.SaveChanges(); dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -777,6 +783,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Update(wasteEquip); dbContext.Update(wasteEquip);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
dbContext.SaveChanges(); dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
} }
else if (item.taskType == 57)//周转位-提升机 else if (item.taskType == 57)//周转位-提升机
{ {
@ -790,6 +797,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Update(emptyEquip); dbContext.Update(emptyEquip);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 6 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 6 });
dbContext.SaveChanges(); dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
} }
else if (item.taskType == 59)//周转区-小包入口 else if (item.taskType == 59)//周转区-小包入口
{ {
@ -801,6 +809,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Remove(item); dbContext.Remove(item);
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 }); dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 8 });
dbContext.SaveChanges(); dbContext.SaveChanges();
_logger.Info("二楼AGV线程完成任务" + item.objid);
} }
} }
} }
@ -812,23 +821,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
finally finally
{ {

@ -316,23 +316,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
finally finally
{ {

@ -306,23 +306,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
finally finally
{ {

@ -36,7 +36,7 @@ namespace Khd.Core.Wcs.Wcs
var PlcHeartBeat30Thread = new Thread(PlcHeartBeat30Logic) var PlcHeartBeat30Thread = new Thread(PlcHeartBeat30Logic)
{ {
Name="PlcHeartBeat30Thread", Name = "PlcHeartBeat30Thread",
IsBackground = true IsBackground = true
}; };
PlcHeartBeat30Thread.Start();//脉冲 PlcHeartBeat30Thread.Start();//脉冲
@ -48,9 +48,40 @@ namespace Khd.Core.Wcs.Wcs
}; };
PlcHeartBeat31Thread.Start();//脉冲 PlcHeartBeat31Thread.Start();//脉冲
var PlcHearBeat220Thread = new Thread(PlcHearBeat220Logic) {
Name = "PlcHeartBeat220Thread",
IsBackground = true
};
PlcHearBeat220Thread.Start();
Console.WriteLine($"{DateTime.Now}: SystemTimer started"); Console.WriteLine($"{DateTime.Now}: SystemTimer started");
} }
private void PlcHearBeat220Logic(object? obj)
{
BasePlcpoint HeartBeat30 = StaticData.BasePlcpointList.First(t => t.plcpointNo == "putTray");
while (true)
{
try
{
StaticData.PlcDic[0].Read(HeartBeat30.plcpointAddress);
}
catch
{
try
{
StaticData.PlcDic[2] = new Plc.S7.Plc(StaticData.PlcDic[2].CPU, StaticData.PlcDic[2].IP, StaticData.PlcDic[2].Port, StaticData.PlcDic[2].Rack, StaticData.PlcDic[2].Slot);
StaticData.PlcDic[2].Open();
}
catch (Exception ex2)
{
_logger.Error("Plc短线重连失败" + ex2.Message);
}
}
Thread.Sleep(1000);
}
}
/// <summary> /// <summary>
/// 定时发送心跳包 /// 定时发送心跳包
/// </summary> /// </summary>
@ -66,25 +97,16 @@ namespace Khd.Core.Wcs.Wcs
heartBeatCount = !heartBeatCount; heartBeatCount = !heartBeatCount;
StaticData.PlcDic[0].WriteToPoint(HeartBeat30.plcpointAddress, heartBeatCount, HeartBeat30.plcpointLength?.ToString()); StaticData.PlcDic[0].WriteToPoint(HeartBeat30.plcpointAddress, heartBeatCount, HeartBeat30.plcpointLength?.ToString());
} }
catch (Exception ex) catch
{ {
if (ex is PlcException) try
{ {
try StaticData.PlcDic[0] = new Plc.S7.Plc(StaticData.PlcDic[0].CPU, StaticData.PlcDic[0].IP, StaticData.PlcDic[0].Port, StaticData.PlcDic[0].Rack, StaticData.PlcDic[0].Slot);
{ StaticData.PlcDic[0].Open();
foreach (var item in StaticData.PlcDic) }
{ catch (Exception ex2)
if (item.Value.IP == ex.Message) {
{ _logger.Error("Plc短线重连失败" + ex2.Message);
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
//报警
}
} }
} }
Thread.Sleep(1000); Thread.Sleep(1000);
@ -98,7 +120,7 @@ namespace Khd.Core.Wcs.Wcs
private void PlcHeartBeat31Logic(object? obj) private void PlcHeartBeat31Logic(object? obj)
{ {
BasePlcpoint HeartBeat31 = StaticData.BasePlcpointList.First(t => t.plcpointNo == "CTUHeart"); BasePlcpoint HeartBeat31 = StaticData.BasePlcpointList.First(t => t.plcpointNo == "CTUHeart");
bool heartBeatCount =false; bool heartBeatCount = false;
while (true) while (true)
{ {
try try
@ -112,20 +134,18 @@ namespace Khd.Core.Wcs.Wcs
{ {
try try
{ {
foreach (var item in StaticData.PlcDic) StaticData.PlcDic[1] = new Plc.S7.Plc(StaticData.PlcDic[1].CPU, StaticData.PlcDic[1].IP, StaticData.PlcDic[1].Port, StaticData.PlcDic[1].Rack, StaticData.PlcDic[1].Slot);
{ StaticData.PlcDic[1].Open();
if (item.Value.IP == ex.Message)
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
} }
catch catch (Exception ex2)
{ {
_logger.Error("Plc短线重连失败" + ex2.Message);
} }
} }
else
{
_logger.Error(ex.Message + "\n" + ex.StackTrace);
}
} }
Thread.Sleep(1000); Thread.Sleep(1000);
} }
@ -187,24 +207,14 @@ namespace Khd.Core.Wcs.Wcs
} }
catch (Exception ex) catch (Exception ex)
{ {
try if (ex is PlcException)
{
if (ex is PlcException)
{
foreach (var item in StaticData.PlcDic)
{
if (item.Value.IP == ex.Message)
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
}
catch
{ {
} }
else
{
_logger.Error(ex.Message + "\n" + ex.StackTrace);
}
} }
Thread.Sleep(1000); Thread.Sleep(1000);
} }

@ -98,23 +98,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
Thread.Sleep(3000); Thread.Sleep(3000);
} }
@ -766,23 +755,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
finally finally
{ {

@ -164,23 +164,12 @@ namespace Khd.Core.Wcs.Wcs
{ {
if (ex is PlcException) if (ex is PlcException)
{ {
try
{ }
foreach (var item in StaticData.PlcDic) else
{ {
if (item.Value.IP == ex.Message) _logger.Error(ex.Message + "\n" + ex.StackTrace);
{
StaticData.PlcDic[item.Key] = new Plc.S7.Plc(item.Value.CPU, item.Value.IP, item.Value.Port, item.Value.Rack, item.Value.Slot);
StaticData.PlcDic[item.Key].Open();
}
}
}
catch
{
}
} }
_logger.Error(ex.Message + "\n" + ex.StackTrace);
} }
finally finally
{ {

@ -22,19 +22,19 @@ namespace Khd.Core.Wpf
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;//Task异常 TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;//Task异常
IConfigurationRoot configuration = new ConfigurationBuilder() IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
.AddJsonFile("appsettings.json") .AddJsonFile("appsettings.json")
.Build(); .Build();
SystemData.PlcConfigs = configuration.GetSection("PlcConfigs").Get<List<PlcConfig>>(); SystemData.PlcConfigs = configuration.GetSection("PlcConfigs").Get<List<PlcConfig>>();
ConnectionStrings.ConnectionString = configuration["ConnectionStrings:DefaultConnection"].ToString(); ConnectionStrings.ConnectionString = configuration["ConnectionStrings:DefaultConnection"].ToString();
//配置文件 加载 Thrift 推送端口 ////配置文件 加载 Thrift 推送端口
ThriftConfig.ThriftIpAddress = configuration["ThriftConfig:ThriftIpAddress"].ToString(); //ThriftConfig.ThriftIpAddress = configuration["ThriftConfig:ThriftIpAddress"].ToString();
ThriftConfig.JiesShouDuanKou = int.Parse(configuration["ThriftConfig:JiesShouDuanKou"]); //ThriftConfig.JiesShouDuanKou = int.Parse(configuration["ThriftConfig:JiesShouDuanKou"]);
ThriftConfig.TuiSongDuankou = int.Parse(configuration["ThriftConfig:TuiSongDuankou"]); //ThriftConfig.TuiSongDuankou = int.Parse(configuration["ThriftConfig:TuiSongDuankou"]);
ThriftConfig.UpSite = configuration["ThriftConfig:upsite"].ToString(); //ThriftConfig.UpSite = configuration["ThriftConfig:upsite"].ToString();
FlagConfig.UpFlagNum = int.Parse(configuration["FlagConfig:UpFlagNum"]); //FlagConfig.UpFlagNum = int.Parse(configuration["FlagConfig:UpFlagNum"]);
} }
void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{ {

@ -1746,7 +1746,7 @@
<hc:Pagination x:Name="Pagination2" Grid.Row="2" MaxWidth="1500" MaxPageCount="1" Margin="0,0,0,15" PageUpdated="Pagination2_PageUpdated" IsJumpEnabled="True" HorizontalAlignment="Center" Width="339" /> <hc:Pagination x:Name="Pagination2" Grid.Row="2" MaxWidth="1500" MaxPageCount="1" Margin="0,0,0,15" PageUpdated="Pagination2_PageUpdated" IsJumpEnabled="True" HorizontalAlignment="Center" Width="339" />
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Visibility="Collapsed" x:Name="InventoryManager" Header="盘库任务" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5"> <TabItem x:Name="InventoryManager" Header="盘库任务" Style="{StaticResource DefaultItem}" FontSize="25" HorizontalContentAlignment="Center" Background="#213269" VerticalContentAlignment="Center" Foreground="White" Width="160" Height="100" Margin="5">
<Grid Height="1100" Width="1700"> <Grid Height="1100" Width="1700">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>

@ -189,7 +189,7 @@ namespace Khd.Core.Wpf.Form
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("条码枪连接失败" + ex.Message); MessageBox.Show("条码枪连接失败");
} }
@ -2894,10 +2894,10 @@ namespace Khd.Core.Wpf.Form
inventoryTaskForm.ShowDialog(); inventoryTaskForm.ShowDialog();
} }
//选择出库
private void SelectOutBtn_Click(object sender, RoutedEventArgs e) private void SelectOutBtn_Click(object sender, RoutedEventArgs e)
{ {
SelectOutRawForm selectOutRawForm=new SelectOutRawForm(this._host); SelectOutRawForm selectOutRawForm = new SelectOutRawForm(this._host);
selectOutRawForm.ShowDialog(); selectOutRawForm.ShowDialog();
} }
} }

Loading…
Cancel
Save