diff --git a/Admin.Core.Api/Admin.Core.Model.xml b/Admin.Core.Api/Admin.Core.Model.xml index 3cd79122..a11a9b32 100644 --- a/Admin.Core.Api/Admin.Core.Model.xml +++ b/Admin.Core.Api/Admin.Core.Model.xml @@ -2721,6 +2721,36 @@ 匹配时间 + + + 异常记录表,暂时只有成品下线使用 + + + + + 主键 + + + + + 产品条码 + + + + + 异常信息 + + + + + 扫描时间 + + + + + 产线编号 + + 计划执行表 diff --git a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs index a906334b..2aa8fa0f 100644 --- a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs +++ b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Common")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+bea6862206de984208a5625df9b5cce4bce9db21")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] [assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Common")] [assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Common")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache index 50f669c8..b3b30e6b 100644 --- a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache +++ b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.AssemblyInfoInputs.cache @@ -1 +1 @@ -c442a599222e602f7178b129382ec63fa23a6ea93c436ae2c4a4f7b01d074c3f +3c08b2a6f95957043123cba0d01dcd1675663fc7 diff --git a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig index 124dffb6..e43b7078 100644 --- a/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig +++ b/Admin.Core.Common/obj/Debug/net6.0/Admin.Core.Common.GeneratedMSBuildEditorConfig.editorconfig @@ -8,6 +8,4 @@ build_property.PlatformNeutralAssembly = build_property.EnforceExtendedAnalyzerRules = build_property._SupportedPlatformList = Linux,macOS,Windows build_property.RootNamespace = Admin.Core.Common -build_property.ProjectDir = D:\Project\gitea\AUCMA\SCADA\Admin.Core.Common\ -build_property.EnableComHosting = -build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.ProjectDir = E:\c#\AUCMA\new\Admin.Core.Common\ diff --git a/Admin.Core.IRepository/IRepository_New/IExceptionRecordRepository.cs b/Admin.Core.IRepository/IRepository_New/IExceptionRecordRepository.cs new file mode 100644 index 00000000..006470d9 --- /dev/null +++ b/Admin.Core.IRepository/IRepository_New/IExceptionRecordRepository.cs @@ -0,0 +1,15 @@ +using Admin.Core.Model; +using Admin.Core.Model.Model_New; +using Admin.Core.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Admin.Core.IRepository +{ + /// + /// IDoorFoamRecordRepository + /// + public interface IExceptionRecordRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/IExceptionRecordServices.cs b/Admin.Core.IService/IService_New/IExceptionRecordServices.cs new file mode 100644 index 00000000..22f69dca --- /dev/null +++ b/Admin.Core.IService/IService_New/IExceptionRecordServices.cs @@ -0,0 +1,17 @@ +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Model.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Admin.Core.IService +{ + /// + /// 条码绑定 + /// + public interface IExceptionRecordServices : IBaseServices + { + + + } +} \ No newline at end of file diff --git a/Admin.Core.IService/IService_New/IReportQualityInspectionServices.cs b/Admin.Core.IService/IService_New/IReportQualityInspectionServices.cs index 6fb3f53d..9a6e1aee 100644 --- a/Admin.Core.IService/IService_New/IReportQualityInspectionServices.cs +++ b/Admin.Core.IService/IService_New/IReportQualityInspectionServices.cs @@ -15,7 +15,7 @@ namespace Admin.Core.IService /// 判断是否有不合格质检项 /// /// - List JudgeIsQualified(string barCode); + ReportQualityInsPection JudgeIsQualified(string BoxCode); } } \ No newline at end of file diff --git a/Admin.Core.Model/Model_New/BaseMaterialInfo.cs b/Admin.Core.Model/Model_New/BaseMaterialInfo.cs index 935e9f82..a52c2549 100644 --- a/Admin.Core.Model/Model_New/BaseMaterialInfo.cs +++ b/Admin.Core.Model/Model_New/BaseMaterialInfo.cs @@ -99,7 +99,7 @@ namespace Admin.Core.Model /// 增量日期 /// [SugarColumn(ColumnName = "INCREMENT_DATE")] - public string IncrementDate { get; set; } + public DateTime IncrementDate { get; set; } /// /// 入库方向-A/B /// diff --git a/Admin.Core.Model/Model_New/ExceptionRecord.cs b/Admin.Core.Model/Model_New/ExceptionRecord.cs new file mode 100644 index 00000000..4d72e0b5 --- /dev/null +++ b/Admin.Core.Model/Model_New/ExceptionRecord.cs @@ -0,0 +1,48 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Model +{ + /// + /// 异常记录表,暂时只有成品下线使用 + /// + [SugarTable("RECORD_EXCEPTION", "AUCMA_SCADA")] + public class ExceptionRecord + { + /// + /// 主键 + /// + [SugarColumn(ColumnName = "OBJ_ID", IsIdentity = true, IsPrimaryKey = true, OracleSequenceName = "SEQ_RECORD_EXCEPTION")] + public int ObjId { get; set; } + + /// + /// 产品条码 + /// + [SugarColumn(ColumnName = "PRODUCT_SNCODE")] + public string ProductSnCode { get; set; } + + /// + /// 异常信息 + /// + [SugarColumn(ColumnName = "EXCEPTION_MSG")] + public string ExceptionMsg { get; set; } + + /// + /// 扫描时间 + /// + [SugarColumn(ColumnName = "PRODUCT_SCANTIME")] + public DateTime ProductScanTime { get; set; } + + /// + /// 产线编号 + /// + [SugarColumn(ColumnName = "PRODUCT_LINE_CODE")] + public string ProductLineCode { get; set; } + + + } +} diff --git a/Admin.Core.Repository/Repository_New/ExceptionRecordRepository.cs b/Admin.Core.Repository/Repository_New/ExceptionRecordRepository.cs new file mode 100644 index 00000000..ecf1b370 --- /dev/null +++ b/Admin.Core.Repository/Repository_New/ExceptionRecordRepository.cs @@ -0,0 +1,22 @@ +using Admin.Core.IRepository; +using Admin.Core.Model; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Admin.Core.Repository +{ + public class ExceptionRecordRepository : BaseRepository, IExceptionRecordRepository + { + public ExceptionRecordRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + + + + } +} diff --git a/Admin.Core.Service/Service_New/ExceptionRecordServices.cs b/Admin.Core.Service/Service_New/ExceptionRecordServices.cs new file mode 100644 index 00000000..3f784c2f --- /dev/null +++ b/Admin.Core.Service/Service_New/ExceptionRecordServices.cs @@ -0,0 +1,35 @@ +using Admin.Core.IRepository; +using Admin.Core.IService; +using Admin.Core.Model; +using Admin.Core.Model.Model_New; +using Admin.Core.Model.ViewModels; +using Consul; +using log4net; +using Microsoft.IdentityModel.Logging; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Admin.Core.Service +{ + public class ExceptionRecordServices : BaseServices, IExceptionRecordServices + { + #region 对象引用 + private static readonly log4net.ILog log = LogManager.GetLogger(typeof(ExceptionRecordServices)); + #endregion + + private readonly IBaseRepository _dal; + private IExceptionRecordRepository _exceptionRecordRepository; + public ExceptionRecordServices(IBaseRepository dal, IExceptionRecordRepository exceptionRecordRepository) + { + this._dal = dal; + base.BaseDal = dal; + _exceptionRecordRepository = exceptionRecordRepository; + + } + + + } +} diff --git a/Admin.Core.Service/Service_New/ReportQualityInspectionServices.cs b/Admin.Core.Service/Service_New/ReportQualityInspectionServices.cs index d1f14dd2..45e60169 100644 --- a/Admin.Core.Service/Service_New/ReportQualityInspectionServices.cs +++ b/Admin.Core.Service/Service_New/ReportQualityInspectionServices.cs @@ -15,11 +15,11 @@ namespace Admin.Core.Service public class ReportQualityInspectionServices : BaseServices, IReportQualityInspectionServices { private readonly IBaseRepository _dal; - private readonly IReportQualityInspectionRepository _baseSpaceInfoRepository; + private readonly IReportQualityInspectionRepository _qualityInspectionRepository; private readonly ICodeBindingRecordRepository _codeBindingRecordRepository; public ReportQualityInspectionServices(IBaseRepository dal, IReportQualityInspectionRepository reportQualityInspectionRepository, ICodeBindingRecordRepository codeBindingRepository) { - _baseSpaceInfoRepository = reportQualityInspectionRepository; + _qualityInspectionRepository = reportQualityInspectionRepository; _codeBindingRecordRepository = codeBindingRepository; this._dal = dal; base.BaseDal = dal; @@ -27,21 +27,15 @@ namespace Admin.Core.Service /// - /// 判断是否有不合格质检项,传入的是SN码 + /// 判断是否有不合格质检项,传入的是箱体码 /// /// - public List JudgeIsQualified(string SnCode) + public ReportQualityInsPection JudgeIsQualified(string BoxCode) { try { - List list = _codeBindingRecordRepository.Query(s => s.ProductCode == SnCode); - if(list!=null && list.Count > 0) - { - string boxCode = list.FirstOrDefault().BoxCode; - var list1 = _baseSpaceInfoRepository.Query(x => x.BarCode.Equals(boxCode) && x.IsFlag != 1); - return list1; - } - + ReportQualityInsPection record = _qualityInspectionRepository.Db.Ado.SqlQuery($"select * from REPORT_QUALITY_INSPECTION where BAR_CODE = '{BoxCode}' AND STATION_CODE = 2010 AND TREATMENT_MEASURE = 3").FirstOrDefault(); + return record; } catch (System.Exception ex) { diff --git a/Admin.Core.sln b/Admin.Core.sln index 67ec2494..bbd02f6e 100644 --- a/Admin.Core.sln +++ b/Admin.Core.sln @@ -83,6 +83,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.SheetMetal", "Au EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.DataCollector", "Aucma.Core.DataCollector\Aucma.Core.DataCollector.csproj", "{DF628848-79A6-4234-A0F6-F961DFC16A0E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.ProductOffLine", "Aucma.Core.ProductOffLine\Aucma.Core.ProductOffLine.csproj", "{1582FB18-5185-41A0-B185-914501B3FBFA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -213,6 +215,10 @@ Global {DF628848-79A6-4234-A0F6-F961DFC16A0E}.Debug|Any CPU.Build.0 = Debug|Any CPU {DF628848-79A6-4234-A0F6-F961DFC16A0E}.Release|Any CPU.ActiveCfg = Release|Any CPU {DF628848-79A6-4234-A0F6-F961DFC16A0E}.Release|Any CPU.Build.0 = Release|Any CPU + {1582FB18-5185-41A0-B185-914501B3FBFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1582FB18-5185-41A0-B185-914501B3FBFA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1582FB18-5185-41A0-B185-914501B3FBFA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1582FB18-5185-41A0-B185-914501B3FBFA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -252,6 +258,7 @@ Global {B6955077-EEE5-429B-8A79-EDE749A8B034} = {BD987F3A-4E6C-4C47-B28F-1671F875EAE3} {D452CA9F-2CF9-4978-B0BE-7365F1F7A4EB} = {BD987F3A-4E6C-4C47-B28F-1671F875EAE3} {DF628848-79A6-4234-A0F6-F961DFC16A0E} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE} + {1582FB18-5185-41A0-B185-914501B3FBFA} = {BD987F3A-4E6C-4C47-B28F-1671F875EAE3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8047AB56-042B-4AE4-B06A-34137067A86A} diff --git a/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs b/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs index 9311d479..51fe91cb 100644 --- a/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs +++ b/Aucma.Core.BoxFoam/Business/TeamSwitchBusiness.cs @@ -146,40 +146,41 @@ namespace Aucma.Core.BoxFoam.Business private void UpdateShiftInfo(int shiftType) { log.Warn($"{(shiftType == 1 ? "白班" : "夜班")}班组切换,开始处理切换逻辑"); + Console.WriteLine($"{(shiftType == 1 ? "白班" : "夜班")}班组切换,开始处理切换逻辑"); try { - #region 240325 添加清空夹具产量功能 + #region 240325 liulb 添加清空夹具产量功能; Delete By wenjy 2024-03-30 删除清空产量逻辑 //下发PLC清空产量信号 - #region 清空PLC产量,新线暂时未清除产量,如需清除可将注释取消 - var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); - if (obj1 != null) - { - if (obj1.plc.IsConnected) - { - var flag = obj1.plc.WriteBool("M6.0", true);//换班 数据清空 - log.Warn($"班组切换清空1~6区产量数据:写入清空数据点位M6.0 为true,写入结果:{flag}"); - Thread.Sleep(500); - var reset= obj1.plc.WriteBool("M6.0", false);//数据清空后复位 - log.Warn($"班组切换清空1~6区产量数据:写入清空数据点位M6.0 为false,写入结果:{reset}"); - Console.WriteLine($"【{DateTime.Now}】班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); - log.Warn($"班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); - } - } - var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc")); - if (obj2 != null) - { - if (obj2.plc.IsConnected) - { - bool flag = obj2.plc.WriteBool("M6.0", true);//换班 数据清空 - log.Warn($"班组切换清空7~12区产量数据:写入清空数据点位M6.0 为true,写入结果:{flag}"); - Thread.Sleep(500); - var reset = obj2.plc.WriteBool("M6.0", false);//数据清空后复位 - log.Warn($"班组切换清空7~12区产量数据:写入复位数据点位M6.0 为false,写入结果:{reset}"); - Console.WriteLine($"【{DateTime.Now}】班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); - log.Warn($"班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); - } - } + //var obj1 = PlcHelper.siemensList.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);//数据清空后复位 + // Console.WriteLine($"【{DateTime.Now}】班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); + // log.Warn($"班组切换清空1~6区产量数据:{(flag == true ? "成功" : "失败")}"); + // } + //} + //var obj2 = PlcHelper.siemensList.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);//数据清空后复位 + // Console.WriteLine($"【{DateTime.Now}】班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); + // log.Warn($"班组切换清空7~12区产量数据:{(flag == true ? "成功" : "失败")}"); + // } + //} #endregion + + #region Add By wenjy 2024-03-30 10:56:00 清空PLC产量,写true保持500毫秒后写false + ClearPlcOutPut(true); + Thread.Sleep(3000); + ClearPlcOutPut(false); #endregion //小时统计报表数据存至记录表,清空小时统计报表 @@ -278,5 +279,33 @@ namespace Aucma.Core.BoxFoam.Business log.Warn($"{(shiftType == 1 ? "白班" : "夜班")}班组切换,切换逻辑处理异常:{ex.Message}"); } } + + /// + /// 清空PLC产量数据 + /// + /// + private void ClearPlcOutPut(bool value) + { + var obj1 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine1Plc")); + if (obj1 != null) + { + if (obj1.plc.IsConnected) + { + var flag = obj1.plc.WriteBool("M6.0", value);//换班 数据清空 + log.Warn($"班组切换清空A区产量数据写{value}:{(flag == true ? "成功" : "失败")}"); + Console.WriteLine($"班组切换清空A区产量数据写{value}:{(flag == true ? "成功" : "失败")}"); + } + } + var obj2 = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("foamLine2Plc")); + if (obj2 != null) + { + if (obj2.plc.IsConnected) + { + bool flag = obj2.plc.WriteBool("M6.0", value);//换班 数据清空 + log.Warn($"班组切换清空B区产量数据写{value}:{(flag == true ? "成功" : "失败")}"); + Console.WriteLine($"班组切换清空B区产量数据写{value}:{(flag == true ? "成功" : "失败")}"); + } + } + } } } diff --git a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs index a10e728d..a14025df 100644 --- a/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs +++ b/Aucma.Core.BoxFoam/ViewModels/MainWindowViewModel.cs @@ -48,7 +48,7 @@ namespace Aucma.Core.BoxFoam.ViewModels { await init(); await RefreshTeamTime();//班组时间 - await ClearProduct(); + //await ClearProduct(); }); TeamSwitchBusiness teamSwitchBusiness = new TeamSwitchBusiness(); diff --git a/Aucma.Core.CodeBinding/Startup.cs b/Aucma.Core.CodeBinding/Startup.cs index 97613316..23ff0d9e 100644 --- a/Aucma.Core.CodeBinding/Startup.cs +++ b/Aucma.Core.CodeBinding/Startup.cs @@ -116,6 +116,7 @@ namespace Aucma.Core.CodeBinding // Socketɨ app.UseTouchSocketMildd(socket); + // ݺõɼɼ app.UseDataCollectorExtensions(); } diff --git a/Aucma.Core.DataCollector/DataCollectorFactory.cs b/Aucma.Core.DataCollector/DataCollectorFactory.cs index 011ff764..a6e120fd 100644 --- a/Aucma.Core.DataCollector/DataCollectorFactory.cs +++ b/Aucma.Core.DataCollector/DataCollectorFactory.cs @@ -25,7 +25,7 @@ namespace Aucma.Core.DataCollector public readonly IRecordDeviceElectricityServices _deviceElectricityServices; public int AlarmReadTimer = (1000 * 5); - public int EleReadTimer = (1000 * 5); + public int EleReadTimer = (1000 * 60 * 5); public DataCollectorFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) { diff --git a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs index 9ceea115..21bb48c6 100644 --- a/Aucma.Core.Palletiz/Business/InstoreBusiness.cs +++ b/Aucma.Core.Palletiz/Business/InstoreBusiness.cs @@ -37,8 +37,11 @@ namespace Aucma.Core.Palletiz.Business private AppConfig appConfig = new AppConfig(); public string storeCode = Appsettings.app("StoreInfo", "PalletizStoreCodeA"); + // 过点数据表,物料完成记录MaterialCompletion + private readonly IMaterialCompletionServices? _iMaterialCompletionServices = App.ServiceProvider.GetService(); - + private readonly IPrintBarCodeServices? _printBarCodeServices = App.ServiceProvider.GetService(); + private readonly ICodeBindingRecordServices? _codeBindingServices = App.ServiceProvider.GetService(); private readonly IRecordInStoreServices? _recordInstoreServices = App.ServiceProvider.GetService(); #region 委托事件 @@ -54,7 +57,14 @@ namespace Aucma.Core.Palletiz.Business /// public delegate void RefreshMsg(string msg); public static event RefreshMsg? RefreshMsgEvent; - + + + /// + ///入库时DataGrid添加一条DataGrid记录 + /// + public delegate void AddData(RecordInStore record); + public static event AddData? AddDataEvent; + #endregion @@ -177,6 +187,8 @@ namespace Aucma.Core.Palletiz.Business } _ = _recordInstoreServices.AddAsync(recordInstore).Result; + //刷新页面 + AddDataEvent?.Invoke(recordInstore); #endregion if (!result) @@ -208,10 +220,39 @@ namespace Aucma.Core.Palletiz.Business RefreshMsgEvent?.Invoke(msg); } + } + /// + /// 添加过点数据,暂不添加 + /// + /// + public async Task AddCompleteData(string ProductSnCode) + { + CodeBindingRecord bindingRecord1 = _codeBindingServices.FirstAsync(x => x.ProductCode == ProductSnCode).Result; + #region 更新过点数据 + if (bindingRecord1 != null && bindingRecord1.BoxCode != "") + { + PrintBarCode print = _printBarCodeServices.FirstAsync(x => x.MaterialBarcode == bindingRecord1.BoxCode).Result; + if (print != null) + { + MaterialCompletion completion = new MaterialCompletion(); + completion.OrderCode = print.OrderCode; + completion.MaterialBarcode = bindingRecord1.BoxCode; + completion.MaterialCode = print.MaterialCode; + completion.MaterialName = print.MaterialName; + // completion.StationName = "1009"; + completion.CompleteDate = DateTime.Now; + completion.ProductLineCode = "CX_02"; + completion.isDownLine = 1; + completion.ProductionCode = ProductSnCode; + _ = _iMaterialCompletionServices.AddAsync(completion).Result; + + } + } + + #endregion + } - - /// /// 通过物料型号获取货道信息 /// @@ -267,7 +308,7 @@ namespace Aucma.Core.Palletiz.Business if (plcCon == null) { - Task.Delay(1000 * 5).Wait(); + Task.Delay(1000 * 3).Wait(); plcCon = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("InStoreAPlc")); if(plcCon == null) @@ -283,8 +324,8 @@ namespace Aucma.Core.Palletiz.Business { item.SpaceCode = ExtractNumber(item.SpaceName); var plcAddress = _appConfig.plcAddr.Where(x => x.spaceCode.ToString() == item.SpaceCode && x.spaceArea == item.SpaceArea).First(); - int isFlag = _plc.ReadInt16(plcAddress.address); - if (isFlag == 1) + bool isFlag = _plc.ReadBool(plcAddress.address); + if (isFlag) { item.SpaceStatus = 3; } diff --git a/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs b/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs index 49058440..ae3dc75a 100644 --- a/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs @@ -52,6 +52,7 @@ namespace Aucma.Core.Palletiz.ViewModels foreach (ProductAllModel info in list) { MaterialDataGrid.Add(info); + } }); } @@ -97,14 +98,18 @@ namespace Aucma.Core.Palletiz.ViewModels [RelayCommand] public void Save(Window window) { - Console.WriteLine(Area); + if (Area == null) + { + MessageBox.Show("请先选择区域"); + return; + } if (string.IsNullOrEmpty(ProductCode)) { MessageBox.Show("请先选择产品型号"); return; } - HandSendEvent?.Invoke("A", productCode); + HandSendEvent?.Invoke(Area.Content.ToString(), productCode); MessageBox.Show("手动入库成功"); window.Close(); // 入库 diff --git a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs index 48f294cf..78ec4a3f 100644 --- a/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/IndexPageViewModel.cs @@ -8,6 +8,8 @@ using System.Collections.ObjectModel; using System.Linq; using Aucma.Core.Palletiz.Views; using CommunityToolkit.Mvvm.ComponentModel; +using System.Threading.Tasks; +using static Aucma.Core.Palletiz.ViewModels.StatisticsPageViewModel; /* * 成品分垛入库首页信息 @@ -24,6 +26,7 @@ namespace Aucma.Core.Palletiz.ViewModels new InStoreBusiness().Init(); SelectTypeViewModel.RefreshPageEvent += Init; + StatisticsPageViewModel.CountInstoreEvent += CountInstore; this.inStoreBusiness = App.ServiceProvider.GetService(); InStoreBusiness.RefreshMsgEvent += RefreshMsg; InStoreBusiness.RefreshProductInfoEvent += RefreshProductInfo; @@ -31,20 +34,26 @@ namespace Aucma.Core.Palletiz.ViewModels { Console.WriteLine($"{obj};设置"); BaseSpaceInfo space = inStoreBusiness.GetSpaceinfosById(obj); - if(space != null ) + if (space != null) { SelectType direct = new SelectType(space); direct.ShowDialog(); } - + }); this.Init(); - InStoreAmount = inStoreAmount + "19"; + InStoreTaskContent = new StatisticsPageView(); } + public void CountInstore(int count) + { + InStoreAmount = "入库数量:"; + InStoreAmount = inStoreAmount + count; + } + #region 参数定义 public string productSNCode = string.Empty; @@ -55,12 +64,12 @@ namespace Aucma.Core.Palletiz.ViewModels } - public string productModel = string.Empty; + public string productModel = string.Empty; public string ProductModel { get { return this.productModel; } set => SetProperty(ref productModel, value); - + } public string orderCode = string.Empty; @@ -69,7 +78,7 @@ namespace Aucma.Core.Palletiz.ViewModels get { return this.orderCode; } set => SetProperty(ref orderCode, value); - + } public string productScanTime = string.Empty; @@ -77,7 +86,7 @@ namespace Aucma.Core.Palletiz.ViewModels { get { return this.productScanTime; } - set => SetProperty(ref productScanTime, value); + set => SetProperty(ref productScanTime, value); } public string msg = string.Empty; @@ -85,7 +94,7 @@ namespace Aucma.Core.Palletiz.ViewModels { get { return this.msg; } set => SetProperty(ref msg, value); - + } public string inStoreAmount = "入库数量:"; public string InStoreAmount @@ -93,7 +102,7 @@ namespace Aucma.Core.Palletiz.ViewModels get { return this.inStoreAmount; } set => SetProperty(ref inStoreAmount, value); - + } public System.Windows.Controls.UserControl _content; @@ -104,7 +113,7 @@ namespace Aucma.Core.Palletiz.ViewModels set => SetProperty(ref _content, value); - + } /// @@ -116,7 +125,7 @@ namespace Aucma.Core.Palletiz.ViewModels { get { return _areaA_SpaceInfo; } set => SetProperty(ref _areaA_SpaceInfo, value); - + } /// @@ -128,7 +137,7 @@ namespace Aucma.Core.Palletiz.ViewModels { get { return _areaB_SpaceInfo; } set => SetProperty(ref _areaB_SpaceInfo, value); - + } #endregion @@ -160,46 +169,55 @@ namespace Aucma.Core.Palletiz.ViewModels OrderCode = orderCode; ProductScanTime = DateTime.Now.ToString(); } - private void Init() + private async Task Init() { - - var info = inStoreBusiness.GetBaseSpaceinfos("A"); - info = info.OrderByDescending(x => x.ObjId).ToList(); - if (info != null) + await Task.Run(() => { - App.Current.Dispatcher.BeginInvoke((Action)(() => + var info = inStoreBusiness.GetBaseSpaceinfos("A"); + info = info.OrderByDescending(x => x.ObjId).ToList(); + if (info != null) { - if (spaceItems.Count > 0) + App.Current.Dispatcher.BeginInvoke((Action)(() => { - spaceItems.Clear(); - } - foreach (var item in info) + if (spaceItems.Count > 0) + { + spaceItems.Clear(); + } + foreach (var item in info) + { + spaceItems.Add(item); + } + AreaA_SpaceInfo = spaceItems; + })); + } + + var info2 = inStoreBusiness.GetBaseSpaceinfos("A"); + info2 = info2.OrderBy(x => x.ObjId).ToList(); + if (info2 != null) + { + App.Current.Dispatcher.BeginInvoke((Action)(() => { - spaceItems.Add(item); - } - AreaA_SpaceInfo = spaceItems; - })); - } - - - //var info2 = inStoreBusiness.GetBaseSpaceinfos("A"); - //info2 = info2.OrderBy(x => x.ObjId).ToList(); - //if (info2 != null) - //{ - // App.Current.Dispatcher.BeginInvoke((Action)(() => - // { - // if (spaceItemsB.Count > 0) - // { - // spaceItemsB.Clear(); - // } - // foreach (var item in info2) - // { - // spaceItemsB.Add(item); - // } - // AreaB_SpaceInfo = spaceItemsB; - // })); - //} + if (spaceItemsB.Count > 0) + { + spaceItemsB.Clear(); + } + foreach (var item in info2) + { + spaceItemsB.Add(item); + } + AreaB_SpaceInfo = spaceItemsB; + })); + } + + }); + + } + + + + } } + diff --git a/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs index 250eb1e5..d4b6d6b5 100644 --- a/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/PalletizPageViewModel.cs @@ -20,7 +20,7 @@ namespace Aucma.Core.Palletiz.ViewModels public PalletizPageViewModel() { _baseSpaceInfoServices = App.ServiceProvider.GetService(); LoadDataGrid(); - SelectTypeViewModel.RefreshPageEvent += LoadDataGrid; + // SelectTypeViewModel.RefreshPageEvent += LoadDataGrid; } public void LoadDataGrid() diff --git a/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs b/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs index d4257d3c..651afb9f 100644 --- a/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/SelectTypeViewModel.cs @@ -33,7 +33,7 @@ namespace Aucma.Core.Palletiz.ViewModels /// 刷新货道页面 /// /// - public delegate void RefreshPage(); + public delegate Task RefreshPage(); public static event RefreshPage RefreshPageEvent; private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseSpaceInfoServices)); diff --git a/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs b/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs index 69cfb168..e56f017c 100644 --- a/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs +++ b/Aucma.Core.Palletiz/ViewModels/StatisticsPageViewModel.cs @@ -1,6 +1,7 @@ using Admin.Core.Common; using Admin.Core.IService; using Admin.Core.Model; +using Aucma.Core.Palletiz.Business; using Aucma.Core.Palletiz.Models; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; @@ -13,15 +14,28 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; +using System.Windows.Documents; namespace Aucma.Core.Palletiz.ViewModels { public partial class StatisticsPageViewModel : ObservableObject { - // private static readonly Lazy lazy = new Lazy(() => new StatisticsPageViewModel()); - // public static StatisticsPageViewModel Instance => lazy.Value; - public StatisticsPageViewModel() { + + + /// + /// 入库数量统计 + /// + public delegate void CountInstore(int count); + public static event CountInstore? CountInstoreEvent; + + + + // private static readonly Lazy lazy = new Lazy(() => new StatisticsPageViewModel()); + // public static StatisticsPageViewModel Instance => lazy.Value; + public StatisticsPageViewModel() + { MainWindowViewModel.RefreshInfoEvent += LoadData; + InStoreBusiness.AddDataEvent += AddData; LoadData(); } private readonly IRecordInStoreServices? _recordInstoreServices = App.ServiceProvider.GetService(); @@ -30,36 +44,52 @@ namespace Aucma.Core.Palletiz.ViewModels public string storeCodeB = Appsettings.app("StoreInfo", "PalletizStoreCodeB"); - + + /// + /// 入库时DataGrid添加一条记录 + /// + /// + public void AddData(RecordInStore record) + { + App.Current.Dispatcher.Invoke(() => + { + MaterialDataGrid.Add(record); + CountInstoreEvent?.Invoke(MaterialDataGrid.Count); + }); + } + #region 加载DataGrid数据 - private async Task LoadData() + private async Task LoadData() { + await Task.Run(() => + { + try + { - await Task.Run(() => - { - try - { + List list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.InStoreTime >= DateTime.Today).Result; + if (list != null && list.Count > 0) + { + App.Current.Dispatcher.Invoke(() => + { + MaterialDataGrid.Clear(); + CountInstoreEvent?.Invoke(list.Count); + list.OrderByDescending(x => x.InStoreTime); + foreach (RecordInStore record in list) + { - List list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.InStoreTime >= DateTime.Today).Result; - if (list != null && list.Count > 0) - { - list.OrderByDescending(x => x.InStoreTime); - foreach (RecordInStore record in list) - { - App.Current.Dispatcher.Invoke(() => - { - MaterialDataGrid.Add(record); - }); - } - } - } - catch (Exception ex) - { - Console.WriteLine("" + ex.Message.ToString()); + MaterialDataGrid.Add(record); + + } + }); + } + } + catch (Exception ex) + { + Console.WriteLine("" + ex.Message.ToString()); + + } + }); - } - }); - //MaterialDataGrid.Add(new MaterialComplateInfo() { No = 1, ProductPlanCode = "8659452123",MaterialCode = "8659452123", MaterialName = "SC-AUCMA-农夫山泉,SC", PlanAmount = 50, CompleteAmount = 10 }); } @@ -93,14 +123,14 @@ namespace Aucma.Core.Palletiz.ViewModels List list = _recordInstoreServices.QueryAsync(x => (x.StoreCode == storeCodeA || x.StoreCode == storeCodeB) && x.BarCodeCode.Contains(result)).Result; if (list != null && list.Count > 0) { - MaterialDataGrid.Clear(); - foreach (RecordInStore record in list) + App.Current.Dispatcher.Invoke(() => { - App.Current.Dispatcher.Invoke(() => + MaterialDataGrid.Clear(); + foreach (RecordInStore record in list) { MaterialDataGrid.Add(record); - }); - } + } + }); } }); } diff --git a/Aucma.Core.Palletiz/Views/HandPalletizView.xaml b/Aucma.Core.Palletiz/Views/HandPalletizView.xaml index e5b71fd6..951174e9 100644 --- a/Aucma.Core.Palletiz/Views/HandPalletizView.xaml +++ b/Aucma.Core.Palletiz/Views/HandPalletizView.xaml @@ -113,7 +113,7 @@ diff --git a/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml b/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml index 518741da..4c377bb6 100644 --- a/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml +++ b/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml @@ -108,12 +108,20 @@ + - + + + + + + + + diff --git a/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml.cs b/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml.cs index 5eae4837..9b6d4ddf 100644 --- a/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml.cs +++ b/Aucma.Core.Palletiz/Views/StatisticsPageView.xaml.cs @@ -27,5 +27,9 @@ namespace Aucma.Core.Palletiz.Views this.DataContext = new StatisticsPageViewModel(); } + private void DataGrid_LoadingRow(object sender, DataGridRowEventArgs e) + { + e.Row.Header = (e.Row.GetIndex() + 1).ToString(); + } } } diff --git a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs index 0036cfb9..3d4e4677 100644 --- a/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs +++ b/Aucma.Core.ProductOffLine/Business/offLineBusiness.cs @@ -62,14 +62,14 @@ namespace Aucma.Core.ProductOffLine.Business /// 扫码器2扫到条码的临时数据 /// public static TempInfo TempOffLineInfo2 = new TempInfo(); - // 河南工厂编码 - private static string Werks = "1301"; + #endregion #region 接口引用 private AppConfig appConfig = AppConfig.Instance; private static readonly log4net.ILog log = LogManager.GetLogger(typeof(OffLineBusiness)); + private readonly IExceptionRecordServices? exceptionRecordServices = App.ServiceProvider.GetService(); private readonly IBaseOrderInfoServices _baseOrderInfoServices = App.ServiceProvider.GetService(); private readonly IPrintBarCodeServices? _printBarCodeServices = App.ServiceProvider.GetService(); @@ -115,7 +115,7 @@ namespace Aucma.Core.ProductOffLine.Business GunBusiness.RefreshMaterialCodeStrEvent += MaterialBarScan; HandSendPlcWindow.SendPlcPassEvent += DownLoadPassFlag; - // test(); + // test(); } #region 变量定义 /// @@ -129,15 +129,7 @@ namespace Aucma.Core.ProductOffLine.Business { #region 成品条码与69码校验 - //BaseMaterialInfo materialInfo = _baseMaterialInfoServices.FirstAsync(x => x.ProductCode == "6933973114570").Result; - //if (materialInfo == null) - //{ - // Console.WriteLine(); - //} - //if (!"BCD-212CFT".Contains(materialInfo.ProductName)) - //{ - // Console.WriteLine(); - //} + MaterialBarScan("15147X0CD0099E3W03410","12344", "10.10.92.141"); #endregion } @@ -168,7 +160,7 @@ namespace Aucma.Core.ProductOffLine.Business if (ScannerNo == 1) //内侧 { //1.扫描的SN条码去条码系统校验 - BackResult = HandleMaterialBarCode(code, code69, TempOffLineInfo1); //扫码器1 + BackResult = HandleMaterialBarCode(code, code69, TempOffLineInfo1,out CodeBindingRecord bindingRecord1); //扫码器1 materialType = TempOffLineInfo1.ProductCode; if (!BackResult) { @@ -178,7 +170,7 @@ namespace Aucma.Core.ProductOffLine.Business } // TempOffLineInfo1.ProductRefreshFlag = true; // 2.更新mes数据库 - bool MesResult = updateMesData(TempOffLineInfo1); + bool MesResult = updateMesData(TempOffLineInfo1, bindingRecord1); // 3.plc放行 if (MesResult) @@ -224,7 +216,7 @@ namespace Aucma.Core.ProductOffLine.Business // 扫码器2 else if (ScannerNo == 2) // 外侧 { - BackResult = HandleMaterialBarCode(code, code69, TempOffLineInfo2); //扫码器2 + BackResult = HandleMaterialBarCode(code, code69, TempOffLineInfo2, out CodeBindingRecord bindingRecord1); //扫码器2 materialType = TempOffLineInfo2.ProductCode; if (!BackResult) { @@ -233,7 +225,7 @@ namespace Aucma.Core.ProductOffLine.Business } // TempOffLineInfo2.ProductRefreshFlag = true; // 2.更新mes数据库 - bool MesResult = updateMesData(TempOffLineInfo2); + bool MesResult = updateMesData(TempOffLineInfo2, bindingRecord1); //BackResult = true; // 3.plc放行 @@ -285,6 +277,30 @@ namespace Aucma.Core.ProductOffLine.Business } } + + /// + /// 往mes数据库添加异常记录 + /// + /// + /// + public async void AddExceptionRecord(string SNCode,string Msg) + { + try + { + ExceptionRecord record = new ExceptionRecord(); + record.ProductSnCode = SNCode; + record.ProductScanTime = DateTime.Now; + record.ProductLineCode = appConfig.ProductlineCode; + record.ExceptionMsg = Msg; + await exceptionRecordServices.AddAsync(record); + } + catch (Exception ex) + { + log.Info("添加异常记录方法AddExceptionRecord异常:" + ex.Message.ToString()); + } + } + + /// /// 下发plc放行并等待反馈信号 /// @@ -307,30 +323,20 @@ namespace Aucma.Core.ProductOffLine.Business /// /// /// - public bool updateMesData(TempInfo TempOffLineInfo) + public bool updateMesData(TempInfo TempOffLineInfo,CodeBindingRecord bindingRecord1) { try { OffLineInfo info11 = MapperTwo(TempOffLineInfo); - - CodeBindingRecord bindingRecord1 = _codeBindingServices.FirstAsync(x => x.ProductCode == info11.ProductSNCode).Result; - - if (bindingRecord1 == null) - { - log.Info(info11.ProductCode + "mes数据库未查询到条码绑定记录"); - // 条码绑定上位机运行以后打开 - //return false; - - } - else - { + + // log.Info("条码绑定表查到记录:"+JsonHelper.ObjectToJson(bindingRecord1)); - info11.BoxCode = bindingRecord1.BoxCode; - } + info11.BoxCode = bindingRecord1.BoxCode; + // 产线 - info11.ProductLineCode = "CX_02"; + info11.ProductLineCode = appConfig.ProductlineCode.ToString(); info11.SaveRetuenInfo = TempOffLineInfo.MsgInfo; info11.LoginTeam = appConfig.LoginTeam; info11.PlcResult = 1; @@ -347,6 +353,7 @@ namespace Aucma.Core.ProductOffLine.Business TempOffLineInfo.MsgAlarmFlag = true; //界面刷新 RefreshScanMateriaCodeEvent(TempOffLineInfo); + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo); return false; } @@ -361,6 +368,7 @@ namespace Aucma.Core.ProductOffLine.Business log.Info("条码:" + TempOffLineInfo.ProductBarNo + " 订单号:" + TempOffLineInfo.ProductOrderNo + " 查询mes订单失败"); TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "查询mes订单失败"; TempOffLineInfo.MsgAlarmFlag = true; + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.ProductSNCode+TempOffLineInfo.MsgInfo); //界面刷新 RefreshScanMateriaCodeEvent(TempOffLineInfo); return false; @@ -378,6 +386,7 @@ namespace Aucma.Core.ProductOffLine.Business log.Info("条码:" + TempOffLineInfo.ProductBarNo + " 订单号:" + TempOffLineInfo.ProductOrderNo + " 更新mes订单完成数失败"); TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + "更新mes订单完成数失败"; TempOffLineInfo.MsgAlarmFlag = true; + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.ProductSNCode+ "更新mes订单完成数失败"); //界面刷新 RefreshScanMateriaCodeEvent(TempOffLineInfo); return false; @@ -396,7 +405,7 @@ namespace Aucma.Core.ProductOffLine.Business completion.MaterialName = print.MaterialName; completion.StationName = "1009"; completion.CompleteDate = DateTime.Now; - completion.ProductLineCode = "CX_02"; + completion.ProductLineCode = appConfig.ProductlineCode; completion.isDownLine = 1; completion.ProductionCode = TempOffLineInfo.ProductSNCode; _ = _iMaterialCompletionServices.AddAsync(completion).Result; @@ -426,29 +435,42 @@ namespace Aucma.Core.ProductOffLine.Business /// 69码 /// /// - public bool HandleMaterialBarCode(string BarCode, string code69, TempInfo TempOffLineInfo) + public bool HandleMaterialBarCode(string BarCode, string code69, TempInfo TempOffLineInfo,out CodeBindingRecord bindingRecord1) { try { - #region 1.质检--暂未启用 - // List qualityList = _reportQualityInspectionServices.JudgeIsQualified(BarCode); - // if (qualityList != null) - //{ - // TempOffLineInfo.QualityResult = "失败"; - // TempOffLineInfo.ProductSNCode = BarCode.Trim(); //产品SN条码*1 - // TempOffLineInfo.ProductScanTime = System.DateTime.Now; // 扫码时间*2 - // TempOffLineInfo.MsgInfo = "条码质检失败:"; - - // foreach(ReportQualityInsPection item in qualityList) - // { - // TempOffLineInfo.MsgInfo += item.QualityDefectName; - // } - // TempOffLineInfo.MsgAlarmFlag = true; - // //界面刷新 - // // TempOffLineInfo.ProductRefreshFlag = true; - // RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); - // return false; - //} + + bindingRecord1 = _codeBindingServices.FirstAsync(x => x.ProductCode == BarCode).Result; + + if (bindingRecord1 == null) + { + TempOffLineInfo.MsgInfo = BarCode + ":条码绑定工位未查询到条码绑定记录,请拆掉包装重新绑定"; + TempOffLineInfo.MsgAlarmFlag = true; + //界面刷新 + // TempOffLineInfo.ProductRefreshFlag = true; + RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); + log.Info(TempOffLineInfo.ProductSNCode + "条码绑定工位未查询到条码绑定记录,请拆掉包装重新绑定"); + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo); + return false; + + } + + #region 1.质检-未查到终检合格记录即为质检不合格 + ReportQualityInsPection qualityList = _reportQualityInspectionServices.JudgeIsQualified(bindingRecord1.BoxCode); + if (qualityList == null) + { + TempOffLineInfo.QualityResult = "失败"; + TempOffLineInfo.ProductSNCode = BarCode.Trim(); //产品SN条码*1 + TempOffLineInfo.ProductScanTime = System.DateTime.Now; // 扫码时间*2 + TempOffLineInfo.MsgInfo = TempOffLineInfo.ProductSNCode+":条码终检失败或未终检,请回到终检工位重新检查!"; + + TempOffLineInfo.MsgAlarmFlag = true; + //界面刷新 + // TempOffLineInfo.ProductRefreshFlag = true; + RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo); + return false; + } #endregion @@ -508,7 +530,7 @@ namespace Aucma.Core.ProductOffLine.Business { TempOffLineInfo.MsgInfo = "69码校验失败:" + code69+"未维护69码信息!"; TempOffLineInfo.MsgAlarmFlag = true; - + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.ProductSNCode+TempOffLineInfo.MsgInfo); RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); log.Info("69码校验失败:" + code69 + "未维护69码信息!"); return false; // 因为没有录69码校验失败暂不处理,允许下线,等69码录全就禁止下线 @@ -522,6 +544,7 @@ namespace Aucma.Core.ProductOffLine.Business RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); log.Info("69码校验失败,69码:"+code69+";69码名称:" + materialInfo.ProductName + ";成品码名称:" + TempOffLineInfo.ProductName); + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.ProductSNCode+TempOffLineInfo.MsgInfo); return false; } else @@ -550,7 +573,7 @@ namespace Aucma.Core.ProductOffLine.Business else { log.Info(BarCode + "失败返回验证信息:" + FArrayList[1]); - + #region 实体赋值 TempOffLineInfo.MsgAlarmFlag = true; TempOffLineInfo.MsgInfo = "条码系统获取信息失败. " + BarCode + " 返回值:" + FArrayList[0].ToString(); @@ -578,6 +601,8 @@ namespace Aucma.Core.ProductOffLine.Business //界面刷新 // TempOffLineInfo.ProductRefreshFlag = true; RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); + + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo); return false; } @@ -590,6 +615,7 @@ namespace Aucma.Core.ProductOffLine.Business // TempOffLineInfo.ProductRefreshFlag = true; RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); log.Info(BarCode + "条码验证异常:" + ex.Message.ToString()); + bindingRecord1 = null; return false; } } @@ -624,6 +650,8 @@ namespace Aucma.Core.ProductOffLine.Business //界面刷新 // TempOffLineInfo.ProductRefreshFlag = true; RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); + + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo); return false; } @@ -654,6 +682,8 @@ namespace Aucma.Core.ProductOffLine.Business return CodeRepeatProcess(TempOffLineInfo); } + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo); + RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); return false; } @@ -663,6 +693,7 @@ namespace Aucma.Core.ProductOffLine.Business { TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",条码系统保存接口异常"; TempOffLineInfo.MsgAlarmFlag = true; + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo); //界面刷新 // TempOffLineInfo.ProductRefreshFlag = true; RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); @@ -673,6 +704,7 @@ namespace Aucma.Core.ProductOffLine.Business { TempOffLineInfo.MsgInfo = TempOffLineInfo.MsgInfo + ",生产单号异常"; TempOffLineInfo.MsgAlarmFlag = true; + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo); //界面刷新 // TempOffLineInfo.ProductRefreshFlag = true; RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); @@ -721,6 +753,8 @@ namespace Aucma.Core.ProductOffLine.Business TempOffLineInfo.MsgInfo = "条码重复,plc应答字2,禁止重复放行,上传时间:" + offLineInfo.ProductScanTime; + AddExceptionRecord(TempOffLineInfo.ProductSNCode, TempOffLineInfo.MsgInfo); + RefreshScanMateriaCodeEvent?.Invoke(TempOffLineInfo); return false; } diff --git a/Aucma.Core.ProductOffLine/Models/QualityInspectionModel.cs b/Aucma.Core.ProductOffLine/Models/ExceptionModel.cs similarity index 52% rename from Aucma.Core.ProductOffLine/Models/QualityInspectionModel.cs rename to Aucma.Core.ProductOffLine/Models/ExceptionModel.cs index b090d7cb..da95b54e 100644 --- a/Aucma.Core.ProductOffLine/Models/QualityInspectionModel.cs +++ b/Aucma.Core.ProductOffLine/Models/ExceptionModel.cs @@ -1,4 +1,5 @@ -using System; +using SqlSugar; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +7,7 @@ using System.Threading.Tasks; namespace Aucma.Core.ProductOffLine.Models { - public class QualityInspectionModel + public class ExceptionModel { /// /// 序号 @@ -17,17 +18,27 @@ namespace Aucma.Core.ProductOffLine.Models /// public int ObjId { get; set; } /// - /// 质检项编号 + /// 产品条码 /// - public string? QualityDefectCode { get; set; } + + public string? ProductSnCode { get; set; } /// - /// 质检项名称 + /// 异常信息 /// - public string? QualityDefectName { get; set; } + + public string ?ExceptionMsg { get; set; } + /// - /// 是否校验 + /// 扫描时间 /// - public string? IsInSpection { get; set; } - + + public DateTime? ProductScanTime { get; set; } + + /// + /// 产线编号 + /// + + public string? ProductLineCode { get; set; } + } } diff --git a/Aucma.Core.ProductOffLine/Startup.cs b/Aucma.Core.ProductOffLine/Startup.cs index 29719ee5..9d751814 100644 --- a/Aucma.Core.ProductOffLine/Startup.cs +++ b/Aucma.Core.ProductOffLine/Startup.cs @@ -6,6 +6,7 @@ using Admin.Core.IService.ISys; using Admin.Core.Model; using Admin.Core.Repository; using Admin.Core.Service; +using Admin.Core.Socket; using Admin.Core.Tasks; using Aucma.Core.RunPlc; using Aucma.Core.Scanner; @@ -14,6 +15,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using System.Net.Sockets; using System.Text; namespace Aucma.Core.ProductOffLine @@ -65,8 +67,12 @@ namespace Aucma.Core.ProductOffLine //ɨ services.AddScannerSetup(); + //socketɨ + // services.AddTouchSocketSetup(); + + // - // services.AddJobSetup(); + // services.AddJobSetup(); //PLC services.AddPlcSetup(); @@ -91,19 +97,23 @@ namespace Aucma.Core.ProductOffLine /// /// /// - public void Configure(IApplicationBuilder app, IScannerService scannerService, IRunPlcService runPlcService)//, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter + public void Configure(IApplicationBuilder app, IScannerService scannerService, IRunPlcService runPlcService)//, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter,ITouchSocketService socket { // ʹþ̬ļ app.UseStaticFiles(); // ȻȨм //app.UseAuthorization(); - + // QuartzNetJobȷ - // app.UseQuartzJobMildd(tasksQzService, schedulerCenter); + // app.UseQuartzJobMildd(tasksQzService, schedulerCenter); //ɨ app.UseScannerMildd(scannerService); //PLC app.UsePlcMildd(runPlcService); + + // Socketɨ + // app.UseTouchSocketMildd(socket); + } #region ע diff --git a/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs index 93d7af96..4d974124 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/DirectionEditViewModel.cs @@ -26,6 +26,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices; public DirectionEditViewModel() { + DirectionItemViewModel.RefreshPageEvent += ExecuteQuery; _baseMaterialInfoServices = App.ServiceProvider.GetService(); QueryCommand = new RelayCommand(ExecuteQuery); MouseClickCommand = new RelayCommand(MouseClick); @@ -40,7 +41,6 @@ namespace Aucma.Core.ProductOffLine.ViewModels ExecuteQuery(); } - private async void ExecuteQuery() { try diff --git a/Aucma.Core.ProductOffLine/ViewModels/DirectionItemViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/DirectionItemViewModel.cs index 3f6878b7..fd300f5a 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/DirectionItemViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/DirectionItemViewModel.cs @@ -25,7 +25,10 @@ namespace Aucma.Core.ProductOffLine.ViewModels public RelayCommand SaveCommand { get; set; } - + public delegate void RefreshPage(); + public static event RefreshPage? RefreshPageEvent; + + private readonly IBaseMaterialInfoServices? _baseMaterialInfoServices; public DirectionItemViewModel(DirectionEditModel info) { _baseMaterialInfoServices = App.ServiceProvider.GetService(); @@ -107,19 +110,29 @@ namespace Aucma.Core.ProductOffLine.ViewModels } private async void updateDirection() { - BaseMaterialInfo info = await _baseMaterialInfoServices.FirstAsync(x=>x.ObjId==PlanInfo.ObjId); - if (IsSelectedOptionA) - { - info.InboundDirection = "A"; - } - else + try { - info.InboundDirection = "B"; + BaseMaterialInfo info = await _baseMaterialInfoServices.FirstAsync(x => x.ObjId == PlanInfo.ObjId); + if (IsSelectedOptionA) + { + info.InboundDirection = "A"; + } + else + { + info.InboundDirection = "B"; + } + bool result = await _baseMaterialInfoServices.UpdateAsync(info); + if (result) + { + MessageBox.Show(info.MaterialName + "入库方向修改成功"); + } + + //刷新页面 + RefreshPageEvent?.Invoke(); } - bool result = await _baseMaterialInfoServices.UpdateAsync(info); - if (result) + catch (Exception ex) { - MessageBox.Show(info.MaterialName+"入库方向修改成功"); + Console.WriteLine("updateDirection异常:" + ex.Message.ToString()); } } diff --git a/Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs index 631a8748..db8400df 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/QualityItemViewModel.cs @@ -27,24 +27,24 @@ namespace Aucma.Core.ProductOffLine.ViewModels private readonly IBaseQualityInspectionItemInfoServices? _baseQualityInspectionItemInfoServices; - public QualityItemViewModel(QualityInspectionModel info) { + public QualityItemViewModel(ExceptionModel info) { _baseQualityInspectionItemInfoServices = App.ServiceProvider.GetService(); CloseWindowCommand = new RelayCommand(t => CloseWindow(t)); SaveCommand = new RelayCommand(updateDirection); PlanInfo = info; - if("是".Equals(info.IsInSpection)){ - IsSelectedOptionA = true; - } - else - { - IsSelectedOptionB = true; - } + //if("是".Equals(info.IsInSpection)){ + // IsSelectedOptionA = true; + //} + //else + //{ + // IsSelectedOptionB = true; + //} } - private QualityInspectionModel planInfo = new QualityInspectionModel(); - public QualityInspectionModel PlanInfo + private ExceptionModel planInfo = new ExceptionModel(); + public ExceptionModel PlanInfo { get { return planInfo; } set { diff --git a/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs b/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs index cd533e07..c7d77bae 100644 --- a/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs +++ b/Aucma.Core.ProductOffLine/ViewModels/SelectQualityViewModel.cs @@ -31,11 +31,11 @@ namespace Aucma.Core.ProductOffLine.ViewModels public ICommand QueryCommand { get; set; } public RelayCommand MouseClickCommand { get; set; } - private readonly IBaseQualityInspectionItemInfoServices? _baseQualityInspectionItemInfoServices; + private readonly IExceptionRecordServices? exceptionRecordServices; public SelectQualityViewModel() { - _baseQualityInspectionItemInfoServices = App.ServiceProvider.GetService(); + exceptionRecordServices = App.ServiceProvider.GetService(); QueryCommand = new RelayCommand(ExecuteQuery); MouseClickCommand = new RelayCommand(MouseClick); @@ -48,6 +48,8 @@ namespace Aucma.Core.ProductOffLine.ViewModels /// public async void Init() { + + Count = 0; ExecuteQuery(); } @@ -55,12 +57,35 @@ namespace Aucma.Core.ProductOffLine.ViewModels { try { - List list = await _baseQualityInspectionItemInfoServices.query(); - qualityItemGrid.Clear(); - for (int i = 0; i < list.Count; i++) - { - qualityItemGrid.Add(new QualityInspectionModel() { No = i + 1, ObjId = list[i].ObjId, QualityDefectCode = list[i].QualityDefectCode, QualityDefectName = list[i].QualityDefectName, IsInSpection = list[i].IsInSpection == "0" ? "否" : "是" }); + List list = await exceptionRecordServices.QueryAsync(x=>x.ProductScanTime>=DateTime.Today); + if (list == null || list.Count == 0) { + App.Current.Dispatcher.Invoke(() => + { + exceptionItemGrid.Clear(); + Count = 0; + }); + return; } + + list = list.OrderByDescending(x=>x.ProductScanTime).ToList(); + App.Current.Dispatcher.Invoke(() => + { + exceptionItemGrid.Clear(); + Count = list.Count; + for (int i = 0; i < list.Count; i++) + { + ExceptionModel model = new ExceptionModel(); + model.No = exceptionItemGrid.Count+1; + model.ObjId = list[i].ObjId; + model.ProductSnCode = list[i].ProductSnCode; + model.ExceptionMsg = list[i].ExceptionMsg; + model.ProductScanTime = list[i].ProductScanTime; + model.ProductLineCode = list[i].ProductLineCode; + exceptionItemGrid.Add(model); + + } + }); + } catch (Exception) { @@ -70,7 +95,7 @@ namespace Aucma.Core.ProductOffLine.ViewModels public void MouseClick(object obj) { - var info = SelectedDataItem as QualityInspectionModel; + var info = SelectedDataItem as ExceptionModel; if (info != null) { QualityWindow quantityIssuedWindow = new QualityWindow(info); @@ -81,8 +106,8 @@ namespace Aucma.Core.ProductOffLine.ViewModels - private QualityInspectionModel selectedDataItem; - public QualityInspectionModel SelectedDataItem + private ExceptionModel selectedDataItem; + public ExceptionModel SelectedDataItem { get { return selectedDataItem; } set @@ -92,16 +117,27 @@ namespace Aucma.Core.ProductOffLine.ViewModels } } - + private int count; + public int Count + { + get { return count; } + set + { + count = value; + OnPropertyChanged(); + } + } + + #region 初始化datagrid - private ObservableCollection qualityItemGrid = new ObservableCollection(); - public ObservableCollection QualityItemGrid + private ObservableCollection exceptionItemGrid = new ObservableCollection(); + public ObservableCollection ExceptionItemGrid { - get { return qualityItemGrid; } + get { return exceptionItemGrid; } set { - qualityItemGrid = value; + exceptionItemGrid = value; OnPropertyChanged();//属性通知 } } diff --git a/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml b/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml index b6c554c0..a5dbd0ce 100644 --- a/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml +++ b/Aucma.Core.ProductOffLine/Views/ChooseDirectionWindow.xaml @@ -17,8 +17,8 @@