From 3630effe43ba3f441e85eecbad5e3ff87eac0e78 Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 27 Dec 2023 10:38:16 +0800 Subject: [PATCH 1/5] change. --- .../QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs | 3 +- Aucma.Core.BoxFoam/appsettings.json | 10 +++--- Aucma.Core.RunPlc/RunPlcService.cs | 32 +++++++++---------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs index 3784cacd..f2dbd6ea 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs @@ -33,7 +33,8 @@ namespace Admin.Core.Tasks public async Task Execute(IJobExecutionContext context) { - await ExecuteJob(context, async () => await Run(context)); + // await ExecuteJob(context, async () => await Run(context)); + // await ExecuteJob(context, async () => await BoxFoamDataRun(context)); await ExecuteJob(context, async () => await BoxFoamDataRun(context)); } diff --git a/Aucma.Core.BoxFoam/appsettings.json b/Aucma.Core.BoxFoam/appsettings.json index 38afd476..39c4b2cc 100644 --- a/Aucma.Core.BoxFoam/appsettings.json +++ b/Aucma.Core.BoxFoam/appsettings.json @@ -197,12 +197,14 @@ } }, "PLCServer": [ - + { "Id": 1, - "EquipName": "OldTypePlc4", - "IP": "10.10.93.154", - "Port": 5002 + "EquipName": "Plc1", + "PlcType": "Siemens", + "Enabled": true, + "IP": "127.0.0.1", + "Port": 102 } ], "StoreInfo": { diff --git a/Aucma.Core.RunPlc/RunPlcService.cs b/Aucma.Core.RunPlc/RunPlcService.cs index 23f413df..795e67f7 100644 --- a/Aucma.Core.RunPlc/RunPlcService.cs +++ b/Aucma.Core.RunPlc/RunPlcService.cs @@ -63,22 +63,22 @@ namespace Aucma.Core.RunPlc private static Task StartSiemensPlcServer() { - //var allPlcServices = Appsettings.app("PLCServer").ToList(); - //if (allPlcServices==null) return Task.CompletedTask; - ////var list1 = allPlcServices.Where(d => d.PlcType.Equals("Siemens") && d.Enabled == true); - // if (list1 == null) return Task.CompletedTask; - //var list = list1.Where(d => d.PlcType.Equals("Siemens") && d.Enabled == true); - //foreach (var item in list) - //{ - // PlcModel model = new PlcModel(); - // model.Id = item.Id; - // model.EquipName = item.EquipName; - // model.IP = item.IP; - // model.Port = item.Port; - // model.PlcType = item.PlcType; - // model.plc = new SiemensPlc(item.IP, item.Port); - // PlcHelper.siemensList.Add(model); - //} + var allPlcServices = Appsettings.app("PLCServer").ToList(); + //if (allPlcServices == null) return Task.CompletedTask; + // var list1 = allPlcServices.Where(d => d.PlcType.Equals("Siemens") && d.Enabled == true); + // if (list1 == null) return Task.CompletedTask; + var list = allPlcServices.Where(d => d.PlcType.Equals("Siemens") && d.Enabled == true); + foreach (var item in list) + { + PlcModel model = new PlcModel(); + model.Id = item.Id; + model.EquipName = item.EquipName; + model.IP = item.IP; + model.Port = item.Port; + model.PlcType = item.PlcType; + model.plc = new SiemensPlc(item.IP, item.Port); + PlcHelper.siemensList.Add(model); + } return Task.CompletedTask; } #endregion From e6067a3805e461631e647f9550ac659bec742a31 Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 27 Dec 2023 18:29:06 +0800 Subject: [PATCH 2/5] =?UTF-8?q?change-=E6=9C=80=E5=90=8E=E4=B8=80=E6=9E=AA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=87=87=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin.Core.Common/Helper/StringChange.cs | 24 +++++ .../Model_New/BoxLastShotRecord.cs | 12 ++- Admin.Core.Tasks/Admin.Core.Tasks.csproj | 6 ++ .../QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs | 15 ++- .../Jobs/Job_BoxFoamLastData_Quartz.cs | 91 ++++++++++++++++++- .../Business/InStoreBusiness.cs | 55 ++++++----- .../ViewModels/FoamMachinesPageViewModel.cs | 41 +++++++++ Aucma.Core.BoxFoam/appsettings.json | 17 +++- Aucma.Core.HwPLc/Impl/SiemensPlc.cs | 15 ++- 9 files changed, 227 insertions(+), 49 deletions(-) create mode 100644 Admin.Core.Common/Helper/StringChange.cs diff --git a/Admin.Core.Common/Helper/StringChange.cs b/Admin.Core.Common/Helper/StringChange.cs new file mode 100644 index 00000000..1add35f8 --- /dev/null +++ b/Admin.Core.Common/Helper/StringChange.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Common.Helper +{ + public class StringChange + { + public static string bytesToHexStr(byte[] bytes, int iLen)//e.g. { 0x01, 0x01} ---> " 01 01" + { + string returnStr = ""; + if (bytes != null) + { + for (int i = 0; i < iLen; i++) + { + returnStr += bytes[i].ToString("X2"); + } + } + return returnStr; + } + } +} diff --git a/Admin.Core.Model/Model_New/BoxLastShotRecord.cs b/Admin.Core.Model/Model_New/BoxLastShotRecord.cs index 598fa490..332d73fc 100644 --- a/Admin.Core.Model/Model_New/BoxLastShotRecord.cs +++ b/Admin.Core.Model/Model_New/BoxLastShotRecord.cs @@ -12,8 +12,8 @@ namespace Admin.Core.Model /// 获取发泡机最后一枪记录 /// [SugarTable("BOX_LASTSHOTRECORD", "AUCMA_SCADA")] - public class BoxLastShotRecord - { + public class BoxLastShotRecord + { /// /// 主键 /// @@ -148,7 +148,7 @@ namespace Admin.Core.Model /// 注料状态 /// [SugarColumn(ColumnName = "INJECTIONSTATUS")] - public DateTime InjectionStatus { get; set; } + public string InjectionStatus { get; set; } /// /// 最后一次时间 /// @@ -159,5 +159,11 @@ namespace Admin.Core.Model /// [SugarColumn(ColumnName = "CREATETIME")] public DateTime Createtime { get; set; } + /// + /// 产线 + /// + [SugarColumn(ColumnName = "PRODUCT_LINE_CODE")] + public string ProductLineCode { get; set; } + } } diff --git a/Admin.Core.Tasks/Admin.Core.Tasks.csproj b/Admin.Core.Tasks/Admin.Core.Tasks.csproj index 635e3086..4fbcb9c0 100644 --- a/Admin.Core.Tasks/Admin.Core.Tasks.csproj +++ b/Admin.Core.Tasks/Admin.Core.Tasks.csproj @@ -16,4 +16,10 @@ + + + ..\dll\HwCommunication.dll + + + diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs index f2dbd6ea..c282cc4f 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamData_Quartz.cs @@ -8,6 +8,10 @@ using Admin.Core.Model; using System.Linq; using Admin.Core.Model.Model_New; using Aucma.Core.HwPLc; +using HwCommunication.Core; +using Admin.Core.Common.Helper; +using System.Collections; +using System.Text; /// /// 发泡数据采集 @@ -22,27 +26,30 @@ namespace Admin.Core.Tasks private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(Job_BoxFoamData_Quartz)); private readonly IBoxFoamDataServices _boxFoamDataServices; private readonly IOldBoxFoamDataServices _oldBoxFoamDataServices; - + public Job_BoxFoamData_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService, IBoxFoamDataServices boxFoamDataServices, IOldBoxFoamDataServices oldBoxFoamDataServices) { _SysTasksQzService = SysTasksQzService; _boxFoamDataServices = boxFoamDataServices; _oldBoxFoamDataServices = oldBoxFoamDataServices; + } public async Task Execute(IJobExecutionContext context) { - // await ExecuteJob(context, async () => await Run(context)); - // await ExecuteJob(context, async () => await BoxFoamDataRun(context)); - await ExecuteJob(context, async () => await BoxFoamDataRun(context)); + // await ExecuteJob(context, async () => await Run(context)); + // await ExecuteJob(context, async () => await BoxFoamDataRun(context)); + } + public async Task Run(IJobExecutionContext context) { await SaveData(); } + public async Task BoxFoamDataRun(IJobExecutionContext context) { await SaveOldBoxFoamData(); diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs index f339d20b..0748dc5e 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs @@ -8,6 +8,11 @@ using Admin.Core.Model; using System.Linq; using Admin.Core.Model.Model_New; using Aucma.Core.HwPLc; +using Admin.Core.Common.Helper; +using HwCommunication.Core; +using System.Text; +using Admin.Core.Service; +using Admin.Core.Common; /// /// 箱体发泡 最后一枪数据采集 @@ -18,22 +23,100 @@ namespace Admin.Core.Tasks { public delegate Task RefreshBoxFoamDataDelegate(); public static event RefreshBoxFoamDataDelegate RefreshBoxFoamDataDelegateEvent; + /// + /// 刷新最后一枪数据 + /// + public delegate void RefreshLastShotDataDelegate(BoxLastShotRecord record); + public static event RefreshLastShotDataDelegate RefreshLastShotDataDelegateEvent; + private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(Job_BoxFoamData_Quartz)); private readonly IBoxFoamDataServices _boxFoamDataServices; private readonly IOldBoxFoamDataServices _oldBoxFoamDataServices; - + private readonly IBoxLastShotRecordServices _lastShotRecordServices; + private static BoxLastShotRecord tempLastRecord = null; public Job_BoxFoamLastData_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService, - IBoxFoamDataServices boxFoamDataServices, IOldBoxFoamDataServices oldBoxFoamDataServices) + IBoxFoamDataServices boxFoamDataServices, IOldBoxFoamDataServices oldBoxFoamDataServices, IBoxLastShotRecordServices boxLastShotRecordServices) { _SysTasksQzService = SysTasksQzService; _boxFoamDataServices = boxFoamDataServices; _oldBoxFoamDataServices = oldBoxFoamDataServices; + _lastShotRecordServices = boxLastShotRecordServices; } public async Task Execute(IJobExecutionContext context) { - await ExecuteJob(context, async () => await Run(context)); - await ExecuteJob(context, async () => await BoxFoamDataRun(context)); + // await ExecuteJob(context, async () => await Run(context)); + // await ExecuteJob(context, async () => await BoxFoamDataRun(context)); + await ExecuteJob(context, async () => await Collect(context)); + } + + /// + /// 采集注料记录最近一枪 + /// + /// + /// + public async Task Collect(IJobExecutionContext context) + { + await CollectLast(); + } + + public async Task CollectLast() + { + var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("Plc1")); + if (obj != null && obj.plc.IsConnected) + { + BoxLastShotRecord lastShotRecord = new BoxLastShotRecord(); + byte[] info = obj.plc.ReadBytes("DB50.900", (ushort)87); + IByteTransform byteTransform = new RegularByteTransform(); + lastShotRecord.System = "1"; + lastShotRecord.BoxFixtureType = "test"; + lastShotRecord.GunHead = Encoding.ASCII.GetString(info.Skip(0).Take(4).ToArray()); + lastShotRecord.StationNumber = StringChange.bytesToHexStr(info.Skip(4).Take(2).ToArray(), 2); + lastShotRecord.MediumPressureCycleTime = StringChange.bytesToHexStr(info.Skip(6).Take(4).ToArray(), 4); + lastShotRecord.HighPressureCycleTime = StringChange.bytesToHexStr(info.Skip(10).Take(4).ToArray(), 4); + lastShotRecord.SetInjectionWeight = StringChange.bytesToHexStr(info.Skip(14).Take(4).ToArray(), 4); + lastShotRecord.InjectionMaterialRatio = StringChange.bytesToHexStr(info.Skip(18).Take(4).ToArray(), 4); + lastShotRecord.ActualInjectionWeight = StringChange.bytesToHexStr(info.Skip(22).Take(4).ToArray(), 4); + lastShotRecord.ActualInjectionMaterialRatio = StringChange.bytesToHexStr(info.Skip(26).Take(4).ToArray(), 4); + lastShotRecord.PolInjectionpressure = StringChange.bytesToHexStr(info.Skip(30).Take(4).ToArray(), 4); + lastShotRecord.IsoInjectionpressure = StringChange.bytesToHexStr(info.Skip(34).Take(4).ToArray(), 4); + lastShotRecord.PolInjectiontemperature = StringChange.bytesToHexStr(info.Skip(38).Take(4).ToArray(), 4); + lastShotRecord.IsoInjectiontemperature = StringChange.bytesToHexStr(info.Skip(42).Take(4).ToArray(), 4); + + lastShotRecord.InjecPressureOfPOLGunHead = StringChange.bytesToHexStr(info.Skip(46).Take(4).ToArray(), 4); + lastShotRecord.InjecPressureOfISOGunHead = StringChange.bytesToHexStr(info.Skip(50).Take(4).ToArray(), 4); + lastShotRecord.POLInjecTemperatureOfGunHead = StringChange.bytesToHexStr(info.Skip(54).Take(4).ToArray(), 4); + lastShotRecord.ISOInjecTemperatureOfGunHead = StringChange.bytesToHexStr(info.Skip(58).Take(4).ToArray(), 4); + + lastShotRecord.POLInjecFlowRate = StringChange.bytesToHexStr(info.Skip(62).Take(4).ToArray(), 4); + lastShotRecord.ISOInjecFlowRate = StringChange.bytesToHexStr(info.Skip(66).Take(4).ToArray(), 4); + lastShotRecord.HydraulicPressure = StringChange.bytesToHexStr(info.Skip(70).Take(4).ToArray(), 4); + lastShotRecord.HydraulicTemperature = StringChange.bytesToHexStr(info.Skip(74).Take(4).ToArray(), 4); + lastShotRecord.SmallPistonFiringTime = StringChange.bytesToHexStr(info.Skip(78).Take(4).ToArray(), 4); + lastShotRecord.SmallPistonGunShutdownTime = StringChange.bytesToHexStr(info.Skip(82).Take(4).ToArray(), 4); + lastShotRecord.InjectionStatus = StringChange.bytesToHexStr(info.Skip(86).Take(1).ToArray(), 1); + lastShotRecord.LastTime = DateTime.Now; + lastShotRecord.Createtime = DateTime.Now; + lastShotRecord.ProductLineCode = "111"; + + if (tempLastRecord == null) + { + //数据库查 + tempLastRecord = _lastShotRecordServices.Query(x=>x.System == lastShotRecord.System).OrderByDescending(x=>x.Createtime).FirstOrDefault(); + } + if (!tempLastRecord.SmallPistonGunShutdownTime.Equals(lastShotRecord.SmallPistonGunShutdownTime)) + { + // 刷新页面 + RefreshLastShotDataDelegateEvent?.Invoke(lastShotRecord); + //保存 + _lastShotRecordServices.AddAsync(lastShotRecord); + tempLastRecord = lastShotRecord; + } + + + + } + } public async Task Run(IJobExecutionContext context) diff --git a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs index ba2043ee..1c9a7876 100644 --- a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs +++ b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs @@ -108,7 +108,8 @@ namespace Aucma.Core.BoxFoam.Business private static int AAA = 1; public void init() - { + { + allSpaces = _baseSpaceInfoServices.Query(x => x.StoreCode == storeCode); foreach (var space in allSpaces) { @@ -117,13 +118,13 @@ namespace Aucma.Core.BoxFoam.Business Task.Run(() => { Thread.Sleep(5000); - - // test(); + + // test(); // 获取任务下发plc StartPassDown(); - // InStore("B23600083025024860011"); + InStore("B23600083025024860011"); }); - startTimer(); + // startTimer(); } public async void test() @@ -146,7 +147,7 @@ namespace Aucma.Core.BoxFoam.Business /// public void RealInstoreFinish(object? sender, ElapsedEventArgs e) { - var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("发泡Plc")); + var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("泡前库Plc")); if (obj != null && obj.plc.IsConnected) { foreach (SpaceAddress spaceAddress in spaceAddresses) @@ -168,13 +169,17 @@ namespace Aucma.Core.BoxFoam.Business } - public void StartPassDown() + public async void StartPassDown() { - while (true) - { - PassDown(); - Thread.Sleep(1000); - } + Task.Run(() => + { + while (true) + { + PassDown(); + Thread.Sleep(200000); + } + }); + } @@ -405,7 +410,7 @@ namespace Aucma.Core.BoxFoam.Business public BaseSpaceInfo ReadSpaceInfoByPlc(BaseSpaceInfo spaceInfo) { - var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("发泡Plc")); + var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("泡前库Plc")); if (obj != null && obj.plc.IsConnected) { SpaceAddress spaceAddress = spaceConfig.GetSpaceAddress(spaceInfo.StoreCode, spaceInfo.SpaceCode); @@ -440,15 +445,16 @@ namespace Aucma.Core.BoxFoam.Business try { SpaceAddress spaceAddress = spaceConfig.GetSpaceAddress(storeCode, taskInfo.SpaceCode); - var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("发泡Plc")); + var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("泡前库Plc")); if (obj != null && obj.plc.IsConnected) { - //写入货道号 - obj.plc.WriteInt16("DB200.0", taskInfo.SpaceCode.Substring(7,1)); + //写入应答字 obj.plc.WriteInt16("DB200.2", "1"); //写入货道物料类型 obj.plc.WriteString(spaceAddress.materialType, taskInfo.MaterialType); + //写入货道号 + obj.plc.WriteInt16("DB200.0", taskInfo.SpaceCode.Substring(7,1)); //写入完成后读取反馈号进行复位 ReadShellAnswer_InStore(taskInfo); result = true; @@ -466,14 +472,14 @@ namespace Aucma.Core.BoxFoam.Business } /// - /// 读取泡后入库应答 + /// 读取泡前入库应答 /// private void ReadShellAnswer_InStore(RealTaskInfo taskInfo) { lock (string.Empty) { bool isFlag = true; - var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("发泡Plc")); + var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("泡前库Plc")); try { Task.Run(() => @@ -483,17 +489,18 @@ namespace Aucma.Core.BoxFoam.Business do { //读取PLC反馈号,上位机清空写入的入库内容 - if (obj.plc.ReadInt16("DB200.86") == 1) + if (obj.plc.ReadInt16("DB200.86") == 2) { + obj.plc.WriteInt16("DB200.86", "0"); //-------------plc清 //写入货道号 - // obj.plc.WriteString("D110", string.Empty); - //写入应答字 - // obj.plc.WriteInt16("D112", "0"); + obj.plc.WriteInt16("DB200.0", "0"); + // 写入应答字 + obj.plc.WriteInt16("DB200.2", "0"); //写入货道物料类型 // obj.plc.WriteInt16(spaceAddress.materialType, taskInfo.MaterialType); //---------------------- - obj.plc.WriteInt16("DB200.86", "0"); + isFlag = false; InStoreAnswer(taskInfo.TaskCode); // TaskInfos.Add(taskInfo); @@ -579,7 +586,7 @@ namespace Aucma.Core.BoxFoam.Business // lock (string.Empty) // { // bool isFlag = true; - // var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("发泡Plc")); + // var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("泡前库Plc")); // try // { diff --git a/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs index f44ac2f9..77aeeb1d 100644 --- a/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs @@ -1,7 +1,9 @@ using Admin.Core.Common; using Admin.Core.IService; +using Admin.Core.Model; using Admin.Core.Model.ViewModels; using Admin.Core.Service; +using Admin.Core.Tasks; using Aucma.Core.BoxFoam.Models; using CommunityToolkit.Mvvm.ComponentModel; using Microsoft.Extensions.DependencyInjection; @@ -20,9 +22,48 @@ namespace Aucma.Core.BoxFoam.ViewModels public FoamMachinesPageViewModel() { + Job_BoxFoamLastData_Quartz.RefreshLastShotDataDelegateEvent += RefreshData; _boxLastShotRecordServices = App.ServiceProvider.GetService(); + //Task.WaitAll(LoadData()); } + + public void RefreshData(BoxLastShotRecord record) + { + System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () => + { + string system = string.Empty; + if (record.System == "1") { + system = "1系统"; + + PolFlow1 = record.POLInjecFlowRate; + IsoFlow1 = record.ISOInjecFlowRate; + PoleTmperature1 = record.POLInjecTemperatureOfGunHead; + IsoTemperature1 = record.ISOInjecTemperatureOfGunHead; + + } + if (record.System == "2") { system = "2系统"; } + LastShotRecordDataGrid.Add(new LastShotRecordModel() + { + No = LastShotRecordDataGrid.Count+1, + System = system, + GunHead = record.GunHead, + StationNumber = record.StationNumber, + PolInjectionpressure = record.PolInjectionpressure, + IsoInjectionpressure = record.IsoInjectionpressure, + PolInjectiontemperature = record.PolInjectiontemperature, + IsoInjectiontemperature = record.IsoInjectiontemperature, + LastTime = record.LastTime, + Createtime = record.Createtime + }); + + })); + + + } + + + #region 加载DataGrid数据 private async Task LoadData() { diff --git a/Aucma.Core.BoxFoam/appsettings.json b/Aucma.Core.BoxFoam/appsettings.json index 39c4b2cc..3f3b9ee3 100644 --- a/Aucma.Core.BoxFoam/appsettings.json +++ b/Aucma.Core.BoxFoam/appsettings.json @@ -100,15 +100,15 @@ "JobGroup": "DEFAULT", "Cron": "*/1 * * * * ?", "AssemblyName": "Admin.Core.Tasks", - "ClassName": "Job_BoxFoamInStoreTask_Quartz", - "Remark": "入库任务监控", + "ClassName": "Job_BoxFoamLastData_Quartz", + "Remark": "最后一枪数据采集", "RunTimes": 3881, "BeginTime": "2023-04-23 11:08:50.000", "EndTime": "2180-12-01 16:45:30.000", "TriggerType": 1, "IntervalSecond": 5, "CycleRunTimes": 1, - "IsStart": false, + "IsStart": true, "JobParams": null, "DelFlag": false, "CreateBy": "admin", @@ -186,7 +186,7 @@ "Enabled": true }, "QuartzNetJob": { - "Enabled": false + "Enabled": true }, "Scanner": { //扫码器 "Enabled": true @@ -197,9 +197,16 @@ } }, "PLCServer": [ - { "Id": 1, + "EquipName": "泡前库Plc", + "PlcType": "Siemens", + "Enabled": true, + "IP": "10.10.93.41", + "Port": 102 + }, + { + "Id": 2, "EquipName": "Plc1", "PlcType": "Siemens", "Enabled": true, diff --git a/Aucma.Core.HwPLc/Impl/SiemensPlc.cs b/Aucma.Core.HwPLc/Impl/SiemensPlc.cs index a837fd10..fbb817e9 100644 --- a/Aucma.Core.HwPLc/Impl/SiemensPlc.cs +++ b/Aucma.Core.HwPLc/Impl/SiemensPlc.cs @@ -119,18 +119,19 @@ namespace Aucma.Core.HwPLc /// /// /// - public byte[] ReadBytes(string address) + public byte[] ReadBytes(string address,ushort len) { byte[] bytes = null; try { - OperateResult read = siemensS7Net.Read(address, 26); + OperateResult read = siemensS7Net.Read(address, len); if (read.IsSuccess) { byte[] code = new byte[read.Content.Length - 2]; - Array.Copy(read.Content, 2, code, 0, 24); - string scode = Encoding.ASCII.GetString(code, 0, code.Length); - bytes = code; + //Array.Copy(read.Content, 2, code, 0, 24); + //string scode = Encoding.ASCII.GetString(code, 0, code.Length); + //bytes = code; + bytes = read.Content; } } catch (Exception ex) @@ -499,10 +500,6 @@ namespace Aucma.Core.HwPLc return false; } - public byte[] ReadBytes(string address, ushort len) - { - throw new NotImplementedException(); - } #endregion } } From aade61a4c6f9512f86e440f1b4124ba8eb9c1b6d Mon Sep 17 00:00:00 2001 From: liuwf Date: Wed, 27 Dec 2023 18:47:20 +0800 Subject: [PATCH 3/5] change. --- Aucma.Core.RunPlc/RunPlcService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Aucma.Core.RunPlc/RunPlcService.cs b/Aucma.Core.RunPlc/RunPlcService.cs index ce447895..faaf26cc 100644 --- a/Aucma.Core.RunPlc/RunPlcService.cs +++ b/Aucma.Core.RunPlc/RunPlcService.cs @@ -48,7 +48,7 @@ namespace Aucma.Core.RunPlc if (allPlcServices == null) return Task.CompletedTask; var list = allPlcServices.FindAll(d => d.PlcType == "Melsec" && d.Enabled == true); - foreach (var item in allPlcServices) + foreach (var item in list) { PlcModel model = new PlcModel(); model.Id = item.Id; From e32041e33a8bdc1dd3ddbfcdf7756a8399b38f64 Mon Sep 17 00:00:00 2001 From: liuwf Date: Thu, 28 Dec 2023 14:27:44 +0800 Subject: [PATCH 4/5] change. --- .../Model_New/BoxLastShotRecord.cs | 168 ++++++++---------- .../Jobs/Job_BoxFoamLastData_Quartz.cs | 63 ++++--- .../Business/InStoreBusiness.cs | 4 +- .../ViewModels/FoamMachinesPageViewModel.cs | 42 ++--- Aucma.Core.ProductOffLine/appsettings.json | 4 +- 5 files changed, 135 insertions(+), 146 deletions(-) diff --git a/Admin.Core.Model/Model_New/BoxLastShotRecord.cs b/Admin.Core.Model/Model_New/BoxLastShotRecord.cs index 332d73fc..23c94423 100644 --- a/Admin.Core.Model/Model_New/BoxLastShotRecord.cs +++ b/Admin.Core.Model/Model_New/BoxLastShotRecord.cs @@ -13,157 +13,147 @@ namespace Admin.Core.Model /// [SugarTable("BOX_LASTSHOTRECORD", "AUCMA_SCADA")] public class BoxLastShotRecord - { + { /// /// 主键 /// [SugarColumn(ColumnName = "OBJ_ID", IsIdentity = true, IsPrimaryKey = true)] public int ObjId { get; set; } - /// - /// 夹具类型 - /// - [SugarColumn(ColumnName = "BOXFIXTURETYPE")] - public string BoxFixtureType { get; set; } - /// /// 所属系统;1系统 2系统 /// [SugarColumn(ColumnName = "SYSTEM")] public string System { get; set; } + /// - /// 枪头 + /// 枪编号;A1枪,B1枪,A2枪,B2枪 /// - [SugarColumn(ColumnName = "GUNHEAD")] - public string GunHead { get; set; } + [SugarColumn(ColumnName = "GUN_CODE")] + public string GunCode { get; set; } /// - /// 工位号 + /// 产线编号 /// - [SugarColumn(ColumnName = "STATIONNUMBER")] - public string StationNumber { get; set; } + [SugarColumn(ColumnName = "PRODUCT_LINE_CODE")] + public string ProductLineCode { get; set; } /// - /// POL注料压力 + /// 枪POL注料温度 /// - [SugarColumn(ColumnName = "POL_INJECTIONPRESSURE")] - public string PolInjectionpressure { get; set; } - + [SugarColumn(ColumnName = "POL_TEMP")] + public string PolTemp { get; set; } /// - /// ISO注料压力 + /// 枪POL注料压力 /// - [SugarColumn(ColumnName = "ISO_INJECTIONPRESSURE")] - public string IsoInjectionpressure { get; set; } + [SugarColumn(ColumnName = "POL_HP")] + public string PolHp { get; set; } /// - /// POL注料温度 + /// 枪POL注料流量 /// - [SugarColumn(ColumnName = "POL_INJECTIONTEMPERATURE")] - public string PolInjectiontemperature { get; set; } + [SugarColumn(ColumnName = "POL_VOL")] + public string PolVol { get; set; } /// - /// ISO注料温度 + /// 枪POL原料用量 /// - [SugarColumn(ColumnName = "ISO_INJECTIONTEMPERATURE")] - public string IsoInjectiontemperature { get; set; } + [SugarColumn(ColumnName = "POL_USAGE")] + public string PolUsage { get; set; } + /// - /// 中压循环时间 + /// 枪ISO注料温度 /// - [SugarColumn(ColumnName = "MEDIUMPRESSURECYCLETIME")] - public string MediumPressureCycleTime { get; set; } + [SugarColumn(ColumnName = "ISO_TEMP")] + public string IsoTemp { get; set; } /// - /// 高压循环时间 + /// 枪ISO注料压力 /// - [SugarColumn(ColumnName = "HIGHPRESSURECYCLETIME")] - public string HighPressureCycleTime { get; set; } + [SugarColumn(ColumnName = "ISO_HP")] + public string IsoHp { get; set; } /// - /// 设定注料重量 + ///枪ISO注料流量 /// - [SugarColumn(ColumnName = "SETINJECTIONWEIGHT")] - public string SetInjectionWeight { get; set; } + [SugarColumn(ColumnName = "ISO_VOL")] + public string IsoVol { get; set; } /// - /// 设定注料料比 + /// 枪ISO原料用量 /// - [SugarColumn(ColumnName = "INJECTIONMATERIALRATIO")] - public string InjectionMaterialRatio { get; set; } + [SugarColumn(ColumnName = "ISO_USAGE")] + public string IsoUsage { get; set; } /// - /// 实际注料重量 + /// 枪注料工位号 /// - [SugarColumn(ColumnName = "ACTUALINJECTIONWEIGHT")] - public string ActualInjectionWeight { get; set; } + [SugarColumn(ColumnName = "POUR_NU")] + public string PourNu { get; set; } /// - /// 实际注料料比 + /// 枪设定注料时间 /// - [SugarColumn(ColumnName = "ACTUALINJECTIONMATERIALRATIO")] - public string ActualInjectionMaterialRatio { get; set; } + [SugarColumn(ColumnName = "SET_TIME")] + public string SetTime { get; set; } /// - /// 枪头POL注料压力 + /// 枪设定注料重量 /// - [SugarColumn(ColumnName = "INJECPRESSUREOFPOLGUNHEAD")] - public string InjecPressureOfPOLGunHead { get; set; } + [SugarColumn(ColumnName = "SET_WEIGHT")] + public string SetWeight { get; set; } /// - /// 枪头ISO注料压力 + /// 枪设定注料比例 /// - [SugarColumn(ColumnName = "INJECPRESSUREOFISOGUNHEAD")] - public string InjecPressureOfISOGunHead { get; set; } + [SugarColumn(ColumnName = "SET_RATIO")] + public string SetRatio { get; set; } /// - /// 枪头POL注料温度 + /// 枪实际注料重量 /// - [SugarColumn(ColumnName = "POLINJECTEMPERATUREOFGUNHEAD")] - public string POLInjecTemperatureOfGunHead { get; set; } + [SugarColumn(ColumnName = "POUR_WEIGHT")] + public string PourWeight { get; set; } /// - /// 枪头ISO注料温度 + /// 枪实际注料比例 /// - [SugarColumn(ColumnName = "ISOINJECTEMPERATUREOFGUNHEAD")] - public string ISOInjecTemperatureOfGunHead { get; set; } + [SugarColumn(ColumnName = "POUR_RATIO")] + public string PourRatio { get; set; } /// - /// POL注料流量 + /// 枪中压循环时间 /// - [SugarColumn(ColumnName = "POLINJECFLOWRATE")] - public string POLInjecFlowRate { get; set; } + [SugarColumn(ColumnName = "MP_TIME")] + public string MpTime { get; set; } /// - /// ISO注料流量 + /// 枪高压循环时间 /// - [SugarColumn(ColumnName = "ISOINJECFLOWRATE")] - public string ISOInjecFlowRate { get; set; } + [SugarColumn(ColumnName = "HP_TIME")] + public string HpTime { get; set; } /// - /// 液压压力 + /// 枪液压压力 /// - [SugarColumn(ColumnName = "HYDRAULICPRESSURE")] - public string HydraulicPressure { get; set; } + [SugarColumn(ColumnName = "HYDR_PRESS")] + public string HydrPress { get; set; } /// - /// 液压温度 + /// 枪液压温度 /// - [SugarColumn(ColumnName = "HYDRAULICTEMPERATURE")] - public string HydraulicTemperature { get; set; } + [SugarColumn(ColumnName = "HYDR_TEMP")] + public string HydrTemp { get; set; } /// - /// 小活塞开枪时间 + /// 枪开枪时间 /// - [SugarColumn(ColumnName = "SMALLPISTONFIRINGTIME")] - public string SmallPistonFiringTime { get; set; } + [SugarColumn(ColumnName = "MIXPIST_ON")] + public string MixpistOn { get; set; } /// - /// 小活塞关枪时间 + /// 枪关枪时间 /// - [SugarColumn(ColumnName = "SMALLPISTONGUNSHUTDOWNTIME")] - public string SmallPistonGunShutdownTime { get; set; } - + [SugarColumn(ColumnName = "MIXPIST_OFF")] + public string MixpistOff { get; set; } /// - /// 注料状态 + /// 枪总产量 /// - [SugarColumn(ColumnName = "INJECTIONSTATUS")] - public string InjectionStatus { get; set; } + [SugarColumn(ColumnName = "TOTAL_YIELD")] + public string TotalYield { get; set; } + /// - /// 最后一次时间 + /// 枪注料结束信号 /// - [SugarColumn(ColumnName = "LAST_TIME")] - public DateTime LastTime { get; set; } + [SugarColumn(ColumnName = "POUR_END")] + public string PourEnd { get; set; } + /// /// 创建时间 /// - [SugarColumn(ColumnName = "CREATETIME")] - public DateTime Createtime { get; set; } - /// - /// 产线 - /// - [SugarColumn(ColumnName = "PRODUCT_LINE_CODE")] - public string ProductLineCode { get; set; } - + [SugarColumn(ColumnName = "CREATE_TIME")] + public DateTime CreateTime { get; set; } } } diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs index 0748dc5e..a86a753d 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs @@ -66,45 +66,44 @@ namespace Admin.Core.Tasks if (obj != null && obj.plc.IsConnected) { BoxLastShotRecord lastShotRecord = new BoxLastShotRecord(); - byte[] info = obj.plc.ReadBytes("DB50.900", (ushort)87); + byte[] info = obj.plc.ReadBytes("DB50.896", (ushort)88); IByteTransform byteTransform = new RegularByteTransform(); - lastShotRecord.System = "1"; - lastShotRecord.BoxFixtureType = "test"; - lastShotRecord.GunHead = Encoding.ASCII.GetString(info.Skip(0).Take(4).ToArray()); - lastShotRecord.StationNumber = StringChange.bytesToHexStr(info.Skip(4).Take(2).ToArray(), 2); - lastShotRecord.MediumPressureCycleTime = StringChange.bytesToHexStr(info.Skip(6).Take(4).ToArray(), 4); - lastShotRecord.HighPressureCycleTime = StringChange.bytesToHexStr(info.Skip(10).Take(4).ToArray(), 4); - lastShotRecord.SetInjectionWeight = StringChange.bytesToHexStr(info.Skip(14).Take(4).ToArray(), 4); - lastShotRecord.InjectionMaterialRatio = StringChange.bytesToHexStr(info.Skip(18).Take(4).ToArray(), 4); - lastShotRecord.ActualInjectionWeight = StringChange.bytesToHexStr(info.Skip(22).Take(4).ToArray(), 4); - lastShotRecord.ActualInjectionMaterialRatio = StringChange.bytesToHexStr(info.Skip(26).Take(4).ToArray(), 4); - lastShotRecord.PolInjectionpressure = StringChange.bytesToHexStr(info.Skip(30).Take(4).ToArray(), 4); - lastShotRecord.IsoInjectionpressure = StringChange.bytesToHexStr(info.Skip(34).Take(4).ToArray(), 4); - lastShotRecord.PolInjectiontemperature = StringChange.bytesToHexStr(info.Skip(38).Take(4).ToArray(), 4); - lastShotRecord.IsoInjectiontemperature = StringChange.bytesToHexStr(info.Skip(42).Take(4).ToArray(), 4); - lastShotRecord.InjecPressureOfPOLGunHead = StringChange.bytesToHexStr(info.Skip(46).Take(4).ToArray(), 4); - lastShotRecord.InjecPressureOfISOGunHead = StringChange.bytesToHexStr(info.Skip(50).Take(4).ToArray(), 4); - lastShotRecord.POLInjecTemperatureOfGunHead = StringChange.bytesToHexStr(info.Skip(54).Take(4).ToArray(), 4); - lastShotRecord.ISOInjecTemperatureOfGunHead = StringChange.bytesToHexStr(info.Skip(58).Take(4).ToArray(), 4); + lastShotRecord.System = "1"; + lastShotRecord.GunCode = "A1"; + lastShotRecord.GunCode = "A1"; + #region 赋值 + lastShotRecord.PolTemp = Encoding.ASCII.GetString(info.Skip(0).Take(4).ToArray()); + lastShotRecord.PolHp = StringChange.bytesToHexStr(info.Skip(4).Take(4).ToArray(), 4); + lastShotRecord.PolVol = StringChange.bytesToHexStr(info.Skip(8).Take(4).ToArray(), 4); + lastShotRecord.PolUsage = StringChange.bytesToHexStr(info.Skip(12).Take(4).ToArray(), 4); + lastShotRecord.IsoTemp = StringChange.bytesToHexStr(info.Skip(16).Take(4).ToArray(), 4); + lastShotRecord.IsoHp = StringChange.bytesToHexStr(info.Skip(20).Take(4).ToArray(), 4); + lastShotRecord.IsoVol = StringChange.bytesToHexStr(info.Skip(24).Take(4).ToArray(), 4); + lastShotRecord.IsoUsage = StringChange.bytesToHexStr(info.Skip(28).Take(4).ToArray(), 4); + lastShotRecord.PourNu = StringChange.bytesToHexStr(info.Skip(36).Take(2).ToArray(), 2); + lastShotRecord.SetTime = StringChange.bytesToHexStr(info.Skip(38).Take(4).ToArray(), 4); + lastShotRecord.SetWeight = StringChange.bytesToHexStr(info.Skip(42).Take(4).ToArray(), 4); + lastShotRecord.SetRatio = StringChange.bytesToHexStr(info.Skip(46).Take(4).ToArray(), 4); + lastShotRecord.PourWeight = StringChange.bytesToHexStr(info.Skip(50).Take(4).ToArray(), 4); + lastShotRecord.PourRatio = StringChange.bytesToHexStr(info.Skip(54).Take(4).ToArray(), 4); + lastShotRecord.MpTime = StringChange.bytesToHexStr(info.Skip(58).Take(4).ToArray(), 4); + lastShotRecord.HpTime = StringChange.bytesToHexStr(info.Skip(62).Take(4).ToArray(), 4); + lastShotRecord.HydrPress = StringChange.bytesToHexStr(info.Skip(66).Take(4).ToArray(), 4); + lastShotRecord.HydrTemp = StringChange.bytesToHexStr(info.Skip(70).Take(4).ToArray(), 4); + lastShotRecord.MixpistOn = StringChange.bytesToHexStr(info.Skip(74).Take(4).ToArray(), 4); + lastShotRecord.MixpistOff = StringChange.bytesToHexStr(info.Skip(78).Take(4).ToArray(), 4); + lastShotRecord.TotalYield = StringChange.bytesToHexStr(info.Skip(82).Take(4).ToArray(), 4); + lastShotRecord.PourEnd = StringChange.bytesToHexStr(info.Skip(87).Take(4).ToArray(), 4); + lastShotRecord.CreateTime = DateTime.Now; + #endregion - lastShotRecord.POLInjecFlowRate = StringChange.bytesToHexStr(info.Skip(62).Take(4).ToArray(), 4); - lastShotRecord.ISOInjecFlowRate = StringChange.bytesToHexStr(info.Skip(66).Take(4).ToArray(), 4); - lastShotRecord.HydraulicPressure = StringChange.bytesToHexStr(info.Skip(70).Take(4).ToArray(), 4); - lastShotRecord.HydraulicTemperature = StringChange.bytesToHexStr(info.Skip(74).Take(4).ToArray(), 4); - lastShotRecord.SmallPistonFiringTime = StringChange.bytesToHexStr(info.Skip(78).Take(4).ToArray(), 4); - lastShotRecord.SmallPistonGunShutdownTime = StringChange.bytesToHexStr(info.Skip(82).Take(4).ToArray(), 4); - lastShotRecord.InjectionStatus = StringChange.bytesToHexStr(info.Skip(86).Take(1).ToArray(), 1); - lastShotRecord.LastTime = DateTime.Now; - lastShotRecord.Createtime = DateTime.Now; - lastShotRecord.ProductLineCode = "111"; - if (tempLastRecord == null) { //数据库查 - tempLastRecord = _lastShotRecordServices.Query(x=>x.System == lastShotRecord.System).OrderByDescending(x=>x.Createtime).FirstOrDefault(); + tempLastRecord = _lastShotRecordServices.Query(x=>x.System == lastShotRecord.System && x.ProductLineCode==lastShotRecord.ProductLineCode && x.GunCode==lastShotRecord.GunCode).OrderByDescending(x=>x.CreateTime).FirstOrDefault(); } - if (!tempLastRecord.SmallPistonGunShutdownTime.Equals(lastShotRecord.SmallPistonGunShutdownTime)) + if (!tempLastRecord.MixpistOff.Equals(lastShotRecord.MixpistOff)) { // 刷新页面 RefreshLastShotDataDelegateEvent?.Invoke(lastShotRecord); diff --git a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs index 1c9a7876..c2ac9752 100644 --- a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs +++ b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs @@ -122,9 +122,9 @@ namespace Aucma.Core.BoxFoam.Business // test(); // 获取任务下发plc StartPassDown(); - InStore("B23600083025024860011"); + InStore("B23600083025024860011"); }); - // startTimer(); + startTimer(); } public async void test() diff --git a/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs index 77aeeb1d..3975d0fd 100644 --- a/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/FoamMachinesPageViewModel.cs @@ -36,10 +36,10 @@ namespace Aucma.Core.BoxFoam.ViewModels if (record.System == "1") { system = "1系统"; - PolFlow1 = record.POLInjecFlowRate; - IsoFlow1 = record.ISOInjecFlowRate; - PoleTmperature1 = record.POLInjecTemperatureOfGunHead; - IsoTemperature1 = record.ISOInjecTemperatureOfGunHead; + // PolFlow1 = record.POLInjecFlowRate; + // IsoFlow1 = record.ISOInjecFlowRate; + // PoleTmperature1 = record.POLInjecTemperatureOfGunHead; + // IsoTemperature1 = record.ISOInjecTemperatureOfGunHead; } if (record.System == "2") { system = "2系统"; } @@ -47,14 +47,14 @@ namespace Aucma.Core.BoxFoam.ViewModels { No = LastShotRecordDataGrid.Count+1, System = system, - GunHead = record.GunHead, - StationNumber = record.StationNumber, - PolInjectionpressure = record.PolInjectionpressure, - IsoInjectionpressure = record.IsoInjectionpressure, - PolInjectiontemperature = record.PolInjectiontemperature, - IsoInjectiontemperature = record.IsoInjectiontemperature, - LastTime = record.LastTime, - Createtime = record.Createtime + GunHead = record.GunCode, + // StationNumber = record.StationNumber, + PolInjectionpressure = record.PolHp, + IsoInjectionpressure = record.IsoHp, + PolInjectiontemperature = record.PolTemp, + IsoInjectiontemperature = record.IsoTemp, + LastTime = record.CreateTime, + Createtime = record.CreateTime }); })); @@ -74,7 +74,7 @@ namespace Aucma.Core.BoxFoam.ViewModels int i = 1; var list = await _boxLastShotRecordServices.QueryAsync(); if (list == null) return; - list.OrderByDescending(d => d.LastTime); + list.OrderByDescending(d => d.CreateTime); foreach (var item in list.Take(50)) { string system = string.Empty; @@ -84,14 +84,14 @@ namespace Aucma.Core.BoxFoam.ViewModels { No = i, System = system, - GunHead=item.GunHead, - StationNumber=item.StationNumber, - PolInjectionpressure = item.PolInjectionpressure, - IsoInjectionpressure = item.IsoInjectionpressure, - PolInjectiontemperature = item.PolInjectiontemperature, - IsoInjectiontemperature = item.IsoInjectiontemperature, - LastTime = item.LastTime, - Createtime = item.Createtime + GunHead=item.GunCode, + // StationNumber=item.StationNumber, + PolInjectionpressure = item.PolHp, + IsoInjectionpressure = item.IsoHp, + PolInjectiontemperature = item.PolTemp, + IsoInjectiontemperature = item.IsoTemp, + LastTime = item.CreateTime, + Createtime = item.CreateTime }); i++; }; diff --git a/Aucma.Core.ProductOffLine/appsettings.json b/Aucma.Core.ProductOffLine/appsettings.json index e59015e5..f826cdce 100644 --- a/Aucma.Core.ProductOffLine/appsettings.json +++ b/Aucma.Core.ProductOffLine/appsettings.json @@ -82,7 +82,7 @@ "Enabled": true, "HitRate": 50, //"Connection": "Data Source=localhost;Initial Catalog=Hsdb;User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", - "Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=175.27.215.92)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=helowin)));User ID=aucma_scada;Password=aucma;", + "Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.72.20)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORCLCDB)));User ID=C##aucma_scada;Password=aucma;", "ProviderName": "System.Data.SqlClient" }, { @@ -90,7 +90,7 @@ "DBType": 3, "Enabled": true, "HitRate": 40, - "Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=175.27.215.92)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=helowin)));User ID=aucma_mes;Password=aucma;", + "Connection": "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.72.20)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORCLCDB)));User ID=c##aucma_mes;Password=aucma;", "ProviderName": "System.Data.SqlClient" }, { From 85ac6c05fc2e1ee10bcc18589f1e6360f347a74a Mon Sep 17 00:00:00 2001 From: liuwf Date: Thu, 28 Dec 2023 19:35:08 +0800 Subject: [PATCH 5/5] =?UTF-8?q?change-=E6=96=B0=E7=BA=BF=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E4=B8=80=E6=9E=AA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Model_New/BoxLastShotRecord.cs | 2 +- .../Service_New/ProductOffLineServices.cs | 3 +- .../Jobs/Job_BoxFoamLastData_Quartz.cs | 37 +++++++++++++------ .../Business/InStoreBusiness.cs | 6 +-- Aucma.Core.BoxFoam/appsettings.json | 2 +- .../Business/offLineBusiness.cs | 11 +++++- 6 files changed, 42 insertions(+), 19 deletions(-) diff --git a/Admin.Core.Model/Model_New/BoxLastShotRecord.cs b/Admin.Core.Model/Model_New/BoxLastShotRecord.cs index 23c94423..28e380d9 100644 --- a/Admin.Core.Model/Model_New/BoxLastShotRecord.cs +++ b/Admin.Core.Model/Model_New/BoxLastShotRecord.cs @@ -13,7 +13,7 @@ namespace Admin.Core.Model /// [SugarTable("BOX_LASTSHOTRECORD", "AUCMA_SCADA")] public class BoxLastShotRecord - { + { /// /// 主键 /// diff --git a/Admin.Core.Service/Service_New/ProductOffLineServices.cs b/Admin.Core.Service/Service_New/ProductOffLineServices.cs index e328b7e1..1642410d 100644 --- a/Admin.Core.Service/Service_New/ProductOffLineServices.cs +++ b/Admin.Core.Service/Service_New/ProductOffLineServices.cs @@ -34,7 +34,8 @@ namespace Admin.Core.Service try { var _db = baseRepository.Db; - var infos = await _db.Ado.SqlQueryAsync($"SELECT ILS_TMPRD.ILS_SORT_BARCODE_PKG.GET_BARCODE_DATA({barCode}) FROM DUAL"); + string sql = "SELECT ILS_TMPRD.ILS_SORT_BARCODE_PKG.GET_BARCODE_DATA('"+barCode+ "') as result FROM DUAL"; + var infos = await _db.Ado.SqlQueryAsync(sql); return infos.FirstOrDefault().result; } catch (Exception ex) diff --git a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs index a86a753d..a9e22b64 100644 --- a/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs +++ b/Admin.Core.Tasks/QuartzNet/Jobs/Job_BoxFoamLastData_Quartz.cs @@ -47,7 +47,7 @@ namespace Admin.Core.Tasks { // await ExecuteJob(context, async () => await Run(context)); // await ExecuteJob(context, async () => await BoxFoamDataRun(context)); - await ExecuteJob(context, async () => await Collect(context)); + await ExecuteJob(context, async () => await Collect(context)); } /// @@ -57,9 +57,14 @@ namespace Admin.Core.Tasks /// public async Task Collect(IJobExecutionContext context) { - await CollectLast(); - } + CollectLast(); + // CollectMachine(); + } + /// + /// 采集最后一枪数据 + /// + /// public async Task CollectLast() { var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("Plc1")); @@ -86,7 +91,7 @@ namespace Admin.Core.Tasks lastShotRecord.SetWeight = StringChange.bytesToHexStr(info.Skip(42).Take(4).ToArray(), 4); lastShotRecord.SetRatio = StringChange.bytesToHexStr(info.Skip(46).Take(4).ToArray(), 4); lastShotRecord.PourWeight = StringChange.bytesToHexStr(info.Skip(50).Take(4).ToArray(), 4); - lastShotRecord.PourRatio = StringChange.bytesToHexStr(info.Skip(54).Take(4).ToArray(), 4); + lastShotRecord.PourRatio = StringChange.bytesToHexStr(info.Skip(54).Take(4).ToArray(), 4); lastShotRecord.MpTime = StringChange.bytesToHexStr(info.Skip(58).Take(4).ToArray(), 4); lastShotRecord.HpTime = StringChange.bytesToHexStr(info.Skip(62).Take(4).ToArray(), 4); lastShotRecord.HydrPress = StringChange.bytesToHexStr(info.Skip(66).Take(4).ToArray(), 4); @@ -94,16 +99,16 @@ namespace Admin.Core.Tasks lastShotRecord.MixpistOn = StringChange.bytesToHexStr(info.Skip(74).Take(4).ToArray(), 4); lastShotRecord.MixpistOff = StringChange.bytesToHexStr(info.Skip(78).Take(4).ToArray(), 4); lastShotRecord.TotalYield = StringChange.bytesToHexStr(info.Skip(82).Take(4).ToArray(), 4); - lastShotRecord.PourEnd = StringChange.bytesToHexStr(info.Skip(87).Take(4).ToArray(), 4); + lastShotRecord.PourEnd = StringChange.bytesToHexStr(info.Skip(87).Take(1).ToArray(), 1); lastShotRecord.CreateTime = DateTime.Now; #endregion if (tempLastRecord == null) { //数据库查 - tempLastRecord = _lastShotRecordServices.Query(x=>x.System == lastShotRecord.System && x.ProductLineCode==lastShotRecord.ProductLineCode && x.GunCode==lastShotRecord.GunCode).OrderByDescending(x=>x.CreateTime).FirstOrDefault(); + tempLastRecord = _lastShotRecordServices.Query(x => x.System == lastShotRecord.System && x.ProductLineCode == lastShotRecord.ProductLineCode && x.GunCode == lastShotRecord.GunCode).OrderByDescending(x => x.CreateTime).FirstOrDefault(); } - if (!tempLastRecord.MixpistOff.Equals(lastShotRecord.MixpistOff)) + if (tempLastRecord == null || !tempLastRecord.MixpistOff.Equals(lastShotRecord.MixpistOff)) { // 刷新页面 RefreshLastShotDataDelegateEvent?.Invoke(lastShotRecord); @@ -111,14 +116,24 @@ namespace Admin.Core.Tasks _lastShotRecordServices.AddAsync(lastShotRecord); tempLastRecord = lastShotRecord; } + } + } - + /// + /// 采集设备其他数据 + /// + /// + public async Task CollectMachine() + { + var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("Plc1")); + if (obj != null && obj.plc.IsConnected) + { + byte[] info = obj.plc.ReadBytes("DB50.896", (ushort)88); } - } - - public async Task Run(IJobExecutionContext context) + } + public async Task Run(IJobExecutionContext context) { await SaveData(); } diff --git a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs index c2ac9752..63ca3041 100644 --- a/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs +++ b/Aucma.Core.BoxFoam/Business/InStoreBusiness.cs @@ -121,10 +121,10 @@ namespace Aucma.Core.BoxFoam.Business // test(); // 获取任务下发plc - StartPassDown(); - InStore("B23600083025024860011"); + // StartPassDown(); + // InStore("B23600083025024860011"); }); - startTimer(); + // startTimer(); } public async void test() diff --git a/Aucma.Core.BoxFoam/appsettings.json b/Aucma.Core.BoxFoam/appsettings.json index 3f3b9ee3..07ba5ff6 100644 --- a/Aucma.Core.BoxFoam/appsettings.json +++ b/Aucma.Core.BoxFoam/appsettings.json @@ -98,7 +98,7 @@ "ID": 1, "Name": "InstoreJob", "JobGroup": "DEFAULT", - "Cron": "*/1 * * * * ?", + "Cron": "*/20 * * * * ?", "AssemblyName": "Admin.Core.Tasks", "ClassName": "Job_BoxFoamLastData_Quartz", "Remark": "最后一枪数据采集", diff --git a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs index ca516e79..ad65e28b 100644 --- a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs +++ b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs @@ -8,8 +8,12 @@ using Aucma.Core.ProductOffLine; using Aucma.Core.ProductOffLine.Models; using log4net; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.IdentityModel.Logging; +using Microsoft.VisualBasic.ApplicationServices; using NetTaste; +using NPOI.SS.Formula.Functions; +using Oracle.ManagedDataAccess.Client; using RestSharp; using StackExchange.Redis; using System; @@ -99,8 +103,11 @@ namespace Aucma.Core.ProductOffLine.Business public async void test() { - // string result = await _productOffLineServices.QueryChecked("16160030000000910780"); - // Console.WriteLine(result); + + + + string result = await _productOffLineServices.QueryChecked("1531000AP0098DCU0481"); + Console.WriteLine(result); // string tt = "Y@1104@16160030000000910780@000010034895@@ @000000@000000009000004899@BCD-160C,家电下乡@@BCD-160C@皓月白-家电下乡@161601300@160@1-00版@家电下乡产品@默认@2010-09-01"; //Task.Run(() => //{