From dcf1a9224018a0c981552ea8924cfff7de73d3f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8C=83?= <15095123350@163.com>
Date: Tue, 23 Jul 2024 10:05:54 +0800
Subject: [PATCH] 20240723
---
src/Khd.Core.Domain/Models/WcsTaskLog.cs | 2 +
src/Khd.Core.Library/Khd.Core.Library.csproj | 1 +
src/Khd.Core.Library/LoggerUtils.cs | 61 +++
src/Khd.Core.Wcs/Khd.Core.Wcs.csproj | 3 +
src/Khd.Core.Wcs/MainCentralControl.cs | 27 +-
src/Khd.Core.Wcs/NLog.config | 21 +
src/Khd.Core.Wcs/Program.cs | 14 +-
src/Khd.Core.Wcs/SystemData.cs | 1 +
src/Khd.Core.Wcs/Wcs/BackUpData.cs | 6 +-
src/Khd.Core.Wcs/Wcs/CreateTaskByRecord.cs | 413 ++++++++++---------
src/Khd.Core.Wcs/Wcs/FirstFloor.cs | 51 +--
src/Khd.Core.Wcs/Wcs/FiveFloorAGV.cs | 52 +--
src/Khd.Core.Wcs/Wcs/FiveFloorBearAgv.cs | 21 +-
src/Khd.Core.Wcs/Wcs/FiveFloorCTU.cs | 50 +--
src/Khd.Core.Wcs/Wcs/FiveFloorPoint.cs | 168 ++++----
src/Khd.Core.Wcs/Wcs/FourthFloorPoint.cs | 8 +-
src/Khd.Core.Wcs/Wcs/SecondFloorAGV.cs | 55 +--
src/Khd.Core.Wcs/Wcs/SecondFloorLine.cs | 22 +-
src/Khd.Core.Wcs/Wcs/SecondFloorPoint.cs | 26 +-
src/Khd.Core.Wcs/Wcs/SystemTimer.cs | 33 +-
src/Khd.Core.Wcs/Wcs/ThirdFloorAGV.cs | 135 +++---
src/Khd.Core.Wcs/Wcs/ThirdFloorPoint.cs | 135 +++---
src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs | 3 +
23 files changed, 731 insertions(+), 577 deletions(-)
create mode 100644 src/Khd.Core.Library/LoggerUtils.cs
create mode 100644 src/Khd.Core.Wcs/NLog.config
diff --git a/src/Khd.Core.Domain/Models/WcsTaskLog.cs b/src/Khd.Core.Domain/Models/WcsTaskLog.cs
index 5ee9f1b..74658c9 100644
--- a/src/Khd.Core.Domain/Models/WcsTaskLog.cs
+++ b/src/Khd.Core.Domain/Models/WcsTaskLog.cs
@@ -17,6 +17,8 @@ namespace Khd.Core.Domain.Models
[Table("wcs_task_log")]
public class WcsTaskLog
{
+ [Column("taskCode")]
+ public string taskCode { get; set; }
[Column("from_floor_no")]
public int? fromFloorNo { get; set; }
diff --git a/src/Khd.Core.Library/Khd.Core.Library.csproj b/src/Khd.Core.Library/Khd.Core.Library.csproj
index 118e91b..6db1aca 100644
--- a/src/Khd.Core.Library/Khd.Core.Library.csproj
+++ b/src/Khd.Core.Library/Khd.Core.Library.csproj
@@ -8,6 +8,7 @@
+
diff --git a/src/Khd.Core.Library/LoggerUtils.cs b/src/Khd.Core.Library/LoggerUtils.cs
new file mode 100644
index 0000000..654bffd
--- /dev/null
+++ b/src/Khd.Core.Library/LoggerUtils.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Khd.Core.Library
+{
+ public class LoggerUtils : IDisposable
+ {
+
+ NLog.Logger logger = NLog.LogManager.GetLogger("LoggerFile");
+ public LoggerUtils()
+ {
+
+ }
+
+ ///
+ /// 信息记录
+ ///
+ ///
+ public void Log(string msg)
+ {
+ logger.Info(msg);
+ }
+
+ ///
+ /// 信息记录
+ ///
+ ///
+ public void Info(string msg)
+ {
+ logger.Info(msg);
+ }
+ ///
+ /// 错误记录
+ ///
+ ///
+ public void Error(string msg)
+ {
+ logger.Error(msg);
+ }
+
+ public void Close()
+ {
+
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(true);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!disposing)
+ return;
+ }
+ }
+}
diff --git a/src/Khd.Core.Wcs/Khd.Core.Wcs.csproj b/src/Khd.Core.Wcs/Khd.Core.Wcs.csproj
index f8ed9e4..8fa2dec 100644
--- a/src/Khd.Core.Wcs/Khd.Core.Wcs.csproj
+++ b/src/Khd.Core.Wcs/Khd.Core.Wcs.csproj
@@ -33,6 +33,9 @@
Always
+
+ Always
+
diff --git a/src/Khd.Core.Wcs/MainCentralControl.cs b/src/Khd.Core.Wcs/MainCentralControl.cs
index 524ebf6..30ef414 100644
--- a/src/Khd.Core.Wcs/MainCentralControl.cs
+++ b/src/Khd.Core.Wcs/MainCentralControl.cs
@@ -1,5 +1,6 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Wcs.Global;
using Khd.Core.Wcs.Wcs;
using Masuit.Tools.Logging;
@@ -32,7 +33,7 @@ namespace Khd.Core.Wcs
///
public void Start()
{
-
+ LoggerUtils logger=new LoggerUtils();
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService();
try
@@ -50,7 +51,7 @@ namespace Khd.Core.Wcs
plc = new Plc.S7.Plc(plcConfig.CpuType, plcConfig.IP, plcConfig.Port, plcConfig.Rack, plcConfig.Slot);
try
{
- plc.Open();
+ //plc.Open();
Console.WriteLine(DateTime.Now + ":连接到PLC:" + plcConfig.IP);
}
catch
@@ -67,58 +68,58 @@ namespace Khd.Core.Wcs
createTaskByRecord.StartPoint();
//一楼提升机以及接驳位
- FirstFloor firstFloor = new(_host, StaticData.PlcDic[0]);
+ FirstFloor firstFloor = new(_host);
firstFloor.StartPoint();
//二层接驳位
var SecondBaseFloorEquip = StaticData.BaseEquip.Where(t => t.floorNo == 2 && t.equipType == 1).First();
- SecondFloorPoint secondFloorPoint = new(_host, StaticData.PlcDic[0], SecondBaseFloorEquip.floorNo.Value);
+ SecondFloorPoint secondFloorPoint = new(_host, SecondBaseFloorEquip.floorNo.Value);
secondFloorPoint.StartPoint();
//二层AGV
var SecondFloorAgvEquip = StaticData.BaseEquip.Where(t => t.floorNo == 2 && t.equipType == 4).First();
- SecondFloorAGV secondFloorAGV = new(_host, StaticData.PlcDic[0], SecondFloorAgvEquip.floorNo.Value);
+ SecondFloorAGV secondFloorAGV = new(_host, SecondFloorAgvEquip.floorNo.Value);
secondFloorAGV.StartPoint();
//二楼线体
var SecondFloorLineEquip = StaticData.BaseEquip.Where(t => t.floorNo == 2 && t.equipType == 17).First();
- SecondFloorLine secondFloorLine = new(_host, StaticData.PlcDic[2], SecondFloorLineEquip.floorNo.Value);
+ SecondFloorLine secondFloorLine = new(_host, SecondFloorLineEquip.floorNo.Value);
secondFloorLine.StartPoint();
//三层接驳位
var ThirdBaseFloorEquip = StaticData.BaseEquip.Where(t => t.floorNo == 3 && t.equipType == 1).First();
- ThirdFloorPoint thirdFloorPoint = new(_host, StaticData.PlcDic[0], ThirdBaseFloorEquip.floorNo.Value);
+ ThirdFloorPoint thirdFloorPoint = new(_host, ThirdBaseFloorEquip.floorNo.Value);
thirdFloorPoint.StartPoint();
//三层AGV
var ThirdFloorAgvEquip = StaticData.BaseEquip.Where(t => t.floorNo == 3 && t.equipType == 4).First();
- ThirdFloorAGV thirdFloorAGV = new(_host, StaticData.PlcDic[2], ThirdFloorAgvEquip.floorNo.Value);
+ ThirdFloorAGV thirdFloorAGV = new(_host, ThirdFloorAgvEquip.floorNo.Value);
thirdFloorAGV.StartPoint();
//五层接驳位
var FifthBaseFloorEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 1).First();
- FiveFloorPoint fifthFloorPoint = new(_host, StaticData.PlcDic[0], FifthBaseFloorEquip.floorNo.Value);
+ FiveFloorPoint fifthFloorPoint = new(_host, FifthBaseFloorEquip.floorNo.Value);
fifthFloorPoint.StartPoint();
//五层CTU
var FiveFloorCTUEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 6).First();
- FiveFloorCTU fiveFloorCTU = new(_host, StaticData.PlcDic[1], FiveFloorCTUEquip.floorNo.Value);
+ FiveFloorCTU fiveFloorCTU = new(_host,FiveFloorCTUEquip.floorNo.Value);
fiveFloorCTU.StartPoint();
//五层AGV
var FifthFloorAgvEquip = StaticData.BaseEquip.Where(t => t.floorNo == 5 && t.equipType == 5).First();
- FiveFloorAGV fifthFloorAGV = new(_host, StaticData.PlcDic[0], FifthFloorAgvEquip.floorNo.Value);
+ FiveFloorAGV fifthFloorAGV = new(_host, FifthFloorAgvEquip.floorNo.Value);
fifthFloorAGV.StartPoint();
//背负式Agv
var FifthFloorBearAgvEquip = StaticData.BaseEquip.Where(t => t.objid == 28).First();
- FiveFloorBearAgv fiveFloorBearAgv = new(_host, StaticData.PlcDic[0], FifthFloorBearAgvEquip.floorNo.Value);
+ FiveFloorBearAgv fiveFloorBearAgv = new(_host, FifthFloorBearAgvEquip.floorNo.Value);
fiveFloorBearAgv.StartPoint();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
- LogManager.Error(ex);
+ logger.Error(ex.Message+"\n"+ex.StackTrace);
}
}
diff --git a/src/Khd.Core.Wcs/NLog.config b/src/Khd.Core.Wcs/NLog.config
new file mode 100644
index 0000000..46ffac4
--- /dev/null
+++ b/src/Khd.Core.Wcs/NLog.config
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ .
+
+
+
+
+
+
+
+
diff --git a/src/Khd.Core.Wcs/Program.cs b/src/Khd.Core.Wcs/Program.cs
index 8e8b065..236d16e 100644
--- a/src/Khd.Core.Wcs/Program.cs
+++ b/src/Khd.Core.Wcs/Program.cs
@@ -1,4 +1,5 @@
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Wcs;
using Khd.Core.Wcs.Global;
using Masuit.Tools.Logging;
@@ -10,9 +11,10 @@ using System.Diagnostics;
internal class Program
{
-
+ private static LoggerUtils _logger = new LoggerUtils();
private static void Main(string[] args)
{
+
Console.ForegroundColor = ConsoleColor.Yellow;
Init(); //初始化加载配置文件
AppDomain.CurrentDomain.UnhandledException += GlobalExceptionHandler; //全局异常捕获
@@ -30,14 +32,14 @@ internal class Program
{
IHost host = CreateHostBuilder(args).Build();
- LogManager.Info("系统启动开始");
+ _logger.Info("系统启动开始");
Console.WriteLine($"{DateTime.Now}:系统启动开始");
MainCentralControl main = new(host);
main.Start();
mutex.ReleaseMutex(); // 释放 Mutex
- LogManager.Info("系统启动成功");
+ _logger.Info("系统启动成功");
Console.WriteLine($"{DateTime.Now}:系统启动成功");
while (true)
@@ -54,7 +56,7 @@ internal class Program
catch (Exception ex)
{
Console.Write("系统启动异常:" + ex.Message + "\n" + ex.StackTrace);
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
}
@@ -65,13 +67,13 @@ internal class Program
Console.WriteLine("全局异常捕获:");
Console.WriteLine(exception.Message);
Console.WriteLine(exception.StackTrace);
- LogManager.Info("全局异常捕获:" + exception.Message);
+ _logger.Info("全局异常捕获:" + exception.Message);
}
else
{
Console.WriteLine("未知异常捕获:");
Console.WriteLine(e.ExceptionObject);
- LogManager.Info("未知异常捕获:" + e.ExceptionObject);
+ _logger.Info("未知异常捕获:" + e.ExceptionObject);
}
}
diff --git a/src/Khd.Core.Wcs/SystemData.cs b/src/Khd.Core.Wcs/SystemData.cs
index c1b084d..e6ca263 100644
--- a/src/Khd.Core.Wcs/SystemData.cs
+++ b/src/Khd.Core.Wcs/SystemData.cs
@@ -27,5 +27,6 @@ namespace Khd.Core.Wcs
}
}
public static object outStockLock = new object();
+
}
}
diff --git a/src/Khd.Core.Wcs/Wcs/BackUpData.cs b/src/Khd.Core.Wcs/Wcs/BackUpData.cs
index 7d9adc7..5886594 100644
--- a/src/Khd.Core.Wcs/Wcs/BackUpData.cs
+++ b/src/Khd.Core.Wcs/Wcs/BackUpData.cs
@@ -1,4 +1,5 @@
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Masuit.Tools.Logging;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
@@ -41,6 +42,7 @@ namespace Khd.Core.Wcs.Wcs
///
private void OnTimerElapsed(object? sender, ElapsedEventArgs e)
{
+ LoggerUtils _logger = new LoggerUtils();
try
{
using var scope = _host.Services.CreateScope();
@@ -64,11 +66,11 @@ namespace Khd.Core.Wcs.Wcs
est < date_add(NOW(), interval -1 DAY);";
var ret = dbContext.Database.ExecuteSqlRaw(sqlQuery);
string saveLog = ret == 0 ? "备份任务SQL语句存在问题!" : "备份任务SQL语句执行成功!";
- LogManager.Info($"定时备份任务日志记录 >>> {saveLog}");
+ _logger.Info($"定时备份任务日志记录 >>> {saveLog}");
}
catch (Exception ex)
{
- LogManager.Info($"定时备份任务方法报错 >>> {ex.Message}");
+ _logger.Info($"定时备份任务方法报错 >>> {ex.Message}");
}
}
diff --git a/src/Khd.Core.Wcs/Wcs/CreateTaskByRecord.cs b/src/Khd.Core.Wcs/Wcs/CreateTaskByRecord.cs
index 1c239a7..1df27b8 100644
--- a/src/Khd.Core.Wcs/Wcs/CreateTaskByRecord.cs
+++ b/src/Khd.Core.Wcs/Wcs/CreateTaskByRecord.cs
@@ -1,5 +1,6 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Library.Mapper;
using Khd.Core.Wcs.Global;
using Masuit.Tools;
@@ -18,6 +19,7 @@ namespace Khd.Core.Wcs.Wcs
///
public class CreateTaskByRecord
{
+ private readonly LoggerUtils _logger=new LoggerUtils();
private readonly IHost _host;
public CreateTaskByRecord(IHost host)
{
@@ -31,37 +33,62 @@ namespace Khd.Core.Wcs.Wcs
{
//背负式Agv返库任务
var createBearAgvReturnThread = new Thread(CreateBearAgvReturnLogic);
+ createBearAgvReturnThread.IsBackground = true;
+ createBearAgvReturnThread.Name = "CreateBearAgvReturnLogic";
createBearAgvReturnThread.Start();
//五楼半成品入库任务
var createFiveProductInTaskThread = new Thread(CreateFiveProductInTaskLogic);
+ createFiveProductInTaskThread.IsBackground = true;
+ createFiveProductInTaskThread.Name = "CreateFiveProductInTaskLogic";
createFiveProductInTaskThread.Start();
//五楼成品出库任务
var createFiveProductTaskThread = new Thread(CreateFiveProductTaskLogic);
+ createFiveProductTaskThread.IsBackground = true;
+ createFiveProductTaskThread.Name = "CreateFiveProductTaskLogic";
createFiveProductTaskThread.Start();
//五楼CTU出库任务以及原材料出库任务
var createRawTaskThread = new Thread(CreateRawTaskLogic);
+ createRawTaskThread.IsBackground = true;
+ createRawTaskThread.Name = "CreateRawTaskLogic";
createRawTaskThread.Start();
//五楼柜体拆分返库任务
var createRawInThread = new Thread(CreateRawInTaskLogic);
+ createRawInThread.IsBackground = true;
+ createRawInThread.Name = "CreateRawInTaskLogic";
createRawInThread.Start();
//三楼去翻转机任务
var createThirdOutTaskThread = new Thread(CreateThirdOutTaskLogic);
+ createThirdOutTaskThread.IsBackground = true;
+ createThirdOutTaskThread.Name = "CreateThirdOutTaskLogic";
createThirdOutTaskThread.Start();
//二楼成品出库任务
var CreateSecondProductTaskThread = new Thread(CreateSecondProductTaskLogic);
+ CreateSecondProductTaskThread.IsBackground = true;
+ CreateSecondProductTaskThread.Name = "CreateSecondProductTaskLogic";
CreateSecondProductTaskThread.Start();
//三楼托盘收集架满5个或10个时出库合盘任务
var createEmptyTrayThread = new Thread(CreateEmptyTrayLogic);
+ createEmptyTrayThread.IsBackground = true;
+ createEmptyTrayThread.Name = "CreateEmptyTrayLogic";
createEmptyTrayThread.Start();
//二楼废品区人工调度任务
var createThirdWasterTaskThread = new Thread(CreateThirdWasterTaskLogic);
+ createThirdWasterTaskThread.IsBackground = true;
+ createThirdWasterTaskThread.Name = "CreateThirdWasterTaskLogic";
createThirdWasterTaskThread.Start();
-
+ //背负式退库
+ var BackReturnTaskThread= new Thread(BackReturnTaskLogic);
+ BackReturnTaskThread.IsBackground = true;
+ BackReturnTaskThread.Name = "BackReturnTaskLogic";
+ BackReturnTaskThread.Start();
Console.WriteLine(DateTime.Now + ":出库任务监听启动成功");
- LogManager.Info("出库任务监听启动成功");
+ _logger.Info("出库任务监听启动成功");
}
- private void CreateRawInTaskLogic(object? obj)
+ ///
+ /// 五楼柜体拆分返库任务
+ ///
+ private void CreateRawInTaskLogic()
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService();
@@ -120,7 +147,7 @@ namespace Khd.Core.Wcs.Wcs
}
catch (Exception ex)
{
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(5000);
}
@@ -157,7 +184,7 @@ namespace Khd.Core.Wcs.Wcs
}
catch (Exception ex)
{
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(5000);
}
@@ -291,7 +318,7 @@ namespace Khd.Core.Wcs.Wcs
}
catch (Exception ex)
{
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(5000);
}
@@ -304,41 +331,45 @@ namespace Khd.Core.Wcs.Wcs
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService();
- try
+ while (true)
{
- dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
- WcsTask? wcsTask = dbContext.WcsTask.Where(t => t.taskType == 28).FirstOrDefault();
- if (wcsTask != null)
+ try
{
- WmsRawInstock? wmsRawInstock = dbContext.WmsRawInstock.Where(t => t.instockType == "2" && t.warehouseId == 511 && t.executeStatus == "0").FirstOrDefault();
- if (wmsRawInstock != null)
+ dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
+ WcsTask? wcsTask = dbContext.WcsTask.Where(t => t.taskType == 28).FirstOrDefault();
+ if (wcsTask != null)
{
- wcsTask.useFlag = 1;
- wcsTask.createTime = DateTime.Now;
- wmsRawInstock.executeStatus = "1";
- wmsRawInstock.beginTime = DateTime.Now;
- WmsRawInstockDetail wmsRawInstockDetail = new WmsRawInstockDetail()
+ WmsRawInstock? wmsRawInstock = dbContext.WmsRawInstock.Where(t => t.instockType == "2" && t.warehouseId == 511 && t.executeStatus == "0").FirstOrDefault();
+ if (wmsRawInstock != null)
{
- rawInstockDetailId = StaticData.SnowId.NextId(),
- rawInstockId = wmsRawInstock.rawInstockId,
- instockWay = "2",
- activeFlag = "1",
- stackAmount = 1,
- createBy = "WCS",
- createDate = DateTime.Now,
- materialId = wmsRawInstock.materialId,
- instockAmount = 1,
- executeStatus = "0",
- };
- dbContext.Update(wmsRawInstock);
- dbContext.Update(wcsTask);
- dbContext.SaveChanges();
+ wcsTask.useFlag = 1;
+ wcsTask.createTime = DateTime.Now;
+ wmsRawInstock.executeStatus = "1";
+ wmsRawInstock.beginTime = DateTime.Now;
+ WmsRawInstockDetail wmsRawInstockDetail = new WmsRawInstockDetail()
+ {
+ rawInstockDetailId = StaticData.SnowId.NextId(),
+ rawInstockId = wmsRawInstock.rawInstockId,
+ instockWay = "2",
+ activeFlag = "1",
+ stackAmount = 1,
+ createBy = "WCS",
+ createDate = DateTime.Now,
+ materialId = wmsRawInstock.materialId,
+ instockAmount = 1,
+ executeStatus = "0",
+ };
+ dbContext.Update(wmsRawInstock);
+ dbContext.Update(wcsTask);
+ dbContext.SaveChanges();
+ }
}
}
- }
- catch
- {
-
+ catch(Exception ex)
+ {
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
+ }
+ Thread.Sleep(5000);
}
}
@@ -437,7 +468,7 @@ namespace Khd.Core.Wcs.Wcs
}
catch (Exception ex)
{
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(5000);
}
@@ -492,176 +523,179 @@ namespace Khd.Core.Wcs.Wcs
WmsBaseLocation? wmsBaseLocation = null;
WmsRawStock? wmsRawStock = null;
bill = bill.OrderBy(t => t.b.instockDate.Value.Date);//按某个时间段
- var fistbill = bill.FirstOrDefault();
- if (fistbill != null)
+ foreach (var item in bill)
{
- int? locRow = 0;
- if (fistbill.a.locRow % 2 == 1)
+ var fistbill = bill.First();
+ if (fistbill != null)
{
- locRow = fistbill.a.locRow + 1;
- }
- else
- {
- locRow = fistbill.a.locRow - 1;
- }
-
- var lastbill = bill.Where(t => t.a.locRow == locRow)
- .Where(t => t.a.locColumn == fistbill.a.locColumn)
- .Where(t => t.a.locDeep == 2)
- .FirstOrDefault();
- wmsBaseLocation = fistbill.a;
- if (lastbill != null)
- {
- if (lastbill.b.instockDate != null && fistbill.b.instockDate != null)
+ int? locRow = 0;
+ if (fistbill.a.locRow % 2 == 1)
{
- if (wmsBaseLocation.locDeep == 1)
+ locRow = fistbill.a.locRow + 1;
+ }
+ else
+ {
+ locRow = fistbill.a.locRow - 1;
+ }
+
+ var lastbill = bill.Where(t => t.a.locRow == locRow)
+ .Where(t => t.a.locColumn == fistbill.a.locColumn)
+ .Where(t => t.a.locDeep == 2)
+ .FirstOrDefault();
+ wmsBaseLocation = fistbill.a;
+ if (lastbill != null)
+ {
+ if (lastbill.b.instockDate != null && fistbill.b.instockDate != null)
{
- int? row = 0;
- if (wmsBaseLocation.locRow % 2 == 1)
+ if (wmsBaseLocation.locDeep == 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 = AllWmsBaseLocations.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))
+ int? row = 0;
+ if (wmsBaseLocation.locRow % 2 == 1)
{
- WmsRawStock? wmsRawStock1 = dbContext.WmsRawStock.FirstOrDefault(t => t.locationCode == fromBaseLocation.locationCode);
- if (wmsRawStock1 != null)
+ 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 = AllWmsBaseLocations.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))
{
- WmsBaseLocation? toLocation = AllWmsBaseLocations.Where(t => t.warehouseId == wmsBaseLocation.warehouseId)
- .Where(t => t.locDeep == 1)
- .Where(t => string.IsNullOrEmpty(t.containerCode))
- .Where(t => t.locColumn > wmsBaseLocation.locColumn)
- .OrderBy(t => t.locColumn)
- .FirstOrDefault();
- toLocation ??= AllWmsBaseLocations.Where(t => t.warehouseId == wmsBaseLocation.warehouseId)
- .Where(t => t.locDeep == 1)
- .Where(t => string.IsNullOrEmpty(t.containerCode))
- .Where(t => t.locColumn < wmsBaseLocation.locColumn)
- .OrderByDescending(t => t.locColumn)
- .FirstOrDefault();
- toLocation ??= AllWmsBaseLocations.Where(t => t.warehouseId == wmsBaseLocation.warehouseId)
- .Where(t => t.warehouseId != wmsBaseLocation.locationId)
- .Where(t => string.IsNullOrEmpty(t.containerCode))
- .FirstOrDefault();
- if (toLocation != null)
+ WmsRawStock? wmsRawStock1 = dbContext.WmsRawStock.FirstOrDefault(t => t.locationCode == fromBaseLocation.locationCode);
+ if (wmsRawStock1 != null)
{
- var RemoveTask = new WcsTask()
+ WmsBaseLocation? toLocation = AllWmsBaseLocations.Where(t => t.warehouseId == wmsBaseLocation.warehouseId)
+ .Where(t => t.locDeep == 1)
+ .Where(t => string.IsNullOrEmpty(t.containerCode))
+ .Where(t => t.locColumn > wmsBaseLocation.locColumn)
+ .OrderBy(t => t.locColumn)
+ .FirstOrDefault();
+ toLocation ??= AllWmsBaseLocations.Where(t => t.warehouseId == wmsBaseLocation.warehouseId)
+ .Where(t => t.locDeep == 1)
+ .Where(t => string.IsNullOrEmpty(t.containerCode))
+ .Where(t => t.locColumn < wmsBaseLocation.locColumn)
+ .OrderByDescending(t => t.locColumn)
+ .FirstOrDefault();
+ toLocation ??= AllWmsBaseLocations.Where(t => t.warehouseId == wmsBaseLocation.warehouseId)
+ .Where(t => t.warehouseId != wmsBaseLocation.locationId)
+ .Where(t => string.IsNullOrEmpty(t.containerCode))
+ .FirstOrDefault();
+ if (toLocation != null)
{
- objid = StaticData.SnowId.NextId(),
- taskType = 67,
- 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
- };
- 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(RemoveTask);
- dbContext.Add(wcsTaskLog);
+ var RemoveTask = new WcsTask()
+ {
+ objid = StaticData.SnowId.NextId(),
+ taskType = 67,
+ 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
+ };
+ 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(RemoveTask);
+ dbContext.Add(wcsTaskLog);
+ }
+ else
+ {
+ continue;
+ }
}
else
{
continue;
}
}
- else
- {
- 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)
+ if (wmsBaseLocation != null)
{
- MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
- if (mesBaseBarcodeInfo != null)
+ wmsRawStock = wmsRawStocks.Where(t => t.locationCode == wmsBaseLocation.locationCode).First();
+ MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == wmsRawStock.palletInfoCode);
+ if (mesBasePalletInfo != null)
{
- WmsRawOutstockDetail wmsRawOutstockDetail = new WmsRawOutstockDetail()
+ MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
+ if (mesBaseBarcodeInfo != null)
{
- 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()
- {
- objid = StaticData.SnowId.NextId(),
- orderId = wmsRawOutstock.rawOutstockId,
- taskType = 41,
- containerNo = wmsBaseLocation.containerCode,
- createBy = "WCS",
- createTime = DateTime.Now,
- taskStatus = 0,
- materialId = wmsRawOutstock.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
- };
- wmsBaseLocation.locationStatus = "6";
- dbContext.Update(wmsBaseLocation);
- dbContext.Add(wmsRawOutstockDetail);
- WcsTaskLog wcsTaskLog = CoreMapper.Map(wcsTask);
- dbContext.Remove(wcsTaskManual);
- dbContext.Add(wcsTask);
- dbContext.Add(wcsTaskLog);
- dbContext.SaveChanges();
+ 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()
+ {
+ objid = StaticData.SnowId.NextId(),
+ orderId = wmsRawOutstock.rawOutstockId,
+ taskType = 41,
+ containerNo = wmsBaseLocation.containerCode,
+ createBy = "WCS",
+ createTime = DateTime.Now,
+ taskStatus = 0,
+ materialId = wmsRawOutstock.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
+ };
+ wmsBaseLocation.locationStatus = "6";
+ dbContext.Update(wmsBaseLocation);
+ dbContext.Add(wmsRawOutstockDetail);
+ WcsTaskLog wcsTaskLog = CoreMapper.Map(wcsTask);
+ dbContext.Remove(wcsTaskManual);
+ dbContext.Add(wcsTask);
+ dbContext.Add(wcsTaskLog);
+ dbContext.SaveChanges();
+ }
}
}
}
@@ -674,7 +708,7 @@ namespace Khd.Core.Wcs.Wcs
}
catch (Exception ex)
{
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
}
}
@@ -745,7 +779,7 @@ namespace Khd.Core.Wcs.Wcs
}
catch (Exception ex)
{
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(5000);
}
@@ -826,7 +860,6 @@ namespace Khd.Core.Wcs.Wcs
MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.FirstOrDefault(t => t.palletInfoCode == stock.palletInfoCode);
if (mesBasePalletInfo != null)
{
-
if (location.locDeep == 1)
{
int? row = 0;
@@ -969,7 +1002,7 @@ namespace Khd.Core.Wcs.Wcs
catch (Exception ex)
{
Console.WriteLine(ex.Message + ex.StackTrace);
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(5000);
}
@@ -1197,7 +1230,7 @@ namespace Khd.Core.Wcs.Wcs
catch (Exception ex)
{
Console.WriteLine(ex.Message + ex.StackTrace);
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(5000);
}
@@ -1815,7 +1848,7 @@ namespace Khd.Core.Wcs.Wcs
}
catch (Exception ex)
{
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(1000);
}
diff --git a/src/Khd.Core.Wcs/Wcs/FirstFloor.cs b/src/Khd.Core.Wcs/Wcs/FirstFloor.cs
index 693c388..c425e8c 100644
--- a/src/Khd.Core.Wcs/Wcs/FirstFloor.cs
+++ b/src/Khd.Core.Wcs/Wcs/FirstFloor.cs
@@ -1,5 +1,6 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
@@ -15,6 +16,7 @@ namespace Khd.Core.Wcs.Wcs
///
public class FirstFloor
{
+ private readonly LoggerUtils _logger = new LoggerUtils();
private readonly IHost _host;
private readonly long F01 = 1;
private readonly long T01 = 6;
@@ -56,7 +58,7 @@ namespace Khd.Core.Wcs.Wcs
- public FirstFloor(IHost host, Plc.S7.Plc plc)
+ public FirstFloor(IHost host)
{
this._host = host;
@@ -88,24 +90,27 @@ namespace Khd.Core.Wcs.Wcs
{
Thread firstFloorLine = new(FirstFloorLine)//一楼接驳位线程
{
- IsBackground = true
+ IsBackground = true,
+ Name = "FirstFloorLine"
};
firstFloorLine.Start();
Thread firstFloorHoister = new(FirstFloorHoister)//提升机
{
- IsBackground = true
+ IsBackground = true,
+ Name = "FirstFloorHoister"
};
firstFloorHoister.Start();
Thread equipStatusThread = new Thread(EquipStatusLogic)//设备状态,1-5楼接驳位能不能送货,提升机和小车任务
{
- IsBackground = true
+ IsBackground = true,
+ Name = "EquipStatusThread"
};
equipStatusThread.Start();
Console.WriteLine(DateTime.Now + ":一楼提升机线程启动成功");
- LogManager.Info("一楼提升机线程启动成功");
+ _logger.Info("一楼提升机线程启动成功");
}
private void EquipStatusLogic(object? obj)
@@ -185,7 +190,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
}
@@ -231,7 +236,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Add(wcsTaskLog);
dbContext.Add(wcsTask);
dbContext.SaveChanges();
- LogManager.Info("一楼接驳位线程:空托盘任务下发成功");
+ _logger.Info("一楼接驳位线程:空托盘任务下发成功");
Console.WriteLine(DateTime.Now + ":一楼接驳位线程:空托盘任务下发成功");
}
}
@@ -258,7 +263,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(1000);
}
@@ -357,14 +362,14 @@ namespace Khd.Core.Wcs.Wcs
baseEquip.containerNo = null;
dbContext.Update(baseEquip);
dbContext.SaveChanges();
- LogManager.Info("一楼接驳位线程:托盘" + RFID001Value + "解绑信息更新成功");
+ _logger.Info("一楼接驳位线程:托盘" + RFID001Value + "解绑信息更新成功");
}
else if (baseEquip.containerNo != RFID001Value)
{
baseEquip.containerNo = RFID001Value;
dbContext.Update(baseEquip);
dbContext.SaveChanges();
- LogManager.Info("一楼接驳位线程:托盘" + RFID001Value + "绑定信息更新成功");
+ _logger.Info("一楼接驳位线程:托盘" + RFID001Value + "绑定信息更新成功");
Console.WriteLine(DateTime.Now + ":一楼接驳位线程:托盘" + RFID001Value + "绑定信息更新成功");
Thread.Sleep(3000);
continue;
@@ -483,7 +488,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(1000);
}
@@ -522,7 +527,7 @@ namespace Khd.Core.Wcs.Wcs
wcsTask.serialNo ??= SystemData.GetSerialNo(dbContext);
if (wcsTasks.Where(t => t.taskStatus > 0).Where(t => t.objid != wcsTask.objid).Any())
{
- LogManager.Info("提升机线程:有其他任务正在执行,跳过当前任务");
+ _logger.Info("提升机线程:有其他任务正在执行,跳过当前任务");
continue;
}
BaseEquip lineEquip = dbContext.BaseEquip.First(t => t.objid == wcsTask.floorNo);
@@ -530,7 +535,7 @@ namespace Khd.Core.Wcs.Wcs
{
if (lineEquip.equipStatus == 1)
{
- LogManager.Info("提升机线程:" + wcsTask.floorNo + "楼接驳位有AGV任务,跳过当前任务");
+ _logger.Info("提升机线程:" + wcsTask.floorNo + "楼接驳位有AGV任务,跳过当前任务");
continue;
}
BasePlcpoint floorPoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "RFID00" + wcsTask.fromFloorNo);
@@ -546,7 +551,7 @@ namespace Khd.Core.Wcs.Wcs
StaticData.PlcDic[0].WriteToPoint(basePlcpoint.plcpointAddress, "1", basePlcpoint.plcpointLength.ToString());
StaticData.PlcDic[0].WriteToPoint(this.serialno06.plcpointAddress, wcsTask.serialNo.ToString(), this.serialno06.plcpointLength.ToString());
Console.WriteLine(DateTime.Now + ":提升机下发" + wcsTask.fromFloorNo + "楼入库指令");
- LogManager.Info("提升机下发" + wcsTask.fromFloorNo + "楼入库指令");
+ _logger.Info("提升机下发" + wcsTask.fromFloorNo + "楼入库指令");
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 2, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行中" });
lineEquip.equipStatus = 1;
@@ -562,7 +567,7 @@ namespace Khd.Core.Wcs.Wcs
StaticData.PlcDic[0].WriteToPoint(this.targetfloor06.plcpointAddress, wcsTask.fromFloorNo.ToString(), this.targetfloor06.plcpointLength.ToString());//目的地楼层
StaticData.PlcDic[0].WriteToPoint(this.serialno06.plcpointAddress, wcsTask.serialNo.ToString(), this.serialno06.plcpointLength.ToString());
Console.WriteLine(DateTime.Now + ":提升机下发去往" + wcsTask.fromFloorNo + "楼指令");
- LogManager.Info("提升机下发去往" + wcsTask.fromFloorNo + "楼指令");
+ _logger.Info("提升机下发去往" + wcsTask.fromFloorNo + "楼指令");
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 1, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行中" });
lineEquip.equipStatus = 1;
@@ -586,7 +591,7 @@ namespace Khd.Core.Wcs.Wcs
StaticData.PlcDic[0].WriteToPoint(basePlcpoint.plcpointAddress, "1", basePlcpoint.plcpointLength.ToString());
StaticData.PlcDic[0].WriteToPoint(this.serialno06.plcpointAddress, wcsTask.serialNo.ToString(), this.serialno06.plcpointLength.ToString());
Console.WriteLine(DateTime.Now + ":提升机下发" + wcsTask.fromFloorNo + "楼入库指令");
- LogManager.Info("提升机下发" + wcsTask.fromFloorNo + "楼入库指令");
+ _logger.Info("提升机下发" + wcsTask.fromFloorNo + "楼入库指令");
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 2, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行中" });
dbContext.SaveChanges();
@@ -603,7 +608,7 @@ namespace Khd.Core.Wcs.Wcs
wcsTask.remark = "提升机任务执行完成";
StaticData.PlcDic[0].WriteToPoint(this.targetfloor06.plcpointAddress, wcsTask.floorNo.ToString(), this.targetfloor06.plcpointLength.ToString());//目的地楼层
Console.WriteLine(DateTime.Now + ":提升机下发去往" + wcsTask.floorNo + "楼目的地指令");
- LogManager.Info("提升机下发去往" + wcsTask.floorNo + "楼目的地指令");
+ _logger.Info("提升机下发去往" + wcsTask.floorNo + "楼目的地指令");
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 3, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行完成" });
dbContext.SaveChanges();
@@ -623,7 +628,7 @@ namespace Khd.Core.Wcs.Wcs
if (clearPoint != null && Convert.ToBoolean(clearValue) == true)//是否有报警
{
Console.WriteLine(DateTime.Now + ":提升机下发报警消除指令");
- LogManager.Info("提升机下发报警消除指令");
+ _logger.Info("提升机下发报警消除指令");
StaticData.PlcDic[0].WriteToPoint(clearPoint.plcpointAddress, false, clearPoint.plcpointLength.ToString());//清除报警
}
wcsTask.taskStatus = 4;
@@ -633,7 +638,7 @@ namespace Khd.Core.Wcs.Wcs
BasePlcpoint basePlcpoint = StaticData.BasePlcpointList.First(t => t.floorNo == wcsTask.floorNo && t.plcpointNo.Contains("wcsrun"));
StaticData.PlcDic[0].WriteToPoint(basePlcpoint.plcpointAddress, "2", basePlcpoint.plcpointLength.ToString());//去向为2,表示提升机已到达目的地,让货出去
Console.WriteLine(DateTime.Now + ":提升机下发" + wcsTask.floorNo + "楼出库指令");
- LogManager.Info("提升机下发" + wcsTask.floorNo + "楼出库指令");
+ _logger.Info("提升机下发" + wcsTask.floorNo + "楼出库指令");
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 4, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行完成" });
dbContext.SaveChanges();
@@ -651,7 +656,7 @@ namespace Khd.Core.Wcs.Wcs
else
{
Console.WriteLine(DateTime.Now + ":一楼托盘库有任务正在执行,等待任务执行完成");
- LogManager.Info("一楼托盘库有任务正在执行,等待任务执行完成");
+ _logger.Info("一楼托盘库有任务正在执行,等待任务执行完成");
}
}
else
@@ -666,7 +671,7 @@ namespace Khd.Core.Wcs.Wcs
BasePlcpoint basePlcpoint = StaticData.BasePlcpointList.First(t => t.floorNo == wcsTask.floorNo && t.plcpointNo.Contains("wcsrun"));
StaticData.PlcDic[0].WriteToPoint(basePlcpoint.plcpointAddress, "2", basePlcpoint.plcpointLength.ToString());//去向为2,表示提升机已到达目的地,让货出去
Console.WriteLine(DateTime.Now + ":提升机下发" + wcsTask.floorNo + "楼出库指令");
- LogManager.Info("提升机下发" + wcsTask.floorNo + "楼出库指令");
+ _logger.Info("提升机下发" + wcsTask.floorNo + "楼出库指令");
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 4, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行完成" });
dbContext.SaveChanges();
@@ -693,7 +698,7 @@ namespace Khd.Core.Wcs.Wcs
wcsTask.remark = "提升机任务执行完成";
lineEquip.equipStatus = 0;
Console.WriteLine(DateTime.Now + ":提升机任务完成" + wcsTask.fromFloorNo + "---" + wcsTask.floorNo + "楼指令");
- LogManager.Info("提升机任务完成" + wcsTask.fromFloorNo + "---" + wcsTask.floorNo + "楼指令");
+ _logger.Info("提升机任务完成" + wcsTask.fromFloorNo + "---" + wcsTask.floorNo + "楼指令");
dbContext.Update(lineEquip);
dbContext.Update(wcsTask);
dbContext.WcsTaskLog.Where(t => t.objid == wcsTask.objid).Update(t => new WcsTaskLog { taskStatus = 5, nextPointId = floorEquip.objid, nextPointNo = floorEquip.equipNo, updateBy = "提升机线程", updateTime = DateTime.Now, remark = "提升机任务执行完成" });
@@ -734,7 +739,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(5000);
}
diff --git a/src/Khd.Core.Wcs/Wcs/FiveFloorAGV.cs b/src/Khd.Core.Wcs/Wcs/FiveFloorAGV.cs
index 45629ec..cbc68cd 100644
--- a/src/Khd.Core.Wcs/Wcs/FiveFloorAGV.cs
+++ b/src/Khd.Core.Wcs/Wcs/FiveFloorAGV.cs
@@ -1,6 +1,7 @@
using Khd.Core.Domain.Dto.webapi;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
@@ -20,11 +21,12 @@ namespace Khd.Core.Wcs.Wcs
///
public class FiveFloorAGV
{
+ private readonly LoggerUtils _logger = new LoggerUtils();
private readonly IHost _host;
private readonly BasePlcpoint LineSignal;
int FloorNo { get; set; }
int agvID = 28;
- public FiveFloorAGV(IHost host, Plc.S7.Plc plc, int floor)
+ public FiveFloorAGV(IHost host, int floor)
{
this._host = host;
FloorNo = floor;
@@ -37,9 +39,11 @@ namespace Khd.Core.Wcs.Wcs
{
Thread FlowPointThread = new(MonitorInLocatorPoint);
+ FlowPointThread.IsBackground = true;
+ FlowPointThread.Name = "FiveFloorAGV";
FlowPointThread.Start();
Console.WriteLine(DateTime.Now + ":五楼AGV上件扫描监听启动成功");
- LogManager.Info("五楼AGV上件扫描监听启动成功");
+ _logger.Info("五楼AGV上件扫描监听启动成功");
}
public void MonitorInLocatorPoint()
@@ -60,7 +64,7 @@ namespace Khd.Core.Wcs.Wcs
{
if (taskList.Where(t => t.taskStatus > 0).Where(t => t.objid != item.objid).Any())
{
- LogManager.Info($"5楼AGV线程:有其他任务正在执行,跳过当前任务{item.objid}");
+ _logger.Info($"5楼AGV线程:有其他任务正在执行,跳过当前任务{item.objid}");
continue;
}
if (item.taskStatus == 0)//下发任务
@@ -74,7 +78,7 @@ namespace Khd.Core.Wcs.Wcs
bool canSend = dbContext.WcsTask.Where(t => t.nextPointId == lineEquip.objid && t.taskStatus > 0).Any();
if (lineEquip.equipStatus == 1)
{
- LogManager.Info("五楼AGV:接驳位有任务,无法下发出库任务");
+ _logger.Info("五楼AGV:接驳位有任务,无法下发出库任务");
continue;
}
if (Convert.ToInt32(StaticData.PlcDic[0].Read(LineSignal.plcpointAddress)) == 1 && !canSend)
@@ -109,7 +113,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("五楼Agv下发任务成功:" + message);
+ _logger.Info("五楼Agv下发任务成功:" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功:" + wmsBaseLocation.agvPositionCode + "," + nextEquip.agvPositionCode);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -121,7 +125,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
@@ -154,7 +158,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("五楼Agv下发任务成功:" + message);
+ _logger.Info("五楼Agv下发任务成功:" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功:" + wmsBaseLocation.agvPositionCode + "," + endEquip.agvPositionCode);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -164,7 +168,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 34)//背板安装到半成品
@@ -195,7 +199,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("五楼Agv下发任务成功:" + message);
+ _logger.Info("五楼Agv下发任务成功:" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功:" + currentEquip.agvPositionCode + "," + wmsBaseLocation.agvPositionCode);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -205,7 +209,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 46)//原材料到拆分区
@@ -236,7 +240,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("五楼Agv下发任务成功:" + message);
+ _logger.Info("五楼Agv下发任务成功:" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功:" + wmsBaseLocation.agvPositionCode + "," + currentEquip.agvPositionCode);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -246,7 +250,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 28)//拆分区返库
@@ -278,7 +282,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("五楼Agv下发任务成功:" + message);
+ _logger.Info("五楼Agv下发任务成功:" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功:" + currentEquip.agvPositionCode + "," + wmsBaseLocation.agvPositionCode);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -288,7 +292,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 47)//原材料入库
@@ -319,7 +323,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("五楼Agv下发任务成功:" + message);
+ _logger.Info("五楼Agv下发任务成功:" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功:" + startEquip.agvPositionCode + "," + wmsBaseLocation.agvPositionCode);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -329,7 +333,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 66)//移库
@@ -360,7 +364,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("五楼Agv下发任务成功:" + message);
+ _logger.Info("五楼Agv下发任务成功:" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv下发任务成功:" + fromBaseLocation.agvPositionCode + "," + toBaseLocation.agvPositionCode);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -370,7 +374,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
}
@@ -385,7 +389,7 @@ namespace Khd.Core.Wcs.Wcs
if (lineSignalValue == null || Convert.ToInt32(lineSignalValue) == 0)
{
Console.WriteLine(DateTime.Now + ":五楼Agv:接驳位为空,无法取货");
- LogManager.Info("五楼Agv:接驳位为空,无法取货");
+ _logger.Info("五楼Agv:接驳位为空,无法取货");
continue;
}
}
@@ -395,7 +399,7 @@ namespace Khd.Core.Wcs.Wcs
if (lineSignalValue == null || Convert.ToInt32(lineSignalValue) == 1)
{
Console.WriteLine(DateTime.Now + ":五楼Agv:接驳位有货,无法送货");
- LogManager.Info("五楼Agv:接驳位有货,无法送货");
+ _logger.Info("五楼Agv:接驳位有货,无法送货");
continue;
}
}
@@ -409,7 +413,7 @@ namespace Khd.Core.Wcs.Wcs
ReponseMessage? reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("五楼Agv下发继续任务成功:" + message);
+ _logger.Info("五楼Agv下发继续任务成功:" + message);
Console.WriteLine(DateTime.Now + ":五楼Agv继续任务:" + item.currPointNo + "," + item.endPointNo);
item.taskStatus = 4;
dbContext.Update(item);
@@ -420,7 +424,7 @@ namespace Khd.Core.Wcs.Wcs
else if (item.taskStatus == 5)
{
Console.WriteLine(DateTime.Now + ":五楼AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
- LogManager.Info("五楼Agv完成任务成功:" + item.ToJsonString());
+ _logger.Info("五楼Agv完成任务成功:" + item.ToJsonString());
if (item.taskType == 66)//移库
{
using var dbContextTransaction = dbContext.Database.BeginTransaction();
@@ -461,7 +465,7 @@ namespace Khd.Core.Wcs.Wcs
catch (Exception ex)
{
dbContextTransaction.Rollback();
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
}
else if (item.taskType == 38)//出库
@@ -768,7 +772,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
finally
{
diff --git a/src/Khd.Core.Wcs/Wcs/FiveFloorBearAgv.cs b/src/Khd.Core.Wcs/Wcs/FiveFloorBearAgv.cs
index 624970f..b6f6971 100644
--- a/src/Khd.Core.Wcs/Wcs/FiveFloorBearAgv.cs
+++ b/src/Khd.Core.Wcs/Wcs/FiveFloorBearAgv.cs
@@ -1,6 +1,7 @@
using Khd.Core.Domain.Dto.webapi;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Library.Mapper;
using Khd.Core.Wcs.Global;
using Masuit.Tools;
@@ -17,11 +18,11 @@ namespace Khd.Core.Wcs.Wcs
///
public class FiveFloorBearAgv
{
-
+ private readonly LoggerUtils _logger = new LoggerUtils();
private readonly IHost _host;
int FloorNo { get; set; }
int agvID = 10;
- public FiveFloorBearAgv(IHost host, Plc.S7.Plc plc, int floor)
+ public FiveFloorBearAgv(IHost host, int floor)
{
this._host = host;
FloorNo = floor;
@@ -33,9 +34,11 @@ namespace Khd.Core.Wcs.Wcs
{
Thread FlowPointThread = new(MonitorInLocatorPoint);
+ FlowPointThread.IsBackground = true;
+ FlowPointThread.Name = "FiveFloorBearAgv";
FlowPointThread.Start();
Console.WriteLine(DateTime.Now + ":五楼AGV上件扫描监听启动成功");
- LogManager.Info("五楼AGV上件扫描监听启动成功");
+ _logger.Info("五楼AGV上件扫描监听启动成功");
}
public void MonitorInLocatorPoint()
@@ -54,7 +57,7 @@ namespace Khd.Core.Wcs.Wcs
.OrderBy(t => t.createTime).ToList();
if (taskList.Count == 0)
{
- LogManager.Info(FloorNo + "楼AGV无任务");
+ _logger.Info(FloorNo + "楼AGV无任务");
}
foreach (var item in taskList)//出库
{
@@ -87,7 +90,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.code == "0")
{
- LogManager.Info("五楼背负式AGV线程下发任务" + agvTask.ToJsonString());
+ _logger.Info("五楼背负式AGV线程下发任务" + agvTask.ToJsonString());
Console.WriteLine(DateTime.Now + ":五楼背负式AGV线程下发任务" + startEquip.agvPositionCode + "," + endEquip.agvPositionCode);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -97,7 +100,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("下发小车任务失败" + result);
+ _logger.Info("下发小车任务失败" + result);
}
}
else
@@ -117,7 +120,7 @@ namespace Khd.Core.Wcs.Wcs
ReponseMessage? reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("五楼背负式AGV线程完成任务" + item.objid);
+ _logger.Info("五楼背负式AGV线程完成任务" + item.objid);
Console.WriteLine(DateTime.Now + ":五楼背负式AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
item.taskStatus = 5;
dbContext.Update(item);
@@ -127,7 +130,7 @@ namespace Khd.Core.Wcs.Wcs
}
else if (item.taskStatus == 7)//通知拿料完成
{
- LogManager.Info("五楼背负式AGV线程完成任务" + item.objid);
+ _logger.Info("五楼背负式AGV线程完成任务" + item.objid);
Console.WriteLine(DateTime.Now + ":五楼背负式AGV线程完成任务" + item.currPointNo + "," + item.endPointNo);
var agvTask = new RequestAGVTaskDto
{
@@ -161,7 +164,7 @@ namespace Khd.Core.Wcs.Wcs
}
catch (Exception ex)
{
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
finally
{
diff --git a/src/Khd.Core.Wcs/Wcs/FiveFloorCTU.cs b/src/Khd.Core.Wcs/Wcs/FiveFloorCTU.cs
index 8b6b939..e33db67 100644
--- a/src/Khd.Core.Wcs/Wcs/FiveFloorCTU.cs
+++ b/src/Khd.Core.Wcs/Wcs/FiveFloorCTU.cs
@@ -1,6 +1,7 @@
using Khd.Core.Domain.Dto.webapi;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
@@ -20,7 +21,7 @@ namespace Khd.Core.Wcs.Wcs
{
List ScanPoint { get; set; }//点位信息
private readonly IHost _host;
-
+ private readonly LoggerUtils _logger = new LoggerUtils();
private readonly BasePlcpoint LineRFID;
private readonly BasePlcpoint isarrive;
private readonly BasePlcpoint isput;
@@ -29,7 +30,7 @@ namespace Khd.Core.Wcs.Wcs
private readonly BasePlcpoint CtuLineWaring;
int FloorNo { get; set; }
int CTUID = 11;
- public FiveFloorCTU(IHost host, Plc.S7.Plc plc, int floor)
+ public FiveFloorCTU(IHost host, int floor)
{
this._host = host;
FloorNo = floor;
@@ -48,16 +49,20 @@ namespace Khd.Core.Wcs.Wcs
{
Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
+ FlowPointThread.IsBackground = true;
+ FlowPointThread.Name= "FiveFloorCTU";
FlowPointThread.Start();
Thread FlowCTUInWareThread = new Thread(MonitorInWare);
+ FlowCTUInWareThread.IsBackground = true;
+ FlowCTUInWareThread.Name = "FiveFloorCTULine";
FlowCTUInWareThread.Start();
Thread HeartThread = new Thread(HeartLogic);
HeartThread.Start();
Console.WriteLine(DateTime.Now + ":五楼CTU上件扫描监听启动");
- LogManager.Info("五楼CTU上件扫描监听启动");
+ _logger.Info("五楼CTU上件扫描监听启动");
}
private void HeartLogic(object? obj)
@@ -282,7 +287,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(1000);
}
@@ -316,7 +321,7 @@ namespace Khd.Core.Wcs.Wcs
// }
// else
// {
- // LogManager.Info("CTU下发预执行任务失败:\nwaitTask:" + waitMessage + "\nwaitResult:" + waitResult);
+ // _logger.Info("CTU下发预执行任务失败:\nwaitTask:" + waitMessage + "\nwaitResult:" + waitResult);
// }
// Thread.Sleep(1000 * 60 * 10);//每10分钟重新下发预执行任务
// }
@@ -324,7 +329,7 @@ namespace Khd.Core.Wcs.Wcs
// }
// catch (Exception ex)
// {
- // LogManager.Error(ex);
+ // _logger.Error(ex.Message + "\n" + ex.StackTrace);
// }
// Thread.Sleep(3000);
// }
@@ -351,12 +356,12 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("CTU下发预执行任务失败:\nwaitTask:" + waitMessage + "\nwaitResult:" + waitResult);
+ _logger.Info("CTU下发预执行任务失败:\nwaitTask:" + waitMessage + "\nwaitResult:" + waitResult);
}
}
catch (Exception ex)
{
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
return false;
}
return false;
@@ -380,7 +385,7 @@ namespace Khd.Core.Wcs.Wcs
.Where(t => t.nextPointId == CTUID).OrderByDescending(t => t.ud1).ToList();
if (taskList.Count == 0)
{
- LogManager.Info(FloorNo + "楼CTU无任务");
+ _logger.Info(FloorNo + "楼CTU无任务");
}
foreach (var item in taskList)
{
@@ -414,7 +419,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.code == "0")
{
- LogManager.Info("五楼CTU线程开始任务" + item.objid);
+ _logger.Info("五楼CTU线程开始任务" + item.objid);
Console.WriteLine(DateTime.Now + ":五楼CTU线程开始任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -424,7 +429,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("CTU下发出库任务失败:" + reponseMessage?.message);
+ _logger.Info("CTU下发出库任务失败:" + reponseMessage?.message);
}
}
else if (item.taskType == 29)//入库任务
@@ -458,7 +463,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.code == "0")
{
- LogManager.Info("五楼CTU线程开始任务" + item.objid);
+ _logger.Info("五楼CTU线程开始任务" + item.objid);
Console.WriteLine(DateTime.Now + ":五楼CTU线程开始任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -480,7 +485,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("CTU下发入库任务失败:" + reponseMessage?.message);
+ _logger.Info("CTU下发入库任务失败:" + reponseMessage?.message);
}
}
}
@@ -520,7 +525,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("CTU下发出库任务失败:" + reponseMessage?.message);
+ _logger.Info("CTU下发出库任务失败:" + reponseMessage?.message);
}
}
}
@@ -545,14 +550,14 @@ namespace Khd.Core.Wcs.Wcs
ReponseMessage? reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.code == "0")
{
- LogManager.Info("五楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("五楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":五楼CTU线程继续任务" + item.currPointId + "," + item.endPointNo);
dbContext.WcsTask.Where(t => t.objid == item.objid).Update(t => new WcsTask() { taskStatus = 4 });
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 4 });
}
else
{
- LogManager.Info("CTU第一次下发继续任务失败:" + reponseMessage?.message);
+ _logger.Info("CTU第一次下发继续任务失败:" + reponseMessage?.message);
}
}
}
@@ -569,7 +574,7 @@ namespace Khd.Core.Wcs.Wcs
ReponseMessage? reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.code == "0")
{
- LogManager.Info("五楼CTU线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("五楼CTU线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":五楼CTU线程下发任务" + item.currPointId + "," + item.endPointNo);
dbContext.WcsTask.Where(t => t.objid == item.objid).Update(t => new WcsTask() { taskStatus = 4 });
dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 4 });
@@ -577,13 +582,13 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("CTU第二次下发继续任务失败:" + reponseMessage?.message);
+ _logger.Info("CTU第二次下发继续任务失败:" + reponseMessage?.message);
}
}
}
else if (item.taskStatus == 5)
{
- LogManager.Info("五楼CTU线程完成任务" + item.objid);
+ _logger.Info("五楼CTU线程完成任务" + item.objid);
Console.WriteLine(DateTime.Now + ":五楼CTU线程完成任务" + item.currPointNo + "," + item.endPointNo);
if (item.taskType == 30)//出库任务
{
@@ -594,7 +599,6 @@ namespace Khd.Core.Wcs.Wcs
wmsRawOutstockDetail.updateDate = DateTime.Now;
dbContext.Update(wmsRawOutstockDetail);
}
-
WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation
.First(t => t.locationId == item.currPointId && t.warehouseFloor == 5);
wmsBaseLocation.locationStatus = "1";
@@ -670,7 +674,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
finally
{
@@ -699,11 +703,11 @@ namespace Khd.Core.Wcs.Wcs
var executeReponse = JsonConvert.DeserializeObject(executeResult);
if (executeReponse != null && executeReponse.code == "0")
{
- LogManager.Info("下发CTU执行入库任务成功");
+ _logger.Info("下发CTU执行入库任务成功");
}
else
{
- LogManager.Info("下发CTU执行入库任务失败");
+ _logger.Info("下发CTU执行入库任务失败");
Console.WriteLine($"{DateTime.Now}:下发CTU执行入库任务失败" + executeReponse?.message);
ExecuteInTask(baseEquip);
Thread.Sleep(1000);
diff --git a/src/Khd.Core.Wcs/Wcs/FiveFloorPoint.cs b/src/Khd.Core.Wcs/Wcs/FiveFloorPoint.cs
index 9b58004..f1c5220 100644
--- a/src/Khd.Core.Wcs/Wcs/FiveFloorPoint.cs
+++ b/src/Khd.Core.Wcs/Wcs/FiveFloorPoint.cs
@@ -1,5 +1,6 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
@@ -18,10 +19,10 @@ namespace Khd.Core.Wcs.Wcs
private readonly IHost _host;
private readonly BasePlcpoint LineRFID;
private readonly BasePlcpoint LineSignal;
-
+ private readonly LoggerUtils _logger = new LoggerUtils();
int FloorNo { get; set; }
string EquipNo = "";
- public FiveFloorPoint(IHost host, Plc.S7.Plc plc, int floor)
+ public FiveFloorPoint(IHost host, int floor)
{
this._host = host;
FloorNo = floor;
@@ -37,9 +38,10 @@ namespace Khd.Core.Wcs.Wcs
var FlowPointThread = new Thread(MonitorInLocatorPoint);
FlowPointThread.IsBackground = true;
+ FlowPointThread.Name = "FiveFloorPoint";
FlowPointThread.Start();
Console.WriteLine(DateTime.Now + ":五楼接驳位调度启动成功");
- LogManager.Info("五楼接驳位调度启动成功");
+ _logger.Info("五楼接驳位调度启动成功");
}
public void MonitorInLocatorPoint()
@@ -83,104 +85,84 @@ namespace Khd.Core.Wcs.Wcs
.ToList();
if (wmsBaseLocations.Count > 0)
{
- List containerCodes = wmsBaseLocations
- .Where(t => t.locDeep == 1)
- .Select(t => t.containerCode).ToList();//深库位的托盘
- List mesBasePalletInfos = dbContext.MesBasePalletInfo
- .Where(t => t.materialId == wcsTask.materialId)
- .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)
- && a.b.locColumn == b.locColumn
- && b.locationStatus == "1"
- && string.IsNullOrEmpty(b.containerCode)
- select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
-
- WmsBaseLocation? wmsBaseLocation = null;
- 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();//找不到再找任意库位
- //深浅库位问题?库位入库优先级等
-
- var AgvEquip = StaticData.BaseEquip.First(t => t.objid == 28);//5楼叉车
- if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null)
+ MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.Where(t => t.palletInfoCode == rfid).FirstOrDefault();
+ if (mesBasePalletInfo != null)
{
- WcsTask newTask = CoreMapper.Map(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)//如果不是一楼来的,需要通过接口确认入库(质检通过后,点击继续入库)
+ MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
+ if (mesBaseBarcodeInfo != null)
{
- newTask.useFlag = 0;
- }
- else
- {
- newTask.useFlag = 1;
- }
- wmsBaseLocation.locationStatus = "2";
- dbContext.Update(wmsBaseLocation);
- dbContext.Remove(wcsTask);
+ List containerCodes = wmsBaseLocations
+ .Where(t => t.locDeep == 1)
+ .Select(t => t.containerCode).ToList();//深库位的托盘
+ List mesBasePalletInfos = dbContext.MesBaseBarcodeInfo
+ .Where(t => t.materialId == wcsTask.materialId)
+ .Where(t => t.saleOrderId == mesBaseBarcodeInfo.saleOrderId)
+ .Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料
- dbContext.Add(newTask);
- WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
- dbContext.Add(wcsTaskLog);
- dbContext.SaveChanges();
- }
- else
- {
- Console.WriteLine(DateTime.Now + ":五楼接驳位调度入库任务,未找到库位");
- LogManager.Info("五楼接驳位调度入库任务,未找到库位");
+ 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)
+ && a.b.locColumn == b.locColumn
+ && b.locationStatus == "1"
+ && string.IsNullOrEmpty(b.containerCode)
+ select new { a.b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
+
+ WmsBaseLocation? wmsBaseLocation = null;
+ 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();//找不到再找任意库位
+ //深浅库位问题?库位入库优先级等
+
+ var AgvEquip = StaticData.BaseEquip.First(t => t.objid == 28);//5楼叉车
+ if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null)
+ {
+ WcsTask newTask = CoreMapper.Map(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);
+
+ dbContext.Add(newTask);
+ WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
+ dbContext.Add(wcsTaskLog);
+ dbContext.SaveChanges();
+ }
+ else
+ {
+ Console.WriteLine(DateTime.Now + ":五楼接驳位调度入库任务,未找到库位");
+ _logger.Info("五楼接驳位调度入库任务,未找到库位");
+ }
+ }
}
}
}
else if (wcsTask.taskStatus == 6) //出库任务,小车任务是完成状态
{
- //int? floor = 1;
- //var wmsProductOutstock = dbContext.WmsProductOutstock.FirstOrDefault(t => t.productOutstockId == wcsTask.orderId);
- //if (wmsProductOutstock != null)
- //{
- // var endEquip = StaticData.BaseEquip.FirstOrDefault(t => t.equipNo == wmsProductOutstock.endStationCode);
- // if (endEquip != null)
- // {
- // floor = endEquip.floorNo;
- // }
- //}
- //else
- //{
- // var wmsRawOutstock = dbContext.WmsRawOutstock.FirstOrDefault(t => t.rawOutstockId == wcsTask.orderId);
- // if (wmsRawOutstock != null)
- // {
- // var endEquip = StaticData.BaseEquip.FirstOrDefault(t => t.equipNo == wmsRawOutstock.endStationCode);
- // if (endEquip != null)
- // {
- // floor = endEquip.floorNo;
- // }
- // }
- //}
- //if (floor == 0)
- //{
- // Console.WriteLine($"{DateTime.Now}:5楼接驳位未找到目的地楼层");
- // LogManager.Info("5楼接驳位未找到目的地楼层");
- // Thread.Sleep(1000);
- // continue;
- //}
BaseEquip nextEquip = StaticData.BaseEquip.First(t => t.equipType == 2);//提升机
dbContext.Remove(wcsTask);
WcsTask newTask = CoreMapper.Map(wcsTask);
@@ -224,7 +206,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
finally
{
diff --git a/src/Khd.Core.Wcs/Wcs/FourthFloorPoint.cs b/src/Khd.Core.Wcs/Wcs/FourthFloorPoint.cs
index 873c5b9..b00be36 100644
--- a/src/Khd.Core.Wcs/Wcs/FourthFloorPoint.cs
+++ b/src/Khd.Core.Wcs/Wcs/FourthFloorPoint.cs
@@ -1,5 +1,6 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
using Masuit.Tools.Logging;
@@ -14,6 +15,7 @@ namespace Khd.Core.Wcs.Wcs
///
public class FourthFloorPoint
{
+ private readonly LoggerUtils _logger = new LoggerUtils();
private readonly int Floor;
private readonly IHost _host;
private readonly BasePlcpoint LineRFID;
@@ -29,6 +31,8 @@ namespace Khd.Core.Wcs.Wcs
public void StartPoint()
{
Thread MonitorInLocatorPointThread = new Thread(MonitorInLocatorPoint);
+ MonitorInLocatorPointThread.IsBackground = true;
+ MonitorInLocatorPointThread.Name = "FourthFloorPoint";
MonitorInLocatorPointThread.Start();
}
@@ -79,7 +83,7 @@ namespace Khd.Core.Wcs.Wcs
if (floor == 0)
{
Console.WriteLine($"{DateTime.Now}:4楼接驳位未找到目的地楼层");
- LogManager.Info("4楼接驳位未找到目的地楼层");
+ _logger.Info("4楼接驳位未找到目的地楼层");
Thread.Sleep(1000);
continue;
}
@@ -131,7 +135,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
finally
{
diff --git a/src/Khd.Core.Wcs/Wcs/SecondFloorAGV.cs b/src/Khd.Core.Wcs/Wcs/SecondFloorAGV.cs
index a3aff6e..0b7bcda 100644
--- a/src/Khd.Core.Wcs/Wcs/SecondFloorAGV.cs
+++ b/src/Khd.Core.Wcs/Wcs/SecondFloorAGV.cs
@@ -1,6 +1,7 @@
using Khd.Core.Domain.Dto.webapi;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
@@ -19,11 +20,11 @@ namespace Khd.Core.Wcs.Wcs
public class SecondFloorAGV
{
private readonly IHost _host;
-
+ private readonly LoggerUtils _logger = new LoggerUtils();
int FloorNo { get; set; }
int EquipID = 8; //2楼AGV
- public SecondFloorAGV(IHost host, Plc.S7.Plc plc, int floor)
+ public SecondFloorAGV(IHost host, int floor)
{
this._host = host;
FloorNo = floor;
@@ -36,9 +37,11 @@ namespace Khd.Core.Wcs.Wcs
{
Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
+ FlowPointThread.IsBackground = true;
+ FlowPointThread.Name = "SecondFloorAGV";
FlowPointThread.Start();
Console.WriteLine(DateTime.Now + ":二楼AGV上件扫描监听启动成功");
- LogManager.Info("二楼AGV上件扫描监听启动成功");
+ _logger.Info("二楼AGV上件扫描监听启动成功");
}
public void MonitorInLocatorPoint()
@@ -90,7 +93,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":二楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -100,7 +103,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 56)//废料工位-库位
@@ -131,7 +134,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":二楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -141,7 +144,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 49)//小包出口-库位
@@ -172,7 +175,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":二楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -182,7 +185,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("二楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("二楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 57)//周转位-小包入口
@@ -212,7 +215,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":二楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -222,7 +225,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 50)//库位-提升机
@@ -255,7 +258,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":二楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -267,7 +270,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
}
@@ -300,7 +303,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":二楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -310,7 +313,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 53)//提升机-废料工位
@@ -339,7 +342,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":二楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -349,7 +352,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 54)//周转位-废料工位
@@ -381,7 +384,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":二楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -391,7 +394,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
}
@@ -422,7 +425,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":二楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -432,7 +435,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 59)//周转位-小包入口
@@ -464,7 +467,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("二楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":二楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -474,14 +477,14 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
}
else
{
{
- LogManager.Info("二楼AGV线程完成任务" + item.objid);
+ _logger.Info("二楼AGV线程完成任务" + item.objid);
if (item.taskStatus == 3)
{
if (item.currPointId == lineEquip.objid)
@@ -759,7 +762,7 @@ namespace Khd.Core.Wcs.Wcs
catch (Exception ex)
{
transaction.Rollback();
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
}
else if (item.taskType == 56)//废料区到周转区
@@ -825,7 +828,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
finally
{
diff --git a/src/Khd.Core.Wcs/Wcs/SecondFloorLine.cs b/src/Khd.Core.Wcs/Wcs/SecondFloorLine.cs
index 19f8327..1ea8831 100644
--- a/src/Khd.Core.Wcs/Wcs/SecondFloorLine.cs
+++ b/src/Khd.Core.Wcs/Wcs/SecondFloorLine.cs
@@ -1,6 +1,7 @@
using Azure.Identity;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
@@ -16,9 +17,10 @@ namespace Khd.Core.Wcs.Wcs
///
public class SecondFloorLine
{
+ private readonly LoggerUtils _logger = new LoggerUtils();
private readonly IHost _host;
int FloorNo { get; set; }
- public SecondFloorLine(IHost host, Plc.S7.Plc plc, int floor)
+ public SecondFloorLine(IHost host, int floor)
{
this._host = host;
FloorNo = floor;
@@ -31,9 +33,11 @@ namespace Khd.Core.Wcs.Wcs
{
Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
+ FlowPointThread.IsBackground = true;
+ FlowPointThread.Name = "SecondFloorLine";
FlowPointThread.Start();
Console.WriteLine(DateTime.Now + ":二楼码垛输送线调度启动成功");
- LogManager.Info("二楼码垛输送线调度启动成功");
+ _logger.Info("二楼码垛输送线调度启动成功");
}
public void MonitorInLocatorPoint()
@@ -89,7 +93,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
Console.WriteLine(DateTime.Now + ":二楼码垛输送线生成请求空托盘任务成功:" + wcsTask.objid);
- LogManager.Info("二楼码垛输送线生成请求空托盘任务成功:" + wcsTask.objid);
+ _logger.Info("二楼码垛输送线生成请求空托盘任务成功:" + wcsTask.objid);
}
else//二楼周转区没有空托盘
{
@@ -126,7 +130,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
Console.WriteLine(DateTime.Now + ":二楼码垛输送线生成3楼Agv出库任务成功:" + wcsTask.objid);
- LogManager.Info("二楼码垛输送线生成3楼Agv出库任务成功:" + wcsTask.objid);
+ _logger.Info("二楼码垛输送线生成3楼Agv出库任务成功:" + wcsTask.objid);
}
}
else
@@ -168,7 +172,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
Console.WriteLine(DateTime.Now + ":二楼码垛输送线生成手动托盘任务成功:" + wcsTaskManual.objid);
- LogManager.Info("二楼码垛输送线生成手动托盘任务成功:" + wcsTaskManual.objid);
+ _logger.Info("二楼码垛输送线生成手动托盘任务成功:" + wcsTaskManual.objid);
}
}
else if (startEquip.emptyCount > SystemData.maxTray)//如果托盘库大于五个,出一个
@@ -207,14 +211,14 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
Console.WriteLine(DateTime.Now + ":二楼码垛输送线生成手动托盘任务成功:" + wcsTaskManual.objid);
- LogManager.Info("二楼码垛输送线生成手动托盘任务成功:" + wcsTaskManual.objid);
+ _logger.Info("二楼码垛输送线生成手动托盘任务成功:" + wcsTaskManual.objid);
}
}
else
{
//todo:没有空托盘
Console.WriteLine(DateTime.Now + ":二楼码垛输送线没有空托盘");
- LogManager.Info("二楼码垛输送线没有空托盘");
+ _logger.Info("二楼码垛输送线没有空托盘");
}
}
}
@@ -296,7 +300,7 @@ namespace Khd.Core.Wcs.Wcs
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
Console.WriteLine(DateTime.Now + ":二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid);
- LogManager.Info("二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid);
+ _logger.Info("二楼码垛输送线生成入库托盘任务成功:" + wcsTask.objid);
}
else
{
@@ -328,7 +332,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
finally
{
diff --git a/src/Khd.Core.Wcs/Wcs/SecondFloorPoint.cs b/src/Khd.Core.Wcs/Wcs/SecondFloorPoint.cs
index c3a5413..8a96efb 100644
--- a/src/Khd.Core.Wcs/Wcs/SecondFloorPoint.cs
+++ b/src/Khd.Core.Wcs/Wcs/SecondFloorPoint.cs
@@ -1,5 +1,6 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
@@ -13,11 +14,12 @@ namespace Khd.Core.Wcs.Wcs
///
public class SecondFloorPoint
{
+ private readonly LoggerUtils _logger = new LoggerUtils();
private readonly IHost _host;
private readonly BasePlcpoint LineRFID;
private readonly BasePlcpoint LineSignal;
int FloorNo { get; set; }
- public SecondFloorPoint(IHost host, Plc.S7.Plc plc, int floor)
+ public SecondFloorPoint(IHost host,int floor)
{
this._host = host;
FloorNo = floor;
@@ -31,9 +33,11 @@ namespace Khd.Core.Wcs.Wcs
{
Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
+ FlowPointThread.Name = "SecondFloorPoint";
+ FlowPointThread.IsBackground = true;
FlowPointThread.Start();
Console.WriteLine(DateTime.Now + ":二楼接驳位扫描线程启动");
- LogManager.Info("二楼接驳位扫描线程启动");
+ _logger.Info("二楼接驳位扫描线程启动");
}
public void MonitorInLocatorPoint()
@@ -91,7 +95,7 @@ namespace Khd.Core.Wcs.Wcs
WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
- LogManager.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
+ _logger.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
Console.WriteLine(DateTime.Now + ":二楼接驳位生成任务入库成功,托盘号:" + rfid);
}
else if (agvPutValue != null && Convert.ToInt32(agvPutValue) == 1)
@@ -118,7 +122,7 @@ namespace Khd.Core.Wcs.Wcs
WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
- LogManager.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
+ _logger.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
Console.WriteLine(DateTime.Now + ":二楼接驳位生成任务入库成功,托盘号:" + rfid);
}
}
@@ -148,7 +152,7 @@ namespace Khd.Core.Wcs.Wcs
WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
- LogManager.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
+ _logger.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
Console.WriteLine(DateTime.Now + ":二楼接驳位生成任务入库成功,托盘号:" + rfid);
}
else if (agvPutValue != null && Convert.ToInt32(agvPutValue) == 0)
@@ -175,7 +179,7 @@ namespace Khd.Core.Wcs.Wcs
WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
- LogManager.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
+ _logger.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
Console.WriteLine(DateTime.Now + ":二楼接驳位生成任务入库成功,托盘号:" + rfid);
}
}
@@ -202,7 +206,7 @@ namespace Khd.Core.Wcs.Wcs
WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
- LogManager.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
+ _logger.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
Console.WriteLine(DateTime.Now + ":二楼接驳位生成任务入库成功,托盘号:" + rfid);
}
else
@@ -229,7 +233,7 @@ namespace Khd.Core.Wcs.Wcs
WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
- LogManager.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
+ _logger.Info("二楼接驳位生成任务入库成功,托盘号:" + rfid);
Console.WriteLine(DateTime.Now + ":二楼接驳位生成任务入库成功,托盘号:" + rfid);
}
}
@@ -262,7 +266,7 @@ namespace Khd.Core.Wcs.Wcs
WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
- LogManager.Info("二楼接驳位生成任务出库成功,托盘号:" + rfid);
+ _logger.Info("二楼接驳位生成任务出库成功,托盘号:" + rfid);
Console.WriteLine(DateTime.Now + ":二楼接驳位生成任务出库成功,托盘号:" + rfid);
}
else//一般情况下是废料的任务
@@ -289,7 +293,7 @@ namespace Khd.Core.Wcs.Wcs
WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
- LogManager.Info("二楼接驳位生成任务出库成功,托盘号:" + rfid);
+ _logger.Info("二楼接驳位生成任务出库成功,托盘号:" + rfid);
Console.WriteLine(DateTime.Now + ":二楼接驳位生成任务出库成功,托盘号:" + rfid);
}
@@ -318,7 +322,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
finally
{
diff --git a/src/Khd.Core.Wcs/Wcs/SystemTimer.cs b/src/Khd.Core.Wcs/Wcs/SystemTimer.cs
index 0aa3514..85ca5b2 100644
--- a/src/Khd.Core.Wcs/Wcs/SystemTimer.cs
+++ b/src/Khd.Core.Wcs/Wcs/SystemTimer.cs
@@ -1,6 +1,7 @@
using Khd.Core.Domain.Dto.webapi;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
using Masuit.Tools;
@@ -13,6 +14,7 @@ namespace Khd.Core.Wcs.Wcs
{
public class SystemTimer
{
+ private readonly LoggerUtils _logger = new LoggerUtils();
private readonly IHost host;
private Plc.S7.Plc Plc30 = StaticData.PlcDic[0];
private Plc.S7.Plc Plc31 = StaticData.PlcDic[1];
@@ -27,18 +29,21 @@ namespace Khd.Core.Wcs.Wcs
{
var messageSynchronousThread = new Thread(MessageSynchronousLogic)
{
+ Name = "MessageSynchronousThread",
IsBackground = true
};
messageSynchronousThread.Start();//陈工设备信息推送
var PlcHeartBeat30Thread = new Thread(PlcHeartBeat30Logic)
{
+ Name="PlcHeartBeat30Thread",
IsBackground = true
};
PlcHeartBeat30Thread.Start();//脉冲
var PlcHeartBeat31Thread = new Thread(PlcHeartBeat31Logic)
{
+ Name = "PlcHeartBeat31Thread",
IsBackground = true
};
PlcHeartBeat31Thread.Start();//脉冲
@@ -53,20 +58,13 @@ namespace Khd.Core.Wcs.Wcs
private void PlcHeartBeat30Logic(object? obj)
{
BasePlcpoint HeartBeat30 = StaticData.BasePlcpointList.First(t => t.plcpointNo == "HeartBeat30");
- int heartBeatCount = 0;
+ bool heartBeatCount = false;
while (true)
{
try
{
- if (heartBeatCount == 0)
- {
- heartBeatCount = 1;
- }
- else
- {
- heartBeatCount = 0;
- }
- StaticData.PlcDic[0].WriteToPoint(HeartBeat30.plcpointAddress, heartBeatCount.ToString(), HeartBeat30.plcpointType?.ToString());
+ heartBeatCount = !heartBeatCount;
+ StaticData.PlcDic[0].WriteToPoint(HeartBeat30.plcpointAddress, heartBeatCount, HeartBeat30.plcpointLength?.ToString());
}
catch (Exception ex)
{
@@ -88,7 +86,6 @@ namespace Khd.Core.Wcs.Wcs
//报警
}
}
- LogManager.Error(ex);
}
Thread.Sleep(1000);
}
@@ -101,20 +98,13 @@ namespace Khd.Core.Wcs.Wcs
private void PlcHeartBeat31Logic(object? obj)
{
BasePlcpoint HeartBeat31 = StaticData.BasePlcpointList.First(t => t.plcpointNo == "CTUHeart");
- int heartBeatCount = 0;
+ bool heartBeatCount =false;
while (true)
{
try
{
- if (heartBeatCount == 0)
- {
- heartBeatCount = 1;
- }
- else
- {
- heartBeatCount = 0;
- }
- StaticData.PlcDic[1].WriteToPoint(HeartBeat31.plcpointAddress, heartBeatCount.ToString(), HeartBeat31.plcpointType?.ToString());
+ heartBeatCount = !heartBeatCount;
+ StaticData.PlcDic[1].WriteToPoint(HeartBeat31.plcpointAddress, heartBeatCount, HeartBeat31.plcpointLength?.ToString());
}
catch (Exception ex)
{
@@ -136,7 +126,6 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
}
Thread.Sleep(1000);
}
diff --git a/src/Khd.Core.Wcs/Wcs/ThirdFloorAGV.cs b/src/Khd.Core.Wcs/Wcs/ThirdFloorAGV.cs
index b2fdec6..98ea929 100644
--- a/src/Khd.Core.Wcs/Wcs/ThirdFloorAGV.cs
+++ b/src/Khd.Core.Wcs/Wcs/ThirdFloorAGV.cs
@@ -1,6 +1,7 @@
using Khd.Core.Domain.Dto.webapi;
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
@@ -18,11 +19,12 @@ namespace Khd.Core.Wcs.Wcs
///
public class ThirdFloorAGV
{
+ private readonly LoggerUtils _logger = new LoggerUtils();
private readonly IHost _host;
int FloorNo { get; set; }
private readonly BasePlcpoint putTrayPoint;
private readonly BasePlcpoint getTrayPoint;
- public ThirdFloorAGV(IHost host, Plc.S7.Plc plc, int floor)
+ public ThirdFloorAGV(IHost host, int floor)
{
this._host = host;
FloorNo = floor;
@@ -37,13 +39,17 @@ namespace Khd.Core.Wcs.Wcs
{
Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
+ FlowPointThread.Name = "ThirdFloorAGVTrayIn";
+ FlowPointThread.IsBackground = true;
FlowPointThread.Start();
Thread FZJThread = new Thread(MonitorInFZJPoint);
+ FZJThread.Name = "ThirdFloorAGV";
+ FZJThread.IsBackground = true;
FZJThread.Start();
Console.WriteLine(DateTime.Now + ":三楼AGV 启动上件扫描监听");
- LogManager.Info("三楼AGV 启动上件扫描监听");
+ _logger.Info("三楼AGV 启动上件扫描监听");
}
private void MonitorInFZJPoint(object? obj)
@@ -56,9 +62,7 @@ namespace Khd.Core.Wcs.Wcs
{
dbContext.ChangeTracker.Entries().ToList().ForEach(e => e.Reload());
var getTrayValue = StaticData.PlcDic[2].Read(getTrayPoint.plcpointAddress);
- if (getTrayValue != null && Convert.ToInt32(getTrayValue) == 1)
- //BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 31);
- //if (baseEquip.emptyCount == 1)
+ if (getTrayValue != null && Convert.ToBoolean(getTrayValue))
{
var task = dbContext.WcsTask.Where(t => t.taskType == 42 && t.useFlag == 0).FirstOrDefault();
if (task != null)
@@ -85,7 +89,7 @@ namespace Khd.Core.Wcs.Wcs
WcsTaskLog wcsTaskLog = CoreMapper.Map(task);
dbContext.Add(wcsTaskLog);
dbContext.SaveChanges();
- LogManager.Info("三楼AGV 生成空托盘入收集架任务:" + task.objid);
+ _logger.Info("三楼AGV 生成空托盘入收集架任务:" + task.objid);
}
}
}
@@ -110,7 +114,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
Thread.Sleep(3000);
}
@@ -161,7 +165,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":三楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -171,7 +175,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("五楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("五楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 39)//提升机-库位
@@ -202,7 +206,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":三楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -212,55 +216,60 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("三楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("三楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 41)//库位-翻转机
{
- WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.FirstOrDefault(t => t.rawOutstockId == item.orderId && t.executeStatus == "0");
- if (wmsRawOutstockDetail != null)
+ BasePlcpoint basePlcpoint = StaticData.BasePlcpointList.First(t => t.plcpointNo == "putTray");
+ var callMaterial = StaticData.PlcDic[2].Read(basePlcpoint.plcpointAddress);
+ if (callMaterial != null&&Convert.ToBoolean(callMaterial))
{
- wmsRawOutstockDetail.executeStatus = "1";
- wmsRawOutstockDetail.outstockTime = DateTime.Now;
- BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == 31);
- WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
+ WmsRawOutstockDetail? wmsRawOutstockDetail = dbContext.WmsRawOutstockDetail.FirstOrDefault(t => t.rawOutstockId == item.orderId && t.executeStatus == "0");
+ if (wmsRawOutstockDetail != null)
+ {
+ wmsRawOutstockDetail.executeStatus = "1";
+ wmsRawOutstockDetail.outstockTime = DateTime.Now;
+ BaseEquip endEquip = StaticData.BaseEquip.First(t => t.objid == 31);
+ WmsBaseLocation wmsBaseLocation = dbContext.WmsBaseLocation.First(t => t.locationId == item.currPointId);
- var agvTask = new RequestAGVTaskDto
- {
- reqCode =StaticData.SnowId.NextId().ToString(),
- positionCodePath = new List
- {
- new ()
+ var agvTask = new RequestAGVTaskDto
{
- positionCode=wmsBaseLocation.agvPositionCode,
- type="00"
+ reqCode = StaticData.SnowId.NextId().ToString(),
+ positionCodePath = new List
+ {
+ new ()
+ {
+ positionCode=wmsBaseLocation.agvPositionCode,
+ type="00"
+ },
+ new ()
+ {
+ positionCode=endEquip.agvPositionCode,
+ type="00"
+ }
},
- new ()
+ taskTyp = baseDictionary.dicValue,
+ ctnrTyp = "2",
+ };
+ string message = JsonConvert.SerializeObject(agvTask);
+ string result = HttpHelper.SendPostMessage(baseEquip.serverIp, baseEquip.serverPort.Value, "rcms/services/rest/hikRpcService/genAgvSchedulingTask", message);
+ var reponseMessage = JsonConvert.DeserializeObject(result);
+ if (reponseMessage != null && reponseMessage.message == "成功")
{
- positionCode=endEquip.agvPositionCode,
- type="00"
+ _logger.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ Console.WriteLine(DateTime.Now + ":三楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
+ item.taskCode = reponseMessage.data;
+ item.taskStatus = 1;
+ dbContext.Update(wmsRawOutstockDetail);
+ dbContext.Update(item);
+ dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 1 });
+ dbContext.SaveChanges();
+ }
+ else
+ {
+ _logger.Info("三楼Agv下发任务失败" + item.taskType + message);
}
- },
- taskTyp = baseDictionary.dicValue,
- ctnrTyp = "2",
- };
- string message = JsonConvert.SerializeObject(agvTask);
- string result = HttpHelper.SendPostMessage(baseEquip.serverIp, baseEquip.serverPort.Value, "rcms/services/rest/hikRpcService/genAgvSchedulingTask", message);
- var reponseMessage = JsonConvert.DeserializeObject(result);
- if (reponseMessage != null && reponseMessage.message == "成功")
- {
- LogManager.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
- Console.WriteLine(DateTime.Now + ":三楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
- item.taskCode = reponseMessage.data;
- item.taskStatus = 1;
- dbContext.Update(wmsRawOutstockDetail);
- dbContext.Update(item);
- dbContext.WcsTaskLog.Where(t => t.objid == item.objid).Update(t => new WcsTaskLog() { taskStatus = 1 });
- dbContext.SaveChanges();
- }
- else
- {
- LogManager.Info("三楼Agv下发任务失败" + item.taskType + message);
}
}
}
@@ -293,7 +302,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":三楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -303,7 +312,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("三楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("三楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 42)//翻转机-收集架
@@ -335,7 +344,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":三楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -345,7 +354,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("三楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("三楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 43)//收集架-周转区
@@ -378,7 +387,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":三楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -388,7 +397,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("三楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("三楼Agv下发任务失败" + item.taskType + message);
}
}
else if (item.taskType == 44)//周转区-提升机
@@ -423,7 +432,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":三楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -435,7 +444,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("三楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("三楼Agv下发任务失败" + item.taskType + message);
}
}
}
@@ -470,7 +479,7 @@ namespace Khd.Core.Wcs.Wcs
var reponseMessage = JsonConvert.DeserializeObject(result);
if (reponseMessage != null && reponseMessage.message == "成功")
{
- LogManager.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
+ _logger.Info("三楼楼AGV线程下发任务" + agvTask.ToJsonString() + "\n" + message);
Console.WriteLine(DateTime.Now + ":三楼AGV线程下发任务" + item.currPointNo + "," + item.endPointNo);
item.taskCode = reponseMessage.data;
item.taskStatus = 1;
@@ -482,7 +491,7 @@ namespace Khd.Core.Wcs.Wcs
}
else
{
- LogManager.Info("三楼Agv下发任务失败" + item.taskType + message);
+ _logger.Info("三楼Agv下发任务失败" + item.taskType + message);
}
}
}
@@ -501,7 +510,7 @@ namespace Khd.Core.Wcs.Wcs
var RfidValue = StaticData.PlcDic[0].ReadRFID(Rfid.plcpointAddress);
if (lineSignalValue == null || item.containerNo != RfidValue || Convert.ToInt32(lineSignalValue) == 0)
{
- LogManager.Info($"三楼Agv继续任务失败,所取货物与任务不符,任务货物为{item.containerNo},RFID为{RfidValue},线路信号为{lineSignalValue}");
+ _logger.Info($"三楼Agv继续任务失败,所取货物与任务不符,任务货物为{item.containerNo},RFID为{RfidValue},线路信号为{lineSignalValue}");
Console.WriteLine($"{DateTime.Now}:三楼Agv继续任务失败,所取货物与任务不符,任务货物为{item.containerNo},RFID为{RfidValue},线路信号为{lineSignalValue}");
Thread.Sleep(1000);
continue;
@@ -513,7 +522,7 @@ namespace Khd.Core.Wcs.Wcs
var lineSignalValue = StaticData.PlcDic[0].Read(lineSignal.plcpointAddress);
if (lineSignalValue == null || Convert.ToInt32(lineSignalValue) == 1)
{
- LogManager.Info($"三楼Agv继续任务失败,提升机有货物");
+ _logger.Info($"三楼Agv继续任务失败,提升机有货物");
Console.WriteLine($"{DateTime.Now}:三楼Agv继续任务失败,提升机有货物");
Thread.Sleep(1000);
continue;
@@ -572,7 +581,7 @@ namespace Khd.Core.Wcs.Wcs
catch (Exception ex)
{
transaction.Rollback();
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
}
if (item.taskType == 39)//入库
@@ -773,7 +782,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
finally
{
diff --git a/src/Khd.Core.Wcs/Wcs/ThirdFloorPoint.cs b/src/Khd.Core.Wcs/Wcs/ThirdFloorPoint.cs
index 95c00b4..0a11861 100644
--- a/src/Khd.Core.Wcs/Wcs/ThirdFloorPoint.cs
+++ b/src/Khd.Core.Wcs/Wcs/ThirdFloorPoint.cs
@@ -1,5 +1,6 @@
using Khd.Core.Domain.Models;
using Khd.Core.EntityFramework;
+using Khd.Core.Library;
using Khd.Core.Library.Mapper;
using Khd.Core.Plc.S7;
using Khd.Core.Wcs.Global;
@@ -15,11 +16,12 @@ namespace Khd.Core.Wcs.Wcs
///
public class ThirdFloorPoint
{
+ private readonly LoggerUtils _logger = new LoggerUtils();
private readonly IHost _host;
private readonly BasePlcpoint LineRFID;
private readonly BasePlcpoint LineSignal;
int FloorNo { get; set; }
- public ThirdFloorPoint(IHost host, Plc.S7.Plc plc, int floor)
+ public ThirdFloorPoint(IHost host, int floor)
{
this._host = host;
FloorNo = floor;
@@ -33,9 +35,11 @@ namespace Khd.Core.Wcs.Wcs
{
Thread FlowPointThread = new Thread(MonitorInLocatorPoint);
+ FlowPointThread.IsBackground = true;
+ FlowPointThread.Name = "ThirdFloorPoint";
FlowPointThread.Start();
Console.WriteLine(DateTime.Now + ":三楼接驳位调度启动成功");
- LogManager.Info("三楼接驳位调度启动成功");
+ _logger.Info("三楼接驳位调度启动成功");
}
public void MonitorInLocatorPoint()
@@ -63,66 +67,75 @@ namespace Khd.Core.Wcs.Wcs
{
if (wcsTask.taskStatus == 5)//提升机任务是完成状态
{
- 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.locationStatus == "1")
- .OrderByDescending(t => t.locRow)
- .ThenByDescending(t => t.locColumn)
- .ToList();
-
- List containerCodes = wmsBaseLocations.Where(t => t.locDeep == 1).Select(t => t.containerCode).ToList();//深库位的托盘
- List mesBasePalletInfos = dbContext.MesBasePalletInfo
- .Where(t => t.materialId == wcsTask.materialId)
- .Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料
-
-
- var bill = from a in mesBasePalletInfos
- join b in wmsBaseLocations.Where(t => t.locDeep == 1 && !string.IsNullOrEmpty(t.containerCode)) on a.palletInfoCode equals b.containerCode
- select new { b };//等于当前任务的物料的托盘的库位信息
-
-
- var outBill = from b in wmsBaseLocations
- from a in bill
- where a.b.layerNum == b.layerNum
- && 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 { b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
- WmsBaseLocation? wmsBaseLocation = outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位
- wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位
- wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
-
- if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null)
+ MesBasePalletInfo? mesBasePalletInfo = dbContext.MesBasePalletInfo.Where(t => t.palletInfoCode == rfid).FirstOrDefault();
+ if (mesBasePalletInfo != null)
{
- dbContext.Remove(wcsTask);
- WcsTask newTask = CoreMapper.Map(wcsTask);
- newTask.objid = StaticData.SnowId.NextId();
- 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.taskType = 39;
- newTask.useFlag = 1;
- wmsBaseLocation.locationStatus = "2";
- dbContext.Update(wmsBaseLocation);
- dbContext.Add(newTask);
- WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
- dbContext.Add(wcsTaskLog);
- dbContext.SaveChanges();
- }
- else
- {
- Console.WriteLine(DateTime.Now + ":三楼楼接驳位调度入库任务,未找到库位");
- LogManager.Info("三楼接驳位调度入库任务,未找到库位");
+ MesBaseBarcodeInfo? mesBaseBarcodeInfo = dbContext.MesBaseBarcodeInfo.FirstOrDefault(t => t.barcodeInfo == mesBasePalletInfo.materialBarcode);
+ if (mesBaseBarcodeInfo != null)
+ {
+ 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.locationStatus == "1")
+ .OrderByDescending(t => t.locRow)
+ .ThenByDescending(t => t.locColumn)
+ .ToList();
+
+ List containerCodes = wmsBaseLocations.Where(t => t.locDeep == 1).Select(t => t.containerCode).ToList();//深库位的托盘
+ List mesBasePalletInfos = dbContext.MesBaseBarcodeInfo
+ .Where(t => t.materialId == wcsTask.materialId)
+ .Where(t=>t.saleOrderId== mesBaseBarcodeInfo.saleOrderId)
+ .Where(t => containerCodes.Contains(t.palletInfoCode)).ToList();//深库位的托盘的物料等于当前任务的物料
+
+ var bill = from a in mesBasePalletInfos
+ join b in wmsBaseLocations.Where(t => t.locDeep == 1 && !string.IsNullOrEmpty(t.containerCode)) on a.palletInfoCode equals b.containerCode
+ select new { b };//等于当前任务的物料的托盘的库位信息
+
+
+ var outBill = from b in wmsBaseLocations
+ from a in bill
+ where a.b.layerNum == b.layerNum
+ && 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 { b };//在上面的基础上获取对应托盘的外侧库位的空库位信息
+ WmsBaseLocation? wmsBaseLocation = outBill.FirstOrDefault()?.b;//先找相同物料的外侧库位
+ wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault(t => t.locDeep == 1);//找不到再找深库位
+ wmsBaseLocation ??= wmsBaseLocations.Where(t => string.IsNullOrEmpty(t.containerCode)).FirstOrDefault();//找不到再找任意库位
+
+ if (wmsBaseLocations.Count > 0 && wmsBaseLocation != null)
+ {
+ dbContext.Remove(wcsTask);
+ WcsTask newTask = CoreMapper.Map(wcsTask);
+ newTask.objid = StaticData.SnowId.NextId();
+ 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.taskType = 39;
+ newTask.useFlag = 1;
+ wmsBaseLocation.locationStatus = "2";
+ dbContext.Update(wmsBaseLocation);
+ dbContext.Add(newTask);
+ WcsTaskLog wcsTaskLog = CoreMapper.Map(newTask);
+ dbContext.Add(wcsTaskLog);
+ dbContext.SaveChanges();
+ }
+ else
+ {
+ Console.WriteLine(DateTime.Now + ":三楼楼接驳位调度入库任务,未找到库位");
+ _logger.Info("三楼接驳位调度入库任务,未找到库位");
+ }
+ }
}
+
}
else if (wcsTask.taskStatus == 6)//小车任务是完成状态,说明是出库
{
@@ -167,7 +180,7 @@ namespace Khd.Core.Wcs.Wcs
}
}
- LogManager.Error(ex);
+ _logger.Error(ex.Message + "\n" + ex.StackTrace);
}
finally
{
diff --git a/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs b/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs
index 9804ed7..0041c27 100644
--- a/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs
+++ b/src/Khd.Core.Wpf/Form/FormBoardT.xaml.cs
@@ -1077,6 +1077,9 @@ namespace Khd.Core.Wpf.Form
{
using var scope = _host.Services.CreateScope();
using var dbContext = scope.ServiceProvider.GetRequiredService();
+ BaseEquip baseEquip = dbContext.BaseEquip.First(t => t.objid == 10);
+ baseEquip.endStationCode = string.Empty;
+ dbContext.Update(baseEquip);
var wcsCmd = dbContext.WcsCmd
.Where(t => t.cmdStatus == 6 || t.cmdStatus == 3)
.FirstOrDefault();