diff --git a/Admin.Core.FrameWork/obj/Debug/netcoreapp3.1/Admin.Core.FrameWork.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.FrameWork/obj/Debug/netcoreapp3.1/Admin.Core.FrameWork.GeneratedMSBuildEditorConfig.editorconfig index a3871f56..78bd9222 100644 --- a/Admin.Core.FrameWork/obj/Debug/netcoreapp3.1/Admin.Core.FrameWork.GeneratedMSBuildEditorConfig.editorconfig +++ b/Admin.Core.FrameWork/obj/Debug/netcoreapp3.1/Admin.Core.FrameWork.GeneratedMSBuildEditorConfig.editorconfig @@ -1,3 +1,9 @@ is_global = true build_property.RootNamespace = Admin.Core.FrameWork +<<<<<<< HEAD build_property.ProjectDir = E:\c#\AUCMA\new\Admin.Core.FrameWork\ +======= +build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.FrameWork\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +>>>>>>> 346821a670b23ccc6bf0121bb0363fb2fb2b4f48 diff --git a/Admin.Core.Model/Model_New/PrintSuppleMentBarCode.cs b/Admin.Core.Model/Model_New/PrintSuppleMentBarCode.cs index 871b561a..c2f2e370 100644 --- a/Admin.Core.Model/Model_New/PrintSuppleMentBarCode.cs +++ b/Admin.Core.Model/Model_New/PrintSuppleMentBarCode.cs @@ -58,7 +58,7 @@ namespace Admin.Core.Model /// 是否打印 1=>打印 /// [SugarColumn(ColumnName = "IS_PRINT")] - public int IsPrint { get; set; } + public string IsPrint { get; set; } } } diff --git a/Admin.Core.RealTimeService/obj/Debug/net6.0/Admin.Core.RealTimeService.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.RealTimeService/obj/Debug/net6.0/Admin.Core.RealTimeService.GeneratedMSBuildEditorConfig.editorconfig index 6a8a8ca9..eba502bd 100644 --- a/Admin.Core.RealTimeService/obj/Debug/net6.0/Admin.Core.RealTimeService.GeneratedMSBuildEditorConfig.editorconfig +++ b/Admin.Core.RealTimeService/obj/Debug/net6.0/Admin.Core.RealTimeService.GeneratedMSBuildEditorConfig.editorconfig @@ -8,4 +8,10 @@ build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = Admin.Core.RealTimeService +<<<<<<< HEAD build_property.ProjectDir = E:\c#\AUCMA\new\Admin.Core.RealTimeService\ +======= +build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.RealTimeService\ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +>>>>>>> 346821a670b23ccc6bf0121bb0363fb2fb2b4f48 diff --git a/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs b/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs index 04d485dd..bf530f85 100644 --- a/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs +++ b/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Timers; @@ -156,6 +157,9 @@ namespace Aucma.Core.BoxFoam.Business if (obj1.plc.IsConnected) { var flag = obj1.plc.WriteBool("M6.0", true);//换班 数据清空 + Thread.Sleep(500); + obj1.plc.WriteBool("M6.0", false);//数据清空后复位 + Console.WriteLine($"班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); log.Warn($"班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); } } @@ -165,6 +169,9 @@ namespace Aucma.Core.BoxFoam.Business if (obj2.plc.IsConnected) { bool flag = obj2.plc.WriteBool("M6.0", true);//换班 数据清空 + Thread.Sleep(500); + obj2.plc.WriteBool("M6.0", false);//数据清空后复位 + Console.WriteLine($"班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); log.Warn($"班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); } } diff --git a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs index fa69b91d..6cb37907 100644 --- a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs @@ -47,7 +47,7 @@ namespace Aucma.Core.BoxFoam.ViewModels await init(); await RefreshTeamTime();//班组时间 }); - + TeamSwitchBusiness teamSwitchBusiness = new TeamSwitchBusiness(); teamSwitchBusiness.Init();//切换班组清空发泡产量 //实时更新界面时间 @@ -489,8 +489,62 @@ namespace Aucma.Core.BoxFoam.ViewModels { System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { - CurrentDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - + DateTime now = DateTime.Now; + CurrentDateTime = now.ToString("yyyy-MM-dd HH:mm:ss"); + DateTime scheduledTime = new DateTime(now.Year, now.Month, now.Day, 20, 00, 00); + string date = scheduledTime.ToString(); + if (CurrentDateTime== date) + { + var obj1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); + if (obj1 != null) + { + if (obj1.plc.IsConnected) + { + var flag = obj1.plc.WriteBool("M6.0", true);//换班 数据清空 + Thread.Sleep(500); + obj1.plc.WriteBool("M6.0", false);//换班 数据清空 + log.Warn($"班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); + } + } + var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc")); + if (obj2 != null) + { + if (obj2.plc.IsConnected) + { + bool flag = obj2.plc.WriteBool("M6.0", true);//换班 数据清空 + Thread.Sleep(500); + obj2.plc.WriteBool("M6.0", false);//换班 数据清空 + log.Warn($"班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); + } + } + } + DateTime scheduledTime2 = new DateTime(now.Year, now.Month, now.Day, 8, 00, 00); + string date2 = scheduledTime2.ToString(); + if (CurrentDateTime == date2) + { + var obj1 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); + if (obj1 != null) + { + if (obj1.plc.IsConnected) + { + var flag = obj1.plc.WriteBool("M6.0", true);//换班 数据清空 + Thread.Sleep(500); + obj1.plc.WriteBool("M6.0", false);//换班 数据清空 + log.Warn($"班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); + } + } + var obj2 = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc")); + if (obj2 != null) + { + if (obj2.plc.IsConnected) + { + bool flag = obj2.plc.WriteBool("M6.0", true);//换班 数据清空 + Thread.Sleep(500); + obj2.plc.WriteBool("M6.0", false);//换班 数据清空 + log.Warn($"班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); + } + } + } })); } diff --git a/Aucma.Core.DataCollector/Factory/Class1.cs b/Aucma.Core.DataCollector/Factory/Class1.cs new file mode 100644 index 00000000..1b5c4494 --- /dev/null +++ b/Aucma.Core.DataCollector/Factory/Class1.cs @@ -0,0 +1,27 @@ +using Admin.Core.IService.IService_New; +using Admin.Core.Model.Model_New; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Aucma.Core.DataCollector.Factory +{ + internal class Class1 : DataCollectorFactory + { + public Class1(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices) + { + } + + public override void CollectDeviceAlarmInfo(out List deviceAlarmInfos) + { + throw new NotImplementedException(); + } + + public override void CollectDeviceElectricity(out Record_DeviceElectricity deviceElectricity) + { + throw new NotImplementedException(); + } + } +} diff --git a/Aucma.Core.PrintTo/Assets/Images/favicon.ico b/Aucma.Core.PrintTo/Assets/Images/favicon.ico new file mode 100644 index 00000000..3a4f8e6f Binary files /dev/null and b/Aucma.Core.PrintTo/Assets/Images/favicon.ico differ diff --git a/Aucma.Core.PrintTo/Assets/Images/log.png b/Aucma.Core.PrintTo/Assets/Images/log.png new file mode 100644 index 00000000..108e91b2 Binary files /dev/null and b/Aucma.Core.PrintTo/Assets/Images/log.png differ diff --git a/Aucma.Core.PrintTo/Assets/Images/login-background.png b/Aucma.Core.PrintTo/Assets/Images/login-background.png new file mode 100644 index 00000000..40909f97 Binary files /dev/null and b/Aucma.Core.PrintTo/Assets/Images/login-background.png differ diff --git a/Aucma.Core.PrintTo/Aucma.Core.PrintTo.csproj b/Aucma.Core.PrintTo/Aucma.Core.PrintTo.csproj index 012acd71..fe6ff038 100644 --- a/Aucma.Core.PrintTo/Aucma.Core.PrintTo.csproj +++ b/Aucma.Core.PrintTo/Aucma.Core.PrintTo.csproj @@ -5,18 +5,32 @@ net6.0-windows enable true + favicon.ico + + + + + + + + + + + + + @@ -59,7 +73,7 @@ PreserveNewest - PreserveNewest + Always diff --git a/Aucma.Core.PrintTo/ViewModels/IndexPageViewModel.cs b/Aucma.Core.PrintTo/ViewModels/IndexPageViewModel.cs index 23881587..c36560d4 100644 --- a/Aucma.Core.PrintTo/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.PrintTo/ViewModels/IndexPageViewModel.cs @@ -1,4 +1,5 @@ -using Admin.Core.IService; +using Admin.Core.Common; +using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Model.ViewModels; using Aucma.Core.PrintTo.Models; @@ -6,6 +7,7 @@ using Aucma.Core.PrintTo.Views; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Messaging; +using FastReport; using log4net; using Microsoft.Extensions.DependencyInjection; using System; @@ -51,7 +53,9 @@ namespace Aucma.Core.PrintTo.ViewModels Datalist.Clear(); List list = await _baseOrderInfoServices.QueryPrintInfo(); if (list == null) return; - list= list.OrderBy(d => d.CreateTime).ToList(); + list= list.Where(d=>d.PlanAmount>d.CompleteAmount).ToList(); + if (list == null) return; + list = list.OrderBy(d => d.CreateTime).ToList(); var printBarCode = await _printBarCodeServices.QueryAsync(); foreach (var item in list) { @@ -406,5 +410,49 @@ namespace Aucma.Core.PrintTo.ViewModels } #endregion + + #region 测试打印 + [RelayCommand] + public void GetTest() + { + string MaterialCode = "8301501093", + falg = "L"; + string barCode = $"{falg}{DateTime.Now.ToString("yyMMdd")}{MaterialCode}"; + string printer = Appsettings.app("Printer", "PrinterName"); + for (int i = 1; i < 123; i++) + { + string code = i.ToString().PadLeft(4, '0'); + + #region 打印 + + //对接打印机 + Report barReport = new Report(); + barReport.Load(System.Environment.CurrentDirectory + @"\Report\MaterialBar.frx");//打印报表位置 + + // 设置打印机和打印选项 + barReport.PrintSettings.ShowDialog = false; // 是否打开打印机选择框 + barReport.PrintSettings.Printer = printer; // 设置打印机名称 + barReport.PrintSettings.Copies = 1; // 设置打印份数 + barReport.SetParameterValue("BoxBarData.Id", barCode + code); + barReport.SetParameterValue("BoxBarData.Order_No", "11260310");//订单号 + barReport.SetParameterValue("BoxBarData.Order_Material_Name", "BC/BD-100HT.白");//物料简码 + barReport.SetParameterValue("BoxBarData.Bar_Code", barCode + code);//二维码 + barReport.Print(); + + #endregion + + PrintBarCode printBarCode = new PrintBarCode(); + printBarCode.MaterialBarcode = barCode + code; + printBarCode.PrintBarType = 2;//内胆码 + printBarCode.OrderCode = "11260310"; + printBarCode.MaterialCode = "8301501093"; + printBarCode.MaterialName = "内胆部件,BC/BD-100HT,预涂钢板,标准白,成型线,N"; + printBarCode.PrintTime = DateTime.Now; + printBarCode.SupplementMaterial = 0; + + var num = _printBarCodeServices.AddAsync(printBarCode).Result; + } + } + #endregion } } diff --git a/Aucma.Core.PrintTo/ViewModels/PrintToDevViewModel.cs b/Aucma.Core.PrintTo/ViewModels/PrintToDevViewModel.cs index 348a680a..ec9cd7b8 100644 --- a/Aucma.Core.PrintTo/ViewModels/PrintToDevViewModel.cs +++ b/Aucma.Core.PrintTo/ViewModels/PrintToDevViewModel.cs @@ -7,6 +7,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Messaging; using FastReport; +using FastReport.DevComponents.DotNetBar; using log4net; using Microsoft.Extensions.DependencyInjection; using StackExchange.Profiling.Internal; @@ -323,21 +324,33 @@ namespace Aucma.Core.PrintTo.ViewModels string barCode = string.Empty; if (_printType== 200) { - string rowNum = GetMaxNumAsync(item.MaterialCode,"B").Result;//最大值+1 - barCode = $"B{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}{rowNum}"; + barCode = GetMaxNumAsync(item.MaterialCode,"B").Result;//最大值+1 + if (string.IsNullOrEmpty(barCode)) + { + printState = PrintState.Paused; + SetPaused(); + continue; + } + //barCode = $"B{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}{rowNum}"; PrintProgress = $"[{PrintAmount}/{i}] {barCode}"; printBarCode.MaterialBarcode = barCode; printBarCode.PrintBarType = 1; - Console.WriteLine($"B{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}{rowNum}"); + Console.WriteLine($"{barCode}"); } if (_printType == 500) { - string rowNum = GetMaxNumAsync(item.MaterialCode, "L").Result;//最大值+1 - barCode = $"L{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}{rowNum}"; + barCode = GetMaxNumAsync(item.MaterialCode, "B").Result;//最大值+1 + if (string.IsNullOrEmpty(barCode)) + { + printState = PrintState.Paused; + SetPaused(); + continue; + } + // barCode = $"L{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}{rowNum}"; PrintProgress = $"[{PrintAmount}/{i}] {barCode}"; printBarCode.MaterialBarcode = barCode; printBarCode.PrintBarType = 2;//内胆码 - Console.WriteLine($"L{DateTime.Now.ToString("yyMMdd")}{item.MaterialCode}{rowNum}"); + Console.WriteLine($"{barCode}"); } #region 打印 @@ -414,13 +427,15 @@ namespace Aucma.Core.PrintTo.ViewModels /// public async Task GetMaxNumAsync(string MaterialCode,string falg) { + string barCode = $"{falg}{DateTime.Now.ToString("yyMMdd")}{MaterialCode}"; try { + List tempList = new List(); - var list = await _printBarCodeServices.QueryAsync(d => d.MaterialBarcode.Contains(MaterialCode) && d.MaterialBarcode.Substring(0, 1).Equals(falg)); + var list = await _printBarCodeServices.QueryAsync(d => d.MaterialBarcode.Contains(barCode) ); if (list.Count() == 0) { - return "0001"; + return barCode+"0001"; } foreach (var item in list) { @@ -428,15 +443,23 @@ namespace Aucma.Core.PrintTo.ViewModels int num = Convert.ToInt32(code); tempList.Add(num); } + int row = tempList.Max() + 1; + if (row==10000) + { + MessageBox.Show("订单打印数据已经超过10000!无法查询打印条码数据。", "系统提醒"); + return null; + } string maxStr = (tempList.Max() + 1).ToString(); string rowNum = maxStr.PadLeft(4, '0'); - return rowNum; + return barCode+rowNum; } catch { - return "0001"; + return barCode+"0001"; } } + + #endregion #endregion diff --git a/Aucma.Core.PrintTo/ViewModels/SupplementPrintPageViewModel.cs b/Aucma.Core.PrintTo/ViewModels/SupplementPrintPageViewModel.cs index b6a207e5..865e4337 100644 --- a/Aucma.Core.PrintTo/ViewModels/SupplementPrintPageViewModel.cs +++ b/Aucma.Core.PrintTo/ViewModels/SupplementPrintPageViewModel.cs @@ -7,6 +7,7 @@ using Aucma.Core.PrintTo.Models; using Aucma.Core.PrintTo.Views; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; +using CommunityToolkit.Mvvm.Messaging; using log4net; using Microsoft.Extensions.DependencyInjection; using System; @@ -30,6 +31,7 @@ namespace Aucma.Core.PrintTo.ViewModels _printSuppleMentBarCodeServices = App.ServiceProvider.GetService(); _baseOrderInfoServices = App.ServiceProvider.GetService(); Task.WaitAll(LoadData()); + WeakReferenceMessenger.Default.Register(this, Recive); } #region 选中订单参数 @@ -73,11 +75,16 @@ namespace Aucma.Core.PrintTo.ViewModels MessageBox.Show("请选中要补打的条码!", "系统提醒"); return; } - int Id = Convert.ToInt32(obj); + if (string.IsNullOrWhiteSpace(obj)) + { + MessageBox.Show("请选中要补打的条码!", "系统提醒"); + return; + } + int Id = Convert.ToInt32(obj); var printSuppleMentBarCode = _printSuppleMentBarCodeServices.FirstAsync(d => d.ObjId == Id).Result; if (printSuppleMentBarCode != null) { - if (printSuppleMentBarCode.IsPrint==1) + if (printSuppleMentBarCode.IsPrint=="1") { MessageBox.Show("选中的条码已补打过,请选择其他未补打条码!", "系统提醒"); return; @@ -156,7 +163,7 @@ namespace Aucma.Core.PrintTo.ViewModels private async Task LoadData() { - var list = await _printSuppleMentBarCodeServices.QueryAsync(); + var list = await _printSuppleMentBarCodeServices.QueryAsync(d=>d.IsPrint==null|| d.IsPrint == ""); if (list == null) return; foreach (var item in list) @@ -200,5 +207,22 @@ namespace Aucma.Core.PrintTo.ViewModels } } #endregion + + #region 刷新列表-其他界面刷新该方法 + /// + /// 刷新列表 + /// + /// + /// + private void Recive(object recipient, string message) + { + if (message == "RefreshSupplement") + { + Datalist.Clear(); + Task.WaitAll(LoadData()); + } + + } + #endregion } } diff --git a/Aucma.Core.PrintTo/ViewModels/SupplementViewModel.cs b/Aucma.Core.PrintTo/ViewModels/SupplementViewModel.cs index bae51344..41ec61db 100644 --- a/Aucma.Core.PrintTo/ViewModels/SupplementViewModel.cs +++ b/Aucma.Core.PrintTo/ViewModels/SupplementViewModel.cs @@ -82,7 +82,7 @@ namespace Aucma.Core.PrintTo.ViewModels #endregion //打印完成 不可以再次打印 - printSuppleMentBarCode.IsPrint = 1; + printSuppleMentBarCode.IsPrint = "1"; printSuppleMentBarCode.PrintTime = DateTime.Now; await _printSuppleMentBarCodeServices.UpdateAsync(printSuppleMentBarCode); //打印完成 @@ -229,7 +229,27 @@ namespace Aucma.Core.PrintTo.ViewModels } #endregion + #region 关闭当前界面 + /// + /// 关闭当前界面 + /// + /// + [RelayCommand] + public void CloseWindow(object parameter) + { + var window = parameter as Window; + if (window == null) return; + + + if (MessageBox.Show("确定要退出打印吗?", "系统提醒", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) + { + printState = PrintState.Stopped; + WeakReferenceMessenger.Default.Send("RefreshSupplement");//刷新窗口 + window.Close(); + } + } + + #endregion - } } diff --git a/Aucma.Core.PrintTo/Views/IndexPageView.xaml b/Aucma.Core.PrintTo/Views/IndexPageView.xaml index 8014b7d2..2d75ed70 100644 --- a/Aucma.Core.PrintTo/Views/IndexPageView.xaml +++ b/Aucma.Core.PrintTo/Views/IndexPageView.xaml @@ -166,6 +166,7 @@