diff --git a/MaterialTraceability.Business/EquipBusiness.cs b/MaterialTraceability.Business/EquipBusiness.cs index d082e7d..96bad7c 100644 --- a/MaterialTraceability.Business/EquipBusiness.cs +++ b/MaterialTraceability.Business/EquipBusiness.cs @@ -717,7 +717,14 @@ namespace MaterialTraceability.Business //DbHandler db = new DbHandler(); int machineId = appConfig.machineId; Expression> expression = s1 => true; - expression = expression.And(x => x.machineId == machineId); + if (appConfig.machineId == 1) + { + expression = expression.And(x => x.machineId == machineId && x.equipName.Contains("收卷")); + } + else + { + expression = expression.And(x => x.machineId == machineId); + } _equipList = await equipServices.Query(expression); foreach (var equip in _equipList) diff --git a/MaterialTraceability.Business/Impl/MQSignalReadBusiness.cs b/MaterialTraceability.Business/Impl/MQSignalReadBusiness.cs index 2fa4c17..9b70fb9 100644 --- a/MaterialTraceability.Business/Impl/MQSignalReadBusiness.cs +++ b/MaterialTraceability.Business/Impl/MQSignalReadBusiness.cs @@ -364,10 +364,10 @@ namespace MaterialTraceability.Business.Impl #endregion try { - LogRefreshEvent?.Invoke(LogType.PlcLog, "模切" + logStr + "位放卷结束信号触发成功"); - LogRefreshEvent?.Invoke(LogType.RfidLog, "模切" + logStr + "位放卷结束信号触发成功"); + LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + "位放卷结束信号触发成功"); + LogRefreshEvent?.Invoke(LogType.RfidLog, logStr + "位放卷结束信号触发成功"); //upLoadBusiness.SaveLogRecord(position, logStr + "位放卷结束信号触发成功"); - LogHelper.Info("模切" + logStr + "位结束信号触发成功"); + LogHelper.Info(logStr + "位结束信号触发成功"); ProShaftInfo shaftInfo = await this.GetShaftInfoByPosition(position); if (shaftInfo == null) { @@ -431,7 +431,7 @@ namespace MaterialTraceability.Business.Impl #endregion try { - LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + "轴涨紧触发成功"); + LogRefreshEvent?.Invoke(LogType.PlcLog, logStr + "轴涨紧信号触发成功"); LogRefreshEvent?.Invoke(LogType.RfidLog, String.Format("开始读取{0}轴卷筒RFID物料信息", logStr)); //读取卷筒RFID物料信息 @@ -458,7 +458,7 @@ namespace MaterialTraceability.Business.Impl epc = epc.Replace("\0", "").Trim(); - if (StringExtension.IsBlank(epc) || epc.Length != 14 || !epc.Contains("JSLY") || !epc.Contains("CATT")) + if (StringExtension.IsBlank(epc) || epc.Length != 14 && !epc.Contains("JSLY") && !epc.Contains("CATT")) { LogHelper.Info(String.Format("{0}轴设备:{1};读取失败", logStr, proEquip.equipIp)); AngrilyResultSendToPlc(position, 2, 0);//收卷位报警 @@ -728,7 +728,7 @@ namespace MaterialTraceability.Business.Impl if (await spiltPreventDaze(position, shaftInfo)) { writeError(position, 2); - LogRefreshEvent?.Invoke(LogType.AlarmLog, string.Format("{0}拆分异常,不允许直接拆分下收卷轴", logStr)); + LogRefreshEvent?.Invoke(LogType.AlarmLog, string.Format("{0}拆分异常,不允许直接拆分下收卷轴,先拆分上轴再执行下轴拆分", logStr)); LogRefreshEvent?.Invoke(LogType.RfidLog, string.Format("{0}拆分异常,不允许直接拆分下收卷轴,先拆分上轴再执行下轴拆分", logStr)); } else @@ -940,7 +940,7 @@ namespace MaterialTraceability.Business.Impl #endregion #region MES入账开始接口 - LogRefreshEvent?.Invoke(LogType.MesLog, logStr + "MES入账开始接口"); + LogRefreshEvent?.Invoke(LogType.MesLog, logStr + "c"); if (!SFCBegin(shaftInfo)) { writeError(position, 2); @@ -1393,8 +1393,8 @@ namespace MaterialTraceability.Business.Impl if (shaftInfo == null) { - LogRefreshEvent?.Invoke(LogType.RfidLog, "绑定卷轴与物料信息,获取卷轴信息为空"); - LogRefreshEvent?.Invoke(LogType.AlarmLog, "绑定卷轴与物料信息,获取卷轴信息为空"); + LogRefreshEvent?.Invoke(LogType.RfidLog, "绑定卷轴与RFID,获取卷轴信息为空"); + LogRefreshEvent?.Invoke(LogType.AlarmLog, "绑定卷轴与RFID,获取卷轴信息为空"); LogHelper.Info("绑定卷轴与物料信息,获取卷轴信息为空"); return; } diff --git a/MaterialTraceability.Business/Impl/TBSignalReadBusiness.cs b/MaterialTraceability.Business/Impl/TBSignalReadBusiness.cs index 1cadda0..7e017dd 100644 --- a/MaterialTraceability.Business/Impl/TBSignalReadBusiness.cs +++ b/MaterialTraceability.Business/Impl/TBSignalReadBusiness.cs @@ -26,6 +26,8 @@ namespace MaterialTraceability.Business.Impl { // INIFile配置文件 private INIFile inifile = new INIFile(System.Environment.CurrentDirectory + "/MesConfig/App.InI"); + private INIFile appinifile = new INIFile(System.Environment.CurrentDirectory + "/App.InI"); + /// /// 日志刷新 /// @@ -102,7 +104,7 @@ namespace MaterialTraceability.Business.Impl private UpLoadBusiness upLoadBusiness = UpLoadBusiness.Instance; private AppConfigDto appConfig = AppConfigDto.Instance; - + string ran = ""; /// /// 放卷位涨紧 /// @@ -206,13 +208,17 @@ namespace MaterialTraceability.Business.Impl string epc = equipBusiness.ReadEPCByAntana(proEquip.equipId); //string epc = System.Guid.NewGuid().ToString("N").Substring(0,14); epc = epc.Replace("\0", "").Trim(); - //if (epc == "" || epc == null) - //{ - // Random random = new Random(); + if (epc == "" || epc == null) + { + //Random random = new Random(); + if (!string.IsNullOrEmpty(appinifile.IniReadValue("SystemConfig", "RFIDnum"))) + { + ran = appinifile.IniReadValue("SystemConfig", "RFIDnum"); + ran = ran.PadLeft(6, '0'); + epc = "CATT1RDA" + ran; + } + } - // epc = "JSLY3RDC005400"; - //} - //20231028新增读取到上一次相同标签报警泄气 bool iFlag = await GetSameRFIDInfo(position, epc); if (iFlag) @@ -249,7 +255,7 @@ namespace MaterialTraceability.Business.Impl }); return; } - if (StringExtension.IsBlank(epc) || !epc.Contains("JSLY") || !epc.Contains("CATT")) + if (StringExtension.IsBlank(epc) || (!epc.Contains("JSLY") && !epc.Contains("CATT") && !epc.Contains("YBC"))) { //读取失败,控制PLC气胀轴 @@ -376,7 +382,7 @@ namespace MaterialTraceability.Business.Impl //site = "2100", url = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"), site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"), - processlotref = String.Format("ProcessLotBO:2100,{0}", rfidStr), + processlotref = String.Format("ProcessLotBO:2400,{0}", rfidStr), loginUser = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "loginUser"), password = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "password"), }; @@ -418,8 +424,8 @@ namespace MaterialTraceability.Business.Impl { url = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "url"), site = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "site"), - processlotref = "ProcessLotBO:2100," + rfidStr, - memberlist = new string[] { "SFCBO:2100," + sfcStr }, + processlotref = "ProcessLotBO:2400," + rfidStr, + memberlist = new string[] { "SFCBO:2400," + sfcStr }, loginUser = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "loginUser"), password = inifile.IniReadValue("ProcessLotServiceWSServiceParam", "password"), @@ -501,14 +507,14 @@ namespace MaterialTraceability.Business.Impl return; } - if (sfc.Substring(0, 1) != "L") - { - sfc = GetSFC(position); - if (StringExtension.IsBlank(sfc)) - { - return; - } - } + //if (sfc.Substring(0, 1) != "L") + //{ + // sfc = GetSFC(position); + // if (StringExtension.IsBlank(sfc)) + // { + // return; + // } + //} #endregion LogHelper.Info("涂布工单下达接口调用成功,SFC膜卷号为:" + sfc); @@ -516,6 +522,10 @@ namespace MaterialTraceability.Business.Impl GetSFCByMesEvent?.Invoke(true, sfc); WriteSfcAndEpc(position, sfc, epc); + if (!string.IsNullOrEmpty(appinifile.IniReadValue("SystemConfig", "RFIDnum"))) + { + appinifile.IniWriteValue("SystemConfig", "RFIDnum", int.Parse(appinifile.IniReadValue("SystemConfig", "RFIDnum") + 1).ToString()); + } ViewModelRefreshEvent?.Invoke(new ViewModelDto() { @@ -569,7 +579,8 @@ namespace MaterialTraceability.Business.Impl RecordTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; await downRecordServices.Add(downRecord); - + + //upLoadBusiness.SaveDownRecord(downRecord); } catch (Exception e) @@ -706,7 +717,7 @@ namespace MaterialTraceability.Business.Impl { url = inifile.IniReadValue("FindShopRequestParam","url"), site = inifile.IniReadValue("FindShopRequestParam", "site"), - shopOrder = String.Format("ShopOrderBO:2100,{0}", shopOrderStr), + shopOrder = String.Format("ShopOrderBO:2400,{0}", shopOrderStr), loginUser = inifile.IniReadValue("FindShopRequestParam", "loginUser"), password = inifile.IniReadValue("FindShopRequestParam", "password"), }; diff --git a/MaterialTraceability.Business/LanguageHelper.cs b/MaterialTraceability.Business/LanguageHelper.cs new file mode 100644 index 0000000..914241d --- /dev/null +++ b/MaterialTraceability.Business/LanguageHelper.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace MaterialTraceability.Business +{ + public class LanguageHelper + { + public static string language { get; set; } + public static string ShowMessage(string Message) + { + string Result = Message; + switch (language) + { + + case "de-DE": + if (Message == "PLC连接失败") + { + Result = "PLC Connect Fail"; + } + if (Message == "PLC断开,重新建立连接") + { + Result = "PLC Connect Fail,Reconnect..."; + } + break; + case "en-US": + if (Message == "PLC连接失败") + { + Result = "PLC Connect Fail"; + } + if (Message == "PLC断开,重新建立连接") + { + Result = "PLC Connect Fail,Reconnect..."; + } + if (Message == "PLC断开,重新连接失败") + { + Result = "PLC Connect Fail,Reconnect Fail"; + } + break; + case "pl-PL": + + break; + case "zh-cn": + + break; + default: + break; + } + return Result; + } + } + +} diff --git a/MaterialTraceability.Business/MainBusiness.cs b/MaterialTraceability.Business/MainBusiness.cs index 656e0f9..5847957 100644 --- a/MaterialTraceability.Business/MainBusiness.cs +++ b/MaterialTraceability.Business/MainBusiness.cs @@ -8,6 +8,9 @@ using MaterialTraceability.SqlSugar; using MaterialTraceability.SqlSugar.ServiceImpl; using System; using System.Collections.Generic; +using System.Globalization; +using System.Threading; +using static System.Net.Mime.MediaTypeNames; namespace MaterialTraceability.Business { @@ -157,7 +160,15 @@ namespace MaterialTraceability.Business } if (plcBusiness.Connect()) { - LogRefreshEvent?.Invoke(LogType.PlcLog, "PLC连接成功"); + if(LanguageHelper.language == "en-us") + { + LogRefreshEvent?.Invoke(LogType.PlcLog, "PLC Connect Success"); + } + else + { + LogRefreshEvent?.Invoke(LogType.PlcLog, "PLC连接成功"); + } + viewModel.plcStatus = true; switch (appConfig.processId) @@ -197,6 +208,7 @@ namespace MaterialTraceability.Business { LogRefreshEvent?.Invoke(LogType.PlcLog, "PLC连接失败"); LogRefreshEvent?.Invoke(LogType.AlarmLog, "PLC连接失败"); + viewModel.plcStatus = false; } ViewModelRefreshEvent?.Invoke(viewModel); @@ -300,12 +312,14 @@ namespace MaterialTraceability.Business if (!info) { + //LanguageHelper.ShowMessage("cs"); LogRefreshEvent?.Invoke(LogType.PlcLog,"PLC断开,重新建立连接"); LogHelper.Info("PLC断开,重新建立连接"); bool result = plcBusiness.ReConnect(); if (result) { + string ss = LanguageHelper.language; LogRefreshEvent?.Invoke(LogType.PlcLog, "PLC断开,重新连接成功"); LogHelper.Info("PLC断开,重新连接成功"); diff --git a/MaterialTraceability.Business/MaterialTraceability.Business.csproj b/MaterialTraceability.Business/MaterialTraceability.Business.csproj index 470ee49..f3144f0 100644 --- a/MaterialTraceability.Business/MaterialTraceability.Business.csproj +++ b/MaterialTraceability.Business/MaterialTraceability.Business.csproj @@ -61,6 +61,7 @@ + diff --git a/MaterialTraceability.Business/PlcBusiness.cs b/MaterialTraceability.Business/PlcBusiness.cs index 119c2d1..33185b9 100644 --- a/MaterialTraceability.Business/PlcBusiness.cs +++ b/MaterialTraceability.Business/PlcBusiness.cs @@ -118,6 +118,7 @@ namespace MaterialTraceability.Business else { LogHelper.Info("PLC初始化成功"); + #region 读取时间初始化 var initTime = DateTime.Now.AddMinutes(-1); lastReadTime_A_Begin = initTime; diff --git a/MaterialTraceability.Business/UpLoadBusiness.cs b/MaterialTraceability.Business/UpLoadBusiness.cs index 20dee94..d9911aa 100644 --- a/MaterialTraceability.Business/UpLoadBusiness.cs +++ b/MaterialTraceability.Business/UpLoadBusiness.cs @@ -510,13 +510,13 @@ namespace MaterialTraceability.Business { try { - LogRecord logRecord = new LogRecord() - { - resource = appConfig.resource, - positionId = position, - message = msg - }; - int result = _db.Insertable(logRecord).ExecuteCommand(); + //LogRecord logRecord = new LogRecord() + //{ + // resource = appConfig.resource, + // positionId = position, + // message = msg + //}; + //int result = _db.Insertable(logRecord).ExecuteCommand(); } catch (Exception ex) { @@ -561,6 +561,7 @@ namespace MaterialTraceability.Business { try { + return "MES接口错误码:"+code + "," + message; AlarmInfo alarmInfo = new AlarmInfo(); DataTable info = _db.Queryable().Where(x => x.alarmCode == code.ToString()).ToDataTable(); if (info.Rows.Count > 0) diff --git a/MaterialTraceability.Common/LanguageHelper.cs b/MaterialTraceability.Common/LanguageHelper.cs new file mode 100644 index 0000000..2d558f6 --- /dev/null +++ b/MaterialTraceability.Common/LanguageHelper.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MaterialTraceability.Common +{ + public class LanguageHelper + { + public string language { get; set; } + } +} diff --git a/MaterialTraceability.Common/MaterialTraceability.Common.csproj b/MaterialTraceability.Common/MaterialTraceability.Common.csproj index a165cb5..573e1bc 100644 --- a/MaterialTraceability.Common/MaterialTraceability.Common.csproj +++ b/MaterialTraceability.Common/MaterialTraceability.Common.csproj @@ -44,10 +44,12 @@ ..\dll\NPOI.dll + + @@ -61,6 +63,7 @@ + diff --git a/MaterialTraceability.Entity/DAO/ApiResponse.cs b/MaterialTraceability.Entity/DAO/ApiResponse.cs new file mode 100644 index 0000000..ec9cc0d --- /dev/null +++ b/MaterialTraceability.Entity/DAO/ApiResponse.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MaterialTraceability.Entity.DAO +{ + public class ApiResponse + { + /// + /// 状态码(如 200 成功,400 失败,500 错误) + /// + public int Code { get; set; } + + /// + /// 消息(如 "操作成功"、"参数错误") + /// + public string Msg { get; set; } + + /// + /// 返回数据 + /// + public List Data { get; set; } + + public ParameterList parameterList { get; set; } + } + + public class ParameterList + { + private string Parameter; + private string Value; + } +} diff --git a/MaterialTraceability.Entity/DAO/SysUserInfo.cs b/MaterialTraceability.Entity/DAO/SysUserInfo.cs index 7e35197..b348bd0 100644 --- a/MaterialTraceability.Entity/DAO/SysUserInfo.cs +++ b/MaterialTraceability.Entity/DAO/SysUserInfo.cs @@ -19,31 +19,31 @@ namespace MaterialTraceability.Entity.DAO /// /// /// - [SugarColumn(ColumnName="userId" )] - public string userId { get; set; } + [SugarColumn(ColumnName= "CardID")] + public int CardID { get; set; } /// /// /// - [SugarColumn(ColumnName="userName" )] - public string userName { get; set; } + [SugarColumn(ColumnName= "JobID")] + public int JobID { get; set; } /// /// /// - [SugarColumn(ColumnName="userPwd" )] - public string userPwd { get; set; } + [SugarColumn(ColumnName= "Name")] + public string Name { get; set; } /// /// /// - [SugarColumn(ColumnName="roleId" )] - public string roleId { get; set; } + [SugarColumn(ColumnName= "Level")] + public string Level { get; set; } /// /// /// - [SugarColumn(ColumnName = "pwdKey")] - public string pwdKey { get; set; } + [SugarColumn(ColumnName = "PWD")] + public string PWD { get; set; } } } diff --git a/MaterialTraceability.Entity/DTO/AppConfigDto.cs b/MaterialTraceability.Entity/DTO/AppConfigDto.cs index 4af437b..f8755ea 100644 --- a/MaterialTraceability.Entity/DTO/AppConfigDto.cs +++ b/MaterialTraceability.Entity/DTO/AppConfigDto.cs @@ -54,6 +54,8 @@ namespace MaterialTraceability.Entity.DTO public int isSpiltPreventDaze = StringChange.ParseToInt(iNIFile.IniReadValue("SystemConfig", "isSpiltPreventDaze")); + + public TbAddress TbAddress = TbAddress.Instance; public LyAddress LyAddress = LyAddress.Instance; diff --git a/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj b/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj index 7428180..2200e7a 100644 --- a/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj +++ b/MaterialTraceability.Entity/MaterialTraceability.Entity.csproj @@ -49,6 +49,7 @@ + diff --git a/MaterialTraceability.Plc/MaterialTraceability.Plc.csproj b/MaterialTraceability.Plc/MaterialTraceability.Plc.csproj index ec93074..c890299 100644 --- a/MaterialTraceability.Plc/MaterialTraceability.Plc.csproj +++ b/MaterialTraceability.Plc/MaterialTraceability.Plc.csproj @@ -35,10 +35,6 @@ False ..\dll\HslCommunication.dll - - False - ..\dll\Newtonsoft.Json.dll - diff --git a/MaterialTraceability.SqlSugar/IBaseServices.cs b/MaterialTraceability.SqlSugar/IBaseServices.cs index 2ed622c..b408bf7 100644 --- a/MaterialTraceability.SqlSugar/IBaseServices.cs +++ b/MaterialTraceability.SqlSugar/IBaseServices.cs @@ -199,6 +199,6 @@ namespace MaterialTraceability.SqlSugar /// sql语句 /// Task> QueryBySql(string sql, List parameters) where T : class, new(); - + Task TruncateTable(); } } diff --git a/MaterialTraceability.SqlSugar/ServiceImpl/BaseServices.cs b/MaterialTraceability.SqlSugar/ServiceImpl/BaseServices.cs index 55c9ae8..4cd8768 100644 --- a/MaterialTraceability.SqlSugar/ServiceImpl/BaseServices.cs +++ b/MaterialTraceability.SqlSugar/ServiceImpl/BaseServices.cs @@ -744,5 +744,11 @@ namespace MaterialTraceability.SqlSugar.ServiceImpl { return await _db.Ado.SqlQueryAsync(sql, parameters); } + public async Task TruncateTable() + { + //var i = await Task.Run(() => _db.Deleteable().In(ids).ExecuteCommand()); + //return i > 0; + return _db.DbMaintenance.TruncateTable(); + } } } \ No newline at end of file diff --git a/MaterialTraceability.SqlSugar/ServiceImpl/BaseServices_Server.cs b/MaterialTraceability.SqlSugar/ServiceImpl/BaseServices_Server.cs index 6cc1df9..61b46d1 100644 --- a/MaterialTraceability.SqlSugar/ServiceImpl/BaseServices_Server.cs +++ b/MaterialTraceability.SqlSugar/ServiceImpl/BaseServices_Server.cs @@ -744,5 +744,10 @@ namespace MaterialTraceability.SqlSugar.ServiceImpl { return await _db.Ado.SqlQueryAsync(sql, parameters); } + + public Task TruncateTable() + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/MaterialTraceabilityUI/App.config b/MaterialTraceabilityUI/App.config index 3290c7f..b9bc6aa 100644 --- a/MaterialTraceabilityUI/App.config +++ b/MaterialTraceabilityUI/App.config @@ -7,9 +7,9 @@ - + - + @@ -56,12 +56,20 @@ - + + + + + + + + + diff --git a/MaterialTraceabilityUI/DieCuttingProcess.xaml.cs b/MaterialTraceabilityUI/DieCuttingProcess.xaml.cs index 9471356..1ed0c73 100644 --- a/MaterialTraceabilityUI/DieCuttingProcess.xaml.cs +++ b/MaterialTraceabilityUI/DieCuttingProcess.xaml.cs @@ -1379,8 +1379,8 @@ namespace MaterialTraceabilityUI else { MessageBox.Show("下右收卷强制下料触发"); - ListBoxItemAdd(this.PlcLog, "下右收卷强制下料触发成功,MW24830写入0"); - LogHelperBusiness.LogInfo("下右收卷强制下料触发成功,MW24830写入0"); + ListBoxItemAdd(this.PlcLog, "下右收卷强制下料触发成功"); + LogHelperBusiness.LogInfo("下右收卷强制下料触发成功"); plcBusiness.writePlc(appConfig.mqAddress.下右收卷下料, 0); int position = 0; diff --git a/MaterialTraceabilityUI/MainWindow.xaml b/MaterialTraceabilityUI/MainWindow.xaml index 3d6751b..718323f 100644 --- a/MaterialTraceabilityUI/MainWindow.xaml +++ b/MaterialTraceabilityUI/MainWindow.xaml @@ -51,8 +51,11 @@ + + + diff --git a/MaterialTraceabilityUI/MainWindow.xaml.cs b/MaterialTraceabilityUI/MainWindow.xaml.cs index 0460701..1492d23 100644 --- a/MaterialTraceabilityUI/MainWindow.xaml.cs +++ b/MaterialTraceabilityUI/MainWindow.xaml.cs @@ -2,11 +2,13 @@ using MaterialTraceability.Business; using MaterialTraceability.Entity.DAO; using MaterialTraceability.Entity.DTO; +using MaterialTraceability.Entity.Enum; using MaterialTraceability.Entity.UpLoad; using MaterialTraceability.SqlSugar; using MaterialTraceability.SqlSugar.ServiceImpl; using MaterialTraceabilityUI.Common; using MaterialTraceabilityUI.Resources; +using MaterialTraceabilityUI.ViewModel; using SqlSugar; using System; using System.Collections.Generic; @@ -44,6 +46,8 @@ namespace MaterialTraceabilityUI //卷绕界面 private JRProcess JRProcess = new JRProcess(); + private UserInfo UserInfo = new UserInfo(); + //记录报表 private secondPage secondPage = new secondPage(); @@ -168,6 +172,8 @@ namespace MaterialTraceabilityUI { try { + GlobalClass.ChangeLanguage("zh-cn"); + LanguageHelper.language = "zh-cn"; notifyIcon.Visible = true; notifyIcon.Text = "RFID物料追溯系统"; notifyIcon.Icon = new Icon("amn06-tnywh-001.ico"); @@ -229,7 +235,15 @@ namespace MaterialTraceabilityUI { action = () => { - this.TestTB.Text = "PLC连接成功"; + if (LanguageHelper.language == "en-us") + { + this.TestTB.Text = "PLC Connect Success"; + } + else + { + this.TestTB.Text = "PLC连接成功"; + } + this.TestTB.Foreground = System.Windows.Media.Brushes.SpringGreen; }; TestTB.Dispatcher.BeginInvoke(action); @@ -256,7 +270,15 @@ namespace MaterialTraceabilityUI action = () => { - this.TestTB.Text = "PLC连接失败"; + if (LanguageHelper.language == "en-us") + { + this.TestTB.Text = "PLC Connect Fail"; + } + else + { + this.TestTB.Text = "PLC连接失败"; + } + this.TestTB.Foreground = System.Windows.Media.Brushes.Red; }; TestTB.Dispatcher.BeginInvoke(action); @@ -443,16 +465,38 @@ namespace MaterialTraceabilityUI { //LanguageManager.Instance.ChangeLanguage(new CultureInfo("zh-cn")); GlobalClass.ChangeLanguage("zh-cn"); + LanguageHelper.language = "zh-cn"; } private void ChangeLanguage2_Click(object sender, RoutedEventArgs e) { //LanguageManager.Instance.ChangeLanguage(new CultureInfo("en-us")); - GlobalClass.ChangeLanguage("en-us"); + GlobalClass.ChangeLanguage("en-US"); + LanguageHelper.language = "en-US"; + } private void ChangeLanguage3_Click(object sender, RoutedEventArgs e) { //LanguageManager.Instance.ChangeLanguage(new CultureInfo("pl")); - GlobalClass.ChangeLanguage("pl"); + GlobalClass.ChangeLanguage("pl-PL"); + LanguageHelper.language = "pl-PL"; + } + private void ChangeLanguage4_Click(object sender, RoutedEventArgs e) + { + //LanguageManager.Instance.ChangeLanguage(new CultureInfo("pl")); + GlobalClass.ChangeLanguage("de-DE"); + LanguageHelper.language = "de-DE"; + } + + private void UserInfoPage_Click(object sender, RoutedEventArgs e) + { + if (!"2".Equals(ConfigHelper.GetConfig("roleId"))) + { + System.Windows.MessageBox.Show("请登录系统管理账号进行操作"); + } + else + { + UserContent = UserInfo; + } } } } diff --git a/MaterialTraceabilityUI/MaterialTraceabilityUI.csproj b/MaterialTraceabilityUI/MaterialTraceabilityUI.csproj index 818eacc..33dcf8e 100644 --- a/MaterialTraceabilityUI/MaterialTraceabilityUI.csproj +++ b/MaterialTraceabilityUI/MaterialTraceabilityUI.csproj @@ -88,14 +88,16 @@ ..\dll\Nancy.dll - False - ..\dll\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll False ..\dll\SqlSugar.dll + + ..\packages\System.Buffers.4.5.1\lib\netstandard1.1\System.Buffers.dll + @@ -109,7 +111,20 @@ ..\dll\System.Data.SQLite.Linq.dll + + ..\packages\System.Memory.4.5.5\lib\netstandard1.1\System.Memory.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll + + @@ -121,6 +136,21 @@ 4.0 + + ..\packages\TouchSocket.3.1.19\lib\net45\TouchSocket.dll + + + ..\packages\TouchSocket.Core.3.1.19\lib\net45\TouchSocket.Core.dll + + + ..\packages\TouchSocket.Http.3.1.19\lib\net45\TouchSocket.Http.dll + + + ..\packages\TouchSocket.Rpc.3.1.19\lib\net45\TouchSocket.Rpc.dll + + + ..\packages\TouchSocket.WebApi.3.1.19\lib\net45\TouchSocket.WebApi.dll + @@ -160,6 +190,9 @@ SplitSfc.xaml + + UserInfo.xaml + UserLogin.xaml @@ -172,6 +205,7 @@ firstPage.xaml + WriteInfo.xaml @@ -224,6 +258,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -301,14 +339,16 @@ ResXFileCodeGenerator Resources.Designer.cs + - + + SettingsSingleFileGenerator Settings.Designer.cs @@ -373,5 +413,10 @@ false + + + + + \ No newline at end of file diff --git a/MaterialTraceabilityUI/ReadRecordControl.xaml b/MaterialTraceabilityUI/ReadRecordControl.xaml index b820f1b..21a9fac 100644 --- a/MaterialTraceabilityUI/ReadRecordControl.xaml +++ b/MaterialTraceabilityUI/ReadRecordControl.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="clr-namespace:MaterialTraceabilityUI" + xmlns:local="clr-namespace:MaterialTraceabilityUI.Resources" mc:Ignorable="d" d:DesignHeight="452" d:DesignWidth="640" Background="Transparent" Loaded="UserControl_Loaded"> @@ -107,7 +107,7 @@ - + diff --git a/MaterialTraceabilityUI/Resources/2025_09_18.snapshot b/MaterialTraceabilityUI/Resources/2025_09_18.snapshot new file mode 100644 index 0000000..e3c428c --- /dev/null +++ b/MaterialTraceabilityUI/Resources/2025_09_18.snapshot @@ -0,0 +1 @@ +[{"ProjectName":"MaterialTraceabilityUI","UniqueName":"Properties\\Resources","Entries":[]},{"ProjectName":"MaterialTraceabilityUI","UniqueName":"Resources\\Lang","Entries":[{"Key":"btnChina","Data":[{"L":".en-US","T":"Chinese"},{"L":".pl","T":"Chińczycy"},{"L":".zh-CN","T":"中文"}]},{"Key":"btnEnglish","Data":[{"L":".en-US","T":"English"},{"L":".pl","T":"yw"},{"L":".zh-CN","T":"英文"}]},{"Key":"btnBl","Data":[{"L":".en-US","T":"bolan"},{"L":".pl","T":"pl"},{"L":".zh-CN","T":"波兰"}]},{"Key":"btnJLBB","Data":[{"L":".en-US","T":"Report"},{"L":".pl","T":"jlbb"},{"L":".zh-CN","T":"记录报表"}]},{"Key":"btnCSPZ","Data":[{"L":".en-US","T":"Config"},{"L":".pl","T":"cspz"},{"L":".zh-CN","T":"参数配置"}]},{"Key":"btnDL","Data":[{"L":".en-US","T":"Login in"},{"L":".pl","T":"dl"},{"L":".zh-CN","T":"登录"}]},{"Key":"btnZX","Data":[{"L":".en-US","T":"Login out"},{"L":".pl","T":"zx"},{"L":".zh-CN","T":"注销"}]},{"Key":"btnSY","Data":[{"L":".en-US","T":"Fistpage"},{"L":".pl","T":"sy"},{"L":".zh-CN","T":"首页"}]},{"Key":"lbtext","Data":[{"L":".en-US","T":"RFID MaterialTraceability System"},{"L":".pl","T":"RFID"},{"L":".zh-CN","T":"RFID物料追溯系统"}]},{"Key":"lbPLCStatus","Data":[{"L":".en-US","T":"PLC Offline"},{"L":".pl","T":"PLC"},{"L":".zh-CN","T":"PLC状态异常"}]},{"Key":"lbLoginStatus","Data":[{"L":".en-US","T":"NLI"},{"L":".pl","T":"nli"},{"L":".zh-CN","T":"未登录"}]},{"Key":"MQDevice","Data":[{"L":".en-US","T":"MQ DeviceStatus"},{"L":".pl","T":"mqds"},{"L":".zh-CN","T":"设备状态"}]}]}] \ No newline at end of file diff --git a/MaterialTraceabilityUI/Resources/2025_09_18_15_03.xlsx b/MaterialTraceabilityUI/Resources/2025_09_18_15_03.xlsx new file mode 100644 index 0000000..f3b40da Binary files /dev/null and b/MaterialTraceabilityUI/Resources/2025_09_18_15_03.xlsx differ diff --git a/MaterialTraceabilityUI/Resources/GlobalClass.cs b/MaterialTraceabilityUI/Resources/GlobalClass.cs index 01b137c..c7f3e4c 100644 --- a/MaterialTraceabilityUI/Resources/GlobalClass.cs +++ b/MaterialTraceabilityUI/Resources/GlobalClass.cs @@ -69,11 +69,29 @@ namespace MaterialTraceabilityUI.Resources Thread.CurrentThread.CurrentUICulture = culture; StringResource.CurrentCulture = culture; - + // 如果是WPF应用,需要更新应用级别的文化 + if (Application.Current != null) + { + Application.Current.MainWindow?.UpdateLayout(); + // 重新加载资源字典(如果有语言资源文件) + //UpdateResourceDictionary(cultureName); + } if (LanguageChangeEvent != null) { LanguageChangeEvent(null, null); } } + + // 检查当前是否为中文 + public static bool IsChinese() + { + return Thread.CurrentThread.CurrentUICulture.Name.StartsWith("zh"); + } + + // 检查当前是否为英文 + public static bool IsEnglish() + { + return Thread.CurrentThread.CurrentUICulture.Name.StartsWith("en"); + } } } diff --git a/MaterialTraceabilityUI/Resources/Lang.de-DE.resx b/MaterialTraceabilityUI/Resources/Lang.de-DE.resx new file mode 100644 index 0000000..299ddda --- /dev/null +++ b/MaterialTraceabilityUI/Resources/Lang.de-DE.resx @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 1 + + + 2 + + + 3 + + + 4 + + + 5 + + + 6 + + + 8 + + + 7 + + + 0 + + + 0 + + + 9 + + + 0 + + + 0 + + + 0 + + + 用户信息 + + \ No newline at end of file diff --git a/MaterialTraceabilityUI/Resources/Lang.en-US.resx b/MaterialTraceabilityUI/Resources/Lang.en-US.resx index 563d0fd..152da92 100644 --- a/MaterialTraceabilityUI/Resources/Lang.en-US.resx +++ b/MaterialTraceabilityUI/Resources/Lang.en-US.resx @@ -117,17 +117,11 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Chinese - - - English - bolan - - Report + + 中文 Config @@ -135,6 +129,12 @@ Login in + + English + + + Report + Login out @@ -153,4 +153,13 @@ MQ DeviceStatus + + ID + + + Device Name + + + 用户信息 + \ No newline at end of file diff --git a/MaterialTraceabilityUI/Resources/Lang.pl.resx b/MaterialTraceabilityUI/Resources/Lang.pl-PL.resx similarity index 95% rename from MaterialTraceabilityUI/Resources/Lang.pl.resx rename to MaterialTraceabilityUI/Resources/Lang.pl-PL.resx index b258ac0..9cfde75 100644 --- a/MaterialTraceabilityUI/Resources/Lang.pl.resx +++ b/MaterialTraceabilityUI/Resources/Lang.pl-PL.resx @@ -117,17 +117,11 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - zw - - - yw - - bl + pl - - jlbb + + Chińczycy cspz @@ -135,6 +129,12 @@ dl + + yw + + + jlbb + zx @@ -153,4 +153,13 @@ mqds + + id + + + Device Name + + + 用户信息 + \ No newline at end of file diff --git a/MaterialTraceabilityUI/Resources/Lang.zh-cn.resx b/MaterialTraceabilityUI/Resources/Lang.zh-cn.resx index 769f5cf..cd7cfc4 100644 --- a/MaterialTraceabilityUI/Resources/Lang.zh-cn.resx +++ b/MaterialTraceabilityUI/Resources/Lang.zh-cn.resx @@ -117,17 +117,11 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 中文 - - - 英文 - 波兰 - - 记录报表 + + 中文 参数配置 @@ -135,6 +129,12 @@ 登录 + + English + + + 记录报表 + 注销 @@ -153,4 +153,13 @@ 设备状态 + + 编号 + + + 设备名称 + + + 用户信息 + \ No newline at end of file diff --git a/MaterialTraceabilityUI/Resources/翻译.xlsx b/MaterialTraceabilityUI/Resources/翻译.xlsx new file mode 100644 index 0000000..d6a47df Binary files /dev/null and b/MaterialTraceabilityUI/Resources/翻译.xlsx differ diff --git a/MaterialTraceabilityUI/ShaftInfoControl.xaml b/MaterialTraceabilityUI/ShaftInfoControl.xaml index 7c9757c..54f4bc3 100644 --- a/MaterialTraceabilityUI/ShaftInfoControl.xaml +++ b/MaterialTraceabilityUI/ShaftInfoControl.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="clr-namespace:MaterialTraceabilityUI" + xmlns:local="clr-namespace:MaterialTraceabilityUI.Resources" mc:Ignorable="d" d:DesignHeight="452" d:DesignWidth="640" Background="Transparent" Loaded="UserControl_Loaded"> @@ -99,8 +99,8 @@ - - + + diff --git a/MaterialTraceabilityUI/TJJProcess.xaml.cs b/MaterialTraceabilityUI/TJJProcess.xaml.cs index 7cb19b7..8058291 100644 --- a/MaterialTraceabilityUI/TJJProcess.xaml.cs +++ b/MaterialTraceabilityUI/TJJProcess.xaml.cs @@ -325,7 +325,7 @@ namespace MaterialTraceabilityUI string info = massage; string logTypeStr = ""; int isAlarm = 0; - + massage = LanguageHelper.ShowMessage(massage); if (logType == LogType.MesLog) { logTypeStr = "MES"; diff --git a/MaterialTraceabilityUI/UserInfo.xaml b/MaterialTraceabilityUI/UserInfo.xaml new file mode 100644 index 0000000..508d7a7 --- /dev/null +++ b/MaterialTraceabilityUI/UserInfo.xaml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + +