diff --git a/Admin.Core.Model/Model_New/RecordSidePanelComplate.cs b/Admin.Core.Model/Model_New/RecordSidePanelComplate.cs
index 9cbae34c..97e9d77a 100644
--- a/Admin.Core.Model/Model_New/RecordSidePanelComplate.cs
+++ b/Admin.Core.Model/Model_New/RecordSidePanelComplate.cs
@@ -16,8 +16,9 @@ namespace Admin.Core.Model
///
/// 主键标识
///
- [SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, OracleSequenceName = "SEQ_RECORD_SIDEPANEL_COMPLATE")]
- public decimal ObjId { get; set; }
+ //[SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, OracleSequenceName = "SEQ_RECORD_SIDEPANEL_COMPLATE")]
+ [SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, IsIdentity = true)]
+ public int ObjId { get; set; }
///
/// 计划编号
///
@@ -52,10 +53,10 @@ namespace Admin.Core.Model
public int OutPutAmount { get; set; }
[SugarColumn(ColumnName = "DEVICE_STATUS")]
- public decimal? DeviceStatus { get; set; }
+ public string DeviceStatus { get; set; }
[SugarColumn(ColumnName = "PRODUCTION_BEAT")]
- public decimal? ProductionBeat { get; set; }
+ public string ProductionBeat { get; set; }
///
/// 记录时间
@@ -66,6 +67,6 @@ namespace Admin.Core.Model
/// 是否标识
///
[SugarColumn(ColumnName = "IS_FLAG")]
- public decimal? IsFlag { get; set; }
+ public string IsFlag { get; set; }
}
}
diff --git a/Aucma.Core.OldBoxFoam/Business/Collection.cs b/Aucma.Core.OldBoxFoam/Business/Collection.cs
index bbf5d148..c3f6ddfd 100644
--- a/Aucma.Core.OldBoxFoam/Business/Collection.cs
+++ b/Aucma.Core.OldBoxFoam/Business/Collection.cs
@@ -37,7 +37,7 @@ namespace Aucma.Core.OldBoxFoam.Business
{
try
{
- await ExecTaskMethod();
+ //await ExecTaskMethod();
return;
}
catch (Exception ex)
diff --git a/Aucma.Core.OldBoxFoam/Startup.cs b/Aucma.Core.OldBoxFoam/Startup.cs
index ee08f978..3f034ef5 100644
--- a/Aucma.Core.OldBoxFoam/Startup.cs
+++ b/Aucma.Core.OldBoxFoam/Startup.cs
@@ -67,7 +67,7 @@ namespace Aucma.Core.OldBoxFoam
//services.AddJobSetup();
//PLC
services.AddPlcSetup();
- // services.AddAucmaTaskSetup();
+ services.AddAucmaTaskSetup();
//ֱ֧ȫ :֧ System.Text.Encoding.GetEncoding("GB2312") System.Text.Encoding.GetEncoding("GB18030")
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
}
@@ -89,7 +89,7 @@ namespace Aucma.Core.OldBoxFoam
///
///
public void Configure(IApplicationBuilder app,
- IRunPlcService runPlcService)
+ IRunPlcService runPlcService, IAucamTaskService aucamTaskService)
{
// ʹþ̬ļ
app.UseStaticFiles();
@@ -98,7 +98,7 @@ namespace Aucma.Core.OldBoxFoam
// QuartzNetJobȷ
// app.UseQuartzJobMildd(tasksQzService, schedulerCenter);
- //app.AucmaTaskMildds(aucamTaskService);
+ app.AucmaTaskMildds(aucamTaskService);
//PLC
app.UsePlcMildd(runPlcService);
}
diff --git a/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs b/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs
index de2369a1..e96ec5f1 100644
--- a/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs
+++ b/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs
@@ -53,10 +53,10 @@ namespace Aucma.Core.OldBoxFoam.ViewModels
_boxFoamDataRecordServices = App.ServiceProvider.GetService();
//AucamTaskService.RefreshOldBoxFoamDataDelegateEvent += OldBoxFoamOnLoad3;
- timer2.Elapsed += new System.Timers.ElapsedEventHandler(RealTimeFoamingTask); //到达时间的时候执行事件;
- timer2.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
- timer2.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它,
- timer2.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
+ //timer2.Elapsed += new System.Timers.ElapsedEventHandler(RealTimeFoamingTask); //到达时间的时候执行事件;
+ //timer2.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
+ //timer2.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它,
+ //timer2.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
}
diff --git a/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs b/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs
index cfa8368a..6c90b693 100644
--- a/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs
+++ b/Aucma.Core.SheetMetal/Business/SheetMetalPlanTaskHandle.cs
@@ -21,22 +21,21 @@ namespace Aucma.Core.SheetMetal.Business;
///
public class SheetMetalPlanTaskHandle
{
-
+
///
/// 刷新当前正在执行的计划
///
public delegate void RefreshCurrentPlanInfo(ExecutePlanInfo planInfo);
public event RefreshCurrentPlanInfo RefreshCurrentPlanInfoEvent;
-
+
protected readonly IExecutePlanInfoServices? _executePlanInfoServices;
protected readonly IRecordSidePanelComplateServices _sidePanelComplateServices;
protected readonly IRecordBackPanelComplateServices _backPanelComplateServices;
public HwPLc.PlcModel plc1 = null;
- int completeAmount = 0;
- string planCodeTask = string.Empty;
+
public SheetMetalPlanTaskHandle()
{
- _executePlanInfoServices =
+ _executePlanInfoServices =
App.ServiceProvider.GetService();
_sidePanelComplateServices = App.ServiceProvider.GetService();
_backPanelComplateServices = App.ServiceProvider.GetService();
@@ -50,18 +49,14 @@ public class SheetMetalPlanTaskHandle
Thread.Sleep(5000);
var obj_sidePanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
var obj_backPanel = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC"));
- var productLineCode = Appsettings.app("StationInfo", "StationCode");
+
while (true)
{
- var planInfos = _executePlanInfoServices.QueryAsync(d => d.ProductLineCode.Equals(productLineCode) ).Result;
- if (planInfos == null) return;
- var planWait = planInfos.FirstOrDefault(d => d.ExecuteStatus == 2);
+ var planInfos = _executePlanInfoServices.Query(d => d.ProductLineCode.Equals("1001") && d.ExecuteStatus == 1);
- if (planWait == null)
+ if (planInfos != null)
{
- var planWaite1 = planInfos.Where(d => d.ExecuteStatus == 1);
- if (planWaite1 == null) return;
- if (planWaite1.Count() > 0)
+ if (planInfos.Count > 0)
{
ExecutePlanInfo planInfo = planInfos.First();
if (planInfo.PlanType == 1) //联合下发
@@ -90,43 +85,6 @@ public class SheetMetalPlanTaskHandle
Console.WriteLine("未获取到需要下发的任务");
}
}
- else
- {
- //获取上料数据,与计划书匹配任务结束
- //再次判断当前完工数和计划数是否一样,一样结束任务
- //List sidePanelComplates2 = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planWait.TaskCode);
-
- if (planWait.PlanType == 2)
- {
- ReadDeviceComplate_SidePanel(obj_sidePanel);
-
- #region 测试
- //byte[] info = obj_sidePanel.plc.Read("D6030", 59);
-
- //if (info == null)
- //{
- // Thread.Sleep(1000);
- // continue;
- //}
-
- ////计划编号
- //string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray());
-
- ////物料编号
- //string materialCode = Encoding.ASCII.GetString(info.Skip(20).Take(20).ToArray());
- ////完成数量
- //int complateAmount = short.Parse(bytesToHexStr(info.Skip(40).Take(1).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
-
- //if (complateAmount == planWait.PlanAmount && "2023122900001" == planCode.Replace("\0", "").Trim())
- //{
- // //数据计划
- // planWait.ExecuteStatus = 3;
- // planWait.CompleteAmount = planWait.PlanAmount;
- // _ = _executePlanInfoServices.UpdateAsync(planWait).Result;
- //}
- #endregion
- }
- }
Thread.Sleep(3000);
}
@@ -140,7 +98,6 @@ public class SheetMetalPlanTaskHandle
{
try
{
- var productLineCode = Appsettings.app("StationInfo", "ProductLineCode");
lock (string.Empty)
{
bool isComplate = true;
@@ -148,17 +105,17 @@ public class SheetMetalPlanTaskHandle
do
{
//等待计划执行完成
- List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == productLineCode && x.PlanCode == planInfo.TaskCode);
+ List sidePanelComplates = _sidePanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
int sumSidePanelAmount = sidePanelComplates.Sum(x => x.OutPutAmount);
- List backPanelComplates = _backPanelComplateServices.Query(x => x.ProductlineCode == productLineCode && x.PlanCode == planInfo.TaskCode);
+ List backPanelComplates = _backPanelComplateServices.Query(x => x.ProductlineCode == "1001" && x.PlanCode == planInfo.TaskCode);
int sumBackPanelAmount = backPanelComplates.Sum(x => x.OutPutAmount);
Console.WriteLine($"当前计划:{planInfo.TaskCode};计划产量:{planInfo.PlanAmount};围板完成:{sumSidePanelAmount};背板完成:{sumBackPanelAmount}");
int sumAmount = 0;
- if(planInfo.PlanType == 1)
+ if (planInfo.PlanType == 1)
{
if (sumSidePanelAmount >= sumBackPanelAmount)
{
@@ -168,7 +125,8 @@ public class SheetMetalPlanTaskHandle
{
sumAmount = sumSidePanelAmount;
}
- }else if(planInfo.PlanType == 2)
+ }
+ else if (planInfo.PlanType == 2)
{
sumAmount = sumSidePanelAmount;
}
@@ -191,7 +149,8 @@ public class SheetMetalPlanTaskHandle
} while (isComplate);
}
- }catch(Exception ex)
+ }
+ catch (Exception ex)
{
Console.WriteLine($"计划任务信息更新异常:{ex.Message}");
}
@@ -203,7 +162,7 @@ public class SheetMetalPlanTaskHandle
///
///
///
- private void SendPlanTask(ExecutePlanInfo planInfo, PlcModel obj_sidePanel,PlcModel obj_backPanel)
+ private void SendPlanTask(ExecutePlanInfo planInfo, PlcModel obj_sidePanel, PlcModel obj_backPanel)
{
try
{
@@ -212,7 +171,7 @@ public class SheetMetalPlanTaskHandle
if (obj_sidePanel != null)
{
//计划编号10个字:D6000-D6009、物料编号10个字:D6010-D6019、计划数量1个字:D6020、应答字1个字D6021
- obj_sidePanel.plc.WriteString("D6030", planInfo.TaskCode.Substring(0, 16));
+ obj_sidePanel.plc.WriteString("D6030", planInfo.TaskCode);
string processNumber = GetProcessNumberBy(planInfo.MaterialCode);
obj_sidePanel.plc.WriteString("D6010", "BCD/310NF");
obj_sidePanel.plc.WriteInt32("D6020", planInfo.PlanAmount);
@@ -342,7 +301,7 @@ public class SheetMetalPlanTaskHandle
}
catch (Exception ex)
{
- MessageBox.Show($"围板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
+ MessageBox.Show($"围板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
@@ -354,6 +313,7 @@ public class SheetMetalPlanTaskHandle
public void ReadDeviceComplate_SidePanel(PlcModel obj)
{
bool isFlag = true;
+
try
{
do
@@ -370,12 +330,10 @@ public class SheetMetalPlanTaskHandle
//计划编号
string planCode = Encoding.ASCII.GetString(info.Skip(0).Take(20).ToArray());
-
//物料编号
string materialCode = Encoding.ASCII.GetString(info.Skip(20).Take(20).ToArray());
//完成数量
int complateAmount = short.Parse(bytesToHexStr(info.Skip(40).Take(1).ToArray(), 1), System.Globalization.NumberStyles.HexNumber);
-
//下线数量
int offLineAmount = short.Parse(bytesToHexStr(info.Skip(41).Take(2).ToArray(), 2), System.Globalization.NumberStyles.HexNumber);
//设备状态
@@ -385,7 +343,6 @@ public class SheetMetalPlanTaskHandle
Console.WriteLine($"围板设备数据读取====>>>>当前计划:{planCode},物料编号:{materialCode},完成数量:{complateAmount},下线数量:{offLineAmount},设备状态:{deviceStatus},生产节拍:{productionBeat}");
-
//添加完工记录
RecordSidePanelComplate sidePanelComplate = new RecordSidePanelComplate()
{
@@ -439,16 +396,11 @@ public class SheetMetalPlanTaskHandle
if (planInfo.PlanAmount - sumComplateAmount == 0)
{
isFlag = false;
-
- //结束执行数据计划
- planInfo.ExecuteStatus = 3;
- planInfo.CompleteAmount = sumComplateAmount;
- _ = _executePlanInfoServices.UpdateAsync(planInfo).Result;
-
Console.WriteLine($"围板计划执行完成,计划数量:{planInfo.PlanAmount};实际产量:{sumComplateAmount};差异值:{planInfo.PlanAmount - sumComplateAmount}");
}
}
}
+
}
}
}
@@ -465,6 +417,8 @@ public class SheetMetalPlanTaskHandle
}
}
+
+
///
/// 下发背板生产计划
///
@@ -515,11 +469,11 @@ public class SheetMetalPlanTaskHandle
}
catch (Exception ex)
{
- MessageBox.Show($"背板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
+ MessageBox.Show($"背板⽣产计划下发异常:{ex.Message}", "提示", MessageBoxButton.OK, MessageBoxImage.Error,
MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
}
}
-
+
///
/// 读取背板生产数据
///
@@ -531,7 +485,7 @@ public class SheetMetalPlanTaskHandle
try
{
do
- {
+ {
//计划编号:D6030-D6039,物料编号:D6040-D6049,计划完成数:D6050,计划下线数:D6051,设备状态:D6052-D6056,生产节拍:D6057-D6058
byte[] info = obj.plc.Read("D6030", 59);
@@ -600,7 +554,7 @@ public class SheetMetalPlanTaskHandle
List planInfos = _executePlanInfoServices.Query(x => x.TaskCode == planCode.Substring(0, 16) && x.ExecuteStatus == 2);
if (planInfos != null)
{
- if(planInfos.Count > 0)
+ if (planInfos.Count > 0)
{
ExecutePlanInfo planInfo = planInfos.First();
if (planInfo != null)
@@ -620,15 +574,15 @@ public class SheetMetalPlanTaskHandle
_backPanelComplateServices.InsertBackPanelCimplate(backPanelComplate);
Thread.Sleep(5000);
- } while (isFlag);
+ } while (isFlag);
}
catch (Exception e)
{
Console.WriteLine($"读取背板设备完成数据异常:{e.Message}");
}
}
-
-
+
+
///
/// 通过物料编号获取工艺编号
@@ -637,9 +591,9 @@ public class SheetMetalPlanTaskHandle
///
private string GetProcessNumberBy(string materialCode)
{
- return System.Guid.NewGuid().ToString("N").Substring(0,20);
+ return System.Guid.NewGuid().ToString("N").Substring(0, 20);
}
-
+
public static string bytesToHexStr(byte[] bytes, int iLen)//e.g. { 0x01, 0x01} ---> " 01 01"
{
string returnStr = "";
diff --git a/Aucma.Core.Tasks/AucamTaskService.cs b/Aucma.Core.Tasks/AucamTaskService.cs
index b719ebe8..2260662e 100644
--- a/Aucma.Core.Tasks/AucamTaskService.cs
+++ b/Aucma.Core.Tasks/AucamTaskService.cs
@@ -3,6 +3,7 @@ using Admin.Core.IService;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using Aucma.Core.HwPLc;
+using Aucma.Core.Tasks.Business;
using log4net;
using System.Timers;
@@ -22,7 +23,7 @@ namespace Aucma.Core.Tasks
{
}
- System.Timers.Timer timer1 = new System.Timers.Timer(1000);
+ System.Timers.Timer timer1 = new System.Timers.Timer(5000);
bool qFlay=true;//完成
@@ -47,8 +48,7 @@ namespace Aucma.Core.Tasks
qFlay = false;
try
{
- var plc1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("OldMelsecPlc1"));
-
+ Collection.startCollect();
}
catch (Exception)
{
diff --git a/Aucma.Core.Tasks/Business/Collection.cs b/Aucma.Core.Tasks/Business/Collection.cs
index f8d09283..b0fd6660 100644
--- a/Aucma.Core.Tasks/Business/Collection.cs
+++ b/Aucma.Core.Tasks/Business/Collection.cs
@@ -17,12 +17,12 @@ namespace Aucma.Core.Tasks.Business
{
public class Collection
{
- public HwPLc.PlcModel plc1 = null;
- public HwPLc.PlcModel plc2 = null;
- public HwPLc.PlcModel plc3 = null;
- public HwPLc.PlcModel plc4 = null;
- public List listFixtureStatus = new List();
- public List spaceDetailModel = new List();
+ public static HwPLc.PlcModel plc1 = null;
+ public static HwPLc.PlcModel plc2 = null;
+ public static HwPLc.PlcModel plc3 = null;
+ public static HwPLc.PlcModel plc4 = null;
+ public static List listFixtureStatus = new List();
+ public static List spaceDetailModel = new List();
public static List BoxTypeList = new List();
public static List HolderStatusList = new List();
@@ -34,11 +34,11 @@ namespace Aucma.Core.Tasks.Business
public Collection() {
}
- public async void startCollect()
+ public static void startCollect()
{
try
{
- await ExecTaskMethod();
+ ExecTaskMethod();
return;
}
catch (Exception ex)
@@ -47,10 +47,8 @@ namespace Aucma.Core.Tasks.Business
}
}
- private Task ExecTaskMethod()
+ private static void ExecTaskMethod()
{
- Task.Run(() =>
- {
while (true)
{
Thread.Sleep(3000);
@@ -75,7 +73,6 @@ namespace Aucma.Core.Tasks.Business
ReadHolderStatus(plc1, HolderStatusList);
ReadHolderStatus(plc2, HolderStatusList);
ReadHolderStatus(plc3, HolderStatusList);
- ReadHolderStatus(plc4, HolderStatusList);
ReadHolderOutPut(plc1, HolderOutPutList);
ReadHolderOutPut(plc2, HolderOutPutList);
@@ -143,9 +140,7 @@ namespace Aucma.Core.Tasks.Business
spaceDetailModel.Add(model);
}
}
- });
-
- return Task.CompletedTask;
+
}
///